diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-02-24 17:14:23 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-02-27 08:11:16 +0000 |
commit | 4e203ca3915e0cee2e7e02b95e78b3f5a8870098 (patch) | |
tree | 5a0e897019df5b6d463b9779caf9911aa6c61e26 /vcl | |
parent | 51eb2ad7a05938b69aa7874caf17079ed6c19e31 (diff) |
tdf#105461 vcl: add text highlight textcase
Fails with commit ee32c7d8083ae1449d6b379034be92995c142da9 (tdf#105461
PDF export: handle text fill color, 2017-02-01) reverted.
Change-Id: I3628a16d0810e3be3fb352340d06cdba472dcd3f
Reviewed-on: https://gerrit.libreoffice.org/34621
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/pdfexport/data/tdf105461.odp | bin | 0 -> 10320 bytes | |||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 50 |
2 files changed, 50 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf105461.odp b/vcl/qa/cppunit/pdfexport/data/tdf105461.odp Binary files differnew file mode 100644 index 000000000000..9c86a3bd7901 --- /dev/null +++ b/vcl/qa/cppunit/pdfexport/data/tdf105461.odp diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 949ef6109043..1c665b8d2174 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -19,6 +19,7 @@ #include <unotools/mediadescriptor.hxx> #include <unotools/tempfile.hxx> #include <xmlsecurity/pdfio/pdfdocument.hxx> +#include <tools/zcodec.hxx> using namespace ::com::sun::star; @@ -39,11 +40,14 @@ public: #if HAVE_FEATURE_PDFIUM /// Tests that a pdf image is roundtripped back to PDF as a vector format. void testTdf106059(); + /// Tests that text highlight from Impress is not lost. + void testTdf105461(); #endif CPPUNIT_TEST_SUITE(PdfExportTest); #if HAVE_FEATURE_PDFIUM CPPUNIT_TEST(testTdf106059); + CPPUNIT_TEST(testTdf105461); #endif CPPUNIT_TEST_SUITE_END(); }; @@ -100,6 +104,52 @@ void PdfExportTest::testTdf106059() // This dictionary key was missing, so the XObject wasn't a reference one. CPPUNIT_ASSERT(pReferenceXObject->Lookup("Ref")); } + +void PdfExportTest::testTdf105461() +{ + // Import the bugdoc and export as PDF. + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf105461.odp"; + mxComponent = loadFromDesktop(aURL); + CPPUNIT_ASSERT(mxComponent.is()); + + uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OUString("impress_pdf_Export"); + xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + + // Parse the export result. + xmlsecurity::pdfio::PDFDocument aDocument; + SvFileStream aStream(aTempFile.GetURL(), StreamMode::READ); + CPPUNIT_ASSERT(aDocument.Read(aStream)); + + // The document has one page. + std::vector<xmlsecurity::pdfio::PDFObjectElement*> aPages = aDocument.GetPages(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPages.size()); + + // The page has a stream. + xmlsecurity::pdfio::PDFObjectElement* pContents = aPages[0]->LookupObject("Contents"); + CPPUNIT_ASSERT(pContents); + xmlsecurity::pdfio::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 is a filled rectangle inside. + OString aFilledRectangle("re f*"); + auto pStart = static_cast<const char*>(aUncompressed.GetData()); + const char* pEnd = pStart + aUncompressed.GetSize(); + auto it = std::search(pStart, pEnd, aFilledRectangle.getStr(), aFilledRectangle.getStr() + aFilledRectangle.getLength()); + // This failed, stream contained no filled rectangle. + CPPUNIT_ASSERT(it != pEnd); +} #endif CPPUNIT_TEST_SUITE_REGISTRATION(PdfExportTest); |