summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-01-13 20:08:54 +0100
committerMichael Stahl <michael.stahl@cib.de>2020-01-14 14:24:59 +0100
commit0424ae2df464cbcf8997a85b53daeaded462b429 (patch)
tree66107c53c6d471be2276579f11df51e706e43bf1 /oox
parent352ab705a8b97414ac3fe95419473299811104a7 (diff)
tdf#129516 DOCX import: fix incorrect z-order with textboxes
Commit 3272c1eb5563f3bda2caa24f32b1018372622109 (related tdf#100074: prepare group shapes text input via writerfilter, 2018-10-01) tweaked the oox code, so that later it'll be able to call back to writerfilter to parse group shape text. That makes sense, but it also removed the reset of the group shape context, which means that two subsequent group shapes are now imported as a single group shape with a merged child list. Reset the group shape context again when writerfilter asks for the XShape from oox. If this causes a problem for the above scenario later, then it could be considered to handle this in ShapeContextHandler::endFastElement(). (cherry picked from commit 5960c6f4ca9dd6ab4b4081d3be7253468cd212c4) Change-Id: I14f7f0bab2c66c8430313d5b2daffe3160a58c27 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86746 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Diffstat (limited to 'oox')
-rw-r--r--oox/CppunitTest_oox_shape.mk45
-rw-r--r--oox/Module_oox.mk1
-rw-r--r--oox/qa/unit/data/multiple-group-shapes.docxbin0 -> 29653 bytes
-rw-r--r--oox/qa/unit/shape.cxx84
-rw-r--r--oox/source/shape/ShapeContextHandler.cxx1
5 files changed, 131 insertions, 0 deletions
diff --git a/oox/CppunitTest_oox_shape.mk b/oox/CppunitTest_oox_shape.mk
new file mode 100644
index 000000000000..9ae7bbd634cd
--- /dev/null
+++ b/oox/CppunitTest_oox_shape.mk
@@ -0,0 +1,45 @@
+# -*- 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,oox_shape))
+
+$(eval $(call gb_CppunitTest_use_externals,oox_shape,\
+ boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,oox_shape, \
+ oox/qa/unit/shape \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,oox_shape, \
+ comphelper \
+ cppu \
+ oox \
+ sal \
+ test \
+ unotest \
+ utl \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,oox_shape))
+
+$(eval $(call gb_CppunitTest_use_ure,oox_shape))
+$(eval $(call gb_CppunitTest_use_vcl,oox_shape))
+
+$(eval $(call gb_CppunitTest_use_rdb,oox_shape,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,oox_shape,\
+ officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,oox_shape))
+
+# vim: set noet sw=4 ts=4:
diff --git a/oox/Module_oox.mk b/oox/Module_oox.mk
index 6bcc596c14ab..540b9a8d2ba0 100644
--- a/oox/Module_oox.mk
+++ b/oox/Module_oox.mk
@@ -27,6 +27,7 @@ $(eval $(call gb_Module_add_check_targets,oox,\
CppunitTest_oox_crypto \
CppunitTest_oox_mathml \
CppunitTest_oox_vml \
+ CppunitTest_oox_shape \
))
# vim: set noet sw=4 ts=4:
diff --git a/oox/qa/unit/data/multiple-group-shapes.docx b/oox/qa/unit/data/multiple-group-shapes.docx
new file mode 100644
index 000000000000..c751bcdf650b
--- /dev/null
+++ b/oox/qa/unit/data/multiple-group-shapes.docx
Binary files differ
diff --git a/oox/qa/unit/shape.cxx b/oox/qa/unit/shape.cxx
new file mode 100644
index 000000000000..27d26aa91b57
--- /dev/null
+++ b/oox/qa/unit/shape.cxx
@@ -0,0 +1,84 @@
+/* -*- 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/XDrawPagesSupplier.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/text/WritingMode2.hpp>
+
+#include <comphelper/embeddedobjectcontainer.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/propertyvalue.hxx>
+#include <comphelper/scopeguard.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <unotools/mediadescriptor.hxx>
+#include <unotools/tempfile.hxx>
+
+using namespace ::com::sun::star;
+
+char const DATA_DIRECTORY[] = "/oox/qa/unit/data/";
+
+/// oox shape tests.
+class OoxShapeTest : 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 load(const OUString& rURL);
+};
+
+void OoxShapeTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxComponentContext.set(comphelper::getComponentContext(getMultiServiceFactory()));
+ mxDesktop.set(frame::Desktop::create(mxComponentContext));
+}
+
+void OoxShapeTest::tearDown()
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+
+ test::BootstrapFixture::tearDown();
+}
+
+void OoxShapeTest::load(const OUString& rFileName)
+{
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + rFileName;
+ mxComponent = loadFromDesktop(aURL);
+}
+
+CPPUNIT_TEST_FIXTURE(OoxShapeTest, testMultipleGroupShapes)
+{
+ load("multiple-group-shapes.docx");
+
+ uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
+ uno::UNO_QUERY);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 2
+ // - Actual : 1
+ // i.e. the 2 group shapes from the document were imported as a single one.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xDrawPage->getCount());
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index 23041d6cee48..1a1aafa5cf38 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -500,6 +500,7 @@ ShapeContextHandler::getShape()
pShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aMatrix, pShape->getFillProperties());
xResult = pShape->getXShape();
mxSavedShape = xResult;
+ mxWpgContext.clear();
}
}
else if (mpShape.get() != nullptr)