summaryrefslogtreecommitdiffstats
path: root/fpicker/source/aqua/FilterHelper.mm
diff options
context:
space:
mode:
Diffstat (limited to 'fpicker/source/aqua/FilterHelper.mm')
-rw-r--r--fpicker/source/aqua/FilterHelper.mm47
1 files changed, 24 insertions, 23 deletions
diff --git a/fpicker/source/aqua/FilterHelper.mm b/fpicker/source/aqua/FilterHelper.mm
index fc6bca998755..98c27b720728 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 );
}
}
@@ -45,14 +48,14 @@ void fillSuffixList(OUStringList& aSuffixList, const OUString& suffixString) {
#pragma mark FilterEntry
-FilterEntry::FilterEntry( const OUString& _rTitle, const UnoFilterList& _rSubFilters )
+AquaFilterEntry::AquaFilterEntry( const OUString& _rTitle, const UnoFilterList& _rSubFilters )
:m_sTitle( _rTitle )
,m_aSubFilters( _rSubFilters )
{
}
-bool FilterEntry::hasSubFilters() const
+bool AquaFilterEntry::hasSubFilters() const
{
bool bReturn = ( 0 < m_aSubFilters.getLength() );
@@ -60,7 +63,7 @@ bool FilterEntry::hasSubFilters() const
}
-sal_Int32 FilterEntry::getSubFilters( UnoFilterList& _rSubFilterList )
+sal_Int32 AquaFilterEntry::getSubFilters( UnoFilterList& _rSubFilterList )
{
_rSubFilterList = m_aSubFilters;
sal_Int32 nReturn = m_aSubFilters.getLength();
@@ -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"" );
}
}
@@ -134,7 +135,7 @@ public:
FilterTitleMatch( const OUString& _rTitle ) : rTitle( _rTitle ) { }
- bool operator () ( const FilterEntry& _rEntry )
+ bool operator () ( const AquaFilterEntry& _rEntry )
{
bool bMatch;
if( !_rEntry.hasSubFilters() ) {
@@ -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;
@@ -273,7 +274,7 @@ void FilterHelper::appendFilter(const OUString& aTitle, const OUString& aFilterS
// append the filter
OUStringList suffixList;
fillSuffixList(suffixList, aFilterString);
- m_pFilterList->push_back(FilterEntry( aTitle, suffixList ) );
+ m_pFilterList->push_back(AquaFilterEntry( aTitle, suffixList ) );
}
void FilterHelper::setCurrentFilter( const OUString& aTitle )
@@ -304,7 +305,7 @@ void FilterHelper::appendFilterGroup( const css::uno::Sequence< css::beans::Stri
// append the filter
if (bPrependSeparator) {
OUStringList emptyList;
- m_pFilterList->push_back(FilterEntry("-", emptyList));
+ m_pFilterList->push_back(AquaFilterEntry("-", emptyList));
}
const css::beans::StringPair* pSubFilters = aFilters.getConstArray();
@@ -390,7 +391,7 @@ void FilterHelper::SetFilterAtIndex(unsigned index)
if (m_pFilterList->size() <= index) {
index = 0;
}
- FilterEntry entry = m_pFilterList->at(index);
+ AquaFilterEntry entry = m_pFilterList->at(index);
SetCurFilter(entry.getTitle());
}