diff options
author | Tor Lillqvist <tml@collabora.com> | 2018-04-16 18:42:25 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2018-05-31 14:21:51 +0300 |
commit | 91fd5449c6f3f2c2114992da7def915a9f90a580 (patch) | |
tree | 90922ff0d3b3c3bef986d723ed72930896a1c68c | |
parent | bbe55ee8e78b2e293234ea8d2b234c4cd7091aa1 (diff) |
If a DocumentBeforeClose event handler says no, don't then
Change-Id: I13601337a78d22eca1df185fb4d51b34a90925f3
-rw-r--r-- | sw/source/uibase/app/docsh2.cxx | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx index 2042640d66c9..a6b11a5f4500 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * @@ -365,23 +365,33 @@ bool SwDocShell::PrepareClose( bool bUI ) { bool bRet = SfxObjectShell::PrepareClose( bUI ); - if( bRet ) - EndListening( *this ); - - if (m_xDoc && IsInPrepareClose()) + // If we are going to close it at this point, let potential DocumentBeforeClose event handlers + // in Automation clients veto it. + if (bRet && m_xDoc && IsInPrepareClose()) { uno::Any aDocument; aDocument <<= mxAutomationDocumentObject; uno::Sequence< uno::Any > aArgs(2); + // Arg 0: Document aArgs[0] = aDocument; - // FIXME: This should be an out argument, hmm? + // Arg 1: Cancel aArgs[1] <<= false; SW_MOD()->CallAutomationApplicationEventSinks( "DocumentBeforeClose", aArgs ); - // FIXME: Do something based on what value the callback set the second argument to + // If the Cancel argument was set to True by an event handler, return false. + bool bCancel; + aArgs[1] >>= bCancel; + if (bCancel) + bRet = false; + } + + if( bRet ) + EndListening( *this ); + if (m_xDoc && IsInPrepareClose()) + { uno::Reference< script::vba::XVBAEventProcessor > const xVbaEvents = m_xDoc->GetVbaEventProcessor(); if( xVbaEvents.is() ) |