[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - oox/source sw/qa

Regényi Balázs (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 24 14:04:40 UTC 2021


 oox/source/export/shapes.cxx                          |   36 +++++++++++-------
 sw/qa/extras/ooxmlexport/data/tdf99810-lost-arrow.odt |binary
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx             |   10 +++++
 3 files changed, 33 insertions(+), 13 deletions(-)

New commits:
commit 72be5a9973d4df86e74e8e8c836fa5e372ecb56e
Author:     Regényi Balázs <regenyi.balazs at nisz.hu>
AuthorDate: Tue Oct 6 15:52:18 2020 +0200
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Wed Feb 24 15:04:03 2021 +0100

    tdf#99810 DOCX export: fix lost arrow shape
    
    by saving connector shape as shape element
    wps:wps instead of the invalid wps:cxnSp.
    
    Co-author-by: Szabolcs Tóth
    
    Change-Id: I0ed435eff8e4284f04f71f8fa8c1dc4cfbee5af9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104032
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 7b2f0094f86266c64972d3e505a28b2d4e5caef6)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111453
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 6828bc629152..8a86bb07152c 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1347,19 +1347,29 @@ ShapeExport& ShapeExport::WriteConnectorShape( const Reference< XShape >& xShape
         aRect.setHeight( aStartPoint.Y - aEndPoint.Y );
     }
 
-    pFS->startElementNS(mnXmlNamespace, XML_cxnSp);
+    // tdf#99810 connector shape (cxnSp) is not valid with namespace 'wps'
+    const auto nShapeNode = (mnXmlNamespace == XML_wps ? XML_wsp : XML_cxnSp);
+    pFS->startElementNS(mnXmlNamespace, nShapeNode);
 
-    // non visual shape properties
-    pFS->startElementNS(mnXmlNamespace, XML_nvCxnSpPr);
-    pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
-                          XML_id, OString::number(GetNewShapeID(xShape)),
-                          XML_name, IDS( Line ) );
-    // non visual connector shape drawing properties
-    pFS->startElementNS(mnXmlNamespace, XML_cNvCxnSpPr);
-    WriteConnectorConnections( aConnectorEntry, GetShapeID( rXShapeA ), GetShapeID( rXShapeB ) );
-    pFS->endElementNS( mnXmlNamespace, XML_cNvCxnSpPr );
-    pFS->singleElementNS(mnXmlNamespace, XML_nvPr);
-    pFS->endElementNS( mnXmlNamespace, XML_nvCxnSpPr );
+    if (mnXmlNamespace == XML_wps)
+    {
+        // non visual connector shape drawing properties
+        pFS->singleElementNS(mnXmlNamespace, XML_cNvCnPr);
+    }
+    else
+    {
+        // non visual shape properties
+        pFS->startElementNS(mnXmlNamespace, XML_nvCxnSpPr);
+        pFS->singleElementNS(mnXmlNamespace, XML_cNvPr,
+            XML_id, OString::number(GetNewShapeID(xShape)),
+            XML_name, IDS(xShape));
+        // non visual connector shape drawing properties
+        pFS->startElementNS(mnXmlNamespace, XML_cNvCxnSpPr);
+        WriteConnectorConnections(aConnectorEntry, GetShapeID(rXShapeA), GetShapeID(rXShapeB));
+        pFS->endElementNS(mnXmlNamespace, XML_cNvCxnSpPr);
+        pFS->singleElementNS(mnXmlNamespace, XML_nvPr);
+        pFS->endElementNS(mnXmlNamespace, XML_nvCxnSpPr);
+    }
 
     // visual shape properties
     pFS->startElementNS(mnXmlNamespace, XML_spPr);
@@ -1374,7 +1384,7 @@ ShapeExport& ShapeExport::WriteConnectorShape( const Reference< XShape >& xShape
     // write text
     WriteTextBox( xShape, mnXmlNamespace );
 
-    pFS->endElementNS( mnXmlNamespace, XML_cxnSp );
+    pFS->endElementNS(mnXmlNamespace, nShapeNode);
 
     return *this;
 }
diff --git a/sw/qa/extras/ooxmlexport/data/tdf99810-lost-arrow.odt b/sw/qa/extras/ooxmlexport/data/tdf99810-lost-arrow.odt
new file mode 100644
index 000000000000..20e60f6cef06
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf99810-lost-arrow.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 61ba601ed1c5..3848bc0f5d13 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -1200,6 +1200,16 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testBodyPrUpright, "tdf123610_handle_upright
         "/a:graphic/a:graphicData/wps:wsp/wps:bodyPr", "upright", "1");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testLostArrow, "tdf99810-lost-arrow.odt")
+{
+    // tdf#99810: check whether we use normal shape instead of connector shape if the XML namespace
+    // is wps, because wps:
+    xmlDocUniquePtr pDoc = parseExport("word/document.xml");
+
+    assertXPath(pDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor"
+        "/a:graphic/a:graphicData/wps:wsp");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list