[Libreoffice-commits] core.git: basctl/source

Andreas Heinisch (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 5 09:42:37 UTC 2019


 basctl/source/basicide/basobj2.cxx        |    8 +++++-
 basctl/source/basicide/moduldl2.cxx       |    5 +++
 basctl/source/basicide/moduldlg.cxx       |    2 +
 basctl/source/basicide/scriptdocument.cxx |   38 ++++++++++--------------------
 basctl/source/inc/bastype2.hxx            |   22 +++++++++++++++++
 5 files changed, 48 insertions(+), 27 deletions(-)

New commits:
commit ff7e327e9e537ea129464a1de5a01bf32c1b9fd3
Author:     Andreas Heinisch <andreas.heinisch at yahoo.de>
AuthorDate: Tue Jun 25 14:28:07 2019 +0200
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Fri Jul 5 11:41:44 2019 +0200

    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 at cib.de>

diff --git a/basctl/source/basicide/basobj2.cxx b/basctl/source/basicide/basobj2.cxx
old mode 100644
new mode 100755
index 1f627d0fd7ec..29c1ff6d5598
--- 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
old mode 100644
new mode 100755
index 12b47788cfbd..37254f2c63ee
--- 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
old mode 100644
new mode 100755
index 3516fc08f634..531fd7a00e0e
--- 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
old mode 100644
new mode 100755
index 5e2c32eed5ca..3146da2be9d1
--- 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
old mode 100644
new mode 100755
index 6abe67c23ae5..90fdb6915303
--- 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&);
 


More information about the Libreoffice-commits mailing list