factor out dialog hacks

Change-Id: Iceefc8d739fb93b97adfa1e35d8308f0c48f02e1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88600
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2020-02-13 10:54:35 +00:00
parent 119044e8c9
commit a2e0abc7c6
6 changed files with 74 additions and 26 deletions

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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: */

View File

@@ -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& )
{

View File

@@ -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);
}
}

View File

@@ -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;
for (auto it = rExecuteDialogs.rbegin(); it != rExecuteDialogs.rend(); ++it)
void EndAllDialogs( vcl::Window const * pParent )
{
if (!pParent || pParent->IsWindowOrChild(*it, true))
ImplSVData* pSVData = ImplGetSVData();
auto& rExecuteDialogs = pSVData->mpWinData->mpExecuteDialogs;
for (auto it = rExecuteDialogs.rbegin(); it != rExecuteDialogs.rend(); ++it)
{
(*it)->EndDialog();
(*it)->PostUserEvent(Link<void*, void>());
if (!pParent || pParent->IsWindowOrChild(*it, true))
{
(*it)->EndDialog();
(*it)->PostUserEvent(Link<void*, void>());
}
}
}
void EnableDialogInput(vcl::Window* pWindow)
{
if (Dialog* pDialog = dynamic_cast<Dialog*>(pWindow))
{
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 )