include/vcl/GraphicObject.hxx | 3 ++- vcl/inc/unx/gtk/gtkdata.hxx | 3 ++- vcl/source/graphic/GraphicObject.cxx | 5 +++-- vcl/source/graphic/UnoGraphicProvider.cxx | 28 +++++++++++++++------------- vcl/source/window/layout.cxx | 9 +++++++-- vcl/source/window/toolbox.cxx | 12 +++++++----- vcl/unx/gtk3/gtkdata.cxx | 5 +++-- 7 files changed, 39 insertions(+), 26 deletions(-)
New commits: commit c638bcc78cfa3974b7461096b6ac521dfc5e927c Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Wed Sep 22 17:15:04 2021 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Wed Sep 22 18:55:18 2021 +0200 Extend loplugin:stringviewparam to starts/endsWith: vcl Change-Id: Ic208697fd985da223819d203e67325b03028fca5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122469 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/include/vcl/GraphicObject.hxx b/include/vcl/GraphicObject.hxx index 27b50455864a..980f686f6ba9 100644 --- a/include/vcl/GraphicObject.hxx +++ b/include/vcl/GraphicObject.hxx @@ -20,6 +20,7 @@ #pragma once #include <memory> +#include <string_view> #include <vcl/graph.hxx> #include <vcl/dllapi.h> #include <o3tl/typed_flags_set.hxx> @@ -268,7 +269,7 @@ public: void StopAnimation( const OutputDevice* pOut = nullptr, tools::Long nExtraData = 0 ); - static bool isGraphicObjectUniqueIdURL(OUString const & rURL); + static bool isGraphicObjectUniqueIdURL(std::u16string_view rURL); // create CropScaling information // fWidth, fHeight: object size diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx index 5ca53c368104..185a000e0398 100644 --- a/vcl/inc/unx/gtk/gtkdata.hxx +++ b/vcl/inc/unx/gtk/gtkdata.hxx @@ -39,6 +39,7 @@ #include <saltimer.hxx> #include <o3tl/enumarray.hxx> +#include <string_view> #include <vector> namespace com::sun::star::accessibility { class XAccessibleEventListener; } @@ -195,7 +196,7 @@ inline GdkGLContext* surface_create_gl_context(GdkSurface* pSurface) typedef GtkClipboard GdkClipboard; #endif -int getButtonPriority(const OString &rType); +int getButtonPriority(std::string_view rType); class GtkSalTimer final : public SalTimer { diff --git a/vcl/source/graphic/GraphicObject.cxx b/vcl/source/graphic/GraphicObject.cxx index d6c0963b6c61..96f69b3c37df 100644 --- a/vcl/source/graphic/GraphicObject.cxx +++ b/vcl/source/graphic/GraphicObject.cxx @@ -21,6 +21,7 @@ #include <algorithm> +#include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <tools/fract.hxx> #include <tools/helpers.hxx> @@ -884,9 +885,9 @@ Graphic GraphicObject::GetTransformedGraphic( const GraphicAttr* pAttr ) const return aGraphic; } -bool GraphicObject::isGraphicObjectUniqueIdURL(OUString const & rURL) +bool GraphicObject::isGraphicObjectUniqueIdURL(std::u16string_view rURL) { - return rURL.startsWith("vnd.sun.star.GraphicObject:"); + return o3tl::starts_with(rURL, u"vnd.sun.star.GraphicObject:"); } // calculate scalings between real image size and logic object size. This diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx index c4c77e43064b..058f72830041 100644 --- a/vcl/source/graphic/UnoGraphicProvider.cxx +++ b/vcl/source/graphic/UnoGraphicProvider.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <o3tl/string_view.hxx> #include <vcl/svapp.hxx> #include <vcl/image.hxx> #include <vcl/metaact.hxx> @@ -45,6 +46,7 @@ #include <vcl/dibtools.hxx> #include <comphelper/sequence.hxx> #include <memory> +#include <string_view> #include <vcl/TypeSerializer.hxx> @@ -81,9 +83,9 @@ protected: private: static css::uno::Reference< css::graphic::XGraphic > implLoadMemory( const OUString& rResourceURL ); - static css::uno::Reference< css::graphic::XGraphic > implLoadRepositoryImage( const OUString& rResourceURL ); + static css::uno::Reference< css::graphic::XGraphic > implLoadRepositoryImage( std::u16string_view rResourceURL ); static css::uno::Reference< css::graphic::XGraphic > implLoadBitmap( const css::uno::Reference< css::awt::XBitmap >& rBitmap ); - static css::uno::Reference< css::graphic::XGraphic > implLoadStandardImage( const OUString& rResourceURL ); + static css::uno::Reference< css::graphic::XGraphic > implLoadStandardImage( std::u16string_view rResourceURL ); }; GraphicProvider::GraphicProvider() @@ -142,15 +144,15 @@ uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadMemory( const OUS } -uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadRepositoryImage( const OUString& rResourceURL ) +uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadRepositoryImage( std::u16string_view rResourceURL ) { uno::Reference< ::graphic::XGraphic > xRet; - OUString sPathName; - if( rResourceURL.startsWith("private:graphicrepository/", &sPathName) ) + std::u16string_view sPathName; + if( o3tl::starts_with(rResourceURL, u"private:graphicrepository/", &sPathName) ) { BitmapEx aBitmap; - if ( vcl::ImageRepository::loadImage( sPathName, aBitmap ) ) + if ( vcl::ImageRepository::loadImage( OUString(sPathName), aBitmap ) ) { xRet = Graphic(aBitmap).GetXGraphic(); } @@ -159,26 +161,26 @@ uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadRepositoryImage( } -uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadStandardImage( const OUString& rResourceURL ) +uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadStandardImage( std::u16string_view rResourceURL ) { uno::Reference< ::graphic::XGraphic > xRet; - OUString sImageName; - if( rResourceURL.startsWith("private:standardimage/", &sImageName) ) + std::u16string_view sImageName; + if( o3tl::starts_with(rResourceURL, u"private:standardimage/", &sImageName) ) { - if ( sImageName == "info" ) + if ( sImageName == u"info" ) { xRet = Graphic(GetStandardInfoBoxImage().GetBitmapEx()).GetXGraphic(); } - else if ( sImageName == "warning" ) + else if ( sImageName == u"warning" ) { xRet = Graphic(GetStandardWarningBoxImage().GetBitmapEx()).GetXGraphic(); } - else if ( sImageName == "error" ) + else if ( sImageName == u"error" ) { xRet = Graphic(GetStandardErrorBoxImage().GetBitmapEx()).GetXGraphic(); } - else if ( sImageName == "query" ) + else if ( sImageName == u"query" ) { xRet = Graphic(GetStandardQueryBoxImage().GetBitmapEx()).GetXGraphic(); } diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index 4d25a0671836..e49396313449 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -7,11 +7,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <sal/config.h> + +#include <string_view> + #include <config_features.h> #include <com/sun/star/accessibility/AccessibleRole.hpp> #include <comphelper/base64.hxx> #include <o3tl/enumarray.hxx> #include <o3tl/enumrange.hxx> +#include <o3tl/string_view.hxx> #include <tools/stream.hxx> #include <vcl/builder.hxx> #include <vcl/toolkit/button.hxx> @@ -747,7 +752,7 @@ struct ButtonOrder } -static int getButtonPriority(const OString &rType) +static int getButtonPriority(std::string_view rType) { static const size_t N_TYPES = 6; static const ButtonOrder aDiscardCancelSave[N_TYPES] = @@ -783,7 +788,7 @@ static int getButtonPriority(const OString &rType) for (size_t i = 0; i < N_TYPES; ++i, ++pOrder) { - if (rType.endsWith(pOrder->m_aType)) + if (o3tl::ends_with(rType, pOrder->m_aType)) return pOrder->m_nPriority; } diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index ea731d784a7d..1f142ab6775b 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -36,6 +36,7 @@ #include <tools/poly.hxx> #include <svl/imageitm.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <accel.hxx> @@ -49,6 +50,7 @@ #include <cstdlib> #include <map> +#include <string_view> #include <vector> #include <math.h> @@ -3591,12 +3593,12 @@ void ToolBox::Resize() namespace { - bool DispatchableCommand(const OUString& rName) + bool DispatchableCommand(std::u16string_view rName) { - return rName.startsWith(".uno") || - rName.startsWith("slot:") || - rName.startsWith("macro:") || - rName.startsWith("vnd.sun.star.script"); + return o3tl::starts_with(rName, u".uno") || + o3tl::starts_with(rName, u"slot:") || + o3tl::starts_with(rName, u"macro:") || + o3tl::starts_with(rName, u"vnd.sun.star.script"); } } diff --git a/vcl/unx/gtk3/gtkdata.cxx b/vcl/unx/gtk3/gtkdata.cxx index b5f49e821bd3..d5cc7a5f369b 100644 --- a/vcl/unx/gtk3/gtkdata.cxx +++ b/vcl/unx/gtk3/gtkdata.cxx @@ -32,6 +32,7 @@ #include <bitmaps.hlst> #include <cursor_hotspots.hxx> #include <o3tl/safeint.hxx> +#include <o3tl/string_view.hxx> #include <osl/thread.h> #include <osl/process.h> @@ -875,7 +876,7 @@ struct ButtonOrder } -int getButtonPriority(const OString &rType) +int getButtonPriority(std::string_view rType) { static const size_t N_TYPES = 8; static const ButtonOrder aDiscardCancelSave[N_TYPES] = @@ -915,7 +916,7 @@ int getButtonPriority(const OString &rType) for (size_t i = 0; i < N_TYPES; ++i, ++pOrder) { - if (rType.endsWith(pOrder->m_aType)) + if (o3tl::ends_with(rType, pOrder->m_aType)) return pOrder->m_nPriority; }