writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx | 18 ++++++++++++ writerfilter/qa/cppunittests/dmapper/data/chart-zorder.docx |binary writerfilter/source/dmapper/DomainMapper_Impl.cxx | 3 ++ 3 files changed, 21 insertions(+)
New commits: commit 482adfc9dd5c08dae2a51d93ee579efa7df6e862 Author: Miklos Vajna <[email protected]> AuthorDate: Mon Oct 18 19:54:07 2021 +0200 Commit: Xisco Fauli <[email protected]> CommitDate: Tue Oct 19 17:34:30 2021 +0200 tdf#144798 DOCX import: handle ZOrder of chart objects Regression from commit 10efab2b9a3cf7fc49655c90ba29db4512680c38 (tdf#82824 DOCX import: fix at-char embedded object handling, 2016-11-15), the problem was that if we start supporting anchor types other than as-char, then handling ZOrder is no longer optional. (cherry picked from commit 63007619da7e6c4a6d0c466a8fe54324252be14b) Change-Id: I605cee33180490817055978b22f3271b3c08a1c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123794 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx index ef4c8ed40fb0..3719a09e3323 100644 --- a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx @@ -18,6 +18,7 @@ #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/XTextTablesSupplier.hpp> #include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <vcl/scheduler.hxx> @@ -212,6 +213,23 @@ CPPUNIT_TEST_FIXTURE(Test, testCreateDatePreserve) // i.e. the formatting of the create date field was lost. CPPUNIT_ASSERT_EQUAL(OUString("7/7/2020 10:11:00 AM"), xPortion->getString()); } + +CPPUNIT_TEST_FIXTURE(Test, testChartZOrder) +{ + // Given a document with a chart and a shape on it: + OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "chart-zorder.docx"; + + // When loading the document: + getComponent() = loadFromDesktop(aURL); + + // Then make sure the shape is on top of the chart: + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(getComponent(), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<lang::XServiceInfo> xChart(xDrawPage->getByIndex(0), uno::UNO_QUERY); + // Without the accompanying fix in place, this test would have failed, as the chart was on top + // of the shape. + CPPUNIT_ASSERT(xChart->supportsService("com.sun.star.text.TextEmbeddedObject")); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/qa/cppunittests/dmapper/data/chart-zorder.docx b/writerfilter/qa/cppunittests/dmapper/data/chart-zorder.docx new file mode 100644 index 000000000000..e022a3bde266 Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/chart-zorder.docx differ diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 46bf027d293a..3af37fc28f59 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -7308,6 +7308,9 @@ void DomainMapper_Impl::ImportGraphic(const writerfilter::Reference< Properties xEmbeddedProps->setPropertyValue("VertOrientRelation", xShapeProps->getPropertyValue("VertOrientRelation")); //tdf123873 fix missing textwrap import xEmbeddedProps->setPropertyValue("TextWrap", xShapeProps->getPropertyValue("TextWrap")); + + // GraphicZOrderHelper::findZOrder() was called already, so can just copy it over. + xEmbeddedProps->setPropertyValue("ZOrder", xShapeProps->getPropertyValue("ZOrder")); } } //insert it into the document at the current cursor position
