[Libreoffice-commits] core.git: Branch 'feature/cib_contract139' - drawinglayer/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Mar 21 20:58:35 UTC 2019
drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx | 78 ++++++++++---
drawinglayer/source/processor2d/vclmetafileprocessor2d.hxx | 6 +
2 files changed, 69 insertions(+), 15 deletions(-)
New commits:
commit c1c641fdf500e22cae445f844309f943e21d87d8
Author: Katarina Behrens <Katarina.Behrens at cib.de>
AuthorDate: Thu Mar 21 13:27:03 2019 +0100
Commit: Katarina Behrens <Katarina.Behrens at cib.de>
CommitDate: Thu Mar 21 21:49:32 2019 +0100
Nested list L must be a child of parent's LBody
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
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
More information about the Libreoffice-commits
mailing list