diff options
author | Tibor Nagy <tibor.nagy.extern@allotropia.de> | 2024-01-19 03:19:41 +0100 |
---|---|---|
committer | Nagy Tibor <tibor.nagy.extern@allotropia.de> | 2024-01-19 11:55:12 +0100 |
commit | 01e41414847bcc3670df9537bbcba6a98ebd5190 (patch) | |
tree | 800dbd4fc1d7fcaae6ff968e70a3211aa4a3909f /sc/qa | |
parent | 18e579761cb622e8ff7e67f319ef80c61b3bd588 (diff) |
tdf#159067 drawinglayer: fix untagged form control (PDF/UA export)
If the form object is marked as decorative, the form control should be exported as "Artifact"
Change-Id: I615d308ae966bf3d0f156899a0b4fad2d5a7c492
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162268
Tested-by: Jenkins
Reviewed-by: Nagy Tibor <tibor.nagy.extern@allotropia.de>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/extras/scpdfexport.cxx | 62 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/tdf159067.ods | bin | 0 -> 10406 bytes |
2 files changed, 62 insertions, 0 deletions
diff --git a/sc/qa/extras/scpdfexport.cxx b/sc/qa/extras/scpdfexport.cxx index bd6807e6375f..6cf93f71ed51 100644 --- a/sc/qa/extras/scpdfexport.cxx +++ b/sc/qa/extras/scpdfexport.cxx @@ -66,6 +66,7 @@ public: void testUnoCommands_Tdf120161(); void testTdf64703_hiddenPageBreak(); void testTdf159068(); + void testTdf159067(); void testTdf159066(); void testTdf159065(); void testTdf123870(); @@ -81,6 +82,7 @@ public: CPPUNIT_TEST(testUnoCommands_Tdf120161); CPPUNIT_TEST(testTdf64703_hiddenPageBreak); CPPUNIT_TEST(testTdf159068); + CPPUNIT_TEST(testTdf159067); CPPUNIT_TEST(testTdf159066); CPPUNIT_TEST(testTdf159065); CPPUNIT_TEST(testTdf123870); @@ -460,6 +462,66 @@ void ScPDFExportTest::testTdf159068() CPPUNIT_ASSERT_EQUAL(static_cast<decltype(nArtifact)>(5), nArtifact); } +void ScPDFExportTest::testTdf159067() +{ + loadFromFile(u"tdf159067.ods"); + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + + // A1:B3 + ScRange range1(0, 0, 0, 1, 2, 0); + exportToPDF(xModel, range1); + + 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()); + + vcl::filter::PDFObjectElement* pContents = aPages[0]->LookupObject("Contents"_ostr); + CPPUNIT_ASSERT(pContents); + vcl::filter::PDFStreamElement* pStream = pContents->GetStream(); + CPPUNIT_ASSERT(pStream); + + SvMemoryStream& rObjectStream = pStream->GetMemory(); + // Uncompress it. + SvMemoryStream aUncompressed; + ZCodec aZCodec; + aZCodec.BeginCompression(); + rObjectStream.Seek(0); + aZCodec.Decompress(rObjectStream, aUncompressed); + CPPUNIT_ASSERT(aZCodec.EndCompression()); + + auto pStart = static_cast<const char*>(aUncompressed.GetData()); + const char* const pEnd = pStart + aUncompressed.GetSize(); + + auto nArtifact(0); + auto nLine(0); + while (true) + { + ++nLine; + auto const pLine = ::std::find(pStart, pEnd, '\n'); + if (pLine == pEnd) + { + break; + } + std::string_view const line(pStart, pLine - pStart); + pStart = pLine + 1; + if (!line.empty() && line[0] != '%') + { + ::std::cerr << nLine << ": " << line << "\n "; + if (o3tl::starts_with(line, "/Artifact BMC")) + nArtifact++; + } + } + + // Without the fix in place, this test would have failed with + // - Expected: 3 (Artifact: Header, Footer, TextBox) + // - Actual : 2 (Artifact: Header, Footer) + CPPUNIT_ASSERT_EQUAL(static_cast<decltype(nArtifact)>(3), nArtifact); +} + void ScPDFExportTest::testTdf159066() { loadFromFile(u"tdf159066.ods"); diff --git a/sc/qa/extras/testdocuments/tdf159067.ods b/sc/qa/extras/testdocuments/tdf159067.ods Binary files differnew file mode 100644 index 000000000000..a6e268d0d94b --- /dev/null +++ b/sc/qa/extras/testdocuments/tdf159067.ods |