basic/inc/sbxform.hxx                                         |   10 -
 basic/source/sbx/sbxform.cxx                                  |   68 +++++-----
 codemaker/source/javamaker/javatype.cxx                       |   17 +-
 comphelper/source/misc/string.cxx                             |    2 
 compilerplugins/clang/stringviewparam.cxx                     |    3 
 desktop/source/app/dispatchwatcher.cxx                        |   10 -
 framework/inc/uifactory/configurationaccessfactorymanager.hxx |    2 
 framework/source/uifactory/uielementfactorymanager.cxx        |    8 -
 i18npool/source/transliteration/transliteration_body.cxx      |    4 
 idl/source/prj/svidl.cxx                                      |    8 -
 pyuno/source/loader/pyuno_loader.cxx                          |   16 +-
 sal/cppunittester/cppunittester.cxx                           |   10 -
 scripting/source/provider/URIHelper.cxx                       |    8 -
 scripting/source/provider/URIHelper.hxx                       |    2 
 scripting/source/vbaevents/eventhelper.cxx                    |   14 +-
 svx/source/svdraw/svdmrkv.cxx                                 |   62 ++++-----
 unodevtools/source/skeletonmaker/cpptypemaker.cxx             |   12 -
 unodevtools/source/skeletonmaker/javacompskeleton.cxx         |    8 -
 unodevtools/source/skeletonmaker/javatypemaker.cxx            |    4 
 uui/source/iahndl-ssl.cxx                                     |   14 +-
 uui/source/secmacrowarnings.cxx                               |   18 +-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx             |   41 +++---
 22 files changed, 173 insertions(+), 168 deletions(-)

New commits:
commit 33bd16b344e273c427091ee68e946bf67b371dd7
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Sun Apr 3 10:34:37 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Apr 17 10:27:33 2022 +0200

    loplugin:stringviewparam convert methods using copy()
    
    which converts to std::string_view::substr()
    
    Change-Id: I3f42213b41a97e77ddcc79d84d512f49d68ca559
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132729
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/basic/inc/sbxform.hxx b/basic/inc/sbxform.hxx
index 8ae9cb2db3f4..8accc399547a 100644
--- a/basic/inc/sbxform.hxx
+++ b/basic/inc/sbxform.hxx
@@ -93,7 +93,7 @@ class SbxBasicFormater {
         String containing the formatted output
     */
     OUString  BasicFormat( double dNumber, const OUString& sFormatStrg );
-    static OUString BasicFormatNull( const OUString& sFormatStrg );
+    static OUString BasicFormatNull( std::u16string_view sFormatStrg );
 
     static  bool isBasicFormat( std::u16string_view sFormatStrg );
 
@@ -112,10 +112,10 @@ class SbxBasicFormater {
     short  GetDigitAtPosExpScan( double dNewExponent, short nPos,
                                                   bool& bFoundFirstDigit );
     short  GetDigitAtPosExpScan( short nPos, bool& bFoundFirstDigit );
-    static OUString GetPosFormatString( const OUString& sFormatStrg, bool & 
bFound );
-    static OUString GetNegFormatString( const OUString& sFormatStrg, bool & 
bFound );
-    static OUString Get0FormatString( const OUString& sFormatStrg, bool & 
bFound );
-    static OUString GetNullFormatString( const OUString& sFormatStrg, bool & 
bFound );
+    static OUString GetPosFormatString( std::u16string_view sFormatStrg, bool 
& bFound );
+    static OUString GetNegFormatString( std::u16string_view sFormatStrg, bool 
& bFound );
+    static OUString Get0FormatString( std::u16string_view sFormatStrg, bool & 
bFound );
+    static OUString GetNullFormatString( std::u16string_view sFormatStrg, bool 
& bFound );
     static void AnalyseFormatString( const OUString& sFormatStrg,
                                                  short& nNoOfDigitsLeft, 
short& nNoOfDigitsRight,
                                                  short& 
nNoOfOptionalDigitsLeft,
diff --git a/basic/source/sbx/sbxform.cxx b/basic/source/sbx/sbxform.cxx
index ef273c1f392b..4bd0c09ac99f 100644
--- a/basic/source/sbx/sbxform.cxx
+++ b/basic/source/sbx/sbxform.cxx
@@ -296,71 +296,71 @@ short SbxBasicFormater::GetDigitAtPosExpScan( double 
dNewExponent, short nPos,
 
 // Copies the respective part of the format-string, if existing, and returns 
it.
 // So a new string is created, which has to be freed by the caller later.
-OUString SbxBasicFormater::GetPosFormatString( const OUString& sFormatStrg, 
bool & bFound )
+OUString SbxBasicFormater::GetPosFormatString( std::u16string_view 
sFormatStrg, bool & bFound )
 {
     bFound = false;     // default...
-    sal_Int32 nPos = sFormatStrg.indexOf( FORMAT_SEPARATOR );
+    size_t nPos = sFormatStrg.find( FORMAT_SEPARATOR );
 
-    if( nPos >= 0 )
+    if( nPos != std::u16string_view::npos )
     {
         bFound = true;
         // the format-string for positive numbers is
         // everything before the first ';'
-        return sFormatStrg.copy( 0,nPos );
+        return OUString(sFormatStrg.substr( 0,nPos ));
     }
 
     return OUString();
 }
 
 // see also GetPosFormatString()
-OUString SbxBasicFormater::GetNegFormatString( const OUString& sFormatStrg, 
bool & bFound )
+OUString SbxBasicFormater::GetNegFormatString( std::u16string_view 
sFormatStrg, bool & bFound )
 {
     bFound = false;     // default...
-    sal_Int32 nPos = sFormatStrg.indexOf( FORMAT_SEPARATOR );
+    size_t nPos = sFormatStrg.find( FORMAT_SEPARATOR );
 
-    if( nPos >= 0)
+    if( nPos != std::u16string_view::npos)
     {
         // the format-string for negative numbers is
         // everything between the first and the second ';'
-        OUString sTempStrg = sFormatStrg.copy( nPos+1 );
-        nPos = sTempStrg.indexOf( FORMAT_SEPARATOR );
+        std::u16string_view sTempStrg = sFormatStrg.substr( nPos+1 );
+        nPos = sTempStrg.find( FORMAT_SEPARATOR );
         bFound = true;
-        if( nPos < 0 )
+        if( nPos == std::u16string_view::npos )
         {
-            return sTempStrg;
+            return OUString(sTempStrg);
         }
         else
         {
-            return sTempStrg.copy( 0,nPos );
+            return OUString(sTempStrg.substr( 0,nPos ));
         }
     }
     return OUString();
 }
 
 // see also GetPosFormatString()
-OUString SbxBasicFormater::Get0FormatString( const OUString& sFormatStrg, bool 
& bFound )
+OUString SbxBasicFormater::Get0FormatString( std::u16string_view sFormatStrg, 
bool & bFound )
 {
     bFound = false;     // default...
-    sal_Int32 nPos = sFormatStrg.indexOf( FORMAT_SEPARATOR );
+    size_t nPos = sFormatStrg.find( FORMAT_SEPARATOR );
 
-    if( nPos >= 0 )
+    if( nPos != std::u16string_view::npos )
     {
         // the format string for the zero is
         // everything after the second ';'
-        OUString sTempStrg = sFormatStrg.copy( nPos+1 );
-        nPos = sTempStrg.indexOf( FORMAT_SEPARATOR );
-        if( nPos >= 0 )
+        std::u16string_view sTempStrg = sFormatStrg.substr( nPos+1 );
+        nPos = sTempStrg.find( FORMAT_SEPARATOR );
+        if( nPos != std::u16string_view::npos )
         {
             bFound = true;
-            sTempStrg = sTempStrg.copy( nPos+1 );
-            nPos = sTempStrg.indexOf( FORMAT_SEPARATOR );
-            if( nPos < 0 )
+            sTempStrg = sTempStrg.substr( nPos+1 );
+            nPos = sTempStrg.find( FORMAT_SEPARATOR );
+            if( nPos == std::u16string_view::npos )
             {
-                return sTempStrg;
+                return OUString(sTempStrg);
             }
             else
             {
-                return sTempStrg.copy( 0,nPos );
+                return OUString(sTempStrg.substr( 0,nPos ));
             }
         }
     }
@@ -369,25 +369,25 @@ OUString SbxBasicFormater::Get0FormatString( const 
OUString& sFormatStrg, bool &
 }
 
 // see also GetPosFormatString()
-OUString SbxBasicFormater::GetNullFormatString( const OUString& sFormatStrg, 
bool & bFound )
+OUString SbxBasicFormater::GetNullFormatString( std::u16string_view 
sFormatStrg, bool & bFound )
 {
     bFound = false;     // default...
-    sal_Int32 nPos = sFormatStrg.indexOf( FORMAT_SEPARATOR );
+    size_t nPos = sFormatStrg.find( FORMAT_SEPARATOR );
 
-    if( nPos >= 0 )
+    if( nPos != std::u16string_view::npos )
     {
         // the format-string for the Null is
         // everything after the third ';'
-        OUString sTempStrg = sFormatStrg.copy( nPos+1 );
-        nPos = sTempStrg.indexOf( FORMAT_SEPARATOR );
-        if( nPos >= 0 )
+        std::u16string_view sTempStrg = sFormatStrg.substr( nPos+1 );
+        nPos = sTempStrg.find( FORMAT_SEPARATOR );
+        if( nPos != std::u16string_view::npos )
         {
-            sTempStrg = sTempStrg.copy( nPos+1 );
-            nPos = sTempStrg.indexOf( FORMAT_SEPARATOR );
-            if( nPos >= 0 )
+            sTempStrg = sTempStrg.substr( nPos+1 );
+            nPos = sTempStrg.find( FORMAT_SEPARATOR );
+            if( nPos != std::u16string_view::npos )
             {
                 bFound = true;
-                return sTempStrg.copy( nPos+1 );
+                return OUString(sTempStrg.substr( nPos+1 ));
             }
         }
     }
@@ -841,7 +841,7 @@ void SbxBasicFormater::ScanFormatString( double dNumber,
     sReturnStrgFinal = sReturnStrg.makeStringAndClear();
 }
 
-OUString SbxBasicFormater::BasicFormatNull( const OUString& sFormatStrg )
+OUString SbxBasicFormater::BasicFormatNull( std::u16string_view sFormatStrg )
 {
     bool bNullFormatFound;
     OUString sNullFormatStrg = GetNullFormatString( sFormatStrg, 
bNullFormatFound );
diff --git a/codemaker/source/javamaker/javatype.cxx 
b/codemaker/source/javamaker/javatype.cxx
index 99a07339f821..563506221721 100644
--- a/codemaker/source/javamaker/javatype.cxx
+++ b/codemaker/source/javamaker/javatype.cxx
@@ -44,6 +44,7 @@
 #include <rtl/ustring.hxx>
 #include <sal/types.h>
 #include <unoidl/unoidl.hxx>
+#include <o3tl/string_view.hxx>
 
 #include "classfile.hxx"
 #include "javaoptions.hxx"
@@ -108,14 +109,18 @@ bool isSpecialType(SpecialType special) {
 }
 
 OString translateUnoidlEntityNameToJavaFullyQualifiedName(
-    OUString const & name, std::string_view prefix)
+    std::u16string_view name, std::string_view prefix)
 {
-    assert(!name.startsWith("[]"));
-    assert(name.indexOf('<') == -1);
-    sal_Int32 i = name.lastIndexOf('.') + 1;
-    return codemaker::convertString(name.copy(0, i)).replace('.', '/')
+    assert(!o3tl::starts_with(name, u"[]"));
+    assert(name.find('<') == std::string_view::npos);
+    size_t i = name.rfind('.');
+    if (i == std::string_view::npos)
+        i = 0;
+    else
+        ++i;
+    return codemaker::convertString(OUString(name.substr(0, i))).replace('.', 
'/')
         + codemaker::java::translateUnoToJavaIdentifier(
-            codemaker::convertString(name.copy(i)), prefix);
+            codemaker::convertString(OUString(name.substr(i))), prefix);
 }
 
 struct PolymorphicUnoType {
diff --git a/comphelper/source/misc/string.cxx 
b/comphelper/source/misc/string.cxx
index 2934a6b73cbd..acdb6c88adcb 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -541,8 +541,6 @@ OUString setToken(const OUString& rIn, sal_Int32 nToken, 
sal_Unicode cTok,
     return rIn;
 }
 
-
-
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/compilerplugins/clang/stringviewparam.cxx 
b/compilerplugins/clang/stringviewparam.cxx
index 10b7bd7e9c16..42595e887e45 100644
--- a/compilerplugins/clang/stringviewparam.cxx
+++ b/compilerplugins/clang/stringviewparam.cxx
@@ -140,7 +140,8 @@ DeclRefExpr const* 
relevantCXXMemberCallExpr(CXXMemberCallExpr const* expr)
         if (n == "endsWith" || n == "isEmpty" || n == "startsWith" || n == 
"subView"
             || n == "indexOf" || n == "lastIndexOf" || n == "compareTo" || n 
== "match"
             || n == "trim" || n == "toInt32" || n == "toInt64" || n == 
"toDouble"
-            || n == "equalsIgnoreAsciiCase" || n == "compareToIgnoreAsciiCase" 
|| n == "getToken")
+            || n == "equalsIgnoreAsciiCase" || n == "compareToIgnoreAsciiCase" 
|| n == "getToken"
+            || n == "copy")
         {
             good = true;
         }
diff --git a/desktop/source/app/dispatchwatcher.cxx 
b/desktop/source/app/dispatchwatcher.cxx
index 3d24a158261e..e4745f6761a5 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -243,16 +243,16 @@ void scriptCat(const Reference< XModel >& xDoc )
 }
 
 // Perform batch print
-void batchPrint( const OUString &rPrinterName, const Reference< XPrintable > 
&xDoc,
+void batchPrint( std::u16string_view rPrinterName, const Reference< XPrintable 
> &xDoc,
                  const INetURLObject &aObj, const OUString &aName )
 {
     OUString aFilterOut;
     OUString aPrinterName;
-    sal_Int32 nPathIndex =  rPrinterName.lastIndexOf( ';' );
-    if( nPathIndex != -1 )
-        aFilterOut=rPrinterName.copy( nPathIndex+1 );
+    size_t nPathIndex =  rPrinterName.rfind( ';' );
+    if( nPathIndex != std::u16string_view::npos )
+        aFilterOut=rPrinterName.substr( nPathIndex+1 );
     if( nPathIndex != 0 )
-        aPrinterName=rPrinterName.copy( 0, nPathIndex );
+        aPrinterName=rPrinterName.substr( 0, nPathIndex );
 
     INetURLObject aOutFilename( aObj );
     aOutFilename.SetExtension( u"pdf" );
diff --git a/framework/inc/uifactory/configurationaccessfactorymanager.hxx 
b/framework/inc/uifactory/configurationaccessfactorymanager.hxx
index 9f710d235c8d..8e2bbf4c4b1a 100644
--- a/framework/inc/uifactory/configurationaccessfactorymanager.hxx
+++ b/framework/inc/uifactory/configurationaccessfactorymanager.hxx
@@ -44,7 +44,7 @@ class ConfigurationAccess_FactoryManager final : public 
::cppu::WeakImplHelper<
 
         void          readConfigurationData();
 
-        OUString                           
getFactorySpecifierFromTypeNameModule( std::u16string_view rType, const 
OUString& rName, std::u16string_view rModule ) const;
+        OUString                           
getFactorySpecifierFromTypeNameModule( std::u16string_view rType, 
std::u16string_view rName, std::u16string_view rModule ) const;
         void                                    
addFactorySpecifierToTypeNameModule( std::u16string_view rType, 
std::u16string_view rName, std::u16string_view rModule, const OUString& 
aServiceSpecifier );
         void                                    
removeFactorySpecifierFromTypeNameModule( std::u16string_view rType, 
std::u16string_view rName, std::u16string_view rModule );
         css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >  
 getFactoriesDescription() const;
diff --git a/framework/source/uifactory/uielementfactorymanager.cxx 
b/framework/source/uifactory/uielementfactorymanager.cxx
index 39b34246651f..f1cdea2e98ea 100644
--- a/framework/source/uifactory/uielementfactorymanager.cxx
+++ b/framework/source/uifactory/uielementfactorymanager.cxx
@@ -84,7 +84,7 @@ 
ConfigurationAccess_FactoryManager::~ConfigurationAccess_FactoryManager()
         xContainer->removeContainerListener(m_xConfigListener);
 }
 
-OUString 
ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModule( 
std::u16string_view rType, const OUString& rName, std::u16string_view rModule ) 
const
+OUString 
ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModule( 
std::u16string_view rType, std::u16string_view rName, std::u16string_view 
rModule ) const
 {
     // SAFE
     std::unique_lock g(m_aMutex);
@@ -102,10 +102,10 @@ OUString 
ConfigurationAccess_FactoryManager::getFactorySpecifierFromTypeNameModu
         else
         {
             // Support factories which uses a defined prefix before the ui 
name.
-            sal_Int32 nIndex = rName.indexOf( '_' );
-            if ( nIndex > 0 )
+            size_t nIndex = rName.find( '_' );
+            if ( nIndex > 0 && nIndex != std::u16string_view::npos)
             {
-                OUString aName = rName.copy( 0, nIndex+1 );
+                std::u16string_view aName = rName.substr( 0, nIndex+1 );
                 pIter = m_aFactoryManagerMap.find( getHashKeyFromStrings( 
rType, aName, std::u16string_view() ));
                 if ( pIter != m_aFactoryManagerMap.end() )
                     return pIter->second;
diff --git a/i18npool/source/transliteration/transliteration_body.cxx 
b/i18npool/source/transliteration/transliteration_body.cxx
index 9b05f05b585c..605a3bb64284 100644
--- a/i18npool/source/transliteration/transliteration_body.cxx
+++ b/i18npool/source/transliteration/transliteration_body.cxx
@@ -225,11 +225,11 @@ Transliteration_titlecase::Transliteration_titlecase()
 
 /// @throws RuntimeException
 static OUString transliterate_titlecase_Impl(
-    const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount,
+    std::u16string_view inStr, sal_Int32 startPos, sal_Int32 nCount,
     const Locale &rLocale,
     Sequence< sal_Int32 >* pOffset )
 {
-    const OUString aText( inStr.copy( startPos, nCount ) );
+    const OUString aText( inStr.substr( startPos, nCount ) );
 
     OUString aRes;
     if (!aText.isEmpty())
diff --git a/idl/source/prj/svidl.cxx b/idl/source/prj/svidl.cxx
index efc6bf2946df..2c9fbf63d770 100644
--- a/idl/source/prj/svidl.cxx
+++ b/idl/source/prj/svidl.cxx
@@ -79,14 +79,14 @@ static bool FileMove_Impl( const OUString & rFile1, const 
OUString & rFile2, boo
 
 //This function gets a system path to a file [fname], creates a temp file in
 //the same folder as [fname] and returns the system path of the temp file.
-static OUString tempFileHelper(OUString const & fname)
+static OUString tempFileHelper(std::u16string_view fname)
 {
     OUString aTmpFile;
 
-    sal_Int32 delimIndex = fname.lastIndexOf( '/' );
-    if( delimIndex > 0 )
+    size_t delimIndex = fname.rfind( '/' );
+    if( delimIndex > 0 && delimIndex != std::u16string_view::npos)
     {
-        OUString aTmpDir( fname.copy( 0,  delimIndex ) );
+        OUString aTmpDir( fname.substr( 0,  delimIndex ) );
         osl::FileBase::getFileURLFromSystemPath( aTmpDir, aTmpDir );
         osl::FileBase::createTempFile( &aTmpDir, nullptr, &aTmpFile );
         osl::FileBase::getSystemPathFromFileURL( aTmpFile, aTmpFile );
diff --git a/pyuno/source/loader/pyuno_loader.cxx 
b/pyuno/source/loader/pyuno_loader.cxx
index 0db6e637a2a7..f01d8a0529a3 100644
--- a/pyuno/source/loader/pyuno_loader.cxx
+++ b/pyuno/source/loader/pyuno_loader.cxx
@@ -133,25 +133,25 @@ static void setPythonHome ( const OUString & pythonHome )
     Py_SetPythonHome(wide);
 }
 
-static void prependPythonPath( const OUString & pythonPathBootstrap )
+static void prependPythonPath( std::u16string_view pythonPathBootstrap )
 {
     OUStringBuffer bufPYTHONPATH( 256 );
     bool bAppendSep = false;
     sal_Int32 nIndex = 0;
     while( true )
     {
-        sal_Int32 nNew = pythonPathBootstrap.indexOf( ' ', nIndex );
-        OUString fileUrl;
-        if( nNew == -1 )
+        size_t nNew = pythonPathBootstrap.find( ' ', nIndex );
+        std::u16string_view fileUrl;
+        if( nNew == std::u16string_view::npos )
         {
-            fileUrl = pythonPathBootstrap.copy(nIndex);
+            fileUrl = pythonPathBootstrap.substr(nIndex);
         }
         else
         {
-            fileUrl = pythonPathBootstrap.copy(nIndex, nNew - nIndex);
+            fileUrl = pythonPathBootstrap.substr(nIndex, nNew - nIndex);
         }
         OUString systemPath;
-        osl_getSystemPathFromFileURL( fileUrl.pData, &(systemPath.pData) );
+        osl_getSystemPathFromFileURL( OUString(fileUrl).pData, 
&(systemPath.pData) );
         if (!systemPath.isEmpty())
         {
             if (bAppendSep)
@@ -159,7 +159,7 @@ static void prependPythonPath( const OUString & 
pythonPathBootstrap )
             bufPYTHONPATH.append(systemPath);
             bAppendSep = true;
         }
-        if( nNew == -1 )
+        if( nNew == std::u16string_view::npos )
             break;
         nIndex = nNew + 1;
     }
diff --git a/sal/cppunittester/cppunittester.cxx 
b/sal/cppunittester/cppunittester.cxx
index ae77bb3e3961..fec62c261260 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -357,16 +357,16 @@ double get_time(timeval* time)
     return nTime;
 }
 
-OString generateTestName(const OUString& rPath)
+OString generateTestName(std::u16string_view rPath)
 {
-    sal_Int32 nPathSep = rPath.lastIndexOf("/");
-    OUString aTestName = rPath.copy(nPathSep+1);
+    size_t nPathSep = rPath.rfind('/');
+    std::u16string_view aTestName = rPath.substr(nPathSep+1);
     return OUStringToOString(aTestName, RTL_TEXTENCODING_UTF8);
 }
 
-void reportResourceUsage(const OUString& rPath)
+void reportResourceUsage(std::u16string_view rPath)
 {
-    OUString aFullPath = rPath + ".resource.log";
+    OUString aFullPath = OUString::Concat(rPath) + ".resource.log";
     rusage resource_usage;
     getrusage(RUSAGE_SELF, &resource_usage);
 
diff --git a/scripting/source/provider/URIHelper.cxx 
b/scripting/source/provider/URIHelper.cxx
index 481a5b2f6e4e..5333bee34da4 100644
--- a/scripting/source/provider/URIHelper.cxx
+++ b/scripting/source/provider/URIHelper.cxx
@@ -164,16 +164,16 @@ ScriptingFrameworkURIHelper::initBaseURI()
 }
 
 OUString
-ScriptingFrameworkURIHelper::getLanguagePart(const OUString& rStorageURI)
+ScriptingFrameworkURIHelper::getLanguagePart(std::u16string_view rStorageURI)
 {
     OUString result;
 
-    sal_Int32 idx = rStorageURI.indexOf(m_sBaseURI);
+    size_t idx = rStorageURI.find(m_sBaseURI);
     sal_Int32 len = m_sBaseURI.getLength() + 1;
 
-    if ( idx != -1 )
+    if ( idx != std::u16string_view::npos )
     {
-        result = rStorageURI.copy(idx + len);
+        result = rStorageURI.substr(idx + len);
         result = result.replace('/', '|');
     }
     return result;
diff --git a/scripting/source/provider/URIHelper.hxx 
b/scripting/source/provider/URIHelper.hxx
index e7a05fd73d99..9d200a1a377f 100644
--- a/scripting/source/provider/URIHelper.hxx
+++ b/scripting/source/provider/URIHelper.hxx
@@ -50,7 +50,7 @@ private:
     OUString SCRIPTS_PART;
 
     bool initBaseURI();
-    OUString getLanguagePart(const OUString& rStorageURI);
+    OUString getLanguagePart(std::u16string_view rStorageURI);
     static OUString getLanguagePath(const OUString& rLanguagePart);
 
 public:
diff --git a/scripting/source/vbaevents/eventhelper.cxx 
b/scripting/source/vbaevents/eventhelper.cxx
index d89cce2a36a1..3e54f5d6ffc8 100644
--- a/scripting/source/vbaevents/eventhelper.cxx
+++ b/scripting/source/vbaevents/eventhelper.cxx
@@ -76,8 +76,8 @@ using namespace ::com::sun::star::uno;
 using namespace ::ooo::vba;
 
 // Some constants
-const char DELIM[] = "::";
-const sal_Int32 DELIMLEN = strlen(DELIM);
+constexpr std::u16string_view DELIM = u"::";
+constexpr sal_Int32 DELIMLEN = DELIM.size();
 
 static bool isKeyEventOk( awt::KeyEvent& evt, const Sequence< Any >& params )
 {
@@ -295,7 +295,7 @@ private:
 }
 
 static bool
-eventMethodToDescriptor( const OUString& rEventMethod, ScriptEventDescriptor& 
evtDesc, const OUString& sCodeName )
+eventMethodToDescriptor( std::u16string_view rEventMethod, 
ScriptEventDescriptor& evtDesc, const OUString& sCodeName )
 {
     // format of ControlListener is TypeName::methodname e.g.
     // "com.sun.star.awt.XActionListener::actionPerformed" or
@@ -303,13 +303,13 @@ eventMethodToDescriptor( const OUString& rEventMethod, 
ScriptEventDescriptor& ev
 
     OUString sMethodName;
     OUString sTypeName;
-    sal_Int32 nDelimPos = rEventMethod.indexOf( DELIM );
-    if ( nDelimPos == -1 )
+    size_t nDelimPos = rEventMethod.find( DELIM );
+    if ( nDelimPos == std::u16string_view::npos )
     {
         return false;
     }
-    sMethodName = rEventMethod.copy( nDelimPos + DELIMLEN );
-    sTypeName = rEventMethod.copy( 0, nDelimPos );
+    sMethodName = rEventMethod.substr( nDelimPos + DELIMLEN );
+    sTypeName = rEventMethod.substr( 0, nDelimPos );
 
     EventInfoHash& infos = getEventTransInfo();
 
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index e831dbc92733..506125be7d43 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -51,6 +51,7 @@
 #include <vcl/uitest/logger.hxx>
 #include <vcl/uitest/eventdescription.hxx>
 #include <vcl/window.hxx>
+#include <o3tl/string_view.hxx>
 
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <comphelper/lok.hxx>
@@ -647,50 +648,50 @@ bool SdrMarkView::ImpIsFrameHandles() const
 
 namespace
 {
-OUString lcl_getDragMethodServiceName( const OUString& rCID )
+std::u16string_view lcl_getDragMethodServiceName( std::u16string_view rCID )
 {
-    OUString aRet;
+    std::u16string_view aRet;
 
-    sal_Int32 nIndexStart = rCID.indexOf( "DragMethod=" );
-    if( nIndexStart != -1 )
+    size_t nIndexStart = rCID.find( u"DragMethod=" );
+    if( nIndexStart != std::u16string_view::npos )
     {
-        nIndexStart = rCID.indexOf( '=', nIndexStart );
-        if( nIndexStart != -1 )
+        nIndexStart = rCID.find( '=', nIndexStart );
+        if( nIndexStart != std::u16string_view::npos )
         {
             nIndexStart++;
-            sal_Int32 nNextSlash = rCID.indexOf( '/', nIndexStart );
-            if( nNextSlash != -1 )
+            size_t nNextSlash = rCID.find( '/', nIndexStart );
+            if( nNextSlash != std::u16string_view::npos )
             {
                 sal_Int32 nIndexEnd = nNextSlash;
-                sal_Int32 nNextColon = rCID.indexOf( ':', nIndexStart );
-                if( nNextColon < nNextSlash )
+                size_t nNextColon = rCID.find( ':', nIndexStart );
+                if( nNextColon == std::u16string_view::npos || nNextColon < 
nNextSlash )
                     nIndexEnd = nNextColon;
-                aRet = rCID.copy(nIndexStart,nIndexEnd-nIndexStart);
+                aRet = rCID.substr(nIndexStart,nIndexEnd-nIndexStart);
             }
         }
     }
     return aRet;
 }
 
-OUString lcl_getDragParameterString( const OUString& rCID )
+std::u16string_view lcl_getDragParameterString( std::u16string_view rCID )
 {
-    OUString aRet;
+    std::u16string_view aRet;
 
-    sal_Int32 nIndexStart = rCID.indexOf( "DragParameter=" );
-    if( nIndexStart != -1 )
+    size_t nIndexStart = rCID.find( u"DragParameter=" );
+    if( nIndexStart != std::u16string_view::npos )
     {
-        nIndexStart = rCID.indexOf( '=', nIndexStart );
-        if( nIndexStart != -1 )
+        nIndexStart = rCID.find( '=', nIndexStart );
+        if( nIndexStart != std::u16string_view::npos )
         {
             nIndexStart++;
-            sal_Int32 nNextSlash = rCID.indexOf( '/', nIndexStart );
-            if( nNextSlash != -1 )
+            size_t nNextSlash = rCID.find( '/', nIndexStart );
+            if( nNextSlash != std::u16string_view::npos )
             {
                 sal_Int32 nIndexEnd = nNextSlash;
-                sal_Int32 nNextColon = rCID.indexOf( ':', nIndexStart );
-                if( nNextColon < nNextSlash )
+                size_t nNextColon = rCID.find( ':', nIndexStart );
+                if( nNextColon == std::u16string_view::npos || nNextColon < 
nNextSlash )
                     nIndexEnd = nNextColon;
-                aRet = rCID.copy(nIndexStart,nIndexEnd-nIndexStart);
+                aRet = rCID.substr(nIndexStart,nIndexEnd-nIndexStart);
             }
         }
     }
@@ -905,29 +906,28 @@ void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle 
const & rRect, const S
                             
aExtraInfo.append(OString::boolean(aObjectCID[nPos] == '1'));
                         }
 
-                        OUString sDragMethod = 
lcl_getDragMethodServiceName(aValue);
-                        if (sDragMethod == "PieSegmentDragging")
+                        std::u16string_view sDragMethod = 
lcl_getDragMethodServiceName(aValue);
+                        if (sDragMethod == u"PieSegmentDragging")
                         {
                             // old initial offset inside the CID returned by 
xSelectionSupplier->getSelection()
                             // after a pie segment dragging; using 
SdrObject::GetName for getting a CID with the updated offset
                             aValue = pO->GetName();
-                            OUString sDragParameters = 
lcl_getDragParameterString(aValue);
-                            if (!sDragParameters.isEmpty())
+                            std::u16string_view sDragParameters = 
lcl_getDragParameterString(aValue);
+                            if (!sDragParameters.empty())
                             {
                                 aExtraInfo.append(", \"dragInfo\": { ");
                                 aExtraInfo.append("\"dragMethod\": \"");
-                                aExtraInfo.append(sDragMethod.toUtf8());
+                                
aExtraInfo.append(OUString(sDragMethod).toUtf8());
                                 aExtraInfo.append("\"");
 
-                                OUString sParam;
                                 sal_Int32 nStartIndex = 0;
                                 std::array<int, 5> aDragParameters;
                                 for (auto& rParam : aDragParameters)
                                 {
-                                    sParam = sDragParameters.getToken(0, ',', 
nStartIndex);
-                                    if (sParam.isEmpty())
+                                    std::u16string_view sParam = 
o3tl::getToken(sDragParameters, 0, ',', nStartIndex);
+                                    if (sParam.empty())
                                         break;
-                                    rParam = sParam.toInt32();
+                                    rParam = o3tl::toInt32(sParam);
                                 }
 
                                 // initial offset in %
diff --git a/unodevtools/source/skeletonmaker/cpptypemaker.cxx 
b/unodevtools/source/skeletonmaker/cpptypemaker.cxx
index 59407c2c6b47..62f86056573f 100644
--- a/unodevtools/source/skeletonmaker/cpptypemaker.cxx
+++ b/unodevtools/source/skeletonmaker/cpptypemaker.cxx
@@ -36,7 +36,7 @@ namespace skeletonmaker::cpp {
 static void printType(
     std::ostream & o, ProgramOptions const & options,
     rtl::Reference< TypeManager > const & manager,
-    codemaker::UnoType::Sort sort, OUString const & nucleus, sal_Int32 rank,
+    codemaker::UnoType::Sort sort, std::u16string_view nucleus, sal_Int32 rank,
     std::vector< OUString > const & arguments,
     rtl::Reference< unoidl::Entity > const & entity, short referenceType,
     bool defaultvalue)
@@ -67,7 +67,7 @@ static void printType(
         if (sort == codemaker::UnoType::Sort::Enum) {
             auto pEnumTypeEntity(dynamic_cast<unoidl::EnumTypeEntity 
*>(entity.get()));
             assert(pEnumTypeEntity);
-            o << nucleus.copy(nucleus.lastIndexOf('.') + 1) << "_"
+            o << OUString(nucleus.substr(nucleus.rfind('.') + 1)) << "_"
               << pEnumTypeEntity->getMembers()[0].name;
         }
         return;
@@ -261,10 +261,10 @@ static void printConstructor(
     std::ostream & o, ProgramOptions const & options,
     rtl::Reference< TypeManager > const & manager,
     codemaker::UnoType::Sort sort,
-    rtl::Reference< unoidl::Entity > const & entity, OUString const & name,
+    rtl::Reference< unoidl::Entity > const & entity, std::u16string_view name,
     std::vector< OUString > const & arguments)
 {
-    o << "public " << name.copy(name.lastIndexOf('.') + 1) << '(';
+    o << "public " << OUString(name.substr(name.rfind('.') + 1)) << '(';
     printConstructorParameters(
         o, options, manager, sort, entity, name, arguments);
     o << ");\n";
@@ -713,7 +713,7 @@ static void printServiceMembers(
 static void printMapsToCppType(
     std::ostream & o, ProgramOptions const & options,
     rtl::Reference< TypeManager > const & manager,
-    codemaker::UnoType::Sort sort, OUString const & nucleus, sal_Int32 rank,
+    codemaker::UnoType::Sort sort, std::u16string_view nucleus, sal_Int32 rank,
     std::vector< OUString > const & arguments,
     rtl::Reference< unoidl::Entity > const & entity, const char * cppTypeSort)
 {
@@ -722,7 +722,7 @@ static void printMapsToCppType(
         o << cppTypeSort << ' ';
 
     o << "type \"";
-    if (rank == 0 && nucleus == "com.sun.star.uno.XInterface") {
+    if (rank == 0 && nucleus == u"com.sun.star.uno.XInterface") {
         o << "Reference< com::sun::star::uno::XInterface >";
     } else {
         printType(
diff --git a/unodevtools/source/skeletonmaker/javacompskeleton.cxx 
b/unodevtools/source/skeletonmaker/javacompskeleton.cxx
index c6576c40bfc8..e5f15a180d51 100644
--- a/unodevtools/source/skeletonmaker/javacompskeleton.cxx
+++ b/unodevtools/source/skeletonmaker/javacompskeleton.cxx
@@ -32,11 +32,11 @@ using namespace ::codemaker::java;
 
 namespace skeletonmaker::java {
 
-static void generatePackage(std::ostream & o, const OString & implname)
+static void generatePackage(std::ostream & o, std::string_view implname)
 {
-    sal_Int32 index = implname.lastIndexOf('.');
-    if (index != -1)
-        o << "package " << implname.copy(0, index) << ";\n\n";
+    size_t index = implname.rfind('.');
+    if (index != std::string_view::npos)
+        o << "package " << implname.substr(0, index) << ";\n\n";
 }
 
 static void generateImports(std::ostream & o, ProgramOptions const & options,
diff --git a/unodevtools/source/skeletonmaker/javatypemaker.cxx 
b/unodevtools/source/skeletonmaker/javatypemaker.cxx
index e724eb498838..d576f5a1dd12 100644
--- a/unodevtools/source/skeletonmaker/javatypemaker.cxx
+++ b/unodevtools/source/skeletonmaker/javatypemaker.cxx
@@ -248,10 +248,10 @@ static void printConstructor(
     std::ostream & o, ProgramOptions const & options,
     rtl::Reference< TypeManager > const & manager,
     codemaker::UnoType::Sort sort,
-    rtl::Reference< unoidl::Entity > const & entity, OUString const & name,
+    rtl::Reference< unoidl::Entity > const & entity, std::u16string_view name,
     std::vector< OUString > const & arguments)
 {
-    o << "public " << name.copy(name.lastIndexOf('.') + 1) << '(';
+    o << "public " << OUString(name.substr(name.rfind('.') + 1)) << '(';
     printConstructorParameters(
         o, options, manager, sort, entity, name, arguments);
     o << ");\n";
diff --git a/uui/source/iahndl-ssl.cxx b/uui/source/iahndl-ssl.cxx
index fa1b2a6a16e4..fce82e8de6c6 100644
--- a/uui/source/iahndl-ssl.cxx
+++ b/uui/source/iahndl-ssl.cxx
@@ -54,7 +54,7 @@ using namespace com::sun::star;
 namespace {
 
 OUString
-getContentPart( const OUString& _rRawString )
+getContentPart( std::u16string_view _rRawString )
 {
     // search over some parts to find a string
     static char const * aIDs[] = { "CN=", "OU=", "O=", "E=", nullptr };
@@ -63,15 +63,15 @@ getContentPart( const OUString& _rRawString )
     while ( aIDs[i] )
     {
         OUString sPartId = OUString::createFromAscii( aIDs[i++] );
-        sal_Int32 nContStart = _rRawString.indexOf( sPartId );
-        if ( nContStart != -1 )
+        size_t nContStart = _rRawString.find( sPartId );
+        if ( nContStart != std::u16string_view::npos )
         {
             nContStart += sPartId.getLength();
-            sal_Int32 nContEnd = _rRawString.indexOf( ',', nContStart );
-            if ( nContEnd != -1 )
-                sPart = _rRawString.copy( nContStart, nContEnd - nContStart );
+            size_t nContEnd = _rRawString.find( ',', nContStart );
+            if ( nContEnd != std::u16string_view::npos )
+                sPart = _rRawString.substr( nContStart, nContEnd - nContStart 
);
             else
-                sPart = _rRawString.copy( nContStart );
+                sPart = _rRawString.substr( nContStart );
             break;
         }
     }
diff --git a/uui/source/secmacrowarnings.cxx b/uui/source/secmacrowarnings.cxx
index 8f8e222c99e8..164890efca69 100644
--- a/uui/source/secmacrowarnings.cxx
+++ b/uui/source/secmacrowarnings.cxx
@@ -38,22 +38,22 @@ using namespace ::com::sun::star;
 
 namespace
 {
-    OUString GetContentPart( const OUString& _rRawString, const OUString& 
_rPartId )
+    std::u16string_view GetContentPart( std::u16string_view _rRawString, const 
OUString& _rPartId )
     {
-        OUString      s;
+        std::u16string_view      s;
 
-        sal_Int32  nContStart = _rRawString.indexOf( _rPartId );
-        if( nContStart != -1 )
+        size_t  nContStart = _rRawString.find( _rPartId );
+        if( nContStart != std::u16string_view::npos )
         {
             nContStart = nContStart + _rPartId.getLength();
             ++nContStart;                   // now its start of content, 
directly after Id
 
-            sal_Int32  nContEnd = _rRawString.indexOf( ',', nContStart );
+            size_t  nContEnd = _rRawString.find( ',', nContStart );
 
-            if ( nContEnd != -1 )
-                s = _rRawString.copy( nContStart, nContEnd - nContStart );
+            if ( nContEnd != std::u16string_view::npos )
+                s = _rRawString.substr( nContStart, nContEnd - nContStart );
             else
-                s = _rRawString.copy( nContStart );
+                s = _rRawString.substr( nContStart );
         }
 
         return s;
@@ -195,7 +195,7 @@ void MacroWarning::SetCertificate( const 
css::uno::Reference< css::security::XCe
     mxCert = _rxCert;
     if( mxCert.is() )
     {
-        OUString s = GetContentPart( mxCert->getSubjectName(), "CN" );
+        OUString s( GetContentPart( mxCert->getSubjectName(), "CN" ) );
         mxSignsFI->set_label(s);
         mxViewSignsBtn->set_sensitive(true);
     }
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index d87c05afff01..6bf0651bcbe8 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -4324,27 +4324,27 @@ std::tuple<OUString, std::vector<OUString>, 
std::vector<OUString> > splitFieldCo
     return std::make_tuple(sType, arguments, switches);
 }
 
-static OUString lcl_ExtractVariableAndHint( const OUString& rCommand, 
OUString& rHint )
+static OUString lcl_ExtractVariableAndHint( std::u16string_view rCommand, 
OUString& rHint )
 {
     // the first word after "ASK " is the variable
     // the text after the variable and before a '\' is the hint
     // if no hint is set the variable is used as hint
     // the quotes of the hint have to be removed
-    sal_Int32 nIndex = rCommand.indexOf( ' ', 2); //find last space after 'ASK'
-    if (nIndex == -1)
+    size_t nIndex = rCommand.find( ' ', 2); //find last space after 'ASK'
+    if (nIndex == std::u16string_view::npos)
         return OUString();
     while(rCommand[nIndex] == ' ')
         ++nIndex;
-    OUString sShortCommand( rCommand.copy( nIndex ) ); //cut off the " ASK "
+    std::u16string_view sShortCommand( rCommand.substr( nIndex ) ); //cut off 
the " ASK "
 
-    sShortCommand = sShortCommand.getToken(0, '\\');
-    nIndex = 0;
-    OUString sRet = sShortCommand.getToken( 0, ' ', nIndex);
-    if( nIndex > 0)
-        rHint = sShortCommand.copy( nIndex );
+    sShortCommand = o3tl::getToken(sShortCommand, 0, '\\');
+    sal_Int32 nIndex2 = 0;
+    std::u16string_view sRet = o3tl::getToken(sShortCommand, 0, ' ', nIndex2);
+    if( nIndex2 > 0)
+        rHint = sShortCommand.substr( nIndex2 );
     if( rHint.isEmpty() )
         rHint = sRet;
-    return sRet;
+    return OUString(sRet);
 }
 
 
@@ -5169,17 +5169,17 @@ void DomainMapper_Impl::handleFieldSet
     // remove surrounding "" if exists
     if(sHint.getLength() >= 2)
     {
-        OUString sTmp = sHint.trim();
-        if (sTmp.startsWith("\"") && sTmp.endsWith("\""))
+        std::u16string_view sTmp = o3tl::trim(sHint);
+        if (o3tl::starts_with(sTmp, u"\"") && o3tl::ends_with(sTmp, u"\""))
         {
-            sHint = sTmp.copy(1, sTmp.getLength() - 2);
+            sHint = sTmp.substr(1, sTmp.size() - 2);
         }
     }
 
     // determine field master name
     uno::Reference< beans::XPropertySet > xMaster =
         FindOrCreateFieldMaster
-        ("com.sun.star.text.FieldMaster.SetExpression", sVariable );
+        ("com.sun.star.text.FieldMaster.SetExpression", sVariable);
 
     // a set field is a string
     xMaster->setPropertyValue(getPropertyName(PROP_SUB_TYPE), 
uno::makeAny(text::SetVariableType::STRING));
@@ -5189,8 +5189,9 @@ void DomainMapper_Impl::handleFieldSet
         ( xFieldInterface, uno::UNO_QUERY_THROW );
     xDependentField->attachTextFieldMaster( xMaster );
 
-    xFieldProperties->setPropertyValue(getPropertyName(PROP_HINT), 
uno::makeAny( sHint ));
-    xFieldProperties->setPropertyValue(getPropertyName(PROP_CONTENT), 
uno::makeAny( sHint ));
+    uno::Any aAnyHint = uno::makeAny(sHint);
+    xFieldProperties->setPropertyValue(getPropertyName(PROP_HINT), aAnyHint);
+    xFieldProperties->setPropertyValue(getPropertyName(PROP_CONTENT), 
aAnyHint);
     xFieldProperties->setPropertyValue(getPropertyName(PROP_SUB_TYPE), 
uno::makeAny(text::SetVariableType::STRING));
 
     // Mimic MS Word behavior (hide the SET)
@@ -6657,13 +6658,13 @@ void DomainMapper_Impl::CloseFieldCommand()
                     // command looks like: " SEQ Table \* ARABIC "
                     OUString sCmd(pContext->GetCommand());
                     // find the sequence name, e.g. "SEQ"
-                    OUString sSeqName( msfilter::util::findQuotedText(sCmd, 
"SEQ ", '\\') );
-                    sSeqName = sSeqName.trim();
+                    std::u16string_view sSeqName = 
msfilter::util::findQuotedText(sCmd, "SEQ ", '\\');
+                    sSeqName = o3tl::trim(sSeqName);
 
                     // create a sequence field master using the sequence name
                     uno::Reference< beans::XPropertySet > xMaster = 
FindOrCreateFieldMaster(
                                 "com.sun.star.text.FieldMaster.SetExpression",
-                                sSeqName);
+                                OUString(sSeqName));
 
                     xMaster->setPropertyValue(
                         getPropertyName(PROP_SUB_TYPE),
@@ -6678,7 +6679,7 @@ void DomainMapper_Impl::CloseFieldCommand()
                     uno::Reference< text::XDependentTextField > 
xDependentField( xFieldInterface, uno::UNO_QUERY_THROW );
                     xDependentField->attachTextFieldMaster( xMaster );
 
-                    OUString sFormula = sSeqName + "+1";
+                    OUString sFormula = OUString::Concat(sSeqName) + "+1";
                     OUString sValue;
                     if( lcl_FindInCommand( pContext->GetCommand(), 'c', sValue 
))
                     {

Reply via email to