[Libreoffice-commits] core.git: sw/qa writerfilter/qa writerfilter/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Mon Feb 17 18:06:54 UTC 2020
sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 2 -
writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx | 17 ++++++++++
writerfilter/qa/cppunittests/dmapper/data/inline-inshape-anchored-zorder.docx |binary
writerfilter/source/dmapper/DomainMapper.cxx | 2 +
writerfilter/source/dmapper/DomainMapper.hxx | 1
writerfilter/source/dmapper/GraphicImport.cxx | 3 +
6 files changed, 23 insertions(+), 2 deletions(-)
New commits:
commit 70ae12fe0b9e33633fc62cf805c261ef51fb4b59
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Feb 17 14:35:54 2020 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Feb 17 19:06:19 2020 +0100
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).
Change-Id: I817e4fb70cb789e8eb116219050fc1aeaec76667
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88873
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index e057f4e1c856..344b493dae4b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -564,7 +564,7 @@ DECLARE_OOXMLEXPORT_TEST(test76317, "test76317.docx")
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(fdo76591, "fdo76591.docx")
{
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
- assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[3]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]", "relativeHeight", "4");
+ assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[3]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]", "relativeHeight", "3");
}
DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(test76317_2K10, "test76317_2K10.docx")
diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
index f825ea1d7510..c148ee518833 100644
--- a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
@@ -102,6 +102,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
Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/inline-inshape-anchored-zorder.docx differ
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 68179bf31f82..d17f1978cb8f 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3854,6 +3854,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 0742c44d5c04..0fbd2eaf7455 100644
--- a/writerfilter/source/dmapper/DomainMapper.hxx
+++ b/writerfilter/source/dmapper/DomainMapper.hxx
@@ -112,6 +112,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 17691cb1c8b5..7c4c9d37eb04 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -292,7 +292,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;
}
More information about the Libreoffice-commits
mailing list