summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2023-05-26 16:20:47 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2023-05-26 19:19:20 +0200
commit370533da3f07169791c0a17013ca55c57df2f3c9 (patch)
treee61a654563517962ab16f2cc4d836857067d861d /vcl
parentef2d064c403738660e9ba6bee6de736d0575dade (diff)
tdf#155190 svx,sw: PDF export: don't tag SwNoTextFrame as Artifact
The problem is that inside of the Figure tag, in SwNoTextFrame::ImplPaintPictureGraphic(), ViewContactOfSwNoTextFrame and ViewObjectContactOfSwNoTextFrame are used to create and process another primitive sequence. ViewObjectContactOfSwNoTextFrame does not have access to a SdrObject, because that was already processed by the outer layer of code that called the SwFlyFrame painting code. Avoid running the code that assumes anything without an SdrObject is an artifact by disabling PDF tags altogether in ViewObjectContactOfSwNoTextFrame. (regression from commit 81ef84648515965bf67afaced946227d0f63a71e) Change-Id: I9fabe7f7e5296f8d850448ac44865f87cd164591 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152335 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/pdfexport/data/tdf155190.odtbin0 -> 9628 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx88
2 files changed, 88 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf155190.odt b/vcl/qa/cppunit/pdfexport/data/tdf155190.odt
new file mode 100644
index 000000000000..51930ad2992d
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf155190.odt
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index bf2ca137646f..0739cd25cd8a 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3598,6 +3598,94 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf135192)
CPPUNIT_ASSERT_EQUAL(int(1), nTable);
}
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf155190)
+{
+ aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+
+ // Enable PDF/UA
+ uno::Sequence<beans::PropertyValue> aFilterData(
+ comphelper::InitPropertySequence({ { "PDFUACompliance", uno::Any(true) } }));
+ aMediaDescriptor["FilterData"] <<= aFilterData;
+
+ saveAsPDF(u"tdf155190.odt");
+
+ vcl::filter::PDFDocument aDocument;
+ SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
+ CPPUNIT_ASSERT(aDocument.Read(aStream));
+
+ // The document has one page.
+ std::vector<vcl::filter::PDFObjectElement*> aPages = aDocument.GetPages();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPages.size());
+
+ auto nDiv(0);
+ auto nFigure(0);
+ for (const auto& rDocElement : aDocument.GetElements())
+ {
+ auto pObject1 = dynamic_cast<vcl::filter::PDFObjectElement*>(rDocElement.get());
+ if (!pObject1)
+ continue;
+ auto pType1 = dynamic_cast<vcl::filter::PDFNameElement*>(pObject1->Lookup("Type"));
+
+ auto pS1 = dynamic_cast<vcl::filter::PDFNameElement*>(pObject1->Lookup("S"));
+ // start with the text box
+ if (pType1 && pType1->GetValue() == "StructElem" && pS1 && pS1->GetValue() == "Div")
+ {
+ ++nDiv;
+ auto pKids1 = dynamic_cast<vcl::filter::PDFArrayElement*>(pObject1->Lookup("K"));
+ CPPUNIT_ASSERT(pKids1);
+ for (auto pKid1 : pKids1->GetElements())
+ {
+ auto pRefKid1 = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKid1);
+ if (pRefKid1)
+ {
+ auto pObject2 = pRefKid1->LookupObject();
+ CPPUNIT_ASSERT(pObject2);
+ auto pType2
+ = dynamic_cast<vcl::filter::PDFNameElement*>(pObject2->Lookup("Type"));
+ CPPUNIT_ASSERT(pType2);
+ CPPUNIT_ASSERT_EQUAL(OString("StructElem"), pType2->GetValue());
+ auto pS2 = dynamic_cast<vcl::filter::PDFNameElement*>(pObject2->Lookup("S"));
+ CPPUNIT_ASSERT_EQUAL(OString("FigureCaption"), pS2->GetValue());
+ auto pKids2
+ = dynamic_cast<vcl::filter::PDFArrayElement*>(pObject2->Lookup("K"));
+ CPPUNIT_ASSERT(pKids2);
+ // there are additional children, MCID ref
+ for (auto pKid2 : pKids2->GetElements())
+ {
+ auto pRefKid2 = dynamic_cast<vcl::filter::PDFReferenceElement*>(pKid2);
+ if (pRefKid2)
+ {
+ auto pObject3 = pRefKid2->LookupObject();
+ CPPUNIT_ASSERT(pObject3);
+ auto pType3 = dynamic_cast<vcl::filter::PDFNameElement*>(
+ pObject3->Lookup("Type"));
+ if (pType3 && pType3->GetValue() == "StructElem")
+ {
+ auto pS3 = dynamic_cast<vcl::filter::PDFNameElement*>(
+ pObject3->Lookup("S"));
+ CPPUNIT_ASSERT_EQUAL(OString("Figure"), pS3->GetValue());
+ auto pAlt = dynamic_cast<vcl::filter::PDFHexStringElement*>(
+ pObject3->Lookup("Alt"));
+ CPPUNIT_ASSERT_EQUAL(
+ OUString("Picture of apples"),
+ ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAlt));
+ auto pKids3 = dynamic_cast<vcl::filter::PDFArrayElement*>(
+ pObject3->Lookup("K"));
+ CPPUNIT_ASSERT(pKids3);
+ // the problem was that this didn't reference an MCID
+ CPPUNIT_ASSERT(!pKids3->GetElements().empty());
+ ++nFigure;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ CPPUNIT_ASSERT_EQUAL(static_cast<decltype(nDiv)>(1), nDiv);
+ CPPUNIT_ASSERT_EQUAL(static_cast<decltype(nDiv)>(1), nFigure);
+}
+
CPPUNIT_TEST_FIXTURE(PdfExportTest, testMediaShapeAnnot)
{
aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");