include/vcl/layout.hxx              |   13 +----------
 include/vcl/toolkit/treelistbox.hxx |    2 -
 include/vcl/window.hxx              |    1 
 svx/source/dialog/charmap.cxx       |    2 -
 svx/source/dialog/searchcharmap.cxx |   41 ++----------------------------------
 vcl/inc/salvtables.hxx              |    3 --
 vcl/inc/window.h                    |    1 
 vcl/source/app/salvtables.cxx       |   27 ++++++-----------------
 vcl/source/treelist/treelistbox.cxx |    3 +-
 vcl/source/window/window.cxx        |    9 +++++++
 10 files changed, 27 insertions(+), 75 deletions(-)

New commits:
commit 0fe9cd48b8b726eac40a03a2d0b82ae4faa9b8e5
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Dec 11 10:57:13 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Dec 12 13:26:39 2025 +0100

    svx: Move more SvxSearchCharSet::KeyInput logic to base class
    
    Adjust the handling of the KEY_END case in the base
    class to also cover the logic previously implemented
    in SvxSearchCharSet::KeyInput.
    
    SvxShowCharSet::getMaxCharCount returns
    `mxFontCharMap->GetCharCount()`, so calling the former
    is equivalent for the base class and covers the
    logic previously only implemented in the subclass.
    
    With that in place, only the default case is still
    handled in SvxSearchCharSet::KeyInput itself, meaning
    that `tmpSelected` will always be -1 and the logic
    further down will never be triggered. Drop it and
    simplify accordingly.
    
    Change-Id: Ib9cf60eaba44f6745b4897ec1dfa53d581f3ae37
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195492
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx
index cfa6ee3742a8..ce2435ca3219 100644
--- a/svx/source/dialog/charmap.cxx
+++ b/svx/source/dialog/charmap.cxx
@@ -422,7 +422,7 @@ bool SvxShowCharSet::KeyInput(const KeyEvent& rKEvt)
             tmpSelected = 0;
             break;
         case KEY_END:
-            tmpSelected = mxFontCharMap->GetCharCount() - 1;
+            tmpSelected = getMaxCharCount() - 1;
             break;
         case KEY_TAB:   // some fonts have a character at these unicode 
control codes
         case KEY_ESCAPE:
diff --git a/svx/source/dialog/searchcharmap.cxx 
b/svx/source/dialog/searchcharmap.cxx
index 625fdf74321a..3de2ad4e3fe2 100644
--- a/svx/source/dialog/searchcharmap.cxx
+++ b/svx/source/dialog/searchcharmap.cxx
@@ -53,10 +53,6 @@ bool SvxSearchCharSet::KeyInput(const KeyEvent& rKEvt)
     if (aCode.GetModifier())
         return false;
 
-    int tmpSelected = mnSelectedIndex;
-
-    bool bRet = true;
-
     switch (aCode.GetCode())
     {
         case KEY_RETURN:
@@ -68,25 +64,13 @@ bool SvxSearchCharSet::KeyInput(const KeyEvent& rKEvt)
         case KEY_PAGEUP:
         case KEY_PAGEDOWN:
         case KEY_HOME:
+        case KEY_END:
         case KEY_TAB:
         case KEY_ESCAPE:
             return SvxShowCharSet::KeyInput(rKEvt);
-        case KEY_END:
-            tmpSelected = getMaxCharCount() - 1;
-            break;
         default:
-            tmpSelected = -1;
-            bRet = false;
-            break;
+            return false;
     }
-
-    if ( tmpSelected >= 0 )
-    {
-        SelectIndex( tmpSelected, true );
-        maPreSelectHdl.Call(*this);
-    }
-
-    return bRet;
 }
 
 void SvxSearchCharSet::SelectCharacter( const Subset* sub )
commit d6ae8d86fc5b81e46adfb036ca00521b4fe59dbd
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Dec 11 10:51:07 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Dec 12 13:26:32 2025 +0100

    svx: Deduplicate SvxSearchCharSet::KeyInput with base class
    
    The base class implementation in SvxShowCharSet::KeyInput
    does the same for those cases, so just call that one
    instead of duplicating the logic here.
    
    Change-Id: I5929cf814c1b0bce273da938161c7a798adff654
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195491
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/svx/source/dialog/searchcharmap.cxx 
b/svx/source/dialog/searchcharmap.cxx
index 27974c8c75d9..625fdf74321a 100644
--- a/svx/source/dialog/searchcharmap.cxx
+++ b/svx/source/dialog/searchcharmap.cxx
@@ -60,39 +60,20 @@ bool SvxSearchCharSet::KeyInput(const KeyEvent& rKEvt)
     switch (aCode.GetCode())
     {
         case KEY_RETURN:
-            return SvxShowCharSet::KeyInput(rKEvt);
         case KEY_SPACE:
-            maDoubleClkHdl.Call(*this);
-            return true;
         case KEY_LEFT:
-            --tmpSelected;
-            break;
         case KEY_RIGHT:
-            ++tmpSelected;
-            break;
         case KEY_UP:
-            tmpSelected -= COLUMN_COUNT;
-            break;
         case KEY_DOWN:
-            tmpSelected += COLUMN_COUNT;
-            break;
         case KEY_PAGEUP:
-            tmpSelected -= ROW_COUNT * COLUMN_COUNT;
-            break;
         case KEY_PAGEDOWN:
-            tmpSelected += ROW_COUNT * COLUMN_COUNT;
-            break;
         case KEY_HOME:
-            tmpSelected = 0;
-            break;
+        case KEY_TAB:
+        case KEY_ESCAPE:
+            return SvxShowCharSet::KeyInput(rKEvt);
         case KEY_END:
             tmpSelected = getMaxCharCount() - 1;
             break;
-        case KEY_TAB:   // some fonts have a character at these unicode 
control codes
-        case KEY_ESCAPE:
-            bRet = false;
-            tmpSelected = - 1;  // mark as invalid
-            break;
         default:
             tmpSelected = -1;
             bRet = false;
commit 121357b9016701803004d955af8e2bf72ba75163
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Dec 11 02:10:51 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Dec 12 13:26:25 2025 +0100

    tdf#130857 vcl weld: Forward context menu events for all widgets
    
    This is basically the vcl/SalInstanceWidget version of previous
    commit
    
        Change-Id: I07c5f136cc1671e1e0ca0ee3df11d2d9febc654a
        Author: Michael Weghorn <[email protected]>
        Date:   Thu Dec 11 00:45:42 2025 +0100
    
            tdf#130857 qt weld: Forward context menu events for all widgets
    
    and allows handling ContextMenu events for all weld::Widget
    subclasses, as demonstrated e.g. by the scenario described
    in the above-mentioned commit, which now also works with
    the vcl implementation, tested with the gen VCL plugin on
    Linux.
    
    Change-Id: Ic3d46657f50ad897fa22095c69fe121c2eaaed98
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195420
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index c42802cc328d..8b85b17725aa 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -631,7 +631,6 @@ private:
     Link<const KeyEvent&, bool> m_aKeyPressHdl;
     Link<const KeyEvent&, bool> m_aKeyReleaseHdl;
     Link<VclDrawingArea&, void> m_aStyleUpdatedHdl;
-    Link<const CommandEvent&, bool> m_aCommandHdl;
     Link<tools::Rectangle&, OUString> m_aQueryTooltipHdl;
     Link<OUString&, int> m_aGetSurroundingHdl;
     Link<const Selection&, bool> m_aDeleteSurroundingHdl;
@@ -674,12 +673,7 @@ private:
             Invalidate();
         }
     }
-    virtual void Command(const CommandEvent& rEvent) override
-    {
-        if (m_aCommandHdl.Call(rEvent))
-            return;
-        Control::Command(rEvent);
-    }
+
     virtual void RequestHelp(const HelpEvent& rHelpEvent) override;
     virtual void StartDrag(sal_Int8 nAction, const Point& rPosPixel) override;
     virtual FactoryFunction GetUITestFactory() const override;
@@ -753,10 +747,7 @@ public:
     {
         m_aStyleUpdatedHdl = rLink;
     }
-    void SetCommandHdl(const Link<const CommandEvent&, bool>& rLink)
-    {
-        m_aCommandHdl = rLink;
-    }
+
     void SetQueryTooltipHdl(const Link<tools::Rectangle&, OUString>& rLink)
     {
         m_aQueryTooltipHdl = rLink;
diff --git a/include/vcl/toolkit/treelistbox.hxx 
b/include/vcl/toolkit/treelistbox.hxx
index 22a995a35178..7e86a5aa74b1 100644
--- a/include/vcl/toolkit/treelistbox.hxx
+++ b/include/vcl/toolkit/treelistbox.hxx
@@ -198,7 +198,6 @@ class UNLESS_MERGELIBS_MORE(VCL_DLLPUBLIC) SvTreeListBox
     Link<SvTreeListBox*,bool>  aExpandingHdl;
     Link<SvTreeListBox*,void>  aSelectHdl;
     Link<SvTreeListBox*,void>  aDeselectHdl;
-    Link<const CommandEvent&, bool> aPopupMenuHdl;
     Link<SvTreeListEntry*, OUString> aTooltipHdl;
     Link<svtree_render_args, void> aCustomRenderHdl;
     Link<svtree_measure_args, Size> aCustomMeasureHdl;
@@ -411,7 +410,6 @@ public:
     void            SetDoubleClickHdl(const Link<SvTreeListBox*,bool>& 
rNewHdl) {aDoubleClickHdl=rNewHdl;}
     void            SetExpandingHdl(const Link<SvTreeListBox*,bool>& 
rNewHdl){aExpandingHdl=rNewHdl;}
     void            SetExpandedHdl(const Link<SvTreeListBox*,void>& 
rNewHdl){aExpandedHdl=rNewHdl;}
-    void SetPopupMenuHdl(const Link<const CommandEvent&, bool>& rLink) { 
aPopupMenuHdl = rLink; }
     void SetTooltipHdl(const Link<SvTreeListEntry*, OUString>& rLink) { 
aTooltipHdl = rLink; }
     void SetCustomRenderHdl(const Link<svtree_render_args, void>& rLink) { 
aCustomRenderHdl = rLink; }
     void SetCustomMeasureHdl(const Link<svtree_measure_args, Size>& rLink) { 
aCustomMeasureHdl = rLink; }
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 8369693dd05f..a52a1ed59f0d 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1459,6 +1459,7 @@ public:
     virtual bool IsChart() const { return false; }
     virtual bool IsStarMath() const { return false; }
 
+    SAL_DLLPRIVATE void SetCommandHdl(const Link<const CommandEvent&, bool>& 
rLink);
     SAL_DLLPRIVATE void SetHelpHdl(const Link<vcl::Window&, bool>& rLink);
     SAL_DLLPRIVATE void SetMnemonicActivateHdl(const Link<vcl::Window&, bool>& 
rLink);
     void SetModalHierarchyHdl(const Link<bool, void>& rLink);
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 875eb912c9da..da289d302845 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -192,6 +192,7 @@ protected:
 
 private:
     DECL_LINK(EventListener, VclWindowEvent&, void);
+    DECL_LINK(CommandHdl, const CommandEvent&, bool);
     DECL_LINK(KeyEventListener, VclWindowEvent&, bool);
     DECL_LINK(MouseEventListener, VclWindowEvent&, void);
     DECL_LINK(SettingsChangedHdl, VclWindowEvent&, void);
@@ -1508,7 +1509,6 @@ protected:
     DECL_LINK(EditedEntryHdl, const IterString&, bool);
     DECL_LINK(VisibleRangeChangedHdl, SvTreeListBox*, void);
     DECL_LINK(CompareHdl, const SvSortData&, sal_Int32);
-    DECL_LINK(PopupMenuHdl, const CommandEvent&, bool);
     DECL_LINK(TooltipHdl, SvTreeListEntry*, OUString);
     DECL_LINK(CustomRenderHdl, svtree_render_args, void);
     DECL_LINK(CustomMeasureHdl, svtree_measure_args, Size);
@@ -1893,7 +1893,6 @@ private:
     DECL_LINK(SelectHdl, SvTreeListBox*, void);
     DECL_LINK(DeSelectHdl, SvTreeListBox*, void);
     DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool);
-    DECL_LINK(CommandHdl, const CommandEvent&, bool);
     DECL_LINK(TooltipHdl, SvTreeListEntry*, OUString);
     DECL_LINK(DumpImageHdl, const ::IconView::encoded_image_query&, bool);
 
diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 3173eac28712..6d21cf618f03 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -253,6 +253,7 @@ public:
     std::vector<Link<VclWindowEvent&,void>> maChildEventListeners;
     int mnChildEventListenersIteratingCount;
     std::set<Link<VclWindowEvent&,void>> maChildEventListenersDeleted;
+    Link<const CommandEvent&, bool> maCommandHdl;
     Link<vcl::Window&, bool> maHelpRequestHdl;
     Link<vcl::Window&, bool> maMnemonicActivateHdl;
     Link<tools::JsonWriter&, void> maDumpAsPropertyTreeHdl;
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 936ececfda44..1d2d44ffbfa3 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -368,6 +368,7 @@ SalInstanceWidget::SalInstanceWidget(vcl::Window* pWidget, 
SalInstanceBuilder* p
     , m_bMouseEventListener(false)
     , m_nFreezeCount(0)
 {
+    m_xWidget->SetCommandHdl(LINK(this, SalInstanceWidget, CommandHdl));
 }
 
 void SalInstanceWidget::set_sensitive(bool sensitive) { 
m_xWidget->Enable(sensitive); }
@@ -635,6 +636,7 @@ void SalInstanceWidget::queue_resize() { 
m_xWidget->queue_resize(); }
 
 SalInstanceWidget::~SalInstanceWidget()
 {
+    m_xWidget->SetCommandHdl(Link<const CommandEvent&, bool>());
     if (m_aStyleUpdatedHdl.IsSet())
         m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, 
SettingsChangedHdl));
     if (m_aMnemonicActivateHdl.IsSet())
@@ -811,6 +813,11 @@ IMPL_LINK(SalInstanceWidget, EventListener, 
VclWindowEvent&, rEvent, void)
     HandleEventListener(rEvent);
 }
 
+IMPL_LINK(SalInstanceWidget, CommandHdl, const CommandEvent&, rEvent, bool)
+{
+    return signal_command(rEvent);
+}
+
 IMPL_LINK(SalInstanceWidget, KeyEventListener, VclWindowEvent&, rEvent, bool)
 {
     return HandleKeyEventListener(rEvent);
@@ -3744,7 +3751,6 @@ SalInstanceTreeView::SalInstanceTreeView(SvTabListBox* 
pTreeView, SalInstanceBui
     m_xTreeView->SetDeselectHdl(LINK(this, SalInstanceTreeView, DeSelectHdl));
     m_xTreeView->SetDoubleClickHdl(LINK(this, SalInstanceTreeView, 
DoubleClickHdl));
     m_xTreeView->SetExpandingHdl(LINK(this, SalInstanceTreeView, 
ExpandingHdl));
-    m_xTreeView->SetPopupMenuHdl(LINK(this, SalInstanceTreeView, 
PopupMenuHdl));
     m_xTreeView->SetCustomRenderHdl(LINK(this, SalInstanceTreeView, 
CustomRenderHdl));
     m_xTreeView->SetCustomMeasureHdl(LINK(this, SalInstanceTreeView, 
CustomMeasureHdl));
     const std::vector<tools::Long> aTabPositions{ 0 };
@@ -5018,7 +5024,6 @@ SalInstanceTreeView::~SalInstanceTreeView()
     }
     if (g_DragSource == this)
         g_DragSource = nullptr;
-    m_xTreeView->SetPopupMenuHdl(Link<const CommandEvent&, bool>());
     m_xTreeView->SetExpandingHdl(Link<SvTreeListBox*, bool>());
     m_xTreeView->SetDoubleClickHdl(Link<SvTreeListBox*, bool>());
     m_xTreeView->SetSelectHdl(Link<SvTreeListBox*, void>());
@@ -5234,11 +5239,6 @@ bool SalInstanceTreeView::ExpandRow(const 
SalInstanceTreeIter& rIter)
     return bRet;
 }
 
-IMPL_LINK(SalInstanceTreeView, PopupMenuHdl, const CommandEvent&, rEvent, bool)
-{
-    return signal_command(rEvent);
-}
-
 IMPL_LINK(SalInstanceTreeView, EditingEntryHdl, SvTreeListEntry*, pEntry, bool)
 {
     return signal_editing_started(SalInstanceTreeIter(pEntry));
@@ -5258,7 +5258,6 @@ SalInstanceIconView::SalInstanceIconView(::IconView* 
pIconView, SalInstanceBuild
     m_xIconView->SetSelectHdl(LINK(this, SalInstanceIconView, SelectHdl));
     m_xIconView->SetDeselectHdl(LINK(this, SalInstanceIconView, DeSelectHdl));
     m_xIconView->SetDoubleClickHdl(LINK(this, SalInstanceIconView, 
DoubleClickHdl));
-    m_xIconView->SetPopupMenuHdl(LINK(this, SalInstanceIconView, CommandHdl));
 }
 
 int SalInstanceIconView::get_item_width() const { return 
m_xIconView->GetEntryWidth(); }
@@ -5627,11 +5626,6 @@ IMPL_LINK_NOARG(SalInstanceIconView, DoubleClickHdl, 
SvTreeListBox*, bool)
     return !signal_item_activated();
 }
 
-IMPL_LINK(SalInstanceIconView, CommandHdl, const CommandEvent&, rEvent, bool)
-{
-    return signal_command(rEvent);
-}
-
 SalInstanceSpinButton::SalInstanceSpinButton(FormattedField* pButton, 
SalInstanceBuilder* pBuilder,
                                              bool bTakeOwnership)
     : SalInstanceEntry(pButton, pBuilder, bTakeOwnership)
@@ -6083,7 +6077,6 @@ 
SalInstanceDrawingArea::SalInstanceDrawingArea(VclDrawingArea* pDrawingArea,
     m_xDrawingArea->SetKeyPressHdl(LINK(this, SalInstanceDrawingArea, 
KeyPressHdl));
     m_xDrawingArea->SetKeyReleaseHdl(LINK(this, SalInstanceDrawingArea, 
KeyReleaseHdl));
     m_xDrawingArea->SetStyleUpdatedHdl(LINK(this, SalInstanceDrawingArea, 
StyleUpdatedHdl));
-    m_xDrawingArea->SetCommandHdl(LINK(this, SalInstanceDrawingArea, 
CommandHdl));
     m_xDrawingArea->SetQueryTooltipHdl(LINK(this, SalInstanceDrawingArea, 
QueryTooltipHdl));
     m_xDrawingArea->SetGetSurroundingHdl(LINK(this, SalInstanceDrawingArea, 
GetSurroundingHdl));
     m_xDrawingArea->SetDeleteSurroundingHdl(
@@ -6194,7 +6187,6 @@ SalInstanceDrawingArea::~SalInstanceDrawingArea()
     m_xDrawingArea->SetDeleteSurroundingHdl(Link<const Selection&, bool>());
     m_xDrawingArea->SetGetSurroundingHdl(Link<OUString&, int>());
     m_xDrawingArea->SetQueryTooltipHdl(Link<tools::Rectangle&, OUString>());
-    m_xDrawingArea->SetCommandHdl(Link<const CommandEvent&, bool>());
     m_xDrawingArea->SetStyleUpdatedHdl(Link<VclDrawingArea&, void>());
     m_xDrawingArea->SetMousePressHdl(Link<const MouseEvent&, bool>());
     m_xDrawingArea->SetMouseMoveHdl(Link<const MouseEvent&, bool>());
@@ -6296,11 +6288,6 @@ IMPL_LINK_NOARG(SalInstanceDrawingArea, StyleUpdatedHdl, 
VclDrawingArea&, void)
     m_aStyleUpdatedHdl.Call(*this);
 }
 
-IMPL_LINK(SalInstanceDrawingArea, CommandHdl, const CommandEvent&, rEvent, 
bool)
-{
-    return signal_command(rEvent);
-}
-
 IMPL_LINK(SalInstanceDrawingArea, GetSurroundingHdl, OUString&, rSurrounding, 
int)
 {
     return m_aGetSurroundingHdl.Call(rSurrounding);
diff --git a/vcl/source/treelist/treelistbox.cxx 
b/vcl/source/treelist/treelistbox.cxx
index 1ebe7f643343..d43e3e51f67b 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -45,6 +45,7 @@
 #include <vcl/toolkit/viewdataentry.hxx>
 #include <accel.hxx>
 #include <svimpbox.hxx>
+#include <window.h>
 
 #include <set>
 #include <string.h>
@@ -3288,7 +3289,7 @@ void SvTreeListBox::SetHighlightRange( sal_uInt16 nStart, 
sal_uInt16 nEnd)
 
 void SvTreeListBox::Command(const CommandEvent& rCEvt)
 {
-    if (!aPopupMenuHdl.Call(rCEvt))
+    if (!ImplGetWindowImpl()->maCommandHdl.Call(rCEvt))
         pImpl->Command(rCEvt);
     //pass at least alt press/release to parent impl
     if (rCEvt.GetCommand() == CommandEventId::ModKeyChange)
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index de3b96718527..edff345c6ab0 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -1860,6 +1860,12 @@ void Window::LoseFocus()
     CompatNotify( aNEvt );
 }
 
+void Window::SetCommandHdl(const Link<const CommandEvent&, bool>& rLink)
+{
+    if (mpWindowImpl)
+        mpWindowImpl->maCommandHdl = rLink;
+}
+
 void Window::SetHelpHdl(const Link<vcl::Window&, bool>& rLink)
 {
     if (mpWindowImpl) // may be called after dispose
@@ -1924,6 +1930,9 @@ void Window::RequestHelp( const HelpEvent& rHEvt )
 
 void Window::Command( const CommandEvent& rCEvt )
 {
+    if (mpWindowImpl && mpWindowImpl->maCommandHdl.Call(rCEvt))
+        return;
+
     CallEventListeners( VclEventId::WindowCommand, const_cast<CommandEvent 
*>(&rCEvt) );
 
     NotifyEvent aNEvt( NotifyEventType::COMMAND, this, &rCEvt );

Reply via email to