summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-04-16 18:13:01 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-05-05 10:21:52 +0200
commiteaafd7378bd3a06d2d99360667858a3b6106d0de (patch)
tree94e8b7094293dfdcdff13163ea795bc0e08c831c /vcl/qa/cppunit
parent0ce45bf39c53a953c9f84635699ee116f1cbb5a3 (diff)
PDF export: fix handling of page sizes larger than 508 cm
The value of these coordinates are not allowed to be larger than 14 400, and Adobe Reader complains about them. Use UserUnit to declare in case we won't work with points anymore, but with a larger unit. This will mean UserUnit=2 in practice, since e.g. Draw has is page size limited to 600x600cm, so larger values won't happen, at least not for now. (cherry picked from commit 4830592b780833cf5eee2aef30bc9c5d444dfb24) Conflicts: vcl/source/gdi/pdfwriter_impl.cxx vcl/source/gdi/pdfwriter_impl.hxx Change-Id: I8ee159f2571f4070aded85388792a215de86f7ff
Diffstat (limited to 'vcl/qa/cppunit')
-rw-r--r--vcl/qa/cppunit/pdfexport/data/6m-wide.odgbin0 -> 9146 bytes
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx24
2 files changed, 24 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/pdfexport/data/6m-wide.odg b/vcl/qa/cppunit/pdfexport/data/6m-wide.odg
new file mode 100644
index 000000000000..49fb9bfff92e
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/6m-wide.odg
Binary files differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 48f12080f74b..28b0b693e426 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -138,6 +138,7 @@ public:
void testTocLink();
void testPdfImageResourceInlineXObjectRef();
void testLinkWrongPage();
+ void testLargePage();
CPPUNIT_TEST_SUITE(PdfExportTest);
CPPUNIT_TEST(testTdf106059);
@@ -176,6 +177,7 @@ public:
CPPUNIT_TEST(testTocLink);
CPPUNIT_TEST(testPdfImageResourceInlineXObjectRef);
CPPUNIT_TEST(testLinkWrongPage);
+ CPPUNIT_TEST(testLargePage);
CPPUNIT_TEST_SUITE_END();
};
@@ -1895,6 +1897,28 @@ void PdfExportTest::testLinkWrongPage()
CPPUNIT_ASSERT(!HasLinksOnPage(pPdfPage2));
}
+void PdfExportTest::testLargePage()
+{
+ // Import the bugdoc and export as PDF.
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "6m-wide.odg";
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("draw_pdf_Export");
+ DocumentHolder pPdfDocument = exportAndParse(aURL, aMediaDescriptor);
+
+ // The document has 1 page.
+ CPPUNIT_ASSERT_EQUAL(1, FPDF_GetPageCount(pPdfDocument.get()));
+
+ // Check the value (not the unit) of the page size.
+ double fWidth = 0;
+ double fHeight = 0;
+ FPDF_GetPageSizeByIndex(pPdfDocument.get(), 0, &fWidth, &fHeight);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 8503.94
+ // - Actual : 17007.875
+ // i.e. the value for 600 cm was larger than the 14 400 limit set in the spec.
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(8503.94, fWidth, 0.01);
+}
+
void PdfExportTest::testPdfImageResourceInlineXObjectRef()
{
// Create an empty document.