summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-01-27 21:07:09 +0100
committerMichael Stahl <michael.stahl@cib.de>2020-02-14 11:07:59 +0100
commitb941971ca39df9cf76ce558a0add0faa4e6c2faa (patch)
treea720e300269810e321523cbb76ad46710a511b87 /writerfilter
parentd021827a277c08053d11b7319f9b6180b4988684 (diff)
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.) (cherry picked from commit 9fedce7a261f28dc286943f7bdd2adb010ed9b31) Conflicts: writerfilter/CppunitTest_writerfilter_dmapper.mk Change-Id: I8e12c28e65c5f64168c3f802546fddf472fcc6eb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87589 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/CppunitTest_writerfilter_dmapper.mk1
-rw-r--r--writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx75
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/group-shape-rotation.docxbin0 -> 24177 bytes
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx7
4 files changed, 81 insertions, 2 deletions
diff --git a/writerfilter/CppunitTest_writerfilter_dmapper.mk b/writerfilter/CppunitTest_writerfilter_dmapper.mk
index 695dcf95691b..8678bb92da10 100644
--- a/writerfilter/CppunitTest_writerfilter_dmapper.mk
+++ b/writerfilter/CppunitTest_writerfilter_dmapper.mk
@@ -20,6 +20,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,writerfilter_dmapper, \
writerfilter/qa/cppunittests/dmapper/DomainMapperTableHandler \
writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl \
writerfilter/qa/cppunittests/dmapper/PropertyMap \
+ writerfilter/qa/cppunittests/dmapper/GraphicImport \
))
$(eval $(call gb_CppunitTest_use_libraries,writerfilter_dmapper, \
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
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/group-shape-rotation.docx
Binary files differ
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 409bdb1861b1..97c807752f60 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -844,10 +844,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)));