sw/inc/AnnotationWin.hxx                        |    3 ++-
 sw/source/uibase/docvw/AnnotationMenuButton.cxx |    5 +----
 sw/source/uibase/docvw/AnnotationWin.cxx        |    2 ++
 sw/source/uibase/docvw/AnnotationWin2.cxx       |    4 ++--
 4 files changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 8b7650f6fd7b6e4442e16eb930a5cfc4c61773a3
Author:     Michael Weghorn <[email protected]>
AuthorDate: Wed Dec 10 12:36:55 2025 +0100
Commit:     Adolfo Jayme Barrientos <[email protected]>
CommitDate: Fri Dec 12 04:18:15 2025 +0100

    tdf#167385 sw: Keep AnnotationWin menu up to date
    
    Since
    
        commit f075fa01cb4f74185f13eb0a8d7f84cf1f47af49
        Author: Michael Weghorn <[email protected]>
        Date:   Tue Aug 22 10:26:32 2023 +0200
    
            tdf#141101 tdf#101886 a11y: Restore previous focus on col/line 
popup close
    
    , the menu button toggled handler is no more called before
    the menu shows (at least for the vcl/SalInstanceMenuButton
    implementation).
    
    Therefore, instead of relying on that handler, update the
    menu when initializing the AnnotationWin controls and in
    SwAnnotationWin::UpdateData instead, to make sure it stays
    up to date.
    
    Change-Id: I0fe42b633679488fa0d9262c8a840fbe0b93f76a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195376
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>
    (cherry picked from commit 9c9357a350d8e4ca532af36ea26a2fd90e6c9257)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195485
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>

diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index c1ac7c4c9598..9e0cf0ba1884 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -215,10 +215,11 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public 
InterimItemWindow
         virtual void Paint(vcl::RenderContext& rRenderContext, const 
tools::Rectangle& rRect) override;
         void        SetSizePixel( const Size& rNewSize ) override;
 
+        void UpdateMenu();
+
         DECL_DLLPRIVATE_LINK(ModifyHdl, LinkParamNone*, void);
         DECL_DLLPRIVATE_LINK(ScrollHdl, weld::ScrolledWindow&, void);
         DECL_DLLPRIVATE_LINK(DeleteHdl, void*, void);
-        DECL_DLLPRIVATE_LINK(ToggleHdl, weld::Toggleable&, void);
         DECL_DLLPRIVATE_LINK(SelectHdl, const OUString&, void);
         DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent&, bool);
         DECL_DLLPRIVATE_LINK(MouseMoveHdl, const MouseEvent&, bool);
diff --git a/sw/source/uibase/docvw/AnnotationMenuButton.cxx 
b/sw/source/uibase/docvw/AnnotationMenuButton.cxx
index 5dbe5f07beae..2db79c324d69 100644
--- a/sw/source/uibase/docvw/AnnotationMenuButton.cxx
+++ b/sw/source/uibase/docvw/AnnotationMenuButton.cxx
@@ -63,11 +63,8 @@ IMPL_LINK(SwAnnotationWin, SelectHdl, const OUString&, 
rIdent, void)
     GrabFocusToDocument();
 }
 
-IMPL_LINK_NOARG(SwAnnotationWin, ToggleHdl, weld::Toggleable&, void)
+void SwAnnotationWin::UpdateMenu()
 {
-    if (!mxMenuButton->get_active())
-        return;
-
     bool bReadOnly = IsReadOnly();
     if (bReadOnly)
     {
diff --git a/sw/source/uibase/docvw/AnnotationWin.cxx 
b/sw/source/uibase/docvw/AnnotationWin.cxx
index d38950ad9547..6d463fc7dcd4 100644
--- a/sw/source/uibase/docvw/AnnotationWin.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin.cxx
@@ -385,6 +385,8 @@ void SwAnnotationWin::UpdateData()
         else
             mpFormatField->Broadcast(SwFormatFieldHint( nullptr, 
SwFormatFieldHintWhich::CHANGED));
         mrView.GetDocShell()->SetModified();
+
+        UpdateMenu();
     }
     mpOutliner->ClearModifyFlag();
     mpOutliner->GetUndoManager().Clear();
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx 
b/sw/source/uibase/docvw/AnnotationWin2.cxx
index 4f2200896d75..5798e81485a3 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -402,8 +402,6 @@ void SwAnnotationWin::InitControls()
     
mxMenuButton->set_accessible_name(SwResId(STR_ACCESS_ANNOTATION_BUTTON_NAME));
     
mxMenuButton->set_accessible_description(SwResId(STR_ACCESS_ANNOTATION_BUTTON_DESC));
     mxMenuButton->set_tooltip_text(SwResId(STR_ACCESS_ANNOTATION_BUTTON_DESC));
-
-    mxMenuButton->connect_toggled(LINK(this, SwAnnotationWin, ToggleHdl));
     mxMenuButton->connect_selected(LINK(this, SwAnnotationWin, SelectHdl));
     mxMenuButton->connect_key_press(LINK(this, SwAnnotationWin, KeyInputHdl));
     mxMenuButton->connect_mouse_move(LINK(this, SwAnnotationWin, 
MouseMoveHdl));
@@ -412,6 +410,8 @@ void SwAnnotationWin::InitControls()
     SetPostItText();
     mpOutliner->CompleteOnlineSpelling();
 
+    UpdateMenu();
+
     mxSidebarTextControl->Show();
     mxMetadataAuthor->show();
     mxMetadataDate->show();

Reply via email to