writerfilter/CppunitTest_writerfilter_rtftok.mk | 49 ++++++ writerfilter/Module_writerfilter.mk | 1 writerfilter/qa/cppunittests/rtftok/data/picture-in-textframe.rtf | 29 ++++ writerfilter/qa/cppunittests/rtftok/rtfsdrimport.cxx | 71 ++++++++++ writerfilter/source/rtftok/rtfsdrimport.cxx | 5 5 files changed, 155 insertions(+)
New commits: commit ed714bd7ca70979340292b9d7a4b99b3a14db64c Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Jul 20 21:22:14 2020 +0200 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Tue Jul 21 17:19:17 2020 +0200 tdf#134400 RTF import: fix unexpected inner properties for picture-in-textframe Regression from commit 4ab658b56f5c6ff0082d38d8ace1924d11e30e96 (RTF import: implement support for tables inside text frames, 2013-06-16), the problem was that both the outer "textbox" and the inner "picture frame" object had a shapeType property, and the properties were stored in a vector. So by the time RTFSdrImport::initShape() looked up the shape type for the inner shape, it thought it's not a picture frame, leading to data loss. (cherry picked from commit 5a083be34456e91427d0f2e2fea172f49f4502db) Change-Id: I4a536789371619d1d54afa8c8d41c7d273b0d21b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99118 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/writerfilter/CppunitTest_writerfilter_rtftok.mk b/writerfilter/CppunitTest_writerfilter_rtftok.mk new file mode 100644 index 000000000000..4ca730b9d3fc --- /dev/null +++ b/writerfilter/CppunitTest_writerfilter_rtftok.mk @@ -0,0 +1,49 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# 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/. +# +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,writerfilter_rtftok)) + +$(eval $(call gb_CppunitTest_use_externals,writerfilter_rtftok,\ + boost_headers \ +)) + +$(eval $(call gb_CppunitTest_add_exception_objects,writerfilter_rtftok, \ + writerfilter/qa/cppunittests/rtftok/rtfsdrimport \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,writerfilter_rtftok, \ + basegfx \ + comphelper \ + cppu \ + oox \ + sal \ + test \ + unotest \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,writerfilter_rtftok)) + +$(eval $(call gb_CppunitTest_use_ure,writerfilter_rtftok)) +$(eval $(call gb_CppunitTest_use_vcl,writerfilter_rtftok)) + +$(eval $(call gb_CppunitTest_use_rdb,writerfilter_rtftok,services)) + +$(eval $(call gb_CppunitTest_use_custom_headers,writerfilter_rtftok,\ + officecfg/registry \ +)) + +$(eval $(call gb_CppunitTest_use_configuration,writerfilter_rtftok)) + +# we need to explicitly depend on library writerfilter because it is not implied +# by a link relation +$(call gb_CppunitTest_get_target,writerfilter_rtftok) : $(call gb_Library_get_target,writerfilter) + +# vim: set noet sw=4 ts=4: diff --git a/writerfilter/Module_writerfilter.mk b/writerfilter/Module_writerfilter.mk index 34b75ee9d54d..46d7af0ff63a 100644 --- a/writerfilter/Module_writerfilter.mk +++ b/writerfilter/Module_writerfilter.mk @@ -18,6 +18,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,writerfilter,\ CppunitTest_writerfilter_filters_test \ CppunitTest_writerfilter_misc \ CppunitTest_writerfilter_dmapper \ + CppunitTest_writerfilter_rtftok \ )) # vim: set noet sw=4 ts=4: diff --git a/writerfilter/qa/cppunittests/rtftok/data/picture-in-textframe.rtf b/writerfilter/qa/cppunittests/rtftok/data/picture-in-textframe.rtf new file mode 100644 index 000000000000..ec0a07690bdf --- /dev/null +++ b/writerfilter/qa/cppunittests/rtftok/data/picture-in-textframe.rtf @@ -0,0 +1,29 @@ +{\rtf1 +\paperw10080\paperh12960\margl1066\margr1066\margt1642\margb1066 +\pard\plain +{\shp +{\*\shpinst\shpleft31\shptop105\shpright4108\shpbottom3887\shpfhdr0\shpwr2\shpwrk3\shpfblwtxt0 +{\sp +{\sn shapeType} +{\sv 202} +} +{\shptxt \pard\plain +before +{\*\shppict +{\pict +{\*\picprop\shplid1025 +{\sp +{\sn shapeType} +{\sv 75} +} +} +\picscalex23\picscaley24\piccropl0\piccropr0\piccropt0\piccropb0\picw30372\pich22437\picwgoal17219\pichgoal12720\pngblip +47494638396110001000d5ff00000000ffffffc0c0c0555f00ffffaafcfcfcf6f6f6eaeaeae6e6e6e4e4e4e3e3e3c2c2c2c1c1c1bcbcbcb5b5b5b3b3b3b0b0b0adadada5a5a5a2a2a2a1a1a19f9f9f9494948a8a8a8888888686867b7b7b6c6c6c5c5c5c4e4e4e4b4b4b4747474646463d3d3d3c3c3c2e2e2e2525251b1b1b18181810101009090906060603030300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021f90401000002002c0000000010001000000684408170482c0a06c8a4728924389f506833b281302a8e6b164b18103024c52111504cca67332102e0042e9a40d9319f8300a343c1200f54e47f7e2a00001e0b0a7d0d728a010d838400261a7c0d94947784252700127e9d159f6c8411140019080ea7a9a85f842122281612b1b3b25d6b1f29291d0fbbbdbc5d5e51c34e4cc64a46c94341003b +} +} +after\par +} +} +} +\par +} diff --git a/writerfilter/qa/cppunittests/rtftok/rtfsdrimport.cxx b/writerfilter/qa/cppunittests/rtftok/rtfsdrimport.cxx new file mode 100644 index 000000000000..64c679f6e5cc --- /dev/null +++ b/writerfilter/qa/cppunittests/rtftok/rtfsdrimport.cxx @@ -0,0 +1,71 @@ +/* -*- 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/frame/Desktop.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/text/TextContentAnchorType.hpp> + +using namespace ::com::sun::star; + +namespace +{ +/// Tests for writerfilter/source/rtftok/rtfsdrimport.cxx. +class Test : public test::BootstrapFixture, public unotest::MacrosTest +{ +private: + 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(); + + mxDesktop.set(frame::Desktop::create(mxComponentContext)); +} + +void Test::tearDown() +{ + if (mxComponent.is()) + mxComponent->dispose(); + + test::BootstrapFixture::tearDown(); +} + +char const DATA_DIRECTORY[] = "/writerfilter/qa/cppunittests/rtftok/data/"; + +CPPUNIT_TEST_FIXTURE(Test, testPictureInTextframe) +{ + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "picture-in-textframe.rtf"; + getComponent() = loadFromDesktop(aURL); + uno::Reference<drawing::XDrawPageSupplier> xTextDocument(getComponent(), uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xTextDocument->getDrawPage(); + uno::Reference<beans::XPropertySet> xInnerShape(xDrawPage->getByIndex(1), uno::UNO_QUERY); + text::TextContentAnchorType eAnchorType = text::TextContentAnchorType_AT_PARAGRAPH; + xInnerShape->getPropertyValue("AnchorType") >>= eAnchorType; + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 4 + // i.e. the properties of the inner shape (including its anchor type and bitmap fill) were lost + // on import. + CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER, eAnchorType); +} +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 7c4209a9ea8e..1ecde8a8a684 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -1126,6 +1126,11 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap m_rImport.Mapper().endShape(); } } + + // If the shape has an inner shape, the inner object's properties should not be influenced by + // the outer one. + rShape.getProperties().clear(); + m_xShape = xShape; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits