summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-09-22 23:25:16 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-09-23 07:25:40 +0200
commitcb3058aa4e3155d97d47d1444b808da7297b5794 (patch)
tree2e712390eccca93e5e19d87a429ed6214d840a4b /framework
parent84e61754bfe2f07de412c24513774900702a48a2 (diff)
Extend loplugin:stringviewparam to starts/endsWith: framework
Change-Id: Idc92058e7d2ff63d55e97e6b2fee83314fc0334c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122498 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/protocols.h43
-rw-r--r--framework/source/layoutmanager/toolbarlayoutmanager.cxx5
-rw-r--r--framework/source/layoutmanager/toolbarlayoutmanager.hxx3
3 files changed, 29 insertions, 22 deletions
diff --git a/framework/inc/protocols.h b/framework/inc/protocols.h
index f9dfffd85a3d..30d87cc59336 100644
--- a/framework/inc/protocols.h
+++ b/framework/inc/protocols.h
@@ -21,6 +21,11 @@
#pragma once
+#include <sal/config.h>
+
+#include <string_view>
+
+#include <o3tl/string_view.hxx>
#include <rtl/ustring.hxx>
namespace framework{
@@ -34,23 +39,23 @@ namespace framework{
// indicates a loadable content in general!
#define SPECIALPROTOCOL_PRIVATE "private:"
// indicates loading of components using a model directly
-#define SPECIALPROTOCOL_PRIVATE_OBJECT "private:object"
+#define SPECIALPROTOCOL_PRIVATE_OBJECT u"private:object"
// indicates loading of components using a stream only
-#define SPECIALPROTOCOL_PRIVATE_STREAM "private:stream"
+#define SPECIALPROTOCOL_PRIVATE_STREAM u"private:stream"
// indicates creation of empty documents
-#define SPECIALPROTOCOL_PRIVATE_FACTORY "private:factory"
+#define SPECIALPROTOCOL_PRIVATE_FACTORY u"private:factory"
// internal protocol of the sfx project for generic dispatch functionality
-#define SPECIALPROTOCOL_SLOT "slot:"
+#define SPECIALPROTOCOL_SLOT u"slot:"
// external representation of the slot protocol using names instead of id's
-#define SPECIALPROTOCOL_UNO ".uno:"
+#define SPECIALPROTOCOL_UNO u".uno:"
// special sfx protocol to execute macros
-#define SPECIALPROTOCOL_MACRO "macro:"
+#define SPECIALPROTOCOL_MACRO u"macro:"
// generic way to start uno services during dispatch
-#define SPECIALPROTOCOL_SERVICE "service:"
+#define SPECIALPROTOCOL_SERVICE u"service:"
// for sending mails
-#define SPECIALPROTOCOL_MAILTO "mailto:"
+#define SPECIALPROTOCOL_MAILTO u"mailto:"
// for sending news
-#define SPECIALPROTOCOL_NEWS "news:"
+#define SPECIALPROTOCOL_NEWS u"news:"
/** well known protocols */
enum class EProtocol
@@ -75,37 +80,37 @@ class ProtocolCheck
It should be used instead of specifyProtocol() if only this question
is interesting to perform the code. We must not check for all possible protocols here...
*/
- static bool isProtocol( const OUString& sURL, EProtocol eRequired )
+ static bool isProtocol( std::u16string_view sURL, EProtocol eRequired )
{
bool bRet = false;
switch(eRequired)
{
case EProtocol::PrivateObject:
- bRet = sURL.startsWith(SPECIALPROTOCOL_PRIVATE_OBJECT);
+ bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_PRIVATE_OBJECT);
break;
case EProtocol::PrivateStream:
- bRet = sURL.startsWith(SPECIALPROTOCOL_PRIVATE_STREAM);
+ bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_PRIVATE_STREAM);
break;
case EProtocol::PrivateFactory:
- bRet = sURL.startsWith(SPECIALPROTOCOL_PRIVATE_FACTORY);
+ bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_PRIVATE_FACTORY);
break;
case EProtocol::Slot:
- bRet = sURL.startsWith(SPECIALPROTOCOL_SLOT);
+ bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_SLOT);
break;
case EProtocol::Uno:
- bRet = sURL.startsWith(SPECIALPROTOCOL_UNO);
+ bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_UNO);
break;
case EProtocol::Macro:
- bRet = sURL.startsWith(SPECIALPROTOCOL_MACRO);
+ bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_MACRO);
break;
case EProtocol::Service:
- bRet = sURL.startsWith(SPECIALPROTOCOL_SERVICE);
+ bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_SERVICE);
break;
case EProtocol::MailTo:
- bRet = sURL.startsWith(SPECIALPROTOCOL_MAILTO);
+ bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_MAILTO);
break;
case EProtocol::News:
- bRet = sURL.startsWith(SPECIALPROTOCOL_NEWS);
+ bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_NEWS);
break;
default:
bRet = false;
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
index 6ad7939ccb8f..97e8e75e5b29 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx
@@ -34,6 +34,7 @@
#include <com/sun/star/ui/XUIFunctionListener.hpp>
#include <cppuhelper/queryinterface.hxx>
+#include <o3tl/string_view.hxx>
#include <unotools/cmdoptions.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <toolkit/helper/convert.hxx>
@@ -558,14 +559,14 @@ bool ToolbarLayoutManager::createToolbar( const OUString& rResourceURL )
return bNotify;
}
-bool ToolbarLayoutManager::destroyToolbar( const OUString& rResourceURL )
+bool ToolbarLayoutManager::destroyToolbar( std::u16string_view rResourceURL )
{
uno::Reference< lang::XComponent > xComponent;
bool bNotify( false );
bool bMustBeSorted( false );
bool bMustLayouted( false );
- bool bMustBeDestroyed( !rResourceURL.startsWith("private:resource/toolbar/addon_") );
+ bool bMustBeDestroyed( !o3tl::starts_with(rResourceURL, u"private:resource/toolbar/addon_") );
{
SolarMutexGuard aWriteLock;
diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.hxx b/framework/source/layoutmanager/toolbarlayoutmanager.hxx
index d91938a55d47..b826b1e8cd34 100644
--- a/framework/source/layoutmanager/toolbarlayoutmanager.hxx
+++ b/framework/source/layoutmanager/toolbarlayoutmanager.hxx
@@ -21,6 +21,7 @@
#include <sal/config.h>
+#include <string_view>
#include <vector>
#include <uiconfiguration/globalsettings.hxx>
@@ -86,7 +87,7 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper< css::awt::XDockableW
bool requestToolbar( const OUString& rResourceURL );
bool createToolbar( const OUString& rResourceURL );
- bool destroyToolbar( const OUString& rResourceURL );
+ bool destroyToolbar( std::u16string_view rResourceURL );
// visibility
bool showToolbar( std::u16string_view rResourceURL );