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

Noel (via logerrit) logerrit at kemper.freedesktop.org
Thu Dec 17 13:06:00 UTC 2020


 include/xmloff/xmluconv.hxx                   |   12 ++++++------
 reportdesign/source/filter/xml/xmlGroup.cxx   |    2 +-
 reportdesign/source/filter/xml/xmlSection.cxx |    2 +-
 reportdesign/source/filter/xml/xmlTable.cxx   |    2 +-
 xmloff/inc/txtflde.hxx                        |    2 +-
 xmloff/source/chart/SchXMLTools.cxx           |    2 +-
 xmloff/source/chart/SchXMLTools.hxx           |    2 +-
 xmloff/source/core/xmluconv.cxx               |   16 +++++++++-------
 xmloff/source/text/XMLAnchorTypePropHdl.hxx   |    2 +-
 xmloff/source/text/XMLSectionExport.cxx       |    2 +-
 xmloff/source/text/XMLSectionExport.hxx       |    2 +-
 xmloff/source/text/txtflde.cxx                |    6 +++---
 xmloff/source/text/txtprhdl.cxx               |    2 +-
 13 files changed, 28 insertions(+), 26 deletions(-)

New commits:
commit 95283f63fd1095121c30f7fc23259f03a5382955
Author:     Noel <noelgrandin at gmail.com>
AuthorDate: Thu Dec 17 13:33:39 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Dec 17 14:05:21 2020 +0100

    use more string_view in SvXMLUnitConverter
    
    Change-Id: Id40a071e1abf0bf2e13217e8745fdf266010c1c0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107872
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/xmloff/xmluconv.hxx b/include/xmloff/xmluconv.hxx
index 40edab42cdfd..3a9950edbd64 100644
--- a/include/xmloff/xmluconv.hxx
+++ b/include/xmloff/xmluconv.hxx
@@ -136,7 +136,7 @@ public:
         not found in the map, this method will return false */
     template<typename EnumT>
     static bool convertEnum( EnumT& rEnum,
-                             const OUString& rValue,
+                             std::u16string_view rValue,
                              const SvXMLEnumMapEntry<EnumT> *pMap )
     {
         sal_uInt16 nTmp;
@@ -151,7 +151,7 @@ public:
         not found in the map, this method will return false */
     template<typename EnumT>
     static bool convertEnum( EnumT& rEnum,
-                             const OUString& rValue,
+                             std::u16string_view rValue,
                              const SvXMLEnumStringMapEntry<EnumT> *pMap )
     {
         sal_uInt16 nTmp;
@@ -213,7 +213,7 @@ public:
 
     /** convert string to ::basegfx::B3DVector */
     static bool convertB3DVector( ::basegfx::B3DVector& rVector,
-                              const OUString& rValue );
+                              std::u16string_view rValue );
 
     /** convert string to ::basegfx::B3DVector */
     static bool convertB3DVector( ::basegfx::B3DVector& rVector,
@@ -253,7 +253,7 @@ public:
                                      bool *pEncoded=nullptr ) const;
     /** convert string (hex) to number (sal_uInt32) */
     static bool convertHex( sal_uInt32& nVal,
-                              const OUString& rValue );
+                              std::u16string_view rValue );
 
     /** convert number (sal_uInt32) to string (hex) */
     static void convertHex( OUStringBuffer& rBuffer,
@@ -261,11 +261,11 @@ public:
 
 private:
     static bool convertEnumImpl( sal_uInt16& rEnum,
-                             const OUString& rValue,
+                             std::u16string_view rValue,
                              const SvXMLEnumMapEntry<sal_uInt16> *pMap );
 
     static bool convertEnumImpl( sal_uInt16& rEnum,
-                             const OUString& rValue,
+                             std::u16string_view rValue,
                              const SvXMLEnumStringMapEntry<sal_uInt16> *pMap );
 
     static bool convertEnumImpl( OUStringBuffer& rBuffer,
diff --git a/reportdesign/source/filter/xml/xmlGroup.cxx b/reportdesign/source/filter/xml/xmlGroup.cxx
index b8a8e10abc10..938ec7f3238e 100644
--- a/reportdesign/source/filter/xml/xmlGroup.cxx
+++ b/reportdesign/source/filter/xml/xmlGroup.cxx
@@ -39,7 +39,7 @@ namespace rptxml
     using namespace ::com::sun::star::report;
     using namespace ::com::sun::star::xml::sax;
 
-    static sal_Int16 lcl_getKeepTogetherOption(const OUString& _sValue)
+    static sal_Int16 lcl_getKeepTogetherOption(std::u16string_view _sValue)
     {
         sal_Int16 nRet = report::KeepTogether::NO;
         const SvXMLEnumMapEntry<sal_Int16>* aXML_EnumMap = OXMLHelper::GetKeepTogetherOptions();
diff --git a/reportdesign/source/filter/xml/xmlSection.cxx b/reportdesign/source/filter/xml/xmlSection.cxx
index 71a458947fdd..2d5a20ea1927 100644
--- a/reportdesign/source/filter/xml/xmlSection.cxx
+++ b/reportdesign/source/filter/xml/xmlSection.cxx
@@ -36,7 +36,7 @@ namespace rptxml
     using namespace ::com::sun::star::uno;
     using namespace ::com::sun::star::xml::sax;
 
-    static sal_Int16 lcl_getReportPrintOption(const OUString& _sValue)
+    static sal_Int16 lcl_getReportPrintOption(std::u16string_view _sValue)
     {
         sal_Int16 nRet = report::ReportPrintOption::ALL_PAGES;
         const SvXMLEnumMapEntry<sal_Int16>* aXML_EnumMap = OXMLHelper::GetReportPrintOptions();
diff --git a/reportdesign/source/filter/xml/xmlTable.cxx b/reportdesign/source/filter/xml/xmlTable.cxx
index f6934e2a3ae6..7a6055ace448 100644
--- a/reportdesign/source/filter/xml/xmlTable.cxx
+++ b/reportdesign/source/filter/xml/xmlTable.cxx
@@ -50,7 +50,7 @@ namespace rptxml
     using ::com::sun::star::uno::Reference;
     using namespace ::com::sun::star::xml::sax;
 
-    static sal_Int16 lcl_getForceNewPageOption(const OUString& _sValue)
+    static sal_Int16 lcl_getForceNewPageOption(std::u16string_view _sValue)
     {
         sal_Int16 nRet = report::ForceNewPage::NONE;
         const SvXMLEnumMapEntry<sal_Int16>* aXML_EnumMap = OXMLHelper::GetForceNewPageOptions();
diff --git a/xmloff/inc/txtflde.hxx b/xmloff/inc/txtflde.hxx
index 9ea45f66f24c..bf8545b77b60 100644
--- a/xmloff/inc/txtflde.hxx
+++ b/xmloff/inc/txtflde.hxx
@@ -386,7 +386,7 @@ private:
                           const css::uno::Reference < css::beans::XPropertySet > & xPropSet);
 
     /// get field ID from XTextField service name (and it's PropertySet)
-    static enum FieldIdEnum MapFieldName(const OUString& sFieldName,
+    static enum FieldIdEnum MapFieldName(std::u16string_view sFieldName,
                             const css::uno::Reference < css::beans::XPropertySet> & xPropSet);
 
     /// determine, whether field has string or numeric content
diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx
index 4c2a94c2292b..f6c8e681a265 100644
--- a/xmloff/source/chart/SchXMLTools.cxx
+++ b/xmloff/source/chart/SchXMLTools.cxx
@@ -145,7 +145,7 @@ const SvXMLEnumMapEntry<SchXMLChartTypeEnum> aXMLChartClassMap[] =
     { XML_TOKEN_INVALID, XML_CHART_CLASS_UNKNOWN }
 };
 
-SchXMLChartTypeEnum GetChartTypeEnum( const OUString& rClassName )
+SchXMLChartTypeEnum GetChartTypeEnum( std::u16string_view rClassName )
 {
     SchXMLChartTypeEnum nEnumVal = XML_CHART_CLASS_UNKNOWN;
     SvXMLUnitConverter::convertEnum( nEnumVal, rClassName, aXMLChartClassMap );
diff --git a/xmloff/source/chart/SchXMLTools.hxx b/xmloff/source/chart/SchXMLTools.hxx
index f734faebaded..e2fc6cc9c308 100644
--- a/xmloff/source/chart/SchXMLTools.hxx
+++ b/xmloff/source/chart/SchXMLTools.hxx
@@ -67,7 +67,7 @@ namespace SchXMLTools
         XML_CHART_CLASS_UNKNOWN
     };
 
-    SchXMLChartTypeEnum GetChartTypeEnum( const OUString& rClassName );
+    SchXMLChartTypeEnum GetChartTypeEnum( std::u16string_view rClassName );
 
     OUString GetChartTypeByClassName(
         const OUString & rClassName, bool bUseOldNames );
diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx
index 6b5a6b65634e..e31dbfa231ca 100644
--- a/xmloff/source/core/xmluconv.cxx
+++ b/xmloff/source/core/xmluconv.cxx
@@ -210,12 +210,15 @@ OUString SvXMLUnitConverter::convertMeasureToXML( sal_Int32 nMeasure ) const
     not found in the map, this method will return false
 */
 bool SvXMLUnitConverter::convertEnumImpl( sal_uInt16& rEnum,
-                                      const OUString& rValue,
+                                      std::u16string_view rValue,
                                       const SvXMLEnumStringMapEntry<sal_uInt16> *pMap )
 {
     while( pMap->GetName() )
     {
-        if( rValue.equalsAsciiL( pMap->GetName(), pMap->GetNameLength() ) )
+        auto nameLength = pMap->GetNameLength();
+        if( static_cast<sal_Int32>(rValue.size()) == nameLength &&
+            rtl_ustr_asciil_reverseEquals_WithLength(
+                    rValue.data(), pMap->GetName(), nameLength ) )
         {
             rEnum = pMap->GetValue();
             return true;
@@ -230,7 +233,7 @@ bool SvXMLUnitConverter::convertEnumImpl( sal_uInt16& rEnum,
     not found in the map, this method will return false */
 bool SvXMLUnitConverter::convertEnumImpl(
     sal_uInt16& rEnum,
-    const OUString& rValue,
+    std::u16string_view rValue,
     const SvXMLEnumMapEntry<sal_uInt16> *pMap )
 {
     while( pMap->GetToken() != XML_TOKEN_INVALID )
@@ -546,7 +549,7 @@ static bool lcl_getPositions(std::string_view _sValue,OUString& _rContentX,OUStr
 }
 
 /** convert string to ::basegfx::B3DVector */
-bool SvXMLUnitConverter::convertB3DVector( ::basegfx::B3DVector& rVector, const OUString& rValue )
+bool SvXMLUnitConverter::convertB3DVector( ::basegfx::B3DVector& rVector, std::u16string_view rValue )
 {
     OUString aContentX,aContentY,aContentZ;
     if ( !lcl_getPositions(rValue,aContentX,aContentY,aContentZ) )
@@ -911,10 +914,9 @@ OUString SvXMLUnitConverter::encodeStyleName(
 }
 
 /** convert string (hex) to number (sal_uInt32) */
-bool SvXMLUnitConverter::convertHex( sal_uInt32& nVal,
-                                       const OUString& rValue )
+bool SvXMLUnitConverter::convertHex( sal_uInt32& nVal, std::u16string_view rValue )
 {
-    if( rValue.getLength() != 8 )
+    if( rValue.size() != 8 )
         return false;
 
     nVal = 0;
diff --git a/xmloff/source/text/XMLAnchorTypePropHdl.hxx b/xmloff/source/text/XMLAnchorTypePropHdl.hxx
index 7f6c8ddfe27c..9cd0a06f0d7e 100644
--- a/xmloff/source/text/XMLAnchorTypePropHdl.hxx
+++ b/xmloff/source/text/XMLAnchorTypePropHdl.hxx
@@ -37,7 +37,7 @@ public:
             OUString& rStrExpValue,
             const css::uno::Any& rValue,
             const SvXMLUnitConverter& rUnitConverter ) const override;
-    static bool convert( const OUString& rStrImpValue,
+    static bool convert( std::u16string_view rStrImpValue,
                  css::text::TextContentAnchorType& rType );
 };
 
diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx
index b8b0a5432ddf..6ee77829170f 100644
--- a/xmloff/source/text/XMLSectionExport.cxx
+++ b/xmloff/source/text/XMLSectionExport.cxx
@@ -329,7 +329,7 @@ SvXMLEnumStringMapEntry<SectionTypeEnum> const aIndexTypeMap[] =
 };
 
 enum SectionTypeEnum XMLSectionExport::MapSectionType(
-    const OUString& rServiceName)
+    std::u16string_view rServiceName)
 {
     enum SectionTypeEnum eType = TEXT_SECTION_TYPE_UNKNOWN;
 
diff --git a/xmloff/source/text/XMLSectionExport.hxx b/xmloff/source/text/XMLSectionExport.hxx
index 72c6247bcd2c..06243cc24122 100644
--- a/xmloff/source/text/XMLSectionExport.hxx
+++ b/xmloff/source/text/XMLSectionExport.hxx
@@ -195,7 +195,7 @@ private:
         css::uno::Reference < css::text::XDocumentIndex > & rIndex);
 
     /// map service name to section type
-    static enum SectionTypeEnum MapSectionType(const OUString& rSectionName);
+    static enum SectionTypeEnum MapSectionType(std::u16string_view rSectionName);
 
     /**
      * Export the index element start (for all index types).
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index dc767767f3a6..13d221672bff 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -435,7 +435,7 @@ enum FieldIdEnum XMLTextFieldExport::GetFieldID(
 }
 
 enum FieldIdEnum XMLTextFieldExport::MapFieldName(
-    const OUString& sFieldName,             // field (master) name
+    std::u16string_view sFieldName,             // field (master) name
     const Reference<XPropertySet> & xPropSet)   // for subtype
 {
     // we'll proceed in 2 steps:
@@ -447,9 +447,9 @@ enum FieldIdEnum XMLTextFieldExport::MapFieldName(
     // a) find prelim. FIELD_ID via aFieldServiceMapping
 
     // check for non-empty service name
-    DBG_ASSERT(!sFieldName.isEmpty(), "no valid service name!");
+    DBG_ASSERT(!sFieldName.empty(), "no valid service name!");
     enum FieldIdEnum nToken = FIELD_ID_UNKNOWN;
-    if (!sFieldName.isEmpty())
+    if (!sFieldName.empty())
     {
         // map name to prelim. ID
         bool bRet = SvXMLUnitConverter::convertEnum(
diff --git a/xmloff/source/text/txtprhdl.cxx b/xmloff/source/text/txtprhdl.cxx
index 77dbcb1bdd27..e68a8316a503 100644
--- a/xmloff/source/text/txtprhdl.cxx
+++ b/xmloff/source/text/txtprhdl.cxx
@@ -631,7 +631,7 @@ XMLAnchorTypePropHdl::~XMLAnchorTypePropHdl()
 {
 }
 
-bool XMLAnchorTypePropHdl::convert( const OUString& rStrImpValue,
+bool XMLAnchorTypePropHdl::convert( std::u16string_view rStrImpValue,
                  TextContentAnchorType& rType )
 {
     TextContentAnchorType nAnchor;


More information about the Libreoffice-commits mailing list