[Libreoffice-commits] core.git: sw/qa writerfilter/source

Justin Luth (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 12 09:57:44 UTC 2020


 sw/qa/extras/ooxmlexport/data/tdf137850_compat14ZOrder.docx |binary
 sw/qa/extras/ooxmlexport/data/tdf137850_compat15ZOrder.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx                  |   18 ++++++++++++
 writerfilter/source/dmapper/GraphicImport.cxx               |   17 +++++++++++
 4 files changed, 35 insertions(+)

New commits:
commit aaf931335b39cc788a544994fb0712286c4d998e
Author:     Justin Luth <justin_luth at sil.org>
AuthorDate: Mon Nov 9 18:54:18 2020 +0300
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Nov 12 10:57:04 2020 +0100

    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 at sil.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

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
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf137850_compat14ZOrder.docx 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
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf137850_compat15ZOrder.docx 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;


More information about the Libreoffice-commits mailing list