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

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Fri Oct 4 10:40:44 UTC 2019


 include/sax/fshelper.hxx             |    1 +
 oox/source/export/vmlexport.cxx      |    4 ++--
 sax/source/tools/fshelper.cxx        |    6 ++++++
 sc/source/filter/excel/xecontent.cxx |    2 +-
 sc/source/filter/excel/xeextlst.cxx  |    2 +-
 sc/source/filter/excel/xestream.cxx  |   27 ---------------------------
 sc/source/filter/inc/xestream.hxx    |   12 +++++++++---
 7 files changed, 20 insertions(+), 34 deletions(-)

New commits:
commit 59e5d2c8839ee6bf2bb237c0db4a618cb98b2dd9
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Fri Oct 4 11:55:05 2019 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Fri Oct 4 12:40:06 2019 +0200

    Deduplicate some serializer writing code, and simplify writing OString
    
    Change-Id: I391f8cb499a83f1f774fdcaa794169a218bdc7e5
    Reviewed-on: https://gerrit.libreoffice.org/80189
    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 8169ce5ea166..773ce6892e26 100644
--- a/include/sax/fshelper.hxx
+++ b/include/sax/fshelper.hxx
@@ -131,6 +131,7 @@ public:
         { startElement( FSNS( namespaceTokenId, elementTokenId ), xAttrList ); }
 
     FastSerializerHelper* write(const char* value);
+    FastSerializerHelper* write(const OString& value);
     FastSerializerHelper* write(const OUString& value);
     FastSerializerHelper* write(sal_Int32 value);
     FastSerializerHelper* write(sal_Int64 value);
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index eaf761a5d168..0bc408f3ef1c 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -1189,7 +1189,7 @@ sal_Int32 VMLExport::StartShape()
                         "<v:path shadowok=\"f\" o:extrusionok=\"f\" strokeok=\"f\" fillok=\"f\" o:connecttype=\"rect\"/>\n"
                         "<o:lock v:ext=\"edit\" shapetype=\"t\"/>\n"
                         "</v:shapetype>");
-                m_pSerializer->write(sShapeType.makeStringAndClear().getStr());
+                m_pSerializer->write(sShapeType.makeStringAndClear());
                 m_aShapeTypeWritten[ m_nShapeType ] = true;
             }
             break;
@@ -1224,7 +1224,7 @@ sal_Int32 VMLExport::StartShape()
                         "<v:path o:extrusionok=\"f\" gradientshapeok=\"t\" o:connecttype=\"rect\"/>\n"
                         "<o:lock v:ext=\"edit\" aspectratio=\"t\"/>\n"
                         "</v:shapetype>");
-                m_pSerializer->write(sShapeType.makeStringAndClear().getStr());
+                m_pSerializer->write(sShapeType.makeStringAndClear());
                 m_aShapeTypeWritten[ m_nShapeType ] = true;
             }
             break;
diff --git a/sax/source/tools/fshelper.cxx b/sax/source/tools/fshelper.cxx
index 383d4a794bbc..0d265fe36d24 100644
--- a/sax/source/tools/fshelper.cxx
+++ b/sax/source/tools/fshelper.cxx
@@ -81,6 +81,12 @@ FastSerializerHelper* FastSerializerHelper::write(const char* value)
     return this;
 }
 
+FastSerializerHelper* FastSerializerHelper::write(const OString& value)
+{
+    mpSerializer->write(value);
+    return this;
+}
+
 FastSerializerHelper* FastSerializerHelper::write(const OUString& value)
 {
     mpSerializer->write(value);
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 444b737d038c..c61425647e59 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1507,7 +1507,7 @@ void XclExpDataBar::SaveXml( XclExpXmlStream& rStrm )
         XML_uri, "{B025F937-C7B1-47D3-B67F-A62EFF666E3E}");
 
     rWorksheet->startElementNS( XML_x14, XML_id );
-    rWorksheet->write( maGUID.getStr() );
+    rWorksheet->write(maGUID);
     rWorksheet->endElementNS( XML_x14, XML_id );
 
     rWorksheet->endElement( XML_ext );
diff --git a/sc/source/filter/excel/xeextlst.cxx b/sc/source/filter/excel/xeextlst.cxx
index 2d74db8b25dd..c2764b43da26 100644
--- a/sc/source/filter/excel/xeextlst.cxx
+++ b/sc/source/filter/excel/xeextlst.cxx
@@ -464,7 +464,7 @@ void XclExpExtConditionalFormatting::SaveXml( XclExpXmlStream& rStrm )
 
     maCfRules.SaveXml( rStrm );
     rWorksheet->startElementNS(XML_xm, XML_sqref);
-    rWorksheet->write(XclXmlUtils::ToOString(maRange).getStr());
+    rWorksheet->write(XclXmlUtils::ToOString(maRange));
 
     rWorksheet->endElementNS( XML_xm, XML_sqref );
 
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 98444d6ca0b4..937a7d0c8ed2 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -813,33 +813,6 @@ OUString XclXmlUtils::ToOUString( const XclExpString& s )
     return ToOUString( s.GetUnicodeBuffer() );
 }
 
-sax_fastparser::FSHelperPtr XclXmlUtils::WriteElement( sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, sal_Int32 nValue )
-{
-    pStream->startElement(nElement);
-    pStream->write( nValue );
-    pStream->endElement( nElement );
-
-    return pStream;
-}
-
-sax_fastparser::FSHelperPtr XclXmlUtils::WriteElement( sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, sal_Int64 nValue )
-{
-    pStream->startElement(nElement);
-    pStream->write( nValue );
-    pStream->endElement( nElement );
-
-    return pStream;
-}
-
-sax_fastparser::FSHelperPtr XclXmlUtils::WriteElement( sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, const char* sValue )
-{
-    pStream->startElement(nElement);
-    pStream->write( sValue );
-    pStream->endElement( nElement );
-
-    return pStream;
-}
-
 static void lcl_WriteValue( const sax_fastparser::FSHelperPtr& rStream, sal_Int32 nElement, const char* pValue )
 {
     if( !pValue )
diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx
index 72239ef829a7..36e1543f5269 100644
--- a/sc/source/filter/inc/xestream.hxx
+++ b/sc/source/filter/inc/xestream.hxx
@@ -265,9 +265,15 @@ public:
     static OUString ToOUString( sc::CompileFormulaContext& rCtx, const ScAddress& rAddress, const ScTokenArray* pTokenArray );
     static OUString ToOUString( const XclExpString& s );
 
-    static sax_fastparser::FSHelperPtr  WriteElement( sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, sal_Int32 nValue );
-    static sax_fastparser::FSHelperPtr  WriteElement( sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, sal_Int64 nValue );
-    static sax_fastparser::FSHelperPtr  WriteElement( sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, const char* sValue );
+    template <class T>
+    static sax_fastparser::FSHelperPtr WriteElement(sax_fastparser::FSHelperPtr pStream, sal_Int32 nElement, const T& value)
+    {
+        pStream->startElement(nElement);
+        pStream->write(value);
+        pStream->endElement(nElement);
+
+        return pStream;
+    }
     static sax_fastparser::FSHelperPtr  WriteFontData( sax_fastparser::FSHelperPtr pStream, const XclFontData& rFontData, sal_Int32 nNameId );
 };
 


More information about the Libreoffice-commits mailing list