diff options
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/CppunitTest_writerfilter_dmapper.mk | 1 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx | 75 | ||||
-rw-r--r-- | writerfilter/qa/cppunittests/dmapper/data/group-shape-rotation.docx | bin | 0 -> 24177 bytes | |||
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 7 |
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 Binary files differnew file mode 100644 index 000000000000..c9fee726bb89 --- /dev/null +++ b/writerfilter/qa/cppunittests/dmapper/data/group-shape-rotation.docx 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))); |