summaryrefslogtreecommitdiff
path: root/vcl/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-04-05 17:31:47 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-04-05 20:05:14 +0000
commit4443d7be61a9ae45630183d856a566cecd06ad95 (patch)
treec59595e63f39e248db0037c4b22fd49b458ee9bd /vcl/qa
parentdbcb866e46b3f964deb77b62b52bec1bb2b009ea (diff)
Related: tdf#106972 vcl PDF export, PDF images: ignore PDF >= 1.5
When copying their page steam into ours, we need to make sure their syntax is <= 1.4; so when checking if the image has PDF data, ignore the case when it has, but it's >= 1.5 (at least in the default case when not using reference XObjects). Change-Id: I6bd77803b92fe16bdd327e5e7c3d2b42adeacca4 Reviewed-on: https://gerrit.libreoffice.org/36161 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl/qa')
-rw-r--r--vcl/qa/cppunit/pdfexport/data/tdf106972-pdf17.odtbin0 -> 21561 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx38
2 files changed, 38 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf106972-pdf17.odt b/vcl/qa/cppunit/pdfexport/data/tdf106972-pdf17.odt
new file mode 100644
index 000000000000..d46c93dffb5f
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf106972-pdf17.odt
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 2bbb9f3c9f01..566495f38edf 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -50,6 +50,7 @@ public:
/// Tests export of PDF images without reference XObjects.
void testTdf106693();
void testTdf106972();
+ void testTdf106972Pdf17();
#endif
CPPUNIT_TEST_SUITE(PdfExportTest);
@@ -60,6 +61,7 @@ public:
CPPUNIT_TEST(testTdf106206);
CPPUNIT_TEST(testTdf106693);
CPPUNIT_TEST(testTdf106972);
+ CPPUNIT_TEST(testTdf106972Pdf17);
#endif
CPPUNIT_TEST_SUITE_END();
};
@@ -365,6 +367,42 @@ void PdfExportTest::testTdf106972()
// This failed: the PDF image had no Font resource.
CPPUNIT_ASSERT(pImageResources->LookupElement("Font"));
}
+
+void PdfExportTest::testTdf106972Pdf17()
+{
+ // Import the bugdoc and export as PDF.
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf106972-pdf17.odt";
+ 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("writer_pdf_Export");
+ xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+
+ // Parse the export result.
+ vcl::filter::PDFDocument aDocument;
+ SvFileStream aStream(aTempFile.GetURL(), StreamMode::READ);
+ CPPUNIT_ASSERT(aDocument.Read(aStream));
+
+ // Get access to the only image on the only page.
+ std::vector<vcl::filter::PDFObjectElement*> aPages = aDocument.GetPages();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aPages.size());
+ vcl::filter::PDFObjectElement* pResources = aPages[0]->LookupObject("Resources");
+ CPPUNIT_ASSERT(pResources);
+ auto pXObjects = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pResources->Lookup("XObject"));
+ CPPUNIT_ASSERT(pXObjects);
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pXObjects->GetItems().size());
+ vcl::filter::PDFObjectElement* pXObject = pXObjects->LookupObject(pXObjects->GetItems().begin()->first);
+ CPPUNIT_ASSERT(pXObject);
+
+ // This failed, the "image" had resources; that typically means we tried to
+ // preserve the original PDF markup here; which is not OK till our default
+ // output is PDF 1.4, and this bugdoc has PDF 1.7 data.
+ CPPUNIT_ASSERT(!pXObject->Lookup("Resources"));
+}
#endif
CPPUNIT_TEST_SUITE_REGISTRATION(PdfExportTest);