[Libreoffice-commits] core.git: oox/source sw/qa
Regényi Balázs (via logerrit)
logerrit at kemper.freedesktop.org
Fri Oct 9 08:31:56 UTC 2020
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 7b2f0094f86266c64972d3e505a28b2d4e5caef6
Author: Regényi Balázs <regenyi.balazs at nisz.hu>
AuthorDate: Tue Oct 6 15:52:18 2020 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Fri Oct 9 10:31:20 2020 +0200
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>
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 215d56595ebc..00a44d3fccfa 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1309,19 +1309,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, GetShapeName(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 );
+ 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, GetShapeName(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);
@@ -1336,7 +1346,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 200d34033ede..ec359b119b58 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -1152,6 +1152,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