diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-01-28 17:46:43 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-01-28 17:30:06 +0000 |
commit | 62c063de37b777ae2b0d06220ffdbdd8e8912d02 (patch) | |
tree | deb2331d374c4a91b5a4a4e455ff84c33b0eaf0f /sdext | |
parent | d817456fb0f5c55ea47c16a18c44da107a24b906 (diff) |
tdf#105536: PDF image should be v-flipped unconditionally
Unit test included
Change-Id: Id0d054a6b9922666daf4f36908f97ed6e65fb6c7
Reviewed-on: https://gerrit.libreoffice.org/33649
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sdext')
-rw-r--r-- | sdext/source/pdfimport/test/testTdf105536.pdf | bin | 0 -> 59646 bytes | |||
-rw-r--r-- | sdext/source/pdfimport/test/tests.cxx | 15 | ||||
-rw-r--r-- | sdext/source/pdfimport/tree/pdfiprocessor.cxx | 8 |
3 files changed, 21 insertions, 2 deletions
diff --git a/sdext/source/pdfimport/test/testTdf105536.pdf b/sdext/source/pdfimport/test/testTdf105536.pdf Binary files differnew file mode 100644 index 000000000000..d0bb7d776a6f --- /dev/null +++ b/sdext/source/pdfimport/test/testTdf105536.pdf diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index 9e4437e6d8cd..987865c258db 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -522,12 +522,27 @@ namespace CPPUNIT_ASSERT(aOutput.indexOf("svg:height=\"-262.82mm\"") != -1); } + void testTdf105536() + { + rtl::Reference<pdfi::PDFIRawAdaptor> xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext())); + xAdaptor->setTreeVisitorFactory(createDrawTreeVisitorFactory()); + + OString aOutput; + CPPUNIT_ASSERT_MESSAGE("Exporting to ODF", + xAdaptor->odfConvert(m_directories.getURLFromSrc("/sdext/source/pdfimport/test/testTdf105536.pdf"), + new OutputWrapString(aOutput), + nullptr)); + // This ensures that the imported image arrives properly flipped + CPPUNIT_ASSERT(aOutput.indexOf("draw:transform=\"matrix(-21488.4 0 0 -27978.1 21488.4 27978.1)\"") != -1); + } + CPPUNIT_TEST_SUITE(PDFITest); CPPUNIT_TEST(testXPDFParser); CPPUNIT_TEST(testOdfWriterExport); CPPUNIT_TEST(testOdfDrawExport); CPPUNIT_TEST(testTdf96993); CPPUNIT_TEST(testTdf98421); + CPPUNIT_TEST(testTdf105536); CPPUNIT_TEST_SUITE_END(); }; diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx index cb514072e91b..a19f71642fce 100644 --- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx +++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx @@ -349,8 +349,12 @@ void PDFIProcessor::setupImage(ImageId nImage) pFrame->h = pImageElement->h = aScale.getY(); pFrame->ZOrder = m_nNextZOrder++; - if (aScale.getY() < 0) - pFrame->MirrorVertical = pImageElement->MirrorVertical = true; + // Poppler wrapper takes into account that vertical axes of PDF and ODF are opposite, + // and it flips matrix vertically (see poppler's GfxState::GfxState()). + // But image internal vertical axis is independent of PDF vertical axis direction, + // so arriving matrix is extra-flipped relative to image. + // We force vertical flip here to compensate that. + pFrame->MirrorVertical = true; } void PDFIProcessor::drawMask(const uno::Sequence<beans::PropertyValue>& xBitmap, |