summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-04-16 18:42:25 +0300
committerTor Lillqvist <tml@collabora.com>2018-05-31 21:50:29 +0300
commit2ea6e4c00c1d3c5e020935c4fa2eca3ff3ee13e6 (patch)
treec566cb1c2fb90a7457837771c5409d400ad2abe0 /sw
parent467e76889e8a8b8d42904f0d11c1c27f8ce1c4a0 (diff)
If a DocumentBeforeClose event handler says no, don't then
Change-Id: I13601337a78d22eca1df185fb4d51b34a90925f3 (cherry picked from commit 91fd5449c6f3f2c2114992da7def915a9f90a580)
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/app/docsh2.cxx24
1 files changed, 17 insertions, 7 deletions
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 809633cd8eff..a8c0f522c9d2 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.
*
@@ -360,23 +360,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() )