summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <Vasily.Melenchuk@cib.de>2017-06-05 13:21:46 +0300
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-06-06 11:52:51 +0200
commita915f55c1867c73b3d231afc6e9f6dee17965c00 (patch)
tree1d05e2e3c14826a5607904eb8c10ca523c2535da
parent2f5d1fc88f5d8b302d5c777b1becaad2f8406f97 (diff)
tdf#99680 unittest to ensure there are no empty clipping regions
Change-Id: Id4565858b0135b3177044558db87a68ef828955b Reviewed-on: https://gerrit.libreoffice.org/38403 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--vcl/qa/cppunit/pdfexport/data/tdf99680.odtbin0 -> 30257 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx35
2 files changed, 35 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf99680.odt b/vcl/qa/cppunit/pdfexport/data/tdf99680.odt
new file mode 100644
index 000000000000..de12f9baa180
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf99680.odt
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index f4fbf022e198..2b3db2584ea5 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -66,6 +66,7 @@ public:
void testTdf107013();
void testTdf107018();
void testTdf107089();
+ void testTdf99680();
#endif
CPPUNIT_TEST_SUITE(PdfExportTest);
@@ -81,6 +82,7 @@ public:
CPPUNIT_TEST(testTdf107013);
CPPUNIT_TEST(testTdf107018);
CPPUNIT_TEST(testTdf107089);
+ CPPUNIT_TEST(testTdf99680);
#endif
CPPUNIT_TEST_SUITE_END();
};
@@ -592,6 +594,39 @@ void PdfExportTest::testTdf107089()
// This failed, 'Hello' was part only a mixed compressed/uncompressed stream, i.e. garbage.
CPPUNIT_ASSERT(it != pEnd);
}
+
+void PdfExportTest::testTdf99680()
+{
+ vcl::filter::PDFDocument aDocument;
+ load("tdf99680.odt", aDocument);
+
+ // 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 1 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());
+
+ // Make sure there are no empty clipping regions.
+ OString aEmptyReqion("0 0 m h W* n");
+ auto pStart = static_cast<const char*>(aUncompressed.GetData());
+ const char* pEnd = pStart + aUncompressed.GetSize();
+ auto it = std::search(pStart, pEnd, aEmptyReqion.getStr(), aEmptyReqion.getStr() + aEmptyReqion.getLength());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Empty clipping region detected!", it, pEnd);
+}
+
#endif
CPPUNIT_TEST_SUITE_REGISTRATION(PdfExportTest);