svx/source/sdr/contact/viewobjectcontact.cxx | 105 +++++++++++++++------------ 1 file changed, 60 insertions(+), 45 deletions(-)
New commits: commit 7b506aaafa7a982d19ec1cba2909f3ccfe29b130 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Nov 30 16:40:27 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Dec 7 19:49:51 2022 +0000 (related: tdf#135192) svx: PDF/UA export: tag background as Artifact ISO 14289-1:2014, Clause: 7.1, Test number: 3 Content shall be marked as Artifact or tagged as real content This needs to have an effect on ViewObjectContactOfSdrPage etc. but let's put it in ViewObjectContact and hope anything that's not SdrObject can be tagged as Artifact. Also VclMetafileProcessor2D::processStructureTagPrimitive2D() has a very peculiar habit of ignoring any obvious way to create an Artifact, which should perhaps be fixed? Change-Id: I8d22c36a8e31692d3ee24af692026e02b8faa70a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143502 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 81ef84648515965bf67afaced946227d0f63a71e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143540 Tested-by: Jenkins Reviewed-by: Armin Le Grand <armin.le.gr...@me.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/svx/source/sdr/contact/viewobjectcontact.cxx b/svx/source/sdr/contact/viewobjectcontact.cxx index ec1256140b4d..18acd5e52b83 100644 --- a/svx/source/sdr/contact/viewobjectcontact.cxx +++ b/svx/source/sdr/contact/viewobjectcontact.cxx @@ -385,59 +385,74 @@ drawinglayer::primitive2d::Primitive2DContainer const & ViewObjectContact::getPr // Check if we need to embed to a StructureTagPrimitive2D, too. This // was done at ImplRenderPaintProc::createRedirectedPrimitive2DSequence before - if(!xNewPrimitiveSequence.empty() && nullptr != pSdrObj && GetObjectContact().isExportTaggedPDF()) + if (!xNewPrimitiveSequence.empty() && GetObjectContact().isExportTaggedPDF()) { - vcl::PDFWriter::StructElement eElement(vcl::PDFWriter::NonStructElement); - const SdrInventor nInventor(pSdrObj->GetObjInventor()); - const SdrObjKind nIdentifier(pSdrObj->GetObjIdentifier()); - const bool bIsTextObj(nullptr != dynamic_cast<const SdrTextObj *>(pSdrObj)); - - // Note: SwFlyDrawObj/SwVirtFlyDrawObj have SdrInventor::Swg - these - // are *not* handled here because not all of them are painted - // completely with primitives, so a tag here does not encapsulate them. - // The tag must be created by SwTaggedPDFHelper until this is fixed. - if ( nInventor == SdrInventor::Default ) + if (nullptr != pSdrObj) { - if ( nIdentifier == SdrObjKind::Group ) - eElement = vcl::PDFWriter::Section; - else if (nIdentifier == SdrObjKind::Table) - eElement = vcl::PDFWriter::Table; - else if ( nIdentifier == SdrObjKind::TitleText ) - eElement = vcl::PDFWriter::Heading; - else if ( nIdentifier == SdrObjKind::OutlineText ) - eElement = vcl::PDFWriter::Division; - else if ( !bIsTextObj || !static_cast<const SdrTextObj&>(*pSdrObj).HasText() ) - eElement = vcl::PDFWriter::Figure; - else - eElement = vcl::PDFWriter::Division; - } - - if(vcl::PDFWriter::NonStructElement != eElement) - { - SdrPage* pSdrPage(pSdrObj->getSdrPageFromSdrObject()); + vcl::PDFWriter::StructElement eElement(vcl::PDFWriter::NonStructElement); + const SdrInventor nInventor(pSdrObj->GetObjInventor()); + const SdrObjKind nIdentifier(pSdrObj->GetObjIdentifier()); + const bool bIsTextObj(nullptr != dynamic_cast<const SdrTextObj *>(pSdrObj)); + + // Note: SwFlyDrawObj/SwVirtFlyDrawObj have SdrInventor::Swg - these + // are *not* handled here because not all of them are painted + // completely with primitives, so a tag here does not encapsulate them. + // The tag must be created by SwTaggedPDFHelper until this is fixed. + if ( nInventor == SdrInventor::Default ) + { + if ( nIdentifier == SdrObjKind::Group ) + eElement = vcl::PDFWriter::Section; + else if (nIdentifier == SdrObjKind::Table) + eElement = vcl::PDFWriter::Table; + else if ( nIdentifier == SdrObjKind::TitleText ) + eElement = vcl::PDFWriter::Heading; + else if ( nIdentifier == SdrObjKind::OutlineText ) + eElement = vcl::PDFWriter::Division; + else if ( !bIsTextObj || !static_cast<const SdrTextObj&>(*pSdrObj).HasText() ) + eElement = vcl::PDFWriter::Figure; + else + eElement = vcl::PDFWriter::Division; + } - if(pSdrPage) + if(vcl::PDFWriter::NonStructElement != eElement) { - const bool bBackground(pSdrPage->IsMasterPage()); - const bool bImage(SdrObjKind::Graphic == pSdrObj->GetObjIdentifier()); - // note: there must be output device here, in PDF export - sal_Int32 nAnchorId(-1); - if (auto const pUserCall = pSdrObj->GetUserCall()) + SdrPage* pSdrPage(pSdrObj->getSdrPageFromSdrObject()); + + if(pSdrPage) { - nAnchorId = pUserCall->GetPDFAnchorStructureElementId( - *pSdrObj, *GetObjectContact().TryToGetOutputDevice()); + const bool bBackground(pSdrPage->IsMasterPage()); + const bool bImage(SdrObjKind::Graphic == pSdrObj->GetObjIdentifier()); + // note: there must be output device here, in PDF export + sal_Int32 nAnchorId(-1); + if (auto const pUserCall = pSdrObj->GetUserCall()) + { + nAnchorId = pUserCall->GetPDFAnchorStructureElementId( + *pSdrObj, *GetObjectContact().TryToGetOutputDevice()); + } + + drawinglayer::primitive2d::Primitive2DReference xReference( + new drawinglayer::primitive2d::StructureTagPrimitive2D( + eElement, + bBackground, + bImage, + std::move(xNewPrimitiveSequence), + nAnchorId)); + xNewPrimitiveSequence = drawinglayer::primitive2d::Primitive2DContainer { xReference }; } - - drawinglayer::primitive2d::Primitive2DReference xReference( - new drawinglayer::primitive2d::StructureTagPrimitive2D( - eElement, - bBackground, - bImage, - std::move(xNewPrimitiveSequence), - nAnchorId)); - xNewPrimitiveSequence = drawinglayer::primitive2d::Primitive2DContainer { xReference }; } } + else + { + // page backgrounds etc should be tagged as artifacts: + xNewPrimitiveSequence = drawinglayer::primitive2d::Primitive2DContainer { + new drawinglayer::primitive2d::StructureTagPrimitive2D( + // lies to force silly VclMetafileProcessor2D to emit NonStructElement + vcl::PDFWriter::Division, + true, + true, + std::move(xNewPrimitiveSequence)) + }; + } } // Local up-to-date checks. New list different from local one?