vcl/qa/cppunit/pdfexport/data/tdf99680.odt |binary vcl/qa/cppunit/pdfexport/pdfexport.cxx | 35 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+)
New commits: commit a915f55c1867c73b3d231afc6e9f6dee17965c00 Author: Vasily Melenchuk <[email protected]> Date: Mon Jun 5 13:21:46 2017 +0300 tdf#99680 unittest to ensure there are no empty clipping regions Change-Id: Id4565858b0135b3177044558db87a68ef828955b Reviewed-on: https://gerrit.libreoffice.org/38403 Tested-by: Jenkins <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> 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 Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf99680.odt 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); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
