sc/qa/unit/tiledrendering/tiledrendering.cxx |   42 +++++++++++++++++++++++++++
 sc/source/ui/view/tabvwshc.cxx               |    9 +++--
 2 files changed, 48 insertions(+), 3 deletions(-)

New commits:
commit c50571d34723aa53ebba705c14c07a85c37faa93
Author:     Marco Cecchetti <marco.cecche...@collabora.com>
AuthorDate: Tue Jul 14 18:09:04 2020 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Wed Jul 22 16:07:43 2020 +0200

    lok: sc: Desktop: Function wizard isn't properly async
    
    Open another view of the same spreadsheet when the function dialog is
    open. Note how the document in the new view can't be edited.
    
    This patch avoids to have a view locked after creation when in an
    other view the formula dialog is open.
    
    See also commit 009d275.
    
    Change-Id: Ie51f414c4ad83ef20526d10be3251e174158096c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98822
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx 
b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index e35233cbc3f0..1b7eb5343560 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -110,6 +110,7 @@ public:
     void testJumpHorizontallyInvalidation();
     void testJumpToLastRowInvalidation();
     void testDeleteCellMultilineContent();
+    void testFunctionDlg();
 
     CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
     CPPUNIT_TEST(testRowColumnHeaders);
@@ -151,6 +152,7 @@ public:
     CPPUNIT_TEST(testJumpHorizontallyInvalidation);
     CPPUNIT_TEST(testJumpToLastRowInvalidation);
     CPPUNIT_TEST(testDeleteCellMultilineContent);
+    CPPUNIT_TEST(testFunctionDlg);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1695,6 +1697,46 @@ void ScTiledRenderingTest::testFilterDlg()
     SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, 
nullptr);
 }
 
+void ScTiledRenderingTest::testFunctionDlg()
+{
+    comphelper::LibreOfficeKit::setActive();
+
+    createDoc("empty.ods");
+
+    // view #1
+    SfxViewShell* pView1 = SfxViewShell::Current();
+    int nView1 = SfxLokHelper::getView();
+    {
+        pView1->GetViewFrame()->GetDispatcher()->Execute(SID_OPENDLG_FUNCTION,
+            SfxCallMode::SLOT|SfxCallMode::RECORD);
+    }
+    Scheduler::ProcessEventsToIdle();
+    SfxChildWindow* pRefWindow = 
pView1->GetViewFrame()->GetChildWindow(SID_OPENDLG_FUNCTION);
+    CPPUNIT_ASSERT(pRefWindow);
+
+    // view #2
+    int nView2 = SfxLokHelper::createView();
+    SfxViewShell* pView2 = SfxViewShell::Current();
+    CPPUNIT_ASSERT(pView1 != pView2);
+
+    // check loking
+    CPPUNIT_ASSERT_EQUAL(true, 
pView1->GetViewFrame()->GetDispatcher()->IsLocked());
+    CPPUNIT_ASSERT_EQUAL(false, 
pView2->GetViewFrame()->GetDispatcher()->IsLocked());
+
+    SfxLokHelper::setView(nView1);
+    KeyEvent aEvent(27, KEY_ESCAPE, 0);
+    Application::PostKeyEvent(VclEventId::WindowKeyInput, 
pRefWindow->GetWindow(), &aEvent);
+    Application::PostKeyEvent(VclEventId::WindowKeyUp, 
pRefWindow->GetWindow(), &aEvent);
+
+    Scheduler::ProcessEventsToIdle();
+    CPPUNIT_ASSERT_EQUAL(false, 
pView1->GetViewFrame()->GetDispatcher()->IsLocked());
+    CPPUNIT_ASSERT_EQUAL(false, 
pView2->GetViewFrame()->GetDispatcher()->IsLocked());
+
+    SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, 
nullptr);
+    SfxLokHelper::setView(nView2);
+    SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, 
nullptr);
+}
+
 void ScTiledRenderingTest::testVbaRangeCopyPaste()
 {
     comphelper::LibreOfficeKit::setActive();
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 1f0cd9bf737b..d725b4bba9a3 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -129,10 +129,13 @@ VclPtr<SfxModelessDialog> ScTabViewShell::CreateRefDialog(
 
     if ( nCurRefDlgId != nSlotId )
     {
-        //  the dialog has been opened in a different view
-        //  -> lock the dispatcher for this view (modal mode)
+        if (!(comphelper::LibreOfficeKit::isActive() && nSlotId == 
SID_OPENDLG_FUNCTION))
+        {
+            //  the dialog has been opened in a different view
+            //  -> lock the dispatcher for this view (modal mode)
 
-        GetViewData().GetDispatcher().Lock( true );    // lock is reset when 
closing dialog
+            GetViewData().GetDispatcher().Lock( true );    // lock is reset 
when closing dialog
+        }
         return nullptr;
     }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to