summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-04-25 17:02:42 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-04-25 23:24:04 +0200
commit8e77be57024fa9422db2dddce7c0c7ef4302a3c2 (patch)
tree1e6e8e5baf88e95119db31b47501a8c681672f47 /fpicker
parentf12448ce5f6fdccdaccfeed76b1ec22cccdcddec (diff)
loplugin:stringviewparam
...and loplugin:stringview(param) follow-ups Change-Id: I5ccb5c7b246a35aefb43c8f608d781b753f9830c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133392 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/aqua/FilterHelper.hxx3
-rw-r--r--fpicker/source/aqua/FilterHelper.mm33
2 files changed, 19 insertions, 17 deletions
diff --git a/fpicker/source/aqua/FilterHelper.hxx b/fpicker/source/aqua/FilterHelper.hxx
index 6cf4aec5996e..21cb9c4b4464 100644
--- a/fpicker/source/aqua/FilterHelper.hxx
+++ b/fpicker/source/aqua/FilterHelper.hxx
@@ -27,6 +27,7 @@
#include <com/sun/star/uno/RuntimeException.hpp>
#include <list>
+#include <string_view>
#include <vector>
#include <premac.h>
@@ -82,7 +83,7 @@ public:
//XFilterManager delegates
/// @throws css::lang::IllegalArgumentException
/// @throws css::uno::RuntimeException
- void appendFilter( const OUString& aTitle, const OUString& aFilter );
+ void appendFilter( const OUString& aTitle, std::u16string_view aFilter );
/// @throws css::lang::IllegalArgumentException
/// @throws css::uno::RuntimeException
diff --git a/fpicker/source/aqua/FilterHelper.mm b/fpicker/source/aqua/FilterHelper.mm
index fc6bca998755..f11d8447d91a 100644
--- a/fpicker/source/aqua/FilterHelper.mm
+++ b/fpicker/source/aqua/FilterHelper.mm
@@ -21,6 +21,9 @@
#include <sal/log.hxx>
#include <algorithm>
+#include <cstddef>
+#include <string_view>
+#include <o3tl/string_view.hxx>
#include <osl/mutex.hxx>
#include <vcl/svapp.hxx>
@@ -31,12 +34,12 @@
namespace {
-void fillSuffixList(OUStringList& aSuffixList, const OUString& suffixString) {
- sal_Int32 nIndex = 0;
+void fillSuffixList(OUStringList& aSuffixList, std::u16string_view suffixString) {
+ std::size_t nIndex = 0;
do {
- OUString aToken = suffixString.getToken( 0, ';', nIndex );
- aSuffixList.push_back(aToken.copy(1));
- } while ( nIndex >= 0 );
+ std::u16string_view aToken = o3tl::getToken( suffixString, u';', nIndex );
+ aSuffixList.push_back(OUString(aToken.substr(1)));
+ } while ( nIndex != std::u16string_view::npos );
}
}
@@ -70,24 +73,22 @@ sal_Int32 FilterEntry::getSubFilters( UnoFilterList& _rSubFilterList )
#pragma mark statics
static bool
-isFilterString( const OUString& rFilterString, const char *pMatch )
+isFilterString( std::u16string_view rFilterString, std::u16string_view pMatch )
{
- sal_Int32 nIndex = 0;
- OUString aToken;
+ std::size_t nIndex = 0;
+ std::u16string_view aToken;
bool bIsFilter = true;
- OUString aMatch(OUString::createFromAscii(pMatch));
-
do
{
- aToken = rFilterString.getToken( 0, ';', nIndex );
- if( !aToken.match( aMatch ) )
+ aToken = o3tl::getToken( rFilterString, u';', nIndex );
+ if( !o3tl::starts_with( aToken, pMatch ) )
{
bIsFilter = false;
break;
}
}
- while( nIndex >= 0 );
+ while( nIndex != std::u16string_view::npos );
return bIsFilter;
}
@@ -109,11 +110,11 @@ shrinkFilterName( const OUString& aFilterName, bool bAllowNoStar = false )
sal_Int32 nBracketLen = nBracketEnd - i;
if( nBracketEnd <= 0 )
continue;
- if( isFilterString( aFilterName.copy( i + 1, nBracketLen - 1 ), "*." ) )
+ if( isFilterString( aFilterName.subView( i + 1, nBracketLen - 1 ), u"*." ) )
aRealName = aRealName.replaceAt( i, nBracketLen + 1, u"" );
else if (bAllowNoStar)
{
- if( isFilterString( aFilterName.copy( i + 1, nBracketLen - 1 ), ".") )
+ if( isFilterString( aFilterName.subView( i + 1, nBracketLen - 1 ), u".") )
aRealName = aRealName.replaceAt( i, nBracketLen + 1, u"" );
}
}
@@ -259,7 +260,7 @@ void FilterHelper::SetFilters()
}
}
-void FilterHelper::appendFilter(const OUString& aTitle, const OUString& aFilterString)
+void FilterHelper::appendFilter(const OUString& aTitle, std::u16string_view aFilterString)
{
SolarMutexGuard aGuard;