[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sdext/source

Mike Kaganski mike.kaganski at collabora.com
Wed Mar 9 14:21:19 UTC 2016


 sdext/source/pdfimport/test/outputwrap.hxx         |   27 ++++++++++++++++++
 sdext/source/pdfimport/test/testTdf96993.pdf       |binary
 sdext/source/pdfimport/test/tests.cxx              |   31 +++++++++++++++++++++
 sdext/source/pdfimport/tree/writertreevisiting.cxx |    9 ++++++
 4 files changed, 67 insertions(+)

New commits:
commit 9fb382d4e6afd40f8c50981cac3cbea9334b5639
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Tue Mar 8 21:36:11 2016 +1000

    tdf#98421: properly import vertical mirroring of images from PDF
    
    Since commit ae0e830f9ace78b889713e7e74ce46f88fa21470, mirroring
    is handled correctly in LO, so no need to handle it specially in
    PDF import code. Commit 11c865031cffc170d3db6b00fb48c683fb4ff070
    fixed import to Draw, this one fixes import to Writer.
    Also, unit tests for both cases are provided.
    
    Change-Id: I9ef9753a364af34f9e158052855c5dba1300c934
    Reviewed-on: https://gerrit.libreoffice.org/23028
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    (cherry picked from commit 345d5b172cb81f86e91cb5c0b49f54d4957b9663)
    Reviewed-on: https://gerrit.libreoffice.org/23063
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sdext/source/pdfimport/test/outputwrap.hxx b/sdext/source/pdfimport/test/outputwrap.hxx
index 015a3e2..aa4c541 100644
--- a/sdext/source/pdfimport/test/outputwrap.hxx
+++ b/sdext/source/pdfimport/test/outputwrap.hxx
@@ -25,6 +25,7 @@
 #include <cppuhelper/compbase.hxx>
 #include <com/sun/star/io/XOutputStream.hpp>
 #include <osl/file.hxx>
+#include <rtl/strbuf.hxx>
 
 namespace pdfi
 {
@@ -59,6 +60,32 @@ typedef ::cppu::WeakComponentImplHelper<
             maFile.close();
         }
     };
+
+    class OutputWrapString : private cppu::BaseMutex, public OutputWrapBase
+    {
+        OString& mrString;
+        OStringBuffer maBuffer;
+
+    public:
+
+        explicit OutputWrapString(OString& rString) : OutputWrapBase(m_aMutex), mrString(rString), maBuffer(rString)
+        {
+        }
+
+        virtual void SAL_CALL writeBytes(const css::uno::Sequence< ::sal_Int8 >& aData) throw (css::io::NotConnectedException, css::io::BufferSizeExceededException, css::io::IOException, css::uno::RuntimeException, std::exception) override
+        {
+            maBuffer.append(reinterpret_cast<const sal_Char *>(aData.getConstArray()), aData.getLength());
+        }
+
+        virtual void SAL_CALL flush() throw (css::io::NotConnectedException, css::io::BufferSizeExceededException, css::io::IOException, css::uno::RuntimeException, std::exception) override
+        {
+        }
+
+        virtual void SAL_CALL closeOutput() throw (css::io::NotConnectedException, css::io::BufferSizeExceededException, css::io::IOException, css::uno::RuntimeException, std::exception) override
+        {
+            mrString = maBuffer.makeStringAndClear();
+        }
+    };
 }
 #endif
 
diff --git a/sdext/source/pdfimport/test/testTdf96993.pdf b/sdext/source/pdfimport/test/testTdf96993.pdf
new file mode 100644
index 0000000..73abbd1
Binary files /dev/null and b/sdext/source/pdfimport/test/testTdf96993.pdf differ
diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx
index cdad633..e2b043c 100644
--- a/sdext/source/pdfimport/test/tests.cxx
+++ b/sdext/source/pdfimport/test/tests.cxx
@@ -496,10 +496,41 @@ namespace
             osl::File::remove( tempFileURL );
         }
 
+        void testTdf96993()
+        {
+            uno::Reference<pdfi::PDFIRawAdaptor> xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext()));
+            xAdaptor->setTreeVisitorFactory(createDrawTreeVisitorFactory());
+
+            OString aOutput;
+            CPPUNIT_ASSERT_MESSAGE("Exporting to ODF",
+                xAdaptor->odfConvert(getURLFromSrc("/sdext/source/pdfimport/test/testTdf96993.pdf"),
+                new OutputWrapString(aOutput),
+                nullptr));
+            // This ensures that the imported image arrives properly flipped
+            CPPUNIT_ASSERT(aOutput.indexOf("draw:transform=\"matrix(18520.8333333333 0 0 26281.9444444444 0 0)\"") != -1);
+        }
+
+        void testTdf98421()
+        {
+            uno::Reference<pdfi::PDFIRawAdaptor> xAdaptor(new pdfi::PDFIRawAdaptor(OUString(), getComponentContext()));
+            xAdaptor->setTreeVisitorFactory(createWriterTreeVisitorFactory());
+
+            OString aOutput;
+            CPPUNIT_ASSERT_MESSAGE("Exporting to ODF",
+                xAdaptor->odfConvert(getURLFromSrc("/sdext/source/pdfimport/test/testTdf96993.pdf"),
+                new OutputWrapString(aOutput),
+                nullptr));
+            // This ensures that the imported image arrives properly flipped
+            CPPUNIT_ASSERT(aOutput.indexOf("draw:transform=\"scale( 1.0 -1.0 ) translate( 0mm 0mm )\"") != -1);
+            CPPUNIT_ASSERT(aOutput.indexOf("svg:height=\"-262.82mm\"") != -1);
+        }
+
         CPPUNIT_TEST_SUITE(PDFITest);
         CPPUNIT_TEST(testXPDFParser);
         CPPUNIT_TEST(testOdfWriterExport);
         CPPUNIT_TEST(testOdfDrawExport);
+        CPPUNIT_TEST(testTdf96993);
+        CPPUNIT_TEST(testTdf98421);
         CPPUNIT_TEST_SUITE_END();
     };
 
diff --git a/sdext/source/pdfimport/tree/writertreevisiting.cxx b/sdext/source/pdfimport/tree/writertreevisiting.cxx
index 5cf4156..9224792 100644
--- a/sdext/source/pdfimport/tree/writertreevisiting.cxx
+++ b/sdext/source/pdfimport/tree/writertreevisiting.cxx
@@ -164,6 +164,15 @@ void WriterXmlEmitter::fillFrameProps( DrawElement&       rElem,
         // that ODF rotation is oriented the other way
 
         // build transformation string
+        if (rElem.MirrorVertical)
+        {
+            // At some point, rElem.h may start arriving positive,
+            // so use robust adjusting math
+            rel_y -= std::abs(rElem.h);
+            if (!aBuf.isEmpty())
+                aBuf.append(' ');
+            aBuf.append("scale( 1.0 -1.0 )");
+        }
         if( fShearX != 0.0 )
         {
             aBuf.append( "skewX( " );


More information about the Libreoffice-commits mailing list