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>
This commit is contained in:
committed by
Samuel Mehrbrodt
parent
151eae3143
commit
ff7e327e9e
Regular → Executable
+7
-1
@@ -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 )
|
||||
|
||||
Regular → Executable
+4
-1
@@ -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
|
||||
|
||||
Regular → Executable
+2
@@ -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);
|
||||
|
||||
Regular → Executable
+13
-25
@@ -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;
|
||||
|
||||
Regular → Executable
+22
@@ -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&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user