diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2019-03-21 13:27:03 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2019-03-22 08:06:39 +0100 |
commit | 36eaf9ef8be056151a6a83dc63eaecf154e90a99 (patch) | |
tree | fb857c710bb1e3c7db5a0177a789f89e62eb7061 | |
parent | d3f21588d3d1402bee42d5374ed060a7e26b7b91 (diff) |
Nested list L must be a child of parent's LBodyfeature/cib_contract139
Implement this as
https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G13.2259746
describes. The example implementation in Annex H8.2
https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G21.1021285
where nested L is a sibling of its parent LI contradicts the
specification and is prolly wrong
Change-Id: I2bd4a6692ac0cbe02ff6f1746656f104de3fe1f2
-rw-r--r-- | drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx | 78 | ||||
-rw-r--r-- | drawinglayer/source/processor2d/vclmetafileprocessor2d.hxx | 6 |
2 files changed, 69 insertions, 15 deletions
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index c2259341781c..036b8d14e8ea 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -555,6 +555,35 @@ namespace drawinglayer } } + void VclMetafileProcessor2D::popListItem() + { + if (!maListElements.empty()) + { + if (maListElements.top() == vcl::PDFWriter::LIBody) + { + maListElements.pop(); + mpPDFExtOutDevData->EndStructureElement(); + } + if (maListElements.top() == vcl::PDFWriter::ListItem) + { + maListElements.pop(); + mpPDFExtOutDevData->EndStructureElement(); + } + } + } + + void VclMetafileProcessor2D::popList() + { + if (!maListElements.empty()) + { + if (maListElements.top() == vcl::PDFWriter::List) + { + maListElements.pop(); + mpPDFExtOutDevData->EndStructureElement(); + } + } + } + // init static break iterator uno::Reference< css::i18n::XBreakIterator > VclMetafileProcessor2D::mxBreakIterator; @@ -1233,7 +1262,10 @@ namespace drawinglayer // this is a part of list item, start LILabel ( = bullet) if(mbInListItem) + { + maListElements.push(vcl::PDFWriter::LILabel); mpPDFExtOutDevData->BeginStructureElement(vcl::PDFWriter::LILabel); + } // process recursively and add MetaFile comment process(rBulletPrimitive); @@ -1241,8 +1273,12 @@ namespace drawinglayer if(mbInListItem) { - mpPDFExtOutDevData->EndStructureElement(); // end LILabel - mbBulletPresent = true; + if (maListElements.top() == vcl::PDFWriter::LILabel) + { + maListElements.pop(); + mpPDFExtOutDevData->EndStructureElement(); // end LILabel + mbBulletPresent = true; + } } } @@ -1286,29 +1322,41 @@ namespace drawinglayer if(nNewOutlineLevel > mnCurrentOutlineLevel) { // increase List level - for(sal_Int16 a(mnCurrentOutlineLevel); a != nNewOutlineLevel; a++) + for(sal_Int16 a(mnCurrentOutlineLevel); a != nNewOutlineLevel; ++a) { + maListElements.push(vcl::PDFWriter::List); mpPDFExtOutDevData->BeginStructureElement( vcl::PDFWriter::List ); } } else // if(nNewOutlineLevel < mnCurrentOutlineLevel) { - // decrease List level - for(sal_Int16 a(mnCurrentOutlineLevel); a != nNewOutlineLevel; a--) + // close list levels below nNewOutlineLevel completely by removing + // list items as well as list tag itself + for(sal_Int16 a(nNewOutlineLevel); a < mnCurrentOutlineLevel; ++a) { - mpPDFExtOutDevData->EndStructureElement(); + popListItem(); // end LBody and LI + popList(); // end L } - } + + // on nNewOutlineLevel close the previous list item + popListItem(); + } // Remember new current OutlineLevel mnCurrentOutlineLevel = nNewOutlineLevel; } + else // the same list level + { + // close the previous list item + popListItem(); + } const bool bDumpAsListItem(-1 != mnCurrentOutlineLevel); if(bDumpAsListItem) { // Dump as ListItem + maListElements.push(vcl::PDFWriter::ListItem); mpPDFExtOutDevData->BeginStructureElement( vcl::PDFWriter::ListItem ); mbInListItem = true; } @@ -1323,10 +1371,7 @@ namespace drawinglayer mpMetaFile->AddAction(new MetaCommentAction(aCommentString)); if(bDumpAsListItem) - { - mpPDFExtOutDevData->EndStructureElement(); // end ListItem mbInListItem = false; - } else mpPDFExtOutDevData->EndStructureElement(); // end Paragraph } @@ -1343,8 +1388,11 @@ namespace drawinglayer if (mnCurrentOutlineLevel >= 0 ) { // end any opened List structure elements - for(sal_Int16 i(0); i <= mnCurrentOutlineLevel; ++i) - mpPDFExtOutDevData->EndStructureElement(); + for(sal_Int16 a(0); a <= mnCurrentOutlineLevel; ++a) + { + popListItem(); + popList(); + } } mpMetaFile->AddAction(new MetaCommentAction(aCommentStringB)); @@ -1359,16 +1407,16 @@ namespace drawinglayer // this is a 2nd portion of list item // bullet has been already processed, start LIBody if (mbInListItem && mbBulletPresent) + { + maListElements.push(vcl::PDFWriter::LIBody); mpPDFExtOutDevData->BeginStructureElement(vcl::PDFWriter::LIBody); + } // directdraw of text simple portion; use default processing RenderTextSimpleOrDecoratedPortionPrimitive2D(rTextCandidate); if (mbInListItem && mbBulletPresent) - { - mpPDFExtOutDevData->EndStructureElement(); // end LIBody mbBulletPresent = false; - } // restore DrawMode mpOutputDevice->SetDrawMode(nOriginalDrawMode); diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.hxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.hxx index 3b9f39f804a6..a5f9a7fd9597 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.hxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.hxx @@ -20,6 +20,8 @@ #ifndef INCLUDED_DRAWINGLAYER_SOURCE_PROCESSOR2D_VCLMETAFILEPROCESSOR2D_HXX #define INCLUDED_DRAWINGLAYER_SOURCE_PROCESSOR2D_VCLMETAFILEPROCESSOR2D_HXX +#include <stack> + #include <drawinglayer/drawinglayerdllapi.h> #include "vclprocessor2d.hxx" @@ -112,6 +114,8 @@ namespace drawinglayer const attribute::LineStartEndAttribute* pEnd); void impStartSvtGraphicStroke(SvtGraphicStroke const * pSvtGraphicStroke); void impEndSvtGraphicStroke(SvtGraphicStroke* pSvtGraphicStroke); + void popListItem(); + void popList(); void processGraphicPrimitive2D(const primitive2d::GraphicPrimitive2D& rGraphicPrimitive); void processControlPrimitive2D(const primitive2d::ControlPrimitive2D& rControlPrimitive); @@ -177,6 +181,8 @@ namespace drawinglayer bool mbInListItem; bool mbBulletPresent; + std::stack<vcl::PDFWriter::StructElement> maListElements; + protected: /* the local processor for BasePrimitive2D-Implementation based primitives, called from the common process()-implementation |