[Libreoffice-commits] core.git: desktop/source include/vcl svtools/source vcl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 13 15:51:51 UTC 2020


 desktop/source/lib/init.cxx                   |   22 ++++++---------
 include/vcl/dialog.hxx                        |    1 
 include/vcl/dialoghelper.hxx                  |   29 ++++++++++++++++++++
 svtools/source/hatchwindow/documentcloser.cxx |    7 ++---
 vcl/source/app/svapp.cxx                      |    3 +-
 vcl/source/window/dialog.cxx                  |   36 ++++++++++++++++++++------
 6 files changed, 73 insertions(+), 25 deletions(-)

New commits:
commit a2e0abc7c6b02e2ea37d269e216d6550be76c8fe
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Feb 13 10:54:35 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Feb 13 16:51:11 2020 +0100

    factor out dialog hacks
    
    Change-Id: Iceefc8d739fb93b97adfa1e35d8308f0c48f02e1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88600
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 34b6155975c5..0869b3a92ab7 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -126,7 +126,7 @@
 #include <vcl/virdev.hxx>
 #include <vcl/ImageTree.hxx>
 #include <vcl/ITiledRenderable.hxx>
-#include <vcl/dialog.hxx>
+#include <vcl/dialoghelper.hxx>
 #include <unicode/uchar.h>
 #include <unotools/syslocaleoptions.hxx>
 #include <unotools/mediadescriptor.hxx>
@@ -3813,10 +3813,7 @@ static void doc_postWindowMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned
     const Point aPos(nX, nY);
     MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
 
-    if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow.get()))
-    {
-        pDialog->EnableInput();
-    }
+    vcl::EnableDialogInput(pWindow);
 
     switch (nType)
     {
@@ -3865,10 +3862,7 @@ static void doc_postWindowGestureEvent(LibreOfficeKitDocument* /*pThis*/, unsign
         PanningOrientation::Vertical,
     };
 
-    if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow.get()))
-    {
-        pDialog->EnableInput();
-    }
+    vcl::EnableDialogInput(pWindow);
 
     Application::PostGestureEvent(VclEventId::WindowGestureEvent, pWindow, &aEvent);
 }
@@ -5174,10 +5168,12 @@ static void doc_postWindow(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindo
 
     if (nAction == LOK_WINDOW_CLOSE)
     {
-        if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow.get()))
-            pDialog->Close();
-        else if (FloatingWindow* pFloatWin = dynamic_cast<FloatingWindow*>(pWindow.get()))
-            pFloatWin->EndPopupMode(FloatWinPopupEndFlags::Cancel | FloatWinPopupEndFlags::CloseAll);
+        bool bWasDialog = vcl::CloseDialog(pWindow);
+        if (!bWasDialog)
+        {
+            if (FloatingWindow* pFloatWin = dynamic_cast<FloatingWindow*>(pWindow.get()))
+                pFloatWin->EndPopupMode(FloatWinPopupEndFlags::Cancel | FloatWinPopupEndFlags::CloseAll);
+        }
     }
     else if (nAction == LOK_WINDOW_PASTE)
     {
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 775714ec8658..e4c9aecaf7d1 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -131,7 +131,6 @@ public:
 
 
     void            EndDialog( long nResult = RET_CANCEL );
-    static void     EndAllDialogs( vcl::Window const * pParent );
 
     void            GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
                                          sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
diff --git a/include/vcl/dialoghelper.hxx b/include/vcl/dialoghelper.hxx
new file mode 100644
index 000000000000..a975811c792f
--- /dev/null
+++ b/include/vcl/dialoghelper.hxx
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <vcl/dllapi.h>
+
+namespace vcl
+{
+class Window;
+
+/* cancel dialogs that are a child of pParent
+   this is used by com.sun.star.embed.DocumentCloser which itself is only used by
+   extensions/source/activex/SOActiveX.cxx see extensions/source/activex/README.txt
+   posibly dubious if this actually works as expected
+*/
+
+VCL_DLLPUBLIC void EndAllDialogs(vcl::Window const* pParent);
+
+/* for LibreOffice kit */
+VCL_DLLPUBLIC void EnableDialogInput(vcl::Window* pDialog);
+VCL_DLLPUBLIC bool CloseDialog(vcl::Window* pDialog);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/svtools/source/hatchwindow/documentcloser.cxx b/svtools/source/hatchwindow/documentcloser.cxx
index 4459953e45d4..6e014dd7ea46 100644
--- a/svtools/source/hatchwindow/documentcloser.cxx
+++ b/svtools/source/hatchwindow/documentcloser.cxx
@@ -30,7 +30,8 @@
 #include <cppuhelper/supportsservice.hxx>
 #include <osl/mutex.hxx>
 #include <vcl/svapp.hxx>
-#include <vcl/dialog.hxx>
+#include <vcl/dialoghelper.hxx>
+#include <vcl/window.hxx>
 #include <tools/link.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 
@@ -115,8 +116,8 @@ IMPL_STATIC_LINK( MainThreadFrameCloserRequest, worker, void*, p, void )
             xWinPeer->setProperty( "PluginParent", uno::makeAny( sal_Int64(0) ) );
 
             VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
-            if ( pWindow )
-                Dialog::EndAllDialogs( pWindow );
+            if (pWindow)
+                vcl::EndAllDialogs(pWindow);
         }
         catch( uno::Exception& )
         {
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index 6e389da9c87a..4f70cceae081 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -33,6 +33,7 @@
 #include <unotools/syslocaleoptions.hxx>
 
 #include <vcl/dialog.hxx>
+#include <vcl/dialoghelper.hxx>
 #include <vcl/lok.hxx>
 #include <vcl/floatwin.hxx>
 #include <vcl/settings.hxx>
@@ -300,7 +301,7 @@ IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplEndAllDialogsMsg, void*, void )
     vcl::Window* pAppWindow = Application::GetFirstTopLevelWindow();
     while (pAppWindow)
     {
-        Dialog::EndAllDialogs(pAppWindow);
+        vcl::EndAllDialogs(pAppWindow);
         pAppWindow = Application::GetNextTopLevelWindow(pAppWindow);
     }
 }
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 588fbbd874fa..91516baffeb5 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -50,6 +50,7 @@
 #include <vcl/button.hxx>
 #include <vcl/mnemonic.hxx>
 #include <vcl/dialog.hxx>
+#include <vcl/dialoghelper.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/weld.hxx>
@@ -1135,19 +1136,40 @@ void Dialog::EndDialog( long nResult )
     }
 }
 
-void Dialog::EndAllDialogs( vcl::Window const * pParent )
+namespace vcl
 {
-    ImplSVData* pSVData = ImplGetSVData();
-    auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
+    void EndAllDialogs( vcl::Window const * pParent )
+    {
+        ImplSVData* pSVData = ImplGetSVData();
+        auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
+
+        for (auto it = rExecuteDialogs.rbegin(); it != rExecuteDialogs.rend(); ++it)
+        {
+            if (!pParent || pParent->IsWindowOrChild(*it, true))
+            {
+                (*it)->EndDialog();
+                (*it)->PostUserEvent(Link<void*, void>());
+            }
+        }
+    }
 
-    for (auto it = rExecuteDialogs.rbegin(); it != rExecuteDialogs.rend(); ++it)
+    void EnableDialogInput(vcl::Window* pWindow)
     {
-        if (!pParent || pParent->IsWindowOrChild(*it, true))
+        if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow))
         {
-            (*it)->EndDialog();
-            (*it)->PostUserEvent(Link<void*, void>());
+            pDialog->EnableInput();
         }
     }
+
+    bool CloseDialog(vcl::Window* pWindow)
+    {
+        if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow))
+        {
+            pDialog->Close();
+            return true;
+        }
+        return false;
+    }
 }
 
 void Dialog::SetModalInputMode( bool bModal )


More information about the Libreoffice-commits mailing list