Kaydet (Commit) 67adfc89 authored tarafından Katarina Behrens's avatar Katarina Behrens

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
Reviewed-on: https://gerrit.libreoffice.org/69506
Tested-by: Jenkins
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst a80317b6
......@@ -554,6 +554,27 @@ namespace drawinglayer
}
}
void VclMetafileProcessor2D::popStructureElement(vcl::PDFWriter::StructElement eElem)
{
if (!maListElements.empty() && maListElements.top() == eElem)
{
maListElements.pop();
mpPDFExtOutDevData->EndStructureElement();
}
}
void VclMetafileProcessor2D::popListItem()
{
popStructureElement(vcl::PDFWriter::LIBody);
popStructureElement(vcl::PDFWriter::ListItem);
}
void VclMetafileProcessor2D::popList()
{
popListItem();
popStructureElement(vcl::PDFWriter::List);
}
// init static break iterator
uno::Reference< css::i18n::XBreakIterator > VclMetafileProcessor2D::mxBreakIterator;
......@@ -1232,7 +1253,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);
......@@ -1240,8 +1264,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;
}
}
}
......@@ -1285,29 +1313,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();
popList(); // end LBody LI and L
}
}
// on nNewOutlineLevel close the previous list item (LBody and LI)
popListItem();
}
// Remember new current OutlineLevel
mnCurrentOutlineLevel = nNewOutlineLevel;
}
else // the same list level
{
// close the previous list item (LBody and LI)
popListItem();
}
const bool bDumpAsListItem(-1 != mnCurrentOutlineLevel);
if(bDumpAsListItem)
{
// Dump as ListItem
maListElements.push(vcl::PDFWriter::ListItem);
mpPDFExtOutDevData->BeginStructureElement( vcl::PDFWriter::ListItem );
mbInListItem = true;
}
......@@ -1322,10 +1362,7 @@ namespace drawinglayer
mpMetaFile->AddAction(new MetaCommentAction(aCommentString));
if(bDumpAsListItem)
{
mpPDFExtOutDevData->EndStructureElement(); // end ListItem
mbInListItem = false;
}
else
mpPDFExtOutDevData->EndStructureElement(); // end Paragraph
}
......@@ -1341,9 +1378,11 @@ namespace drawinglayer
if (mnCurrentOutlineLevel >= 0 )
{
// end any opened List structure elements
for(sal_Int16 i(0); i <= mnCurrentOutlineLevel; ++i)
mpPDFExtOutDevData->EndStructureElement();
// end any opened List structure elements (LBody, LI, L)
for(sal_Int16 a(0); a <= mnCurrentOutlineLevel; ++a)
{
popList();
}
}
mpMetaFile->AddAction(new MetaCommentAction(aCommentStringB));
......@@ -1358,16 +1397,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);
......
......@@ -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,9 @@ namespace drawinglayer
const attribute::LineStartEndAttribute* pEnd);
void impStartSvtGraphicStroke(SvtGraphicStroke const * pSvtGraphicStroke);
void impEndSvtGraphicStroke(SvtGraphicStroke const * pSvtGraphicStroke);
void popStructureElement(vcl::PDFWriter::StructElement eElem);
void popListItem();
void popList();
void processGraphicPrimitive2D(const primitive2d::GraphicPrimitive2D& rGraphicPrimitive);
void processControlPrimitive2D(const primitive2d::ControlPrimitive2D& rControlPrimitive);
......@@ -177,6 +182,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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment