summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-03 10:34:37 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-17 10:27:33 +0200
commit33bd16b344e273c427091ee68e946bf67b371dd7 (patch)
tree85fb383ea8e3d30f393bb197b5c74f73f6ca247f /scripting
parentfe597a337914decd62480d3eba84258333116db9 (diff)
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.grandin@collabora.co.uk>
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/provider/URIHelper.cxx8
-rw-r--r--scripting/source/provider/URIHelper.hxx2
-rw-r--r--scripting/source/vbaevents/eventhelper.cxx14
3 files changed, 12 insertions, 12 deletions
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();