summaryrefslogtreecommitdiff
path: root/vcl/qa
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2021-03-11 13:21:49 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2021-03-12 15:33:03 +0100
commit2f1effff74c77eb13b53a7d4b5d31a7f2ac9ff8f (patch)
tree9e1ef2b168c9033542a2ba2728272674b0038703 /vcl/qa
parentc0ec7d342bd715d9910cf28afe10a6bfa3ba28cb (diff)
tdf#124272: vcl_pdfexport: Add unittest
Change-Id: I5d5aa7a2b9cc9c7cb522a84e00d48a348912ad95 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112341 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'vcl/qa')
-rw-r--r--vcl/qa/cppunit/pdfexport/data/tdf124272.odtbin0 -> 10292 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx44
2 files changed, 44 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf124272.odt b/vcl/qa/cppunit/pdfexport/data/tdf124272.odt
new file mode 100644
index 000000000000..54d4dcb2a1a4
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf124272.odt
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 365a9a0955c1..a15832aeabff 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1688,6 +1688,50 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf115967)
CPPUNIT_ASSERT_EQUAL(OUString("m=750abc"), sText);
}
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf124272)
+{
+ // Import the bugdoc and export as PDF.
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf124272.odt";
+ mxComponent = loadFromDesktop(aURL);
+
+ uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+ xStorable->storeToURL(maTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+
+ // Parse the export result.
+ 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());
+
+ // The page has a stream.
+ vcl::filter::PDFObjectElement* pContents = aPages[0]->LookupObject("Contents");
+ 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());
+
+ OString aBitmap("Q q 299.899 782.189 m\n"
+ "55.2 435.889 l 299.899 435.889 l 299.899 782.189 l\n"
+ "h");
+
+ auto pStart = static_cast<const char*>(aUncompressed.GetData());
+ const char* pEnd = pStart + aUncompressed.GetSize();
+ auto it = std::search(pStart, pEnd, aBitmap.getStr(), aBitmap.getStr() + aBitmap.getLength());
+ CPPUNIT_ASSERT(it != pEnd);
+}
+
CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf121615)
{
vcl::filter::PDFDocument aDocument;