diff options
-rw-r--r-- | cui/source/customize/cfgutil.cxx | 33 | ||||
-rw-r--r-- | cui/source/inc/cfgutil.hxx | 2 |
2 files changed, 24 insertions, 11 deletions
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx index aa77952563a8..3039486a2f30 100644 --- a/cui/source/customize/cfgutil.cxx +++ b/cui/source/customize/cfgutil.cxx @@ -469,21 +469,16 @@ void CuiConfigGroupListBox::ClearAll() m_xTreeView->clear(); } -void CuiConfigGroupListBox::InitModule() +sal_Int32 CuiConfigGroupListBox::InitModule() { try { + // return the number of added groups css::uno::Reference< css::frame::XDispatchInformationProvider > xProvider(m_xFrame, css::uno::UNO_QUERY_THROW); css::uno::Sequence< sal_Int16 > lGroups = xProvider->getSupportedCommandGroups(); sal_Int32 c1 = lGroups.getLength(); sal_Int32 i1 = 0; - - if ( c1 ) - { - // Add All Commands category - aArr.push_back(std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_ALLFUNCTIONS, 0)); - m_xTreeView->append(weld::toId(aArr.back().get()), CuiResId(RID_CUISTR_ALLFUNCTIONS)); - } + sal_Int32 nAddedGroups = 0; for (i1=0; i1<c1; ++i1) { @@ -502,12 +497,15 @@ void CuiConfigGroupListBox::InitModule() aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_FUNCTION, nGroupID ) ); m_xTreeView->append(weld::toId(aArr.back().get()), sGroupName); + nAddedGroups++; } + return nAddedGroups; } catch(const css::uno::RuntimeException&) { throw; } catch(const css::uno::Exception&) {} + return 0; } void CuiConfigGroupListBox::FillScriptList(const css::uno::Reference< css::script::browse::XBrowseNode >& xRootNode, @@ -634,6 +632,7 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent m_xContext = xContext; m_xFrame = xFrame; + sal_Int32 nAddedGroups = 0; if( bEventMode ) { m_sModuleLongName = sModuleLongName; @@ -641,7 +640,7 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent m_xModuleCategoryInfo.set(m_xGlobalCategoryInfo->getByName(m_sModuleLongName), css::uno::UNO_QUERY_THROW); m_xUICmdDescription = css::frame::theUICommandDescription::get( m_xContext ); - InitModule(); + nAddedGroups = InitModule(); } SAL_INFO("cui.customize", "** ** About to initialise SF Scripts"); @@ -658,7 +657,21 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent // TODO exception handling } + m_xTreeView->thaw(); + m_xTreeView->make_sorted(); + m_xTreeView->make_unsorted(); + m_xTreeView->freeze(); + + // add All Commands to the top + if ( bEventMode && nAddedGroups ) + { + aArr.insert(aArr.begin(), std::make_unique<SfxGroupInfo_Impl>(SfxCfgKind::GROUP_ALLFUNCTIONS, 0)); + OUString sId(weld::toId(aArr.front().get())); + OUString s(CuiResId(RID_CUISTR_ALLFUNCTIONS)); + m_xTreeView->insert(nullptr, 0, &s, &sId, nullptr, nullptr, false, nullptr); + } + // add application macros to the end if ( rootNode.is() ) { if ( bEventMode ) @@ -681,7 +694,7 @@ void CuiConfigGroupListBox::Init(const css::uno::Reference< css::uno::XComponent } } - // add styles and sidebar decks + // add styles and sidebar decks to the end if ( bEventMode ) { aArr.push_back( std::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::GROUP_STYLES, 0, nullptr ) ); // TODO last parameter should contain user data diff --git a/cui/source/inc/cfgutil.hxx b/cui/source/inc/cfgutil.hxx index 44f532baa6ba..b1f22e4065b9 100644 --- a/cui/source/inc/cfgutil.hxx +++ b/cui/source/inc/cfgutil.hxx @@ -204,7 +204,7 @@ class CuiConfigGroupListBox css::uno::Reference< css::uno::XComponentContext > const & xCtx, std::u16string_view docName); - void InitModule(); + sal_Int32 InitModule(); void FillScriptList(const css::uno::Reference< css::script::browse::XBrowseNode >& xRootNode, const weld::TreeIter* pParentEntry); void FillFunctionsList(const css::uno::Sequence< css::frame::DispatchInformation >& xCommands); |