summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2020-11-09 18:54:18 +0300
committerMiklos Vajna <vmiklos@collabora.com>2020-11-12 10:57:04 +0100
commitaaf931335b39cc788a544994fb0712286c4d998e (patch)
tree11f8a3d8456dc924a0f46ffd03b917e80364fb0b
parenta5389cb5ddcd72e494040e7a976c4f290e2da4cc (diff)
tdf#137850 writerfilter compatibilityMode15: ignore behindDoc if wrapped
This patch is based on testing results, since I couldn't find anything in the documentation that indicated a change between Word 2010 and Word 2013. But the evidence is fairly clear I think. To quote from MS documentation on relativeHeight: > This attribute shall only indicate the Z-order with respect to other objects > in the document which have an identical behindDoc attribute value. > _All_ objects with a behindDoc value of false shall be displayed > above elements with a value of true. But only wrapNone makes mention of being affected by behindDoc, so apparently MS decided to ignore it for some reason starting in Word 2013. By simply changing the compatibiltyMode value to one lower, Word 2013 again starts to honour the behindDoc setting. Change-Id: I7ef40387707ab5376cf8fa4d8a208c5b6a8b37ed Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105486 Tested-by: Jenkins Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf137850_compat14ZOrder.docxbin0 -> 24821 bytes
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/tdf137850_compat15ZOrder.docxbin0 -> 24816 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport15.cxx18
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx17
4 files changed, 35 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf137850_compat14ZOrder.docx b/sw/qa/extras/ooxmlexport/data/tdf137850_compat14ZOrder.docx
new file mode 100644
index 000000000000..ab2715c1a2cd
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf137850_compat14ZOrder.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/data/tdf137850_compat15ZOrder.docx b/sw/qa/extras/ooxmlexport/data/tdf137850_compat15ZOrder.docx
new file mode 100755
index 000000000000..07158e4c7383
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf137850_compat15ZOrder.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 07f2e06288f9..b9ae69668c6d 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -105,6 +105,24 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133334_followPgStyle, "tdf133334_followPgStyle.o
CPPUNIT_ASSERT_EQUAL(2, getPages());
}
+DECLARE_OOXMLEXPORT_TEST(testTdf137850_compat14ZOrder, "tdf137850_compat14ZOrder.docx")
+{
+ // The file contains 2 shapes which have a different value of behindDoc.
+ // Test that the textbox is hidden behind the arrow (for Word <= 2010/compatibilityMode==14)
+ uno::Reference<text::XText> xShape(getShape(2), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("2015"), xShape->getString());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Textbox is in the background", false, getProperty<bool>(xShape, "Opaque"));
+}
+
+DECLARE_OOXMLEXPORT_TEST(testTdf137850_compat15ZOrder, "tdf137850_compat15ZOrder.docx")
+{
+ // The file contains 2 shapes which have a different value of behindDoc.
+ // Test that the textbox is not hidden behind the arrow (for Word >= 2013/compatibilityMode==15)
+ uno::Reference<text::XText> xShape(getShape(2), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("2015"), xShape->getString());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Textbox is in the foreground", true, getProperty<bool>(xShape, "Opaque"));
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf88126, "tdf88126.docx")
{
// Without the fix in place, this test would have hung
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index ac62a161fe2a..59c972ec8429 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1136,6 +1136,20 @@ void GraphicImport::lcl_sprm(Sprm& rSprm)
m_pImpl->m_aInteropGrabBag["EG_WrapType"] <<= OUString("wrapTight");
else if (nSprmId == NS_ooxml::LN_EG_WrapType_wrapThrough)
m_pImpl->m_aInteropGrabBag["EG_WrapType"] <<= OUString("wrapThrough");
+
+ switch (nSprmId)
+ {
+ case NS_ooxml::LN_EG_WrapType_wrapSquare:
+ case NS_ooxml::LN_EG_WrapType_wrapThrough:
+ case NS_ooxml::LN_EG_WrapType_wrapTight:
+ {
+ // tdf#137850: Word >= 2013 seems to ignore bBehindDoc except for wrapNone, but older versions honour it.
+ if (m_pImpl->bBehindDoc && m_pImpl->rDomainMapper.GetSettingsTable()->GetWordCompatibilityMode() > 14)
+ m_pImpl->bOpaque = true;
+ }
+ break;
+ }
+
}
break;
case NS_ooxml::LN_CT_WrapTight_wrapPolygon:
@@ -1247,6 +1261,9 @@ void GraphicImport::lcl_sprm(Sprm& rSprm)
m_pImpl->nBottomMargin = 0;
break;
case NS_ooxml::LN_EG_WrapType_wrapTopAndBottom: // 90948;
+ // tdf#137850: Word >= 2013 seems to ignore bBehindDoc except for wrapNone, but older versions honour it.
+ if (m_pImpl->bBehindDoc && m_pImpl->rDomainMapper.GetSettingsTable()->GetWordCompatibilityMode() > 14)
+ m_pImpl->bOpaque = true;
m_pImpl->nWrap = text::WrapTextMode_NONE;
break;
case NS_ooxml::LN_CT_GraphicalObject_graphicData:// 90660;