diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-11-23 14:05:26 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-11-24 09:55:17 +0100 |
commit | 6f31670783b3445a8073bd49fe4c041b655e91b3 (patch) | |
tree | 3cbfc77e7f9e8191c6eaded7f92633f9808ba414 /sfx2 | |
parent | 99534540df148513fc0bb9622b7285e10b285ccb (diff) |
set new document window as parent for dialogs during load
and exit typedetection early and completely if application quits
while detecting
During typedetection, before loading proper, we have the hidden window as
parent so warnings are not modal to existing windows and they are cancelled on
exit.
Once we do have a window, then reinit interaction handler to have that window
as the parent for any further dialogs.
Change-Id: I5c6711557266bf7d1eb9291f1c454cbfaf766886
Reviewed-on: https://gerrit.libreoffice.org/45148
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/preventduplicateinteraction.hxx | 4 | ||||
-rw-r--r-- | sfx2/source/appl/preventduplicateinteraction.cxx | 17 |
2 files changed, 19 insertions, 2 deletions
diff --git a/sfx2/inc/preventduplicateinteraction.hxx b/sfx2/inc/preventduplicateinteraction.hxx index 9e31a5bcc829..5e1db5043aec 100644 --- a/sfx2/inc/preventduplicateinteraction.hxx +++ b/sfx2/inc/preventduplicateinteraction.hxx @@ -25,6 +25,7 @@ #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/TerminationVetoException.hpp> #include <com/sun/star/frame/XTerminateListener2.hpp> +#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/task/XInteractionHandler2.hpp> #include <com/sun/star/task/XInteractionRequest.hpp> @@ -160,7 +161,7 @@ struct ThreadHelpBase2 }; class PreventDuplicateInteraction : private ThreadHelpBase2 - ,public ::cppu::WeakImplHelper< css::task::XInteractionHandler2 > + , public ::cppu::WeakImplHelper<css::lang::XInitialization, css::task::XInteractionHandler2> { // structs, types etc. @@ -220,6 +221,7 @@ class PreventDuplicateInteraction : private ThreadHelpBase2 // uno interface public: + virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override; /** @interface XInteractionHandler diff --git a/sfx2/source/appl/preventduplicateinteraction.cxx b/sfx2/source/appl/preventduplicateinteraction.cxx index 009754cae517..ffe89813c0db 100644 --- a/sfx2/source/appl/preventduplicateinteraction.cxx +++ b/sfx2/source/appl/preventduplicateinteraction.cxx @@ -42,6 +42,7 @@ void PreventDuplicateInteraction::setHandler(const css::uno::Reference< css::tas { // SAFE -> ::osl::ResettableMutexGuard aLock(m_aLock); + m_xWarningDialogsParent.reset(); m_xHandler = xHandler; aLock.clear(); // <- SAFE @@ -54,6 +55,8 @@ void PreventDuplicateInteraction::useDefaultUUIHandler() aLock.clear(); // <- SAFE + //if we use the default handler, set the parent to a window belonging to this object so that the dialogs + //don't block unrelated windows. m_xWarningDialogsParent.reset(new WarningDialogsParentScope(m_xContext)); css::uno::Reference<css::task::XInteractionHandler> xHandler(css::task::InteractionHandler::createWithParent( m_xContext, m_xWarningDialogsParent->GetDialogParent()), css::uno::UNO_QUERY_THROW); @@ -74,7 +77,7 @@ css::uno::Any SAL_CALL PreventDuplicateInteraction::queryInterface( const css::u if ( !xHandler.is() ) return css::uno::Any(); } - return ::cppu::WeakImplHelper< css::task::XInteractionHandler2 >::queryInterface( aType ); + return ::cppu::WeakImplHelper<css::lang::XInitialization, css::task::XInteractionHandler2>::queryInterface(aType); } void SAL_CALL PreventDuplicateInteraction::handle(const css::uno::Reference< css::task::XInteractionRequest >& xRequest) @@ -230,6 +233,18 @@ bool PreventDuplicateInteraction::getInteractionInfo(const css::uno::Type& return false; } +void SAL_CALL PreventDuplicateInteraction::initialize(const css::uno::Sequence<css::uno::Any>& rArguments) +{ + // If we're re-initialized to set a specific new window as a parent then drop our temporary + // dialog parent + css::uno::Reference<css::lang::XInitialization> xHandler(m_xHandler, css::uno::UNO_QUERY); + if (xHandler.is()) + { + m_xWarningDialogsParent.reset(); + xHandler->initialize(rArguments); + } +} + IMPL_STATIC_LINK_NOARG(WarningDialogsParent, TerminateDesktop, void*, void) { css::frame::Desktop::create(comphelper::getProcessComponentContext())->terminate(); |