diff options
-rw-r--r-- | cui/source/customize/CommandCategoryListBox.cxx | 136 | ||||
-rw-r--r-- | cui/source/customize/SvxMenuConfigPage.cxx | 17 | ||||
-rw-r--r-- | cui/source/customize/SvxToolbarConfigPage.cxx | 7 | ||||
-rw-r--r-- | cui/source/customize/cfg.cxx | 7 | ||||
-rw-r--r-- | cui/source/inc/CommandCategoryListBox.hxx | 23 | ||||
-rw-r--r-- | cui/source/inc/SvxMenuConfigPage.hxx | 2 | ||||
-rw-r--r-- | cui/source/inc/cfg.hxx | 18 | ||||
-rw-r--r-- | cui/uiconfig/ui/menuassignpage.ui | 31 | ||||
-rw-r--r-- | extras/source/glade/libreoffice-catalog.xml.in | 3 |
9 files changed, 178 insertions, 66 deletions
diff --git a/cui/source/customize/CommandCategoryListBox.cxx b/cui/source/customize/CommandCategoryListBox.cxx index fac557fcf210..c1abd3fe7d05 100644 --- a/cui/source/customize/CommandCategoryListBox.cxx +++ b/cui/source/customize/CommandCategoryListBox.cxx @@ -18,6 +18,7 @@ */ #include "CommandCategoryListBox.hxx" +#include <svtools/treelistentry.hxx> #include <com/sun/star/frame/XDispatchInformationProvider.hpp> #include <com/sun/star/frame/theUICommandDescription.hpp> @@ -26,6 +27,7 @@ #include "dialmgr.hxx" #include "strings.hrc" +#include <comphelper/sequenceashashmap.hxx> #include <o3tl/make_unique.hxx> CommandCategoryListBox::CommandCategoryListBox(vcl::Window* pParent, WinBits nStyle) @@ -36,6 +38,24 @@ CommandCategoryListBox::CommandCategoryListBox(vcl::Window* pParent, WinBits nSt VCL_BUILDER_FACTORY(CommandCategoryListBox); +CommandCategoryListBox::~CommandCategoryListBox() +{ + disposeOnce(); +} + +void CommandCategoryListBox::dispose() +{ + ClearAll(); + ListBox::dispose(); +} + +void CommandCategoryListBox::ClearAll() +{ + //TODO: Handle SfxCfgKind::GROUP_SCRIPTCONTAINER when it gets added to Init + m_aGroupInfo.clear(); + Clear(); +} + void CommandCategoryListBox::Init( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::frame::XFrame >& xFrame, @@ -50,6 +70,7 @@ void CommandCategoryListBox::Init( m_sModuleLongName = sModuleLongName; m_xGlobalCategoryInfo = css::ui::theUICategoryDescription::get( m_xContext ); m_xModuleCategoryInfo.set(m_xGlobalCategoryInfo->getByName(m_sModuleLongName), css::uno::UNO_QUERY_THROW); + m_xUICmdDescription = css::frame::theUICommandDescription::get( m_xContext ); /**** InitModule Start ****/ try @@ -103,11 +124,118 @@ void CommandCategoryListBox::Init( SelectEntryPos(0); } -void CommandCategoryListBox::ClearAll() +void CommandCategoryListBox::FillFunctionsList( + const css::uno::Sequence<css::frame::DispatchInformation>& xCommands, + const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox) { - //TODO: Handle SfxCfgKind::GROUP_SCRIPTCONTAINER when it gets added to Init - m_aGroupInfo.clear(); - Clear(); + for (const auto & rInfo : xCommands) + { + OUString sUIName = MapCommand2UIName(rInfo.Command); + + SvTreeListEntry* pFuncEntry = pFunctionListBox->InsertEntry(sUIName ); + + m_aGroupInfo.push_back( o3tl::make_unique<SfxGroupInfo_Impl>( SfxCfgKind::FUNCTION_SLOT, 0 ) ); + SfxGroupInfo_Impl* pGrpInfo = m_aGroupInfo.back().get(); + pGrpInfo->sCommand = rInfo.Command; + pGrpInfo->sLabel = sUIName; + pFuncEntry->SetUserData(pGrpInfo); + } +} + +OUString CommandCategoryListBox::MapCommand2UIName(const OUString& sCommand) +{ + OUString sUIName; + try + { + css::uno::Reference< css::container::XNameAccess > xModuleConf; + m_xUICmdDescription->getByName(m_sModuleLongName) >>= xModuleConf; + if (xModuleConf.is()) + { + ::comphelper::SequenceAsHashMap lProps(xModuleConf->getByName(sCommand)); + sUIName = lProps.getUnpackedValueOrDefault("Name", OUString()); + } + } + catch(const css::uno::RuntimeException&) + { throw; } + catch(css::uno::Exception&) + { sUIName.clear(); } + + // fallback for missing UINames !? + if (sUIName.isEmpty()) + { + sUIName = sCommand; + } + + return sUIName; +} + +void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox ) +{ + SfxGroupInfo_Impl *pInfo = static_cast<SfxGroupInfo_Impl*>(GetSelectEntryData()); + pFunctionListBox->SetUpdateMode(false); + pFunctionListBox->ClearAll(); + + switch ( pInfo->nKind ) + { + case SfxCfgKind::GROUP_ALLFUNCTIONS: + { + css::uno::Reference< css::frame::XDispatchInformationProvider > + xProvider( m_xFrame, css::uno::UNO_QUERY ); + sal_Int32 nEntryCount = GetEntryCount(); + + for (sal_Int32 nCurPos = 0; nCurPos < nEntryCount; ++nCurPos) + { + SfxGroupInfo_Impl *pCurrentInfo = + static_cast<SfxGroupInfo_Impl*>(GetEntryData(nCurPos)); + + if (pCurrentInfo->nKind == SfxCfgKind::GROUP_FUNCTION) + { + css::uno::Sequence< css::frame::DispatchInformation > lCommands; + try + { + lCommands = xProvider->getConfigurableDispatchInformation( + pCurrentInfo->nUniqueID ); + FillFunctionsList( lCommands, pFunctionListBox ); + } + catch( css::container::NoSuchElementException& ) + { + } + } + } + + + break; + } + case SfxCfgKind::GROUP_FUNCTION: + { + sal_uInt16 nGroup = pInfo->nUniqueID; + css::uno::Reference< css::frame::XDispatchInformationProvider > + xProvider (m_xFrame, css::uno::UNO_QUERY_THROW); + css::uno::Sequence< css::frame::DispatchInformation > lCommands = + xProvider->getConfigurableDispatchInformation(nGroup); + FillFunctionsList( lCommands, pFunctionListBox ); + break; + } + case SfxCfgKind::GROUP_SCRIPTCONTAINER: + { + //TODO:Implement + break; + } + case SfxCfgKind::GROUP_STYLES: + { + //TODO:Implement + break; + } + default: + // Do nothing, the list box will stay empty + SAL_INFO( "cui.customize", "Ignoring unexpected SfxCfgKind: " << static_cast<int>(pInfo->nKind) ); + break; + } + + if ( pFunctionListBox->GetEntryCount() ) + pFunctionListBox->Select( pFunctionListBox->GetEntry( nullptr, 0 ) ); + + pFunctionListBox->SetUpdateMode(true); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx index 54c9cfe4fe44..e0a0a9801682 100644 --- a/cui/source/customize/SvxMenuConfigPage.cxx +++ b/cui/source/customize/SvxMenuConfigPage.cxx @@ -113,19 +113,15 @@ SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSe m_pContentsListBox->set_vexpand(true); m_pContentsListBox->Show(); - m_pFunctionsListBox = VclPtr<SvxMenuEntriesListBox>::Create(m_pFunctions, this); - m_pFunctionsListBox->set_grid_left_attach(0); - m_pFunctionsListBox->set_grid_top_attach(0); - m_pFunctionsListBox->set_hexpand(true); - m_pFunctionsListBox->set_vexpand(true); - m_pFunctionsListBox->Show(); - m_pTopLevelListBox->SetSelectHdl( LINK( this, SvxMenuConfigPage, SelectMenu ) ); m_pContentsListBox->SetSelectHdl( LINK( this, SvxMenuConfigPage, SelectMenuEntry ) ); + m_pCommandCategoryListBox->SetSelectHdl( + LINK( this, SvxMenuConfigPage, SelectCategory ) ); + m_pMoveUpButton->SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) ); m_pMoveDownButton->SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) ); } @@ -147,11 +143,11 @@ void SvxMenuConfigPage::Init() m_pTopLevelListBox->SelectEntryPos(0); m_pTopLevelListBox->GetSelectHdl().Call(*m_pTopLevelListBox); - m_pCommandCategoryListBox->Clear(); m_pCommandCategoryListBox->Init( comphelper::getProcessComponentContext(), m_xFrame, vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame)); + m_pCommandCategoryListBox->categorySelected( m_pFunctions ); } void SvxMenuConfigPage::dispose() @@ -288,6 +284,11 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenu, ListBox&, void ) UpdateButtonStates(); } +IMPL_LINK_NOARG( SvxMenuConfigPage, SelectCategory, ListBox&, void ) +{ + m_pCommandCategoryListBox->categorySelected( m_pFunctions ); +} + SaveInData* SvxMenuConfigPage::CreateSaveInData( const css::uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr, const css::uno::Reference< css::ui::XUIConfigurationManager >& xParentCfgMgr, diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx index 9f8968120d6a..ef6f2969f9c7 100644 --- a/cui/source/customize/SvxToolbarConfigPage.cxx +++ b/cui/source/customize/SvxToolbarConfigPage.cxx @@ -114,13 +114,6 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe m_pContentsListBox->set_vexpand(true); m_pContentsListBox->Show(); - m_pFunctionsListBox = VclPtr<SvxToolbarEntriesListBox>::Create(m_pFunctions, this); - m_pFunctionsListBox->set_grid_left_attach(0); - m_pFunctionsListBox->set_grid_top_attach(0); - m_pFunctionsListBox->set_hexpand(true); - m_pFunctionsListBox->set_vexpand(true); - m_pFunctionsListBox->Show(); - m_pTopLevelListBox->SetHelpId ( HID_SVX_TOPLEVELLISTBOX ); m_pContentsListBox->SetHelpId( HID_SVX_CONFIG_TOOLBAR_CONTENTS ); m_pSaveInListBox->SetHelpId( HID_SVX_SAVE_IN ); diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx index ca28982f102d..7513fcf2d42c 100644 --- a/cui/source/customize/cfg.cxx +++ b/cui/source/customize/cfg.cxx @@ -1131,11 +1131,12 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet) , bInitialised(false) , pCurrentSaveInData(nullptr) , m_pContentsListBox(nullptr) - , m_pFunctionsListBox(nullptr) , m_pSelectorDlg(nullptr) { - get(m_pTopLevelListBox, "toplevellist"); get(m_pCommandCategoryListBox, "commandcategorylist"); + get(m_pFunctions, "functions"); + + get(m_pTopLevelListBox, "toplevellist"); get(m_pContents, "contents"); get(m_pMoveUpButton, "up"); get(m_pMoveDownButton, "down"); @@ -1143,7 +1144,6 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet) get(m_pDescriptionField, "desc"); m_pDescriptionField->set_height_request(m_pDescriptionField->GetTextHeight()*4); get(m_pEntries, "entries"); - get(m_pFunctions, "functions"); Size aSize(LogicToPixel(Size(108, 115), MapUnit::MapAppFont)); m_pEntries->set_height_request(aSize.Height()); m_pEntries->set_width_request(aSize.Width()); @@ -1173,7 +1173,6 @@ void SvxConfigPage::dispose() m_pSelectorDlg.disposeAndClear(); m_pContentsListBox.disposeAndClear(); - m_pFunctionsListBox.disposeAndClear(); SfxTabPage::dispose(); } diff --git a/cui/source/inc/CommandCategoryListBox.hxx b/cui/source/inc/CommandCategoryListBox.hxx index 19138b6ceb77..5afc4ce798d8 100644 --- a/cui/source/inc/CommandCategoryListBox.hxx +++ b/cui/source/inc/CommandCategoryListBox.hxx @@ -30,16 +30,29 @@ class CommandCategoryListBox : public ListBox css::uno::Reference< css::frame::XFrame > m_xFrame; css::uno::Reference< css::container::XNameAccess > m_xGlobalCategoryInfo; css::uno::Reference< css::container::XNameAccess > m_xModuleCategoryInfo; + css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription; public: CommandCategoryListBox( vcl::Window* pParent, WinBits nBits = WB_BORDER | WB_DROPDOWN ); + virtual ~CommandCategoryListBox() override; + virtual void dispose() override; + void ClearAll(); - void Init( - const css::uno::Reference< css::uno::XComponentContext >& xContext, - const css::uno::Reference< css::frame::XFrame >& xFrame, - const OUString& sModuleLongName); + void Init( + const css::uno::Reference< css::uno::XComponentContext >& xContext, + const css::uno::Reference< css::frame::XFrame >& xFrame, + const OUString& sModuleLongName); + void FillFunctionsList( + const css::uno::Sequence< css::frame::DispatchInformation >& xCommands, + const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox); + OUString MapCommand2UIName(const OUString& sCommand); - void ClearAll(); + /** + Signals that a command category has been selected. + And updates the functions list box to include + the commands in the selected category. + */ + void categorySelected( const VclPtr<SfxConfigFunctionListBox>& pFunctionListBox ); }; #endif // INCLUDED_CUI_SOURCE_INC_COMMANDCATEGORYLISTBOX_HXX diff --git a/cui/source/inc/SvxMenuConfigPage.hxx b/cui/source/inc/SvxMenuConfigPage.hxx index 72796b8b2235..73165ed140f7 100644 --- a/cui/source/inc/SvxMenuConfigPage.hxx +++ b/cui/source/inc/SvxMenuConfigPage.hxx @@ -54,6 +54,8 @@ private: DECL_LINK( SelectMenu, ListBox&, void ); DECL_LINK( SelectMenuEntry, SvTreeListBox *, void ); + DECL_LINK( SelectCategory, ListBox&, void ); + void Init() override; void UpdateButtonStates() override; short QueryReset() override; diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx index 843057131fc6..0035e86aa047 100644 --- a/cui/source/inc/cfg.hxx +++ b/cui/source/inc/cfg.hxx @@ -382,29 +382,25 @@ private: protected: - // the top section of the tab page where top level menus and toolbars - // are displayed in a listbox - VclPtr<ListBox> m_pTopLevelListBox; + // Left side of the dialog where command categories and the available + // commands in them are displayed as a searchable list VclPtr<CommandCategoryListBox> m_pCommandCategoryListBox; + VclPtr<SfxConfigFunctionListBox> m_pFunctions; + + VclPtr<VclMultiLineEdit> m_pDescriptionField; - // the contents section where the contents of the selected + // Right side of the dialog where the contents of the selected // menu or toolbar are displayed + VclPtr<ListBox> m_pTopLevelListBox; VclPtr<VclFrame> m_pContents; VclPtr<VclContainer> m_pEntries; VclPtr<SvTreeListBox> m_pContentsListBox; - // the functions section where functions in the - // selected category will be displayed - VclPtr<VclContainer> m_pFunctions; - VclPtr<SvTreeListBox> m_pFunctionsListBox; - VclPtr<PushButton> m_pMoveUpButton; VclPtr<PushButton> m_pMoveDownButton; VclPtr<ListBox> m_pSaveInListBox; - VclPtr<VclMultiLineEdit> m_pDescriptionField; - VclPtr<SvxScriptSelectorDialog> m_pSelectorDlg; /// the ResourceURL to select when opening the dialog diff --git a/cui/uiconfig/ui/menuassignpage.ui b/cui/uiconfig/ui/menuassignpage.ui index f9cac5ae58dc..3eb6837c6992 100644 --- a/cui/uiconfig/ui/menuassignpage.ui +++ b/cui/uiconfig/ui/menuassignpage.ui @@ -2,6 +2,7 @@ <!-- Generated with glade 3.20.0 --> <interface domain="cui"> <requires lib="gtk+" version="3.10"/> + <requires lib="LibreOffice" version="1.0"/> <object class="GtkImage" id="image1"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -435,37 +436,13 @@ </packing> </child> <child> - <object class="GtkGrid" id="functions"> + <object class="cuilo-SfxConfigFunctionListBox" id="functions:border"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> </child> </object> <packing> diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index 83d1bc211779..73ef75c861af 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -854,5 +854,8 @@ <glade-widget-class title="Category ListBox" name="sdlo-CategoryListBox" generic-name="Category ListBox" parent="GtkTreeView" icon-name="widget-gtk-treeview"/> + <glade-widget-class title="Command Category ListBox" name="cuilo-CommandCategoryListBox" + generic-name="Command Category ListBox" parent="GtkComboBox" + icon-name="widget-gtk-combobox"/> </glade-widget-classes> </glade-catalog> |