sc/inc/dputil.hxx                          |    6 +++++-
 sc/source/core/data/dputil.cxx             |    5 +++--
 sc/source/core/tool/stylehelper.cxx        |    9 +++++++--
 sc/source/ui/dataprovider/dataprovider.cxx |    5 +++--
 sc/source/ui/inc/dataprovider.hxx          |    3 ++-
 sc/source/ui/vba/vbaworkbooks.cxx          |   11 ++++++-----
 sc/source/ui/vba/vbaworkbooks.hxx          |    6 +++++-
 7 files changed, 31 insertions(+), 14 deletions(-)

New commits:
commit 3b6dd54994ab1e624729cb007a8e3dc2b5f3b891
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed Sep 22 21:15:20 2021 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Wed Sep 22 23:23:35 2021 +0200

    Extend loplugin:stringviewparam to starts/endsWith: sc
    
    Change-Id: Ibda7acf66bd8382de25fae9b4385d655be6ab409
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122490
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/sc/inc/dputil.hxx b/sc/inc/dputil.hxx
index 70fa54e1aa3c..5081c758ab77 100644
--- a/sc/inc/dputil.hxx
+++ b/sc/inc/dputil.hxx
@@ -9,6 +9,10 @@
 
 #pragma once
 
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <rtl/ustring.hxx>
 #include "scdllapi.h"
 #include "global.hxx"
@@ -20,7 +24,7 @@ enum class ScGeneralFunction;
 class ScDPUtil
 {
 public:
-    static bool isDuplicateDimension(const OUString& rName);
+    static bool isDuplicateDimension(std::u16string_view rName);
 
     SC_DLLPUBLIC static OUString getSourceDimensionName(std::u16string_view 
rName);
 
diff --git a/sc/source/core/data/dputil.cxx b/sc/source/core/data/dputil.cxx
index b589d4e80156..0f5083f810df 100644
--- a/sc/source/core/data/dputil.cxx
+++ b/sc/source/core/data/dputil.cxx
@@ -20,6 +20,7 @@
 #include <svl/numformat.hxx>
 #include <svl/zforlist.hxx>
 #include <rtl/math.hxx>
+#include <o3tl/string_view.hxx>
 #include <osl/diagnose.h>
 
 #include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
@@ -57,9 +58,9 @@ OUString getSpecialDateName(double fValue, bool bFirst, 
SvNumberFormatter* pForm
 
 }
 
-bool ScDPUtil::isDuplicateDimension(const OUString& rName)
+bool ScDPUtil::isDuplicateDimension(std::u16string_view rName)
 {
-    return rName.endsWith("*");
+    return o3tl::ends_with(rName, u"*");
 }
 
 OUString ScDPUtil::getSourceDimensionName(std::u16string_view rName)
diff --git a/sc/source/core/tool/stylehelper.cxx 
b/sc/source/core/tool/stylehelper.cxx
index 076e968265ff..7caab7580dec 100644
--- a/sc/source/core/tool/stylehelper.cxx
+++ b/sc/source/core/tool/stylehelper.cxx
@@ -17,7 +17,12 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <svl/style.hxx>
+#include <o3tl/string_view.hxx>
 #include <osl/diagnose.h>
 
 #include <stylehelper.hxx>
@@ -120,9 +125,9 @@ static const ScDisplayNameMap* lcl_GetStyleNameMap( 
SfxStyleFamily nType )
 
 constexpr OUStringLiteral SC_SUFFIX_USER = u" (user)";
 
-static bool lcl_EndsWithUser( const OUString& rString )
+static bool lcl_EndsWithUser( std::u16string_view rString )
 {
-    return rString.endsWith(SC_SUFFIX_USER);
+    return o3tl::ends_with(rString, SC_SUFFIX_USER);
 }
 
 OUString ScStyleNameConversion::DisplayToProgrammaticName( const OUString& 
rDispName, SfxStyleFamily nType )
diff --git a/sc/source/ui/dataprovider/dataprovider.cxx 
b/sc/source/ui/dataprovider/dataprovider.cxx
index ff0ee8626fef..72f674a7b99d 100644
--- a/sc/source/ui/dataprovider/dataprovider.cxx
+++ b/sc/source/ui/dataprovider/dataprovider.cxx
@@ -11,6 +11,7 @@
 #include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
 #include <com/sun/star/ucb/SimpleFileAccess.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
+#include <o3tl/string_view.hxx>
 #include <rtl/strbuf.hxx>
 #include <sal/log.hxx>
 #include <unotools/charclass.hxx>
@@ -266,9 +267,9 @@ ScDBData* ScDBDataManager::getDBData()
     return pDBData;
 }
 
-bool DataProviderFactory::isInternalDataProvider(const OUString& rProvider)
+bool DataProviderFactory::isInternalDataProvider(std::u16string_view rProvider)
 {
-    return rProvider.startsWith("org.libreoffice.calc");
+    return o3tl::starts_with(rProvider, u"org.libreoffice.calc");
 }
 
 std::shared_ptr<DataProvider> DataProviderFactory::getDataProvider(ScDocument* 
pDoc,
diff --git a/sc/source/ui/inc/dataprovider.hxx 
b/sc/source/ui/inc/dataprovider.hxx
index 87022fc34a7e..9f7b2b2e3a50 100644
--- a/sc/source/ui/inc/dataprovider.hxx
+++ b/sc/source/ui/inc/dataprovider.hxx
@@ -10,6 +10,7 @@
 #pragma once
 
 #include <memory>
+#include <string_view>
 #include <salhelper/thread.hxx>
 #include <rtl/ustring.hxx>
 #include <rtl/ref.hxx>
@@ -134,7 +135,7 @@ class DataProviderFactory
 {
 private:
 
-    static bool isInternalDataProvider(const OUString& rProvider);
+    static bool isInternalDataProvider(std::u16string_view rProvider);
 
 public:
 
diff --git a/sc/source/ui/vba/vbaworkbooks.cxx 
b/sc/source/ui/vba/vbaworkbooks.cxx
index 0b8316824033..facfc89fe23c 100644
--- a/sc/source/ui/vba/vbaworkbooks.cxx
+++ b/sc/source/ui/vba/vbaworkbooks.cxx
@@ -30,6 +30,7 @@
 #include "vbaworkbooks.hxx"
 #include <vbahelper/vbahelper.hxx>
 
+#include <o3tl/string_view.hxx>
 #include <osl/file.hxx>
 #include <rtl/ref.hxx>
 
@@ -164,13 +165,13 @@ ScVbaWorkbooks::isTextFile( std::u16string_view sType )
 }
 
 bool
-ScVbaWorkbooks::isSpreadSheetFile( const OUString& sType )
+ScVbaWorkbooks::isSpreadSheetFile( std::u16string_view sType )
 {
     // include calc_QPro etc. ? ( not for the moment anyway )
-    return sType.startsWith( "calc_MS" )
-      || sType.startsWith( "MS Excel" )
-      || sType.startsWith( "calc8" )
-      || sType.startsWith( "calc_StarOffice" );
+    return o3tl::starts_with( sType, u"calc_MS" )
+      || o3tl::starts_with( sType, u"MS Excel" )
+      || o3tl::starts_with( sType, u"calc8" )
+      || o3tl::starts_with( sType, u"calc_StarOffice" );
 }
 
 OUString
diff --git a/sc/source/ui/vba/vbaworkbooks.hxx 
b/sc/source/ui/vba/vbaworkbooks.hxx
index e93ca6337a9e..45d41757a4fc 100644
--- a/sc/source/ui/vba/vbaworkbooks.hxx
+++ b/sc/source/ui/vba/vbaworkbooks.hxx
@@ -18,6 +18,10 @@
  */
 #pragma once
 
+#include <sal/config.h>
+
+#include <string_view>
+
 #include <cppuhelper/implbase.hxx>
 #include <ooo/vba/excel/XWorkbooks.hpp>
 #include <vbahelper/vbadocumentsbase.hxx>
@@ -29,7 +33,7 @@ class ScVbaWorkbooks : public ScVbaWorkbooks_BASE
 private:
     OUString   getFileFilterType( const OUString& rString );
     static bool       isTextFile( std::u16string_view rString );
-    static bool       isSpreadSheetFile( const OUString& rString );
+    static bool       isSpreadSheetFile( std::u16string_view rString );
     static sal_Int16& getCurrentDelim(){ static sal_Int16 nDelim = 44; return 
nDelim; }
 public:
     ScVbaWorkbooks( const css::uno::Reference< ov::XHelperInterface >& 
xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext );

Reply via email to