Implement "Add" button in the Customize dialog
Now new commands can be added to Toolbars, Menus, and Context Menus
by using the Add (right arrow) button which is between the commands list
and the menu/toolbar entries list.
Change-Id: I9c094a5142f82922c5e5bc3075a35442875a5fec
Reviewed-on: https://gerrit.libreoffice.org/41240
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index e0a0a98..8c85eb4 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -124,6 +124,9 @@ SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSe
m_pMoveUpButton->SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) );
m_pMoveDownButton->SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) );
m_pAddCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, AddCommandHdl ) );
//m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, RemoveCommandHdl ) );
}
SvxMenuConfigPage::~SvxMenuConfigPage()
@@ -289,6 +292,16 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, SelectCategory, ListBox&, void )
m_pCommandCategoryListBox->categorySelected( m_pFunctions );
}
IMPL_LINK_NOARG( SvxMenuConfigPage, AddCommandHdl, Button *, void )
{
AddFunction();
}
/*IMPL_LINK_NOARG( SvxMenuConfigPage, RemoveCommandHdl, Button *, void )
{
//TODO:Implement
}*/
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 55240bf..f5f6d7b 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -135,6 +135,9 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
m_pMoveDownButton->Enable();
m_pMoveUpButton->Enable();
m_pAddCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, AddCommandHdl ) );
//m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, RemoveCommandHdl ) );
// default toolbar to select is standardbar unless a different one
// has been passed in
m_aURLToSelect = ITEM_TOOLBAR_URL;
@@ -321,6 +324,16 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectCategory, ListBox&, void )
m_pCommandCategoryListBox->categorySelected( m_pFunctions );
}
IMPL_LINK_NOARG( SvxToolbarConfigPage, AddCommandHdl, Button *, void )
{
AddFunction();
}
/*IMPL_LINK_NOARG( SvxToolbarConfigPage, RemoveCommandHdl, Button *, void )
{
//TODO:Implement
}*/
void SvxToolbarConfigPage::UpdateButtonStates()
{
@@ -391,14 +404,10 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbar, ListBox&, void )
UpdateButtonStates();
}
IMPL_LINK_NOARG( SvxToolbarConfigPage, AddFunctionHdl, SvxScriptSelectorDialog&, void )
{
AddFunction();
}
void SvxToolbarConfigPage::AddFunction(
SvTreeListEntry* pTarget, bool bFront )
{
// Add the command to the contents listbox of the selected toolbar
SvTreeListEntry* pNewLBEntry =
SvxConfigPage::AddFunction( pTarget, bFront, true/*bAllowDuplicates*/ );
@@ -416,6 +425,9 @@ void SvxToolbarConfigPage::AddFunction(
pNewLBEntry, SvButtonState::Tristate );
}
// Changes are not visible on the toolbar until this point
// TODO: Figure out a way to show the changes on the toolbar, but revert if
// the dialog is closed by pressing "Cancel"
// get currently selected toolbar and apply change
SvxConfigEntry* pToolbar = GetTopLevelSelection();
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 7513fcf..9c339e3 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1136,6 +1136,9 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
get(m_pCommandCategoryListBox, "commandcategorylist");
get(m_pFunctions, "functions");
get(m_pAddCommandButton, "add");
get(m_pRemoveCommandButton, "remove");
get(m_pTopLevelListBox, "toplevellist");
get(m_pContents, "contents");
get(m_pMoveUpButton, "up");
@@ -1166,6 +1169,8 @@ void SvxConfigPage::dispose()
m_pContents.clear();
m_pEntries.clear();
m_pFunctions.clear();
m_pAddCommandButton.clear();
m_pRemoveCommandButton.clear();
m_pMoveUpButton.clear();
m_pMoveDownButton.clear();
m_pSaveInListBox.clear();
@@ -1442,6 +1447,30 @@ OUString SvxConfigPage::GetFrameWithDefaultAndIdentify( uno::Reference< frame::X
return sModuleID;
}
OUString SvxConfigPage::GetScriptURL() const
{
OUString result;
SvTreeListEntry *pEntry = m_pFunctions->FirstSelected();
if ( pEntry )
{
SfxGroupInfo_Impl *pData = static_cast<SfxGroupInfo_Impl*>(pEntry->GetUserData());
if ( ( pData->nKind == SfxCfgKind::FUNCTION_SLOT ) ||
( pData->nKind == SfxCfgKind::FUNCTION_SCRIPT ) ||
( pData->nKind == SfxCfgKind::GROUP_STYLES ) )
{
result = pData->sCommand;
}
}
return result;
}
OUString SvxConfigPage::GetSelectedDisplayName()
{
return m_pFunctions->GetEntryText( m_pFunctions->FirstSelected() );
}
bool SvxConfigPage::FillItemSet( SfxItemSet* )
{
bool result = false;
@@ -1555,7 +1584,7 @@ SvxEntries* SvxConfigPage::FindParentForChild(
SvTreeListEntry* SvxConfigPage::AddFunction(
SvTreeListEntry* pTarget, bool bFront, bool bAllowDuplicates )
{
OUString aURL = m_pSelectorDlg->GetScriptURL();
OUString aURL = GetScriptURL();
if ( aURL.isEmpty() )
{
@@ -1577,7 +1606,7 @@ SvTreeListEntry* SvxConfigPage::AddFunction(
pNewEntryData->SetUserDefined();
if ( aDisplayName.isEmpty() )
pNewEntryData->SetName( m_pSelectorDlg->GetSelectedDisplayName() );
pNewEntryData->SetName( GetSelectedDisplayName() );
// check that this function is not already in the menu
SvxConfigEntry* pParent = GetTopLevelSelection();
diff --git a/cui/source/inc/SvxMenuConfigPage.hxx b/cui/source/inc/SvxMenuConfigPage.hxx
index 73165ed..9110ede 100644
--- a/cui/source/inc/SvxMenuConfigPage.hxx
+++ b/cui/source/inc/SvxMenuConfigPage.hxx
@@ -56,6 +56,9 @@ private:
DECL_LINK( SelectCategory, ListBox&, void );
DECL_LINK( AddCommandHdl, Button *, void );
//DECL_LINK( RemoveCommandHdl, Button *, void );
void Init() override;
void UpdateButtonStates() override;
short QueryReset() override;
diff --git a/cui/source/inc/SvxToolbarConfigPage.hxx b/cui/source/inc/SvxToolbarConfigPage.hxx
index 21d63fb..e472155 100644
--- a/cui/source/inc/SvxToolbarConfigPage.hxx
+++ b/cui/source/inc/SvxToolbarConfigPage.hxx
@@ -53,11 +53,13 @@ private:
DECL_LINK( SelectToolbar, ListBox&, void );
DECL_LINK( SelectToolbarEntry, SvTreeListBox*, void );
DECL_LINK( AddFunctionHdl, SvxScriptSelectorDialog&, void );
DECL_LINK( MoveHdl, Button *, void );
DECL_LINK( SelectCategory, ListBox&, void );
DECL_LINK( AddCommandHdl, Button *, void );
//DECL_LINK( RemoveCommandHdl, Button *, void );
void UpdateButtonStates() override;
short QueryReset() override;
void Init() override;
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index 0035e86..f05d8fa 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -403,6 +403,10 @@ protected:
VclPtr<SvxScriptSelectorDialog> m_pSelectorDlg;
// Middle buttons
VclPtr<PushButton> m_pAddCommandButton;
VclPtr<PushButton> m_pRemoveCommandButton;
/// the ResourceURL to select when opening the dialog
OUString m_aURLToSelect;
@@ -479,6 +483,9 @@ public:
*/
static OUString
GetFrameWithDefaultAndIdentify( css::uno::Reference< css::frame::XFrame >& _inout_rxFrame );
OUString GetScriptURL() const;
OUString GetSelectedDisplayName();
};
class SvxMainMenuOrganizerDialog : public ModalDialog