summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oovbaapi/ooo/vba/excel/XApplicationOutgoing.idl1
-rw-r--r--sc/source/ui/docshell/docsh.cxx32
-rw-r--r--sc/source/ui/inc/docsh.hxx6
-rw-r--r--sc/source/ui/vba/vbaworkbook.cxx3
4 files changed, 41 insertions, 1 deletions
diff --git a/oovbaapi/ooo/vba/excel/XApplicationOutgoing.idl b/oovbaapi/ooo/vba/excel/XApplicationOutgoing.idl
index 9e601c5331d6..6ca5b4581d75 100644
--- a/oovbaapi/ooo/vba/excel/XApplicationOutgoing.idl
+++ b/oovbaapi/ooo/vba/excel/XApplicationOutgoing.idl
@@ -25,6 +25,7 @@ module ooo { module vba { module excel {
interface XApplicationOutgoing : XInterfaceWithIID
{
+ void NewWorkbook([in] any Wb);
void WorkbookOpen([in] any Wb);
void WorkbookBeforeClose([in] any Wb, [out] any Cancel);
};
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index d2ae9a945c18..362ddbd0a6e7 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1080,6 +1080,33 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
pClipDoc->ClosingClipboardSource();
}
}
+
+ if ( const SfxEventHint* pSfxEventHint = dynamic_cast<const SfxEventHint*>(&rHint) )
+ {
+ switch( pSfxEventHint->GetEventId() )
+ {
+ case SfxEventHintId::CreateDoc:
+ {
+ uno::Any aWorkbook;
+ aWorkbook <<= mxAutomationWorkbookObject;
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[0] = aWorkbook;
+ SC_MOD()->CallAutomationApplicationEventSinks( "NewWorkbook", aArgs );
+ }
+ break;
+ case SfxEventHintId::OpenDoc:
+ {
+ uno::Any aWorkbook;
+ aWorkbook <<= mxAutomationWorkbookObject;
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[0] = aWorkbook;
+ SC_MOD()->CallAutomationApplicationEventSinks( "WorkbookOpen", aArgs );
+ }
+ break;
+ default:
+ break;
+ }
+ }
}
// Load contents for organizer
@@ -3340,6 +3367,11 @@ void ScDocShell::SetIsInUcalc()
mbUcalcTest = true;
}
+void ScDocShell::RegisterAutomationWorkbookObject(css::uno::Reference< ooo::vba::excel::XWorkbook > const& xWorkbook)
+{
+ mxAutomationWorkbookObject = xWorkbook;
+}
+
extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportSLK(SvStream &rStream)
{
ScDLL::Init();
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 29fe6de0873d..55cbdb91e652 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -20,8 +20,8 @@
#ifndef INCLUDED_SC_SOURCE_UI_INC_DOCSH_HXX
#define INCLUDED_SC_SOURCE_UI_INC_DOCSH_HXX
+#include <ooo/vba/excel/XWorkbook.hpp>
#include <sfx2/objsh.hxx>
-
#include <sfx2/docfac.hxx>
#include <sfx2/sfxmodelfactory.hxx>
#include <sfx2/viewsh.hxx>
@@ -114,6 +114,8 @@ class SC_DLLPUBLIC ScDocShell final: public SfxObjectShell, public SfxListener
ScDocShellModificator* pModificator; // #109979#; is used to load XML (created in BeforeXMLLoading and destroyed in AfterXMLLoading)
+ css::uno::Reference< ooo::vba::excel::XWorkbook> mxAutomationWorkbookObject;
+
// Only used by Vba helper functions
css::uno::Reference<css::script::vba::XVBAScriptListener> m_xVBAListener;
css::uno::Reference<css::datatransfer::XTransferable2> m_xClipData;
@@ -427,6 +429,8 @@ public:
void SnapVisArea( tools::Rectangle& rRect ) const;
void SetIsInUcalc();
+
+ void RegisterAutomationWorkbookObject(css::uno::Reference< ooo::vba::excel::XWorkbook > const& xWorkbook);
};
void UpdateAcceptChangesDialog();
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
index 96ee2bf64a99..93f773838195 100644
--- a/sc/source/ui/vba/vbaworkbook.cxx
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -201,6 +201,9 @@ ScVbaWorkbook::init()
{
if ( !ColorData.getLength() )
ResetColors();
+ uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY );
+ if ( xModel.is() )
+ excel::getDocShell( xModel )->RegisterAutomationWorkbookObject( this );
}
ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, css::uno::Reference< css::frame::XModel > const & xModel ) : ScVbaWorkbook_BASE( xParent, xContext, xModel )