[Libreoffice-commits] core.git: include/sax oox/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Sun Jul 5 20:14:50 UTC 2020


 include/sax/fshelper.hxx     |   13 +++++++++++++
 oox/source/export/shapes.cxx |   24 ++++++++++++------------
 2 files changed, 25 insertions(+), 12 deletions(-)

New commits:
commit 57afeb8d9e35933630568a02fc48a00f5582b261
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Jul 5 17:20:49 2020 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Jul 5 22:14:12 2020 +0200

    Allow use OUString as attribute value in FastSerializerHelper::*Element
    
    Change-Id: Id34d08787d0188d5c7847dcb75958a511a1fef27
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98143
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/include/sax/fshelper.hxx b/include/sax/fshelper.hxx
index b38689a5927f..235181bf9846 100644
--- a/include/sax/fshelper.hxx
+++ b/include/sax/fshelper.hxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/xml/sax/XFastAttributeList.hpp>
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/ustring.hxx>
 #include <sax/saxdllapi.h>
 #include <memory>
 #include <utility>
@@ -62,6 +63,12 @@ public:
         pushAttributeValue(attribute, value);
         startElement(elementTokenId, std::forward<Args>(args)...);
     }
+    template<typename... Args>
+    void startElement(sal_Int32 elementTokenId, sal_Int32 attribute, const OUString& value, Args&&... args)
+    {
+        // The temporary created by toUtf8() must stay alive until startElement() ends using it
+        startElement(elementTokenId, attribute, value.toUtf8(), std::forward<Args>(args)...);
+    }
     void startElement(sal_Int32 elementTokenId);
 
     /// Start an element. After the first two arguments there can be a number of (attribute, value) pairs.
@@ -85,6 +92,12 @@ public:
         pushAttributeValue(attribute, value);
         singleElement(elementTokenId, std::forward<Args>(args)...);
     }
+    template<typename... Args>
+    void singleElement(sal_Int32 elementTokenId, sal_Int32 attribute, const OUString& value, Args&&... args)
+    {
+        // The temporary created by toUtf8() must stay alive until singleElement() ends using it
+        singleElement(elementTokenId, attribute, value.toUtf8(), std::forward<Args>(args)...);
+    }
     void singleElement(sal_Int32 elementTokenId);
 
     /// Create a single element. After the first two arguments there can be a number of (attribute, value) pairs.
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 3ea0ae57ba6b..eb5eedff1d89 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -414,7 +414,7 @@ ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& xSha
         pFS->startElementNS(mnXmlNamespace, XML_nvSpPr);
         pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
                               XML_id, OString::number(GetNewShapeID(xShape)),
-                              XML_name, GetShapeName(xShape).toUtf8());
+                              XML_name, GetShapeName(xShape));
     }
     pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr);
     if (GetDocumentType() != DOCUMENT_DOCX)
@@ -475,7 +475,7 @@ ShapeExport& ShapeExport::WriteGroupShape(const uno::Reference<drawing::XShape>&
         pFS->startElementNS(mnXmlNamespace, XML_nvGrpSpPr);
         pFS->singleElementNS(mnXmlNamespace, XML_cNvPr,
                 XML_id, OString::number(GetNewShapeID(xShape)),
-                XML_name, GetShapeName(xShape).toUtf8());
+                XML_name, GetShapeName(xShape));
         pFS->singleElementNS(mnXmlNamespace, XML_cNvGrpSpPr);
         WriteNonVisualProperties(xShape );
         pFS->endElementNS(mnXmlNamespace, XML_nvGrpSpPr);
@@ -801,7 +801,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape )
         pFS->startElementNS( mnXmlNamespace, XML_nvSpPr );
         pFS->startElementNS( mnXmlNamespace, XML_cNvPr,
                 XML_id, OString::number(GetNewShapeID(xShape)),
-                XML_name, GetShapeName(xShape).toUtf8(),
+                XML_name, GetShapeName(xShape),
                 XML_hidden, isVisible ? nullptr : "1" );
 
         if( GETA( URL ) )
@@ -1049,7 +1049,7 @@ ShapeExport& ShapeExport::WriteEllipseShape( const Reference< XShape >& xShape )
         pFS->startElementNS(mnXmlNamespace, XML_nvSpPr);
         pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
                 XML_id, OString::number(GetNewShapeID(xShape)),
-                XML_name, GetShapeName(xShape).toUtf8());
+                XML_name, GetShapeName(xShape));
         pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr );
         WriteNonVisualProperties( xShape );
         pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
@@ -1193,7 +1193,7 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape
 
     pFS->startElementNS( mnXmlNamespace, XML_cNvPr,
                           XML_id,     OString::number(GetNewShapeID(xShape)),
-                          XML_name,   GetShapeName(xShape).toUtf8(),
+                          XML_name,   GetShapeName(xShape),
                           XML_descr,  bHaveDesc ? sDescr.toUtf8().getStr() : nullptr );
 
     // OOXTODO: //cNvPr children: XML_extLst, XML_hlinkHover
@@ -1337,7 +1337,7 @@ ShapeExport& ShapeExport::WriteConnectorShape( const Reference< XShape >& xShape
     pFS->startElementNS(mnXmlNamespace, XML_nvCxnSpPr);
     pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
                           XML_id, OString::number(GetNewShapeID(xShape)),
-                          XML_name, GetShapeName(xShape).toUtf8());
+                          XML_name, GetShapeName(xShape));
     // non visual connector shape drawing properties
     pFS->startElementNS(mnXmlNamespace, XML_cNvCxnSpPr);
     WriteConnectorConnections( aConnectorEntry, GetShapeID( rXShapeA ), GetShapeID( rXShapeB ) );
@@ -1389,7 +1389,7 @@ ShapeExport& ShapeExport::WriteLineShape( const Reference< XShape >& xShape )
         pFS->startElementNS(mnXmlNamespace, XML_nvSpPr);
         pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
                               XML_id, OString::number(GetNewShapeID(xShape)),
-                              XML_name, GetShapeName(xShape).toUtf8());
+                              XML_name, GetShapeName(xShape));
     }
     pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr );
     if (GetDocumentType() != DOCUMENT_DOCX)
@@ -1464,7 +1464,7 @@ ShapeExport& ShapeExport::WriteRectangleShape( const Reference< XShape >& xShape
     pFS->startElementNS(mnXmlNamespace, XML_nvSpPr);
     pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
                           XML_id, OString::number(GetNewShapeID(xShape)),
-                          XML_name, GetShapeName(xShape).toUtf8());
+                          XML_name, GetShapeName(xShape));
     pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr);
     WriteNonVisualProperties( xShape );
     pFS->endElementNS( mnXmlNamespace, XML_nvSpPr );
@@ -1841,7 +1841,7 @@ ShapeExport& ShapeExport::WriteTableShape( const Reference< XShape >& xShape )
 
     pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
                           XML_id, OString::number(GetNewShapeID(xShape)),
-                          XML_name,   GetShapeName(xShape).toUtf8());
+                          XML_name,   GetShapeName(xShape));
 
     pFS->singleElementNS(mnXmlNamespace, XML_cNvGraphicFramePr);
 
@@ -1870,7 +1870,7 @@ ShapeExport& ShapeExport::WriteTextShape( const Reference< XShape >& xShape )
         pFS->startElementNS(mnXmlNamespace, XML_nvSpPr);
         pFS->startElementNS(mnXmlNamespace, XML_cNvPr,
                               XML_id, OString::number(GetNewShapeID(xShape)),
-                              XML_name, GetShapeName(xShape).toUtf8());
+                              XML_name, GetShapeName(xShape));
         OUString sURL;
         if (GetProperty(xShapeProps, "URL"))
             mAny >>= sURL;
@@ -1933,7 +1933,7 @@ void ShapeExport::WriteMathShape(Reference<XShape> const& xShape)
     mpFS->startElementNS(mnXmlNamespace, XML_nvSpPr);
     mpFS->singleElementNS(mnXmlNamespace, XML_cNvPr,
          XML_id, OString::number(GetNewShapeID(xShape)),
-         XML_name, GetShapeName(xShape).toUtf8());
+         XML_name, GetShapeName(xShape));
     mpFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr, XML_txBox, "1");
     mpFS->singleElementNS(mnXmlNamespace, XML_nvPr);
     mpFS->endElementNS(mnXmlNamespace, XML_nvSpPr);
@@ -2106,7 +2106,7 @@ ShapeExport& ShapeExport::WriteOLE2Shape( const Reference< XShape >& xShape )
 
     mpFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
                            XML_id,     OString::number(GetNewShapeID(xShape)),
-                           XML_name,   GetShapeName(xShape).toUtf8());
+                           XML_name,   GetShapeName(xShape));
 
     mpFS->singleElementNS(mnXmlNamespace, XML_cNvGraphicFramePr);
 


More information about the Libreoffice-commits mailing list