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

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 25 12:44:57 UTC 2021


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

New commits:
commit 2fa5cabd48724ed6fc5009ec19c155d6160f3f7b
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sun Jul 5 17:20:49 2020 +0300
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Thu Feb 25 13:44:24 2021 +0100

    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>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111537
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

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 ab0d53861d3e..0f2488520221 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 ) )
@@ -1059,7 +1059,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 );
@@ -1203,7 +1203,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
@@ -1409,7 +1409,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)
@@ -1484,7 +1484,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 );
@@ -1862,7 +1862,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);
 
@@ -1891,7 +1891,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;
@@ -1954,7 +1954,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);
@@ -2127,7 +2127,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