Allow non-modal Dialogs during FileImport/Load
When opening a file that triggers Dialogs (e.g. cannot
read/repair/FileType) the Frame from which it was
initialized gets blocked. This irritates quite some
people. Changed this to a non-modal Dialog so that
the user can continue to work with all opened docs,
open new ones, close and print/PDF/export these.
Change-Id: I048d3de3369527cec20d26396b87439254764b8a
Reviewed-on: https://gerrit.libreoffice.org/41534
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index 6100d83..1467e0e 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -787,7 +787,7 @@
NameClashQueryBox::NameClashQueryBox( vcl::Window* pParent,
const OUString& rTitle, const OUString& rMessage )
: MessBox( pParent, MessBoxStyle::NONE, rTitle, rMessage )
: MessBox( pParent, MessBoxStyle::NONE, 0, rTitle, rMessage )
{
if ( !rTitle.isEmpty() )
SetText( rTitle );
@@ -812,7 +812,7 @@
LanguageMismatchQueryBox::LanguageMismatchQueryBox( vcl::Window* pParent,
const OUString& rTitle, const OUString& rMessage )
: MessBox( pParent, MessBoxStyle::NONE, rTitle, rMessage )
: MessBox( pParent, MessBoxStyle::NONE, 0, rTitle, rMessage )
{
if ( !rTitle.isEmpty() )
SetText( rTitle );
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index 73899c4..ee13148 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -722,9 +722,9 @@
{
#if defined __GNUC__
vcl::Window* pParent = Application::GetDefDialogParent();
ScopedVclPtrInstance<MessBox>( pParent, MessBoxStyle::Ok, OUString(), aOut )->Execute();
ScopedVclPtrInstance<MessBox>( pParent, MessBoxStyle::Ok, 0, OUString(), aOut )->Execute();
#else
ScopedVclPtrInstance<MessBox>( Application::GetDefDialogParent(), MessBoxStyle::Ok, OUString(), aOut )->Execute();
ScopedVclPtrInstance<MessBox>( Application::GetDefDialogParent(), MessBoxStyle::Ok, 0, OUString(), aOut )->Execute();
#endif
}
aOut.clear();
@@ -870,7 +870,7 @@
if( !ScopedVclPtrInstance<MessBox>(
Application::GetDefDialogParent(),
MessBoxStyle::OkCancel | MessBoxStyle::DefaultOk,
OUString(), s)->Execute() )
0, OUString(), s)->Execute() )
{
nError = ERRCODE_BASIC_USER_ABORT;
}
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 26fcf6b..680b65a 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -4345,7 +4345,7 @@
pBox.reset(VclPtr<InfoBox>::Create( pParent, nWinBits, aMsg ));
break;
default:
pBox.reset(VclPtr<MessBox>::Create( pParent, nWinBits, aTitle, aMsg ));
pBox.reset(VclPtr<MessBox>::Create( pParent, nWinBits, 0, aTitle, aMsg ));
}
pBox->SetText( aTitle );
short nRet = pBox->Execute();
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index 98b9444d..72d08f2 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -3467,7 +3467,7 @@
SvxIconReplacementDialog::SvxIconReplacementDialog(
vcl::Window *pWindow, const OUString& aMessage, bool /*bYestoAll*/ )
:
MessBox( pWindow, MessBoxStyle::DefaultYes, CuiResId( RID_SVXSTR_REPLACE_ICON_CONFIRM ), CuiResId( RID_SVXSTR_REPLACE_ICON_WARNING ) )
MessBox( pWindow, MessBoxStyle::DefaultYes, 0, CuiResId( RID_SVXSTR_REPLACE_ICON_CONFIRM ), CuiResId( RID_SVXSTR_REPLACE_ICON_WARNING ) )
{
SetImage( WarningBox::GetStandardImage() );
@@ -3481,7 +3481,7 @@
SvxIconReplacementDialog::SvxIconReplacementDialog(
vcl::Window *pWindow, const OUString& aMessage )
: MessBox( pWindow, MessBoxStyle::YesNoCancel, CuiResId( RID_SVXSTR_REPLACE_ICON_CONFIRM ), CuiResId( RID_SVXSTR_REPLACE_ICON_WARNING ) )
: MessBox( pWindow, MessBoxStyle::YesNoCancel, 0, CuiResId( RID_SVXSTR_REPLACE_ICON_CONFIRM ), CuiResId( RID_SVXSTR_REPLACE_ICON_WARNING ) )
{
SetImage( WarningBox::GetStandardImage() );
SetMessText( ReplaceIconName( aMessage ));
diff --git a/framework/source/dispatch/closedispatcher.cxx b/framework/source/dispatch/closedispatcher.cxx
index 8ee7791..2d89836 100644
--- a/framework/source/dispatch/closedispatcher.cxx
+++ b/framework/source/dispatch/closedispatcher.cxx
@@ -38,6 +38,7 @@
#include <vcl/window.hxx>
#include <vcl/svapp.hxx>
#include <vcl/syswin.hxx>
#include <vcl/dialog.hxx>
#include <unotools/moduleoptions.hxx>
#include <comphelper/processfactory.hxx>
@@ -366,6 +367,14 @@
}
}
// if we still have dialogs open, temporary suppress termination
if (bTerminateApp && Dialog::AreDialogsOpen())
{
Application::SetShutdownDelayed();
bCloseFrame = true;
bTerminateApp = false;
}
// Do it now ...
bool bSuccess = false;
if (bCloseFrame)
diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx
index 0bff7d4..ea57962 100644
--- a/framework/source/loadenv/loadenv.cxx
+++ b/framework/source/loadenv/loadenv.cxx
@@ -371,6 +371,10 @@
if (!bStarted)
bStarted = impl_loadContent();
// This may have triggered Dialogs (error cases) that may have
// delayed the shutdown, so give delayed shutdown a chance
Application::TriggerShutdownDelayed();
// not started => general error
// We can't say - what was the reason for.
if (!bStarted)
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 49737fd..2730467 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -34,7 +34,17 @@
class VCL_DLLPUBLIC Dialog : public SystemWindow
{
public:
enum class InitFlag { Default, NoParent };
enum class InitFlag
{
/** Use given parent or get a default one using GetDefaultParent(...) */
Default,
/** Suppress Parent so that Parent is not blocked (kind of modal mode) */
NoParent,
/** Suppress Parent (no modal, see above) and additionally center on default parent */
NoParentCentered
};
private:
VclPtr<Dialog> mpPrevExecuteDlg;
@@ -84,6 +94,9 @@
virtual ~Dialog() override;
virtual void dispose() override;
// get the default parent for a dialog as is done in standard initialization
static vcl::Window* GetDefaultParent(WinBits nStyle);
virtual bool EventNotify( NotifyEvent& rNEvt ) override;
virtual void StateChanged( StateChangedType nStateChange ) override;
virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
@@ -130,6 +143,7 @@
void EndDialog( long nResult = 0 );
static void EndAllDialogs( vcl::Window const * pParent );
static bool AreDialogsOpen();
void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
diff --git a/include/vcl/msgbox.hxx b/include/vcl/msgbox.hxx
index 8504c6c..7c37717 100644
--- a/include/vcl/msgbox.hxx
+++ b/include/vcl/msgbox.hxx
@@ -69,10 +69,9 @@
SAL_DLLPRIVATE void ImplPosControls();
public:
MessBox( vcl::Window* pParent, MessBoxStyle nMessBoxStyle,
const OUString& rTitle, const OUString& rMessage );
MessBox( vcl::Window* pParent, MessBoxStyle nMessBoxStyle, WinBits n,
const OUString& rTitle, const OUString& rMessage );
const OUString& rTitle, const OUString& rMessage,
Dialog::InitFlag eInitFlag = Dialog::InitFlag::NoParentCentered);
virtual ~MessBox() override;
virtual void dispose() override;
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index d5b81b2..7bdb4da 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -1387,6 +1387,12 @@
// For vclbootstrapprotector:
static void setDeInitHook(Link<LinkParamNone*,void> const & hook);
// for delayed shutdown: set using SetShutdownDelayed, then
// trigger using TriggerShutdownDelayed which may actually shutdown
// when SetShutdownDelayed is set
static void SetShutdownDelayed();
static void TriggerShutdownDelayed();
private:
DECL_STATIC_LINK( Application, PostEventHandler, void*, void );
};
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 79d77f7..03ca038 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -408,7 +408,7 @@
}
}
ScopedVclPtrInstance< MessBox > aBox( pParent, nStyle, aTitle, aMessage );
ScopedVclPtrInstance< MessBox > aBox( pParent, nStyle, 0, aTitle, aMessage );
sal_uInt16 nRet = aBox->Execute();
return ( eErrorStyle == SC_VALERR_STOP || nRet == RET_CANCEL );
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index df07aca..96fc598 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -994,7 +994,7 @@
if (rParam.bReplace)
if (rDoc.TestRemoveSubTotals( nTab, rParam ))
{
bOk = ScopedVclPtrInstance<MessBox>( ScDocShell::GetActiveDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes,
bOk = ScopedVclPtrInstance<MessBox>( ScDocShell::GetActiveDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, 0,
// "StarCalc" "Delete Data?"
ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ),
ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_1 ) )->Execute()
diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx
index 16a5d4d..40e6ec4 100644
--- a/sc/source/ui/view/dbfunc.cxx
+++ b/sc/source/ui/view/dbfunc.cxx
@@ -340,7 +340,7 @@
{
if (!bHeader)
{
if ( ScopedVclPtrInstance<MessBox>( GetViewData().GetDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes,
if ( ScopedVclPtrInstance<MessBox>( GetViewData().GetDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, 0,
ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), // "StarCalc"
ScGlobal::GetRscString( STR_MSSG_MAKEAUTOFILTER_0 ) // header from first row?
)->Execute() == RET_YES )
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index fc0a8da..c6d0409 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -396,7 +396,7 @@
if (rParam.bReplace)
if (rDoc.TestRemoveSubTotals( nTab, rParam ))
{
bOk = ScopedVclPtrInstance<MessBox>( GetViewData().GetDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes,
bOk = ScopedVclPtrInstance<MessBox>( GetViewData().GetDialogParent(), MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, 0,
// "StarCalc" "delete data?"
ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ),
ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_1 ) )->Execute()
diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx
index f3100a2..c540595 100644
--- a/sc/source/ui/view/spelleng.cxx
+++ b/sc/source/ui/view/spelleng.cxx
@@ -306,7 +306,7 @@
{
vcl::Window* pParent = GetDialogParent();
ScWaitCursorOff aWaitOff( pParent );
ScopedVclPtrInstance<MessBox> aMsgBox( pParent, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes,
ScopedVclPtrInstance<MessBox> aMsgBox( pParent, MessBoxStyle::YesNo | MessBoxStyle::DefaultYes, 0,
ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ),
ScGlobal::GetRscString( STR_SPELLING_BEGIN_TAB) );
return aMsgBox->Execute() == RET_YES;
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
index 0cf938c..fc53751 100644
--- a/sc/source/ui/view/viewfun2.cxx
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -2042,7 +2042,7 @@
}
ScopedVclPtrInstance<MessBox> aBox( GetViewData().GetDialogParent(),
MessBoxStyle::YesNo | MessBoxStyle::DefaultNo,
MessBoxStyle::YesNo | MessBoxStyle::DefaultNo, 0,
ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), aMsgStr );
sal_uInt16 nRetVal = aBox->Execute();
diff --git a/sfx2/source/doc/querytemplate.cxx b/sfx2/source/doc/querytemplate.cxx
index 1e1ca56..521dd77 100644
--- a/sfx2/source/doc/querytemplate.cxx
+++ b/sfx2/source/doc/querytemplate.cxx
@@ -28,7 +28,7 @@
{
QueryTemplateBox::QueryTemplateBox( vcl::Window* pParent, const OUString& rMessage ) :
MessBox ( pParent, MessBoxStyle::NONE, Application::GetDisplayName(), rMessage )
MessBox ( pParent, MessBoxStyle::NONE, 0, Application::GetDisplayName(), rMessage )
{
SetImage( QueryBox::GetStandardImage() );
SetHelpId( HID_QUERY_LOAD_TEMPLATE );
diff --git a/svx/source/dialog/prtqry.cxx b/svx/source/dialog/prtqry.cxx
index 898da94..3f8ddf0 100644
--- a/svx/source/dialog/prtqry.cxx
+++ b/svx/source/dialog/prtqry.cxx
@@ -23,7 +23,7 @@
#include <svx/dialmgr.hxx>
SvxPrtQryBox::SvxPrtQryBox(vcl::Window* pParent) :
MessBox(pParent, MessBoxStyle::NONE,
MessBox(pParent, MessBoxStyle::NONE, 0,
SvxResId(RID_SVXSTR_QRY_PRINT_TITLE),
SvxResId(RID_SVXSTR_QRY_PRINT_MSG))
{
diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx
index 420ff42..0793190 100644
--- a/sw/source/ui/table/tautofmt.cxx
+++ b/sw/source/ui/table/tautofmt.cxx
@@ -375,7 +375,7 @@
aMessage += m_pLbFormat->GetSelectEntry();
aMessage += "\n";
VclPtrInstance<MessBox> pBox( this, MessBoxStyle::OkCancel,
VclPtrInstance<MessBox> pBox( this, MessBoxStyle::OkCancel, 0,
aStrDelTitle, aMessage );
if ( pBox->Execute() == RET_OK )
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index 001690e..4142142 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -251,7 +251,7 @@
static short lcl_AskRedlineFlags(vcl::Window *pWin)
{
ScopedVclPtrInstance<MessBox> aQBox( pWin, MessBoxStyle::NONE,
ScopedVclPtrInstance<MessBox> aQBox( pWin, MessBoxStyle::NONE, 0,
SwResId( STR_REDLINE_TITLE ),
SwResId( STR_REDLINE_MSG ) );
aQBox->SetImage( QueryBox::GetStandardImage() );
diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx
index 3aaafda..5e3f9c4 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -417,7 +417,7 @@
// do not hyphenate if interactive hyphenation is active elsewhere
if (SwEditShell::HasHyphIter())
{
ScopedVclPtrInstance<MessBox>( nullptr, MessBoxStyle::Ok, SwResId( STR_HYPH_TITLE ),
ScopedVclPtrInstance<MessBox>( nullptr, MessBoxStyle::Ok, 0, SwResId( STR_HYPH_TITLE ),
SwResId( STR_MULT_INTERACT_HYPH_WARN ) )->Execute();
return;
}
diff --git a/uui/source/alreadyopen.cxx b/uui/source/alreadyopen.cxx
index 02687af..0c417c0 100644
--- a/uui/source/alreadyopen.cxx
+++ b/uui/source/alreadyopen.cxx
@@ -22,7 +22,7 @@
#include <unotools/resmgr.hxx>
AlreadyOpenQueryBox::AlreadyOpenQueryBox( vcl::Window* pParent, const std::locale& rLocale, const OUString& aMessage, bool bIsStoring ) :
MessBox(pParent, MessBoxStyle::NONE,
MessBox(pParent, MessBoxStyle::NONE, 0,
Translate::get(STR_ALREADYOPEN_TITLE, rLocale),
aMessage )
{
diff --git a/uui/source/filechanged.cxx b/uui/source/filechanged.cxx
index e9d50ce..bac5fc6 100644
--- a/uui/source/filechanged.cxx
+++ b/uui/source/filechanged.cxx
@@ -22,7 +22,7 @@
#include "filechanged.hxx"
FileChangedQueryBox::FileChangedQueryBox( vcl::Window* pParent, const std::locale& rLocale ) :
MessBox(pParent, MessBoxStyle::NONE,
MessBox(pParent, MessBoxStyle::NONE, 0,
Translate::get(STR_FILECHANGED_TITLE, rLocale),
OUString() )
{
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx
index d136f04..7bee920 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -961,11 +961,35 @@
vcl::Window * pParent,
OUString const & rTitle,
OUString const & rMessage,
MessBoxStyle nButtonMask )
MessBoxStyle nButtonMask,
Dialog::InitFlag eInitFlag)
{
SolarMutexGuard aGuard;
WinBits nStyle(0);
ScopedVclPtrInstance< MessBox > xBox(pParent, nButtonMask, rTitle, rMessage);
ScopedVclPtrInstance< MessBox > xBox(pParent, nButtonMask, nStyle, rTitle, rMessage, eInitFlag);
if (Dialog::InitFlag::NoParentCentered == eInitFlag)
{
vcl::Window* pDefaultParent = Dialog::GetDefaultParent(nStyle);
if (pDefaultParent)
{
// need to 'Show' to have the following tasks do someting, does
// not work without and may even stumble on nullptrs/errors
xBox->Show();
// center on parent window
const Point aP(pDefaultParent->GetPosPixel());
const Size aS(pDefaultParent->GetSizePixel());
const Size aMySize(xBox->GetSizePixel());
xBox->SetPosPixel(
Point(
aP.X() + ((aS.Width() - aMySize.Width()) >> 1),
aP.Y() + ((aS.Height() - aMySize.Height()) >> 1)));
}
}
sal_uInt16 aMessResult = xBox->Execute();
DialogMask aResult = DialogMask::NONE;
@@ -1110,7 +1134,7 @@
aTitle += aErrTitle;
executeMessageBox(
getParentProperty(), aTitle, aErrorString, MessBoxStyle::Ok );
getParentProperty(), aTitle, aErrorString, MessBoxStyle::Ok, Dialog::InitFlag::NoParentCentered);
}
else
ErrorHandler::HandleError(nErrorCode);
@@ -1226,7 +1250,7 @@
utl::ConfigManager::getProductVersion() );
switch (
executeMessageBox( getParentProperty(), title, aMessage, nButtonMask ) )
executeMessageBox( getParentProperty(), title, aMessage, nButtonMask, Dialog::InitFlag::NoParentCentered) )
{
case DialogMask::ButtonsOk:
OSL_ENSURE( xAbort.is(), "unexpected situation" );
diff --git a/uui/source/lockcorrupt.cxx b/uui/source/lockcorrupt.cxx
index 5812216..cfc2ed3 100644
--- a/uui/source/lockcorrupt.cxx
+++ b/uui/source/lockcorrupt.cxx
@@ -24,7 +24,7 @@
#include <vcl/button.hxx>
LockCorruptQueryBox::LockCorruptQueryBox(vcl::Window* pParent, const std::locale& rResLocale)
: MessBox(pParent, MessBoxStyle::NONE, Translate::get(STR_LOCKCORRUPT_TITLE, rResLocale), OUString())
: MessBox(pParent, MessBoxStyle::NONE, 0, Translate::get(STR_LOCKCORRUPT_TITLE, rResLocale), OUString())
{
SetImage( ErrorBox::GetStandardImage() );
diff --git a/uui/source/lockfailed.cxx b/uui/source/lockfailed.cxx
index 80209ee..2dbf095 100644
--- a/uui/source/lockfailed.cxx
+++ b/uui/source/lockfailed.cxx
@@ -23,7 +23,7 @@
#include <vcl/button.hxx>
LockFailedQueryBox::LockFailedQueryBox(vcl::Window* pParent, const std::locale& rResLocale)
: MessBox(pParent, MessBoxStyle::NONE, Translate::get(STR_LOCKFAILED_TITLE, rResLocale), OUString())
: MessBox(pParent, MessBoxStyle::NONE, 0, Translate::get(STR_LOCKFAILED_TITLE, rResLocale), OUString())
{
SetImage( ErrorBox::GetStandardImage() );
diff --git a/uui/source/openlocked.cxx b/uui/source/openlocked.cxx
index dfd5942..84f69bc 100644
--- a/uui/source/openlocked.cxx
+++ b/uui/source/openlocked.cxx
@@ -22,7 +22,7 @@
#include <unotools/resmgr.hxx>
OpenLockedQueryBox::OpenLockedQueryBox( vcl::Window* pParent, const std::locale& rResLocale, const OUString& aMessage ) :
MessBox(pParent, MessBoxStyle::NONE,
MessBox(pParent, MessBoxStyle::NONE, 0,
Translate::get(STR_OPENLOCKED_TITLE, rResLocale),
aMessage )
{
diff --git a/uui/source/trylater.cxx b/uui/source/trylater.cxx
index 01a0950..2e996d9 100644
--- a/uui/source/trylater.cxx
+++ b/uui/source/trylater.cxx
@@ -22,7 +22,7 @@
#include "trylater.hxx"
TryLaterQueryBox::TryLaterQueryBox(vcl::Window* pParent, const std::locale& rResLocale, const OUString& aMessage)
: MessBox(pParent, MessBoxStyle::NONE, Translate::get(STR_TRYLATER_TITLE, rResLocale), aMessage)
: MessBox(pParent, MessBoxStyle::NONE, 0, Translate::get(STR_TRYLATER_TITLE, rResLocale), aMessage)
{
SetImage( QueryBox::GetStandardImage() );
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 9edd2e9..65e1c10 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -144,6 +144,7 @@
bool mbInAppMain = false; // is Application::Main() on stack
bool mbInAppExecute = false; // is Application::Execute() on stack
bool mbAppQuit = false; // is Application::Quit() called
bool mbShutdownDelayed = false;
bool mbSettingsInit = false; // true: Settings are initialized
Application::DialogCancelMode meDialogCancel = Application::DialogCancelMode::Off; // true: All Dialog::Execute() calls will be terminated immediately with return false
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index c4b9007..5a5be86 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -1677,4 +1677,20 @@
pSVData->maAppData.mbInAppMain = true;
}
void Application::SetShutdownDelayed()
{
ImplSVData * pSVData = ImplGetSVData();
pSVData->maAppData.mbShutdownDelayed = true;
}
void Application::TriggerShutdownDelayed()
{
ImplSVData * pSVData = ImplGetSVData();
if (pSVData->maAppData.mbShutdownDelayed && !Dialog::AreDialogsOpen())
{
Application::PostUserEvent(LINK(nullptr, ImplSVAppData, ImplPrepareExitMsg));
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index aa25bae..1ad300f 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -356,6 +356,36 @@
mpDialogImpl.reset(new DialogImpl);
}
vcl::Window* Dialog::GetDefaultParent(WinBits nStyle)
{
vcl::Window* pParent = Application::GetDefDialogParent();
if (!pParent && !(nStyle & WB_SYSTEMWINDOW))
pParent = ImplGetSVData()->maWinData.mpAppWin;
// If Parent is disabled, then we search for a modal dialog
// in this frame
if (pParent && (!pParent->IsInputEnabled() || pParent->IsInModalMode()))
{
ImplSVData* pSVData = ImplGetSVData();
Dialog* pExeDlg = pSVData->maWinData.mpLastExecuteDlg;
while (pExeDlg)
{
// only if visible and enabled
if (pParent->ImplGetFirstOverlapWindow()->IsWindowOrChild(pExeDlg, true) &&
pExeDlg->IsReallyVisible() &&
pExeDlg->IsEnabled() && pExeDlg->IsInputEnabled() && !pExeDlg->IsInModalMode())
{
pParent = pExeDlg;
break;
}
pExeDlg = pExeDlg->mpPrevExecuteDlg;
}
}
return pParent;
}
void Dialog::ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag )
{
SystemWindowFlags nSysWinMode = Application::GetSystemWindowMode();
@@ -367,34 +397,13 @@
// Now, all Dialogs are per default system windows !!!
nStyle |= WB_SYSTEMWINDOW;
if (eFlag == InitFlag::NoParent)
if (InitFlag::NoParent == eFlag || InitFlag::NoParentCentered == eFlag)
{
pParent = nullptr;
}
else if (!pParent) // parent is NULL: get the default Dialog parent
{
pParent = Application::GetDefDialogParent();
if ( !pParent && !(nStyle & WB_SYSTEMWINDOW) )
pParent = ImplGetSVData()->maWinData.mpAppWin;
// If Parent is disabled, then we search for a modal dialog
// in this frame
if ( pParent && (!pParent->IsInputEnabled() || pParent->IsInModalMode()) )
{
ImplSVData* pSVData = ImplGetSVData();
Dialog* pExeDlg = pSVData->maWinData.mpLastExecuteDlg;
while ( pExeDlg )
{
// only if visible and enabled
if ( pParent->ImplGetFirstOverlapWindow()->IsWindowOrChild( pExeDlg, true ) &&
pExeDlg->IsReallyVisible() &&
pExeDlg->IsEnabled() && pExeDlg->IsInputEnabled() && !pExeDlg->IsInModalMode() )
{
pParent = pExeDlg;
break;
}
pExeDlg = pExeDlg->mpPrevExecuteDlg;
}
}
pParent = Dialog::GetDefaultParent(nStyle);
}
if ( !pParent || (nStyle & WB_SYSTEMWINDOW) ||
@@ -1011,6 +1020,14 @@
}
}
bool Dialog::AreDialogsOpen()
{
ImplSVData* pSVData = ImplGetSVData();
Dialog* pModDialog = pSVData->maWinData.mpLastExecuteDlg;
return (nullptr != pModDialog);
}
void Dialog::SetModalInputMode( bool bModal )
{
if ( bModal == mbModalMode )
diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx
index e00f2e4..096ad1f57 100644
--- a/vcl/source/window/msgbox.cxx
+++ b/vcl/source/window/msgbox.cxx
@@ -122,21 +122,15 @@
}
}
MessBox::MessBox( vcl::Window* pParent, MessBoxStyle nMessBoxStyle,
const OUString& rTitle, const OUString& rMessage ) :
MessBox(pParent, nMessBoxStyle, 0, rTitle, rMessage)
{
}
MessBox::MessBox( vcl::Window* pParent, MessBoxStyle nMessBoxStyle, WinBits nWinBits,
const OUString& rTitle, const OUString& rMessage ) :
const OUString& rTitle, const OUString& rMessage, Dialog::InitFlag eInitFlag) :
ButtonDialog( WindowType::MESSBOX ),
mbHelpBtn( false ),
mbCheck( false ),
mnMessBoxStyle( nMessBoxStyle ),
maMessText( rMessage )
{
ImplInit( pParent, nWinBits | WB_MOVEABLE | WB_HORZ | WB_CENTER );
ImplInit( pParent, nWinBits | WB_MOVEABLE | WB_HORZ | WB_CENTER, eInitFlag);
ImplInitButtons();
if ( !rTitle.isEmpty() )
@@ -373,7 +367,7 @@
}
InfoBox::InfoBox( vcl::Window* pParent, const OUString& rMessage ) :
MessBox( pParent, MessBoxStyle::Ok | MessBoxStyle::DefaultOk, OUString(), rMessage )
MessBox( pParent, MessBoxStyle::Ok | MessBoxStyle::DefaultOk, 0, OUString(), rMessage )
{
// Default Text is the display title from the application
if ( GetText().isEmpty() )
@@ -383,7 +377,7 @@
}
InfoBox::InfoBox( vcl::Window* pParent, MessBoxStyle nStyle, const OUString& rMessage ) :
MessBox( pParent, nStyle, OUString(), rMessage )
MessBox( pParent, nStyle, 0, OUString(), rMessage )
{
// Default Text is the display title from the application
if ( GetText().isEmpty() )
@@ -437,7 +431,7 @@
}
ErrorBox::ErrorBox( vcl::Window* pParent, const OUString& rMessage ) :
MessBox( pParent, MessBoxStyle::Ok | MessBoxStyle::DefaultOk, OUString(), rMessage )
MessBox( pParent, MessBoxStyle::Ok | MessBoxStyle::DefaultOk, 0, OUString(), rMessage )
{
// Default Text is the display title from the application
if ( GetText().isEmpty() )