[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sw/source vcl/qa
sw/source/core/text/EnhancedPDFExportHelper.cxx| 32 ++- vcl/qa/cppunit/pdfexport/data/Description PDF Export test .odt |binary vcl/qa/cppunit/pdfexport/pdfexport.cxx | 102 ++ 3 files changed, 131 insertions(+), 3 deletions(-) New commits: commit 0d59eebe858d0d3e5d2260691f245940757deacd Author: Michael Stahl AuthorDate: Thu Nov 24 13:17:56 2022 +0100 Commit: Caolán McNamara CommitDate: Sat Dec 3 21:02:13 2022 + tdf#57423 sw: PDF/UA export: Alt texts for SwNoTextNode * Specification: ISO 14289-1:2014, Clause: 7.3, Test number: 1 Figure tags shall include an alternative representation or replacement text that represents the contents marked with the Figure tag as noted in ISO 32000-1:2008, 14.7.2, Table 323 This was broken by the previous commit, which tied ObjectInfoPrimitive2D evaluation to StructureTagPrimitive2D, and is restored now, perhaps less elegantly. * Specification: ISO 14289-1:2014, Clause: 7.7, Test number: 1 All mathematical expressions shall be enclosed within a Formula tag as detailed in ISO 32000-1:2008, 14.8.4.5 and shall have Alt or ActualText attributes Haven't checked but it's possible that this worked before commit 2840352ba56a212d191cc16e08378c87672d7b73 - for SwOLENode embedded objects, no ObjectInfoPrimitive2D is created apparently. Change-Id: Ia0077199601f39f666012d31883f63cff115716f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143247 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit 122b4264d23df8b11419839ba700b88c4f936a6c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143292 Reviewed-by: Caolán McNamara diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 6afa8648947c..9f0b028258f4 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -526,6 +526,7 @@ void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType ) bool bHeight = false; bool bBox = false; bool bRowSpan = false; +bool bAltText = false; // Check which attributes to set: @@ -586,11 +587,20 @@ void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType ) case vcl::PDFWriter::Formula : case vcl::PDFWriter::Figure : +bAltText = bPlacement = bWidth = bHeight = bBox = true; break; + +case vcl::PDFWriter::Division: +if (pFrame->IsFlyFrame()) // this can be something else too +{ +bAltText = true; +} +break; + default : break; } @@ -676,9 +686,25 @@ void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType ) } } -// Formerly here bAlternateText was triggered for PDF export, but this -// was moved for more general use to primitives and usage in -// VclMetafileProcessor2D (see processGraphicPrimitive2D). +// ISO 14289-1:2014, Clause: 7.3 +// ISO 14289-1:2014, Clause: 7.7 +// For images (but not embedded objects), an ObjectInfoPrimitive2D is +// created, but it's not evaluated by VclMetafileProcessor2D any more; +// that would require producing StructureTagPrimitive2D here but that +// looks impossible so instead duplicate the code that sets the Alt +// text here again. +if (bAltText) +{ +SwFlyFrameFormat const& rFly(*static_cast(pFrame)->GetFormat()); +OUString const sep( +(rFly.GetObjTitle().isEmpty() || rFly.GetObjDescription().isEmpty()) +? OUString() : OUString(" - ")); +OUString const altText(rFly.GetObjTitle() + sep + rFly.GetObjDescription()); +if (!altText.isEmpty()) +{ +mpPDFExtOutDevData->SetAlternateText(altText); +} +} if ( bWidth ) { diff --git a/vcl/qa/cppunit/pdfexport/data/Description PDF Export test .odt b/vcl/qa/cppunit/pdfexport/data/Description PDF Export test .odt new file mode 100644 index ..78f05b09e9e9 Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/Description PDF Export test .odt differ diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 6b0f90a0581f..461bb937f81d 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -3241,6 +3241,108 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf135638) CPPUNIT_ASSERT_EQUAL(int(2), nFigure); } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf57423) +{ +
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sw/source vcl/qa
sw/source/core/layout/paintfrm.cxx | 15 ++-- sw/source/core/text/EnhancedPDFExportHelper.cxx |8 +- vcl/qa/cppunit/pdfexport/data/tdf139736-1.odt |binary vcl/qa/cppunit/pdfexport/pdfexport.cxx | 86 4 files changed, 101 insertions(+), 8 deletions(-) New commits: commit f91da6e6063e0494559a015a0ec6ea38fcb30baa Author: Michael Stahl AuthorDate: Wed Oct 19 16:38:02 2022 +0200 Commit: Caolán McNamara CommitDate: Mon Oct 24 21:03:50 2022 +0200 tdf#139736 sw: PDF/UA export: flys in header/footer are Artifacts * flys anchored in header/footer cannot simply be ignored, they need to get NonStructElement tag which is translated to "/Artifact" * borders of flys need to get "/Artifact" tag as well; this is also the case if they're anchored in the body as veraPDF complains Change-Id: Id69f0d80c59c3ade295da46c4413a5f0e8d96d54 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141534 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit 72b69b422d33308809070e98a6ea8daad93e16d2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141734 Reviewed-by: Caolán McNamara diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index d470b1ae030f..7cae991210d7 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -4287,12 +4287,15 @@ void SwFlyFrame::PaintSwFrame(vcl::RenderContext& rRenderContext, SwRect const& Validate(); -// first paint lines added by fly frame paint -// and then unlock other lines. -gProp.pSLines->PaintLines( , gProp ); -gProp.pSLines->LockLines( false ); -// have to paint frame borders added in heaven layer here... -ProcessPrimitives(gProp.pBLines->GetBorderLines_Clear()); +{ +SwTaggedPDFHelper tag(nullptr, nullptr, nullptr, *pShell->GetOut()); +// first paint lines added by fly frame paint +// and then unlock other lines. +gProp.pSLines->PaintLines( , gProp ); +gProp.pSLines->LockLines( false ); +// have to paint frame borders added in heaven layer here... +ProcessPrimitives(gProp.pBLines->GetBorderLines_Clear()); +} PaintDecorators(); diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 30c1db446868..ccec950bb954 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -969,7 +969,7 @@ void SwTaggedPDFHelper::BeginBlockStructureElements() // Lowers of NonStructureElements should not be considered: -if ( lcl_IsInNonStructEnv( *pFrame ) ) +if (lcl_IsInNonStructEnv(*pFrame) && !pFrame->IsFlyFrame()) return; // Check if we have to reopen an existing structure element. @@ -1258,7 +1258,11 @@ void SwTaggedPDFHelper::BeginBlockStructureElements() // fly in content or fly at page { const SwFlyFrame* pFly = static_cast(pFrame); -if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() ) +if (pFly->GetAnchorFrame()->FindFooterOrHeader() != nullptr) +{ +nPDFType = vcl::PDFWriter::NonStructElement; +} +else if (pFly->Lower() && pFly->Lower()->IsNoTextFrame()) { bool bFormula = false; diff --git a/vcl/qa/cppunit/pdfexport/data/tdf139736-1.odt b/vcl/qa/cppunit/pdfexport/data/tdf139736-1.odt new file mode 100644 index ..f17f6037885c Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf139736-1.odt differ diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index fb821ae4..51d5e93b9529 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -2987,6 +2987,92 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testPdfUaMetadata) CPPUNIT_ASSERT_EQUAL(OString("1"), aPdfUaPart); } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf139736) +{ +aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export"); + +// Enable PDF/UA +uno::Sequence aFilterData( +comphelper::InitPropertySequence({ { "PDFUACompliance", uno::Any(true) } })); +aMediaDescriptor["FilterData"] <<= aFilterData; +saveAsPDF(u"tdf139736-1.odt"); + +vcl::filter::PDFDocument aDocument; +SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ); +CPPUNIT_ASSERT(aDocument.Read(aStream)); + +std::vector aPages = aDocument.GetPages(); +CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size()); + +vcl::filter::PDFObjectElement* pContents = aPages[0]->LookupObject("Contents"); +CPPUNIT_ASSERT(pContents); +vcl::filter::PDFStreamElement* pStream = pContents->GetStream(); +CPPUNIT_ASSERT(pStream); +SvMemoryStream& rObjectStream =