summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-02-17 14:35:54 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-02-18 20:34:26 +0100
commit66344e5917fc224c1bfd396694b637c853f3b091 (patch)
tree9d2aa7984e4be5811dd92961fc72a6d0fd0a0861 /writerfilter
parent7d722e6d9809959a2f48a456d157882b7f1778d8 (diff)
DOCX import: don't touch the ZOrder of inline, in-shape objects
1) This is not needed: Word only supports inline "anchoring" in textboxes. 2) If the textbox has a certain ZOrder, we don't want the inline shapes to be behind the textbox. 3) This allows restoring the old assert in sw_ooxmlexport7 that was changed in commit 99847d6b3005c5444ed5a46ca578c0e40149d77c (DOCX import: fix ZOrder of inline vs anchored shapes, 2020-02-12). (cherry picked from commit 70ae12fe0b9e33633fc62cf805c261ef51fb4b59) Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport7.cxx Change-Id: I817e4fb70cb789e8eb116219050fc1aeaec76667 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88944 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx17
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/inline-inshape-anchored-zorder.docxbin0 -> 17243 bytes
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx2
-rw-r--r--writerfilter/source/dmapper/DomainMapper.hxx1
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx3
5 files changed, 22 insertions, 1 deletions
diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
index 8d86397a1698..92f059b9760a 100644
--- a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
@@ -87,6 +87,23 @@ CPPUNIT_TEST_FIXTURE(Test, testInlineAnchoredZOrder)
// 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());
}
+
+CPPUNIT_TEST_FIXTURE(Test, testInlineInShapeAnchoredZOrder)
+{
+ // This document has a textbox shape and then an inline shape inside that.
+ // The ZOrder of the inline shape is larger than the hosting textbox, so the image is visible.
+ OUString aURL
+ = m_directories.getURLFromSrc(DATA_DIRECTORY) + "inline-inshape-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: Picture 1
+ // - Actual : Text Box 2
+ // i.e. the image was behind the textbox that was hosting it.
+ CPPUNIT_ASSERT_EQUAL(OUString("Picture 1"), xOval->getName());
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/qa/cppunittests/dmapper/data/inline-inshape-anchored-zorder.docx b/writerfilter/qa/cppunittests/dmapper/data/inline-inshape-anchored-zorder.docx
new file mode 100644
index 000000000000..3792285f4849
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/inline-inshape-anchored-zorder.docx
Binary files differ
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 3fdce0712914..ccd2e1f85859 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3735,6 +3735,8 @@ bool DomainMapper::IsInHeaderFooter() const
return m_pImpl->IsInHeaderFooter();
}
+bool DomainMapper::IsInShape() const { return m_pImpl->IsInShape(); }
+
bool DomainMapper::IsInTable() const
{
return m_pImpl->hasTableManager() && m_pImpl->getTableManager().isInCell();
diff --git a/writerfilter/source/dmapper/DomainMapper.hxx b/writerfilter/source/dmapper/DomainMapper.hxx
index e7a52764bf94..bd7247f84a4c 100644
--- a/writerfilter/source/dmapper/DomainMapper.hxx
+++ b/writerfilter/source/dmapper/DomainMapper.hxx
@@ -110,6 +110,7 @@ public:
bool IsInHeaderFooter() const;
bool IsInTable() const;
bool IsStyleSheetImport() const;
+ bool IsInShape() const;
void hasControls( const bool bSet ) { mbHasControls = bSet; }
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index b8c370cb84e9..d30f59055cef 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -283,7 +283,8 @@ public:
,m_rAligns(rAligns)
,m_rPositivePercentages(rPositivePercentages)
{
- if (eGraphicImportType == GraphicImportType::IMPORT_AS_DETECTED_INLINE)
+ if (eGraphicImportType == GraphicImportType::IMPORT_AS_DETECTED_INLINE
+ && !rDMapper.IsInShape())
{
zOrder = 0;
}