[Libreoffice-commits] core.git: sd/qa sfx2/source

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 22 18:20:58 UTC 2021


 sd/qa/unit/tiledrendering/tiledrendering.cxx |    6 +++++-
 sfx2/source/control/bindings.cxx             |   23 +++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit 35b81a05c7c58d0db2276627a9387a738c409974
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Mon Mar 15 17:10:10 2021 +0100
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Mon Mar 22 19:20:11 2021 +0100

    lok: switch to the correct view before any UI update is done via SfxBindings.
    
    Change-Id: I541e53b4219340233ed5a4bec407ded5adf6a841
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112538
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112730
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index cc11e2483991..d553dfce610f 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -1005,6 +1005,7 @@ void SdTiledRenderingTest::testViewCursorParts()
     SfxLokHelper::createView();
     pXImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
     ViewCallback aView2;
+    int nView2 = SfxLokHelper::getView();
 
     // Select the shape in the second view.
     sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
@@ -1018,6 +1019,7 @@ void SdTiledRenderingTest::testViewCursorParts()
     pView->UnmarkAllObj(pView->GetSdrPageView());
 
     // Now switch to the second part in the second view.
+    SfxLokHelper::setView(nView2);
     pXImpressDocument->setPart(1);
     aView2.m_nPart = 1;
     aView1.m_bGraphicViewSelectionInvalidated = false;
@@ -1058,10 +1060,10 @@ void SdTiledRenderingTest::testCursorViews()
     // second view as well, even if the second view was created after begin
     // text edit in the first view.
     ViewCallback aView2;
+    SfxLokHelper::setView(nView1);
     // This failed: the second view didn't get a lock notification, even if the
     // first view already started text edit.
     CPPUNIT_ASSERT(aView2.m_bViewLock);
-    SfxLokHelper::setView(nView1);
     aView2.m_bTilesInvalidated = false;
     pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
     pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
@@ -1188,6 +1190,8 @@ void SdTiledRenderingTest::testCursorVisibility_MultiView()
     pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
                                       centerX, centerY,
                                       2, MOUSE_LEFT, 0);
+
+    SfxLokHelper::setView(nView1);
     pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP,
                                       centerX, centerY,
                                       2, MOUSE_LEFT, 0);
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index aa565d9c4a96..0c430db5e184 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -48,6 +48,9 @@
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/objsh.hxx>
 #include <sfx2/msgpool.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/lokhelper.hxx>
+#include <comphelper/lok.hxx>
 
 #include <cstddef>
 #include <memory>
@@ -1235,6 +1238,26 @@ bool SfxBindings::NextJob_Impl(Timer const * pTimer)
 
     SfxApplication *pSfxApp = SfxGetpApp();
 
+    // Switch to the right view for state update.
+    if (comphelper::LibreOfficeKit::isActive())
+    {
+        if( pDispatcher )
+        {
+            SfxViewFrame* pFrame = pDispatcher->GetFrame();
+            if (pFrame)
+            {
+                vcl::Window* pFrameWin = pFrame->GetWindow().GetFrameWindow();
+                if (pFrameWin && pFrameWin->GetLOKNotifier()) {
+                    const SfxViewShell* pView = dynamic_cast<const SfxViewShell*>(pFrameWin->GetLOKNotifier());
+                    if (pView)
+                    {
+                        SfxLokHelper::setView(pView->GetViewShellId().get());
+                    }
+                }
+            }
+        }
+    }
+
     if( pDispatcher )
         pDispatcher->Update_Impl();
 


More information about the Libreoffice-commits mailing list