summaryrefslogtreecommitdiff
path: root/writerfilter/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-02-12 15:02:18 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-02-12 21:34:28 +0100
commit99847d6b3005c5444ed5a46ca578c0e40149d77c (patch)
tree7352dc4f228d150fe2a7edfcbbd4eb074edf1c70 /writerfilter/qa
parent7155d0011ecde39c9ea27ef19d475686d80574ee (diff)
DOCX import: fix ZOrder of inline vs anchored shapes
Shapes which are anchored but are not in the background should be always on top of as-char anchored shapes in OOXML terms. Writer supports a custom ZOrder even for as-char shapes, so make sure that they are always behind anchored shapes. To avoid unnecessary work, make sure that when there are multiple inline shapes, we don't pointlessly reorder them (the old vs new style of the sorting controls exactly this, what happens when two shapes have the same ZOrder, and all inline shapes have a 0 ZOrder). Adapt a few tests that used ZOrder indexes to access shapes, but the intention was to just refer to a shape: fix the index and migrate to shape names where possible. Change-Id: I670e4dc2acbd2a0c6d47fe964cb5e3f2300e6848 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88540 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'writerfilter/qa')
-rw-r--r--writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx17
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/inline-anchored-zorder.docxbin0 -> 16684 bytes
2 files changed, 17 insertions, 0 deletions
diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
index 73f863b02100..f825ea1d7510 100644
--- a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
@@ -16,6 +16,7 @@
#include <com/sun/star/table/BorderLine2.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextTablesSupplier.hpp>
+#include <com/sun/star/container/XNamed.hpp>
#include <comphelper/processfactory.hxx>
@@ -85,6 +86,22 @@ CPPUNIT_TEST_FIXTURE(Test, testDrawShapeInlineEffect)
// i.e. the layout result had less pages than expected (compared to Word).
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(273), nBottomMargin);
}
+
+CPPUNIT_TEST_FIXTURE(Test, testInlineAnchoredZOrder)
+{
+ // Load a document which has two shapes: an inline one and an anchored one. The inline has no
+ // explicit ZOrder, the anchored one has, and it's set to a value so it's visible.
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "inline-anchored-zorder.docx";
+ getComponent() = loadFromDesktop(aURL);
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY);
+ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+ uno::Reference<container::XNamed> xOval(xDrawPage->getByIndex(1), uno::UNO_QUERY);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: Oval 2
+ // - Actual :
+ // i.e. the rectangle (with no name) was on top of the oval one, not the other way around.
+ CPPUNIT_ASSERT_EQUAL(OUString("Oval 2"), xOval->getName());
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/qa/cppunittests/dmapper/data/inline-anchored-zorder.docx b/writerfilter/qa/cppunittests/dmapper/data/inline-anchored-zorder.docx
new file mode 100644
index 000000000000..93932c4703b7
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/inline-anchored-zorder.docx
Binary files differ