summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-04-12 10:50:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-04-14 07:54:28 +0200
commitbc2101646bc6e63944c42500af5a15134b9b2d17 (patch)
treeca1da50da2e3e76eef650a1ae3956c16e0a19f33
parenttdf#154501 - Fileopen PPTX: Table with rotated text wrong (diff)
downloadcore-bc2101646bc6e63944c42500af5a15134b9b2d17.tar.gz
core-bc2101646bc6e63944c42500af5a15134b9b2d17.zip
loplugin:stringviewparam improvements
improve the check by checking for methods that exclude using string_view, rather than checking for methods that __can__ use string_view, which leads to exposing some holes in our o3tl/string_view.hxx coverage. Change-Id: Ic9dd60441c671f502692f9cd2a1bb67301c4b960 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150277 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--basic/source/classes/sbxmod.cxx2
-rw-r--r--basic/source/comp/token.cxx5
-rw-r--r--basic/source/inc/token.hxx2
-rw-r--r--comphelper/source/misc/fileurl.cxx6
-rw-r--r--compilerplugins/clang/stringviewparam.cxx11
-rw-r--r--connectivity/source/commontools/CommonTools.cxx4
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignView.cxx2
-rw-r--r--dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx6
-rw-r--r--dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx2
-rw-r--r--framework/inc/jobs/joburl.hxx2
-rw-r--r--framework/source/jobs/joburl.cxx17
-rw-r--r--i18nlangtag/source/isolang/isolang.cxx11
-rw-r--r--include/basic/sbmod.hxx2
-rw-r--r--include/comphelper/fileurl.hxx2
-rw-r--r--include/connectivity/dbtools.hxx2
-rw-r--r--include/i18nlangtag/mslangid.hxx2
-rw-r--r--include/o3tl/string_view.hxx52
-rw-r--r--include/oox/core/filterdetect.hxx2
-rw-r--r--include/sfx2/linkmgr.hxx2
-rw-r--r--include/sfx2/objsh.hxx2
-rw-r--r--include/sot/exchange.hxx2
-rw-r--r--include/test/sheet/xspreadsheets2.hxx2
-rw-r--r--o3tl/qa/test-string_view.cxx31
-rw-r--r--oox/source/core/filterdetect.cxx5
-rw-r--r--sc/source/core/inc/addinhelpid.hxx2
-rw-r--r--sc/source/core/tool/addinhelpid.cxx5
-rw-r--r--sc/source/core/tool/interpr2.cxx5
-rw-r--r--sc/source/filter/oox/defnamesbuffer.cxx4
-rw-r--r--sc/source/ui/dbgui/scuiasciiopt.cxx6
-rw-r--r--sc/source/ui/docshell/impex.cxx2
-rw-r--r--sc/source/ui/inc/impex.hxx2
-rw-r--r--sc/source/ui/inc/scuiasciiopt.hxx2
-rw-r--r--sd/source/filter/eppt/pptexanimations.cxx4
-rw-r--r--sd/source/filter/eppt/pptexanimations.hxx2
-rw-r--r--sd/source/filter/eppt/pptx-animations-nodectx.cxx9
-rw-r--r--sd/source/filter/eppt/pptx-animations.cxx8
-rw-r--r--sfx2/source/appl/appopen.cxx2
-rw-r--r--sfx2/source/appl/linkmgr2.cxx2
-rw-r--r--sfx2/source/doc/doctemplates.cxx6
-rw-r--r--sfx2/source/doc/objcont.cxx2
-rw-r--r--sfx2/source/inc/appopen.hxx2
-rw-r--r--sot/source/base/exchange.cxx6
-rw-r--r--svx/source/unodraw/unoshap2.cxx4
-rw-r--r--sw/inc/SwAppletImpl.hxx2
-rw-r--r--sw/source/filter/basflt/fltini.cxx6
-rw-r--r--sw/source/filter/html/SwAppletImpl.cxx41
-rw-r--r--sw/source/filter/html/htmlfld.cxx5
-rw-r--r--sw/source/filter/html/htmlplug.cxx2
-rw-r--r--sw/source/filter/html/svxcss1.cxx5
-rw-r--r--sw/source/filter/html/svxcss1.hxx2
-rw-r--r--sw/source/filter/html/swhtml.hxx4
-rw-r--r--test/source/sheet/xspreadsheets2.cxx11
-rw-r--r--ucb/source/ucp/webdav-curl/ContentProperties.cxx8
-rw-r--r--xmloff/inc/prstylecond.hxx2
-rw-r--r--xmloff/source/style/prstylecond.cxx4
-rw-r--r--xmloff/source/transform/TransformerBase.cxx6
56 files changed, 225 insertions, 124 deletions
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 2453caa57c8c..cce2caca22b4 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -1735,7 +1735,7 @@ void SbModule::GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache)
}
-OUString SbModule::GetKeywordCase( const OUString& sKeyword )
+OUString SbModule::GetKeywordCase( std::u16string_view sKeyword )
{
return SbiParser::GetKeywordCase( sKeyword );
}
diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx
index a060b3fd9318..814d5488f8ee 100644
--- a/basic/source/comp/token.cxx
+++ b/basic/source/comp/token.cxx
@@ -22,6 +22,7 @@
#include <basic/sberrors.hxx>
#include <sal/macros.h>
+#include <o3tl/string_view.hxx>
#include <basiccharclass.hxx>
#include <token.hxx>
@@ -558,11 +559,11 @@ bool SbiTokenizer::MayBeLabel( bool bNeedsColon )
}
-OUString SbiTokenizer::GetKeywordCase( const OUString& sKeyword )
+OUString SbiTokenizer::GetKeywordCase( std::u16string_view sKeyword )
{
for( auto& rTok : aTokTable_Basic )
{
- if( sKeyword.equalsIgnoreAsciiCaseAscii(rTok.s) )
+ if( o3tl::equalsIgnoreAsciiCase(sKeyword, rTok.s) )
return OStringToOUString(rTok.s, RTL_TEXTENCODING_ASCII_US);
}
return OUString();
diff --git a/basic/source/inc/token.hxx b/basic/source/inc/token.hxx
index 4230ff585b7a..9927e894e3b5 100644
--- a/basic/source/inc/token.hxx
+++ b/basic/source/inc/token.hxx
@@ -130,7 +130,7 @@ public:
{ return t >= FIRSTKWD && t <= LASTKWD; }
static bool IsExtra( SbiToken t )
{ return t >= FIRSTEXTRA; }
- static OUString GetKeywordCase( const OUString& sKeyword );
+ static OUString GetKeywordCase( std::u16string_view sKeyword );
};
diff --git a/comphelper/source/misc/fileurl.cxx b/comphelper/source/misc/fileurl.cxx
index 4f361ab4ba7a..2515b28c5b30 100644
--- a/comphelper/source/misc/fileurl.cxx
+++ b/comphelper/source/misc/fileurl.cxx
@@ -21,7 +21,11 @@
#include <comphelper/fileurl.hxx>
#include <rtl/ustring.hxx>
+#include <o3tl/string_view.hxx>
-bool comphelper::isFileUrl(OUString const& url) { return url.startsWithIgnoreAsciiCase("file:"); }
+bool comphelper::isFileUrl(std::u16string_view url)
+{
+ return o3tl::matchIgnoreAsciiCase(url, "file:");
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/stringviewparam.cxx b/compilerplugins/clang/stringviewparam.cxx
index 1540f03291c3..d16c306f6326 100644
--- a/compilerplugins/clang/stringviewparam.cxx
+++ b/compilerplugins/clang/stringviewparam.cxx
@@ -137,12 +137,11 @@ DeclRefExpr const* relevantCXXMemberCallExpr(CXXMemberCallExpr const* expr)
else if (auto const i = d->getIdentifier())
{
auto const n = i->getName();
- if (n == "endsWith" || n == "isEmpty" || n == "startsWith" || n == "subView"
- || n == "indexOf" || n == "lastIndexOf" || n == "compareTo" || n == "match"
- || n == "trim" || n == "toInt32" || n == "toUInt32" || n == "toInt64" || n == "toDouble"
- || n == "equalsIgnoreAsciiCase" || n == "compareToIgnoreAsciiCase" || n == "getToken"
- || n == "copy" || n == "equalsAscii" || n == "equalsAsciiL"
- || n == "matchIgnoreAsciiCase")
+ if (!(n == "getLength" || n == "getStr" || n == "convertToString" || n == "replace"
+ || n == "replaceAll" || n == "replaceAt" || n == "replaceFirst"
+ || n == "toAsciiLowerCase" || n == "toAsciiUpperCase" || n == "toUtf8"
+ || n == "iterateCodePoints" || n == "startsWithIgnoreAsciiCase" || n == "toUInt64"
+ || n == "toFloat" || n == "toBoolean"))
{
good = true;
}
diff --git a/connectivity/source/commontools/CommonTools.cxx b/connectivity/source/commontools/CommonTools.cxx
index 48e91f2fc72d..596be7097d45 100644
--- a/connectivity/source/commontools/CommonTools.cxx
+++ b/connectivity/source/commontools/CommonTools.cxx
@@ -221,10 +221,10 @@ OUString convertName2SQLName(const OUString& rName, std::u16string_view _rSpecia
return aNewName.makeStringAndClear();
}
-OUString quoteName(const OUString& _rQuote, const OUString& _rName)
+OUString quoteName(std::u16string_view _rQuote, const OUString& _rName)
{
OUString sName = _rName;
- if( !_rQuote.isEmpty() && _rQuote.toChar() != ' ')
+ if( !_rQuote.empty() && _rQuote[0] != ' ')
sName = _rQuote + _rName + _rQuote;
return sName;
}
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index 1c23e936b016..95c8e82c267d 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -97,7 +97,7 @@ namespace
bool bHaving,
bool _bAddOrOnOneLine);
- OUString quoteTableAlias(bool _bQuote, const OUString& _sAliasName, const OUString& _sQuote)
+ OUString quoteTableAlias(bool _bQuote, const OUString& _sAliasName, std::u16string_view _sQuote)
{
OUString sRet;
if ( _bQuote && !_sAliasName.isEmpty() )
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index f053d4b43dd1..eb6c666f532c 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -69,9 +69,9 @@ using namespace ::com::sun::star::accessibility;
namespace
{
- bool isFieldNameAsterisk(const OUString& _sFieldName )
+ bool isFieldNameAsterisk(std::u16string_view _sFieldName )
{
- bool bAsterisk = _sFieldName.isEmpty() || _sFieldName.toChar() == '*';
+ bool bAsterisk = _sFieldName.empty() || _sFieldName[0] == '*';
if ( !bAsterisk )
{
sal_Int32 nTokenCount = comphelper::string::getTokenCount(_sFieldName, '.');
@@ -576,7 +576,7 @@ void OSelectionBrowseBox::notifyFunctionFieldChanged(const OUString& _sOldFuncti
RowModified(GetBrowseRow(BROW_FUNCTION_ROW), _nColumnId);
}
-void OSelectionBrowseBox::clearEntryFunctionField(const OUString& _sFieldName,OTableFieldDescRef const & _pEntry, bool& _bListAction,sal_uInt16 _nColumnId)
+void OSelectionBrowseBox::clearEntryFunctionField(std::u16string_view _sFieldName,OTableFieldDescRef const & _pEntry, bool& _bListAction,sal_uInt16 _nColumnId)
{
if ( !(isFieldNameAsterisk( _sFieldName ) && (!_pEntry->isNoneFunction() || _pEntry->IsGroupBy())) )
return;
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
index 3bddd9a9c996..d5e11c03e332 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.hxx
@@ -306,7 +306,7 @@ namespace dbaui
@param _bListAction
When <TRUE/> a list action will be created.
*/
- void clearEntryFunctionField(const OUString& _sFieldName,OTableFieldDescRef const & _pEntry, bool& _bListAction,sal_uInt16 _nColumnId);
+ void clearEntryFunctionField(std::u16string_view _sFieldName,OTableFieldDescRef const & _pEntry, bool& _bListAction,sal_uInt16 _nColumnId);
/** remove or insert the necessary function types
@param _pEntry
diff --git a/framework/inc/jobs/joburl.hxx b/framework/inc/jobs/joburl.hxx
index 3a227a375c78..23486ec2f4d9 100644
--- a/framework/inc/jobs/joburl.hxx
+++ b/framework/inc/jobs/joburl.hxx
@@ -96,7 +96,7 @@ class JobURL
private:
- static bool implst_split( const OUString& sPart ,
+ static bool implst_split( std::u16string_view sPart ,
const char* pPartIdentifier ,
sal_Int32 nPartLength ,
OUString& rPartValue ,
diff --git a/framework/source/jobs/joburl.cxx b/framework/source/jobs/joburl.cxx
index fc1424867d99..5533014edf80 100644
--- a/framework/source/jobs/joburl.cxx
+++ b/framework/source/jobs/joburl.cxx
@@ -24,6 +24,7 @@
#include <jobs/joburl.hxx>
#include <vcl/svapp.hxx>
+#include <o3tl/string_view.hxx>
namespace framework{
@@ -205,14 +206,14 @@ bool JobURL::getService( /*OUT*/ OUString& sService ) const
@return <TRUE/> if the identifier could be found and the string was split.
<FALSE/> otherwise.
*/
-bool JobURL::implst_split( /*IN*/ const OUString& sPart ,
+bool JobURL::implst_split( /*IN*/ std::u16string_view sPart ,
/*IN*/ const char* pPartIdentifier ,
/*IN*/ sal_Int32 nPartLength ,
/*OUT*/ OUString& rPartValue ,
/*OUT*/ OUString& rPartArguments )
{
// first search for the given identifier
- bool bPartFound = sPart.matchIgnoreAsciiCaseAsciiL(pPartIdentifier,nPartLength);
+ bool bPartFound = o3tl::matchIgnoreAsciiCase(sPart, std::string_view(pPartIdentifier,nPartLength));
// If it exist - we can split the part and return sal_True.
// Otherwise we do nothing and return sal_False.
@@ -222,16 +223,16 @@ bool JobURL::implst_split( /*IN*/ const OUString& sPart ,
// Do so - we set the return value with the whole part string.
// Arguments will be set to an empty string as default.
// If we detect the right sign - we split the arguments and overwrite the default.
- OUString sValueAndArguments = sPart.copy(nPartLength);
- OUString sValue = sValueAndArguments;
+ std::u16string_view sValueAndArguments = sPart.substr(nPartLength);
+ std::u16string_view sValue = sValueAndArguments;
OUString sArguments;
- sal_Int32 nArgStart = sValueAndArguments.indexOf('?');
- if (nArgStart!=-1)
+ size_t nArgStart = sValueAndArguments.find('?');
+ if (nArgStart != std::u16string_view::npos)
{
- sValue = sValueAndArguments.copy(0,nArgStart);
+ sValue = sValueAndArguments.substr(0,nArgStart);
++nArgStart; // ignore '?'!
- sArguments = sValueAndArguments.copy(nArgStart);
+ sArguments = sValueAndArguments.substr(nArgStart);
}
rPartValue = sValue;
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index 192f979dcc0b..01b456f95a4a 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -18,6 +18,7 @@
*/
#include <sal/log.hxx>
+#include <o3tl/string_view.hxx>
#include <rtl/ustring.hxx>
#include <rtl/string.hxx>
@@ -87,7 +88,7 @@ struct IsoLanguageScriptCountryEntry
We don't have OUString::startsWithIgnoreAsciiCaseAscii()
*/
- bool startsInIgnoreAsciiCase( const OUString & rStr ) const;
+ bool startsInIgnoreAsciiCase( std::u16string_view aStr ) const;
};
struct Bcp47CountryEntry
@@ -830,9 +831,9 @@ css::lang::Locale IsoLanguageScriptCountryEntry::getLocale() const
return lang::Locale( I18NLANGTAG_QLT, OUString::createFromAscii( maCountry), getTagString());
}
-bool IsoLanguageScriptCountryEntry::startsInIgnoreAsciiCase( const OUString & rStr ) const
+bool IsoLanguageScriptCountryEntry::startsInIgnoreAsciiCase( std::u16string_view aStr ) const
{
- return rStr.matchIgnoreAsciiCaseAsciiL( maLanguageScript, strlen( maLanguageScript) );
+ return o3tl::matchIgnoreAsciiCase(aStr, std::string_view(maLanguageScript) );
}
OUString Bcp47CountryEntry::getTagString() const
@@ -1208,12 +1209,12 @@ css::lang::Locale MsLangId::Conversion::lookupFallbackLocale(
// static
-LanguageType MsLangId::Conversion::convertPrivateUseToLanguage( const OUString& rPriv )
+LanguageType MsLangId::Conversion::convertPrivateUseToLanguage( std::u16string_view rPriv )
{
for (const IsoLangOtherEntry* pPrivateEntry = aImplPrivateUseEntries;
pPrivateEntry->mnLang != LANGUAGE_DONTKNOW; ++pPrivateEntry)
{
- if ( rPriv.equalsIgnoreAsciiCaseAscii( pPrivateEntry->mpLanguage ) )
+ if ( o3tl::equalsIgnoreAsciiCase(rPriv, pPrivateEntry->mpLanguage ) )
return pPrivateEntry->mnLang;
}
return LANGUAGE_DONTKNOW;
diff --git a/include/basic/sbmod.hxx b/include/basic/sbmod.hxx
index eac88132bafc..4ff300b82aaa 100644
--- a/include/basic/sbmod.hxx
+++ b/include/basic/sbmod.hxx
@@ -135,7 +135,7 @@ public:
void GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache);
const SbxArrayRef& GetMethods() const { return pMethods;}
SbMethod* FindMethod( const OUString&, SbxClassType );
- static OUString GetKeywordCase( const OUString& sKeyword );
+ static OUString GetKeywordCase( std::u16string_view sKeyword );
};
typedef tools::SvRef<SbModule> SbModuleRef;
diff --git a/include/comphelper/fileurl.hxx b/include/comphelper/fileurl.hxx
index 27ac6b576b2e..0da07cdeb495 100644
--- a/include/comphelper/fileurl.hxx
+++ b/include/comphelper/fileurl.hxx
@@ -28,7 +28,7 @@
namespace comphelper
{
// Return true iff url is an absolute URL of "file" scheme:
-COMPHELPER_DLLPUBLIC bool isFileUrl(OUString const& url);
+COMPHELPER_DLLPUBLIC bool isFileUrl(std::u16string_view url);
}
#endif
diff --git a/include/connectivity/dbtools.hxx b/include/connectivity/dbtools.hxx
index 58f34f170be8..17f329ad3302 100644
--- a/include/connectivity/dbtools.hxx
+++ b/include/connectivity/dbtools.hxx
@@ -367,7 +367,7 @@ namespace dbtools
/** quote the given name with the given quote string.
*/
- OOO_DLLPUBLIC_DBTOOLS OUString quoteName(const OUString& _rQuote, const OUString& _rName);
+ OOO_DLLPUBLIC_DBTOOLS OUString quoteName(std::u16string_view _rQuote, const OUString& _rName);
/** quote the given table name (which may contain a catalog and a schema) according to the rules provided by the meta data
*/
diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx
index f59e2d683def..e94b871ddc1e 100644
--- a/include/i18nlangtag/mslangid.hxx
+++ b/include/i18nlangtag/mslangid.hxx
@@ -261,7 +261,7 @@ public:
/** Convert x-... privateuse, used by convertLocaleToLanguageImpl(Locale) */
I18NLANGTAG_DLLPRIVATE static LanguageType convertPrivateUseToLanguage(
- const OUString& rPriv );
+ std::u16string_view rPriv );
/** Used by LanguageTag::canonicalize() */
I18NLANGTAG_DLLPRIVATE static css::lang::Locale getOverride(
diff --git a/include/o3tl/string_view.hxx b/include/o3tl/string_view.hxx
index 91088aaae745..36b786e534e2 100644
--- a/include/o3tl/string_view.hxx
+++ b/include/o3tl/string_view.hxx
@@ -30,6 +30,12 @@ inline bool equalsAscii(std::u16string_view s1, std::string_view s2)
== 0;
}
+// Like OUString::compareToAscii, but for std::u16string_view and std::string_view:
+inline int compareToAscii(std::u16string_view s1, std::string_view s2)
+{
+ return rtl_ustr_asciil_reverseCompare_WithLength(s1.data(), s1.size(), s2.data(), s2.size());
+};
+
// Like OUString::equalsIgnoreAsciiCase, but for two std::u16string_view:
inline bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
{
@@ -41,6 +47,14 @@ inline bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2
== 0;
};
+inline bool equalsIgnoreAsciiCase(std::u16string_view s1, std::string_view s2)
+{
+ return s1.size() == s2.size()
+ && (rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(s1.data(), s1.size(),
+ s2.data(), s2.size())
+ == 0);
+}
+
inline bool equalsIgnoreAsciiCase(std::string_view s1, std::string_view s2)
{
if (s1.size() != s2.size())
@@ -66,6 +80,41 @@ inline bool matchIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2,
== 0;
}
+// Like OUString::matchIgnoreAsciiCase, but for std::u16string_view and std::string_view:
+inline bool matchIgnoreAsciiCase(std::u16string_view s1, std::string_view s2,
+ sal_Int32 fromIndex = 0)
+{
+ return rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength(
+ s1.data() + fromIndex, s1.size() - fromIndex, s2.data(), s2.size())
+ == 0;
+}
+
+// Like OUString::endsWithIgnoreAsciiCase, but for std::u16string_view
+inline bool endsWithIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2,
+ std::u16string_view* rest = nullptr)
+{
+ auto const b = s2.size() <= s1.size() && matchIgnoreAsciiCase(s1, s2, s1.size() - s2.size());
+ if (b && rest != nullptr)
+ {
+ *rest = s1.substr(0, s1.size() - s2.size());
+ }
+ return b;
+}
+
+inline bool endsWithIgnoreAsciiCase(std::u16string_view s1, std::string_view s2,
+ std::u16string_view* rest = nullptr)
+{
+ auto const b = s2.size() <= s1.size()
+ && rtl_ustr_ascii_compareIgnoreAsciiCase_WithLengths(
+ s1.data() + s1.size() - s2.size(), s2.size(), s2.data(), s2.size())
+ == 0;
+ if (b && rest != nullptr)
+ {
+ *rest = s1.substr(0, s1.size() - s2.size());
+ }
+ return b;
+}
+
// Similar to O[U]String::getToken, returning the first token of a std::[u16]string_view starting
// at a given position.
//
@@ -456,6 +505,7 @@ inline double toDouble(std::string_view str)
{
return rtl_math_stringToDouble(str.data(), str.data() + str.size(), '.', 0, nullptr, nullptr);
}
-}
+
+} // namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/include/oox/core/filterdetect.hxx b/include/oox/core/filterdetect.hxx
index 3e3a0df96fa5..8b01bcc5f285 100644
--- a/include/oox/core/filterdetect.hxx
+++ b/include/oox/core/filterdetect.hxx
@@ -84,7 +84,7 @@ public:
private:
void parseRelationship( const AttributeList& rAttribs );
- OUString getFilterNameFromContentType( std::u16string_view rContentType, const OUString& rFileName );
+ OUString getFilterNameFromContentType( std::u16string_view rContentType, std::u16string_view rFileName );
void parseContentTypesDefault( const AttributeList& rAttribs );
void parseContentTypesOverride( const AttributeList& rAttribs );
diff --git a/include/sfx2/linkmgr.hxx b/include/sfx2/linkmgr.hxx
index e4f58a996480..dddd8a54e288 100644
--- a/include/sfx2/linkmgr.hxx
+++ b/include/sfx2/linkmgr.hxx
@@ -157,7 +157,7 @@ public:
// if the mimetype says graphic/bitmap/gdimetafile then get the
// graphic from the Any. Return says no errors
- bool GetGraphicFromAny(const OUString& rMimeType,
+ bool GetGraphicFromAny(std::u16string_view rMimeType,
const css::uno::Any & rValue,
Graphic& rGrf,
weld::Window* pParentWin);
diff --git a/include/sfx2/objsh.hxx b/include/sfx2/objsh.hxx
index e3a5b4a022f1..3a88131b8f27 100644
--- a/include/sfx2/objsh.hxx
+++ b/include/sfx2/objsh.hxx
@@ -418,7 +418,7 @@ public:
void SetUseThumbnailSave( bool _bNew );
void SetLoadReadonly( bool _bReadonly );
void SetSaveVersionOnClose( bool bSet );
- void ResetFromTemplate( const OUString& rTemplateName, const OUString& rFileName );
+ void ResetFromTemplate( const OUString& rTemplateName, std::u16string_view rFileName );
// TODO/LATER: the following two methods should be replaced by Get/SetModifPasswordInfo in future
sal_uInt32 GetModifyPasswordHash() const;
diff --git a/include/sot/exchange.hxx b/include/sot/exchange.hxx
index c7fed6d3b851..f778d86a9714 100644
--- a/include/sot/exchange.hxx
+++ b/include/sot/exchange.hxx
@@ -120,7 +120,7 @@ public:
static bool GetFormatDataFlavor( SotClipboardFormatId nFormat, css::datatransfer::DataFlavor& rFlavor );
static OUString GetFormatMimeType( SotClipboardFormatId nFormat );
static bool IsInternal( const SvGlobalName& );
- static SotClipboardFormatId GetFormatIdFromMimeType( const OUString& rMimeType );
+ static SotClipboardFormatId GetFormatIdFromMimeType( std::u16string_view rMimeType );
// same for XTransferable interface
static sal_uInt8 GetExchangeAction(
diff --git a/include/test/sheet/xspreadsheets2.hxx b/include/test/sheet/xspreadsheets2.hxx
index 1b8d9b8023e3..30311a40c42e 100644
--- a/include/test/sheet/xspreadsheets2.hxx
+++ b/include/test/sheet/xspreadsheets2.hxx
@@ -48,7 +48,7 @@ private:
css::uno::Reference< css::sheet::XSpreadsheetDocument> getDoc(const OUString&);
static css::uno::Reference< css::sheet::XNamedRanges> getNamedRanges(css::uno::Reference< css::sheet::XSpreadsheetDocument > const &);
void importSheetToCopy();
- static bool isExternalReference(const OUString& aDestContent, std::u16string_view aSrcContent );
+ static bool isExternalReference(std::u16string_view aDestContent, std::u16string_view aSrcContent );
css::uno::Reference< css::sheet::XSpreadsheetDocument> xDestDoc;
css::uno::Reference< css::sheet::XSpreadsheet > xDestSheet;
diff --git a/o3tl/qa/test-string_view.cxx b/o3tl/qa/test-string_view.cxx
index 37cb4118a8e2..a95afc923c2c 100644
--- a/o3tl/qa/test-string_view.cxx
+++ b/o3tl/qa/test-string_view.cxx
@@ -699,6 +699,37 @@ private:
o3tl::getToken(suTokenStr, 0, ';', n);
// should not GPF with negative index
}
+ {
+ CPPUNIT_ASSERT_MESSAGE("compareToAscii",
+ OUString(u"aaa").compareToAscii("aa")
+ > 0); // just for comparison to following line
+ CPPUNIT_ASSERT_MESSAGE("compareToAscii", o3tl::compareToAscii(u"aaa", "aa") > 0);
+
+ OUString aa(u"aa");
+ CPPUNIT_ASSERT_MESSAGE("compareToAscii",
+ aa.compareToAscii("aaa")
+ < 0); // just for comparison to following line
+ CPPUNIT_ASSERT_MESSAGE("compareToAscii", o3tl::compareToAscii(u"aa", "aaa") < 0);
+
+ CPPUNIT_ASSERT_MESSAGE(
+ "equalsIgnoreAsciiCase",
+ aa.equalsIgnoreAsciiCase("AA")); // just for comparison to following line
+ CPPUNIT_ASSERT_MESSAGE("equalsIgnoreAsciiCase",
+ o3tl::equalsIgnoreAsciiCase(u"aa", "AA"));
+
+ CPPUNIT_ASSERT_MESSAGE(
+ "matchIgnoreAsciiCase",
+ aa.matchIgnoreAsciiCase("a")); // just for comparison to following line
+ CPPUNIT_ASSERT_MESSAGE("matchIgnoreAsciiCase", o3tl::matchIgnoreAsciiCase(u"aa", "a"));
+
+ CPPUNIT_ASSERT_MESSAGE(
+ "endsWithIgnoreAsciiCase",
+ aa.endsWithIgnoreAsciiCase("a")); // just for comparison to following line
+ CPPUNIT_ASSERT_MESSAGE("endsWithIgnoreAsciiCase",
+ o3tl::endsWithIgnoreAsciiCase(u"aa", "a"));
+ CPPUNIT_ASSERT_MESSAGE("endsWithIgnoreAsciiCase",
+ o3tl::endsWithIgnoreAsciiCase(u"aa", u"a"));
+ }
}
};
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index 6f22d612aa13..7c52f81e615d 100644
--- a/oox/source/core/filterdetect.cxx
+++ b/oox/source/core/filterdetect.cxx
@@ -35,6 +35,7 @@
#include <com/sun/star/uri/UriReferenceFactory.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
+#include <o3tl/string_view.hxx>
#include <utility>
using namespace ::com::sun::star;
@@ -175,9 +176,9 @@ void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs )
}
}
-OUString FilterDetectDocHandler::getFilterNameFromContentType( std::u16string_view rContentType, const OUString& rFileName )
+OUString FilterDetectDocHandler::getFilterNameFromContentType( std::u16string_view rContentType, std::u16string_view rFileName )
{
- bool bDocm = rFileName.endsWithIgnoreAsciiCase(".docm");
+ bool bDocm = o3tl::endsWithIgnoreAsciiCase(rFileName, ".docm");
if( rContentType == u"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" && !bDocm )
{
diff --git a/sc/source/core/inc/addinhelpid.hxx b/sc/source/core/inc/addinhelpid.hxx
index 1130cb844d58..ccc5406d8fbb 100644
--- a/sc/source/core/inc/addinhelpid.hxx
+++ b/sc/source/core/inc/addinhelpid.hxx
@@ -39,7 +39,7 @@ public:
void SetServiceName( std::u16string_view rServiceName );
/** @return The help ID of the function with given built-in name or 0 if not found. */
- OUString GetHelpId( const OUString& rFuncName ) const;
+ OUString GetHelpId( std::u16string_view rFuncName ) const;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/addinhelpid.cxx b/sc/source/core/tool/addinhelpid.cxx
index 9a7cd9213749..9c44e269d00e 100644
--- a/sc/source/core/tool/addinhelpid.cxx
+++ b/sc/source/core/tool/addinhelpid.cxx
@@ -19,6 +19,7 @@
#include <addinhelpid.hxx>
#include <helpids.h>
+#include <o3tl/string_view.hxx>
// A struct containing the built-in function name and the built-in help ID.
struct ScUnoAddInHelpId
@@ -183,7 +184,7 @@ void ScUnoAddInHelpIdGenerator::SetServiceName( std::u16string_view rServiceName
nArrayCount = nSize / sizeof( ScUnoAddInHelpId );
}
-OUString ScUnoAddInHelpIdGenerator::GetHelpId( const OUString& rFuncName ) const
+OUString ScUnoAddInHelpIdGenerator::GetHelpId( std::u16string_view rFuncName ) const
{
if( !pCurrHelpIds || !nArrayCount )
return {};
@@ -194,7 +195,7 @@ OUString ScUnoAddInHelpIdGenerator::GetHelpId( const OUString& rFuncName ) const
while( pFirst <= pLast )
{
const ScUnoAddInHelpId* pMiddle = pFirst + (pLast - pFirst) / 2;
- sal_Int32 nResult = rFuncName.compareToAscii( pMiddle->pFuncName );
+ sal_Int32 nResult = o3tl::compareToAscii( rFuncName, pMiddle->pFuncName );
if( !nResult )
return pMiddle->sHelpId;
else if( nResult < 0 )
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 52bab34899ff..b8fe537ef3f9 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -22,6 +22,7 @@
#include <comphelper/string.hxx>
#include <o3tl/float_int_conversion.hxx>
+#include <o3tl/string_view.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/linkmgr.hxx>
#include <sfx2/objsh.hxx>
@@ -3218,7 +3219,7 @@ void ScInterpreter::ScHyperLink()
http://ec.europa.eu/economy_finance/euro/adoption/conversion/
http://ec.europa.eu/economy_finance/euro/countries/
*/
-static bool lclConvertMoney( const OUString& aSearchUnit, double& rfRate, int& rnDec )
+static bool lclConvertMoney( std::u16string_view aSearchUnit, double& rfRate, int& rnDec )
{
struct ConvertInfo
{
@@ -3251,7 +3252,7 @@ static bool lclConvertMoney( const OUString& aSearchUnit, double& rfRate, int& r
};
for (const auto & i : aConvertTable)
- if ( aSearchUnit.equalsIgnoreAsciiCaseAscii( i.pCurrText ) )
+ if ( o3tl::equalsIgnoreAsciiCase( aSearchUnit, i.pCurrText ) )
{
rfRate = i.fRate;
rnDec = i.nDec;
diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx
index 4f8155cae40e..e79b56211105 100644
--- a/sc/source/filter/oox/defnamesbuffer.cxx
+++ b/sc/source/filter/oox/defnamesbuffer.cxx
@@ -107,10 +107,10 @@ sal_Unicode lclGetBuiltinIdFromPrefixedName( std::u16string_view aModelName )
}
/** returns the built-in name identifier from a built-in base name, e.g. 'Print_Area'. */
-sal_Unicode lclGetBuiltinIdFromBaseName( const OUString& rModelName )
+sal_Unicode lclGetBuiltinIdFromBaseName( std::u16string_view rModelName )
{
for( sal_Unicode cBuiltinId = 0; cBuiltinId < SAL_N_ELEMENTS( sppcBaseNames ); ++cBuiltinId )
- if( rModelName.equalsIgnoreAsciiCaseAscii( sppcBaseNames[ cBuiltinId ] ) )
+ if( o3tl::equalsIgnoreAsciiCase( rModelName, sppcBaseNames[ cBuiltinId ] ) )
return cBuiltinId;
return BIFF_DEFNAME_UNKNOWN;
}
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index 126689d7bce8..df8f77c8553c 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -308,7 +308,7 @@ static void lcl_SaveSeparators(
aItem.PutProperties(aNames, aValues);
}
-ScImportAsciiDlg::ScImportAsciiDlg(weld::Window* pParent, const OUString& aDatName,
+ScImportAsciiDlg::ScImportAsciiDlg(weld::Window* pParent, std::u16string_view aDatName,
SvStream* pInStream, ScImportAsciiCall eCall)
: GenericDialogController(pParent, "modules/scalc/ui/textimportcsv.ui", "TextImportCsvDialog")
, mpDatStream(pInStream)
@@ -353,7 +353,7 @@ ScImportAsciiDlg::ScImportAsciiDlg(weld::Window* pParent, const OUString& aDatNa
case SC_IMPORTFILE:
if (!comphelper::LibreOfficeKit::isActive())
{
- aName += " - [" + aDatName + "]";
+ aName += OUString::Concat(" - [") + aDatName + "]";
m_xDialog->set_title(aName);
}
break;
@@ -362,7 +362,7 @@ ScImportAsciiDlg::ScImportAsciiDlg(weld::Window* pParent, const OUString& aDatNa
}
// To be able to prefill the correct values based on the file extension
- bool bIsTSV = (aDatName.endsWithIgnoreAsciiCase(".tsv") || aDatName.endsWithIgnoreAsciiCase(".tab"));
+ bool bIsTSV = (o3tl::endsWithIgnoreAsciiCase(aDatName, ".tsv") || o3tl::endsWithIgnoreAsciiCase(aDatName, ".tab"));
// Default options are set in officecfg/registry/schema/org/openoffice/Office/Calc.xcs
OUString sFieldSeparators(",;\t");
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 87735c2087a3..507508419a3d 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -284,7 +284,7 @@ void ScImportExport::EndPaste(bool bAutoRowHeight)
}
-bool ScImportExport::ExportData( const OUString& rMimeType,
+bool ScImportExport::ExportData( std::u16string_view rMimeType,
css::uno::Any & rValue )
{
SvMemoryStream aStrm;
diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx
index 2631500e98a9..e30182f7e242 100644
--- a/sc/source/ui/inc/impex.hxx
+++ b/sc/source/ui/inc/impex.hxx
@@ -144,7 +144,7 @@ public:
bool ImportStream( SvStream&, const OUString& rBaseURL, SotClipboardFormatId );
bool ExportStream( SvStream&, const OUString& rBaseURL, SotClipboardFormatId );
- bool ExportData( const OUString& rMimeType,
+ bool ExportData( std::u16string_view rMimeType,
css::uno::Any & rValue );
// after import
diff --git a/sc/source/ui/inc/scuiasciiopt.hxx b/sc/source/ui/inc/scuiasciiopt.hxx
index ee7f512b3548..f966bd2be895 100644
--- a/sc/source/ui/inc/scuiasciiopt.hxx
+++ b/sc/source/ui/inc/scuiasciiopt.hxx
@@ -82,7 +82,7 @@ class ScImportAsciiDlg : public weld::GenericDialogController
public:
ScImportAsciiDlg(
- weld::Window* pParent, const OUString& aDatName,
+ weld::Window* pParent, std::u16string_view aDatName,
SvStream* pInStream, ScImportAsciiCall eCall );
virtual ~ScImportAsciiDlg() override;
diff --git a/sd/source/filter/eppt/pptexanimations.cxx b/sd/source/filter/eppt/pptexanimations.cxx
index faef2b48522e..cbc65ceff792 100644
--- a/sd/source/filter/eppt/pptexanimations.cxx
+++ b/sd/source/filter/eppt/pptexanimations.cxx
@@ -1515,7 +1515,7 @@ void AnimationExporter::exportAnimateSet( SvStream& rStrm, const Reference< XAni
exportAnimateTarget( rStrm, xNode, 0, nAfterEffectType );
}
-sal_uInt32 AnimationExporter::GetValueTypeForAttributeName( const OUString& rAttributeName )
+sal_uInt32 AnimationExporter::GetValueTypeForAttributeName( std::u16string_view rAttributeName )
{
sal_uInt32 nValueType = 0;
@@ -1555,7 +1555,7 @@ sal_uInt32 AnimationExporter::GetValueTypeForAttributeName( const OUString& rAtt
const Entry* pPtr = &lcl_attributeMap[ 0 ];
while( pPtr->pName )
{
- if ( rAttributeName.equalsIgnoreAsciiCaseAscii( pPtr->pName ) )
+ if ( o3tl::equalsIgnoreAsciiCase( rAttributeName, pPtr->pName ) )
{
nValueType = pPtr->nType;
break;
diff --git a/sd/source/filter/eppt/pptexanimations.hxx b/sd/source/filter/eppt/pptexanimations.hxx
index b898c0de0a93..006a5fe062e7 100644
--- a/sd/source/filter/eppt/pptexanimations.hxx
+++ b/sd/source/filter/eppt/pptexanimations.hxx
@@ -125,7 +125,7 @@ public:
static void GetUserData( const css::uno::Sequence< css::beans::NamedValue >& rUserData, const css::uno::Any ** pAny, std::size_t nLen );
static sal_uInt32 TranslatePresetSubType( const sal_uInt32 nPresetClass, const sal_uInt32 nPresetId, std::u16string_view rPresetSubType );
static sal_uInt32 GetPresetID( std::u16string_view aPreset, sal_uInt32 nAPIPresetClass, bool& bPresetId );
- static sal_uInt32 GetValueTypeForAttributeName( const OUString& rAttributeName );
+ static sal_uInt32 GetValueTypeForAttributeName( std::u16string_view rAttributeName );
static const char* FindTransitionName( const sal_Int16 nType, const sal_Int16 nSubType, const bool bDirection );
static css::uno::Reference< css::drawing::XShape > getTargetElementShape( const css::uno::Any& rAny, sal_Int32& rBegin, sal_Int32& rEnd, bool& rParagraphTarget );
diff --git a/sd/source/filter/eppt/pptx-animations-nodectx.cxx b/sd/source/filter/eppt/pptx-animations-nodectx.cxx
index e538a0ca4e99..585917b4f864 100644
--- a/sd/source/filter/eppt/pptx-animations-nodectx.cxx
+++ b/sd/source/filter/eppt/pptx-animations-nodectx.cxx
@@ -23,6 +23,8 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <o3tl/any.hxx>
+#include <o3tl/string_view.hxx>
+
using ::com::sun::star::beans::NamedValue;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::drawing::XShape;
@@ -49,13 +51,14 @@ bool isValidTarget(const Any& rTarget)
return (rTarget >>= aParagraphTarget) && aParagraphTarget.Shape.is();
}
-bool IsAudioURL(const OUString& rURL)
+bool IsAudioURL(std::u16string_view rURL)
{
- return rURL.endsWithIgnoreAsciiCase(".wav") || rURL.endsWithIgnoreAsciiCase(".m4a");
+ return o3tl::endsWithIgnoreAsciiCase(rURL, ".wav")
+ || o3tl::endsWithIgnoreAsciiCase(rURL, ".m4a");
}
/// Returns if rURL has an extension which is a video format.
-bool IsVideoURL(const OUString& rURL) { return rURL.endsWithIgnoreAsciiCase(".mp4"); }
+bool IsVideoURL(std::u16string_view rURL) { return o3tl::endsWithIgnoreAsciiCase(rURL, ".mp4"); }
bool initCondList(const Any& rAny, std::vector<Cond>& rList, bool bIsMainSeqChild)
{
diff --git a/sd/source/filter/eppt/pptx-animations.cxx b/sd/source/filter/eppt/pptx-animations.cxx
index 1effa82a9ab8..9e4e1b3d2fd8 100644
--- a/sd/source/filter/eppt/pptx-animations.cxx
+++ b/sd/source/filter/eppt/pptx-animations.cxx
@@ -18,6 +18,7 @@
*/
#include <o3tl/any.hxx>
+#include <o3tl/string_view.hxx>
#include <oox/token/tokens.hxx>
#include "epptooxml.hxx"
#include <sax/fshelper.hxx>
@@ -508,13 +509,14 @@ public:
};
/// Returns if rURL has an extension which is an audio format.
-bool IsAudioURL(const OUString& rURL)
+bool IsAudioURL(std::u16string_view rURL)
{
- return rURL.endsWithIgnoreAsciiCase(".wav") || rURL.endsWithIgnoreAsciiCase(".m4a");
+ return o3tl::endsWithIgnoreAsciiCase(rURL, ".wav")
+ || o3tl::endsWithIgnoreAsciiCase(rURL, ".m4a");
}
/// Returns if rURL has an extension which is a video format.
-bool IsVideoURL(const OUString& rURL) { return rURL.endsWithIgnoreAsciiCase(".mp4"); }
+bool IsVideoURL(std::u16string_view rURL) { return o3tl::endsWithIgnoreAsciiCase(rURL, ".mp4"); }
}
namespace oox::core
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 3dd2383c1074..b3b11d626362 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -101,7 +101,7 @@ using namespace ::com::sun::star::container;
using namespace ::cppu;
using namespace ::sfx2;
-void SetTemplate_Impl( const OUString &rFileName,
+void SetTemplate_Impl( std::u16string_view rFileName,
const OUString &rLongName,
SfxObjectShell *pDoc)
{
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index aeefbf10da20..6a3e0c7e8821 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -506,7 +506,7 @@ SotClipboardFormatId LinkManager::RegisterStatusInfoId()
return nFormat;
}
-bool LinkManager::GetGraphicFromAny(const OUString& rMimeType,
+bool LinkManager::GetGraphicFromAny(std::u16string_view rMimeType,
const css::uno::Any & rValue,
Graphic& rGraphic,
weld::Window* pParentWin)
diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index 06f125ec9e15..e51e49481d89 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -271,7 +271,7 @@ private:
Content& aNewFolder );
static OUString CreateNewUniqueFileWithPrefix( std::u16string_view aPath,
const OUString& aPrefix,
- const OUString& aExt );
+ std::u16string_view aExt );
std::vector< beans::StringPair > ReadUINamesForTemplateDir_Impl( std::u16string_view aUserPath );
bool UpdateUINamesForTemplateDir_Impl( std::u16string_view aUserPath,
@@ -841,7 +841,7 @@ bool SfxDocTplService::CreateNewUniqueFolderWithPrefix( std::u16string_view aPat
OUString SfxDocTplService::CreateNewUniqueFileWithPrefix( std::u16string_view aPath,
const OUString& aPrefix,
- const OUString& aExt )
+ std::u16string_view aExt )
{
OUString aNewFileURL;
INetURLObject aDirPath( aPath );
@@ -858,7 +858,7 @@ OUString SfxDocTplService::CreateNewUniqueFileWithPrefix( std::u16string_view aP
OUString aTryName = aPrefix;
if ( nInd )
aTryName += OUString::number( nInd );
- if ( aExt.toChar() != '.' )
+ if ( aExt.empty() || aExt[0] != '.' )
aTryName += ".";
aTryName += aExt;
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index caf222c61d2d..77622105a215 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -569,7 +569,7 @@ bool SfxObjectShell::IsHelpDocument() const
return (pFilter && pFilter->GetFilterName() == "writer_web_HTML_help");
}
-void SfxObjectShell::ResetFromTemplate( const OUString& rTemplateName, const OUString& rFileName )
+void SfxObjectShell::ResetFromTemplate( const OUString& rTemplateName, std::u16string_view rFileName )
{
// only care about resetting this data for LibreOffice formats otherwise
if ( !IsOwnStorageFormat( *GetMedium()) )
diff --git a/sfx2/source/inc/appopen.hxx b/sfx2/source/inc/appopen.hxx
index df9057bfa197..5e32a249047a 100644
--- a/sfx2/source/inc/appopen.hxx
+++ b/sfx2/source/inc/appopen.hxx
@@ -29,7 +29,7 @@ class SfxObjectShell;
ErrCode CheckPasswd_Impl(SfxObjectShell* pDoc, SfxMedium* pFile);
-void SetTemplate_Impl(const OUString&, const OUString&, SfxObjectShell*);
+void SetTemplate_Impl(std::u16string_view, const OUString&, SfxObjectShell*);
#endif
diff --git a/sot/source/base/exchange.cxx b/sot/source/base/exchange.cxx
index 582ca49c5598..9777c3117917 100644
--- a/sot/source/base/exchange.cxx
+++ b/sot/source/base/exchange.cxx
@@ -381,18 +381,18 @@ OUString SotExchange::GetFormatMimeType( SotClipboardFormatId nFormat )
|*
*************************************************************************/
-SotClipboardFormatId SotExchange::GetFormatIdFromMimeType( const OUString& rMimeType )
+SotClipboardFormatId SotExchange::GetFormatIdFromMimeType( std::u16string_view rMimeType )
{
const DataFlavorRepresentation *pFormatArray_Impl = FormatArray_Impl();
for( SotClipboardFormatId i = SotClipboardFormatId::STRING; i <= SotClipboardFormatId::FILE_LIST; ++i )
- if( rMimeType.equals( pFormatArray_Impl[ static_cast<int>(i) ].pMimeType ) )
+ if( rMimeType == pFormatArray_Impl[ static_cast<int>(i) ].pMimeType )
return i;
// BM: the chart format 105 ("StarChartDocument 5.0") was written
// only into 5.1 chart documents - in 5.0 and 5.2 it was 42 ("StarChart 5.0")
// The registry only contains the entry for the 42 format id.
for( SotClipboardFormatId i = SotClipboardFormatId::RTF; i <= SotClipboardFormatId::USER_END; ++i )
- if( rMimeType.equals( pFormatArray_Impl[ static_cast<int>(i) ].pMimeType ) )
+ if( rMimeType == pFormatArray_Impl[ static_cast<int>(i) ].pMimeType )
return ( (i == SotClipboardFormatId::STARCHARTDOCUMENT_50)
? SotClipboardFormatId::STARCHART_50
: i );
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 4bf65c5e364b..9e180684fbe5 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -613,11 +613,11 @@ const SvxShapeControlPropertyMapping[] =
namespace
{
- bool lcl_convertPropertyName( const OUString& rApiName, OUString& rInternalName )
+ bool lcl_convertPropertyName( std::u16string_view rApiName, OUString& rInternalName )
{
for( const auto & rEntry : SvxShapeControlPropertyMapping )
{
- if( rApiName.reverseCompareTo( rEntry.msAPIName ) == 0 )
+ if( rApiName == rEntry.msAPIName )
{
rInternalName = rEntry.msFormName;
}
diff --git a/sw/inc/SwAppletImpl.hxx b/sw/inc/SwAppletImpl.hxx
index 24384fda4500..ea30a104ce69 100644
--- a/sw/inc/SwAppletImpl.hxx
+++ b/sw/inc/SwAppletImpl.hxx
@@ -45,7 +45,7 @@ class SwApplet_Impl
OUString m_sAlt;
public:
- static SwHtmlOptType GetOptionType( const OUString& rName, bool bApplet );
+ static SwHtmlOptType GetOptionType( std::u16string_view rName, bool bApplet );
SwApplet_Impl( SfxItemPool& rPool );
SwApplet_Impl( SfxItemSet aSet ): m_aItemSet (std::move(aSet)) {}
~SwApplet_Impl();
diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx
index 429eda6611cd..d2250d18c572 100644
--- a/sw/source/filter/basflt/fltini.cxx
+++ b/sw/source/filter/basflt/fltini.cxx
@@ -490,14 +490,14 @@ const CharSetNameMap *GetCharSetNameMap()
/*
Get a rtl_TextEncoding from its name
*/
-rtl_TextEncoding CharSetFromName(const OUString& rChrSetStr)
+rtl_TextEncoding CharSetFromName(std::u16string_view rChrSetStr)
{
const CharSetNameMap *pStart = GetCharSetNameMap();
rtl_TextEncoding nRet = pStart->eCode;
for(const CharSetNameMap *pMap = pStart; pMap->pName; ++pMap)
{
- if(rChrSetStr.equalsIgnoreAsciiCaseAscii(pMap->pName))
+ if(o3tl::equalsIgnoreAsciiCase(rChrSetStr, pMap->pName))
{
nRet = pMap->eCode;
break;
@@ -549,7 +549,7 @@ void SwAsciiOptions::ReadUserData( std::u16string_view rStr )
sal_Int32 nToken = 0;
std::u16string_view sToken = o3tl::getToken(rStr, 0, ',', nToken); // 1. Charset name
if (!sToken.empty())
- m_eCharSet = CharSetFromName(OUString(sToken));
+ m_eCharSet = CharSetFromName(sToken);
if (nToken >= 0 && !(sToken = o3tl::getToken(rStr, 0, ',', nToken)).empty()) // 2. Line ending type
{
if (o3tl::equalsIgnoreAsciiCase(sToken, u"CRLF"))
diff --git a/sw/source/filter/html/SwAppletImpl.cxx b/sw/source/filter/html/SwAppletImpl.cxx
index 16766d9a3b8a..9c0d64bb7c01 100644
--- a/sw/source/filter/html/SwAppletImpl.cxx
+++ b/sw/source/filter/html/SwAppletImpl.cxx
@@ -26,6 +26,7 @@
#include <comphelper/embeddedobjectcontainer.hxx>
#include <comphelper/classids.hxx>
#include <com/sun/star/uno/Any.hxx>
+#include <o3tl/string_view.hxx>
#include <svtools/embedhlp.hxx>
#include <tools/globname.hxx>
#include <tools/urlobj.hxx>
@@ -33,75 +34,75 @@
using namespace com::sun::star;
-SwHtmlOptType SwApplet_Impl::GetOptionType( const OUString& rName, bool bApplet )
+SwHtmlOptType SwApplet_Impl::GetOptionType( std::u16string_view rName, bool bApplet )
{
SwHtmlOptType nType = bApplet ? SwHtmlOptType::PARAM : SwHtmlOptType::TAG;
- switch( rName.toChar() )
+ switch( rName[0] )
{
case 'A':
case 'a':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_align ) ||
- rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_alt ) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_align ) ||
+ o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_alt ) )
nType = SwHtmlOptType::IGNORE;
else if( bApplet &&
- (rName == "ARCHIVE" || rName == "ARCHIVES" ) )
+ (rName == u"ARCHIVE" || rName == u"ARCHIVES" ) )
nType = SwHtmlOptType::TAG;
break;
case 'C':
case 'c':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_class ) ||
- (bApplet && (rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_code ) ||
- rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_codebase ))) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_class ) ||
+ (bApplet && (o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_code ) ||
+ o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_codebase ))) )
nType = SwHtmlOptType::IGNORE;
break;
case 'H':
case 'h':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_height ) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_height ) )
nType = SwHtmlOptType::SIZE;
- else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_hspace ) ||
- (!bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SW_HTML_O_Hidden )) )
+ else if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_hspace ) ||
+ (!bApplet && o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SW_HTML_O_Hidden )) )
nType = SwHtmlOptType::IGNORE;
break;
case 'I':
case 'i':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_id ) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_id ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'M':
case 'm':
- if( bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
+ if( bApplet && o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'N':
case 'n':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_name ) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_name ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'O':
case 'o':
- if( bApplet && rName == "OBJECT" )
+ if( bApplet && rName == u"OBJECT" )
nType = SwHtmlOptType::TAG;
break;
case 'S':
case 's':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_style ) ||
- (!bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_src )) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_style ) ||
+ (!bApplet && o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_src )) )
nType = SwHtmlOptType::IGNORE;
break;
case 'T':
case 't':
- if( !bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_type ) )
+ if( !bApplet && o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_type ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'V':
case 'v':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_vspace ) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_vspace ) )
nType = SwHtmlOptType::IGNORE;
break;
case 'W':
case 'w':
- if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_width ) )
+ if( o3tl::equalsIgnoreAsciiCase( rName, OOO_STRING_SVTOOLS_HTML_O_width ) )
nType = SwHtmlOptType::SIZE;
break;
}
diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx
index 744157f73cf3..c1eff7ef7cb7 100644
--- a/sw/source/filter/html/htmlfld.cxx
+++ b/sw/source/filter/html/htmlfld.cxx
@@ -20,6 +20,7 @@
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/frame/XModel.hpp>
+#include <o3tl/string_view.hxx>
#include <osl/diagnose.h>
#include <docsh.hxx>
#include <IDocumentFieldsAccess.hxx>
@@ -196,12 +197,12 @@ HTMLOptionEnum<SwFileNameFormat> const aHTMLFileNameFieldFormatTable[] =
{ nullptr, SwFileNameFormat(0) }
};
-SvxNumType SwHTMLParser::GetNumType( const OUString& rStr, SvxNumType nDfltType )
+SvxNumType SwHTMLParser::GetNumType( std::u16string_view rStr, SvxNumType nDfltType )
{
const HTMLOptionEnum<SvxNumType> *pOptEnums = aHTMLPageNumFieldFormatTable;
while( pOptEnums->pName )
{
- if( rStr.equalsIgnoreAsciiCaseAscii( pOptEnums->pName ) )
+ if( o3tl::equalsIgnoreAsciiCase( rStr, pOptEnums->pName ) )
return pOptEnums->nValue;
pOptEnums++;
}
diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx
index 9bb4b2743552..9b43f079d4fb 100644
--- a/sw/source/filter/html/htmlplug.cxx
+++ b/sw/source/filter/html/htmlplug.cxx
@@ -333,7 +333,7 @@ void SwHTMLParser::SetSpace( const Size& rPixSpace,
}
}
-OUString SwHTMLParser::StripQueryFromPath(const OUString& rBase, const OUString& rPath)
+OUString SwHTMLParser::StripQueryFromPath(std::u16string_view rBase, const OUString& rPath)
{
if (!comphelper::isFileUrl(rBase))
return rPath;
diff --git a/sw/source/filter/html/svxcss1.cxx b/sw/source/filter/html/svxcss1.cxx
index 3155d62f2984..c50d7312b76f 100644
--- a/sw/source/filter/html/svxcss1.cxx
+++ b/sw/source/filter/html/svxcss1.cxx
@@ -56,6 +56,7 @@
#include <vcl/svapp.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
+#include <o3tl/string_view.hxx>
#include <hintids.hxx>
@@ -866,11 +867,11 @@ void SvxCSS1Parser::ParseStyleOption( const OUString& rIn,
}
bool SvxCSS1Parser::GetEnum( const CSS1PropertyEnum *pPropTable,
- const OUString &rValue, sal_uInt16& rEnum )
+ std::u16string_view rValue, sal_uInt16& rEnum )
{
while( pPropTable->pName )
{
- if( !rValue.equalsIgnoreAsciiCaseAscii( pPropTable->pName ) )
+ if( !o3tl::equalsIgnoreAsciiCase( rValue, pPropTable->pName ) )
pPropTable++;
else
break;
diff --git a/sw/source/filter/html/svxcss1.hxx b/sw/source/filter/html/svxcss1.hxx
index 30c5a7b4accb..985f98a079b7 100644
--- a/sw/source/filter/html/svxcss1.hxx
+++ b/sw/source/filter/html/svxcss1.hxx
@@ -258,7 +258,7 @@ public:
// convert a string to enum value
static bool GetEnum( const CSS1PropertyEnum *pPropTable,
- const OUString& rValue, sal_uInt16 &rEnum );
+ std::u16string_view rValue, sal_uInt16 &rEnum );
static void PixelToTwip( tools::Long &nWidth, tools::Long &nHeight );
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index 4f017327fe86..1c88e8add932 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -667,7 +667,7 @@ class SwHTMLParser : public SfxHTMLParser, public SvtListener
// <SDFIELD>
public:
- static SvxNumType GetNumType( const OUString& rStr, SvxNumType eDfltType );
+ static SvxNumType GetNumType( std::u16string_view rStr, SvxNumType eDfltType );
private:
void NewField();
void EndField();
@@ -953,7 +953,7 @@ public:
void NotifyMacroEventRead();
/// Strips query and fragment from a URL path if base URL is a file:// one.
- static OUString StripQueryFromPath(const OUString& rBase, const OUString& rPath);
+ static OUString StripQueryFromPath(std::u16string_view rBase, const OUString& rPath);
};
struct SwPendingData
diff --git a/test/source/sheet/xspreadsheets2.cxx b/test/source/sheet/xspreadsheets2.cxx
index 780e806b4deb..3bd539710480 100644
--- a/test/source/sheet/xspreadsheets2.cxx
+++ b/test/source/sheet/xspreadsheets2.cxx
@@ -26,6 +26,7 @@
#include <rtl/ustring.hxx>
#include <cppunit/TestAssert.h>
+#include <o3tl/string_view.hxx>
using namespace css;
using namespace css::uno;
@@ -350,12 +351,14 @@ void XSpreadsheets2::importSheetToCopy()
xDestSheet.set( xDestSheetIndexAccess->getByIndex(nDestPosEffective), UNO_QUERY_THROW);
}
-bool XSpreadsheets2::isExternalReference(const OUString& aDestContent, std::u16string_view aSrcContent )
+bool XSpreadsheets2::isExternalReference(std::u16string_view aDestContent, std::u16string_view aSrcContent )
{
- CPPUNIT_ASSERT(aDestContent.startsWith("'file://"));
+ CPPUNIT_ASSERT(o3tl::starts_with(aDestContent, u"'file://"));
- return (aDestContent.endsWithIgnoreAsciiCase(aSrcContent) // same cell address
- && aDestContent.indexOf(gaSrcFileName)>0); // contains source file name
+ if (!o3tl::endsWithIgnoreAsciiCase(aDestContent, aSrcContent)) // same cell address
+ return false;
+ size_t nPos = aDestContent.find(gaSrcFileName);
+ return nPos != std::u16string_view::npos && nPos > 0; // contains source file name
}
}
diff --git a/ucb/source/ucp/webdav-curl/ContentProperties.cxx b/ucb/source/ucp/webdav-curl/ContentProperties.cxx
index d78d138ab215..d76c03d7589d 100644
--- a/ucb/source/ucp/webdav-curl/ContentProperties.cxx
+++ b/ucb/source/ucp/webdav-curl/ContentProperties.cxx
@@ -25,6 +25,7 @@
#include "DateTimeHelper.hxx"
#include "webdavprovider.hxx"
#include "ContentProperties.hxx"
+#include <o3tl/string_view.hxx>
using namespace com::sun::star;
using namespace http_dav_ucp;
@@ -490,8 +491,7 @@ void ContentProperties::addProperty( const OUString & rName,
namespace
{
- bool isCachable( OUString const & rName,
- bool isCaseSensitive )
+ bool isCachable( std::u16string_view rName, bool isCaseSensitive )
{
const OUString aNonCachableProps [] =
{
@@ -518,11 +518,11 @@ namespace
{
if ( isCaseSensitive )
{
- if ( rName.equals( aNonCachableProps[ n ] ) )
+ if ( rName == aNonCachableProps[ n ] )
return false;
}
else
- if ( rName.equalsIgnoreAsciiCase( aNonCachableProps[ n ] ) )
+ if ( o3tl::equalsIgnoreAsciiCase( rName, aNonCachableProps[ n ] ) )
return false;
}
return true;
diff --git a/xmloff/inc/prstylecond.hxx b/xmloff/inc/prstylecond.hxx
index e658a83b9125..ca4240bb5375 100644
--- a/xmloff/inc/prstylecond.hxx
+++ b/xmloff/inc/prstylecond.hxx
@@ -19,6 +19,6 @@
#include <rtl/ustring.hxx>
-OUString GetParaStyleCondExternal(OUString const&);
+OUString GetParaStyleCondExternal(std::u16string_view);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/xmloff/source/style/prstylecond.cxx b/xmloff/source/style/prstylecond.cxx
index 4da002488c36..a7ab66f8352d 100644
--- a/xmloff/source/style/prstylecond.cxx
+++ b/xmloff/source/style/prstylecond.cxx
@@ -68,11 +68,11 @@ const ConditionMap g_ConditionMap[] =
{ "NumberingLevel10", XML_LIST_LEVEL, 10 }
};
-OUString GetParaStyleCondExternal( OUString const &internal)
+OUString GetParaStyleCondExternal( std::u16string_view internal)
{
for (size_t i = 0; i < SAL_N_ELEMENTS(g_ConditionMap); ++i)
{
- if (internal.compareToAscii( g_ConditionMap[i].aInternal ) == 0)
+ if (o3tl::equalsAscii(internal, g_ConditionMap[i].aInternal ))
{
OUString aResult = GetXMLToken( g_ConditionMap[i].nExternal ) +
"()";
diff --git a/xmloff/source/transform/TransformerBase.cxx b/xmloff/source/transform/TransformerBase.cxx
index e15e81d85d14..288f013a9253 100644
--- a/xmloff/source/transform/TransformerBase.cxx
+++ b/xmloff/source/transform/TransformerBase.cxx
@@ -454,11 +454,11 @@ void SAL_CALL XMLTransformerBase::initialize( const Sequence< Any >& aArguments
assert(m_xHandler.is()); // can't do anything without that
}
-static sal_Int16 lcl_getUnit( const OUString& rValue )
+static sal_Int16 lcl_getUnit( std::u16string_view rValue )
{
- if( rValue.endsWithIgnoreAsciiCase( "cm" ) )
+ if( o3tl::endsWithIgnoreAsciiCase( rValue, "cm" ) )
return util::MeasureUnit::CM;
- else if ( rValue.endsWithIgnoreAsciiCase( "mm" ) )
+ else if ( o3tl::endsWithIgnoreAsciiCase( rValue, "mm" ) )
return util::MeasureUnit::MM;
else
return util::MeasureUnit::INCH;