summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-01 17:42:34 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-02 13:31:19 +0200
commit1927b51993fb68907a75765676179b08ab195196 (patch)
tree1b7d09c1b5e7ea945fb6ea618a4c100e8630ebb4
parent0dfa444f393a5766d36fe7d2480d0c8ec832e329 (diff)
loplugin:stringviewparam convert methods using indexOf
.. and lastIndexOf, which convert to find and rfind Change-Id: I6c4156cf904774c0d867f85a4c2785dba7593f62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132445 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--basctl/source/basicide/baside2b.cxx18
-rw-r--r--basctl/source/inc/bastypes.hxx2
-rw-r--r--basic/source/sbx/sbxscan.cxx2
-rw-r--r--codemaker/source/cppumaker/dumputils.cxx14
-rw-r--r--codemaker/source/cppumaker/dumputils.hxx5
-rw-r--r--compilerplugins/clang/stringviewparam.cxx3
-rw-r--r--configmgr/source/data.cxx8
-rw-r--r--configmgr/source/data.hxx2
-rw-r--r--configmgr/source/xmldata.cxx4
-rw-r--r--configmgr/source/xmldata.hxx4
-rw-r--r--connectivity/source/commontools/CommonTools.cxx8
-rw-r--r--connectivity/source/drivers/dbase/DTable.cxx2
-rw-r--r--cui/source/customize/macropg.cxx6
-rw-r--r--dbaccess/source/filter/hsqldb/createparser.cxx15
-rw-r--r--dbaccess/source/sdbtools/connection/objectnames.cxx16
-rw-r--r--dbaccess/source/ui/control/SqlNameEdit.cxx4
-rw-r--r--dbaccess/source/ui/inc/WColumnSelect.hxx4
-rw-r--r--dbaccess/source/ui/inc/WCopyTable.hxx2
-rw-r--r--dbaccess/source/ui/misc/WColumnSelect.cxx4
-rw-r--r--dbaccess/source/ui/misc/WCopyTable.cxx2
-rw-r--r--filter/source/xmlfilterdetect/filterdetect.cxx6
-rw-r--r--filter/source/xsltdialog/xmlfiltertestdialog.cxx4
-rw-r--r--framework/inc/addonmenu.hxx2
-rw-r--r--framework/inc/uielement/menubarmerger.hxx2
-rw-r--r--framework/inc/uielement/toolbarmerger.hxx2
-rw-r--r--framework/source/fwe/classes/addonmenu.cxx7
-rw-r--r--framework/source/inc/loadenv/targethelper.hxx2
-rw-r--r--framework/source/loadenv/targethelper.cxx6
-rw-r--r--framework/source/uielement/menubarmerger.cxx4
-rw-r--r--framework/source/uielement/toolbarmerger.cxx4
-rw-r--r--framework/source/uifactory/addonstoolbarfactory.cxx7
-rw-r--r--include/connectivity/dbtools.hxx4
-rw-r--r--include/oox/dump/dumperbase.hxx2
-rw-r--r--include/sfx2/docfile.hxx2
-rw-r--r--include/sfx2/filedlghelper.hxx2
-rw-r--r--include/unotools/tempfile.hxx2
-rw-r--r--include/vcl/toolkit/field.hxx6
-rw-r--r--l10ntools/source/localize.cxx10
-rw-r--r--l10ntools/source/propmerge.cxx6
-rw-r--r--l10ntools/source/treemerge.cxx6
-rw-r--r--linguistic/source/dicimp.cxx8
-rw-r--r--linguistic/source/dlistimp.cxx6
-rw-r--r--oox/source/dump/dumperbase.cxx6
-rw-r--r--registry/source/regimpl.cxx14
-rw-r--r--registry/source/regimpl.hxx2
-rw-r--r--sc/inc/stringutil.hxx2
-rw-r--r--sc/source/core/tool/stringutil.cxx10
-rw-r--r--sc/source/ui/app/inputhdl.cxx4
-rw-r--r--sc/source/ui/docshell/docsh.cxx2
-rw-r--r--sc/source/ui/unoobj/exceldetect.cxx4
-rw-r--r--sd/qa/unit/HtmlExportTest.cxx2
-rw-r--r--sd/source/ui/dlg/TemplateScanner.cxx12
-rw-r--r--sfx2/source/appl/sfxhelp.cxx2
-rw-r--r--sfx2/source/dialog/filedlghelper.cxx8
-rw-r--r--sfx2/source/doc/docfile.cxx6
-rw-r--r--sfx2/source/doc/guisaveas.cxx4
-rw-r--r--starmath/source/edit.cxx4
-rw-r--r--svx/source/sidebar/inspector/InspectorTextPanel.cxx12
-rw-r--r--sw/qa/core/uwriter.cxx2
-rw-r--r--sw/source/filter/html/wrthtml.cxx6
-rw-r--r--sw/source/filter/html/wrthtml.hxx2
-rw-r--r--sw/source/ui/dbui/mmlayoutpage.cxx2
-rw-r--r--sw/source/uibase/misc/glosdoc.cxx2
-rw-r--r--sw/source/uibase/uno/unomailmerge.cxx2
-rw-r--r--ucb/source/ucp/webdav-curl/CurlUri.cxx4
-rw-r--r--ucb/source/ucp/webdav-curl/CurlUri.hxx2
-rw-r--r--ucbhelper/source/client/proxydecider.cxx6
-rw-r--r--unoidl/source/legacyprovider.cxx4
-rw-r--r--unoidl/source/unoidl-check.cxx8
-rw-r--r--unotools/source/ucbhelper/tempfile.cxx10
-rw-r--r--vcl/source/control/field2.cxx28
-rw-r--r--xmloff/source/chart/SchXMLTableContext.cxx6
-rw-r--r--xmloff/source/core/xmlmultiimagehelper.cxx8
73 files changed, 204 insertions, 207 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index e15ccc3ef3ed..262f9e49a248 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -971,20 +971,14 @@ void EditorWindow::SetSourceInBasic()
// Returns the position of the last character of any of the following
// EOL char combinations: CR, CR/LF, LF, return -1 if no EOL is found
-sal_Int32 searchEOL( const OUString& rStr, sal_Int32 fromIndex )
+sal_Int32 searchEOL( std::u16string_view rStr, sal_Int32 fromIndex )
{
- sal_Int32 iRetPos = -1;
+ size_t iLF = rStr.find( LINE_SEP, fromIndex );
+ if( iLF != std::u16string_view::npos )
+ return iLF;
- sal_Int32 iLF = rStr.indexOf( LINE_SEP, fromIndex );
- if( iLF != -1 )
- {
- iRetPos = iLF;
- }
- else
- {
- iRetPos = rStr.indexOf( LINE_SEP_CR, fromIndex );
- }
- return iRetPos;
+ size_t iCR = rStr.find( LINE_SEP_CR, fromIndex );
+ return iCR == std::u16string_view::npos ? -1 : iCR;
}
void EditorWindow::CreateEditEngine()
diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx
index f2e989aeb145..520d1a711992 100644
--- a/basctl/source/inc/bastypes.hxx
+++ b/basctl/source/inc/bastypes.hxx
@@ -53,7 +53,7 @@ constexpr auto LINE_SEP_CR = 0x0D;
constexpr auto LINE_SEP = 0x0A;
// Implementation: baside2b.cxx
-sal_Int32 searchEOL( const OUString& rStr, sal_Int32 fromIndex );
+sal_Int32 searchEOL( std::u16string_view rStr, sal_Int32 fromIndex );
// Meaning of bToBeKilled:
// While being in a reschedule-loop, I may not destroy the window.
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index 108b5d56c499..9151c34defba 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -60,7 +60,7 @@ void ImpGetIntntlSep( sal_Unicode& rcDecimalSep, sal_Unicode& rcThousandSep, sal
}
-static bool ImpStrChr( const OUString& str, sal_Unicode c ) { return str.indexOf(c) >= 0; }
+static bool ImpStrChr( std::u16string_view str, sal_Unicode c ) { return str.find(c) != std::u16string_view::npos; }
// scanning a string according to BASIC-conventions
diff --git a/codemaker/source/cppumaker/dumputils.cxx b/codemaker/source/cppumaker/dumputils.cxx
index 15b62e04a407..8524b1962ce2 100644
--- a/codemaker/source/cppumaker/dumputils.cxx
+++ b/codemaker/source/cppumaker/dumputils.cxx
@@ -48,16 +48,16 @@ bool dumpNamespaceOpen(
}
bool dumpNamespaceClose(
- FileStream & out, OUString const & entityName, bool fullModuleType)
+ FileStream & out, std::u16string_view entityName, bool fullModuleType)
{
bool bOutput = false;
bool bFirst = true;
- for (sal_Int32 i = 0; i >= 0;) {
- i = entityName.indexOf('.', i);
- if (i >= 0) {
+ for (size_t i = 0; i != std::u16string_view::npos;) {
+ i = entityName.find('.', i);
+ if (i != std::u16string_view::npos) {
++i;
}
- if (fullModuleType || i >= 0) {
+ if (fullModuleType || i != std::u16string_view::npos) {
if (!bFirst) {
out << " ";
}
@@ -69,8 +69,8 @@ bool dumpNamespaceClose(
return bOutput;
}
-void dumpTypeIdentifier(FileStream & out, OUString const & entityName) {
- out << entityName.subView(entityName.lastIndexOf('.') + 1);
+void dumpTypeIdentifier(FileStream & out, std::u16string_view entityName) {
+ out << entityName.substr(entityName.rfind('.') + 1);
}
}
diff --git a/codemaker/source/cppumaker/dumputils.hxx b/codemaker/source/cppumaker/dumputils.hxx
index 58ccdc93fac5..2fcd708c43fb 100644
--- a/codemaker/source/cppumaker/dumputils.hxx
+++ b/codemaker/source/cppumaker/dumputils.hxx
@@ -20,6 +20,7 @@
#pragma once
#include <sal/config.h>
+#include <string_view>
namespace rtl
{
@@ -31,9 +32,9 @@ namespace codemaker::cppumaker
{
bool dumpNamespaceOpen(FileStream& out, rtl::OUString const& entityName, bool fullModuleType);
-bool dumpNamespaceClose(FileStream& out, rtl::OUString const& entityName, bool fullModuleType);
+bool dumpNamespaceClose(FileStream& out, std::u16string_view entityName, bool fullModuleType);
-void dumpTypeIdentifier(FileStream& out, rtl::OUString const& entityName);
+void dumpTypeIdentifier(FileStream& out, std::u16string_view entityName);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/stringviewparam.cxx b/compilerplugins/clang/stringviewparam.cxx
index ac33ea7c558c..f0d09fe333d9 100644
--- a/compilerplugins/clang/stringviewparam.cxx
+++ b/compilerplugins/clang/stringviewparam.cxx
@@ -137,7 +137,8 @@ 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")
+ if (n == "endsWith" || n == "isEmpty" || n == "startsWith" || n == "subView"
+ || n == "indexOf" || n == "lastIndexOf")
{
good = true;
}
diff --git a/configmgr/source/data.cxx b/configmgr/source/data.cxx
index 6e95f1665726..6279e02cf096 100644
--- a/configmgr/source/data.cxx
+++ b/configmgr/source/data.cxx
@@ -148,14 +148,14 @@ sal_Int32 Data::parseSegment(
}
OUString Data::fullTemplateName(
- OUString const & component, OUString const & name)
+ std::u16string_view component, std::u16string_view name)
{
- if (component.indexOf(':') != -1 || name.indexOf(':') != -1) {
+ if (component.find(':') != std::u16string_view::npos || name.find(':') != std::u16string_view::npos) {
throw css::uno::RuntimeException(
- "bad component/name pair containing colon " + component + "/" +
+ OUString::Concat("bad component/name pair containing colon ") + component + "/" +
name);
}
- return component + ":" + name;
+ return OUString::Concat(component) + ":" + name;
}
bool Data::equalTemplateNames(
diff --git a/configmgr/source/data.hxx b/configmgr/source/data.hxx
index 9e1da0829679..c3614e6435da 100644
--- a/configmgr/source/data.hxx
+++ b/configmgr/source/data.hxx
@@ -58,7 +58,7 @@ struct Data {
bool * setElement, OUString * templateName);
static OUString fullTemplateName(
- OUString const & component, OUString const & name);
+ std::u16string_view component, std::u16string_view name);
//TODO: better rules under which circumstances a short template name matches
static bool equalTemplateNames(
diff --git a/configmgr/source/xmldata.cxx b/configmgr/source/xmldata.cxx
index a2a05877674e..ecb4dacab41f 100644
--- a/configmgr/source/xmldata.cxx
+++ b/configmgr/source/xmldata.cxx
@@ -115,8 +115,8 @@ bool parseBoolean(xmlreader::Span const & text) {
}
OUString parseTemplateReference(
- OUString const & component, bool hasNodeType,
- OUString const & nodeType, OUString const * defaultTemplateName)
+ std::u16string_view component, bool hasNodeType,
+ std::u16string_view nodeType, OUString const * defaultTemplateName)
{
if (!hasNodeType) {
if (defaultTemplateName != nullptr) {
diff --git a/configmgr/source/xmldata.hxx b/configmgr/source/xmldata.hxx
index c72050af84ce..44296b38d58d 100644
--- a/configmgr/source/xmldata.hxx
+++ b/configmgr/source/xmldata.hxx
@@ -38,8 +38,8 @@ Type parseType(
bool parseBoolean(xmlreader::Span const & text);
OUString parseTemplateReference(
- OUString const & component, bool hasNodeType,
- OUString const & nodeType, OUString const * defaultTemplateName);
+ std::u16string_view component, bool hasNodeType,
+ std::u16string_view nodeType, OUString const * defaultTemplateName);
}
diff --git a/connectivity/source/commontools/CommonTools.cxx b/connectivity/source/commontools/CommonTools.cxx
index b7467c6933ab..739fe6e66345 100644
--- a/connectivity/source/commontools/CommonTools.cxx
+++ b/connectivity/source/commontools/CommonTools.cxx
@@ -165,15 +165,15 @@ namespace connectivity
namespace dbtools
{
-static bool isCharOk(sal_Unicode c,const OUString& _rSpecials)
+static bool isCharOk(sal_Unicode c, std::u16string_view _rSpecials)
{
return ( ((c >= 97) && (c <= 122)) || ((c >= 65) && (c <= 90)) || ((c >= 48) && (c <= 57)) ||
- c == '_' || _rSpecials.indexOf(c) != -1);
+ c == '_' || _rSpecials.find(c) != std::u16string_view::npos);
}
-bool isValidSQLName(const OUString& rName,const OUString& _rSpecials)
+bool isValidSQLName(const OUString& rName, std::u16string_view _rSpecials)
{
// Test for correct naming (in SQL sense)
// This is important for table names for example
@@ -202,7 +202,7 @@ bool isValidSQLName(const OUString& rName,const OUString& _rSpecials)
}
// Creates a new name if necessary
-OUString convertName2SQLName(const OUString& rName,const OUString& _rSpecials)
+OUString convertName2SQLName(const OUString& rName, std::u16string_view _rSpecials)
{
if(isValidSQLName(rName,_rSpecials))
return rName;
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index d7a5b1c458a6..ad3aa66f2dd1 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -1015,7 +1015,7 @@ bool ODbaseTable::CreateImpl()
{
OSL_ENSURE(!m_pFileStream, "SequenceError");
- if ( m_pConnection->isCheckEnabled() && ::dbtools::convertName2SQLName(m_Name,OUString()) != m_Name )
+ if ( m_pConnection->isCheckEnabled() && ::dbtools::convertName2SQLName(m_Name, u"") != m_Name )
{
const OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
STR_SQL_NAME_ERROR,
diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx
index 451ff0b0e9df..b1df3957de8b 100644
--- a/cui/source/customize/macropg.cxx
+++ b/cui/source/customize/macropg.cxx
@@ -288,11 +288,11 @@ namespace
return aPureMethod;
}
- OUString GetEventDisplayImage(const OUString &rURL)
+ OUString GetEventDisplayImage(std::u16string_view rURL)
{
- if (rURL.isEmpty())
+ if (rURL.empty())
return OUString();
- sal_Int32 nIndex = rURL.indexOf(aVndSunStarUNO);
+ size_t nIndex = rURL.find(aVndSunStarUNO);
bool bUNO = nIndex == 0;
return bUNO ? OUString(RID_SVXBMP_COMPONENT) : OUString(RID_SVXBMP_MACRO);
}
diff --git a/dbaccess/source/filter/hsqldb/createparser.cxx b/dbaccess/source/filter/hsqldb/createparser.cxx
index de1213945151..9dfe2b2c53d7 100644
--- a/dbaccess/source/filter/hsqldb/createparser.cxx
+++ b/dbaccess/source/filter/hsqldb/createparser.cxx
@@ -67,10 +67,11 @@ std::vector<OUString> lcl_splitColumnPart(const OUString& sColumnPart)
return sReturn;
}
-sal_Int32 lcl_getAutoIncrementDefault(const OUString& sColumnDef)
+sal_Int32 lcl_getAutoIncrementDefault(std::u16string_view sColumnDef)
{
// TODO what if there are more spaces?
- if (sColumnDef.indexOf("GENERATED BY DEFAULT AS IDENTITY") > 0)
+ size_t nPos = sColumnDef.find(u"GENERATED BY DEFAULT AS IDENTITY");
+ if (nPos != std::u16string_view::npos && nPos > 0)
{
// TODO parse starting sequence stated by "START WITH"
return 0;
@@ -93,9 +94,15 @@ OUString lcl_getDefaultValue(const OUString& sColumnDef)
return OUString{};
}
-bool lcl_isNullable(const OUString& sColumnDef) { return sColumnDef.indexOf("NOT NULL") < 0; }
+bool lcl_isNullable(std::u16string_view sColumnDef)
+{
+ return sColumnDef.find(u"NOT NULL") == std::u16string_view::npos;
+}
-bool lcl_isPrimaryKey(const OUString& sColumnDef) { return sColumnDef.indexOf("PRIMARY KEY") >= 0; }
+bool lcl_isPrimaryKey(std::u16string_view sColumnDef)
+{
+ return sColumnDef.find(u"PRIMARY KEY") != std::u16string_view::npos;
+}
sal_Int32 lcl_getDataTypeFromHsql(std::u16string_view sTypeName)
{
diff --git a/dbaccess/source/sdbtools/connection/objectnames.cxx b/dbaccess/source/sdbtools/connection/objectnames.cxx
index 5ec2c22e8ea4..66dd037870c5 100644
--- a/dbaccess/source/sdbtools/connection/objectnames.cxx
+++ b/dbaccess/source/sdbtools/connection/objectnames.cxx
@@ -159,18 +159,18 @@ namespace sdbtools
{
}
- static ::connectivity::ErrorCondition validateName_getErrorCondition( const OUString& _rName )
+ static ::connectivity::ErrorCondition validateName_getErrorCondition( std::u16string_view _rName )
{
- if ( ( _rName.indexOf( u'"' ) >= 0 )
- || ( _rName.indexOf( u'\'' ) >= 0 )
- || ( _rName.indexOf( u'`' ) >= 0 )
- || ( _rName.indexOf( u'\x0091' ) >= 0 )
- || ( _rName.indexOf( u'\x0092' ) >= 0 )
- || ( _rName.indexOf( u'\x00B4' ) >= 0 ) // removed unparsable chars
+ if ( ( _rName.find( u'"' ) != std::u16string_view::npos )
+ || ( _rName.find( u'\'' ) != std::u16string_view::npos )
+ || ( _rName.find( u'`' ) != std::u16string_view::npos )
+ || ( _rName.find( u'\x0091' ) != std::u16string_view::npos )
+ || ( _rName.find( u'\x0092' ) != std::u16string_view::npos )
+ || ( _rName.find( u'\x00B4' ) != std::u16string_view::npos ) // removed unparsable chars
)
return ErrorCondition::DB_QUERY_NAME_WITH_QUOTES;
- if ( _rName.indexOf( '/') >= 0 )
+ if ( _rName.find( '/') != std::u16string_view::npos )
return ErrorCondition::DB_OBJECT_NAME_WITH_SLASHES;
return 0;
diff --git a/dbaccess/source/ui/control/SqlNameEdit.cxx b/dbaccess/source/ui/control/SqlNameEdit.cxx
index 89c0afc0bda1..9d968a0fdb68 100644
--- a/dbaccess/source/ui/control/SqlNameEdit.cxx
+++ b/dbaccess/source/ui/control/SqlNameEdit.cxx
@@ -21,12 +21,12 @@
namespace dbaui
{
- static bool isCharOk(sal_Unicode _cChar,bool _bFirstChar, const OUString& _sAllowedChars)
+ static bool isCharOk(sal_Unicode _cChar,bool _bFirstChar, std::u16string_view _sAllowedChars)
{
return (
(_cChar >= 'A' && _cChar <= 'Z') ||
_cChar == '_' ||
- _sAllowedChars.indexOf(_cChar) != -1 ||
+ _sAllowedChars.find(_cChar) != std::u16string_view::npos ||
(!_bFirstChar && (_cChar >= '0' && _cChar <= '9')) ||
(_cChar >= 'a' && _cChar <= 'z')
);
diff --git a/dbaccess/source/ui/inc/WColumnSelect.hxx b/dbaccess/source/ui/inc/WColumnSelect.hxx
index 706ccfd0371c..38b1317fd507 100644
--- a/dbaccess/source/ui/inc/WColumnSelect.hxx
+++ b/dbaccess/source/ui/inc/WColumnSelect.hxx
@@ -49,7 +49,7 @@ namespace dbaui
OFieldDescription const * _pSrcField,
std::vector< OUString>& _rRightColumns,
const OUString& _sColumnName,
- const OUString& _sExtraChars,
+ std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen,
const ::comphelper::UStringMixEqual& _aCase);
@@ -57,7 +57,7 @@ namespace dbaui
weld::TreeView const * _pLeft,
std::vector< OUString>& _rRightColumns,
const OUString& _sColumnName,
- const OUString& _sExtraChars,
+ std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen,
const ::comphelper::UStringMixEqual& _aCase);
diff --git a/dbaccess/source/ui/inc/WCopyTable.hxx b/dbaccess/source/ui/inc/WCopyTable.hxx
index 936acfc80c96..6133112835af 100644
--- a/dbaccess/source/ui/inc/WCopyTable.hxx
+++ b/dbaccess/source/ui/inc/WCopyTable.hxx
@@ -395,7 +395,7 @@ namespace dbaui
OUString convertColumnName( const TColumnFindFunctor& _rCmpFunctor,
const OUString& _sColumnName,
- const OUString& _sExtraChars,
+ std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen);
TOTypeInfoSP convertType(const TOTypeInfoSP&_pType, bool& _bNotConvert);
diff --git a/dbaccess/source/ui/misc/WColumnSelect.cxx b/dbaccess/source/ui/misc/WColumnSelect.cxx
index a24c2e25468b..8937cfb2d78d 100644
--- a/dbaccess/source/ui/misc/WColumnSelect.cxx
+++ b/dbaccess/source/ui/misc/WColumnSelect.cxx
@@ -275,7 +275,7 @@ void OWizColumnSelect::createNewColumn( weld::TreeView* _pListbox,
OFieldDescription const * _pSrcField,
std::vector< OUString>& _rRightColumns,
const OUString& _sColumnName,
- const OUString& _sExtraChars,
+ std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen,
const ::comphelper::UStringMixEqual& _aCase)
{
@@ -301,7 +301,7 @@ void OWizColumnSelect::moveColumn( weld::TreeView* _pRight,
weld::TreeView const * _pLeft,
std::vector< OUString>& _rRightColumns,
const OUString& _sColumnName,
- const OUString& _sExtraChars,
+ std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen,
const ::comphelper::UStringMixEqual& _aCase)
{
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
index a4f04f1aa037..e378ab35e2f0 100644
--- a/dbaccess/source/ui/misc/WCopyTable.cxx
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -1359,7 +1359,7 @@ void OCopyTableWizard::setOperation( const sal_Int16 _nOperation )
OUString OCopyTableWizard::convertColumnName(const TColumnFindFunctor& _rCmpFunctor,
const OUString& _sColumnName,
- const OUString& _sExtraChars,
+ std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen)
{
OUString sAlias = _sColumnName;
diff --git a/filter/source/xmlfilterdetect/filterdetect.cxx b/filter/source/xmlfilterdetect/filterdetect.cxx
index 1a3f80cb589a..db4ee2d5fe84 100644
--- a/filter/source/xmlfilterdetect/filterdetect.cxx
+++ b/filter/source/xmlfilterdetect/filterdetect.cxx
@@ -35,13 +35,13 @@ using namespace com::sun::star::beans;
namespace {
-OUString supportedByType( const OUString& clipBoardFormat, const OUString& resultString, const OUString& checkType)
+OUString supportedByType( const OUString& clipBoardFormat, std::u16string_view resultString, const OUString& checkType)
{
OUString sTypeName;
if ( clipBoardFormat.match("doctype:") )
{
- OUString tryStr = clipBoardFormat.copy(8);
- if (resultString.indexOf(tryStr) >= 0)
+ std::u16string_view tryStr = clipBoardFormat.subView(8);
+ if (resultString.find(tryStr) != std::u16string_view::npos)
{
sTypeName = checkType;
}
diff --git a/filter/source/xsltdialog/xmlfiltertestdialog.cxx b/filter/source/xsltdialog/xmlfiltertestdialog.cxx
index 6cbea30926fb..e130f6b552fc 100644
--- a/filter/source/xsltdialog/xmlfiltertestdialog.cxx
+++ b/filter/source/xsltdialog/xmlfiltertestdialog.cxx
@@ -419,7 +419,7 @@ void XMLFilterTestDialog::doExport( const Reference< XComponent >& xComp )
if( xStorable.is() )
{
OUString const ext(".xml");
- utl::TempFile aTempFile(OUString(), true, &ext);
+ utl::TempFile aTempFile(u"", true, &ext);
OUString aTempFileURL( aTempFile.GetURL() );
const application_info_impl* pAppInfo = getApplicationInfo( m_xFilterInfo->maExportService );
@@ -579,7 +579,7 @@ void XMLFilterTestDialog::import( const OUString& rURL )
if( m_xCBXDisplaySource->get_active() )
{
OUString const ext(".xml");
- TempFile aTempFile(OUString(), true, &ext);
+ TempFile aTempFile(u"", true, &ext);
OUString aTempFileURL( aTempFile.GetURL() );
Reference< XImportFilter > xImporter( mxContext->getServiceManager()->createInstanceWithContext( "com.sun.star.documentconversion.XSLTFilter", mxContext ), UNO_QUERY );
diff --git a/framework/inc/addonmenu.hxx b/framework/inc/addonmenu.hxx
index 461f81af2fc6..d6f244cdca4a 100644
--- a/framework/inc/addonmenu.hxx
+++ b/framework/inc/addonmenu.hxx
@@ -41,7 +41,7 @@ class AddonMenuManager
static bool HasAddonMenuElements();
// Check if the context string matches the provided xModel context
- static bool IsCorrectContext(std::u16string_view rModuleIdentifier, const OUString& rContext);
+ static bool IsCorrectContext(std::u16string_view rModuleIdentifier, std::u16string_view rContext);
// Create the Add-Ons menu
static VclPtr<PopupMenu> CreateAddonMenu( const css::uno::Reference< css::frame::XFrame >& rFrame );
diff --git a/framework/inc/uielement/menubarmerger.hxx b/framework/inc/uielement/menubarmerger.hxx
index 8ff81de4580a..3e2d4addd408 100644
--- a/framework/inc/uielement/menubarmerger.hxx
+++ b/framework/inc/uielement/menubarmerger.hxx
@@ -60,7 +60,7 @@ struct ReferencePathInfo
namespace MenuBarMerger
{
bool IsCorrectContext(
- const OUString& aContext, std::u16string_view aModuleIdentifier );
+ std::u16string_view aContext, std::u16string_view aModuleIdentifier );
void RetrieveReferencePath( const OUString&,
std::vector< OUString >& aReferencePath );
diff --git a/framework/inc/uielement/toolbarmerger.hxx b/framework/inc/uielement/toolbarmerger.hxx
index ccfa73ad4d9e..157e02170340 100644
--- a/framework/inc/uielement/toolbarmerger.hxx
+++ b/framework/inc/uielement/toolbarmerger.hxx
@@ -62,7 +62,7 @@ struct ReferenceToolbarPathInfo
class ToolBarMerger
{
public:
- static bool IsCorrectContext( const OUString& aContext, std::u16string_view aModuleIdentifier );
+ static bool IsCorrectContext( std::u16string_view aContext, std::u16string_view aModuleIdentifier );
static void ConvertSeqSeqToVector( const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& rSequence,
AddonToolbarItemContainer& rContainer );
diff --git a/framework/source/fwe/classes/addonmenu.cxx b/framework/source/fwe/classes/addonmenu.cxx
index 582460a0ed2c..423a157f8be8 100644
--- a/framework/source/fwe/classes/addonmenu.cxx
+++ b/framework/source/fwe/classes/addonmenu.cxx
@@ -281,15 +281,14 @@ void AddonMenuManager::GetMenuEntry( const Sequence< PropertyValue >& rAddonMenu
}
// Check if the context string matches the provided xModel context
-bool AddonMenuManager::IsCorrectContext( std::u16string_view rModuleIdentifier, const OUString& rContext )
+bool AddonMenuManager::IsCorrectContext( std::u16string_view rModuleIdentifier, std::u16string_view rContext )
{
- if ( rContext.isEmpty() )
+ if ( rContext.empty() )
return true;
if ( !rModuleIdentifier.empty() )
{
- sal_Int32 nIndex = rContext.indexOf( rModuleIdentifier );
- return ( nIndex >= 0 );
+ return rContext.find( rModuleIdentifier ) != std::u16string_view::npos;
}
return false;
diff --git a/framework/source/inc/loadenv/targethelper.hxx b/framework/source/inc/loadenv/targethelper.hxx
index e9eff6126174..1f0d93d7edce 100644
--- a/framework/source/inc/loadenv/targethelper.hxx
+++ b/framework/source/inc/loadenv/targethelper.hxx
@@ -82,7 +82,7 @@ class TargetHelper
@param sName
the new frame name, which should be checked.
*/
- static bool isValidNameForFrame(const OUString& sName);
+ static bool isValidNameForFrame(std::u16string_view sName);
};
} // namespace framework
diff --git a/framework/source/loadenv/targethelper.cxx b/framework/source/loadenv/targethelper.cxx
index d531f81bc04f..7c06521da6d3 100644
--- a/framework/source/loadenv/targethelper.cxx
+++ b/framework/source/loadenv/targethelper.cxx
@@ -43,12 +43,12 @@ bool TargetHelper::matchSpecialTarget(std::u16string_view sCheckTarget ,
}
}
-bool TargetHelper::isValidNameForFrame(const OUString& sName)
+bool TargetHelper::isValidNameForFrame(std::u16string_view sName)
{
// some special targets are really special ones :-)
// E.g. the are really used to locate one frame inside the frame tree.
if (
- (sName.isEmpty() ) ||
+ (sName.empty() ) ||
(TargetHelper::matchSpecialTarget(sName, ESpecialTarget::HelpTask)) ||
(TargetHelper::matchSpecialTarget(sName, ESpecialTarget::Beamer) )
)
@@ -56,7 +56,7 @@ bool TargetHelper::isValidNameForFrame(const OUString& sName)
// all other names must be checked more general
// special targets starts with a "_".
- return (sName.indexOf('_') != 0);
+ return (sName.find('_') != 0);
}
} // namespace framework
diff --git a/framework/source/uielement/menubarmerger.cxx b/framework/source/uielement/menubarmerger.cxx
index b353fc954d56..175cbe8bcde0 100644
--- a/framework/source/uielement/menubarmerger.cxx
+++ b/framework/source/uielement/menubarmerger.cxx
@@ -56,9 +56,9 @@ namespace framework
*/
bool MenuBarMerger::IsCorrectContext(
- const OUString& rContext, std::u16string_view rModuleIdentifier )
+ std::u16string_view rContext, std::u16string_view rModuleIdentifier )
{
- return ( rContext.isEmpty() || ( rContext.indexOf( rModuleIdentifier ) >= 0 ));
+ return ( rContext.empty() || ( rContext.find( rModuleIdentifier ) != std::u16string_view::npos ));
}
void MenuBarMerger::RetrieveReferencePath(
diff --git a/framework/source/uielement/toolbarmerger.cxx b/framework/source/uielement/toolbarmerger.cxx
index faba3cb4e8d9..9e434f672c2d 100644
--- a/framework/source/uielement/toolbarmerger.cxx
+++ b/framework/source/uielement/toolbarmerger.cxx
@@ -92,10 +92,10 @@ using namespace ::com::sun::star;
*/
bool ToolBarMerger::IsCorrectContext(
- const OUString& rContext,
+ std::u16string_view rContext,
std::u16string_view rModuleIdentifier )
{
- return ( rContext.isEmpty() || ( rContext.indexOf( rModuleIdentifier ) >= 0 ));
+ return ( rContext.empty() || ( rContext.find( rModuleIdentifier ) != std::u16string_view::npos ));
}
/**
diff --git a/framework/source/uifactory/addonstoolbarfactory.cxx b/framework/source/uifactory/addonstoolbarfactory.cxx
index 655cf1843491..b9a1c95c90eb 100644
--- a/framework/source/uifactory/addonstoolbarfactory.cxx
+++ b/framework/source/uifactory/addonstoolbarfactory.cxx
@@ -83,15 +83,14 @@ AddonsToolBarFactory::AddonsToolBarFactory(
{
}
-bool IsCorrectContext( std::u16string_view rModuleIdentifier, const OUString& aContextList )
+bool IsCorrectContext( std::u16string_view rModuleIdentifier, std::u16string_view aContextList )
{
- if ( aContextList.isEmpty() )
+ if ( aContextList.empty() )
return true;
if ( !rModuleIdentifier.empty() )
{
- sal_Int32 nIndex = aContextList.indexOf( rModuleIdentifier );
- return ( nIndex >= 0 );
+ return aContextList.find( rModuleIdentifier ) != std::u16string_view::npos;
}
return false;
diff --git a/include/connectivity/dbtools.hxx b/include/connectivity/dbtools.hxx
index 941a978aee69..58f34f170be8 100644
--- a/include/connectivity/dbtools.hxx
+++ b/include/connectivity/dbtools.hxx
@@ -519,7 +519,7 @@ namespace dbtools
@see isValidSQLName
*/
- OOO_DLLPUBLIC_DBTOOLS OUString convertName2SQLName(const OUString& _rName,const OUString& _rSpecials);
+ OOO_DLLPUBLIC_DBTOOLS OUString convertName2SQLName(const OUString& _rName, std::u16string_view _rSpecials);
/** checks whether the given name is a valid SQL name
@@ -528,7 +528,7 @@ namespace dbtools
@see convertName2SQLName
*/
- OOO_DLLPUBLIC_DBTOOLS bool isValidSQLName( const OUString& _rName, const OUString& _rSpecials );
+ OOO_DLLPUBLIC_DBTOOLS bool isValidSQLName( const OUString& _rName, std::u16string_view _rSpecials );
OOO_DLLPUBLIC_DBTOOLS
void showError( const SQLExceptionInfo& _rInfo,
diff --git a/include/oox/dump/dumperbase.hxx b/include/oox/dump/dumperbase.hxx
index 6d8435e94a1e..f32ca388d07b 100644
--- a/include/oox/dump/dumperbase.hxx
+++ b/include/oox/dump/dumperbase.hxx
@@ -102,7 +102,7 @@ public:
// file names -------------------------------------------------------------
static OUString convertFileNameToUrl( const OUString& rFileName );
- static sal_Int32 getFileNamePos( const OUString& rFileUrl );
+ static sal_Int32 getFileNamePos( std::u16string_view rFileUrl );
static OUString getFileNameExtension( const OUString& rFileUrl );
// input streams ----------------------------------------------------------
diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx
index dcf90b7ebf78..6fd2ba45792a 100644
--- a/include/sfx2/docfile.hxx
+++ b/include/sfx2/docfile.hxx
@@ -251,7 +251,7 @@ public:
SAL_DLLPRIVATE void DoBackup_Impl();
SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent );
SAL_DLLPRIVATE void DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent,
- const OUString& aPrefix,
+ std::u16string_view aPrefix,
const OUString& aExtension,
const OUString& aDestDir );
diff --git a/include/sfx2/filedlghelper.hxx b/include/sfx2/filedlghelper.hxx
index ac43226a924c..b0b5303980c8 100644
--- a/include/sfx2/filedlghelper.hxx
+++ b/include/sfx2/filedlghelper.hxx
@@ -172,7 +172,7 @@ public:
FileDialogHelper(sal_Int16 nDialogType,
FileDialogFlags nFlags,
const OUString& aFilterUIName,
- const OUString& aExtName,
+ std::u16string_view aExtName,
const OUString& rStandardDir,
const css::uno::Sequence< OUString >& rDenyList,
weld::Window* pPreferredParent);
diff --git a/include/unotools/tempfile.hxx b/include/unotools/tempfile.hxx
index 60ae7710c59c..b7f691abb1cd 100644
--- a/include/unotools/tempfile.hxx
+++ b/include/unotools/tempfile.hxx
@@ -68,7 +68,7 @@ public:
@param bCreateParentDirs If rLeadingChars contains a slash, this will create the required
parent directories.
*/
- TempFile( const OUString& rLeadingChars, bool _bStartWithZero=true, const OUString* pExtension=nullptr,
+ TempFile( std::u16string_view rLeadingChars, bool _bStartWithZero=true, const OUString* pExtension=nullptr,
const OUString* pParent=nullptr, bool bCreateParentDirs=false );
TempFile(TempFile && other) noexcept;
diff --git a/include/vcl/toolkit/field.hxx b/include/vcl/toolkit/field.hxx
index 2efab32bad2c..836e59591850 100644
--- a/include/vcl/toolkit/field.hxx
+++ b/include/vcl/toolkit/field.hxx
@@ -315,10 +315,10 @@ protected:
public:
static OUString FormatTime(const tools::Time& rNewTime, TimeFieldFormat eFormat, TimeFormat eHourFormat, bool bDuration, const LocaleDataWrapper& rLocaleData);
static bool TextToTime(std::u16string_view rStr, tools::Time& rTime, TimeFieldFormat eFormat, bool bDuration, const LocaleDataWrapper& rLocaleDataWrapper, bool _bSkipInvalidCharacters = true);
- static int GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, int nCursor,
+ static int GetTimeArea(TimeFieldFormat eFormat, std::u16string_view rText, int nCursor,
const LocaleDataWrapper& rLocaleDataWrapper);
static tools::Time SpinTime(bool bUp, const tools::Time& rTime, TimeFieldFormat eFormat,
- bool bDuration, const OUString& rText, int nCursor,
+ bool bDuration, std::u16string_view rText, int nCursor,
const LocaleDataWrapper& rLocaleDataWrapper);
virtual ~TimeFormatter() override;
@@ -423,7 +423,7 @@ protected:
public:
static OUString FormatDate(const Date& rNewDate, ExtDateFieldFormat eFormat, const LocaleDataWrapper& rLocaleData, const Formatter::StaticFormatter& rStaticFormatter);
static bool TextToDate(const OUString& rStr, Date& rTime, ExtDateFieldFormat eFormat, const LocaleDataWrapper& rLocaleDataWrapper, const CalendarWrapper& rCalendarWrapper);
- static int GetDateArea(ExtDateFieldFormat eFormat, const OUString& rText, int nCursor, const LocaleDataWrapper& rLocaleDataWrapper);
+ static int GetDateArea(ExtDateFieldFormat eFormat, std::u16string_view rText, int nCursor, const LocaleDataWrapper& rLocaleDataWrapper);
virtual ~DateFormatter() override;
diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx
index 8dc1f26422ac..d89f89150d04 100644
--- a/l10ntools/source/localize.cxx
+++ b/l10ntools/source/localize.cxx
@@ -117,13 +117,13 @@ void handleCommand(
void InitPoFile(
std::string_view rProject, const OString& rInPath,
- const OString& rPotDir, const OString& rOutPath )
+ std::string_view rPotDir, const OString& rOutPath )
{
//Create directory for po file
{
OUString outDir =
OStringToOUString(
- rPotDir.subView(0,rPotDir.lastIndexOf('/')), RTL_TEXTENCODING_UTF8);
+ rPotDir.substr(0,rPotDir.rfind('/')), RTL_TEXTENCODING_UTF8);
OUString outDirUrl;
if (osl::FileBase::getFileURLFromSystemPath(outDir, outDirUrl)
!= osl::FileBase::E_None)
@@ -174,7 +174,7 @@ bool fileExists(const OString& fileName)
OString gDestRoot;
-bool handleFile(std::string_view rProject, const OUString& rUrl, const OString& rPotDir)
+bool handleFile(std::string_view rProject, const OUString& rUrl, std::string_view rPotDir)
{
struct Command {
std::u16string_view extension;
@@ -216,7 +216,7 @@ bool handleFile(std::string_view rProject, const OUString& rUrl, const OString&
if (bSimpleModuleCase)
sOutPath = gDestRoot + "/" + rProject + "/messages.pot";
else
- sOutPath = rPotDir + ".pot";
+ sOutPath = OString::Concat(rPotDir) + ".pot";
if (!fileExists(sOutPath))
{
@@ -280,7 +280,7 @@ bool handleFile(std::string_view rProject, const OUString& rUrl, const OString&
void handleFilesOfDir(
std::vector<OUString>& aFiles, std::string_view rProject,
- const OString& rPotDir )
+ std::string_view rPotDir )
{
///Handle files in lexical order
std::sort(aFiles.begin(), aFiles.end());
diff --git a/l10ntools/source/propmerge.cxx b/l10ntools/source/propmerge.cxx
index 2e2cf19e4cc6..0fa81e4fb5ac 100644
--- a/l10ntools/source/propmerge.cxx
+++ b/l10ntools/source/propmerge.cxx
@@ -24,11 +24,11 @@ namespace
{
//Find ascii escaped unicode
sal_Int32 lcl_IndexOfUnicode(
- const OString& rSource, const sal_Int32 nFrom = 0 )
+ std::string_view rSource, const sal_Int32 nFrom = 0 )
{
const OString sHexDigits = "0123456789abcdefABCDEF";
- sal_Int32 nIndex = rSource.indexOf( "\\u", nFrom );
- if( nIndex == -1 )
+ size_t nIndex = rSource.find( "\\u", nFrom );
+ if( nIndex == std::string_view::npos )
{
return -1;
}
diff --git a/l10ntools/source/treemerge.cxx b/l10ntools/source/treemerge.cxx
index b50311cce6af..8e577f3dadbc 100644
--- a/l10ntools/source/treemerge.cxx
+++ b/l10ntools/source/treemerge.cxx
@@ -58,7 +58,7 @@ namespace
// Update id and content of the topic
xmlNodePtr lcl_UpdateTopic(
- const xmlNodePtr pCurrent, const OString& rXhpRoot )
+ const xmlNodePtr pCurrent, std::string_view rXhpRoot )
{
xmlNodePtr pReturn = pCurrent;
xmlChar* pID = xmlGetProp(pReturn, reinterpret_cast<const xmlChar*>("id"));
@@ -71,7 +71,7 @@ namespace
{
OString sNewID =
OString::Concat(sID.subView( 0, nFirstSlash + 1 )) +
- rXhpRoot.subView( rXhpRoot.lastIndexOf('/') + 1 ) +
+ rXhpRoot.substr( rXhpRoot.rfind('/') + 1 ) +
sID.subView( sID.indexOf( '/', nFirstSlash + 1 ) );
xmlSetProp(
pReturn, reinterpret_cast<const xmlChar*>("id"),
@@ -79,7 +79,7 @@ namespace
}
const OString sXhpPath =
- rXhpRoot +
+ OString::Concat(rXhpRoot) +
sID.subView(sID.indexOf('/', nFirstSlash + 1));
xmlDocPtr pXhpFile = xmlParseFile( sXhpPath.getStr() );
// if xhpfile is missing than put this topic into comment
diff --git a/linguistic/source/dicimp.cxx b/linguistic/source/dicimp.cxx
index 20fe8bbadac1..ea4718ff8bce 100644
--- a/linguistic/source/dicimp.cxx
+++ b/linguistic/source/dicimp.cxx
@@ -92,14 +92,14 @@ static uno::Reference< XLinguServiceManager2 > GetLngSvcMgr_Impl()
return xRes;
}
-static bool getTag(const OString &rLine, const char *pTagName,
+static bool getTag(std::string_view rLine, const char *pTagName,
OString &rTagValue)
{
- sal_Int32 nPos = rLine.indexOf(pTagName);
- if (nPos == -1)
+ size_t nPos = rLine.find(pTagName);
+ if (nPos == std::string_view::npos)
return false;
- rTagValue = comphelper::string::strip(rLine.subView(nPos + strlen(pTagName)),
+ rTagValue = comphelper::string::strip(rLine.substr(nPos + strlen(pTagName)),
' ');
return true;
}
diff --git a/linguistic/source/dlistimp.cxx b/linguistic/source/dlistimp.cxx
index 53be03d9d20a..2901273c3e30 100644
--- a/linguistic/source/dlistimp.cxx
+++ b/linguistic/source/dlistimp.cxx
@@ -673,13 +673,13 @@ uno::Sequence< OUString > SAL_CALL DicList::getSupportedServiceNames( )
static sal_Int32 lcl_GetToken( OUString &rToken,
- const OUString &rText, sal_Int32 nPos, const OUString &rDelim )
+ const OUString &rText, sal_Int32 nPos, std::u16string_view rDelim )
{
sal_Int32 nRes = -1;
if (rText.isEmpty() || nPos >= rText.getLength())
rToken.clear();
- else if (rDelim.isEmpty())
+ else if (rDelim.empty())
{
rToken = rText;
if (!rToken.isEmpty())
@@ -690,7 +690,7 @@ static sal_Int32 lcl_GetToken( OUString &rToken,
sal_Int32 i;
for (i = nPos; i < rText.getLength(); ++i)
{
- if (-1 != rDelim.indexOf( rText[i] ))
+ if (std::string_view::npos != rDelim.find( rText[i] ))
break;
}
diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx
index 1638d51a6964..d68b382e38e4 100644
--- a/oox/source/dump/dumperbase.cxx
+++ b/oox/source/dump/dumperbase.cxx
@@ -71,10 +71,10 @@ OUString InputOutputHelper::convertFileNameToUrl( const OUString& rFileName )
return OUString();
}
-sal_Int32 InputOutputHelper::getFileNamePos( const OUString& rFileUrl )
+sal_Int32 InputOutputHelper::getFileNamePos( std::u16string_view rFileUrl )
{
- sal_Int32 nSepPos = rFileUrl.lastIndexOf( '/' );
- return (nSepPos < 0) ? 0 : (nSepPos + 1);
+ size_t nSepPos = rFileUrl.find( '/' );
+ return (nSepPos == std::u16string_view::npos) ? 0 : (nSepPos + 1);
}
OUString InputOutputHelper::getFileNameExtension( const OUString& rFileUrl )
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 7a32772b2f38..0d69c64cd000 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -750,11 +750,11 @@ RegError ORegistry::deleteKey(RegKeyHandle hKey, std::u16string_view keyName)
return eraseKey(m_openKeyTable[ROOT], sFullKeyName);
}
-RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& keyName)
+RegError ORegistry::eraseKey(ORegKey* pKey, std::u16string_view keyName)
{
RegError _ret = RegError::NO_ERROR;
- if (keyName.isEmpty())
+ if (keyName.empty())
{
return RegError::INVALID_KEYNAME;
}
@@ -762,18 +762,18 @@ RegError ORegistry::eraseKey(ORegKey* pKey, const OUString& keyName)
OUString sFullKeyName(pKey->getName());
OUString sFullPath(sFullKeyName);
OUString sRelativKey;
- sal_Int32 lastIndex = keyName.lastIndexOf('/');
+ size_t lastIndex = keyName.rfind('/');
- if (lastIndex >= 0)
+ if (lastIndex != std::u16string_view::npos)
{
- sRelativKey += keyName.subView(lastIndex + 1);
+ sRelativKey += keyName.substr(lastIndex + 1);
if (sFullKeyName.getLength() > 1)
sFullKeyName += keyName;
else
- sFullKeyName += keyName.subView(1);
+ sFullKeyName += keyName.substr(1);
- sFullPath = sFullKeyName.copy(0, keyName.lastIndexOf('/') + 1);
+ sFullPath = sFullKeyName.copy(0, keyName.rfind('/') + 1);
} else
{
if (sFullKeyName.getLength() > 1)
diff --git a/registry/source/regimpl.hxx b/registry/source/regimpl.hxx
index 19fa6b1e3232..973a24986106 100644
--- a/registry/source/regimpl.hxx
+++ b/registry/source/regimpl.hxx
@@ -102,7 +102,7 @@ public:
friend class ORegKey;
private:
- RegError eraseKey(ORegKey* pKey, const OUString& keyName);
+ RegError eraseKey(ORegKey* pKey, std::u16string_view keyName);
RegError deleteSubkeysAndValues(ORegKey* pKey);
diff --git a/sc/inc/stringutil.hxx b/sc/inc/stringutil.hxx
index 8cdb5821d0a9..150a3ede269e 100644
--- a/sc/inc/stringutil.hxx
+++ b/sc/inc/stringutil.hxx
@@ -153,7 +153,7 @@ public:
static OUString SC_DLLPUBLIC GetQuotedToken(const OUString &rIn, sal_Int32 nToken, const OUString& rQuotedPairs,
sal_Unicode cTok, sal_Int32& rIndex );
- static bool SC_DLLPUBLIC isMultiline( const OUString& rStr );
+ static bool SC_DLLPUBLIC isMultiline( std::u16string_view rStr );
static ScInputStringType parseInputString(
SvNumberFormatter& rFormatter, const OUString& rStr, LanguageType eLang );
diff --git a/sc/source/core/tool/stringutil.cxx b/sc/source/core/tool/stringutil.cxx
index 7532d720e57a..131853a5f162 100644
--- a/sc/source/core/tool/stringutil.cxx
+++ b/sc/source/core/tool/stringutil.cxx
@@ -421,15 +421,9 @@ OUString ScStringUtil::GetQuotedToken(const OUString &rIn, sal_Int32 nToken, con
}
}
-bool ScStringUtil::isMultiline( const OUString& rStr )
+bool ScStringUtil::isMultiline( std::u16string_view rStr )
{
- if (rStr.indexOf('\n') != -1)
- return true;
-
- if (rStr.indexOf('\r') != -1)
- return true;
-
- return false;
+ return rStr.find_first_of(u"\n\r") != std::u16string_view::npos;
}
ScInputStringType ScStringUtil::parseInputString(
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 4d5d1a1d8ac2..abd1190475fb 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -1107,9 +1107,9 @@ void ScInputHandler::HideTipBelow()
namespace
{
-bool lcl_hasSingleToken(const OUString& s, sal_Unicode c)
+bool lcl_hasSingleToken(std::u16string_view s, sal_Unicode c)
{
- return !s.isEmpty() && s.indexOf(c)<0;
+ return !s.empty() && s.find(c) == std::u16string_view::npos;
}
}
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 8c64e3a8416f..633fda283499 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -3422,7 +3422,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDBF(SvStream &rStream)
OUString sTmpDir = aTmpDir.GetURL();
OUString sExtension(".dbf");
- utl::TempFile aTempInput(OUString(), true, &sExtension, &sTmpDir);
+ utl::TempFile aTempInput(u"", true, &sExtension, &sTmpDir);
aTempInput.EnableKillingFile();
SvStream* pInputStream = aTempInput.GetStream(StreamMode::WRITE);
diff --git a/sc/source/ui/unoobj/exceldetect.cxx b/sc/source/ui/unoobj/exceldetect.cxx
index a50f9994f4d2..75694bbc9620 100644
--- a/sc/source/ui/unoobj/exceldetect.cxx
+++ b/sc/source/ui/unoobj/exceldetect.cxx
@@ -120,9 +120,9 @@ bool isExcel40(const uno::Reference<io::XInputStream>& xInStream)
return true;
}
-bool isTemplate(const OUString& rType)
+bool isTemplate(std::u16string_view rType)
{
- return rType.indexOf("_VorlageTemplate") != -1;
+ return rType.find(u"_VorlageTemplate") != std::u16string_view::npos;
}
}
diff --git a/sd/qa/unit/HtmlExportTest.cxx b/sd/qa/unit/HtmlExportTest.cxx
index dc7a2d73b381..c409dc12f468 100644
--- a/sd/qa/unit/HtmlExportTest.cxx
+++ b/sd/qa/unit/HtmlExportTest.cxx
@@ -21,7 +21,7 @@ private:
{
FileFormat* pFormat = getFormat(HTML);
OUString aExt = "." + OUString::createFromAscii(pFormat->pName);
- utl::TempFile aTempFile(OUString(), true, &aExt);
+ utl::TempFile aTempFile(u"", true, &aExt);
aTempFile.EnableKillingFile();
exportTo(xDocShRef.get(), pFormat, aTempFile);
return parseHtml(aTempFile);
diff --git a/sd/source/ui/dlg/TemplateScanner.cxx b/sd/source/ui/dlg/TemplateScanner.cxx
index 04f5e8261e90..afd23ff855ee 100644
--- a/sd/source/ui/dlg/TemplateScanner.cxx
+++ b/sd/source/ui/dlg/TemplateScanner.cxx
@@ -65,25 +65,25 @@ public:
/** Use a heuristic based on the URL of a top-level template folder to
assign a priority that is used to sort the folders.
*/
-int Classify (const OUString& rsURL)
+int Classify (std::u16string_view rsURL)
{
int nPriority (0);
- if (rsURL.isEmpty())
+ if (rsURL.empty())
nPriority = 100;
- else if (rsURL.indexOf("presnt")>=0)
+ else if (rsURL.find(u"presnt") != std::u16string_view::npos)
{
nPriority = 30;
}
- else if (rsURL.indexOf("layout")>=0)
+ else if (rsURL.find(u"layout") != std::u16string_view::npos)
{
nPriority = 20;
}
- else if (rsURL.indexOf("educate")>=0)
+ else if (rsURL.find(u"educate") != std::u16string_view::npos)
{
nPriority = 40;
}
- else if (rsURL.indexOf("finance")>=0)
+ else if (rsURL.find(u"finance") != std::u16string_view::npos)
{
nPriority = 40;
}
diff --git a/sfx2/source/appl/sfxhelp.cxx b/sfx2/source/appl/sfxhelp.cxx
index c8ea5cf45cd3..5a26931d3f66 100644
--- a/sfx2/source/appl/sfxhelp.cxx
+++ b/sfx2/source/appl/sfxhelp.cxx
@@ -961,7 +961,7 @@ static bool impl_showOfflineHelp(const OUString& rURL, weld::Widget* pDialogPare
if (flatpak::isFlatpak() && !flatpak::createTemporaryHtmlDirectory(&parent)) {
return false;
}
- ::utl::TempFile aTempFile("NewHelp", true, &aExtension, parent, false );
+ ::utl::TempFile aTempFile(u"NewHelp", true, &aExtension, parent, false );
SvStream* pStream = aTempFile.GetStream(StreamMode::WRITE);
pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index 06e9809d1d44..5b0ee7e97b9d 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -2398,7 +2398,7 @@ FileDialogHelper::FileDialogHelper(
sal_Int16 nDialogType,
FileDialogFlags nFlags,
const OUString& aFilterUIName,
- const OUString& aExtName,
+ std::u16string_view aExtName,
const OUString& rStandardDir,
const css::uno::Sequence< OUString >& rDenyList,
weld::Window* pPreferredParent )
@@ -2407,9 +2407,9 @@ FileDialogHelper::FileDialogHelper(
{
// the wildcard here is expected in form "*.extension"
OUString aWildcard;
- if ( aExtName.indexOf( '*' ) != 0 )
+ if ( aExtName.find( '*' ) != 0 )
{
- if ( !aExtName.isEmpty() && aExtName.indexOf( '.' ) != 0 )
+ if ( !aExtName.empty() && aExtName.find( '.' ) != 0 )
aWildcard = "*.";
else
aWildcard = "*";
@@ -2848,7 +2848,7 @@ ErrCode FileOpenDialog_Impl( weld::Window* pParent,
// read-only to discourage editing (which would invalidate existing
// signatures).
if (nFlags & FileDialogFlags::SignPDF)
- pDialog.reset(new FileDialogHelper(nDialogType, nFlags, SfxResId(STR_SFX_FILTERNAME_PDF), "pdf", rStandardDir, rDenyList, pParent));
+ pDialog.reset(new FileDialogHelper(nDialogType, nFlags, SfxResId(STR_SFX_FILTERNAME_PDF), u"pdf", rStandardDir, rDenyList, pParent));
else
pDialog.reset(new FileDialogHelper(nDialogType, nFlags, OUString(), nDialog, SfxFilterFlags::NONE, SfxFilterFlags::NONE, rStandardDir, rDenyList, pParent));
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 61d8c38b3582..baa82c0bc0b3 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -2513,7 +2513,7 @@ void SfxMedium::Transfer_Impl()
void SfxMedium::DoInternalBackup_Impl( const ::ucbhelper::Content& aOriginalContent,
- const OUString& aPrefix,
+ std::u16string_view aPrefix,
const OUString& aExtension,
const OUString& aDestDir )
{
@@ -4271,7 +4271,7 @@ OUString SfxMedium::CreateTempCopyWithExt( const OUString& aURL )
sal_Int32 nPrefixLen = aURL.lastIndexOf( '.' );
OUString aExt = ( nPrefixLen == -1 ) ? OUString() : aURL.copy( nPrefixLen );
- OUString aNewTempFileURL = ::utl::TempFile( OUString(), true, &aExt ).GetURL();
+ OUString aNewTempFileURL = ::utl::TempFile( u"", true, &aExt ).GetURL();
if ( !aNewTempFileURL.isEmpty() )
{
INetURLObject aSource( aURL );
@@ -4344,7 +4344,7 @@ OUString SfxMedium::SwitchDocumentToTempFile()
OUString const aExt = (nPrefixLen == -1)
? OUString()
: aOrigURL.copy(nPrefixLen);
- OUString aNewURL = ::utl::TempFile( OUString(), true, &aExt ).GetURL();
+ OUString aNewURL = ::utl::TempFile( u"", true, &aExt ).GetURL();
// TODO/LATER: In future the aLogicName should be set to shared folder URL
// and a temporary file should be created. Transport_Impl should be impossible then.
diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx
index 0aa47efe74e0..d3c862a01ce5 100644
--- a/sfx2/source/doc/guisaveas.cxx
+++ b/sfx2/source/doc/guisaveas.cxx
@@ -863,14 +863,14 @@ bool ModelData_Impl::OutputFileDialog( sal_Int16 nStoreMode,
// this is a PDF export
// the filter options has been shown already
const OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "UIName", OUString() );
- pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aFilterUIName, "pdf", rStandardDir, rDenyList, pFrameWin ));
+ pFileDlg.reset(new sfx2::FileDialogHelper( aDialogMode, aDialogFlags, aFilterUIName, u"pdf", rStandardDir, rDenyList, pFrameWin ));
pFileDlg->SetCurrentFilter( aFilterUIName );
}
else if ((nStoreMode & EPUBEXPORT_REQUESTED) && !aPreselectedFilterPropsHM.empty())
{
// This is an EPUB export, the filter options has been shown already.
const OUString aFilterUIName = aPreselectedFilterPropsHM.getUnpackedValueOrDefault( "UIName", OUString() );
- pFileDlg.reset(new sfx2::FileDialogHelper(aDialogMode, aDialogFlags, aFilterUIName, "epub", rStandardDir, rDenyList, pFrameWin));
+ pFileDlg.reset(new sfx2::FileDialogHelper(aDialogMode, aDialogFlags, aFilterUIName, u"epub", rStandardDir, rDenyList, pFrameWin));
pFileDlg->SetCurrentFilter(aFilterUIName);
}
else
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 2440a92be948..0b14c492ed23 100644
--- a/starmath/source/edit.cxx
+++ b/starmath/source/edit.cxx
@@ -662,9 +662,9 @@ void SmEditWindow::SelPrevMark()
}
// returns true iff 'rText' contains a mark
-static bool HasMark(const OUString& rText)
+static bool HasMark(std::u16string_view rText)
{
- return rText.indexOf("<?>") != -1;
+ return rText.find(u"<?>") != std::u16string_view::npos;
}
ESelection SmEditWindow::GetSelection() const
diff --git a/svx/source/sidebar/inspector/InspectorTextPanel.cxx b/svx/source/sidebar/inspector/InspectorTextPanel.cxx
index 22f1aa90e759..0b5da3d2d14e 100644
--- a/svx/source/sidebar/inspector/InspectorTextPanel.cxx
+++ b/svx/source/sidebar/inspector/InspectorTextPanel.cxx
@@ -55,12 +55,14 @@ InspectorTextPanel::InspectorTextPanel(weld::Widget* pParent)
mpListBoxStyles->set_column_fixed_widths(aWidths);
}
-static bool GetPropertyValues(const OUString& rPropName, const uno::Any& rAny, OUString& rString)
+static bool GetPropertyValues(std::u16string_view rPropName, const uno::Any& rAny,
+ OUString& rString)
{
// Hide Asian and Complex properties
- if (!SvtCJKOptions::IsCJKFontEnabled() && rPropName.indexOf("Asian") != -1)
+ if (!SvtCJKOptions::IsCJKFontEnabled() && rPropName.find(u"Asian") != std::u16string_view::npos)
return false;
- if (!SvtCTLOptions().IsCTLFontEnabled() && rPropName.indexOf("Complex") != -1)
+ if (!SvtCTLOptions().IsCTLFontEnabled()
+ && rPropName.find(u"Complex") != std::u16string_view::npos)
return false;
if (bool bValue; rAny >>= bValue)
@@ -77,14 +79,14 @@ static bool GetPropertyValues(const OUString& rPropName, const uno::Any& rAny, O
}
else if (tools::Long nValueLong; rAny >>= nValueLong)
{
- if (rPropName.indexOf("Color") != -1)
+ if (rPropName.find(u"Color") != std::u16string_view::npos)
rString = "0x" + OUString::number(nValueLong, 16);
else
rString = OUString::number(nValueLong);
}
else if (double fValue; rAny >>= fValue)
{
- if (rPropName.indexOf("Weight") != -1)
+ if (rPropName.find(u"Weight") != std::u16string_view::npos)
rString = SvxResId(fValue > 100 ? RID_BOLD : RID_NORMAL);
else
rString = OUString::number((round(fValue * 100)) / 100.00);
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 3ba4abc9719a..ae59144b9be8 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -196,7 +196,7 @@ void SwDocTest::testFileNameFields()
{
//Here's a file name with some chars in it that will be %% encoded, when expanding
//SwFileNameFields we want to restore the original readable filename
- utl::TempFile aTempFile("demo [name]");
+ utl::TempFile aTempFile(u"demo [name]");
aTempFile.EnableKillingFile();
INetURLObject aTempFileURL(aTempFile.GetURL());
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index d1e5f64408fb..487fe7e36009 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -1547,7 +1547,7 @@ sal_uInt16 SwHTMLWriter::GetHTMLFontSize( sal_uInt32 nHeight ) const
// Paragraphs with Table of Contents and other index styles will be typeset with
// dot leaders at the position of the last tabulator in PrintLayout (CSS2) mode
-sal_Int32 SwHTMLWriter::indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& rStr )
+sal_Int32 SwHTMLWriter::indexOfDotLeaders( sal_uInt16 nPoolId, std::u16string_view rStr )
{
if (m_bCfgPrintLayout && ((nPoolId >= RES_POOLCOLL_TOX_CNTNT1 && nPoolId <= RES_POOLCOLL_TOX_CNTNT5) ||
(nPoolId >= RES_POOLCOLL_TOX_IDX1 && nPoolId <= RES_POOLCOLL_TOX_IDX3) ||
@@ -1555,9 +1555,9 @@ sal_Int32 SwHTMLWriter::indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& r
nPoolId == RES_POOLCOLL_TOX_ILLUS1 || nPoolId == RES_POOLCOLL_TOX_TABLES1 ||
nPoolId == RES_POOLCOLL_TOX_OBJECT1 ||
(nPoolId >= RES_POOLCOLL_TOX_AUTHORITIES1 && nPoolId <= RES_POOLCOLL_TOX_USER10))) {
- sal_Int32 i = rStr.lastIndexOf('\t');
+ size_t i = rStr.rfind('\t');
// there are only ASCII (Latin-1) characters after the tabulator
- if (i > -1 && OUStringToOString(rStr.subView(i + 1), RTL_TEXTENCODING_ASCII_US).indexOf('?') == -1)
+ if (i != std::u16string_view::npos && OUStringToOString(rStr.substr(i + 1), RTL_TEXTENCODING_ASCII_US).indexOf('?') == -1)
return i;
}
return -1;
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 911eaa629aed..3f6860a6d160 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -595,7 +595,7 @@ public:
FieldUnit GetCSS1Unit() const { return m_eCSS1Unit; }
- sal_Int32 indexOfDotLeaders( sal_uInt16 nPoolId, const OUString& rText );
+ sal_Int32 indexOfDotLeaders( sal_uInt16 nPoolId, std::u16string_view rText );
/// Determines the prefix string needed to respect the requested namespace alias.
OString GetNamespace() const;
diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index 763ae5808138..86d705b2bac6 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -95,7 +95,7 @@ SwMailMergeLayoutPage::SwMailMergeLayoutPage(weld::Container* pPage, SwMailMerge
//creating with extension is not supported by a static method :-(
OUString const sExt(
comphelper::string::stripStart(pSfxFlt->GetDefaultExtension(),'*'));
- utl::TempFile aTempFile( OUString(), true, &sExt );
+ utl::TempFile aTempFile( u"", true, &sExt );
m_sExampleURL = aTempFile.GetURL();
aTempFile.EnableKillingFile();
}
diff --git a/sw/source/uibase/misc/glosdoc.cxx b/sw/source/uibase/misc/glosdoc.cxx
index d147505edbdd..e5f29f1d4aa7 100644
--- a/sw/source/uibase/misc/glosdoc.cxx
+++ b/sw/source/uibase/misc/glosdoc.cxx
@@ -78,7 +78,7 @@ OUString lcl_CheckFileName( const OUString& rNewFilePath,
OUString rSG = SwGlossaries::GetExtension();
//generate generic name
- utl::TempFile aTemp("group", true, &rSG, &rNewFilePath);
+ utl::TempFile aTemp(u"group", true, &rSG, &rNewFilePath);
aTemp.EnableKillingFile();
INetURLObject aTempURL( aTemp.GetURL() );
diff --git a/sw/source/uibase/uno/unomailmerge.cxx b/sw/source/uibase/uno/unomailmerge.cxx
index a6bc6104f43e..203879289a9b 100644
--- a/sw/source/uibase/uno/unomailmerge.cxx
+++ b/sw/source/uibase/uno/unomailmerge.cxx
@@ -766,7 +766,7 @@ uno::Any SAL_CALL SwXMailMerge::execute(
FILTER_XML,
SwDocShell::Factory().GetFilterContainer() );
OUString aExtension(comphelper::string::stripStart(pSfxFlt->GetDefaultExtension(), '*'));
- utl::TempFile aTempFile( "SwMM", true, &aExtension );
+ utl::TempFile aTempFile( u"SwMM", true, &aExtension );
m_aTmpFileName = aTempFile.GetURL();
Reference< XStorable > xStorable( xCurModel, UNO_QUERY );
diff --git a/ucb/source/ucp/webdav-curl/CurlUri.cxx b/ucb/source/ucp/webdav-curl/CurlUri.cxx
index 035c12a132ef..fcd3b652063c 100644
--- a/ucb/source/ucp/webdav-curl/CurlUri.cxx
+++ b/ucb/source/ucp/webdav-curl/CurlUri.cxx
@@ -298,12 +298,12 @@ OUString DecodeURI(OUString const& rURI)
return rtl::Uri::decode(rURI, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8);
}
-OUString ConnectionEndPointString(OUString const& rHostName, sal_uInt16 const nPort)
+OUString ConnectionEndPointString(std::u16string_view rHostName, sal_uInt16 const nPort)
{
OUStringBuffer aBuf;
// Is host a numeric IPv6 address?
- if ((rHostName.indexOf(':') != -1) && (rHostName[0] != '['))
+ if ((rHostName.find(':') != std::u16string_view::npos) && (rHostName[0] != '['))
{
aBuf.append("[");
aBuf.append(rHostName);
diff --git a/ucb/source/ucp/webdav-curl/CurlUri.hxx b/ucb/source/ucp/webdav-curl/CurlUri.hxx
index c9e8d33d279d..56336af78169 100644
--- a/ucb/source/ucp/webdav-curl/CurlUri.hxx
+++ b/ucb/source/ucp/webdav-curl/CurlUri.hxx
@@ -87,7 +87,7 @@ public:
OUString EncodeSegment(OUString const& rSegment);
OUString DecodeURI(OUString const& rURI);
-OUString ConnectionEndPointString(OUString const& rHost, sal_uInt16 nPort);
+OUString ConnectionEndPointString(std::u16string_view rHost, sal_uInt16 nPort);
} // namespace http_dav_ucp
diff --git a/ucbhelper/source/client/proxydecider.cxx b/ucbhelper/source/client/proxydecider.cxx
index 8c95f558f86b..1e2b0adfd2d2 100644
--- a/ucbhelper/source/client/proxydecider.cxx
+++ b/ucbhelper/source/client/proxydecider.cxx
@@ -136,7 +136,7 @@ class InternetProxyDecider_Impl :
mutable HostnameCache m_aHostnames;
private:
- bool shouldUseProxy( const OUString & rHost,
+ bool shouldUseProxy( std::u16string_view rHost,
sal_Int32 nPort,
bool bUseFullyQualified ) const;
public:
@@ -399,13 +399,13 @@ void InternetProxyDecider_Impl::dispose()
}
-bool InternetProxyDecider_Impl::shouldUseProxy( const OUString & rHost,
+bool InternetProxyDecider_Impl::shouldUseProxy( std::u16string_view rHost,
sal_Int32 nPort,
bool bUseFullyQualified ) const
{
OUStringBuffer aBuffer;
- if ( ( rHost.indexOf( ':' ) != -1 ) &&
+ if ( ( rHost.find( ':' ) != std::u16string_view::npos ) &&
( rHost[ 0 ] != '[' ) )
{
// host is given as numeric IPv6 address
diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx
index 1d147a975582..ab99fcf59dd1 100644
--- a/unoidl/source/legacyprovider.cxx
+++ b/unoidl/source/legacyprovider.cxx
@@ -26,9 +26,9 @@ namespace unoidl::detail {
namespace {
-std::vector< OUString > translateAnnotations(OUString const & documentation) {
+std::vector< OUString > translateAnnotations(std::u16string_view documentation) {
std::vector< OUString > ans;
- if (documentation.indexOf("@deprecated") != -1) {
+ if (documentation.find(u"@deprecated") != std::u16string_view::npos) {
//TODO: this check is somewhat crude
ans.push_back("deprecated");
}
diff --git a/unoidl/source/unoidl-check.cxx b/unoidl/source/unoidl-check.cxx
index 58b179ea41b0..253079024106 100644
--- a/unoidl/source/unoidl-check.cxx
+++ b/unoidl/source/unoidl-check.cxx
@@ -886,10 +886,10 @@ void checkMap(
}
}
-bool valid(OUString const & identifier) {
- for (sal_Int32 i = 0;; ++i) {
- i = identifier.indexOf('_', i);
- if (i == -1) {
+bool valid(std::u16string_view identifier) {
+ for (size_t i = 0;; ++i) {
+ i = identifier.find('_', i);
+ if (i == std::u16string_view::npos) {
return true;
}
if (!rtl::isAsciiUpperCase(identifier[0]) || identifier[i - 1] == '_') {
diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx
index cccad1c367f0..4fac0bacd782 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -247,17 +247,17 @@ namespace
};
static OUString lcl_createName(
- const OUString& rLeadingChars, Tokens & tokens, const OUString* pExtension,
+ std::u16string_view rLeadingChars, Tokens & tokens, const OUString* pExtension,
const OUString* pParent, bool bDirectory, bool bKeep, bool bLock,
bool bCreateParentDirs )
{
OUString aName = ConstructTempDir_Impl( pParent, bCreateParentDirs );
if ( bCreateParentDirs )
{
- sal_Int32 nOffset = rLeadingChars.lastIndexOf("/");
+ size_t nOffset = rLeadingChars.rfind(u"/");
OUString aDirName;
- if (-1 != nOffset)
- aDirName = aName + rLeadingChars.subView( 0, nOffset );
+ if (std::u16string_view::npos != nOffset)
+ aDirName = aName + rLeadingChars.substr( 0, nOffset );
else
aDirName = aName;
TempDirCreatedObserver observer;
@@ -365,7 +365,7 @@ TempFile::TempFile( const OUString* pParent, bool bDirectory )
aName = CreateTempName_Impl( pParent, true, bDirectory );
}
-TempFile::TempFile( const OUString& rLeadingChars, bool _bStartWithZero,
+TempFile::TempFile( std::u16string_view rLeadingChars, bool _bStartWithZero,
const OUString* pExtension, const OUString* pParent,
bool bCreateParentDirs )
: bIsDirectory( false )
diff --git a/vcl/source/control/field2.cxx b/vcl/source/control/field2.cxx
index 1fa8d4d0be5b..67c0357a8ebf 100644
--- a/vcl/source/control/field2.cxx
+++ b/vcl/source/control/field2.cxx
@@ -1617,7 +1617,7 @@ bool DateFormatter::ImplAllowMalformedInput() const
return !IsEnforceValidValue();
}
-int DateFormatter::GetDateArea(ExtDateFieldFormat eFormat, const OUString& rText, int nCursor, const LocaleDataWrapper& rLocaleDataWrapper)
+int DateFormatter::GetDateArea(ExtDateFieldFormat eFormat, std::u16string_view rText, int nCursor, const LocaleDataWrapper& rLocaleDataWrapper)
{
sal_Int8 nDateArea = 0;
@@ -1629,12 +1629,12 @@ int DateFormatter::GetDateArea(ExtDateFieldFormat eFormat, const OUString& rText
else
{
// search area
- sal_Int32 nPos = 0;
+ size_t nPos = 0;
OUString aDateSep = ImplGetDateSep(rLocaleDataWrapper, eFormat);
for ( sal_Int8 i = 1; i <= 3; i++ )
{
- nPos = rText.indexOf( aDateSep, nPos );
- if (nPos < 0 || nPos >= nCursor)
+ nPos = rText.find( aDateSep, nPos );
+ if (nPos == std::u16string_view::npos || static_cast<sal_Int32>(nPos) >= nCursor)
{
nDateArea = i;
break;
@@ -2581,7 +2581,7 @@ bool TimeFormatter::ImplAllowMalformedInput() const
return !IsEnforceValidValue();
}
-int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, int nCursor,
+int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, std::u16string_view rText, int nCursor,
const LocaleDataWrapper& rLocaleDataWrapper)
{
int nTimeArea = 0;
@@ -2590,18 +2590,18 @@ int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, i
if (eFormat != TimeFieldFormat::F_SEC_CS)
{
//Which area is the cursor in of HH:MM:SS.TT
- for ( sal_Int32 i = 1, nPos = 0; i <= 4; i++ )
+ for ( size_t i = 1, nPos = 0; i <= 4; i++ )
{
- sal_Int32 nPos1 = rText.indexOf(rLocaleDataWrapper.getTimeSep(), nPos);
- sal_Int32 nPos2 = rText.indexOf(rLocaleDataWrapper.getTime100SecSep(), nPos);
+ size_t nPos1 = rText.find(rLocaleDataWrapper.getTimeSep(), nPos);
+ size_t nPos2 = rText.find(rLocaleDataWrapper.getTime100SecSep(), nPos);
//which ever comes first, bearing in mind that one might not be there
- if (nPos1 >= 0 && nPos2 >= 0)
+ if (nPos1 != std::u16string_view::npos && nPos2 != std::u16string_view::npos)
nPos = std::min(nPos1, nPos2);
- else if (nPos1 >= 0)
+ else if (nPos1 != std::u16string_view::npos)
nPos = nPos1;
else
nPos = nPos2;
- if (nPos < 0 || nPos >= nCursor)
+ if (nPos == std::u16string_view::npos || static_cast<sal_Int32>(nPos) >= nCursor)
{
nTimeArea = i;
break;
@@ -2612,8 +2612,8 @@ int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, i
}
else
{
- sal_Int32 nPos = rText.indexOf(rLocaleDataWrapper.getTime100SecSep());
- if (nPos < 0 || nPos >= nCursor)
+ size_t nPos = rText.find(rLocaleDataWrapper.getTime100SecSep());
+ if (nPos == std::u16string_view::npos || static_cast<sal_Int32>(nPos) >= nCursor)
nTimeArea = 3;
else
nTimeArea = 4;
@@ -2623,7 +2623,7 @@ int TimeFormatter::GetTimeArea(TimeFieldFormat eFormat, const OUString& rText, i
}
tools::Time TimeFormatter::SpinTime(bool bUp, const tools::Time& rTime, TimeFieldFormat eFormat,
- bool bDuration, const OUString& rText, int nCursor,
+ bool bDuration, std::u16string_view rText, int nCursor,
const LocaleDataWrapper& rLocaleDataWrapper)
{
tools::Time aTime(rTime);
diff --git a/xmloff/source/chart/SchXMLTableContext.cxx b/xmloff/source/chart/SchXMLTableContext.cxx
index ac8a9f3e3f51..a59a28b2546b 100644
--- a/xmloff/source/chart/SchXMLTableContext.cxx
+++ b/xmloff/source/chart/SchXMLTableContext.cxx
@@ -181,13 +181,13 @@ bool lcl_mapContainsRange(
}
bool lcl_tableOfRangeMatches(
- const OUString & rRange,
+ std::u16string_view rRange,
std::u16string_view rTableName )
{
// both strings are non-empty and the table name is part of the range
- return ( !rRange.isEmpty() &&
+ return ( !rRange.empty() &&
!rTableName.empty() &&
- (rRange.indexOf( rTableName ) != -1 ));
+ (rRange.find( rTableName ) != std::u16string_view::npos ));
}
} // anonymous namespace
diff --git a/xmloff/source/core/xmlmultiimagehelper.cxx b/xmloff/source/core/xmlmultiimagehelper.cxx
index b3529acc586e..000c6151ee81 100644
--- a/xmloff/source/core/xmlmultiimagehelper.cxx
+++ b/xmloff/source/core/xmlmultiimagehelper.cxx
@@ -19,19 +19,19 @@
#include <rtl/ustring.hxx>
#include <xmlmultiimagehelper.hxx>
-
+#include <o3tl/string_view.hxx>
#include <comphelper/graphicmimetype.hxx>
using namespace ::com::sun::star;
namespace
{
- OUString getMimeTypeForURL(const OUString& rString)
+ OUString getMimeTypeForURL(std::u16string_view rString)
{
OUString sMimeType;
- if (rString.startsWith("vnd.sun.star.Package"))
+ if (o3tl::starts_with(rString, u"vnd.sun.star.Package"))
{
- OString aExtension = OUStringToOString(rString.subView(rString.lastIndexOf(".") + 1), RTL_TEXTENCODING_ASCII_US);
+ OString aExtension = OUStringToOString(rString.substr(rString.rfind('.') + 1), RTL_TEXTENCODING_ASCII_US);
sMimeType = comphelper::GraphicMimeTypeHelper::GetMimeTypeForExtension(aExtension);
}
return sMimeType;