diff options
-rw-r--r-- | include/sfx2/devtools/ObjectInspectorTreeHandler.hxx | 8 | ||||
-rw-r--r-- | sfx2/source/devtools/ObjectInspectorTreeHandler.cxx | 31 |
2 files changed, 38 insertions, 1 deletions
diff --git a/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx b/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx index 03188276a4b4..b6fa678de366 100644 --- a/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx +++ b/include/sfx2/devtools/ObjectInspectorTreeHandler.hxx @@ -12,6 +12,7 @@ #include <vcl/weld.hxx> #include <vcl/commandevent.hxx> +#include <comphelper/string.hxx> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/XInterface.hpp> @@ -40,6 +41,13 @@ private: // just the current context css::uno::Reference<css::uno::XComponentContext> mxContext; + // treeview sort and compare + comphelper::string::NaturalStringSorter mxSorter; + void setSortFunction(std::unique_ptr<weld::TreeView>& pTreeView); + sal_Int32 compare(std::unique_ptr<weld::TreeView>& pTreeView, const weld::TreeIter& rLeft, + const weld::TreeIter& rRight); + + // treeview manipulation static void clearObjectInspectorChildren(std::unique_ptr<weld::TreeView>& pTreeView, weld::TreeIter const& rParent); static void handleExpanding(std::unique_ptr<weld::TreeView>& pTreeView, diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx index 79b69d612b79..18c4206e0730 100644 --- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx +++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx @@ -44,6 +44,9 @@ #include <comphelper/processfactory.hxx> #include <comphelper/extract.hxx> +#include <vcl/settings.hxx> +#include <i18nlangtag/languagetag.hxx> + using namespace css; namespace @@ -928,6 +931,7 @@ ObjectInspectorTreeHandler::ObjectInspectorTreeHandler( std::unique_ptr<ObjectInspectorWidgets>& pObjectInspectorWidgets) : mpObjectInspectorWidgets(pObjectInspectorWidgets) , mxContext(comphelper::getProcessComponentContext()) + , mxSorter(mxContext, Application::GetSettings().GetLanguageTag().getLocale()) { mpObjectInspectorWidgets->mpInterfacesTreeView->connect_expanding( LINK(this, ObjectInspectorTreeHandler, ExpandingHandlerInterfaces)); @@ -955,6 +959,11 @@ ObjectInspectorTreeHandler::ObjectInspectorTreeHandler( mpObjectInspectorWidgets->mpPropertiesTreeView->make_sorted(); mpObjectInspectorWidgets->mpMethodsTreeView->make_sorted(); + setSortFunction(mpObjectInspectorWidgets->mpInterfacesTreeView); + setSortFunction(mpObjectInspectorWidgets->mpServicesTreeView); + setSortFunction(mpObjectInspectorWidgets->mpPropertiesTreeView); + setSortFunction(mpObjectInspectorWidgets->mpMethodsTreeView); + mpObjectInspectorWidgets->mpInterfacesTreeView->connect_column_clicked( LINK(this, ObjectInspectorTreeHandler, HeaderBarClick)); mpObjectInspectorWidgets->mpServicesTreeView->connect_column_clicked( @@ -987,7 +996,27 @@ ObjectInspectorTreeHandler::ObjectInspectorTreeHandler( static_cast<int>(nMethodsDigitWidth * 50) }; mpObjectInspectorWidgets->mpMethodsTreeView->set_column_fixed_widths(aMethodsWidths); - pObjectInspectorWidgets->mpPaned->set_position(160); + mpObjectInspectorWidgets->mpPaned->set_position(160); +} + +void ObjectInspectorTreeHandler::setSortFunction(std::unique_ptr<weld::TreeView>& pTreeView) +{ + pTreeView->set_sort_func( + [this, &pTreeView](const weld::TreeIter& rLeft, const weld::TreeIter& rRight) { + return compare(pTreeView, rLeft, rRight); + }); +} + +sal_Int32 ObjectInspectorTreeHandler::compare(std::unique_ptr<weld::TreeView>& pTreeView, + const weld::TreeIter& rLeft, + const weld::TreeIter& rRight) +{ + int nSortColumn = pTreeView->get_sort_column(); + + OUString sLeft = pTreeView->get_text(rLeft, nSortColumn); + OUString sRight = pTreeView->get_text(rRight, nSortColumn); + sal_Int32 nCompare = mxSorter.compare(sLeft, sRight); + return nCompare; } void ObjectInspectorTreeHandler::handleExpanding(std::unique_ptr<weld::TreeView>& pTreeView, |