[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/inc sw/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 1 07:59:33 UTC 2020


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

New commits:
commit b1574603d61914fc2eb498e99b199ca81d0bf578
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Sep 28 12:32:56 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Oct 1 09:59:00 2020 +0200

    Related: tdf#136985 restore focus to doc it wasn't initially in the comment
    
    after processing a menu command if we grabbed focus to a comment at the start
    of the the menu command processing
    
    Change-Id: I6cf4b59fc0c5d3e09578cb0466b15ae358cfb0ae
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103568
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx
index 32630399c9d0..e8e16158e26a 100644
--- a/sw/inc/AnnotationWin.hxx
+++ b/sw/inc/AnnotationWin.hxx
@@ -195,7 +195,10 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin : public vcl::Window
         bool IsThreadResolved();
 
         // Set this SwAnnotationWin as the currently active one
-        void SetActiveSidebarWin();
+        // return false if it was already active
+        bool SetActiveSidebarWin();
+        // Unset this SwAnnotationWin as the currently active one
+        void UnsetActiveSidebarWin();
 
         /// Find the first annotation for the thread which this annotation is in.
         /// This may be the same annotation as this one.
diff --git a/sw/source/uibase/docvw/AnnotationMenuButton.cxx b/sw/source/uibase/docvw/AnnotationMenuButton.cxx
index 58e4f7a8a610..847905385577 100644
--- a/sw/source/uibase/docvw/AnnotationMenuButton.cxx
+++ b/sw/source/uibase/docvw/AnnotationMenuButton.cxx
@@ -72,7 +72,7 @@ void AnnotationMenuButton::Select()
 
     // tdf#136682 ensure this is the currently active sidebar win so the command
     // operates in an active sidebar context
-    mrSidebarWin.SetActiveSidebarWin();
+    bool bSwitchedFocus = mrSidebarWin.SetActiveSidebarWin();
 
     if (sIdent == "reply")
         mrSidebarWin.ExecuteCommand(FN_REPLY);
@@ -86,6 +86,10 @@ void AnnotationMenuButton::Select()
         mrSidebarWin.ExecuteCommand(FN_DELETE_ALL_NOTES);
     else if (sIdent == "formatall")
         mrSidebarWin.ExecuteCommand(FN_FORMAT_ALL_NOTES);
+
+    if (bSwitchedFocus)
+        mrSidebarWin.UnsetActiveSidebarWin();
+    mrSidebarWin.GrabFocusToDocument();
 }
 
 void AnnotationMenuButton::MouseButtonDown( const MouseEvent& rMEvt )
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx
index f3734704e1ed..9c3539f2e6d7 100644
--- a/sw/source/uibase/docvw/AnnotationWin2.cxx
+++ b/sw/source/uibase/docvw/AnnotationWin2.cxx
@@ -1358,14 +1358,25 @@ IMPL_LINK( SwAnnotationWin, WindowEventListener, VclWindowEvent&, rEvent, void )
     }
 }
 
-void SwAnnotationWin::SetActiveSidebarWin()
+bool SwAnnotationWin::SetActiveSidebarWin()
 {
     if (mrMgr.GetActiveSidebarWin() == this)
-        return;
+        return false;
     const bool bLockView = mrView.GetWrtShell().IsViewLocked();
     mrView.GetWrtShell().LockView( true );
     mrMgr.SetActiveSidebarWin(this);
     mrView.GetWrtShell().LockView( bLockView );
+    return true;
+}
+
+void SwAnnotationWin::UnsetActiveSidebarWin()
+{
+    if (mrMgr.GetActiveSidebarWin() != this)
+        return;
+    const bool bLockView = mrView.GetWrtShell().IsViewLocked();
+    mrView.GetWrtShell().LockView( true );
+    mrMgr.SetActiveSidebarWin(nullptr);
+    mrView.GetWrtShell().LockView( bLockView );
 }
 
 IMPL_LINK(SwAnnotationWin, ScrollHdl, ScrollBar*, pScroll, void)


More information about the Libreoffice-commits mailing list