summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-11-24 13:17:56 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2022-11-25 11:48:00 +0100
commit122b4264d23df8b11419839ba700b88c4f936a6c (patch)
tree64422f6707ad6404947e04a0af13a03ebd3d9b44 /vcl/qa/cppunit
parent78681cd0829dcb6a73690e1a63ae3808d297677a (diff)
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 <michael.stahl@allotropia.de>
Diffstat (limited to 'vcl/qa/cppunit')
-rw-r--r--vcl/qa/cppunit/pdfexport/data/Description PDF Export test .odtbin0 -> 22599 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx102
2 files changed, 102 insertions, 0 deletions
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 000000000000..78f05b09e9e9
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/Description PDF Export test .odt
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 3c75ec632eae..962995a0d6e1 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3277,6 +3277,108 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf135638)
CPPUNIT_ASSERT_EQUAL(int(2), nFigure);
}
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf57423)
+{
+ 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"Description PDF Export test .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());
+
+ int nFigure(0);
+ int nFormula(0);
+ int nDiv(0);
+ for (const auto& rDocElement : aDocument.GetElements())
+ {
+ auto pObject = dynamic_cast<vcl::filter::PDFObjectElement*>(rDocElement.get());
+ if (!pObject)
+ continue;
+ auto pType = dynamic_cast<vcl::filter::PDFNameElement*>(pObject->Lookup("Type"));
+ if (pType && pType->GetValue() == "StructElem")
+ {
+ auto pS = dynamic_cast<vcl::filter::PDFNameElement*>(pObject->Lookup("S"));
+ if (pS && pS->GetValue() == "Figure")
+ {
+ switch (nFigure)
+ {
+ case 0:
+ CPPUNIT_ASSERT_EQUAL(OUString(u"QR Code - Tells how to get to Mosegaard"),
+ ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(
+ *dynamic_cast<vcl::filter::PDFHexStringElement*>(
+ pObject->Lookup("Alt"))));
+ break;
+ case 1:
+ CPPUNIT_ASSERT_EQUAL(OUString(u"Title: Arrows - Description: Explains the "
+ u"different arrow appearances"),
+ ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(
+ *dynamic_cast<vcl::filter::PDFHexStringElement*>(
+ pObject->Lookup("Alt"))));
+ break;
+ case 2:
+ CPPUNIT_ASSERT_EQUAL(
+ OUString(u"My blue triangle - Does not need further description"),
+ ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(
+ *dynamic_cast<vcl::filter::PDFHexStringElement*>(
+ pObject->Lookup("Alt"))));
+ break;
+ }
+ ++nFigure;
+ }
+ if (pS && pS->GetValue() == "Formula")
+ {
+ CPPUNIT_ASSERT_EQUAL(
+ OUString(u"Equation 1 - Now we give the full description of eq 1 here"),
+ ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(
+ *dynamic_cast<vcl::filter::PDFHexStringElement*>(pObject->Lookup("Alt"))));
+ ++nFormula;
+ }
+ if (pS && pS->GetValue() == "Div")
+ {
+ switch (nDiv)
+ {
+ case 0:
+ CPPUNIT_ASSERT_EQUAL(OUString(u"This frame has a description"),
+ ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(
+ *dynamic_cast<vcl::filter::PDFHexStringElement*>(
+ pObject->Lookup("Alt"))));
+ break;
+ case 1:
+ // no properties set on this
+ CPPUNIT_ASSERT(!pObject->Lookup("Alt"));
+ break;
+ case 2:
+ CPPUNIT_ASSERT_EQUAL(OUString(u"My textbox - Has a light background"),
+ ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(
+ *dynamic_cast<vcl::filter::PDFHexStringElement*>(
+ pObject->Lookup("Alt"))));
+ break;
+ case 3:
+ CPPUNIT_ASSERT_EQUAL(OUString(u"Hey! There is no alternate text for Frame "
+ u"// but maybe not needed?"),
+ ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(
+ *dynamic_cast<vcl::filter::PDFHexStringElement*>(
+ pObject->Lookup("Alt"))));
+ break;
+ }
+ ++nDiv;
+ }
+ }
+ }
+ CPPUNIT_ASSERT_EQUAL(int(3), nFigure);
+ CPPUNIT_ASSERT_EQUAL(int(1), nFormula);
+ CPPUNIT_ASSERT_EQUAL(int(4), nDiv);
+}
+
CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf142129)
{
loadFromURL(u"master.odm");