cui/source/customize/SvxNotebookbarConfigPage.cxx |   20 ++++++++++++++------
 cui/source/inc/SvxNotebookbarConfigPage.hxx       |    5 +++++
 2 files changed, 19 insertions(+), 6 deletions(-)

New commits:
commit 6524b8efecaab39486f54d8b95a4e124d1482b08
Author:     Jim Raykowski <[email protected]>
AuthorDate: Thu Mar 23 12:50:49 2023 -0800
Commit:     Adolfo Jayme Barrientos <[email protected]>
CommitDate: Mon Mar 27 09:19:50 2023 +0000

    tdf#154296 Fix customize notebook bar regression
    
    caused by commit e79741488cc740f49ebd4426c40b45e7139ff663
    
    Change-Id: I04fe66124af831c73834b7f695458e1667198ddb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149470
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <[email protected]>
    (cherry picked from commit 48b7cf3182cc8fb0b728860f9cbb489390074101)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149600
    Tested-by: Adolfo Jayme Barrientos <[email protected]>
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>

diff --git a/cui/source/customize/SvxNotebookbarConfigPage.cxx 
b/cui/source/customize/SvxNotebookbarConfigPage.cxx
index 91ce6352ddca..319cfb9ece5e 100644
--- a/cui/source/customize/SvxNotebookbarConfigPage.cxx
+++ b/cui/source/customize/SvxNotebookbarConfigPage.cxx
@@ -240,7 +240,7 @@ void 
SvxConfigPage::InsertEntryIntoNotebookbarTabUI(std::u16string_view sClassId
         if (xImage.is())
             rTreeView.set_image(rIter, xImage, -1);
         rTreeView.set_text(rIter, aName, 0);
-        rTreeView.set_id(rIter, sUIItemCommand);
+        rTreeView.set_id(rIter, sUIItemId);
     }
 }
 
@@ -435,6 +435,7 @@ void SvxNotebookbarConfigPage::SelectElement()
 
     aEntries = std::move(aTempEntries);
 
+    
static_cast<SvxNotebookbarEntriesListBox*>(m_xContentsListBox.get())->GetTooltipMap().clear();
     weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
     rTreeView.bulk_insert_for_each(
         aEntries.size(), [this, &rTreeView, &aEntries](weld::TreeIter& rIter, 
int nIdx) {
@@ -451,6 +452,13 @@ void SvxNotebookbarConfigPage::SelectElement()
             }
             InsertEntryIntoNotebookbarTabUI(aEntries[nIdx].sClassId, 
aEntries[nIdx].sDisplayName,
                                             aEntries[nIdx].sActionName, 
rTreeView, rIter);
+            if (aEntries[nIdx].sClassId != u"GtkSeparatorMenuItem"
+                && aEntries[nIdx].sClassId != u"GtkSeparator")
+            {
+                
static_cast<SvxNotebookbarEntriesListBox*>(m_xContentsListBox.get())
+                    ->GetTooltipMap()[aEntries[nIdx].sDisplayName]
+                    = aEntries[nIdx].sActionName;
+            }
         });
 
     aEntries.clear();
@@ -543,16 +551,16 @@ IMPL_LINK(SvxNotebookbarEntriesListBox, KeyInputHdl, 
const KeyEvent&, rKeyEvent,
 
 IMPL_LINK(SvxNotebookbarEntriesListBox, QueryTooltip, const weld::TreeIter&, 
rIter, OUString)
 {
-    OUString sCommand = m_xControl->get_id(rIter);
-    if (sCommand.isEmpty())
+    const OUString& rsCommand = m_aTooltipMap[m_xControl->get_id(rIter)];
+    if (rsCommand.isEmpty())
         return OUString();
     OUString 
aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(m_pPage->GetFrame()));
-    auto aProperties = 
vcl::CommandInfoProvider::GetCommandProperties(sCommand, aModuleName);
-    OUString sTooltipLabel = 
vcl::CommandInfoProvider::GetTooltipForCommand(sCommand, aProperties,
+    auto aProperties = 
vcl::CommandInfoProvider::GetCommandProperties(rsCommand, aModuleName);
+    OUString sTooltipLabel = 
vcl::CommandInfoProvider::GetTooltipForCommand(rsCommand, aProperties,
                                                                             
m_pPage->GetFrame());
     return CuiResId(RID_CUISTR_COMMANDLABEL) + ": "
            + m_xControl->get_text(rIter).replaceFirst("~", "") + "\n"
-           + CuiResId(RID_CUISTR_COMMANDNAME) + ": " + sCommand + "\n"
+           + CuiResId(RID_CUISTR_COMMANDNAME) + ": " + rsCommand + "\n"
            + CuiResId(RID_CUISTR_COMMANDTIP) + ": " + 
sTooltipLabel.replaceFirst("~", "");
 }
 
diff --git a/cui/source/inc/SvxNotebookbarConfigPage.hxx 
b/cui/source/inc/SvxNotebookbarConfigPage.hxx
index 2f239161dfb6..672d2e8299e4 100644
--- a/cui/source/inc/SvxNotebookbarConfigPage.hxx
+++ b/cui/source/inc/SvxNotebookbarConfigPage.hxx
@@ -74,6 +74,9 @@ public:
 
 class SvxNotebookbarEntriesListBox final : public SvxMenuEntriesListBox
 {
+    typedef std::unordered_map<OUString, OUString> TooltipMap;
+    TooltipMap m_aTooltipMap;
+
     void ChangedVisibility(int nRow);
     DECL_LINK(CheckButtonHdl, const weld::TreeView::iter_col&, void);
     DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
@@ -82,6 +85,8 @@ class SvxNotebookbarEntriesListBox final : public 
SvxMenuEntriesListBox
 public:
     SvxNotebookbarEntriesListBox(std::unique_ptr<weld::TreeView> xControl, 
SvxConfigPage* pPg);
     virtual ~SvxNotebookbarEntriesListBox() override;
+
+    TooltipMap& GetTooltipMap() { return m_aTooltipMap; }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to