sw/source/core/undo/docundo.cxx |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit ad5539626401e097a7026d896339764e805789a4
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Thu Jun 22 16:46:22 2023 +0200
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Sat Jun 24 11:54:35 2023 +0200

    lok: use correct shell when doing undo
    
    When doing undo we save EditShell reference in the context object.
    Later it is used to get cursor we want to move to the place
    where modification was done (in sw/source/core/undo/unins.cxx:281).
    
    In LOK case when 2 different sessions were used and undo was done
    by user A - then user's B cursor was moved. This fixes that issue.
    
    We use current shell instead of getting it indirectly through
    SwDoc::GetEditShell()
    
    Change-Id: I7a10ea98587f48818e8d0aaa9ad739d4eed514f5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153461
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153492
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index ccff1b663cf3..1933741ea971 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -29,6 +29,7 @@
 #include <pam.hxx>
 #include <swundo.hxx>
 #include <UndoCore.hxx>
+#include <wrtsh.hxx>
 #include <editsh.hxx>
 #include <unobaseclass.hxx>
 #include <IDocumentDrawModelAccess.hxx>
@@ -665,8 +666,10 @@ bool UndoManager::impl_DoUndoRedo(UndoOrRedoType 
undoOrRedo, size_t nUndoOffset)
 
     UnoActionContext c(& rDoc); // exception-safe StartAllAction/EndAllAction
 
-    SwEditShell *const pEditShell( rDoc.GetEditShell() );
-
+    SwView* pViewShell = dynamic_cast<SwView*>(SfxViewShell::Current());
+    SwEditShell *const pEditShell(
+        comphelper::LibreOfficeKit::isActive() && pViewShell ? 
pViewShell->GetWrtShellPtr()
+        : rDoc.GetEditShell());
     OSL_ENSURE(pEditShell, "sw::UndoManager needs a SwEditShell!");
     if (!pEditShell)
     {

Reply via email to