diff options
author | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2017-12-07 14:26:16 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2017-12-07 14:27:00 +0100 |
commit | 64d2902a61f6aa90554bc76fe70aee78bba6b3dd (patch) | |
tree | c908119459bf513ba42b7d48f0c47a12be729881 /include | |
parent | 59fdcff85389456a5710bd101dbf2b01c70c2b02 (diff) |
Revert "Resolves: tdf#113160 changing all warning dialogs to non-modal is unsafe"
This reverts commit e0dc344395393c8a9364952a5d241c12fa8b8f54.
Had to redo this because some commits before and after were missing.
Diffstat (limited to 'include')
-rw-r--r-- | include/framework/preventduplicateinteraction.hxx | 112 | ||||
-rw-r--r-- | include/vcl/dialog.hxx | 10 | ||||
-rw-r--r-- | include/vcl/msgbox.hxx | 3 | ||||
-rw-r--r-- | include/vcl/svapp.hxx | 6 |
4 files changed, 15 insertions, 116 deletions
diff --git a/include/framework/preventduplicateinteraction.hxx b/include/framework/preventduplicateinteraction.hxx index 00c76089da2a..cf6ac0058eda 100644 --- a/include/framework/preventduplicateinteraction.hxx +++ b/include/framework/preventduplicateinteraction.hxx @@ -24,127 +24,17 @@ #include <vector> -#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/task/XInteractionHandler2.hpp> #include <com/sun/star/task/XInteractionRequest.hpp> -#include <cppuhelper/compbase.hxx> #include <cppuhelper/implbase.hxx> -#include <sfx2/app.hxx> -#include <toolkit/helper/vclunohelper.hxx> -#include <vcl/dialog.hxx> -#include <vcl/svapp.hxx> -#include <vcl/wrkwin.hxx> - namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; } } } } namespace framework{ -inline void closedialogs(SystemWindow& rTopLevel, bool bCloseRoot) -{ - for (vcl::Window *pChild = rTopLevel.GetWindow(GetWindowType::FirstTopWindowChild); pChild; pChild = rTopLevel.GetWindow(GetWindowType::NextTopWindowSibling)) - closedialogs(dynamic_cast<SystemWindow&>(*pChild), true); - if (bCloseRoot) - rTopLevel.Close(); -} - -// This is intended to be the parent for any warning dialogs launched -// during the load of a document so that those dialogs are modal to -// this window and don't block any existing windows. -// -// If there are dialog children open on exit then veto termination, -// close the topmost dialog and retry termination. -class WarningDialogsParent : - public cppu::WeakComponentImplHelper<css::frame::XTerminateListener> -{ -private: - osl::Mutex m_aLock; - VclPtr<WorkWindow> m_xWin; - css::uno::Reference<css::awt::XWindow> m_xInterface; - -private: - - DECL_STATIC_LINK_TYPED(WarningDialogsParent, TerminateDesktop, void*, void); - - void closewarningdialogs() - { - if (!m_xWin) - return; - SolarMutexGuard aSolarGuard; - closedialogs(dynamic_cast<SystemWindow&>(*m_xWin), false); - } - -public: - - using cppu::WeakComponentImplHelperBase::disposing; - virtual void SAL_CALL disposing(const css::lang::EventObject&) throw (::css::uno::RuntimeException, ::std::exception) override - { - } - - // XTerminateListener - virtual void SAL_CALL queryTermination(const css::lang::EventObject&) throw (::css::frame::TerminationVetoException, ::css::uno::RuntimeException, ::std::exception) override - { - closewarningdialogs(); - Application::PostUserEvent(LINK(this, WarningDialogsParent, TerminateDesktop)); - throw css::frame::TerminationVetoException(); - } - - virtual void SAL_CALL notifyTermination(const css::lang::EventObject&) throw (::css::uno::RuntimeException, ::std::exception) override - { - } - -public: - WarningDialogsParent() - : cppu::WeakComponentImplHelper<css::frame::XTerminateListener>(m_aLock) - { - SolarMutexGuard aSolarGuard; - m_xWin = VclPtr<WorkWindow>::Create(nullptr, WB_STDWORK); - m_xWin->SetText("dialog parent for warning dialogs during load"); - m_xInterface = VCLUnoHelper::GetInterface(m_xWin); - } - - virtual ~WarningDialogsParent() override - { - closewarningdialogs(); - m_xWin.disposeAndClear(); - } - - const css::uno::Reference<css::awt::XWindow>& GetDialogParent() const - { - return m_xInterface; - } -}; - -class WarningDialogsParentScope -{ -private: - css::uno::Reference<css::frame::XDesktop> m_xDesktop; - rtl::Reference<WarningDialogsParent> m_xListener; - -public: - WarningDialogsParentScope(const css::uno::Reference<css::uno::XComponentContext>& rContext) - : m_xDesktop(css::frame::Desktop::create(rContext), css::uno::UNO_QUERY_THROW) - , m_xListener(new WarningDialogsParent) - { - m_xDesktop->addTerminateListener(m_xListener.get()); - } - - const css::uno::Reference<css::awt::XWindow>& GetDialogParent() const - { - return m_xListener->GetDialogParent(); - } - - ~WarningDialogsParentScope() - { - m_xDesktop->removeTerminateListener(m_xListener.get()); - } -}; - /** @short Prevent us from showing the same interaction more than once during the same transaction. @@ -211,8 +101,6 @@ class FWE_DLLPUBLIC PreventDuplicateInteraction : private ThreadHelpBase2 if it's not blocked. */ css::uno::Reference< css::task::XInteractionHandler > m_xHandler; - std::unique_ptr<WarningDialogsParentScope> m_xWarningDialogsParent; - /** This list describe which and how incoming interactions must be handled. Further it contains all collected information after this interaction object was used.*/ diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index 34e03fc03a99..87588d50c85d 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -38,8 +38,11 @@ public: /** Use given parent or get a default one using GetDefaultParent(...) */ Default, - /** No Parent */ - NoParent + /** 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: @@ -121,7 +124,8 @@ public: void EndDialog( long nResult = 0 ); - static void EndAllDialogs( vcl::Window const * pParent ); + static void EndAllDialogs( vcl::Window* pParent=nullptr ); + 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 f3351664574c..0f526f618fe6 100644 --- a/include/vcl/msgbox.hxx +++ b/include/vcl/msgbox.hxx @@ -47,7 +47,8 @@ protected: public: MessBox( vcl::Window* pParent, WinBits nStyle, - const OUString& rTitle, const OUString& rMessage); + const OUString& rTitle, const OUString& rMessage, + Dialog::InitFlag eInitFlag = Dialog::InitFlag::NoParentCentered); virtual ~MessBox(); virtual void dispose() override; diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index 34b659fa7f33..2be63c268198 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -1451,6 +1451,12 @@ public: // 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_TYPED( Application, PostEventHandler, void*, void ); }; |