[Libreoffice-commits] core.git: xmloff/CppunitTest_xmloff_draw.mk xmloff/Module_xmloff.mk xmloff/qa xmloff/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Wed Aug 12 11:19:33 UTC 2020
xmloff/CppunitTest_xmloff_draw.mk | 45 +++++++++++++++++++
xmloff/Module_xmloff.mk | 1
xmloff/qa/unit/data/textbox-loss.docx |binary
xmloff/qa/unit/draw.cxx | 79 ++++++++++++++++++++++++++++++++++
xmloff/source/draw/shapeexport.cxx | 14 ------
5 files changed, 127 insertions(+), 12 deletions(-)
New commits:
commit 347d05edd8910907ae185c61c1e56eee139b3c09
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Aug 12 09:06:14 2020 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Aug 12 13:18:55 2020 +0200
tdf#135144 xmloff textbox: fix export style name to be consitent with import
Regression from commit 28d67b792724a23015dec32fb0278b729f676736
(tdf#107776 sw ODF shape import: make is-textbox check more strict,
2019-08-26), the problem was that in case the import side in
SdXMLCustomShapeContext expects a fixed "Frame" parent style name, then
the export side should go with that name as well.
Fix the problem by simplifying XMLShapeExport::collectShapeAutoStyles(),
which initially assumed that the string may be localized, so try to look
it up: instead just use the fixed string that the import side will look
for.
This solves all problem which may stem from a parent style name which is
non-empty, but other than Frame.
Change-Id: I8146440c591d3dd5a904d243d85741d704711e9c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100577
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/xmloff/CppunitTest_xmloff_draw.mk b/xmloff/CppunitTest_xmloff_draw.mk
new file mode 100644
index 000000000000..4ebac5c27a3b
--- /dev/null
+++ b/xmloff/CppunitTest_xmloff_draw.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,xmloff_draw))
+
+$(eval $(call gb_CppunitTest_use_externals,xmloff_draw,\
+ boost_headers \
+))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,xmloff_draw, \
+ xmloff/qa/unit/draw \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,xmloff_draw, \
+ comphelper \
+ cppu \
+ embobj \
+ sal \
+ test \
+ unotest \
+ utl \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,xmloff_draw))
+
+$(eval $(call gb_CppunitTest_use_ure,xmloff_draw))
+$(eval $(call gb_CppunitTest_use_vcl,xmloff_draw))
+
+$(eval $(call gb_CppunitTest_use_rdb,xmloff_draw,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,xmloff_draw,\
+ officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,xmloff_draw))
+
+# vim: set noet sw=4 ts=4:
diff --git a/xmloff/Module_xmloff.mk b/xmloff/Module_xmloff.mk
index fe69b86b09f6..8f5853c9da41 100644
--- a/xmloff/Module_xmloff.mk
+++ b/xmloff/Module_xmloff.mk
@@ -31,6 +31,7 @@ $(eval $(call gb_Module_add_check_targets,xmloff,\
CppunitTest_xmloff_uxmloff) \
CppunitTest_xmloff_style \
CppunitTest_xmloff_text \
+ CppunitTest_xmloff_draw \
))
$(eval $(call gb_Module_add_subsequentcheck_targets,xmloff,\
diff --git a/xmloff/qa/unit/data/textbox-loss.docx b/xmloff/qa/unit/data/textbox-loss.docx
new file mode 100644
index 000000000000..9190e662f851
Binary files /dev/null and b/xmloff/qa/unit/data/textbox-loss.docx differ
diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx
new file mode 100644
index 000000000000..afffa65354e0
--- /dev/null
+++ b/xmloff/qa/unit/draw.cxx
@@ -0,0 +1,79 @@
+/* -*- 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/frame/XStorable.hpp>
+
+#include <unotools/mediadescriptor.hxx>
+#include <unotools/tempfile.hxx>
+
+using namespace ::com::sun::star;
+
+char const DATA_DIRECTORY[] = "/xmloff/qa/unit/data/";
+
+/// Covers xmloff/source/draw/ fixes.
+class XmloffDrawTest : 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 XmloffDrawTest::setUp()
+{
+ test::BootstrapFixture::setUp();
+
+ mxDesktop.set(frame::Desktop::create(mxComponentContext));
+}
+
+void XmloffDrawTest::tearDown()
+{
+ if (mxComponent.is())
+ mxComponent->dispose();
+
+ test::BootstrapFixture::tearDown();
+}
+
+CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextBoxLoss)
+{
+ // Load a document that has a shape with a textbox in it. Save it to ODF and reload.
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "textbox-loss.docx";
+ getComponent() = loadFromDesktop(aURL);
+ uno::Reference<frame::XStorable> xStorable(getComponent(), uno::UNO_QUERY);
+ utl::TempFile aTempFile;
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= OUString("writer8");
+ xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
+ getComponent()->dispose();
+ getComponent() = loadFromDesktop(aTempFile.GetURL());
+
+ // Make sure that the shape is still a textbox.
+ 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);
+ bool bTextBox = false;
+ xShape->getPropertyValue("TextBox") >>= bTextBox;
+
+ // Without the accompanying fix in place, this test would have failed, as the shape only had
+ // editeng text, loosing the image part of the shape text.
+ CPPUNIT_ASSERT(bTextBox);
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx
index 5365ce26dc1c..26ef683e0650 100644
--- a/xmloff/source/draw/shapeexport.cxx
+++ b/xmloff/source/draw/shapeexport.cxx
@@ -382,18 +382,8 @@ void XMLShapeExport::collectShapeAutoStyles(const uno::Reference< drawing::XShap
if (aParentName.isEmpty() && xPropertySetInfo->hasPropertyByName("TextBox") && xPropSet->getPropertyValue("TextBox").hasValue() && xPropSet->getPropertyValue("TextBox").get<bool>())
{
// Shapes with a Writer TextBox always have a parent style.
- // If there would be none, then just assign the first available.
- uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(GetExport().GetModel(), uno::UNO_QUERY);
- if (xStyleFamiliesSupplier.is()) // tdf#108231
- {
- uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
- uno::Reference<container::XNameAccess> xFrameStyles = xStyleFamilies->getByName("FrameStyles").get< uno::Reference<container::XNameAccess> >();
- uno::Sequence<OUString> aFrameStyles = xFrameStyles->getElementNames();
- if (aFrameStyles.hasElements())
- {
- aParentName = aFrameStyles[0];
- }
- }
+ // If there would be none, then assign the default one.
+ aParentName = "Frame";
}
// filter propset
More information about the Libreoffice-commits
mailing list