summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2019-06-25 14:28:07 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2019-07-05 11:41:44 +0200
commitff7e327e9e537ea129464a1de5a01bf32c1b9fd3 (patch)
treea2dbac41a06a9c7184e9575f84ee3f4d50b69af9 /basctl
parent151eae314358f9ee0df017cb89fbc8c87c969cdb (diff)
tdf#93476 Sort Macro library list after creating/importing a macro
Added sorting to modules, dialogs and libraries using locale Change-Id: Ie9dcadc593beb13417f38b83958a8aeeb77698ee Reviewed-on: https://gerrit.libreoffice.org/74692 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'basctl')
-rwxr-xr-x[-rw-r--r--]basctl/source/basicide/basobj2.cxx8
-rwxr-xr-x[-rw-r--r--]basctl/source/basicide/moduldl2.cxx5
-rwxr-xr-x[-rw-r--r--]basctl/source/basicide/moduldlg.cxx2
-rwxr-xr-x[-rw-r--r--]basctl/source/basicide/scriptdocument.cxx38
-rwxr-xr-x[-rw-r--r--]basctl/source/inc/bastype2.hxx22
5 files changed, 48 insertions, 27 deletions
diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
index 1f627d0fd7ec..29c1ff6d5598 100644..100755
--- a/basctl/source/basicide/basobj2.cxx
+++ b/basctl/source/basicide/basobj2.cxx
@@ -27,10 +27,13 @@
#include <com/sun/star/document/XScriptInvocationContext.hpp>
#include <basic/sbmeth.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/string.hxx>
#include <framework/documentundoguard.hxx>
#include <sal/log.hxx>
#include <tools/diagnose_ex.h>
#include <unotools/moduleoptions.hxx>
+#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld.hxx>
@@ -90,7 +93,10 @@ bool IsValidSbxName( const OUString& rName )
static bool StringCompareLessThan( const OUString& rStr1, const OUString& rStr2 )
{
- return rStr1.compareToIgnoreAsciiCase( rStr2 ) < 0;
+ 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 )
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index 12b47788cfbd..37254f2c63ee 100644..100755
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -651,6 +651,8 @@ void LibPage::InsertLib()
const int nRow = rView.n_children() - 1;
rView.set_toggle(nRow, TRISTATE_TRUE, 0);
rView.set_text(nRow, aLibName, 1);
+ rView.make_sorted();
+ rView.set_cursor(rView.find_text(aLibName));
}
}
@@ -1328,7 +1330,8 @@ void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
if( pLibBox )
{
pLibBox->append_text(aLibName);
- pLibBox->set_cursor(pLibBox->n_children() - 1);
+ pLibBox->make_sorted();
+ pLibBox->set_cursor(pLibBox->find_text(aLibName));
}
// create a module
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index 3516fc08f634..531fd7a00e0e 100644..100755
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -818,6 +818,7 @@ void ObjectPage::NewDialog()
m_xBasicBox->AddEntry(aDlgName, RID_BMP_DIALOG, xSubRootEntry.get(), false,
std::make_unique<Entry>(OBJ_TYPE_DIALOG), xIter.get());
assert(xIter.get() && "Insert entry failed!");
+ m_xBasicBox->make_sorted();
}
m_xBasicBox->set_cursor(*xIter);
m_xBasicBox->select(*xIter);
@@ -976,6 +977,7 @@ SbModule* createModImpl(weld::Window* pWin, const ScriptDocument& rDocument,
{
rBasicBox.AddEntry(aModName, RID_BMP_MODULE, xSubRootEntry.get(), false,
std::make_unique<Entry>(OBJ_TYPE_MODULE), xEntry.get());
+ rBasicBox.make_sorted();
}
rBasicBox.set_cursor(*xEntry);
rBasicBox.select(*xEntry);
diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx
index 5e2c32eed5ca..3146da2be9d1 100644..100755
--- a/basctl/source/basicide/scriptdocument.cxx
+++ b/basctl/source/basicide/scriptdocument.cxx
@@ -46,7 +46,6 @@
#include <sfx2/bindings.hxx>
#include <sfx2/docfile.hxx>
-
#include <basic/basicmanagerrepository.hxx>
#include <xmlscript/xmldlg_imexp.hxx>
@@ -62,6 +61,10 @@
#include <comphelper/documentinfo.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/string.hxx>
+
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
#include <sal/log.hxx>
#include <osl/file.hxx>
@@ -115,7 +118,10 @@ namespace basctl
{
bool StringCompareLessThan( const OUString& lhs, const OUString& rhs )
{
- return lhs.compareToIgnoreAsciiCase( rhs ) < 0;
+ auto const sort = comphelper::string::NaturalStringSorter(
+ comphelper::getProcessComponentContext(),
+ Application::GetSettings().GetUILanguageTag().getLocale());
+ return sort.compare(lhs, rhs) < 0;
}
class FilterDocuments : public docs::IDocumentDescriptorFilter
@@ -1100,26 +1106,6 @@ namespace basctl
return aDocument;
}
-
- namespace
- {
- struct DocumentTitleLess
- {
- explicit DocumentTitleLess( const CollatorWrapper& _rCollator )
- :m_aCollator( _rCollator )
- {
- }
-
- bool operator()( const ScriptDocument& _lhs, const ScriptDocument& _rhs ) const
- {
- return m_aCollator.compareString( _lhs.getTitle(), _rhs.getTitle() ) < 0;
- }
- private:
- const CollatorWrapper m_aCollator;
- };
- }
-
-
ScriptDocuments ScriptDocument::getAllScriptDocuments( ScriptDocument::ScriptDocumentList _eListType )
{
ScriptDocuments aScriptDocs;
@@ -1152,9 +1138,11 @@ namespace basctl
// sort document list by doc title?
if ( _eListType == DocumentsSorted )
{
- CollatorWrapper aCollator( ::comphelper::getProcessComponentContext() );
- aCollator.loadDefaultCollator( SvtSysLocale().GetLanguageTag().getLocale(), 0 );
- std::sort( aScriptDocs.begin(), aScriptDocs.end(), DocumentTitleLess( aCollator ) );
+ std::sort( aScriptDocs.begin(), aScriptDocs.end(),
+ []( const ScriptDocument& lhs, const ScriptDocument& rhs )
+ {
+ return StringCompareLessThan( lhs.getTitle(), rhs.getTitle() );
+ });
}
return aScriptDocs;
diff --git a/basctl/source/inc/bastype2.hxx b/basctl/source/inc/bastype2.hxx
index 6abe67c23ae5..90fdb6915303 100644..100755
--- a/basctl/source/inc/bastype2.hxx
+++ b/basctl/source/inc/bastype2.hxx
@@ -333,6 +333,28 @@ public:
m_xControl->connect_editing_done(rLink);
}
+ void make_sorted() { m_xControl->make_sorted(); };
+ void make_unsorted() { m_xControl->make_unsorted(); }
+ bool get_sort_order() { return m_xControl->get_sort_order(); }
+ void set_sort_order(bool bAscending) { m_xControl->set_sort_order(bAscending); }
+
+ void set_sort_indicator(TriState eState, int nColumn = -1)
+ {
+ m_xControl->set_sort_indicator(eState, nColumn);
+ }
+ TriState get_sort_indicator(int nColumn = -1)
+ {
+ return m_xControl->get_sort_indicator(nColumn);
+ }
+
+ int get_sort_column() { return m_xControl->get_sort_column(); }
+ void set_sort_column(int nColumn) { m_xControl->set_sort_column(nColumn); }
+
+ void set_sort_func(const std::function<int(const weld::TreeIter&, const weld::TreeIter&)>& func)
+ {
+ m_xControl->set_sort_func(func);
+ }
+
void RemoveEntry(const weld::TreeIter& rIter);
void RemoveEntry(const ScriptDocument&);