diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-12-23 10:55:05 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-12-23 14:31:28 +0100 |
commit | 747cf9f95f8f97062f9d4566910f97529fbeedc4 (patch) | |
tree | 3764b1867eccd80b118d5457a4725c7575994f37 /xmloff | |
parent | 554bd2927f525450e96a12e733f16c86c76ac8e6 (diff) |
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@redhat.com>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/inc/txtfldi.hxx | 10 | ||||
-rw-r--r-- | xmloff/inc/txtvfldi.hxx | 4 | ||||
-rw-r--r-- | xmloff/source/text/txtfldi.cxx | 29 | ||||
-rw-r--r-- | xmloff/source/text/txtvfldi.cxx | 4 |
4 files changed, 24 insertions, 23 deletions
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) : |