[Libreoffice-commits] core.git: 2 commits - include/vcl sc/source sd/source sw/source vcl/source

Pranav Kant pranavk at collabora.co.uk
Fri Feb 23 07:43:56 UTC 2018


 include/vcl/dialog.hxx            |    3 +++
 sc/source/ui/unoobj/docuno.cxx    |   24 ++++++++++--------------
 sd/source/ui/unoidl/unomodel.cxx  |   20 +++++++-------------
 sw/source/uibase/uno/unotxdoc.cxx |   19 +++++++++----------
 vcl/source/window/dialog.cxx      |   26 +++++++++++++++++++++-----
 5 files changed, 50 insertions(+), 42 deletions(-)

New commits:
commit 391660de4125da06775f7d94ef352da3926c115f
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Feb 21 13:10:00 2018 +0530

    lokdialog: Allow Execute()ing first, silently cancels others
    
    We want to be able to detect which dialogs are important and need to be
    converted to async while not completely disallowing them. Allow only
    first instance of such dialogs being Execute()d and warn when another
    such instance tries to Execute().
    
    Change-Id: I6742784fa95d9e3f9ff87ece294126d390ae9e9e
    Reviewed-on: https://gerrit.libreoffice.org/50092
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>

diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index e2ad43bcbf48..24e0dfd7378f 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -48,6 +48,7 @@ private:
     std::unique_ptr<DialogImpl> mpDialogImpl;
     long            mnMousePositioned;
     bool            mbInExecute;
+    bool            mbInSyncExecute;
     bool            mbInClose;
     bool            mbModalMode;
     bool            mbPaintComplete;
@@ -127,6 +128,8 @@ public:
 
     virtual short   Execute();
     bool            IsInExecute() const { return mbInExecute; }
+    // Return true when dialog is synchronously executed (calling ::Execute())
+    bool            IsInSyncExecute() const { return mbInSyncExecute; };
 
     virtual FactoryFunction GetUITestFactory() const override;
 
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 9ba5d57da2d4..2da8e08d7ebc 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/util/thePathSettings.hpp>
 #include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
 #include <comphelper/lok.hxx>
+#include <comphelper/scopeguard.hxx>
 #include <comphelper/processfactory.hxx>
 #include <officecfg/Office/Common.hxx>
 #include <osl/file.hxx>
@@ -803,13 +804,26 @@ bool Dialog::ImplStartExecuteModal()
         return false;
     }
 
+    ImplSVData* pSVData = ImplGetSVData();
+
     switch ( Application::GetDialogCancelMode() )
     {
     case Application::DialogCancelMode::Off:
         break;
     case Application::DialogCancelMode::Silent:
         if (GetLOKNotifier())
-            break;
+        {
+            // check if there's already some dialog being ::Execute()d
+            const bool bDialogExecuting = std::any_of(pSVData->maWinData.mpExecuteDialogs.begin(),
+                                                      pSVData->maWinData.mpExecuteDialogs.end(),
+                                                      [](const Dialog* pDialog) {
+                                                          return pDialog->IsInSyncExecute();
+                                                      });
+            if (!(bDialogExecuting && IsInSyncExecute()))
+                break;
+            else
+                SAL_WARN("lok.dialog", "Dialog \"" << ImplGetDialogText(this) << "\" is being synchronously executed over an existing synchronously executing dialog.");
+        }
 
         SAL_INFO(
             "vcl",
@@ -836,9 +850,7 @@ bool Dialog::ImplStartExecuteModal()
     }
 #endif
 
-    ImplSVData* pSVData = ImplGetSVData();
-
-     // link all dialogs which are being executed
+    // link all dialogs which are being executed
     pSVData->maWinData.mpExecuteDialogs.push_back(this);
 
     // stop capturing, in order to have control over the dialog
@@ -950,6 +962,11 @@ short Dialog::Execute()
 #if HAVE_FEATURE_DESKTOP
     VclPtr<vcl::Window> xWindow = this;
 
+    mbInSyncExecute = true;
+    comphelper::ScopeGuard aGuard([&]() {
+            mbInSyncExecute = false;
+        });
+
     if ( !ImplStartExecuteModal() )
         return 0;
 
@@ -959,7 +976,6 @@ short Dialog::Execute()
         Application::Yield();
 
     ImplEndExecuteModal();
-
 #ifdef DBG_UTIL
     assert (!mpDialogParent || !mpDialogParent->IsDisposed());
 #endif
commit 190a44fe052f034368e254d263fca21fc000d6ce
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Feb 20 21:39:15 2018 +0530

    lok: Factor out the code for finding vcl::Window of a document
    
    This should also help with IME input on charts
    
    Change-Id: Ie513790a5d0c87397c39301a328a44b59d394a45
    Reviewed-on: https://gerrit.libreoffice.org/50091
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>

diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index b64645dfe667..cd56f7c5872e 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -552,10 +552,19 @@ OUString ScModelObj::getPartHash( int nPart )
 VclPtr<vcl::Window> ScModelObj::getDocWindow()
 {
     SolarMutexGuard aGuard;
+
+    // There seems to be no clear way of getting the grid window for this
+    // particular document, hence we need to hope we get the right window.
     ScViewData* pViewData = ScDocShell::GetViewData();
     VclPtr<vcl::Window> pWindow;
     if (pViewData)
         pWindow = pViewData->GetActiveWin();
+
+    LokChartHelper aChartHelper(pViewData->GetViewShell());
+    vcl::Window* pChartWindow = aChartHelper.GetWindow();
+    if (pChartWindow)
+        pWindow = pChartWindow;
+
     return pWindow;
 }
 
@@ -597,24 +606,11 @@ void ScModelObj::postKeyEvent(int nType, int nCharCode, int nKeyCode)
 {
     SolarMutexGuard aGuard;
 
-    // There seems to be no clear way of getting the grid window for this
-    // particular document, hence we need to hope we get the right window.
-    ScViewData* pViewData = ScDocShell::GetViewData();
-    vcl::Window* pWindow = pViewData->GetActiveWin();
-
+    VclPtr<vcl::Window> pWindow = getDocWindow();
     if (!pWindow)
         return;
 
     KeyEvent aEvent(nCharCode, nKeyCode, 0);
-
-    ScTabViewShell * pTabViewShell = pViewData->GetViewShell();
-    LokChartHelper aChartHelper(pTabViewShell);
-    vcl::Window* pChartWindow = aChartHelper.GetWindow();
-    if (pChartWindow)
-    {
-        pWindow = pChartWindow;
-    }
-
     switch (nType)
     {
     case LOK_KEYEVENT_KEYINPUT:
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 2ff6f93c0680..3dc5e2839c74 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2344,6 +2344,12 @@ VclPtr<vcl::Window> SdXImpressDocument::getDocWindow()
     VclPtr<vcl::Window> pWindow;
     if (pViewShell)
         pWindow = pViewShell->GetActiveWindow();
+
+    LokChartHelper aChartHelper(pViewShell->GetViewShell());
+    VclPtr<vcl::Window> pChartWindow = aChartHelper.GetWindow();
+    if (pChartWindow)
+        pWindow = pChartWindow;
+
     return pWindow;
 }
 
@@ -2466,23 +2472,11 @@ void SdXImpressDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
 {
     SolarMutexGuard aGuard;
 
-    DrawViewShell* pViewShell = GetViewShell();
-    if (!pViewShell)
-        return;
-
-    vcl::Window* pWindow = pViewShell->GetActiveWindow();
+    VclPtr<vcl::Window> pWindow = getDocWindow();
     if (!pWindow)
         return;
 
-    LokChartHelper aChartHelper(pViewShell->GetViewShell());
-    vcl::Window* pChartWindow = aChartHelper.GetWindow();
-    if (pChartWindow)
-    {
-        pWindow = pChartWindow;
-    }
-
     KeyEvent aEvent(nCharCode, nKeyCode, 0);
-
     switch (nType)
     {
     case LOK_KEYEVENT_KEYINPUT:
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 63f5d0faceba..39c9ad4a4ad7 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3406,6 +3406,12 @@ VclPtr<vcl::Window> SwXTextDocument::getDocWindow()
     SwView* pView = pDocShell->GetView();
     if (pView)
         pWindow = &(pView->GetEditWin());
+
+    LokChartHelper aChartHelper(pView);
+    VclPtr<vcl::Window> pChartWindow = aChartHelper.GetWindow();
+    if (pChartWindow)
+        pWindow = pChartWindow;
+
     return pWindow;
 }
 
@@ -3479,18 +3485,11 @@ void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
 {
     SolarMutexGuard aGuard;
 
-    vcl::Window* pWindow = &(pDocShell->GetView()->GetEditWin());
-
-    SfxViewShell* pViewShell = pDocShell->GetView();
-    LokChartHelper aChartHelper(pViewShell);
-    vcl::Window* pChartWindow = aChartHelper.GetWindow();
-    if (pChartWindow)
-    {
-        pWindow = pChartWindow;
-    }
+    VclPtr<vcl::Window> pWindow = getDocWindow();
+    if (!pWindow)
+        return;
 
     KeyEvent aEvent(nCharCode, nKeyCode, 0);
-
     switch (nType)
     {
     case LOK_KEYEVENT_KEYINPUT:


More information about the Libreoffice-commits mailing list