[Libreoffice-commits] core.git: Branch 'feature/gsoc17-revamp-customize-dialog' - cui/source cui/uiconfig extras/source
Muhammet Kara
muhammet.kara at pardus.org.tr
Mon Aug 14 12:02:22 UTC 2017
cui/source/customize/CommandCategoryListBox.cxx | 136 +++++++++++++++++++++++-
cui/source/customize/SvxMenuConfigPage.cxx | 17 +--
cui/source/customize/SvxToolbarConfigPage.cxx | 7 -
cui/source/customize/cfg.cxx | 7 -
cui/source/inc/CommandCategoryListBox.hxx | 23 +++-
cui/source/inc/SvxMenuConfigPage.hxx | 2
cui/source/inc/cfg.hxx | 18 +--
cui/uiconfig/ui/menuassignpage.ui | 31 -----
extras/source/glade/libreoffice-catalog.xml.in | 3
9 files changed, 178 insertions(+), 66 deletions(-)
New commits:
commit 80bcb11c5b6cdc2d520bb0909eaadcac713a87de
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date: Thu Aug 10 10:37:58 2017 +0300
Initialize and update Function list box properly
* Add dispose methods to CommandCategortListBox
* Cast the commands list to SfxConfigFunctionListBox
* Update the glade catalog to include CommandCategoryListBox widget
* Borrow and adapt FillFunctionsList method from SfxConfigGroupListBox
* Create and setup proper SelectHDL(s)
Now the command list box (Function box on the left) is properly
populated and updated upon selection of a category from the categories
list box.
Implemented for the Menu and Context Menu tabs.
Change-Id: I30ebe89e80bdb2c5b686a26acb7c1ab1178b7525
Reviewed-on: https://gerrit.libreoffice.org/40968
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
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 85bf089d9287..ec7c9e8dfad7 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 eaa855af1f03..e6d52476c330 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 1e34c8e98bfa..018921953be9 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1130,11 +1130,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");
@@ -1142,7 +1143,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());
@@ -1172,7 +1172,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 6027f971a56b..f8058b362c61 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 1ea0c987f45f..816ae1dab7de 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -851,5 +851,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>
More information about the Libreoffice-commits
mailing list