[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - sw/qa writerfilter/qa writerfilter/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 12 08:14:02 UTC 2020


 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx                            |    4 +-
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx                            |    4 +-
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx                             |    4 --
 sw/qa/extras/ooxmlexport/ooxmlexport7.cxx                             |    4 --
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx                             |    2 -
 writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx                |   17 ++++++++++
 writerfilter/qa/cppunittests/dmapper/data/inline-anchored-zorder.docx |binary
 writerfilter/source/dmapper/GraphicImport.cxx                         |   12 +++++--
 8 files changed, 34 insertions(+), 13 deletions(-)

New commits:
commit d51a41cd56b4663c00111250bb0a72d839b92860
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Feb 12 15:02:18 2020 +0100
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Fri Jun 12 10:13:30 2020 +0200

    DOCX import: fix ZOrder of inline vs anchored shapes
    
    Shapes which are anchored but are not in the background should be always
    on top of as-char anchored shapes in OOXML terms. Writer supports a
    custom ZOrder even for as-char shapes, so make sure that they are
    always behind anchored shapes.
    
    To avoid unnecessary work, make sure that when there are multiple inline
    shapes, we don't pointlessly reorder them (the old vs new style of the
    sorting controls exactly this, what happens when two shapes have the
    same ZOrder, and all inline shapes have a 0 ZOrder).
    
    Adapt a few tests that used ZOrder indexes to access shapes, but the
    intention was to just refer to a shape: fix the index and migrate to
    shape names where possible.
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88540
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 99847d6b3005c5444ed5a46ca578c0e40149d77c)
    
    Change-Id: I670e4dc2acbd2a0c6d47fe964cb5e3f2300e6848
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96131
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 86b5ce6e4c28..a5f3ae30e3eb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -501,11 +501,11 @@ DECLARE_OOXMLEXPORT_TEST(testStrict, "strict.docx")
     getParagraphOfText(1, xHeaderText, "This is a header.");
 
     // Picture was missing.
-    uno::Reference<lang::XServiceInfo> xServiceInfo(getShape(1), uno::UNO_QUERY);
+    uno::Reference<lang::XServiceInfo> xServiceInfo(getShapeByName("Picture 2"), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextGraphicObject"));
 
     // SmartArt was missing.
-    xServiceInfo.set(getShape(2), uno::UNO_QUERY);
+    xServiceInfo.set(getShape(1), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"));
 
     // Chart was missing.
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 47db568932bd..bd1e15081434 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -479,10 +479,10 @@ DECLARE_OOXMLEXPORT_TEST(testTdf119201, "tdf119201.docx")
     auto xShape(getShape(1));
     CPPUNIT_ASSERT_MESSAGE("First shape should be visible.", getProperty<bool>(xShape, "Visible"));
     CPPUNIT_ASSERT_MESSAGE("First shape should be printable.", getProperty<bool>(xShape, "Printable"));
-    xShape = getShape(2);
+    xShape = getShapeByName("Rectangle 1");
     CPPUNIT_ASSERT_MESSAGE("Second shape should not be visible.", !getProperty<bool>(xShape, "Visible"));
     CPPUNIT_ASSERT_MESSAGE("Second shape should not be printable.", !getProperty<bool>(xShape, "Printable"));
-    xShape = getShape(3);
+    xShape = getShapeByName("Oval 2");
     CPPUNIT_ASSERT_MESSAGE("Third shape should be visible.", getProperty<bool>(xShape, "Visible"));
     CPPUNIT_ASSERT_MESSAGE("Third shape should be printable.", getProperty<bool>(xShape, "Printable"));
 }
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 29d4d54534f8..93a65a57fc45 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -1084,9 +1084,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf102466, "tdf102466.docx")
 
     // check content of the first page
     {
-        uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
-        uno::Reference<container::XIndexAccess> xIndexAccess = xDrawPageSupplier->getDrawPage();
-        uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+        uno::Reference<beans::XPropertySet> xFrame(getShapeByName("Marco1"), uno::UNO_QUERY);
 
         // no border
         CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xFrame, "LineWidth"));
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
index b673c06a3d2a..77d09469eceb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
@@ -584,9 +584,7 @@ DECLARE_OOXMLEXPORT_TEST(test76317, "test76317.docx")
 DECLARE_OOXMLEXPORT_TEST(fdo76591, "fdo76591.docx")
 {
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
-    if (!pXmlDoc)
-        return;
-    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");
+    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");
 }
 
 DECLARE_OOXMLEXPORT_TEST(test76317_2K10, "test76317_2K10.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 6e9d628763b1..6a70ab6d7408 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -576,7 +576,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf103573, "tdf103573.docx")
 
 DECLARE_OOXMLEXPORT_TEST(testTdf106132, "tdf106132.docx")
 {
-    uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xShape(getShapeByName("Frame1"), uno::UNO_QUERY);
     // This was 250, <wps:bodyPr ... rIns="0" ...> was ignored for an outer shape.
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xShape, "TextRightDistance"));
 }
diff --git a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
index d2143a2366c4..a22304d256ac 100644
--- a/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/GraphicImport.cxx
@@ -17,6 +17,7 @@
 #include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/text/XTextTablesSupplier.hpp>
 #include <com/sun/star/text/RelOrientation.hpp>
+#include <com/sun/star/container/XNamed.hpp>
 
 #include <comphelper/processfactory.hxx>
 
@@ -90,6 +91,22 @@ CPPUNIT_TEST_FIXTURE(Test, testRelfromhInsidemargin)
     xShape->getPropertyValue("PageToggle") >>= bPageToggle;
     CPPUNIT_ASSERT(bPageToggle);
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testInlineAnchoredZOrder)
+{
+    // Load a document which has two shapes: an inline one and an anchored one. The inline has no
+    // explicit ZOrder, the anchored one has, and it's set to a value so it's visible.
+    OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "inline-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: Oval 2
+    // - Actual  :
+    // 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());
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/qa/cppunittests/dmapper/data/inline-anchored-zorder.docx b/writerfilter/qa/cppunittests/dmapper/data/inline-anchored-zorder.docx
new file mode 100644
index 000000000000..93932c4703b7
Binary files /dev/null and b/writerfilter/qa/cppunittests/dmapper/data/inline-anchored-zorder.docx differ
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 174674ae46a0..78572a40d964 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -289,7 +289,12 @@ public:
         ,m_rPositionOffsets(rPositionOffsets)
         ,m_rAligns(rAligns)
         ,m_rPositivePercentages(rPositivePercentages)
-    {}
+    {
+        if (eGraphicImportType == GraphicImportType::IMPORT_AS_DETECTED_INLINE)
+        {
+            zOrder = 0;
+        }
+    }
 
     void setXSize(sal_Int32 _nXSize)
     {
@@ -360,7 +365,8 @@ public:
         if (zOrder >= 0)
         {
             GraphicZOrderHelper* pZOrderHelper = rDomainMapper.graphicZOrderHelper();
-            xGraphicObjectProperties->setPropertyValue(getPropertyName(PROP_Z_ORDER), uno::makeAny(pZOrderHelper->findZOrder(zOrder)));
+            bool bOldStyle = eGraphicImportType == GraphicImportType::IMPORT_AS_DETECTED_INLINE;
+            xGraphicObjectProperties->setPropertyValue(getPropertyName(PROP_Z_ORDER), uno::makeAny(pZOrderHelper->findZOrder(zOrder, bOldStyle)));
             pZOrderHelper->addItem(xGraphicObjectProperties, zOrder);
         }
     }
@@ -911,6 +917,8 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
                     else if (bUseShape && m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_INLINE)
                     {
                         uno::Reference< beans::XPropertySet > xShapeProps(m_xShape, uno::UNO_QUERY_THROW);
+                        m_pImpl->applyMargins(xShapeProps);
+                        m_pImpl->applyZOrder(xShapeProps);
                         comphelper::SequenceAsHashMap aInteropGrabBag(xShapeProps->getPropertyValue("InteropGrabBag"));
                         aInteropGrabBag.update(m_pImpl->getInteropGrabBag());
                         xShapeProps->setPropertyValue("InteropGrabBag", uno::makeAny(aInteropGrabBag.getAsConstPropertyValueList()));


More information about the Libreoffice-commits mailing list