[Libreoffice-commits] core.git: sw/qa writerfilter/CppunitTest_writerfilter_dmapper.mk writerfilter/qa writerfilter/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Jan 28 08:09:03 UTC 2020


 sw/qa/extras/ooxmlimport/ooxmlimport2.cxx                           |    4 
 writerfilter/CppunitTest_writerfilter_dmapper.mk                    |    1 
 writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx              |   75 ++++++++++
 writerfilter/qa/cppunittests/dmapper/data/group-shape-rotation.docx |binary
 writerfilter/source/dmapper/GraphicImport.cxx                       |    7 
 5 files changed, 83 insertions(+), 4 deletions(-)

New commits:
commit 9fedce7a261f28dc286943f7bdd2adb010ed9b31
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Jan 27 21:07:09 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jan 28 09:08:32 2020 +0100

    tdf#103964 DOCX import: ignore rotation when setting position of group shapes
    
    Regression from commit 36ac7749523e0c6f40a77beac278bd9e7a667a9b (DOCX
    import: make sure rotation does not affect shape position, 2014-09-24),
    the motivation for tweaking the rotation when setting the position of a
    shape was for images. By accident, this also happened for group shapes.
    
    But the bugdoc shows it's not a good idea to read the rotation of group
    shapes: the group shape is just a container, it does not have rotation
    in itself.
    
    (The test120551 intention was probably just to verify that the position
    is not entirely off, so the small required change to the expected value
    should be OK.)
    
    Change-Id: I8e12c28e65c5f64168c3f802546fddf472fcc6eb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87551
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index d75a8c0dc4fe..2983be1076e1 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -176,8 +176,8 @@ DECLARE_OOXMLIMPORT_TEST(test120551, "tdf120551.docx")
 {
     auto nHoriOrientPosition = getProperty<sal_Int32>(getShape(1), "HoriOrientPosition");
     // Without the accompanying fix in place, this test would have failed with
-    // 'Expected: 436, Actual  : -2542'.
-    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(436), nHoriOrientPosition);
+    // 'Expected: 430, Actual  : -2542'.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(430), nHoriOrientPosition);
 }
 
 DECLARE_OOXMLIMPORT_TEST(testTdf111550, "tdf111550.docx")
diff --git a/writerfilter/CppunitTest_writerfilter_dmapper.mk b/writerfilter/CppunitTest_writerfilter_dmapper.mk
index 0beb3e6145a5..8c0e7e2d37d3 100644
--- a/writerfilter/CppunitTest_writerfilter_dmapper.mk
+++ b/writerfilter/CppunitTest_writerfilter_dmapper.mk
@@ -19,6 +19,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,writerfilter_dmapper, \
     writerfilter/qa/cppunittests/dmapper/CellColorHandler \
     writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler \
     writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl \
+    writerfilter/qa/cppunittests/dmapper/GraphicImport \
     writerfilter/qa/cppunittests/dmapper/TextEffectsHandler \
 ))
 
diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
new file mode 100644
index 000000000000..2071f1fdf67d
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <test/bootstrapfixture.hxx>
+#include <unotest/macros_test.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
+#include <com/sun/star/text/XTextTablesSupplier.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+using namespace ::com::sun::star;
+
+namespace
+{
+/// Tests for writerfilter/source/dmapper/GraphicImport.cxx.
+class Test : public test::BootstrapFixture, public unotest::MacrosTest
+{
+private:
+    uno::Reference<uno::XComponentContext> mxComponentContext;
+    uno::Reference<lang::XComponent> mxComponent;
+
+public:
+    void setUp() override;
+    void tearDown() override;
+    uno::Reference<lang::XComponent>& getComponent() { return mxComponent; }
+};
+
+void Test::setUp()
+{
+    test::BootstrapFixture::setUp();
+
+    mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory()));
+    mxDesktop.set(frame::Desktop::create(mxComponentContext));
+}
+
+void Test::tearDown()
+{
+    if (mxComponent.is())
+        mxComponent->dispose();
+
+    test::BootstrapFixture::tearDown();
+}
+
+char const DATA_DIRECTORY[] = "/writerfilter/qa/cppunittests/dmapper/data/";
+
+CPPUNIT_TEST_FIXTURE(Test, testGroupShapeRotation)
+{
+    OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "group-shape-rotation.docx";
+    getComponent() = loadFromDesktop(aURL);
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+    uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+    sal_Int32 nVertPosition = 0;
+    xShape->getPropertyValue("VertOrientPosition") >>= nVertPosition;
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 1221
+    // - Actual  : -2048
+    // i.e. the group shape had a so low vertical position that the line shape did not point into
+    // it.
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1221), nVertPosition);
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/qa/cppunittests/dmapper/data/group-shape-rotation.docx b/writerfilter/qa/cppunittests/dmapper/data/group-shape-rotation.docx
new file mode 100644
index 000000000000..c9fee726bb89
Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/group-shape-rotation.docx differ
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index b730d5eff1bd..95a6727027ff 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -851,10 +851,13 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
                             // independent, but they are not. Till we are not
                             // there yet to handle all scaling, translation and
                             // rotation with a single transformation matrix,
-                            // make sure there is no rotation set when we set
+                            // make sure there is no graphic rotation set when we set
                             // the position.
                             sal_Int32 nRotation = 0;
-                            xShapeProps->getPropertyValue("RotateAngle") >>= nRotation;
+                            if (xServiceInfo->supportsService("com.sun.star.drawing.GraphicObjectShape"))
+                            {
+                                xShapeProps->getPropertyValue("RotateAngle") >>= nRotation;
+                            }
                             if (nRotation)
                                 xShapeProps->setPropertyValue("RotateAngle", uno::makeAny(sal_Int32(0)));
 


More information about the Libreoffice-commits mailing list