writerfilter/CppunitTest_writerfilter_dmapper.mk | 1 writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx | 75 ++++++++++ writerfilter/qa/cppunittests/dmapper/data/draw-shape-inline-effect.docx |binary writerfilter/source/dmapper/GraphicImport.cxx | 1 4 files changed, 77 insertions(+)
New commits: commit a00b1e15d844e688d8fa775cdc6a0ca5238c0d8d Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Tue Feb 11 09:51:14 2020 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Feb 11 19:49:18 2020 +0100 DOCX import: fix margins of inline shape with effects, imported as Draw shape Effects have an extent, and unhandled effects (like this blurred shadow) need to take space in the margin of the shape to make sure they use the correct amount of space in the layout. This was working in general, but not in case the importer decided to import the shape as Draw shape + the shape was inline. (cherry picked from commit bf25e69f8f657d5e3bcdd0bd54c5fa0d66ec85fe) Conflicts: writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx Change-Id: I9d0531d9393d8c2cd274e6f54bbbfe8024bf270f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88467 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/writerfilter/CppunitTest_writerfilter_dmapper.mk b/writerfilter/CppunitTest_writerfilter_dmapper.mk index 695dcf95691b..38dd3a8c321a 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/PropertyMap \ )) diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx new file mode 100644 index 000000000000..f08e395e116e --- /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, testDrawShapeInlineEffect) +{ + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "draw-shape-inline-effect.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 nBottomMargin = 0; + xShape->getPropertyValue("BottomMargin") >>= nBottomMargin; + // 273 in mm100 is 98425 EMUs from the file. + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 273 + // - Actual : 0 + // i.e. the layout result had less pages than expected (compared to Word). + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(273), nBottomMargin); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/qa/cppunittests/dmapper/data/draw-shape-inline-effect.docx b/writerfilter/qa/cppunittests/dmapper/data/draw-shape-inline-effect.docx new file mode 100644 index 000000000000..3eb5b0e2f448 Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/draw-shape-inline-effect.docx differ diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index d2e36a5aa638..efdd6acca36f 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -876,6 +876,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue) else if (bUseShape && m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_INLINE) { uno::Reference< beans::XPropertySet > xShapeProps(m_xShape, uno::UNO_QUERY_THROW); + m_pImpl->applyMargins(xShapeProps); comphelper::SequenceAsHashMap aInteropGrabBag(xShapeProps->getPropertyValue("InteropGrabBag")); aInteropGrabBag.update(m_pImpl->getInteropGrabBag()); xShapeProps->setPropertyValue("InteropGrabBag", uno::makeAny(aInteropGrabBag.getAsConstPropertyValueList())); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits