Kaydet (Commit) 7d275e3a authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Implement NewWorkbook and WorkbookOpen Automation callbacks in Calc

Change-Id: I1ff31d692100695a706bf128c18c4e3ae8b55ce3
üst ad57e6d3
......@@ -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);
};
......
......@@ -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();
......
......@@ -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();
......
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment