summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorDaniel Rentz <dr@openoffice.org>2010-07-06 19:34:53 +0200
committerDaniel Rentz <dr@openoffice.org>2010-07-06 19:34:53 +0200
commitc449069c0608be9f263392589cb2c91e44bc9e8b (patch)
tree76ee6e4f7df568f5d2cd21c5e009939708f7b753 /sfx2
parentb687b636115b17970db28c389a8d28040ace86d1 (diff)
mib17: #i112634# add VBA sheet event handling, based on a patch from Noel Power
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/inc/sfx2/objsh.hxx1
-rw-r--r--sfx2/source/doc/objserv.cxx24
-rw-r--r--sfx2/source/view/viewprn.cxx18
3 files changed, 43 insertions, 0 deletions
diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx
index d514235cbfa2..49223c23de75 100644
--- a/sfx2/inc/sfx2/objsh.hxx
+++ b/sfx2/inc/sfx2/objsh.hxx
@@ -292,6 +292,7 @@ public:
sal_Bool IsReadOnlyUI() const;
void SetNoName();
sal_Bool IsInModalMode() const;
+ sal_Bool IsInPrepareClose() const;
//<!--Added by PengYunQuan for Validity Cell Range Picker
virtual sal_Bool AcceptStateUpdate() const;
//-->Added by PengYunQuan for Validity Cell Range Picker
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index c063546da1c7..ae3b527ff7a6 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -100,6 +100,7 @@
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/util/XCloneable.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/script/vba/XCoreEventProcessor.hpp>
#include "helpid.hrc"
@@ -489,6 +490,22 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
case SID_SAVEASDOC:
case SID_SAVEDOC:
{
+ // ask VBA emulation at document model whether to save the document
+ if( nId == SID_SAVEDOC || nId == SID_SAVEASDOC ) try
+ {
+ Reference< script::vba::XCoreEventProcessor > xEventProcessor( GetModel(), UNO_QUERY_THROW );
+ xEventProcessor->processCoreVbaEvent( nId );
+ }
+ catch( util::VetoException& )
+ {
+ // VBA event handler indicates to cancel saving the document
+ rReq.SetReturnValue( SfxBoolItem( 0, TRUE ) );
+ return;
+ }
+ catch( Exception& )
+ {
+ }
+
//!! detaillierte Auswertung eines Fehlercodes
SfxObjectShellRef xLock( this );
@@ -895,6 +912,13 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
rReq.Done();
}
+//-------------------------------------------------------------------------
+
+sal_Bool SfxObjectShell::IsInPrepareClose() const
+{
+ return pImp->bInPrepareClose;
+}
+
//--------------------------------------------------------------------
void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index f62ae4c1ddc7..faf392c90f32 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -29,6 +29,7 @@
#include "precompiled_sfx2.hxx"
#include <com/sun/star/document/XDocumentProperties.hpp>
+#include <com/sun/star/script/vba/XCoreEventProcessor.hpp>
#include <com/sun/star/view/PrintableState.hpp>
#include "com/sun/star/view/XRenderable.hpp"
@@ -697,6 +698,23 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
case SID_PRINTDOCDIRECT:
{
SfxObjectShell* pDoc = GetObjectShell();
+
+ // ask VBA emulation at document model whether to print the document
+ try
+ {
+ uno::Reference< script::vba::XCoreEventProcessor > xEventProcessor( pDoc->GetModel(), uno::UNO_QUERY_THROW );
+ xEventProcessor->processCoreVbaEvent( nId );
+ }
+ catch( util::VetoException& )
+ {
+ // VBA event handler indicates to cancel printing the document
+ rReq.SetReturnValue( SfxBoolItem( 0, FALSE ) );
+ return;
+ }
+ catch( uno::Exception& )
+ {
+ }
+
bool bDetectHidden = ( !bSilent && pDoc );
if ( bDetectHidden && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES )
break;