summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-01-11 21:03:34 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2022-06-23 18:33:21 +0200
commit1b85634e315263b0aa51da8aa07033b802073078 (patch)
tree1f4da64b4e12f8e46177c2cbce374e72cfc32dac
parenttdf#135976 sw: preserve flys on backspace/delete with redlining enabled (diff)
downloadcore-1b85634e315263b0aa51da8aa07033b802073078.tar.gz
core-1b85634e315263b0aa51da8aa07033b802073078.zip
tdf#138995 DOCX import: fix handling of textbox zorders
Regression from commit d379d18666aa42031359ca8eb34b0021960347ae (oox: import WPS shape with text as shape with textbox, 2014-06-18), the problem was that a textbox's shape + textframe are internally 2 sdr objects, so once GraphicZOrderHelper knows the current shape should be on top of a shape+frame pair, it should suggest a larger ZOrder. This is necessary till there is no setter version of SwTextBoxHelper::getOrdNum(), which would allow import filters to ignore this complexity, but that would be a larger change. (cherry picked from commit 200cd2b99bee18962a970edc5d059286f6c3ea0e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109184 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit a4a301c67f4de992d2f4bc66721abd21ebd67494) Change-Id: Ibbb1bcd9301eb369f25f211120f62be7c59b0fd2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136308 Tested-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r--sw/CppunitTest_sw_core_doc.mk1
-rw-r--r--sw/qa/core/doc/data/textbox-zorder.docxbin0 -> 5407 bytes
-rw-r--r--sw/qa/core/doc/doc.cxx16
-rw-r--r--writerfilter/source/dmapper/GraphicHelpers.cxx14
4 files changed, 31 insertions, 0 deletions
diff --git a/sw/CppunitTest_sw_core_doc.mk b/sw/CppunitTest_sw_core_doc.mk
index 856f007cb9b1..071d2901122a 100644
--- a/sw/CppunitTest_sw_core_doc.mk
+++ b/sw/CppunitTest_sw_core_doc.mk
@@ -24,6 +24,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_core_doc, \
editeng \
sal \
sfx \
+ svxcore \
sw \
test \
unotest \
diff --git a/sw/qa/core/doc/data/textbox-zorder.docx b/sw/qa/core/doc/data/textbox-zorder.docx
new file mode 100644
index 000000000000..d5263f8bbd6b
--- /dev/null
+++ b/sw/qa/core/doc/data/textbox-zorder.docx
Binary files differ
diff --git a/sw/qa/core/doc/doc.cxx b/sw/qa/core/doc/doc.cxx
index 72895861f713..381e873ed7b9 100644
--- a/sw/qa/core/doc/doc.cxx
+++ b/sw/qa/core/doc/doc.cxx
@@ -82,6 +82,22 @@ CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testTextboxTextRotateAngle)
ErrorRegistry::Reset();
}
+CPPUNIT_TEST_FIXTURE(SwCoreDocTest, testTextBoxZOrder)
+{
+ SwDoc* pDoc = createDoc("textbox-zorder.docx");
+ SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), rFormats.size());
+ const SwFrameFormat* pEllipse = rFormats[2];
+ const SdrObject* pEllipseShape = pEllipse->FindRealSdrObject();
+ // Make sure we test the right shape.
+ CPPUNIT_ASSERT_EQUAL(OUString("Shape3"), pEllipseShape->GetName());
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 2
+ // - Actual : 1
+ // i.e. the ellipse was under the frame of the shape-frame pair, not on top of it.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(2), pEllipseShape->GetOrdNum());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx
index 9168ad51eebd..0ea364cbff85 100644
--- a/writerfilter/source/dmapper/GraphicHelpers.cxx
+++ b/writerfilter/source/dmapper/GraphicHelpers.cxx
@@ -291,6 +291,20 @@ sal_Int32 GraphicZOrderHelper::findZOrder( sal_Int32 relativeHeight, bool bOldSt
return 0;
--it;
itemZOrderOffset = 1; // after the topmost
+
+ // Check if this shape has a textbox. If so, the textbox will have its own ZOrder, so
+ // suggest a larger offset.
+ bool bTextBox = false;
+ uno::Reference<beans::XPropertySet> xShape = it->second;
+ uno::Reference<beans::XPropertySetInfo> xInfo = xShape->getPropertySetInfo();
+ if (xInfo->hasPropertyByName("TextBox"))
+ {
+ xShape->getPropertyValue("TextBox") >>= bTextBox;
+ }
+ if (bTextBox)
+ {
+ ++itemZOrderOffset;
+ }
}
// SwXFrame::getPropertyValue throws uno::RuntimeException
// when its GetFrameFormat() returns nullptr