diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-03 11:51:18 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-04 10:01:33 +0200 |
commit | bf6b64d5963002d52c3ed2093b064896a4316d0e (patch) | |
tree | f38cc694ab887f63e4cf41eaaf4f57d61cba31fd | |
parent | 8342e4a5c7bd436f869e6c1c23d248556087ebdf (diff) |
use more string_view in unotools
Change-Id: Id10d68f2eb016671be6842dfaa82909207b0708d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133754
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/unotools/charclass.hxx | 4 | ||||
-rw-r--r-- | include/unotools/configpaths.hxx | 4 | ||||
-rw-r--r-- | include/unotools/fontdefs.hxx | 6 | ||||
-rw-r--r-- | include/unotools/localedatawrapper.hxx | 2 | ||||
-rw-r--r-- | sc/inc/global.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/global.cxx | 27 | ||||
-rw-r--r-- | sc/source/core/data/table4.cxx | 6 | ||||
-rw-r--r-- | sc/source/ui/dbgui/asciiopt.cxx | 2 | ||||
-rw-r--r-- | svtools/source/config/colorcfg.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/inc/msfilter.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/writerwordglue.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 8 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 2 | ||||
-rw-r--r-- | unotools/source/config/configpaths.cxx | 12 | ||||
-rw-r--r-- | unotools/source/config/fontcfg.cxx | 8 | ||||
-rw-r--r-- | unotools/source/i18n/charclass.cxx | 16 | ||||
-rw-r--r-- | unotools/source/i18n/localedatawrapper.cxx | 8 | ||||
-rw-r--r-- | unotools/source/misc/fontdefs.cxx | 21 | ||||
-rw-r--r-- | vcl/inc/font/PhysicalFontCollection.hxx | 2 | ||||
-rw-r--r-- | vcl/qa/cppunit/physicalfontcollection.cxx | 2 | ||||
-rw-r--r-- | vcl/source/font/PhysicalFontCollection.cxx | 2 |
21 files changed, 72 insertions, 70 deletions
diff --git a/include/unotools/charclass.hxx b/include/unotools/charclass.hxx index 4405d810875b..ab695beb52cb 100644 --- a/include/unotools/charclass.hxx +++ b/include/unotools/charclass.hxx @@ -81,10 +81,10 @@ public: const LanguageTag& getLanguageTag() const; /// isdigit() on ascii values of entire string - static bool isAsciiNumeric( const OUString& rStr ); + static bool isAsciiNumeric( std::u16string_view rStr ); /// isalpha() on ascii values of entire string - static bool isAsciiAlpha( const OUString& rStr ); + static bool isAsciiAlpha( std::u16string_view rStr ); /// whether type is pure numeric or not, e.g. return of getStringType static bool isNumericType( sal_Int32 nType ) diff --git a/include/unotools/configpaths.hxx b/include/unotools/configpaths.hxx index 15bc7118efa4..119733a477dc 100644 --- a/include/unotools/configpaths.hxx +++ b/include/unotools/configpaths.hxx @@ -134,7 +134,7 @@ namespace utl "*['<Name>']", where <Name> is properly escaped. */ - UNOTOOLS_DLLPUBLIC OUString wrapConfigurationElementName(OUString const& _sElementName); + UNOTOOLS_DLLPUBLIC OUString wrapConfigurationElementName(std::u16string_view _sElementName); /** Create a one-level relative configuration path from a set element name and a known set element type. @@ -152,7 +152,7 @@ namespace utl "<Type>['<Name>']", where <Name> is properly escaped. */ - OUString wrapConfigurationElementName(OUString const& _sElementName, + OUString wrapConfigurationElementName(std::u16string_view _sElementName, OUString const& _sTypeName); } // namespace utl diff --git a/include/unotools/fontdefs.hxx b/include/unotools/fontdefs.hxx index 7f145eba309e..aff10c860122 100644 --- a/include/unotools/fontdefs.hxx +++ b/include/unotools/fontdefs.hxx @@ -40,7 +40,7 @@ namespace o3tl template<> struct typed_flags<SubsFontFlags> : is_typed_flags<SubsFontFlags, 0x03> {}; } -UNOTOOLS_DLLPUBLIC OUString GetSubsFontName( const OUString& rName, SubsFontFlags nFlags ); +UNOTOOLS_DLLPUBLIC OUString GetSubsFontName( std::u16string_view rName, SubsFontFlags nFlags ); UNLESS_MERGELIBS(UNOTOOLS_DLLPUBLIC) void AddTokenFontName( OUString& rName, std::u16string_view rNewToken ); @@ -84,7 +84,7 @@ enum class DefaultFontType CTL_DISPLAY = 4004, }; -UNOTOOLS_DLLPUBLIC std::u16string_view GetNextFontToken( const OUString& rTokenStr, sal_Int32& rIndex ); +UNOTOOLS_DLLPUBLIC std::u16string_view GetNextFontToken( std::u16string_view rTokenStr, sal_Int32& rIndex ); UNOTOOLS_DLLPUBLIC OUString GetEnglishSearchFontName( std::u16string_view rName ); /** Strip any "script font suffix" from the font name @@ -104,7 +104,7 @@ UNOTOOLS_DLLPUBLIC OUString StripScriptFromName(const OUString& rName); @return true if this is Star|Open Symbol */ // FIXME It's quite possible that code using this should instead check for RTL_TEXTENCODING_SYMBOL. -UNOTOOLS_DLLPUBLIC bool IsStarSymbol(const OUString &rFontName); +UNOTOOLS_DLLPUBLIC bool IsStarSymbol(std::u16string_view rFontName); #endif // INCLUDED_UNOTOOLS_FONTDEFS_HXX diff --git a/include/unotools/localedatawrapper.hxx b/include/unotools/localedatawrapper.hxx index 6c2502c2a786..2c408b4a0cf9 100644 --- a/include/unotools/localedatawrapper.hxx +++ b/include/unotools/localedatawrapper.hxx @@ -101,7 +101,7 @@ class UNOTOOLS_DLLPUBLIC LocaleDataWrapper void loadCurrencyFormats(); - void scanCurrFormatImpl( const OUString& rCode, + void scanCurrFormatImpl( std::u16string_view rCode, sal_Int32 nStart, sal_Int32& nSign, sal_Int32& nPar, sal_Int32& nNum, sal_Int32& nBlank, sal_Int32& nSym ) const; diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx index decf343154ae..47b93c845296 100644 --- a/sc/inc/global.hxx +++ b/sc/inc/global.hxx @@ -658,7 +658,7 @@ public: */ SC_DLLPUBLIC static const sal_Unicode* FindUnquoted( const sal_Unicode* pString, sal_Unicode cChar ); - static rtl_TextEncoding GetCharsetValue( const OUString& rCharSet ); + static rtl_TextEncoding GetCharsetValue( std::u16string_view rCharSet ); static OUString GetCharsetString( rtl_TextEncoding eVal ); /// a "ReadOnly" formatter for UNO/XML export diff --git a/sc/source/core/data/global.cxx b/sc/source/core/data/global.cxx index 60a347bd236f..a338c0c76c31 100644 --- a/sc/source/core/data/global.cxx +++ b/sc/source/core/data/global.cxx @@ -24,6 +24,7 @@ #include <svl/itempool.hxx> #include <svl/srchitem.hxx> #include <editeng/langitem.hxx> +#include <o3tl/string_view.hxx> #include <o3tl/unit_conversion.hxx> #include <sfx2/docfile.hxx> #include <sfx2/dispatch.hxx> @@ -560,31 +561,31 @@ void ScGlobal::Clear() xDrawClipDocShellRef.clear(); } -rtl_TextEncoding ScGlobal::GetCharsetValue( const OUString& rCharSet ) +rtl_TextEncoding ScGlobal::GetCharsetValue( std::u16string_view rCharSet ) { // new TextEncoding values if ( CharClass::isAsciiNumeric( rCharSet ) ) { - sal_Int32 nVal = rCharSet.toInt32(); + sal_Int32 nVal = o3tl::toInt32(rCharSet); if ( nVal == RTL_TEXTENCODING_DONTKNOW ) return osl_getThreadTextEncoding(); return static_cast<rtl_TextEncoding>(nVal); } // old CharSet values for compatibility - else if (rCharSet.equalsIgnoreAsciiCase("ANSI") ) return RTL_TEXTENCODING_MS_1252; - else if (rCharSet.equalsIgnoreAsciiCase("MAC") ) return RTL_TEXTENCODING_APPLE_ROMAN; - else if (rCharSet.equalsIgnoreAsciiCase("IBMPC") ) return RTL_TEXTENCODING_IBM_850; - else if (rCharSet.equalsIgnoreAsciiCase("IBMPC_437")) return RTL_TEXTENCODING_IBM_437; - else if (rCharSet.equalsIgnoreAsciiCase("IBMPC_850")) return RTL_TEXTENCODING_IBM_850; - else if (rCharSet.equalsIgnoreAsciiCase("IBMPC_860")) return RTL_TEXTENCODING_IBM_860; - else if (rCharSet.equalsIgnoreAsciiCase("IBMPC_861")) return RTL_TEXTENCODING_IBM_861; - else if (rCharSet.equalsIgnoreAsciiCase("IBMPC_863")) return RTL_TEXTENCODING_IBM_863; - else if (rCharSet.equalsIgnoreAsciiCase("IBMPC_865")) return RTL_TEXTENCODING_IBM_865; + else if (o3tl::equalsIgnoreAsciiCase(rCharSet, u"ANSI") ) return RTL_TEXTENCODING_MS_1252; + else if (o3tl::equalsIgnoreAsciiCase(rCharSet, u"MAC") ) return RTL_TEXTENCODING_APPLE_ROMAN; + else if (o3tl::equalsIgnoreAsciiCase(rCharSet, u"IBMPC") ) return RTL_TEXTENCODING_IBM_850; + else if (o3tl::equalsIgnoreAsciiCase(rCharSet, u"IBMPC_437")) return RTL_TEXTENCODING_IBM_437; + else if (o3tl::equalsIgnoreAsciiCase(rCharSet, u"IBMPC_850")) return RTL_TEXTENCODING_IBM_850; + else if (o3tl::equalsIgnoreAsciiCase(rCharSet, u"IBMPC_860")) return RTL_TEXTENCODING_IBM_860; + else if (o3tl::equalsIgnoreAsciiCase(rCharSet, u"IBMPC_861")) return RTL_TEXTENCODING_IBM_861; + else if (o3tl::equalsIgnoreAsciiCase(rCharSet, u"IBMPC_863")) return RTL_TEXTENCODING_IBM_863; + else if (o3tl::equalsIgnoreAsciiCase(rCharSet, u"IBMPC_865")) return RTL_TEXTENCODING_IBM_865; // Some wrong "help" on the net mentions UTF8 and even unoconv uses it, // which worked accidentally if the system encoding is UTF-8 anyway, so // support it ;) but only when reading. - else if (rCharSet.equalsIgnoreAsciiCase("UTF8")) return RTL_TEXTENCODING_UTF8; - else if (rCharSet.equalsIgnoreAsciiCase("UTF-8")) return RTL_TEXTENCODING_UTF8; + else if (o3tl::equalsIgnoreAsciiCase(rCharSet, u"UTF8")) return RTL_TEXTENCODING_UTF8; + else if (o3tl::equalsIgnoreAsciiCase(rCharSet, u"UTF-8")) return RTL_TEXTENCODING_UTF8; else return osl_getThreadTextEncoding(); } diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index bad81a83dd9a..41250d5e2871 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -70,7 +70,7 @@ short lcl_DecompValueString( OUString& rValue, sal_Int32& nVal, sal_uInt16* pMin sal_Int32 nNum = 0; if ( p[nNum] == '-' || p[nNum] == '+' ) nNum = nSign = 1; - while ( p[nNum] && CharClass::isAsciiNumeric( OUString(p[nNum]) ) ) + while ( p[nNum] && CharClass::isAsciiNumeric( std::u16string_view(&p[nNum], 1) ) ) nNum++; sal_Unicode cNext = p[nNum]; // 0 if at the end @@ -79,7 +79,7 @@ short lcl_DecompValueString( OUString& rValue, sal_Int32& nVal, sal_uInt16* pMin // #i5550# If there are numbers at the beginning and the end, // prefer the one at the beginning only if it's followed by a space. // Otherwise, use the number at the end, to enable things like IP addresses. - if ( nNum > nSign && ( cNext == 0 || cNext == ' ' || !CharClass::isAsciiNumeric(OUString(cLast)) ) ) + if ( nNum > nSign && ( cNext == 0 || cNext == ' ' || !CharClass::isAsciiNumeric(std::u16string_view(&cLast, 1)) ) ) { // number at the beginning nVal = o3tl::toInt32(rValue.subView( 0, nNum )); // any number with a leading zero sets the minimum number of digits @@ -92,7 +92,7 @@ short lcl_DecompValueString( OUString& rValue, sal_Int32& nVal, sal_uInt16* pMin { nSign = 0; sal_Int32 nEnd = nNum = rValue.getLength() - 1; - while ( nNum && CharClass::isAsciiNumeric( OUString(p[nNum]) ) ) + while ( nNum && CharClass::isAsciiNumeric( std::u16string_view(&p[nNum], 1) ) ) nNum--; if ( p[nNum] == '-' || p[nNum] == '+' ) { diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx index d1e3f3dda7f8..933491efbbe5 100644 --- a/sc/source/ui/dbgui/asciiopt.cxx +++ b/sc/source/ui/dbgui/asciiopt.cxx @@ -109,7 +109,7 @@ void ScAsciiOptions::ReadFromString( std::u16string_view rString ) // Token 2: Text encoding. if ( nPos >= 0 ) { - eCharSet = ScGlobal::GetCharsetValue( OUString(o3tl::getToken(rString, 0, ',', nPos)) ); + eCharSet = ScGlobal::GetCharsetValue( o3tl::getToken(rString, 0, ',', nPos) ); } // Token 3: Number of start row. diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index 79279b97d45d..72556dd106dd 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -103,7 +103,7 @@ public: namespace { -uno::Sequence< OUString> GetPropertyNames(const OUString& rScheme) +uno::Sequence< OUString> GetPropertyNames(std::u16string_view rScheme) { struct ColorConfigEntryData_Impl { diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx index 0ca05c0ac9f9..b2696c2d7ddc 100644 --- a/sw/source/filter/inc/msfilter.hxx +++ b/sw/source/filter/inc/msfilter.hxx @@ -243,7 +243,7 @@ namespace sw public: OUString msPrimary; OUString msSecondary; - explicit FontMapExport(const OUString &rFontDescription); + explicit FontMapExport(std::u16string_view rFontDescription); }; class InsertedTableListener final : public SvtListener diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx index e0a7fb3bb941..3de62b243d08 100644 --- a/sw/source/filter/ww8/writerwordglue.cxx +++ b/sw/source/filter/ww8/writerwordglue.cxx @@ -313,7 +313,7 @@ namespace myImplHelpers return pColl ? nullptr : maHelper.MakeStyle(aName); } - static OUString FindBestMSSubstituteFont(const OUString &rFont) + static OUString FindBestMSSubstituteFont(std::u16string_view rFont) { if (IsStarSymbol(rFont)) return "Arial Unicode MS"; @@ -482,7 +482,7 @@ namespace sw return mpImpl->GetStyle(rName, eSti); } - FontMapExport::FontMapExport(const OUString &rFamilyName) + FontMapExport::FontMapExport(std::u16string_view rFamilyName) { sal_Int32 nIndex = 0; msPrimary = GetNextFontToken(rFamilyName, nIndex); diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index dec8d2445678..7dc45d1c7114 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -735,7 +735,7 @@ const SwNumRule* MSWordStyles::GetSwNumRule(sal_uInt16 nId) const // Fonts -wwFont::wwFont(const OUString &rFamilyName, FontPitch ePitch, FontFamily eFamily, +wwFont::wwFont(std::u16string_view rFamilyName, FontPitch ePitch, FontFamily eFamily, rtl_TextEncoding eChrSet) : mbAlt(false), mePitch(ePitch), meFamily(eFamily), meChrSet(eChrSet) { @@ -874,13 +874,13 @@ sal_uInt16 wwFontHelper::GetId(const wwFont &rFont) void wwFontHelper::InitFontTable(const SwDoc& rDoc) { - GetId(wwFont("Times New Roman", PITCH_VARIABLE, + GetId(wwFont(u"Times New Roman", PITCH_VARIABLE, FAMILY_ROMAN, RTL_TEXTENCODING_MS_1252)); - GetId(wwFont("Symbol", PITCH_VARIABLE, FAMILY_ROMAN, + GetId(wwFont(u"Symbol", PITCH_VARIABLE, FAMILY_ROMAN, RTL_TEXTENCODING_SYMBOL)); - GetId(wwFont("Arial", PITCH_VARIABLE, FAMILY_SWISS, + GetId(wwFont(u"Arial", PITCH_VARIABLE, FAMILY_SWISS, RTL_TEXTENCODING_MS_1252)); const SvxFontItem* pFont = GetDfltAttr(RES_CHRATR_FONT); diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 8def69ca2fb4..28428a199eb6 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -306,7 +306,7 @@ private: FontFamily meFamily; rtl_TextEncoding meChrSet; public: - wwFont( const OUString &rFamilyName, FontPitch ePitch, FontFamily eFamily, + wwFont( std::u16string_view rFamilyName, FontPitch ePitch, FontFamily eFamily, rtl_TextEncoding eChrSet); void Write( SvStream *pTableStram ) const; void WriteDocx( DocxAttributeOutput* rAttrOutput ) const; diff --git a/unotools/source/config/configpaths.cxx b/unotools/source/config/configpaths.cxx index 9cf537738889..8efdf19b5519 100644 --- a/unotools/source/config/configpaths.cxx +++ b/unotools/source/config/configpaths.cxx @@ -232,10 +232,10 @@ OUString dropPrefixFromConfigurationPath(OUString const& _sNestedPath, } static -OUString lcl_wrapName(const OUString& _sContent, const OUString& _sType) +OUString lcl_wrapName(std::u16string_view _sContent, const OUString& _sType) { - const sal_Unicode * const pBeginContent = _sContent.getStr(); - const sal_Unicode * const pEndContent = pBeginContent + _sContent.getLength(); + const sal_Unicode * const pBeginContent = _sContent.data(); + const sal_Unicode * const pEndContent = pBeginContent + _sContent.size(); OSL_PRECOND(!_sType.isEmpty(), "Unexpected config type name: empty"); OSL_PRECOND(pBeginContent <= pEndContent, "Invalid config name: empty"); @@ -243,7 +243,7 @@ OUString lcl_wrapName(const OUString& _sContent, const OUString& _sType) if (pBeginContent == pEndContent) return _sType; - OUStringBuffer aNormalized(_sType.getLength() + _sContent.getLength() + 4); // reserve approximate size initially + OUStringBuffer aNormalized(_sType.getLength() + _sContent.size() + 4); // reserve approximate size initially // prefix: type, opening bracket and quote aNormalized.append( _sType + "['" ); @@ -268,12 +268,12 @@ OUString lcl_wrapName(const OUString& _sContent, const OUString& _sType) return aNormalized.makeStringAndClear(); } -OUString wrapConfigurationElementName(OUString const& _sElementName) +OUString wrapConfigurationElementName(std::u16string_view _sElementName) { return lcl_wrapName(_sElementName, "*" ); } -OUString wrapConfigurationElementName(OUString const& _sElementName, +OUString wrapConfigurationElementName(std::u16string_view _sElementName, OUString const& _sTypeName) { // todo: check that _sTypeName is valid diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx index 371084708084..0a8ab40b3116 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -602,13 +602,13 @@ static bool ImplKillLeading( OUString& rName, const char* const* ppStr ) return false; } -static sal_Int32 ImplIsTrailing( const OUString& rName, const char* pStr ) +static sal_Int32 ImplIsTrailing( std::u16string_view rName, const char* pStr ) { - sal_Int32 nStrLen = static_cast<sal_Int32>(strlen( pStr )); - if( nStrLen >= rName.getLength() ) + size_t nStrLen = strlen( pStr ); + if( nStrLen >= rName.size() ) return 0; - const sal_Unicode* pEndName = rName.getStr() + rName.getLength(); + const sal_Unicode* pEndName = rName.data() + rName.size(); const sal_Unicode* pNameStr = pEndName - nStrLen; do if( *(pNameStr++) != *(pStr++) ) return 0; diff --git a/unotools/source/i18n/charclass.cxx b/unotools/source/i18n/charclass.cxx index e11ffb6e27d0..05bc2dd6bf48 100644 --- a/unotools/source/i18n/charclass.cxx +++ b/unotools/source/i18n/charclass.cxx @@ -58,12 +58,12 @@ const css::lang::Locale& CharClass::getMyLocale() const } // static -bool CharClass::isAsciiNumeric( const OUString& rStr ) +bool CharClass::isAsciiNumeric( std::u16string_view rStr ) { - if ( rStr.isEmpty() ) + if ( rStr.empty() ) return false; - const sal_Unicode* p = rStr.getStr(); - const sal_Unicode* const pStop = p + rStr.getLength(); + const sal_Unicode* p = rStr.data(); + const sal_Unicode* const pStop = p + rStr.size(); do { @@ -76,12 +76,12 @@ bool CharClass::isAsciiNumeric( const OUString& rStr ) } // static -bool CharClass::isAsciiAlpha( const OUString& rStr ) +bool CharClass::isAsciiAlpha( std::u16string_view rStr ) { - if ( rStr.isEmpty() ) + if ( rStr.empty() ) return false; - const sal_Unicode* p = rStr.getStr(); - const sal_Unicode* const pStop = p + rStr.getLength(); + const sal_Unicode* p = rStr.data(); + const sal_Unicode* const pStop = p + rStr.size(); do { diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx index 24b19371a5a9..469457986f56 100644 --- a/unotools/source/i18n/localedatawrapper.cxx +++ b/unotools/source/i18n/localedatawrapper.cxx @@ -460,13 +460,13 @@ sal_uInt16 LocaleDataWrapper::getCurrDigits() const return nCurrDigits; } -void LocaleDataWrapper::scanCurrFormatImpl( const OUString& rCode, +void LocaleDataWrapper::scanCurrFormatImpl( std::u16string_view rCode, sal_Int32 nStart, sal_Int32& nSign, sal_Int32& nPar, sal_Int32& nNum, sal_Int32& nBlank, sal_Int32& nSym ) const { nSign = nPar = nNum = nBlank = nSym = -1; - const sal_Unicode* const pStr = rCode.getStr(); - const sal_Unicode* const pStop = pStr + rCode.getLength(); + const sal_Unicode* const pStr = rCode.data(); + const sal_Unicode* const pStop = pStr + rCode.size(); const sal_Unicode* p = pStr + nStart; int nInSection = 0; bool bQuote = false; @@ -523,7 +523,7 @@ void LocaleDataWrapper::scanCurrFormatImpl( const OUString& rCode, p = pStop; break; default: - if (!nInSection && nSym == -1 && rCode.match(aCurrSymbol, static_cast<sal_Int32>(p - pStr))) + if (!nInSection && nSym == -1 && o3tl::starts_with(rCode.substr(static_cast<sal_Int32>(p - pStr)), aCurrSymbol)) { // currency symbol not surrounded by [$...] nSym = p - pStr; if (nBlank == -1 && pStr < p && *(p-1) == ' ') diff --git a/unotools/source/misc/fontdefs.cxx b/unotools/source/misc/fontdefs.cxx index 4a07087fd71f..5a9157d4fb12 100644 --- a/unotools/source/misc/fontdefs.cxx +++ b/unotools/source/misc/fontdefs.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <o3tl/safeint.hxx> #include <unotools/fontdefs.hxx> #include <unotools/fontcfg.hxx> #include <rtl/ustrbuf.hxx> @@ -457,19 +458,19 @@ OUString GetEnglishSearchFontName(std::u16string_view rInName) return rNameStr; } -std::u16string_view GetNextFontToken( const OUString& rTokenStr, sal_Int32& rIndex ) +std::u16string_view GetNextFontToken( std::u16string_view rTokenStr, sal_Int32& rIndex ) { // check for valid start index - sal_Int32 nStringLen = rTokenStr.getLength(); - if( rIndex >= nStringLen ) + size_t nStringLen = rTokenStr.size(); + if( o3tl::make_unsigned(rIndex) >= nStringLen ) { rIndex = -1; return {}; } // find the next token delimiter and return the token substring - const sal_Unicode* pStr = rTokenStr.getStr() + rIndex; - const sal_Unicode* pEnd = rTokenStr.getStr() + nStringLen; + const sal_Unicode* pStr = rTokenStr.data() + rIndex; + const sal_Unicode* pEnd = rTokenStr.data() + nStringLen; for(; pStr < pEnd; ++pStr ) if( (*pStr == ';') || (*pStr == ',') ) break; @@ -478,7 +479,7 @@ std::u16string_view GetNextFontToken( const OUString& rTokenStr, sal_Int32& rInd sal_Int32 nTokenLen; if( pStr < pEnd ) { - rIndex = sal::static_int_cast<sal_Int32>(pStr - rTokenStr.getStr()); + rIndex = sal::static_int_cast<sal_Int32>(pStr - rTokenStr.data()); nTokenLen = rIndex - nTokenStart; ++rIndex; // skip over token separator } @@ -498,10 +499,10 @@ std::u16string_view GetNextFontToken( const OUString& rTokenStr, sal_Int32& rInd } } - return rTokenStr.subView( nTokenStart, nTokenLen ); + return rTokenStr.substr( nTokenStart, nTokenLen ); } -static bool ImplIsFontToken( const OUString& rName, std::u16string_view rToken ) +static bool ImplIsFontToken( std::u16string_view rName, std::u16string_view rToken ) { OUString aTempName; sal_Int32 nIndex = 0; @@ -531,7 +532,7 @@ void AddTokenFontName( OUString& rName, std::u16string_view rNewToken ) ImplAppendFontToken( rName, rNewToken ); } -OUString GetSubsFontName( const OUString& rName, SubsFontFlags nFlags ) +OUString GetSubsFontName( std::u16string_view rName, SubsFontFlags nFlags ) { OUString aName; @@ -563,7 +564,7 @@ OUString GetSubsFontName( const OUString& rName, SubsFontFlags nFlags ) return aName; } -bool IsStarSymbol(const OUString &rFontName) +bool IsStarSymbol(std::u16string_view rFontName) { sal_Int32 nIndex = 0; OUString sFamilyNm(GetNextFontToken(rFontName, nIndex)); diff --git a/vcl/inc/font/PhysicalFontCollection.hxx b/vcl/inc/font/PhysicalFontCollection.hxx index c73be7075ca5..22ceaf8f0904 100644 --- a/vcl/inc/font/PhysicalFontCollection.hxx +++ b/vcl/inc/font/PhysicalFontCollection.hxx @@ -59,7 +59,7 @@ public: vcl::font::PhysicalFontFamily* FindFontFamily( std::u16string_view rFontName ) const; vcl::font::PhysicalFontFamily* FindOrCreateFontFamily( const OUString &rFamilyName ); vcl::font::PhysicalFontFamily* FindFontFamily( vcl::font::FontSelectPattern& ) const; - vcl::font::PhysicalFontFamily* FindFontFamilyByTokenNames(const OUString& rTokenStr) const; + vcl::font::PhysicalFontFamily* FindFontFamilyByTokenNames(std::u16string_view rTokenStr) const; vcl::font::PhysicalFontFamily* FindFontFamilyByAttributes(ImplFontAttrs nSearchType, FontWeight, FontWidth, FontItalic, const OUString& rSearchFamily) const; diff --git a/vcl/qa/cppunit/physicalfontcollection.cxx b/vcl/qa/cppunit/physicalfontcollection.cxx index 7df20ce76b66..0d79c0f8fde5 100644 --- a/vcl/qa/cppunit/physicalfontcollection.cxx +++ b/vcl/qa/cppunit/physicalfontcollection.cxx @@ -146,7 +146,7 @@ void VclPhysicalFontCollectionTest::testShouldFindFontFamilyByTokenNames() sTokenNames += GetEnglishSearchFontName(u"Test 2"); vcl::font::PhysicalFontFamily* pFontFamily - = aFontCollection.FindFontFamilyByTokenNames("Test Font Family Name"); + = aFontCollection.FindFontFamilyByTokenNames(u"Test Font Family Name"); CPPUNIT_ASSERT_MESSAGE("Did not find the font family", pFontFamily); CPPUNIT_ASSERT_EQUAL_MESSAGE("Font family name incorrect", GetEnglishSearchFontName(u"Test Font Family Name"), diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx index 6a1b35372952..3abf7db3d668 100644 --- a/vcl/source/font/PhysicalFontCollection.cxx +++ b/vcl/source/font/PhysicalFontCollection.cxx @@ -337,7 +337,7 @@ PhysicalFontFamily *PhysicalFontCollection::FindOrCreateFontFamily(OUString cons return pFoundData; } -PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByTokenNames(OUString const& rTokenStr) const +PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByTokenNames(std::u16string_view rTokenStr) const { PhysicalFontFamily* pFoundData = nullptr; |