diff options
author | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2019-08-02 15:04:22 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-08-03 20:23:06 +0200 |
commit | 087f778579900998e8a37e2e9581ea230870a26e (patch) | |
tree | ec74c8caa607f84fc993c736b2ed7c8dab0f1ca5 /basctl | |
parent | b6dd7f8af5c8da1f5e337be53381860166da575e (diff) |
tdf#93476 Sort Macro library list after creating/importing a macro
Moved sorting to inline functions, so the sorter is created only once
Change-Id: I5f06e8d94d2b93f8856cacfd42257f62b84d6e73
Reviewed-on: https://gerrit.libreoffice.org/76867
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basctl')
-rwxr-xr-x[-rw-r--r--] | basctl/source/basicide/basobj2.cxx | 24 | ||||
-rwxr-xr-x[-rw-r--r--] | basctl/source/basicide/scriptdocument.cxx | 29 |
2 files changed, 28 insertions, 25 deletions
diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx index 4131f7a6453d..801be80507b4 100644..100755 --- a/basctl/source/basicide/basobj2.cxx +++ b/basctl/source/basicide/basobj2.cxx @@ -91,17 +91,12 @@ bool IsValidSbxName( const OUString& rName ) return true; } -static bool StringCompareLessThan( const OUString& rStr1, const OUString& rStr2 ) +Sequence< OUString > GetMergedLibraryNames( const Reference< script::XLibraryContainer >& xModLibContainer, const Reference< script::XLibraryContainer >& xDlgLibContainer ) { + // create a sorted list of module library names auto const sort = comphelper::string::NaturalStringSorter( comphelper::getProcessComponentContext(), Application::GetSettings().GetUILanguageTag().getLocale()); - return sort.compare(rStr1, rStr2) < 0; -} - -Sequence< OUString > GetMergedLibraryNames( const Reference< script::XLibraryContainer >& xModLibContainer, const Reference< script::XLibraryContainer >& xDlgLibContainer ) -{ - // create a sorted list of module library names std::vector<OUString> aModLibList; if ( xModLibContainer.is() ) { @@ -110,7 +105,10 @@ Sequence< OUString > GetMergedLibraryNames( const Reference< script::XLibraryCon const OUString* pModLibNames = aModLibNames.getConstArray(); for ( sal_Int32 i = 0 ; i < nModLibCount ; i++ ) aModLibList.push_back( pModLibNames[ i ] ); - std::sort( aModLibList.begin() , aModLibList.end() , StringCompareLessThan ); + std::sort(aModLibList.begin(), aModLibList.end(), + [&sort](const OUString& rLHS, const OUString& rRHS) { + return sort.compare(rLHS, rRHS) < 0; + }); } // create a sorted list of dialog library names @@ -122,12 +120,18 @@ Sequence< OUString > GetMergedLibraryNames( const Reference< script::XLibraryCon const OUString* pDlgLibNames = aDlgLibNames.getConstArray(); for ( sal_Int32 i = 0 ; i < nDlgLibCount ; i++ ) aDlgLibList.push_back( pDlgLibNames[ i ] ); - std::sort( aDlgLibList.begin() , aDlgLibList.end() , StringCompareLessThan ); + std::sort(aDlgLibList.begin(), aDlgLibList.end(), + [&sort](const OUString& rLHS, const OUString& rRHS) { + return sort.compare(rLHS, rRHS) < 0; + }); } // merge both lists std::vector<OUString> aLibList( aModLibList.size() + aDlgLibList.size() ); - std::merge( aModLibList.begin(), aModLibList.end(), aDlgLibList.begin(), aDlgLibList.end(), aLibList.begin(), StringCompareLessThan ); + std::merge(aModLibList.begin(), aModLibList.end(), aDlgLibList.begin(), aDlgLibList.end(), + aLibList.begin(), [&sort](const OUString& rLHS, const OUString& rRHS) { + return sort.compare(rLHS, rRHS) < 0; + }); std::vector<OUString>::iterator aIterEnd = std::unique( aLibList.begin(), aLibList.end() ); // move unique elements to the front aLibList.erase( aIterEnd, aLibList.end() ); // remove duplicates diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx index 3146da2be9d1..2ecc4a2ab23e 100644..100755 --- a/basctl/source/basicide/scriptdocument.cxx +++ b/basctl/source/basicide/scriptdocument.cxx @@ -116,14 +116,6 @@ namespace basctl namespace { - bool StringCompareLessThan( const OUString& lhs, const OUString& rhs ) - { - auto const sort = comphelper::string::NaturalStringSorter( - comphelper::getProcessComponentContext(), - Application::GetSettings().GetUILanguageTag().getLocale()); - return sort.compare(lhs, rhs) < 0; - } - class FilterDocuments : public docs::IDocumentDescriptorFilter { public: @@ -1138,11 +1130,13 @@ namespace basctl // sort document list by doc title? if ( _eListType == DocumentsSorted ) { - std::sort( aScriptDocs.begin(), aScriptDocs.end(), - []( const ScriptDocument& lhs, const ScriptDocument& rhs ) - { - return StringCompareLessThan( lhs.getTitle(), rhs.getTitle() ); - }); + auto const sort = comphelper::string::NaturalStringSorter( + comphelper::getProcessComponentContext(), + Application::GetSettings().GetUILanguageTag().getLocale()); + std::sort(aScriptDocs.begin(), aScriptDocs.end(), + [&sort](const ScriptDocument& rLHS, const ScriptDocument& rRHS) { + return sort.compare(rLHS.getTitle(), rRHS.getTitle()) < 0; + }); } return aScriptDocs; @@ -1222,8 +1216,13 @@ namespace basctl } // sort - std::sort( aModuleNames.begin(), aModuleNames.end(), StringCompareLessThan ); - + auto const sort = comphelper::string::NaturalStringSorter( + comphelper::getProcessComponentContext(), + Application::GetSettings().GetUILanguageTag().getLocale()); + std::sort(aModuleNames.begin(), aModuleNames.end(), + [&sort](const OUString& rLHS, const OUString& rRHS) { + return sort.compare(rLHS, rRHS) < 0; + }); return aModuleNames; } |