20#ifndef INCLUDED_VBAHELPER_VBAEVENTSHELPERBASE_HXX
21#define INCLUDED_VBAHELPER_VBAEVENTSHELPERBASE_HXX
25#include <unordered_map>
27#include <com/sun/star/document/XEventListener.hpp>
28#include <com/sun/star/lang/EventObject.hpp>
29#include <com/sun/star/lang/XServiceInfo.hpp>
30#include <com/sun/star/lang/IllegalArgumentException.hpp>
31#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
32#include <com/sun/star/uno/Any.hxx>
33#include <com/sun/star/uno/Reference.hxx>
34#include <com/sun/star/uno/Sequence.hxx>
35#include <com/sun/star/util/XChangesListener.hpp>
37#include <rtl/ustring.hxx>
42 namespace document {
struct EventObject; }
43 namespace frame {
class XModel; }
44 namespace script::vba {
class XVBAModuleInfo; }
45 namespace uno {
class XComponentContext; }
46 namespace util {
struct ChangesEvent; }
51typedef ::cppu::WeakImplHelper<
52 css::script::vba::XVBAEventProcessor,
53 css::document::XEventListener,
54 css::util::XChangesListener,
61 const css::uno::Sequence< css::uno::Any >& rArgs );
65 virtual sal_Bool SAL_CALL hasVbaEventHandler( sal_Int32 nEventId,
const css::uno::Sequence< css::uno::Any >& rArgs )
override;
66 virtual sal_Bool SAL_CALL processVbaEvent( sal_Int32 nEventId,
const css::uno::Sequence< css::uno::Any >& rArgs )
override;
69 virtual void SAL_CALL notifyEvent(
const css::document::EventObject& rEvent )
override;
72 virtual void SAL_CALL changesOccurred(
const css::util::ChangesEvent& rEvent )
override;
75 virtual void SAL_CALL disposing(
const css::lang::EventObject& rEvent )
override;
81 bool hasModule(
const OUString& rModuleName);
84 void processVbaEventNoThrow( sal_Int32 nEventId,
const css::uno::Sequence< css::uno::Any >& rArgs );
87 static void checkArgument(
const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex )
88 {
if( (
nIndex < 0) || (
nIndex >= rArgs.getLength()) )
throw css::lang::IllegalArgumentException(); }
91 template<
typename Type >
92 static void checkArgumentType(
const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex )
93 { checkArgument( rArgs,
nIndex );
if( !rArgs[
nIndex ].has< Type >() )
throw css::lang::IllegalArgumentException(); }
114 void registerEventHandler(
116 sal_Int32 nModuleType,
117 const char* pcMacroName,
118 sal_Int32 nCancelIndex = -1,
119 const css::uno::Any& rUserData = css::uno::Any() );
125 css::uno::Sequence< css::uno::Any >
maArgs;
139 const css::uno::Sequence< css::uno::Any >& rArgs ) = 0;
148 const css::uno::Sequence< css::uno::Any >& rArgs ) = 0;
167 const css::uno::Sequence< css::uno::Any >& rArgs )
const = 0;
173 void startListening();
175 void stopListening();
190 OUString getEventHandlerPath(
192 const css::uno::Sequence< css::uno::Any >& rArgs );
198 void ensureVBALibrary();
204 sal_Int32 getModuleType(
const OUString& rModuleName );
210 ModulePathMap& updateModulePathMap(
const OUString& rModuleName );
213 css::uno::Reference< css::frame::XModel >
mxModel;
const sal_Int16 mnEventId
::std::deque< EventQueueEntry > EventQueue
virtual void implPostProcessEvent(EventQueue &rEventQueue, const EventHandlerInfo &rInfo, bool bCancel)=0
Derived classes may do additional postprocessing.
EventHandlerInfoMap maEventInfos
EventHandlerPathMap maEventPaths
virtual bool implPrepareEvent(EventQueue &rEventQueue, const EventHandlerInfo &rInfo, const css::uno::Sequence< css::uno::Any > &rArgs)=0
Derived classes do additional preparations and return whether the event handler has to be called.
std::map< sal_Int32, EventHandlerInfo > EventHandlerInfoMap
virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList(const EventHandlerInfo &rInfo, const css::uno::Sequence< css::uno::Any > &rArgs)=0
Derived classes have to return the argument list for the specified VBA event handler.
css::uno::Reference< css::script::vba::XVBAModuleInfo > mxModuleInfos
std::unordered_map< OUString, ModulePathMap > EventHandlerPathMap
::std::map< sal_Int32, OUString > ModulePathMap
virtual OUString implGetDocumentModuleName(const EventHandlerInfo &rInfo, const css::uno::Sequence< css::uno::Any > &rArgs) const =0
Derived classes have to return the name of the Basic document module.
css::uno::Reference< css::frame::XModel > mxModel
static void checkArgumentType(const css::uno::Sequence< css::uno::Any > &rArgs, sal_Int32 nIndex)
static void checkArgument(const css::uno::Sequence< css::uno::Any > &rArgs, sal_Int32 nIndex)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
EventQueueEntry(sal_Int32 nEventId)
css::uno::Sequence< css::uno::Any > maArgs
EventQueueEntry(sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any > &rArgs)
#define VBAHELPER_DLLPUBLIC
::cppu::WeakImplHelper< css::script::vba::XVBAEventProcessor, css::document::XEventListener, css::util::XChangesListener, css::lang::XServiceInfo > VbaEventsHelperBase_BASE