[Libreoffice-commits] core.git: vcl/qa
Xisco Fauli (via logerrit)
logerrit at kemper.freedesktop.org
Fri Mar 12 14:33:52 UTC 2021
vcl/qa/cppunit/pdfexport/data/tdf124272.odt |binary
vcl/qa/cppunit/pdfexport/pdfexport.cxx | 44 ++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
New commits:
commit 2f1effff74c77eb13b53a7d4b5d31a7f2ac9ff8f
Author: Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Thu Mar 11 13:21:49 2021 +0100
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri Mar 12 15:33:03 2021 +0100
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 at libreoffice.org>
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
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf124272.odt 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;
More information about the Libreoffice-commits
mailing list