[Libreoffice-commits] core.git: 12 commits - cui/inc cui/Library_cui.mk cui/source cui/uiconfig extras/source

Muhammet Kara muhammet.kara at pardus.org.tr
Mon Sep 4 20:43:14 UTC 2017


 cui/Library_cui.mk                              |    1 
 cui/inc/strings.hrc                             |    3 
 cui/source/customize/CommandCategoryListBox.cxx |  268 ++++++++
 cui/source/customize/SvxMenuConfigPage.cxx      |  329 ++++------
 cui/source/customize/SvxToolbarConfigPage.cxx   |  747 ++++++++--------------
 cui/source/customize/cfg.cxx                    |  168 +++--
 cui/source/inc/CommandCategoryListBox.hxx       |   66 ++
 cui/source/inc/SvxConfigPageHelper.hxx          |    5 
 cui/source/inc/SvxMenuConfigPage.hxx            |   20 
 cui/source/inc/SvxToolbarConfigPage.hxx         |   24 
 cui/source/inc/cfg.hxx                          |   55 -
 cui/uiconfig/ui/customizedialog.ui              |   14 
 cui/uiconfig/ui/menuassignpage.ui               |  789 ++++++++++--------------
 extras/source/glade/libreoffice-catalog.xml.in  |    3 
 14 files changed, 1287 insertions(+), 1205 deletions(-)

New commits:
commit 6c68f38bc28bb55a4f0d53b8f38957516d3935d1
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Mon Aug 28 15:19:57 2017 +0300

    Make the Modify button functional in the Customize dialog
    
    By adding "rename", "change icon", "reset icon", and "restore default command"
    options to the Modify button at the bottom of the right (toolbar/menu
    entries) list.
    
    Change icon / Reset icon / Restore default command options are not
    supported in the menu/context menu tabs yet.
    
    Change-Id: Iade3d1aca722c7f8eddcadf251b9562c5366d8ad
    Reviewed-on: https://gerrit.libreoffice.org/41620
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
    Tested-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 336e6bbe4ed9..016141184758 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -135,9 +135,18 @@ SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSe
 
     m_pInsertBtn->SetSelectHdl(
         LINK( this, SvxMenuConfigPage, InsertHdl ) );
+    m_pModifyBtn->SetSelectHdl(
+        LINK( this, SvxMenuConfigPage, ModifyItemHdl ) );
     m_pResetBtn->SetClickHdl(
         LINK( this, SvxMenuConfigPage, ResetMenuHdl ) );
 
+    PopupMenu* pPopup = m_pModifyBtn->GetPopupMenu();
+    // These operations are not possible on menus/context menus yet
+    pPopup->EnableItem( pPopup->GetItemId("changeIcon"), false );
+    pPopup->EnableItem( pPopup->GetItemId("resetIcon"), false );
+    pPopup->EnableItem( pPopup->GetItemId("restoreItem"), false );
+    pPopup->RemoveDisabledEntries();
+
     if ( !bIsMenuBar )
     {
         // Context menus cannot be added/removed
@@ -149,7 +158,6 @@ SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSe
         // TODO: Remove this when it is possible to reset menubar menus individually
         m_pResetBtn->Disable();
     }
-
 }
 
 SvxMenuConfigPage::~SvxMenuConfigPage()
@@ -197,19 +205,19 @@ void SvxMenuConfigPage::UpdateButtonStates()
     // Disable Up and Down buttons depending on current selection
     SvTreeListEntry* selection = m_pContentsListBox->GetCurEntry();
 
-    if ( m_pContentsListBox->GetEntryCount() == 0 || selection == nullptr )
-    {
-        m_pMoveUpButton->Enable( false );
-        m_pMoveDownButton->Enable( false );
+    bool  bIsSeparator =
+        selection && (static_cast<SvxConfigEntry*>(selection->GetUserData()))->IsSeparator();
+    bool bIsValidSelection =
+        !(m_pContentsListBox->GetEntryCount() == 0 || selection == nullptr);
 
-        return;
-    }
+    m_pMoveUpButton->Enable(
+        bIsValidSelection &&  selection != m_pContentsListBox->First() );
+    m_pMoveDownButton->Enable(
+        bIsValidSelection && selection != m_pContentsListBox->Last() );
 
-    SvTreeListEntry* first = m_pContentsListBox->First();
-    SvTreeListEntry* last = m_pContentsListBox->Last();
+    m_pRemoveCommandButton->Enable( bIsValidSelection );
 
-    m_pMoveUpButton->Enable( selection != first );
-    m_pMoveDownButton->Enable( selection != last );
+    m_pModifyBtn->Enable( bIsValidSelection && !bIsSeparator);
 }
 
 void SvxMenuConfigPage::DeleteSelectedTopLevel()
@@ -386,6 +394,49 @@ IMPL_LINK( SvxMenuConfigPage, InsertHdl, MenuButton *, pButton, void )
     }
 }
 
+IMPL_LINK( SvxMenuConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
+{
+    OString sIdent = pButton->GetCurItemIdent();
+
+    SAL_WARN("cui.customize", "sIdent: " << sIdent);
+
+    if (sIdent == "renameItem")
+    {
+        SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry();
+        SvxConfigEntry* pEntry =
+            static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
+
+        OUString aNewName( SvxConfigPageHelper::stripHotKey( pEntry->GetName() ) );
+        OUString aDesc = CuiResId( RID_SVXSTR_LABEL_NEW_NAME );
+
+        VclPtrInstance< SvxNameDialog > pNameDialog( this, aNewName, aDesc );
+        pNameDialog->SetHelpId( HID_SVX_CONFIG_RENAME_MENU_ITEM );
+        pNameDialog->SetText( CuiResId( RID_SVXSTR_RENAME_MENU ) );
+
+        if ( pNameDialog->Execute() == RET_OK )
+        {
+            pNameDialog->GetName( aNewName );
+
+            pEntry->SetName( aNewName );
+            m_pContentsListBox->SetEntryText( pActEntry, aNewName );
+
+            GetSaveInData()->SetModified();
+            GetTopLevelSelection()->SetModified();
+        }
+    }
+    else
+    {
+        //This block should never be reached
+        SAL_WARN("cui.customize", "Unknown insert option: " << sIdent);
+        return;
+    }
+
+    if ( GetSaveInData()->IsModified() )
+    {
+        UpdateButtonStates();
+    }
+}
+
 IMPL_LINK_NOARG( SvxMenuConfigPage, ResetMenuHdl, Button *, void )
 {
     SvxConfigEntry* pMenuData = GetTopLevelSelection();
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index f9c700c82f2b..5446c673f5ed 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -145,6 +145,8 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
 
     m_pInsertBtn->SetSelectHdl(
         LINK( this, SvxToolbarConfigPage, InsertHdl ) );
+    m_pModifyBtn->SetSelectHdl(
+        LINK( this, SvxToolbarConfigPage, ModifyItemHdl ) );
     m_pResetBtn->SetClickHdl(
         LINK( this, SvxToolbarConfigPage, ResetToolbarHdl ) );
 
@@ -454,6 +456,226 @@ IMPL_LINK( SvxToolbarConfigPage, InsertHdl, MenuButton *, pButton, void )
     }
 }
 
+IMPL_LINK( SvxToolbarConfigPage, ModifyItemHdl, MenuButton *, pButton, void )
+{
+    bool bNeedsApply = false;
+
+    // get currently selected toolbar
+    SvxConfigEntry* pToolbar = GetTopLevelSelection();
+
+    OString sIdent = pButton->GetCurItemIdent();
+
+    if (sIdent == "renameItem")
+    {
+        SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry();
+        SvxConfigEntry* pEntry =
+            static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
+
+        OUString aNewName( SvxConfigPageHelper::stripHotKey( pEntry->GetName() ) );
+        OUString aDesc = CuiResId( RID_SVXSTR_LABEL_NEW_NAME );
+
+        VclPtrInstance< SvxNameDialog > pNameDialog( this, aNewName, aDesc );
+        pNameDialog->SetHelpId( HID_SVX_CONFIG_RENAME_TOOLBAR_ITEM );
+        pNameDialog->SetText( CuiResId( RID_SVXSTR_RENAME_TOOLBAR ) );
+
+        if ( pNameDialog->Execute() == RET_OK )
+        {
+            pNameDialog->GetName(aNewName);
+
+            if( aNewName.isEmpty() )    // tdf#80758 - Accelerator character ("~") is passed as
+                pEntry->SetName( "~" ); // the button name in case of empty values.
+            else
+                pEntry->SetName( aNewName );
+
+            m_pContentsListBox->SetEntryText( pActEntry, aNewName );
+            bNeedsApply = true;
+        }
+    }
+    else if (sIdent == "changeIcon")
+    {
+        SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry();
+        SvxConfigEntry* pEntry =
+            static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
+
+        // Position of entry within the list
+        // TODO: Add a GetSelectionPos() method to the SvTreeListBox class
+        sal_uInt16 nSelectionPos = m_pContentsListBox->GetModel()->GetAbsPos( pActEntry );
+
+        ScopedVclPtr<SvxIconSelectorDialog> pIconDialog(
+            VclPtr<SvxIconSelectorDialog>::Create( nullptr,
+                GetSaveInData()->GetImageManager(),
+                GetSaveInData()->GetParentImageManager() ));
+
+        if ( pIconDialog->Execute() == RET_OK )
+        {
+            css::uno::Reference< css::graphic::XGraphic > newgraphic =
+                pIconDialog->GetSelectedIcon();
+
+            if ( newgraphic.is() )
+            {
+                css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > >
+                    aGraphicSeq( 1 );
+
+                css::uno::Sequence<OUString> aURLSeq { pEntry->GetCommand() };
+
+                if ( !pEntry->GetBackupGraphic().is() )
+                {
+                    css::uno::Reference< css::graphic::XGraphic > backup;
+                    backup = SvxConfigPageHelper::GetGraphic(
+                        GetSaveInData()->GetImageManager(), aURLSeq[ 0 ] );
+
+                    if ( backup.is() )
+                    {
+                        pEntry->SetBackupGraphic( backup );
+                    }
+                }
+
+                aGraphicSeq[ 0 ] = newgraphic;
+                try
+                {
+                    GetSaveInData()->GetImageManager()->replaceImages(
+                        SvxConfigPageHelper::GetImageType(), aURLSeq, aGraphicSeq );
+
+                    m_pContentsListBox->GetModel()->Remove( pActEntry );
+                    SvTreeListEntry* pNewLBEntry =
+                        InsertEntryIntoUI( pEntry, nSelectionPos );
+
+                    m_pContentsListBox->SetCheckButtonState( pNewLBEntry,
+                        pEntry->IsVisible() ?
+                        SvButtonState::Checked : SvButtonState::Unchecked );
+
+                    m_pContentsListBox->Select( pNewLBEntry );
+                    m_pContentsListBox->MakeVisible( pNewLBEntry );
+
+                    GetSaveInData()->PersistChanges(
+                        GetSaveInData()->GetImageManager() );
+                }
+                catch ( css::uno::Exception& e)
+                {
+                    SAL_WARN("cui.customize", "Error replacing image: " << e.Message);
+                }
+            }
+        }
+    }
+    else if (sIdent == "resetIcon")
+    {
+        SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry();
+        SvxConfigEntry* pEntry =
+            static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
+
+        // Position of entry within the list
+        // TODO: Add a GetSelectionPos() method to the SvTreeListBox class
+        sal_uInt16 nSelectionPos = m_pContentsListBox->GetModel()->GetAbsPos( pActEntry );
+
+        css::uno::Reference< css::graphic::XGraphic > backup =
+            pEntry->GetBackupGraphic();
+
+        css::uno::Sequence< css::uno::Reference< css::graphic::XGraphic > >
+            aGraphicSeq( 1 );
+        aGraphicSeq[ 0 ] = backup;
+
+        css::uno::Sequence<OUString> aURLSeq { pEntry->GetCommand() };
+
+        try
+        {
+            GetSaveInData()->GetImageManager()->replaceImages(
+                SvxConfigPageHelper::GetImageType(), aURLSeq, aGraphicSeq );
+
+            m_pContentsListBox->GetModel()->Remove( pActEntry );
+
+            SvTreeListEntry* pNewLBEntry =
+                InsertEntryIntoUI( pEntry, nSelectionPos );
+
+            m_pContentsListBox->SetCheckButtonState( pNewLBEntry,
+                pEntry->IsVisible() ?
+                    SvButtonState::Checked : SvButtonState::Unchecked );
+
+            m_pContentsListBox->Select( pNewLBEntry );
+            m_pContentsListBox->MakeVisible( pNewLBEntry );
+
+            // reset backup in entry
+            pEntry->SetBackupGraphic(
+                css::uno::Reference< css::graphic::XGraphic >() );
+
+            GetSaveInData()->PersistChanges(
+                GetSaveInData()->GetImageManager() );
+        }
+        catch ( css::uno::Exception& e )
+        {
+            SAL_WARN("cui.customize", "Error resetting image: " << e.Message);
+        }
+    }
+    else if (sIdent == "restoreItem")
+    {
+        SvTreeListEntry* pActEntry = m_pContentsListBox->GetCurEntry();
+        SvxConfigEntry* pEntry =
+            static_cast<SvxConfigEntry*>(pActEntry->GetUserData());
+
+        // Position of entry within the list
+        // TODO: Add a GetSelectionPos() method to the SvTreeListBox class
+        sal_uInt16 nSelectionPos = m_pContentsListBox->GetModel()->GetAbsPos( pActEntry );
+
+        ToolbarSaveInData* pSaveInData =
+            static_cast<ToolbarSaveInData*>( GetSaveInData() );
+
+        OUString aSystemName =
+            pSaveInData->GetSystemUIName( pEntry->GetCommand() );
+
+        if ( !pEntry->GetName().equals( aSystemName ) )
+        {
+            pEntry->SetName( aSystemName );
+            m_pContentsListBox->SetEntryText(
+                pActEntry, SvxConfigPageHelper::stripHotKey( aSystemName ) );
+            bNeedsApply = true;
+        }
+
+        css::uno::Sequence<OUString> aURLSeq { pEntry->GetCommand() };
+
+        try
+        {
+            GetSaveInData()->GetImageManager()->removeImages(
+                SvxConfigPageHelper::GetImageType(), aURLSeq );
+
+            // reset backup in entry
+            pEntry->SetBackupGraphic(
+                css::uno::Reference< css::graphic::XGraphic >() );
+
+            GetSaveInData()->PersistChanges(
+                GetSaveInData()->GetImageManager() );
+
+            m_pContentsListBox->RemoveEntry( pActEntry );
+
+            SvTreeListEntry* pNewLBEntry =
+                InsertEntryIntoUI( pEntry, nSelectionPos );
+
+            m_pContentsListBox->SetCheckButtonState( pNewLBEntry,
+                pEntry->IsVisible() ?
+                    SvButtonState::Checked : SvButtonState::Unchecked );
+
+            m_pContentsListBox->Select( pNewLBEntry );
+            m_pContentsListBox->MakeVisible( pNewLBEntry );
+
+            bNeedsApply = true;
+        }
+        catch ( css::uno::Exception& e )
+        {
+            SAL_WARN("cui.customize", "Error restoring image: " << e.Message);
+        }
+    }
+    else
+    {
+        //This block should never be reached
+        SAL_WARN("cui.customize", "Unknown insert option: " << sIdent);
+        return;
+    }
+
+    if ( bNeedsApply )
+    {
+        static_cast<ToolbarSaveInData*>( GetSaveInData())->ApplyToolbar( pToolbar );
+        UpdateButtonStates();
+    }
+}
+
 IMPL_LINK_NOARG( SvxToolbarConfigPage, ResetToolbarHdl, Button *, void )
 {
     sal_Int32 nSelectionPos = m_pTopLevelListBox->GetSelectEntryPos();
@@ -477,19 +699,19 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, ResetToolbarHdl, Button *, void )
 
 void SvxToolbarConfigPage::UpdateButtonStates()
 {
-    m_pDescriptionField->SetText("");
-
     SvTreeListEntry* selection = m_pContentsListBox->GetCurEntry();
-    if ( m_pContentsListBox->GetEntryCount() == 0 || selection == nullptr )
-    {
-        return;
-    }
 
-    SvxConfigEntry* pEntryData = static_cast<SvxConfigEntry*>(selection->GetUserData());
-    if ( !pEntryData->IsSeparator() )
-    {
-        m_pDescriptionField->SetText(pEntryData->GetHelpText());
-    }
+    bool  bIsSeparator =
+        selection && (static_cast<SvxConfigEntry*>(selection->GetUserData()))->IsSeparator();
+    bool bIsValidSelection =
+        !(m_pContentsListBox->GetEntryCount() == 0 || selection == nullptr);
+
+    m_pMoveUpButton->Enable( bIsValidSelection );
+    m_pMoveDownButton->Enable( bIsValidSelection );
+
+    m_pRemoveCommandButton->Enable( bIsValidSelection );
+
+    m_pModifyBtn->Enable( bIsValidSelection && !bIsSeparator );
 }
 
 short SvxToolbarConfigPage::QueryReset()
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index d94632922098..efb488fbfe97 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1163,6 +1163,7 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
     get(m_pMoveDownButton, "down");
     get(m_pSaveInListBox, "savein");
     get(m_pInsertBtn, "insert");
+    get(m_pModifyBtn, "modify");
     get(m_pResetBtn, "resetbtn");
     get(m_pDescriptionField, "desc");
     m_pDescriptionField->set_height_request(m_pDescriptionField->GetTextHeight()*4);
@@ -1204,6 +1205,7 @@ void SvxConfigPage::dispose()
     m_pMoveDownButton.clear();
     m_pSaveInListBox.clear();
     m_pInsertBtn.clear();
+    m_pModifyBtn.clear();
     m_pResetBtn.clear();
     m_pDescriptionField.clear();
 
diff --git a/cui/source/inc/SvxMenuConfigPage.hxx b/cui/source/inc/SvxMenuConfigPage.hxx
index f0b0bcafa247..3763dcaffe77 100644
--- a/cui/source/inc/SvxMenuConfigPage.hxx
+++ b/cui/source/inc/SvxMenuConfigPage.hxx
@@ -63,6 +63,7 @@ private:
     DECL_LINK( RemoveCommandHdl, Button *, void );
 
     DECL_LINK( InsertHdl, MenuButton *, void );
+    DECL_LINK( ModifyItemHdl, MenuButton *, void );
     DECL_LINK( ResetMenuHdl, Button *, void );
 
     void            Init() override;
diff --git a/cui/source/inc/SvxToolbarConfigPage.hxx b/cui/source/inc/SvxToolbarConfigPage.hxx
index 07cae0dab56d..7426fb2b7be3 100644
--- a/cui/source/inc/SvxToolbarConfigPage.hxx
+++ b/cui/source/inc/SvxToolbarConfigPage.hxx
@@ -64,6 +64,7 @@ private:
     DECL_LINK( RemoveCommandHdl, Button *, void );
 
     DECL_LINK( InsertHdl, MenuButton *, void );
+    DECL_LINK( ModifyItemHdl, MenuButton *, void );
     DECL_LINK( ResetToolbarHdl, Button *, void );
 
     void            UpdateButtonStates() override;
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index f8b397b7d614..06b2c4d1c844 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -409,6 +409,7 @@ protected:
     VclPtr<ListBox>                            m_pSaveInListBox;
 
     VclPtr<MenuButton>                         m_pInsertBtn;
+    VclPtr<MenuButton>                         m_pModifyBtn;
     // Used to reset the selected toolbar/menu/context menu
     VclPtr<PushButton>                         m_pResetBtn;
 
diff --git a/cui/uiconfig/ui/menuassignpage.ui b/cui/uiconfig/ui/menuassignpage.ui
index 571cc2c8e073..928e78d6ce7a 100644
--- a/cui/uiconfig/ui/menuassignpage.ui
+++ b/cui/uiconfig/ui/menuassignpage.ui
@@ -166,7 +166,7 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkButton">
+                          <object class="GtkButton" id="modify:modifymenu">
                             <property name="label" translatable="yes">Modify</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
@@ -576,6 +576,42 @@
       </object>
     </child>
   </object>
+  <object class="GtkMenu" id="modifymenu">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkMenuItem" id="renameItem">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Rename...</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="changeIcon">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Change Icon...</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="resetIcon">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Reset Icon</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="restoreItem">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Restore Default Command</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+  </object>
   <object class="GtkSizeGroup" id="sizegroup1"/>
   <object class="GtkSizeGroup" id="sizegroup2"/>
 </interface>
commit 862b968d1c015bca2226f18c767d350da63517c8
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Fri Aug 25 23:53:37 2017 +0300

    Disable the individual reset button for the menubar menus
    
    And:
    * Cut m_pDescriptionField's ties to the entries list on the right.
    * Disable Add and Remove buttons depending on current command selection
    * Display the description of the selected command
    
    Change-Id: I65a06f2f143c335f26de9007c6067f3116465c30
    Reviewed-on: https://gerrit.libreoffice.org/41582
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 1e7cac7598a5..336e6bbe4ed9 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -144,6 +144,11 @@ SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSe
         m_pPlusBtn->Hide();
         m_pMinusBtn->Hide();
     }
+    else
+    {
+        // TODO: Remove this when it is possible to reset menubar menus individually
+        m_pResetBtn->Disable();
+    }
 
 }
 
@@ -189,7 +194,6 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenuEntry, SvTreeListBox *, void )
 
 void SvxMenuConfigPage::UpdateButtonStates()
 {
-
     // Disable Up and Down buttons depending on current selection
     SvTreeListEntry* selection = m_pContentsListBox->GetCurEntry();
 
@@ -198,8 +202,6 @@ void SvxMenuConfigPage::UpdateButtonStates()
         m_pMoveUpButton->Enable( false );
         m_pMoveDownButton->Enable( false );
 
-        m_pDescriptionField->SetText("");
-
         return;
     }
 
@@ -208,18 +210,6 @@ void SvxMenuConfigPage::UpdateButtonStates()
 
     m_pMoveUpButton->Enable( selection != first );
     m_pMoveDownButton->Enable( selection != last );
-
-    SvxConfigEntry* pEntryData =
-        static_cast<SvxConfigEntry*>(selection->GetUserData());
-
-    if ( pEntryData->IsSeparator() )
-    {
-        m_pDescriptionField->SetText("");
-    }
-    else
-    {
-        m_pDescriptionField->SetText(pEntryData->GetHelpText());
-    }
 }
 
 void SvxMenuConfigPage::DeleteSelectedTopLevel()
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 2546f91df020..d94632922098 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1178,6 +1178,9 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
 
     m_pSearchEdit->SetUpdateDataHdl ( LINK( this, SvxConfigPage, SearchUpdateHdl ));
     m_pSearchEdit->EnableUpdateData();
+
+    m_pFunctions->SetSelectHdl(
+        LINK( this, SvxConfigPage, SelectFunctionHdl ) );
 }
 
 SvxConfigPage::~SvxConfigPage()
@@ -1773,6 +1776,29 @@ IMPL_LINK( SvxConfigPage, MoveHdl, Button *, pButton, void )
     MoveEntry(pButton == m_pMoveUpButton);
 }
 
+IMPL_LINK_NOARG( SvxConfigPage, SelectFunctionHdl, SvTreeListBox *, void )
+{
+    // GetScriptURL() returns a non-empty string if a
+    // valid command is selected on the left box
+    bool bIsValidCommand = !GetScriptURL().isEmpty();
+
+    // Enable/disable Add and Remove buttons depending on current selection
+    if (bIsValidCommand)
+    {
+        m_pAddCommandButton->Enable();
+        m_pRemoveCommandButton->Enable();
+
+        m_pDescriptionField->SetText( m_pFunctions->GetHelpText() );
+    }
+    else
+    {
+        m_pAddCommandButton->Disable();
+        m_pRemoveCommandButton->Disable();
+
+        m_pDescriptionField->SetText("");
+    }
+}
+
 IMPL_LINK_NOARG(SvxConfigPage, SearchUpdateHdl, Edit&, void)
 {
     OUString aSearchTerm( m_pSearchEdit->GetText() );
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index fec9e139c32e..f8b397b7d614 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -424,6 +424,7 @@ protected:
     SvxConfigPage( vcl::Window*, const SfxItemSet& );
 
     DECL_LINK( MoveHdl, Button *, void );
+    DECL_LINK( SelectFunctionHdl, SvTreeListBox *, void );
 
     virtual SaveInData* CreateSaveInData(
         const css::uno::Reference< css::ui::XUIConfigurationManager >&,
commit 25435b29da75ac6fa5106eba3456ea3f8ca32cda
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Tue Aug 22 21:50:46 2017 +0300

    Make toolbar/menu addition/removal functional again in the Customize dialog
    
    "+" and "-" buttons next to the menu/toolbar listbox can be used
    to add new toolbars/menus or remove existing toolbars/menus.
    
    Most of the code was borrowed from the previous implementation,
    and adapted to fit the current structure.
    
    Change-Id: I7e7f51a46251c2d010154f2a0bab3bb20280bf7c
    Reviewed-on: https://gerrit.libreoffice.org/41431
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index ced1a5f0ec92..1e7cac7598a5 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -119,6 +119,11 @@ SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSe
     m_pContentsListBox->SetSelectHdl(
         LINK( this, SvxMenuConfigPage, SelectMenuEntry ) );
 
+    m_pPlusBtn->SetClickHdl(
+        LINK( this, SvxMenuConfigPage, AddMenuHdl ) );
+    m_pMinusBtn->SetClickHdl(
+        LINK( this, SvxMenuConfigPage, RemoveMenuHdl ) );
+
     m_pCommandCategoryListBox->SetSelectHdl(
         LINK( this, SvxMenuConfigPage, SelectCategory ) );
 
@@ -133,6 +138,13 @@ SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSe
     m_pResetBtn->SetClickHdl(
         LINK( this, SvxMenuConfigPage, ResetMenuHdl ) );
 
+    if ( !bIsMenuBar )
+    {
+        // Context menus cannot be added/removed
+        m_pPlusBtn->Hide();
+        m_pMinusBtn->Hide();
+    }
+
 }
 
 SvxMenuConfigPage::~SvxMenuConfigPage()
@@ -280,6 +292,9 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenu, ListBox&, void )
 
     if ( pMenuData )
     {
+        // Built-in menus cannot be deleted
+        m_pMinusBtn->Enable( pMenuData->IsDeletable() );
+
         SvxEntries* pEntries = pMenuData->GetEntries();
         SvxEntries::const_iterator iter = pEntries->begin();
 
@@ -293,6 +308,24 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenu, ListBox&, void )
     UpdateButtonStates();
 }
 
+IMPL_LINK_NOARG( SvxMenuConfigPage, AddMenuHdl, Button *, void )
+{
+    VclPtrInstance<SvxMainMenuOrganizerDialog> pDialog(
+        nullptr, GetSaveInData()->GetEntries(), nullptr, true );
+
+    if ( pDialog->Execute() == RET_OK )
+    {
+        GetSaveInData()->SetEntries( pDialog->GetEntries() );
+        ReloadTopLevelListBox( pDialog->GetSelectedEntry() );
+        GetSaveInData()->SetModified();
+    }
+}
+
+IMPL_LINK_NOARG( SvxMenuConfigPage, RemoveMenuHdl, Button *, void )
+{
+    DeleteSelectedTopLevel();
+}
+
 IMPL_LINK_NOARG( SvxMenuConfigPage, SelectCategory, ListBox&, void )
 {
     OUString aSearchTerm( m_pSearchEdit->GetText() );
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index b71e05e66a3b..f9c700c82f2b 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -128,6 +128,11 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
     m_pCommandCategoryListBox->SetSelectHdl(
         LINK( this, SvxToolbarConfigPage, SelectCategory ) );
 
+    m_pPlusBtn->SetClickHdl(
+        LINK( this, SvxToolbarConfigPage, AddToolbarHdl ) );
+    m_pMinusBtn->SetClickHdl(
+        LINK( this, SvxToolbarConfigPage, RemoveToolbarHdl ) );
+
     m_pMoveUpButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) );
     m_pMoveDownButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) );
     // Always enable Up and Down buttons
@@ -329,6 +334,79 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbarEntry, SvTreeListBox *, void
     UpdateButtonStates();
 }
 
+IMPL_LINK_NOARG( SvxToolbarConfigPage, AddToolbarHdl, Button *, void )
+{
+    OUString prefix = CuiResId( RID_SVXSTR_NEW_TOOLBAR );
+
+    OUString aNewName =
+        SvxConfigPageHelper::generateCustomName( prefix, GetSaveInData()->GetEntries() );
+
+    OUString aNewURL =
+        SvxConfigPageHelper::generateCustomURL( GetSaveInData()->GetEntries() );
+
+    VclPtrInstance< SvxNewToolbarDialog > pNameDialog( nullptr, aNewName );
+
+    // Reflect the actual m_pSaveInListBox into the new toolbar dialog
+    for ( sal_Int32 i = 0; i < m_pSaveInListBox->GetEntryCount(); ++i )
+    {
+        SaveInData* pData =
+            static_cast<SaveInData*>(m_pSaveInListBox->GetEntryData( i ));
+
+        const sal_Int32 nInsertPos =
+            pNameDialog->m_pSaveInListBox->InsertEntry( m_pSaveInListBox->GetEntry( i ) );
+
+        pNameDialog->m_pSaveInListBox->SetEntryData( nInsertPos, pData );
+    }
+
+    pNameDialog->m_pSaveInListBox->SelectEntryPos(
+        m_pSaveInListBox->GetSelectEntryPos() );
+
+    if ( pNameDialog->Execute() == RET_OK )
+    {
+        aNewName = pNameDialog->GetName();
+
+        // Where to save the new toolbar? (i.e. Modulewise or documentwise)
+        sal_Int32 nInsertPos = pNameDialog->m_pSaveInListBox->GetSelectEntryPos();
+
+        ToolbarSaveInData* pData =
+            static_cast<ToolbarSaveInData*>(
+                pNameDialog->m_pSaveInListBox->GetEntryData( nInsertPos ) );
+
+        if ( GetSaveInData() != pData )
+        {
+            m_pSaveInListBox->SelectEntryPos( nInsertPos );
+            m_pSaveInListBox->GetSelectHdl().Call(*m_pSaveInListBox);
+        }
+
+        SvxConfigEntry* pToolbar =
+            new SvxConfigEntry( aNewName, aNewURL, true );
+
+        pToolbar->SetUserDefined();
+        pToolbar->SetMain();
+
+        pData->CreateToolbar( pToolbar );
+
+        nInsertPos = m_pTopLevelListBox->InsertEntry( pToolbar->GetName() );
+        m_pTopLevelListBox->SetEntryData( nInsertPos, pToolbar );
+        m_pTopLevelListBox->SelectEntryPos( nInsertPos );
+        m_pTopLevelListBox->GetSelectHdl().Call(*m_pTopLevelListBox);
+
+        pData->SetModified();
+    }
+}
+
+IMPL_LINK_NOARG( SvxToolbarConfigPage, RemoveToolbarHdl, Button *, void )
+{
+    SvxConfigEntry* pToolbar = GetTopLevelSelection();
+
+    if ( pToolbar && pToolbar->IsDeletable() )
+    {
+        DeleteSelectedTopLevel();
+        UpdateButtonStates();
+    }
+
+}
+
 IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectCategory, ListBox&, void )
 {
     OUString aSearchTerm( m_pSearchEdit->GetText() );
@@ -436,8 +514,20 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbar, ListBox&, void )
     if ( pToolbar == nullptr )
     {
         //TODO: Disable related buttons
+        m_pPlusBtn->Enable( false );
+        m_pMinusBtn->Enable( false );
+        m_pInsertBtn->Enable( false );
+        m_pResetBtn->Enable( false );
+
         return;
     }
+    else
+    {
+        m_pPlusBtn->Enable();
+        m_pMinusBtn->Enable( pToolbar->IsDeletable() );
+        m_pInsertBtn->Enable();
+        m_pResetBtn->Enable();
+    }
 
     SvxEntries* pEntries = pToolbar->GetEntries();
     SvxEntries::const_iterator iter = pEntries->begin();
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index e3272a4c9dd5..2546f91df020 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1156,6 +1156,8 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
     get(m_pRemoveCommandButton, "remove");
 
     get(m_pTopLevelListBox, "toplevellist");
+    get(m_pPlusBtn, "plusbtn");
+    get(m_pMinusBtn, "minusbtn");
     get(m_pContents, "contents");
     get(m_pMoveUpButton, "up");
     get(m_pMoveDownButton, "down");
@@ -1186,6 +1188,8 @@ SvxConfigPage::~SvxConfigPage()
 void SvxConfigPage::dispose()
 {
     m_pTopLevelListBox.clear();
+    m_pPlusBtn.clear();
+    m_pMinusBtn.clear();
     m_pSearchEdit.clear();
     m_pCommandCategoryListBox.clear();
     m_pContents.clear();
diff --git a/cui/source/inc/SvxConfigPageHelper.hxx b/cui/source/inc/SvxConfigPageHelper.hxx
index 4f0dd0470a83..75f8373201f6 100644
--- a/cui/source/inc/SvxConfigPageHelper.hxx
+++ b/cui/source/inc/SvxConfigPageHelper.hxx
@@ -47,6 +47,11 @@ public:
         SvxEntries* entries,
         sal_Int32 suffix = 1 );
     static sal_uInt32   generateRandomValue();
+    /**
+        Generates a custom resource URL for a new toolbar.
+        Typically something like: private:resource/toolbar/custom_toolbar_########
+        The last 8 letters are randomly generated alphanumeric characters.
+    */
     static OUString     generateCustomURL( SvxEntries* entries );
 
     static OUString GetModuleName( const OUString& aModuleId );
diff --git a/cui/source/inc/SvxMenuConfigPage.hxx b/cui/source/inc/SvxMenuConfigPage.hxx
index 56365d79aa93..f0b0bcafa247 100644
--- a/cui/source/inc/SvxMenuConfigPage.hxx
+++ b/cui/source/inc/SvxMenuConfigPage.hxx
@@ -54,6 +54,9 @@ private:
     DECL_LINK( SelectMenu, ListBox&, void );
     DECL_LINK( SelectMenuEntry, SvTreeListBox *, void );
 
+    DECL_LINK( AddMenuHdl, Button *, void );
+    DECL_LINK( RemoveMenuHdl, Button *, void );
+
     DECL_LINK( SelectCategory, ListBox&, void );
 
     DECL_LINK( AddCommandHdl, Button *, void );
diff --git a/cui/source/inc/SvxToolbarConfigPage.hxx b/cui/source/inc/SvxToolbarConfigPage.hxx
index 471d9bc0d6d3..07cae0dab56d 100644
--- a/cui/source/inc/SvxToolbarConfigPage.hxx
+++ b/cui/source/inc/SvxToolbarConfigPage.hxx
@@ -55,6 +55,9 @@ private:
     DECL_LINK( SelectToolbarEntry, SvTreeListBox*, void );
     DECL_LINK( MoveHdl, Button *, void );
 
+    DECL_LINK( AddToolbarHdl, Button *, void );
+    DECL_LINK( RemoveToolbarHdl, Button *, void );
+
     DECL_LINK( SelectCategory, ListBox&, void );
 
     DECL_LINK( AddCommandHdl, Button *, void );
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index bd9704d25420..fec9e139c32e 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -396,6 +396,9 @@ protected:
     // Right side of the dialog where the contents of the selected
     // menu or toolbar are displayed
     VclPtr<ListBox>                            m_pTopLevelListBox;
+    // Used to add and remove toolbars/menus
+    VclPtr<PushButton>                         m_pPlusBtn;
+    VclPtr<PushButton>                         m_pMinusBtn;
     VclPtr<VclFrame>                           m_pContents;
     VclPtr<VclContainer>                       m_pEntries;
     VclPtr<SvTreeListBox>                      m_pContentsListBox;
diff --git a/cui/uiconfig/ui/menuassignpage.ui b/cui/uiconfig/ui/menuassignpage.ui
index 6093fb2ab644..571cc2c8e073 100644
--- a/cui/uiconfig/ui/menuassignpage.ui
+++ b/cui/uiconfig/ui/menuassignpage.ui
@@ -262,7 +262,7 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkButton" id="add1">
+                          <object class="GtkButton" id="plusbtn">
                             <property name="label" translatable="yes">+</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
@@ -276,7 +276,7 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkButton" id="remove1">
+                          <object class="GtkButton" id="minusbtn">
                             <property name="label" translatable="yes">-</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
commit 46d993c352c2f34af532ffd9034ebf7bd3ab9691
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Sun Aug 20 20:43:56 2017 +0300

    Implement "Reset" button in the Customize dialog
    
    For now, it works for the Toolbar and the Context Menu tabs.
    Normal top-level menus cannot be reset individually at the moment
    because they are sharing a single xml file, and the removeSettings()
    mathod doesn't provide per-item removal from within a single file.
    
    Change-Id: I42d62dc26130e4c03cf75a1ce6dc9ff367a58d47
    Reviewed-on: https://gerrit.libreoffice.org/41367
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc
index 74b0bcb4f80e..266f93bdd5de 100644
--- a/cui/inc/strings.hrc
+++ b/cui/inc/strings.hrc
@@ -69,6 +69,7 @@
 #define RID_SVXSTR_CONFIRM_MENU_RESET               NC_("RID_SVXSTR_CONFIRM_MENU_RESET", "The menu configuration for %SAVE IN SELECTION% will be reset to the default settings. Do you want to continue?")
 #define RID_SVXSTR_CONFIRM_TOOLBAR_RESET            NC_("RID_SVXSTR_CONFIRM_TOOLBAR_RESET", "The toolbar configuration for %SAVE IN SELECTION% will be reset to the default settings. Do you want to continue?")
 #define RID_SVXSTR_CONFIRM_RESTORE_DEFAULT          NC_("RID_SVXSTR_CONFIRM_RESTORE_DEFAULT", "This will delete all changes previously made to this toolbar. Do you really want to reset the toolbar?")
+#define RID_SVXSTR_CONFIRM_RESTORE_DEFAULT_MENU     NC_("RID_SVXSTR_CONFIRM_RESTORE_DEFAULT_MENU", "This will delete all changes previously made to this context menu. Do you really want to reset?")
 #define RID_SVXSTR_MNUCFG_ALREADY_INCLUDED          NC_("RID_SVXSTR_MNUCFG_ALREADY_INCLUDED", "Function is already included in this popup.")
 #define RID_SVXSTR_LABEL_NEW_NAME                   NC_("RID_SVXSTR_LABEL_NEW_NAME", "~New name")
 #define RID_SVXSTR_RENAME_MENU                      NC_("RID_SVXSTR_RENAME_MENU", "Rename Menu")
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 4b3a69f6e2db..ced1a5f0ec92 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -130,6 +130,9 @@ SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSe
 
     m_pInsertBtn->SetSelectHdl(
         LINK( this, SvxMenuConfigPage, InsertHdl ) );
+    m_pResetBtn->SetClickHdl(
+        LINK( this, SvxMenuConfigPage, ResetMenuHdl ) );
+
 }
 
 SvxMenuConfigPage::~SvxMenuConfigPage()
@@ -360,6 +363,34 @@ IMPL_LINK( SvxMenuConfigPage, InsertHdl, MenuButton *, pButton, void )
     }
 }
 
+IMPL_LINK_NOARG( SvxMenuConfigPage, ResetMenuHdl, Button *, void )
+{
+    SvxConfigEntry* pMenuData = GetTopLevelSelection();
+
+    ScopedVclPtrInstance<MessageDialog> qbox(this,
+        CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT_MENU), VclMessageType::Question, VclButtonsType::YesNo);
+
+    // Resetting individual top-level menus is not possible at the moment.
+    // So we are resetting only if it is a context menu
+    if (!m_bIsMenuBar && qbox->Execute() == RET_YES)
+    {
+        sal_Int32 nPos = m_pTopLevelListBox->GetSelectEntryPos();
+        ContextMenuSaveInData* pSaveInData = static_cast< ContextMenuSaveInData* >(GetSaveInData());
+
+        pSaveInData->ResetContextMenu(pMenuData);
+
+        // ensure that the UI is cleared before populating it
+        m_pTopLevelListBox->Clear();
+        m_pContentsListBox->Clear();
+
+        ReloadTopLevelListBox();
+
+        // Reselect the resetted menu
+        m_pTopLevelListBox->SelectEntryPos(nPos);
+        m_pTopLevelListBox->GetSelectHdl().Call(*m_pTopLevelListBox);
+    }
+}
+
 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 848c68980607..b71e05e66a3b 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -140,6 +140,9 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
 
     m_pInsertBtn->SetSelectHdl(
         LINK( this, SvxToolbarConfigPage, InsertHdl ) );
+    m_pResetBtn->SetClickHdl(
+        LINK( this, SvxToolbarConfigPage, ResetToolbarHdl ) );
+
     // "Insert Submenu" is irrelevant to the toolbars
     PopupMenu* pPopup = m_pInsertBtn->GetPopupMenu();
     pPopup->EnableItem(OString( "insertsubmenu"), false );
@@ -373,6 +376,26 @@ IMPL_LINK( SvxToolbarConfigPage, InsertHdl, MenuButton *, pButton, void )
     }
 }
 
+IMPL_LINK_NOARG( SvxToolbarConfigPage, ResetToolbarHdl, Button *, void )
+{
+    sal_Int32 nSelectionPos = m_pTopLevelListBox->GetSelectEntryPos();
+
+    SvxConfigEntry* pToolbar =
+        static_cast<SvxConfigEntry*>(m_pTopLevelListBox->GetEntryData( nSelectionPos ));
+
+    ScopedVclPtrInstance<MessageDialog> qbox(this,
+        CuiResId(RID_SVXSTR_CONFIRM_RESTORE_DEFAULT), VclMessageType::Question, VclButtonsType::YesNo);
+
+    if ( qbox->Execute() == RET_YES )
+    {
+        ToolbarSaveInData* pSaveInData =
+            static_cast<ToolbarSaveInData*>(GetSaveInData());
+
+        pSaveInData->RestoreToolbar( pToolbar );
+
+        m_pTopLevelListBox->GetSelectHdl().Call( *m_pTopLevelListBox );
+    }
+}
 
 void SvxToolbarConfigPage::UpdateButtonStates()
 {
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 8e0989810b1d..e3272a4c9dd5 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -924,8 +924,24 @@ void ContextMenuSaveInData::Reset()
         {
             GetConfigManager()->removeSettings( pEntry->GetCommand() );
         }
-        catch ( const css::uno::Exception& )
-        {}
+        catch ( const css::uno::Exception& e )
+        {
+            SAL_WARN("cui.customize", "Exception caught while resetting context menus: " << e.Message);
+        }
+    }
+    PersistChanges( GetConfigManager() );
+    m_pRootEntry.reset();
+}
+
+void ContextMenuSaveInData::ResetContextMenu( SvxConfigEntry* pEntry )
+{
+    try
+    {
+        GetConfigManager()->removeSettings( pEntry->GetCommand() );
+    }
+    catch ( const css::uno::Exception& e )
+    {
+        SAL_WARN("cui.customize", "Exception caught while resetting context menu: " << e.Message);
     }
     PersistChanges( GetConfigManager() );
     m_pRootEntry.reset();
@@ -1145,6 +1161,7 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
     get(m_pMoveDownButton, "down");
     get(m_pSaveInListBox, "savein");
     get(m_pInsertBtn, "insert");
+    get(m_pResetBtn, "resetbtn");
     get(m_pDescriptionField, "desc");
     m_pDescriptionField->set_height_request(m_pDescriptionField->GetTextHeight()*4);
     get(m_pEntries, "entries");
@@ -1180,6 +1197,7 @@ void SvxConfigPage::dispose()
     m_pMoveDownButton.clear();
     m_pSaveInListBox.clear();
     m_pInsertBtn.clear();
+    m_pResetBtn.clear();
     m_pDescriptionField.clear();
 
     m_pContentsListBox.disposeAndClear();
diff --git a/cui/source/inc/SvxMenuConfigPage.hxx b/cui/source/inc/SvxMenuConfigPage.hxx
index a0ba3abd1cbe..56365d79aa93 100644
--- a/cui/source/inc/SvxMenuConfigPage.hxx
+++ b/cui/source/inc/SvxMenuConfigPage.hxx
@@ -60,6 +60,7 @@ private:
     DECL_LINK( RemoveCommandHdl, Button *, void );
 
     DECL_LINK( InsertHdl, MenuButton *, void );
+    DECL_LINK( ResetMenuHdl, Button *, void );
 
     void            Init() override;
     void            UpdateButtonStates() override;
diff --git a/cui/source/inc/SvxToolbarConfigPage.hxx b/cui/source/inc/SvxToolbarConfigPage.hxx
index 2f7e0e48331e..471d9bc0d6d3 100644
--- a/cui/source/inc/SvxToolbarConfigPage.hxx
+++ b/cui/source/inc/SvxToolbarConfigPage.hxx
@@ -61,6 +61,7 @@ private:
     DECL_LINK( RemoveCommandHdl, Button *, void );
 
     DECL_LINK( InsertHdl, MenuButton *, void );
+    DECL_LINK( ResetToolbarHdl, Button *, void );
 
     void            UpdateButtonStates() override;
     short           QueryReset() override;
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index 555dba9ee30b..bd9704d25420 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -241,6 +241,8 @@ public:
     bool HasURL( const OUString& rURL ) override;
     void Reset() override;
     bool Apply() override;
+
+    void ResetContextMenu( SvxConfigEntry* pEntry );
 };
 
 class SvxConfigEntry
@@ -404,6 +406,8 @@ protected:
     VclPtr<ListBox>                            m_pSaveInListBox;
 
     VclPtr<MenuButton>                         m_pInsertBtn;
+    // Used to reset the selected toolbar/menu/context menu
+    VclPtr<PushButton>                         m_pResetBtn;
 
     // Middle buttons
     VclPtr<PushButton>                         m_pAddCommandButton;
diff --git a/cui/uiconfig/ui/menuassignpage.ui b/cui/uiconfig/ui/menuassignpage.ui
index 1a0393941fb6..6093fb2ab644 100644
--- a/cui/uiconfig/ui/menuassignpage.ui
+++ b/cui/uiconfig/ui/menuassignpage.ui
@@ -183,7 +183,7 @@
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkButton">
+                          <object class="GtkButton" id="resetbtn">
                             <property name="label" translatable="yes">Reset</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
commit 7e0ecdecb1131bffd263d0e51583a25991b9a878
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Sun Aug 20 12:55:45 2017 +0300

    Implement "Insert" button in the Customize dialog
    
    Now the Insert button allows the user to insert separators
    to the toolbars, and separators and submenus to the menus
    and context menus.
    
    Change-Id: Ic520c78dee2152a0294e86d3bc7098a29155e4b9
    Reviewed-on: https://gerrit.libreoffice.org/41360
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 3d0bdff25f73..4b3a69f6e2db 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -127,6 +127,9 @@ SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSe
 
     m_pAddCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, AddCommandHdl ) );
     m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, RemoveCommandHdl ) );
+
+    m_pInsertBtn->SetSelectHdl(
+        LINK( this, SvxMenuConfigPage, InsertHdl ) );
 }
 
 SvxMenuConfigPage::~SvxMenuConfigPage()
@@ -308,6 +311,55 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, RemoveCommandHdl, Button *, void )
     }
 }
 
+IMPL_LINK( SvxMenuConfigPage, InsertHdl, MenuButton *, pButton, void )
+{
+    OString sIdent = pButton->GetCurItemIdent();
+
+    if (sIdent == "insertseparator")
+    {
+        SvxConfigEntry* pNewEntryData = new SvxConfigEntry;
+        pNewEntryData->SetUserDefined();
+        InsertEntry( pNewEntryData );
+    }
+    else if (sIdent == "insertsubmenu")
+    {
+        OUString aNewName;
+        OUString aDesc = CuiResId( RID_SVXSTR_SUBMENU_NAME );
+
+        VclPtrInstance< SvxNameDialog > pNameDialog( this, aNewName, aDesc );
+        pNameDialog->SetHelpId( HID_SVX_CONFIG_NAME_SUBMENU );
+        pNameDialog->SetText( CuiResId( RID_SVXSTR_ADD_SUBMENU ) );
+
+        if ( pNameDialog->Execute() == RET_OK )
+        {
+            pNameDialog->GetName(aNewName);
+
+            SvxConfigEntry* pNewEntryData =
+                new SvxConfigEntry( aNewName, aNewName, true );
+            pNewEntryData->SetName( aNewName );
+            pNewEntryData->SetUserDefined();
+
+            InsertEntry( pNewEntryData );
+
+            ReloadTopLevelListBox();
+
+            GetSaveInData()->SetModified();
+        }
+
+    }
+    else
+    {
+        //This block should never be reached
+        SAL_WARN("cui.customize", "Unknown insert option: " << sIdent);
+        return;
+    }
+
+    if ( GetSaveInData()->IsModified() )
+    {
+        UpdateButtonStates();
+    }
+}
+
 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 76a29b8acced..848c68980607 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -138,6 +138,13 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
     m_pAddCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, AddCommandHdl ) );
     m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, RemoveCommandHdl ) );
 
+    m_pInsertBtn->SetSelectHdl(
+        LINK( this, SvxToolbarConfigPage, InsertHdl ) );
+    // "Insert Submenu" is irrelevant to the toolbars
+    PopupMenu* pPopup = m_pInsertBtn->GetPopupMenu();
+    pPopup->EnableItem(OString( "insertsubmenu"), false );
+    pPopup->RemoveDisabledEntries();
+
     // default toolbar to select is standardbar unless a different one
     // has been passed in
     m_aURLToSelect = ITEM_TOOLBAR_URL;
@@ -336,6 +343,36 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, RemoveCommandHdl, Button *, void )
     DeleteSelectedContent();
 }
 
+IMPL_LINK( SvxToolbarConfigPage, InsertHdl, MenuButton *, pButton, void )
+{
+    OString sIdent = pButton->GetCurItemIdent();
+
+    if (sIdent == "insertseparator")
+    {
+        // Get the currently selected toolbar
+        SvxConfigEntry* pToolbar = GetTopLevelSelection();
+
+        SvxConfigEntry* pNewEntryData = new SvxConfigEntry;
+        pNewEntryData->SetUserDefined();
+
+        SvTreeListEntry* pNewLBEntry = InsertEntry( pNewEntryData );
+
+        m_pContentsListBox->SetCheckButtonInvisible( pNewLBEntry );
+        m_pContentsListBox->SetCheckButtonState(
+            pNewLBEntry, SvButtonState::Tristate );
+
+        static_cast<ToolbarSaveInData*>( GetSaveInData())->ApplyToolbar( pToolbar );
+
+        UpdateButtonStates();
+    }
+    else
+    {
+        //This block should never be reached
+        SAL_WARN("cui.customize", "Unknown insert option: " << sIdent);
+        return;
+    }
+}
+
 
 void SvxToolbarConfigPage::UpdateButtonStates()
 {
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 7883a3c13444..8e0989810b1d 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1131,7 +1131,6 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
     , bInitialised(false)
     , pCurrentSaveInData(nullptr)
     , m_pContentsListBox(nullptr)
-    , m_pSelectorDlg(nullptr)
 {
     get(m_pSearchEdit, "searchEntry");
     get(m_pCommandCategoryListBox, "commandcategorylist");
@@ -1145,6 +1144,7 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
     get(m_pMoveUpButton, "up");
     get(m_pMoveDownButton, "down");
     get(m_pSaveInListBox, "savein");
+    get(m_pInsertBtn, "insert");
     get(m_pDescriptionField, "desc");
     m_pDescriptionField->set_height_request(m_pDescriptionField->GetTextHeight()*4);
     get(m_pEntries, "entries");
@@ -1179,9 +1179,9 @@ void SvxConfigPage::dispose()
     m_pMoveUpButton.clear();
     m_pMoveDownButton.clear();
     m_pSaveInListBox.clear();
+    m_pInsertBtn.clear();
     m_pDescriptionField.clear();
 
-    m_pSelectorDlg.disposeAndClear();
     m_pContentsListBox.disposeAndClear();
     SfxTabPage::dispose();
 }
diff --git a/cui/source/inc/SvxMenuConfigPage.hxx b/cui/source/inc/SvxMenuConfigPage.hxx
index 162adc94c198..a0ba3abd1cbe 100644
--- a/cui/source/inc/SvxMenuConfigPage.hxx
+++ b/cui/source/inc/SvxMenuConfigPage.hxx
@@ -59,6 +59,8 @@ private:
     DECL_LINK( AddCommandHdl, Button *, void );
     DECL_LINK( RemoveCommandHdl, Button *, void );
 
+    DECL_LINK( InsertHdl, MenuButton *, 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 29e48078b596..2f7e0e48331e 100644
--- a/cui/source/inc/SvxToolbarConfigPage.hxx
+++ b/cui/source/inc/SvxToolbarConfigPage.hxx
@@ -60,6 +60,8 @@ private:
     DECL_LINK( AddCommandHdl, Button *, void );
     DECL_LINK( RemoveCommandHdl, Button *, void );
 
+    DECL_LINK( InsertHdl, MenuButton *, 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 f951acc8a137..555dba9ee30b 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -403,7 +403,7 @@ protected:
 
     VclPtr<ListBox>                            m_pSaveInListBox;
 
-    VclPtr<SvxScriptSelectorDialog>            m_pSelectorDlg;
+    VclPtr<MenuButton>                         m_pInsertBtn;
 
     // Middle buttons
     VclPtr<PushButton>                         m_pAddCommandButton;
diff --git a/cui/uiconfig/ui/menuassignpage.ui b/cui/uiconfig/ui/menuassignpage.ui
index 9ad40abc03c9..1a0393941fb6 100644
--- a/cui/uiconfig/ui/menuassignpage.ui
+++ b/cui/uiconfig/ui/menuassignpage.ui
@@ -149,7 +149,7 @@
                         <property name="hexpand">True</property>
                         <property name="layout_style">start</property>
                         <child>
-                          <object class="GtkButton">
+                          <object class="GtkButton" id="insert:insertmenu">
                             <property name="label" translatable="yes">Insert</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
@@ -556,6 +556,26 @@
       </packing>
     </child>
   </object>
+  <object class="GtkMenu" id="insertmenu">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkMenuItem" id="insertseparator">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Insert Separator</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuItem" id="insertsubmenu">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Insert Submenu</property>
+        <property name="use_underline">True</property>
+      </object>
+    </child>
+  </object>
   <object class="GtkSizeGroup" id="sizegroup1"/>
   <object class="GtkSizeGroup" id="sizegroup2"/>
 </interface>
commit 0114ef64fc357a0faa8b32cb1e79c0ed789d0de4
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Fri Aug 18 16:22:31 2017 +0300

    Implement Search/Filter feature in the Customize dialog
    
    Now commands in the list (left box) are filtered/updated
    in the Menu, Context Menu, and the Toolbar tabs as you type.
    
    Instead of filling the box, and then removing non-matching
    items (as in the current search feature in the keyboard tab),
    we filter out items during the Fill process, and don't add them
    to the sequence att all. This should give a performance boost
    to the filter operations.
    
    Change-Id: I473596a2c897f1cd96a7d55fd3ab11ee3db39863
    Reviewed-on: https://gerrit.libreoffice.org/41321
    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 c1abd3fe7d05..50542739c82e 100644
--- a/cui/source/customize/CommandCategoryListBox.cxx
+++ b/cui/source/customize/CommandCategoryListBox.cxx
@@ -25,15 +25,27 @@
 #include <com/sun/star/ui/theUICategoryDescription.hpp>
 #include <vcl/builderfactory.hxx>
 
+// include search util
+#include <com/sun/star/util/SearchFlags.hpp>
+#include <com/sun/star/util/SearchAlgorithms2.hpp>
+#include <unotools/textsearch.hxx>
+
 #include "dialmgr.hxx"
 #include "strings.hrc"
 #include <comphelper/sequenceashashmap.hxx>
 #include <o3tl/make_unique.hxx>
+#include <i18nutil/searchopt.hxx>
 
 CommandCategoryListBox::CommandCategoryListBox(vcl::Window* pParent, WinBits nStyle)
     : ListBox( pParent, nStyle)
 {
     SetDropDownLineCount(25);
+
+    //Initialize search util
+    m_searchOptions.AlgorithmType2 = css::util::SearchAlgorithms2::ABSOLUTE;
+    m_searchOptions.transliterateFlags |= TransliterationFlags::IGNORE_CASE;
+    m_searchOptions.searchFlag |= (css::util::SearchFlags::REG_NOT_BEGINOFLINE
+                                | css::util::SearchFlags::REG_NOT_ENDOFLINE);
 }
 
 VCL_BUILDER_FACTORY(CommandCategoryListBox);
@@ -126,11 +138,25 @@ void CommandCategoryListBox::Init(
 
 void CommandCategoryListBox::FillFunctionsList(
     const css::uno::Sequence<css::frame::DispatchInformation>& xCommands,
-    const VclPtr<SfxConfigFunctionListBox>&  pFunctionListBox)
+    const VclPtr<SfxConfigFunctionListBox>&  pFunctionListBox,
+    const OUString& filterTerm )
 {
+    // Setup search filter parameters
+    m_searchOptions.searchString = filterTerm;
+    utl::TextSearch textSearch( m_searchOptions );
+
     for (const auto & rInfo : xCommands)
     {
-        OUString sUIName = MapCommand2UIName(rInfo.Command);
+        OUString sUIName    = MapCommand2UIName(rInfo.Command);
+        sal_Int32 aStartPos = 0;
+        sal_Int32 aEndPos   = sUIName.getLength();
+
+        // Apply the search filter
+        if (!filterTerm.isEmpty()
+            && !textSearch.SearchForward( sUIName, &aStartPos, &aEndPos ) )
+        {
+            continue;
+        }
 
         SvTreeListEntry* pFuncEntry = pFunctionListBox->InsertEntry(sUIName );
 
@@ -169,7 +195,8 @@ OUString CommandCategoryListBox::MapCommand2UIName(const OUString& sCommand)
     return sUIName;
 }
 
-void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionListBox>&  pFunctionListBox )
+void CommandCategoryListBox::categorySelected(  const VclPtr<SfxConfigFunctionListBox>&  pFunctionListBox,
+                                                const OUString& filterTerm )
 {
     SfxGroupInfo_Impl *pInfo = static_cast<SfxGroupInfo_Impl*>(GetSelectEntryData());
     pFunctionListBox->SetUpdateMode(false);
@@ -195,7 +222,7 @@ void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionLis
                     {
                         lCommands = xProvider->getConfigurableDispatchInformation(
                                         pCurrentInfo->nUniqueID );
-                        FillFunctionsList( lCommands, pFunctionListBox );
+                        FillFunctionsList( lCommands, pFunctionListBox, filterTerm );
                     }
                     catch( css::container::NoSuchElementException& )
                     {
@@ -213,7 +240,7 @@ void CommandCategoryListBox::categorySelected( const VclPtr<SfxConfigFunctionLis
                 xProvider (m_xFrame, css::uno::UNO_QUERY_THROW);
             css::uno::Sequence< css::frame::DispatchInformation > lCommands =
                 xProvider->getConfigurableDispatchInformation(nGroup);
-            FillFunctionsList( lCommands, pFunctionListBox );
+            FillFunctionsList( lCommands, pFunctionListBox, filterTerm );
             break;
         }
         case SfxCfgKind::GROUP_SCRIPTCONTAINER:
diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 2c6723240fad..3d0bdff25f73 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -289,7 +289,9 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, SelectMenu, ListBox&, void )
 
 IMPL_LINK_NOARG( SvxMenuConfigPage, SelectCategory, ListBox&, void )
 {
-    m_pCommandCategoryListBox->categorySelected( m_pFunctions );
+    OUString aSearchTerm( m_pSearchEdit->GetText() );
+
+    m_pCommandCategoryListBox->categorySelected( m_pFunctions, aSearchTerm );
 }
 
 IMPL_LINK_NOARG( SvxMenuConfigPage, AddCommandHdl, Button *, void )
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index 5adc6a7f7a0b..76a29b8acced 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -321,7 +321,9 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbarEntry, SvTreeListBox *, void
 
 IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectCategory, ListBox&, void )
 {
-    m_pCommandCategoryListBox->categorySelected( m_pFunctions );
+    OUString aSearchTerm( m_pSearchEdit->GetText() );
+
+    m_pCommandCategoryListBox->categorySelected( m_pFunctions, aSearchTerm );
 }
 
 IMPL_LINK_NOARG( SvxToolbarConfigPage, AddCommandHdl, Button *, void )
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 9c339e395cbe..7883a3c13444 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -1133,6 +1133,7 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
     , m_pContentsListBox(nullptr)
     , m_pSelectorDlg(nullptr)
 {
+    get(m_pSearchEdit, "searchEntry");
     get(m_pCommandCategoryListBox, "commandcategorylist");
     get(m_pFunctions, "functions");
 
@@ -1155,6 +1156,9 @@ SvxConfigPage::SvxConfigPage(vcl::Window *pParent, const SfxItemSet& rSet)
 
     m_pDescriptionField->SetControlBackground( GetSettings().GetStyleSettings().GetDialogColor() );
     m_pDescriptionField->EnableCursor( false );
+
+    m_pSearchEdit->SetUpdateDataHdl ( LINK( this, SvxConfigPage, SearchUpdateHdl ));
+    m_pSearchEdit->EnableUpdateData();
 }
 
 SvxConfigPage::~SvxConfigPage()
@@ -1165,6 +1169,7 @@ SvxConfigPage::~SvxConfigPage()
 void SvxConfigPage::dispose()
 {
     m_pTopLevelListBox.clear();
+    m_pSearchEdit.clear();
     m_pCommandCategoryListBox.clear();
     m_pContents.clear();
     m_pEntries.clear();
@@ -1746,6 +1751,13 @@ IMPL_LINK( SvxConfigPage, MoveHdl, Button *, pButton, void )
     MoveEntry(pButton == m_pMoveUpButton);
 }
 
+IMPL_LINK_NOARG(SvxConfigPage, SearchUpdateHdl, Edit&, void)
+{
+    OUString aSearchTerm( m_pSearchEdit->GetText() );
+
+    m_pCommandCategoryListBox->categorySelected( m_pFunctions, aSearchTerm );
+}
+
 void SvxConfigPage::MoveEntry( bool bMoveUp )
 {
     SvTreeListEntry *pSourceEntry = m_pContentsListBox->FirstSelected();
diff --git a/cui/source/inc/CommandCategoryListBox.hxx b/cui/source/inc/CommandCategoryListBox.hxx
index 5afc4ce798d8..a3480af6ae48 100644
--- a/cui/source/inc/CommandCategoryListBox.hxx
+++ b/cui/source/inc/CommandCategoryListBox.hxx
@@ -20,6 +20,7 @@
 #define INCLUDED_CUI_SOURCE_INC_COMMANDCATEGORYLISTBOX_HXX
 
 #include <vcl/lstbox.hxx>
+#include <i18nutil/searchopt.hxx>
 #include "cfgutil.hxx"
 
 class CommandCategoryListBox : public ListBox
@@ -32,6 +33,9 @@ class CommandCategoryListBox : public ListBox
     css::uno::Reference< css::container::XNameAccess > m_xModuleCategoryInfo;
     css::uno::Reference< css::container::XNameAccess > m_xUICmdDescription;
 
+    // For search
+    i18nutil::SearchOptions2 m_searchOptions;
+
 public:
     CommandCategoryListBox( vcl::Window* pParent, WinBits nBits = WB_BORDER | WB_DROPDOWN );
     virtual ~CommandCategoryListBox() override;
@@ -44,7 +48,8 @@ public:
                     const OUString& sModuleLongName);
     void        FillFunctionsList(
                     const css::uno::Sequence< css::frame::DispatchInformation >& xCommands,
-                    const VclPtr<SfxConfigFunctionListBox>&  pFunctionListBox);
+                    const VclPtr<SfxConfigFunctionListBox>&  pFunctionListBox,
+                    const OUString& filterTerm = OUString() );
     OUString    MapCommand2UIName(const OUString& sCommand);
 
     /**
@@ -52,7 +57,8 @@ public:
         And updates the functions list box to include
         the commands in the selected category.
     */
-    void categorySelected( const VclPtr<SfxConfigFunctionListBox>&  pFunctionListBox );
+    void categorySelected(  const VclPtr<SfxConfigFunctionListBox>&  pFunctionListBox,
+                            const OUString& filterTerm = OUString() );
 };
 
 #endif // INCLUDED_CUI_SOURCE_INC_COMMANDCATEGORYLISTBOX_HXX
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index f05d8fa74d5c..f951acc8a137 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -379,11 +379,13 @@ private:
 
     DECL_LINK(  SelectSaveInLocation, ListBox&, void );
     DECL_LINK( AsyncInfoMsg, void*, void );
+    DECL_LINK( SearchUpdateHdl, Edit&, void );
 
 protected:
 
     // Left side of the dialog where command categories and the available
     // commands in them are displayed as a searchable list
+    VclPtr<Edit>                               m_pSearchEdit;
     VclPtr<CommandCategoryListBox>             m_pCommandCategoryListBox;
     VclPtr<SfxConfigFunctionListBox>           m_pFunctions;
 
diff --git a/cui/uiconfig/ui/menuassignpage.ui b/cui/uiconfig/ui/menuassignpage.ui
index 3eb6837c6992..9ad40abc03c9 100644
--- a/cui/uiconfig/ui/menuassignpage.ui
+++ b/cui/uiconfig/ui/menuassignpage.ui
@@ -487,10 +487,11 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkEntry">
+                      <object class="GtkEntry" id="searchEntry">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="margin_bottom">5</property>
+                        <property name="placeholder_text" translatable="yes">Type to search</property>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
commit 60d622d807f4f3bcc8a699458adf5d6690f9dc4b
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Fri Aug 18 09:56:52 2017 +0300

    Implement "Remove" button in the Customize dialog
    
    By using the already implemented DeleteSelectedContent function.
    
    Now toolbar and menu/context menu items can be removed by using
    the "Remove" (Left Arrow) button which is between the commands
    list and the enrtries list boxes.
    
    Change-Id: If445ec6d431bc10263d961563bdd204e7868b931
    Reviewed-on: https://gerrit.libreoffice.org/41272
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 8c85eb47d6b5..2c6723240fad 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -126,7 +126,7 @@ SvxMenuConfigPage::SvxMenuConfigPage(vcl::Window *pParent, const SfxItemSet& rSe
     m_pMoveDownButton->SetClickHdl ( LINK( this, SvxConfigPage, MoveHdl) );
 
     m_pAddCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, AddCommandHdl ) );
-    //m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, RemoveCommandHdl ) );
+    m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxMenuConfigPage, RemoveCommandHdl ) );
 }
 
 SvxMenuConfigPage::~SvxMenuConfigPage()
@@ -297,10 +297,14 @@ IMPL_LINK_NOARG( SvxMenuConfigPage, AddCommandHdl, Button *, void )
     AddFunction();
 }
 
-/*IMPL_LINK_NOARG( SvxMenuConfigPage, RemoveCommandHdl, Button *, void )
+IMPL_LINK_NOARG( SvxMenuConfigPage, RemoveCommandHdl, Button *, void )
 {
-    //TODO:Implement
-}*/
+    DeleteSelectedContent();
+    if ( GetSaveInData()->IsModified() )
+    {
+        UpdateButtonStates();
+    }
+}
 
 SaveInData* SvxMenuConfigPage::CreateSaveInData(
     const css::uno::Reference< css::ui::XUIConfigurationManager >& xCfgMgr,
diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index f5f6d7b7a5aa..5adc6a7f7a0b 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -136,7 +136,7 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
     m_pMoveUpButton->Enable();
 
     m_pAddCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, AddCommandHdl ) );
-    //m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, RemoveCommandHdl ) );
+    m_pRemoveCommandButton->SetClickHdl( LINK( this, SvxToolbarConfigPage, RemoveCommandHdl ) );
 
     // default toolbar to select is standardbar unless a different one
     // has been passed in
@@ -329,10 +329,10 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, AddCommandHdl, Button *, void )
     AddFunction();
 }
 
-/*IMPL_LINK_NOARG( SvxToolbarConfigPage, RemoveCommandHdl, Button *, void )
+IMPL_LINK_NOARG( SvxToolbarConfigPage, RemoveCommandHdl, Button *, void )
 {
-    //TODO:Implement
-}*/
+    DeleteSelectedContent();
+}
 
 
 void SvxToolbarConfigPage::UpdateButtonStates()
diff --git a/cui/source/inc/SvxMenuConfigPage.hxx b/cui/source/inc/SvxMenuConfigPage.hxx
index 9110edeeaf9d..162adc94c198 100644
--- a/cui/source/inc/SvxMenuConfigPage.hxx
+++ b/cui/source/inc/SvxMenuConfigPage.hxx
@@ -57,7 +57,7 @@ private:
     DECL_LINK( SelectCategory, ListBox&, void );
 
     DECL_LINK( AddCommandHdl, Button *, void );
-    //DECL_LINK( RemoveCommandHdl, Button *, void );
+    DECL_LINK( RemoveCommandHdl, Button *, void );
 
     void            Init() override;
     void            UpdateButtonStates() override;
diff --git a/cui/source/inc/SvxToolbarConfigPage.hxx b/cui/source/inc/SvxToolbarConfigPage.hxx
index e4721553477f..29e48078b596 100644
--- a/cui/source/inc/SvxToolbarConfigPage.hxx
+++ b/cui/source/inc/SvxToolbarConfigPage.hxx
@@ -58,7 +58,7 @@ private:
     DECL_LINK( SelectCategory, ListBox&, void );
 
     DECL_LINK( AddCommandHdl, Button *, void );
-    //DECL_LINK( RemoveCommandHdl, Button *, void );
+    DECL_LINK( RemoveCommandHdl, Button *, void );
 
     void            UpdateButtonStates() override;
     short           QueryReset() override;
commit c525dc764114f45ec9ff33837e8ae7cb74ce72b1
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Thu Aug 17 06:48:08 2017 +0300

    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 at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index e0a0a9801682..8c85eb47d6b5 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 55240bf1a0d5..f5f6d7b7a5aa 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 7513fcf2d42c..9c339e395cbe 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 73165ed140f7..9110edeeaf9d 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 21d63fbe81ff..e4721553477f 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 0035e86aa047..f05d8fa74d5c 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
commit 3e4de4d63c897fdaa885909f7abb1b3f111458d2
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Sun Aug 13 07:36:46 2017 +0300

    Initialize and update command categories and functions for the Toolbar tab
    
    Change-Id: I27a12fc9e337796fc153e1d243eeba37564ef5c1
    Reviewed-on: https://gerrit.libreoffice.org/41104
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/cui/source/customize/SvxToolbarConfigPage.cxx b/cui/source/customize/SvxToolbarConfigPage.cxx
index ef6f2969f9c7..55240bf1a0d5 100644
--- a/cui/source/customize/SvxToolbarConfigPage.cxx
+++ b/cui/source/customize/SvxToolbarConfigPage.cxx
@@ -125,6 +125,8 @@ SvxToolbarConfigPage::SvxToolbarConfigPage(vcl::Window *pParent, const SfxItemSe
         LINK( this, SvxToolbarConfigPage, SelectToolbar ) );
     m_pContentsListBox->SetSelectHdl(
         LINK( this, SvxToolbarConfigPage, SelectToolbarEntry ) );
+    m_pCommandCategoryListBox->SetSelectHdl(
+        LINK( this, SvxToolbarConfigPage, SelectCategory ) );
 
     m_pMoveUpButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) );
     m_pMoveDownButton->SetClickHdl ( LINK( this, SvxToolbarConfigPage, MoveHdl) );
@@ -291,6 +293,12 @@ void SvxToolbarConfigPage::Init()
 
     m_pTopLevelListBox->SelectEntryPos(nPos);
     m_pTopLevelListBox->GetSelectHdl().Call(*m_pTopLevelListBox);
+
+    m_pCommandCategoryListBox->Init(
+        comphelper::getProcessComponentContext(),
+        m_xFrame,
+        vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame));
+    m_pCommandCategoryListBox->categorySelected( m_pFunctions );
 }
 
 SaveInData* SvxToolbarConfigPage::CreateSaveInData(
@@ -308,6 +316,12 @@ IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectToolbarEntry, SvTreeListBox *, void
     UpdateButtonStates();
 }
 
+IMPL_LINK_NOARG( SvxToolbarConfigPage, SelectCategory, ListBox&, void )
+{
+    m_pCommandCategoryListBox->categorySelected( m_pFunctions );
+}
+
+
 void SvxToolbarConfigPage::UpdateButtonStates()
 {
     m_pDescriptionField->SetText("");
diff --git a/cui/source/inc/SvxToolbarConfigPage.hxx b/cui/source/inc/SvxToolbarConfigPage.hxx
index 02a23979865e..21d63fbe81ff 100644
--- a/cui/source/inc/SvxToolbarConfigPage.hxx
+++ b/cui/source/inc/SvxToolbarConfigPage.hxx
@@ -56,6 +56,8 @@ private:
     DECL_LINK( AddFunctionHdl, SvxScriptSelectorDialog&, void );
     DECL_LINK( MoveHdl, Button *, void );
 
+    DECL_LINK( SelectCategory, ListBox&, void );
+
     void            UpdateButtonStates() override;
     short           QueryReset() override;
     void            Init() override;
commit 3652f6624528abcb5bcba3b637232d1422242eb3
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 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 @@

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list