[Libreoffice-commits] core.git: xmloff/inc xmloff/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Wed Dec 23 13:32:17 UTC 2020


 xmloff/inc/txtfldi.hxx          |   10 +++++-----
 xmloff/inc/txtvfldi.hxx         |    4 ++--
 xmloff/source/text/txtfldi.cxx  |   29 +++++++++++++++--------------
 xmloff/source/text/txtvfldi.cxx |    4 ++--
 4 files changed, 24 insertions(+), 23 deletions(-)

New commits:
commit 747cf9f95f8f97062f9d4566910f97529fbeedc4
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Dec 23 10:55:05 2020 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Dec 23 14:31:28 2020 +0100

    Directly create strings in *::MapTokenToServiceName
    
    ...and pass them into XMLTextFieldImportContext and derived ctors.  The assert
    in the XMLTextFieldImportContext ctor is moved up to the two
    MapTokenToServiceName functions.
    
    Change-Id: I75c76cd6129e79ad54ea87e7d3419ca49679875d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108235
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/xmloff/inc/txtfldi.hxx b/xmloff/inc/txtfldi.hxx
index 6b3aa3365568..8f7e248bddd9 100644
--- a/xmloff/inc/txtfldi.hxx
+++ b/xmloff/inc/txtfldi.hxx
@@ -66,7 +66,7 @@ public:
     XMLTextFieldImportContext(
         SvXMLImport& rImport,                   /// XML Import
         XMLTextImportHelper& rHlp,              /// Text import helper
-        const char* pService);                  /// name of SO API service
+        const OUString& pService);              /// name of SO API service
 
     /// process character data: will be collected in member sContentBuffer
     virtual void SAL_CALL characters( const OUString& sContent ) override;
@@ -327,7 +327,7 @@ protected:
     /// protected constructor: only for subclasses
     XMLDatabaseFieldImportContext(SvXMLImport& rImport,
                                   XMLTextImportHelper& rHlp,
-                                  const char* pServiceName,
+                                  const OUString& pServiceName,
                                   bool bUseDisplay );
 
 public:
@@ -371,7 +371,7 @@ protected:
     // for use in child classes
     XMLDatabaseNextImportContext(SvXMLImport& rImport,
                                  XMLTextImportHelper& rHlp,
-                                 const char* pServiceName);
+                                 const OUString& pServiceName);
 
 public:
 
@@ -463,7 +463,7 @@ protected:
     virtual void PrepareField(
         const css::uno::Reference< css::beans::XPropertySet> & xPropertySet) override;
 
-    static const char* MapTokenToServiceName(sal_Int32 nElementToken);
+    static OUString MapTokenToServiceName(sal_Int32 nElementToken);
 };
 
 /** import docinfo fields with date or time attributes and numberformats */
@@ -711,7 +711,7 @@ private:
     virtual void PrepareField(
         const css::uno::Reference<css::beans::XPropertySet> & xPropertySet) override;
 
-    static const char* MapTokenToServiceName(sal_Int32 nElement);
+    static OUString MapTokenToServiceName(sal_Int32 nElement);
 };
 
 /** import page variable fields (<text:get-page-variable>) */
diff --git a/xmloff/inc/txtvfldi.hxx b/xmloff/inc/txtvfldi.hxx
index 67bc233b77cb..8a288bdfb436 100644
--- a/xmloff/inc/txtvfldi.hxx
+++ b/xmloff/inc/txtvfldi.hxx
@@ -137,7 +137,7 @@ public:
         // for XMLTextFieldImportContext:
         SvXMLImport& rImport,           /// XML Import
         XMLTextImportHelper& rHlp,      /// text import helper
-        const char* pServiceName,   /// name of SO API service
+        const OUString& pServiceName, /// name of SO API service
         // config variables for PrepareField behavior:
         bool bFormula,              /// set Formula property
         bool bFormulaDefault,       /// use content as default for formula
@@ -232,7 +232,7 @@ public:
         // for XMLTextFieldImportContext:
         SvXMLImport& rImport,           /// see XMLTextFieldImportContext
         XMLTextImportHelper& rHlp,      /// see XMLTextFieldImportContext
-        const char* pServiceName,   /// see XMLTextFieldImportContext
+        const OUString& pServiceName, /// see XMLTextFieldImportContext
         // for finding appropriate field master (see endFastElement())
         VarType eVarType,               /// variable type
         // config variables:
diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx
index dd73a5d9395b..0c65d17b1d67 100644
--- a/xmloff/source/text/txtfldi.cxx
+++ b/xmloff/source/text/txtfldi.cxx
@@ -23,6 +23,11 @@
  *  Import of all text fields except those from txtvfldi.cxx
  *  (variable related text fields and database display fields)
  */
+
+#include <sal/config.h>
+
+#include <cassert>
+
 #include <txtfldi.hxx>
 #include <txtvfldi.hxx>
 #include <xmloff/xmlimp.hxx>
@@ -118,14 +123,13 @@ const char sAPI_true[] = "TRUE";
 
 XMLTextFieldImportContext::XMLTextFieldImportContext(
     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
-    const char* pService)
+    const OUString& pService)
 :   SvXMLImportContext( rImport )
+,   sServiceName(pService)
 ,   rTextImportHelper(rHlp)
 ,   sServicePrefix(sAPI_textfield_prefix)
 ,   bValid(false)
 {
-    assert(nullptr != pService && "Need service name!");
-    sServiceName = OUString::createFromAscii(pService);
 }
 
 void XMLTextFieldImportContext::startFastElement(
@@ -1094,7 +1098,7 @@ constexpr OUStringLiteral gsPropertyIsVisible(u"IsVisible");
 
 XMLDatabaseFieldImportContext::XMLDatabaseFieldImportContext(
     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
-    const char* pServiceName, bool bUseDisplay)
+    const OUString& pServiceName, bool bUseDisplay)
 :   XMLTextFieldImportContext(rImport, rHlp, pServiceName)
 ,   m_nCommandType( sdb::CommandType::TABLE )
 ,   m_bCommandTypeOK(false)
@@ -1238,7 +1242,7 @@ void XMLDatabaseNameImportContext::ProcessAttribute(
 
 XMLDatabaseNextImportContext::XMLDatabaseNextImportContext(
     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
-    const char* pServiceName) :
+    const OUString& pServiceName) :
         XMLDatabaseFieldImportContext(rImport, rHlp, pServiceName, false),
         sPropertyCondition(sAPI_condition),
         sTrue(sAPI_true),
@@ -1478,10 +1482,10 @@ void XMLSimpleDocInfoImportContext::PrepareField(
     }
 }
 
-const char* XMLSimpleDocInfoImportContext::MapTokenToServiceName(
+OUString XMLSimpleDocInfoImportContext::MapTokenToServiceName(
     sal_Int32 nElementToken)
 {
-    const char* pServiceName = nullptr;
+    OUString pServiceName;
 
     switch(nElementToken)
     {
@@ -1536,8 +1540,7 @@ const char* XMLSimpleDocInfoImportContext::MapTokenToServiceName(
 
         default:
             XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElementToken);
-            pServiceName = nullptr;
-            break;
+            assert(false);
     }
 
     return pServiceName;
@@ -2209,10 +2212,10 @@ void XMLCountFieldImportContext::PrepareField(
     xPropertySet->setPropertyValue(sPropertyNumberingType, Any(nNumType));
 }
 
-const char* XMLCountFieldImportContext::MapTokenToServiceName(
+OUString XMLCountFieldImportContext::MapTokenToServiceName(
     sal_Int32 nElement)
 {
-    const char* pServiceName = nullptr;
+    OUString pServiceName;
 
     switch (nElement)
     {
@@ -2239,9 +2242,7 @@ const char* XMLCountFieldImportContext::MapTokenToServiceName(
             break;
         default:
             XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
-            pServiceName = nullptr;
-            OSL_FAIL("unknown count field!");
-            break;
+            assert(false);
     }
 
     return pServiceName;
diff --git a/xmloff/source/text/txtvfldi.cxx b/xmloff/source/text/txtvfldi.cxx
index bc59faa149fb..790844cef1bd 100644
--- a/xmloff/source/text/txtvfldi.cxx
+++ b/xmloff/source/text/txtvfldi.cxx
@@ -80,7 +80,7 @@ using namespace ::xmloff::token;
 
 XMLVarFieldImportContext::XMLVarFieldImportContext(
     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
-    const char* pServiceName,
+    const OUString& pServiceName,
     bool bFormula, bool bFormulaDefault,
     bool bDescription, bool bHelp, bool bHint, bool bVisible,
     bool bIsDisplayFormula,
@@ -246,7 +246,7 @@ void XMLVarFieldImportContext::PrepareField(
 
 XMLSetVarFieldImportContext::XMLSetVarFieldImportContext(
     SvXMLImport& rImport, XMLTextImportHelper& rHlp,
-    const char* pServiceName, VarType eVarType,
+    const OUString& pServiceName, VarType eVarType,
     bool bFormula, bool bFormulaDefault,
     bool bDescription, bool bHelp, bool bHint, bool bVisible, bool bIsDisplayFormula,
     bool bType, bool bStyle, bool bValue, bool bPresentation) :


More information about the Libreoffice-commits mailing list