[Libreoffice-commits] core.git: include/svtools svtools/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 22 18:45:13 UTC 2021


 include/svtools/imageresourceaccess.hxx     |    3 ++-
 svtools/source/misc/imageresourceaccess.cxx |   11 ++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

New commits:
commit 49cee95eb4efddefde9caab33d0a639e83f05202
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Sep 22 19:05:10 2021 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Sep 22 20:44:36 2021 +0200

    xtend loplugin:stringviewparam to starts/endsWith: svtools
    
    Change-Id: I5364107766dd77963a9a34468754c4cbcc34c8d8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122480
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/include/svtools/imageresourceaccess.hxx b/include/svtools/imageresourceaccess.hxx
index ccb5b6b69bce..ca76c0909f17 100644
--- a/include/svtools/imageresourceaccess.hxx
+++ b/include/svtools/imageresourceaccess.hxx
@@ -22,6 +22,7 @@
 #include <sal/config.h>
 
 #include <memory>
+#include <string_view>
 
 #include <config_options.h>
 #include <svtools/svtdllapi.h>
@@ -41,7 +42,7 @@ namespace svt::GraphicAccess
 */
 
 /** determines whether the given URL denotes an image within a resource */
-UNLESS_MERGELIBS(SVT_DLLPUBLIC) bool isSupportedURL(OUString const & rURL);
+UNLESS_MERGELIBS(SVT_DLLPUBLIC) bool isSupportedURL(std::u16string_view rURL);
 
 /** for a given URL of an image within a resource, this method retrieves an
     SvStream for this image.
diff --git a/svtools/source/misc/imageresourceaccess.cxx b/svtools/source/misc/imageresourceaccess.cxx
index 24db4ae50ac3..fc12981a3460 100644
--- a/svtools/source/misc/imageresourceaccess.cxx
+++ b/svtools/source/misc/imageresourceaccess.cxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/graphic/GraphicProvider.hpp>
 #include <com/sun/star/graphic/XGraphicProvider.hpp>
 #include <com/sun/star/io/XStream.hpp>
+#include <o3tl/string_view.hxx>
 #include <osl/diagnose.h>
 #include <tools/stream.hxx>
 #include <tools/diagnose_ex.h>
@@ -106,12 +107,12 @@ sal_Int64 SAL_CALL StreamSupplier::getLength()
     return m_xSeekable->getLength();
 }
 
-bool isSupportedURL(OUString const & rURL)
+bool isSupportedURL(std::u16string_view rURL)
 {
-    return rURL.startsWith("private:resource/")
-        || rURL.startsWith("private:graphicrepository/")
-        || rURL.startsWith("private:standardimage/")
-        || rURL.startsWith("vnd.sun.star.extension://");
+    return o3tl::starts_with(rURL, u"private:resource/")
+        || o3tl::starts_with(rURL, u"private:graphicrepository/")
+        || o3tl::starts_with(rURL, u"private:standardimage/")
+        || o3tl::starts_with(rURL, u"vnd.sun.star.extension://");
 }
 
 std::unique_ptr<SvStream> getImageStream(uno::Reference<uno::XComponentContext> const & rxContext, OUString const & rImageResourceURL)


More information about the Libreoffice-commits mailing list