LibreOffice Module vbahelper (master) 1
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
VbaEventsHelperBase Class Referenceabstract

#include <vbaeventshelperbase.hxx>

Inheritance diagram for VbaEventsHelperBase:
[legend]
Collaboration diagram for VbaEventsHelperBase:
[legend]

Classes

struct  EventHandlerInfo
 
struct  EventQueueEntry
 

Public Member Functions

 VbaEventsHelperBase (const css::uno::Sequence< css::uno::Any > &rArgs)
 
virtual ~VbaEventsHelperBase () override
 
virtual sal_Bool SAL_CALL hasVbaEventHandler (sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any > &rArgs) override
 
virtual sal_Bool SAL_CALL processVbaEvent (sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any > &rArgs) override
 
virtual void SAL_CALL notifyEvent (const css::document::EventObject &rEvent) override
 
virtual void SAL_CALL changesOccurred (const css::util::ChangesEvent &rEvent) override
 
virtual void SAL_CALL disposing (const css::lang::EventObject &rEvent) override
 
sal_Bool SAL_CALL supportsService (OUString const &ServiceName) override
 
bool hasModule (const OUString &rModuleName)
 
void processVbaEventNoThrow (sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any > &rArgs)
 Helper to execute event handlers without throwing any exceptions. More...
 

Static Public Member Functions

static void checkArgument (const css::uno::Sequence< css::uno::Any > &rArgs, sal_Int32 nIndex)
 
template<typename Type >
static void checkArgumentType (const css::uno::Sequence< css::uno::Any > &rArgs, sal_Int32 nIndex)
 

Protected Types

typedef ::std::deque< EventQueueEntryEventQueue
 

Protected Member Functions

void registerEventHandler (sal_Int32 nEventId, sal_Int32 nModuleType, const char *pcMacroName, sal_Int32 nCancelIndex=-1, const css::uno::Any &rUserData=css::uno::Any())
 Registers a supported event handler. More...
 
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. More...
 
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. More...
 
virtual void implPostProcessEvent (EventQueue &rEventQueue, const EventHandlerInfo &rInfo, bool bCancel)=0
 Derived classes may do additional postprocessing. More...
 
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. More...
 

Protected Attributes

css::uno::Reference< css::frame::XModel > mxModel
 
SfxObjectShellmpShell
 

Private Types

typedef ::std::map< sal_Int32, OUString > ModulePathMap
 
typedef std::map< sal_Int32, EventHandlerInfoEventHandlerInfoMap
 
typedef std::unordered_map< OUString, ModulePathMapEventHandlerPathMap
 

Private Member Functions

void startListening ()
 Starts listening at the document model. More...
 
void stopListening ()
 Stops listening at the document model. More...
 
const EventHandlerInfogetEventHandlerInfo (sal_Int32 nEventId) const
 Returns the event handler info struct for the specified event, or throws. More...
 
OUString getEventHandlerPath (const EventHandlerInfo &rInfo, const css::uno::Sequence< css::uno::Any > &rArgs)
 Searches the event handler in the document and returns its full script path. More...
 
void ensureVBALibrary ()
 On first call, accesses the Basic library containing the VBA source code. More...
 
sal_Int32 getModuleType (const OUString &rModuleName)
 Returns the type of the Basic module with the specified name. More...
 
ModulePathMapupdateModulePathMap (const OUString &rModuleName)
 Updates the map containing paths to event handlers for a Basic module. More...
 

Private Attributes

EventHandlerInfoMap maEventInfos
 
EventHandlerPathMap maEventPaths
 
css::uno::Reference< css::script::vba::XVBAModuleInfo > mxModuleInfos
 
OUString maLibraryName
 
bool mbDisposed
 

Detailed Description

Definition at line 57 of file vbaeventshelperbase.hxx.

Member Typedef Documentation

◆ EventHandlerInfoMap

Definition at line 217 of file vbaeventshelperbase.hxx.

◆ EventHandlerPathMap

typedef std::unordered_map< OUString, ModulePathMap > VbaEventsHelperBase::EventHandlerPathMap
private

Definition at line 218 of file vbaeventshelperbase.hxx.

◆ EventQueue

typedef ::std::deque< EventQueueEntry > VbaEventsHelperBase::EventQueue
protected

Definition at line 129 of file vbaeventshelperbase.hxx.

◆ ModulePathMap

typedef ::std::map< sal_Int32, OUString > VbaEventsHelperBase::ModulePathMap
private

Definition at line 170 of file vbaeventshelperbase.hxx.

Constructor & Destructor Documentation

◆ VbaEventsHelperBase()

VbaEventsHelperBase::VbaEventsHelperBase ( const css::uno::Sequence< css::uno::Any > &  rArgs)

◆ ~VbaEventsHelperBase()

VbaEventsHelperBase::~VbaEventsHelperBase ( )
overridevirtual

Definition at line 56 of file vbaeventshelperbase.cxx.

References mbDisposed, and SAL_WARN_IF.

Member Function Documentation

◆ changesOccurred()

void SAL_CALL VbaEventsHelperBase::changesOccurred ( const css::util::ChangesEvent &  rEvent)
overridevirtual

◆ checkArgument()

static void VbaEventsHelperBase::checkArgument ( const css::uno::Sequence< css::uno::Any > &  rArgs,
sal_Int32  nIndex 
)
inlinestatic
Exceptions
css::lang::IllegalArgumentExceptionif the passed sequence does not contain a value at the specified index.

Definition at line 87 of file vbaeventshelperbase.hxx.

References nIndex.

Referenced by processVbaEvent().

◆ checkArgumentType()

template<typename Type >
static void VbaEventsHelperBase::checkArgumentType ( const css::uno::Sequence< css::uno::Any > &  rArgs,
sal_Int32  nIndex 
)
inlinestatic
Exceptions
css::lang::IllegalArgumentExceptionif the passed sequence does not contain a value of a specific at the specified index.

Definition at line 92 of file vbaeventshelperbase.hxx.

References nIndex.

◆ disposing()

void SAL_CALL VbaEventsHelperBase::disposing ( const css::lang::EventObject &  rEvent)
overridevirtual

Definition at line 182 of file vbaeventshelperbase.cxx.

References stopListening().

◆ ensureVBALibrary()

void VbaEventsHelperBase::ensureVBALibrary ( )
private

On first call, accesses the Basic library containing the VBA source code.

Exceptions
css::uno::RuntimeException

Definition at line 291 of file vbaeventshelperbase.cxx.

References getDefaultProjectName(), maLibraryName, mpShell, mxModel, mxModuleInfos, and stopListening().

Referenced by changesOccurred(), getModuleType(), and hasModule().

◆ getEventHandlerInfo()

const VbaEventsHelperBase::EventHandlerInfo & VbaEventsHelperBase::getEventHandlerInfo ( sal_Int32  nEventId) const
private

Returns the event handler info struct for the specified event, or throws.

Exceptions
css::lang::IllegalArgumentException

Definition at line 254 of file vbaeventshelperbase.cxx.

References maEventInfos.

Referenced by processVbaEvent().

◆ getEventHandlerPath()

OUString VbaEventsHelperBase::getEventHandlerPath ( const EventHandlerInfo rInfo,
const css::uno::Sequence< css::uno::Any > &  rArgs 
)
private

Searches the event handler in the document and returns its full script path.

Exceptions
css::lang::IllegalArgumentException
css::uno::RuntimeException

Definition at line 263 of file vbaeventshelperbase.cxx.

References implGetDocumentModuleName(), maEventPaths, VbaEventsHelperBase::EventHandlerInfo::mnEventId, VbaEventsHelperBase::EventHandlerInfo::mnModuleType, and updateModulePathMap().

Referenced by hasVbaEventHandler(), and processVbaEvent().

◆ getModuleType()

sal_Int32 VbaEventsHelperBase::getModuleType ( const OUString &  rModuleName)
private

Returns the type of the Basic module with the specified name.

Exceptions
css::uno::RuntimeException

Definition at line 341 of file vbaeventshelperbase.cxx.

References ensureVBALibrary(), and mxModuleInfos.

Referenced by changesOccurred(), and updateModulePathMap().

◆ hasModule()

bool VbaEventsHelperBase::hasModule ( const OUString &  rModuleName)

Definition at line 324 of file vbaeventshelperbase.cxx.

References ensureVBALibrary(), and mxModuleInfos.

◆ hasVbaEventHandler()

sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler ( sal_Int32  nEventId,
const css::uno::Sequence< css::uno::Any > &  rArgs 
)
overridevirtual

Definition at line 245 of file vbaeventshelperbase.cxx.

References getEventHandlerPath(), and maEventInfos.

◆ implBuildArgumentList()

virtual css::uno::Sequence< css::uno::Any > VbaEventsHelperBase::implBuildArgumentList ( const EventHandlerInfo rInfo,
const css::uno::Sequence< css::uno::Any > &  rArgs 
)
protectedpure virtual

Derived classes have to return the argument list for the specified VBA event handler.

Exceptions
css::lang::IllegalArgumentException
css::uno::RuntimeException

Referenced by processVbaEvent().

◆ implGetDocumentModuleName()

virtual OUString VbaEventsHelperBase::implGetDocumentModuleName ( const EventHandlerInfo rInfo,
const css::uno::Sequence< css::uno::Any > &  rArgs 
) const
protectedpure virtual

Derived classes have to return the name of the Basic document module.

Exceptions
css::lang::IllegalArgumentException
css::uno::RuntimeException

Referenced by getEventHandlerPath(), and updateModulePathMap().

◆ implPostProcessEvent()

virtual void VbaEventsHelperBase::implPostProcessEvent ( EventQueue rEventQueue,
const EventHandlerInfo rInfo,
bool  bCancel 
)
protectedpure virtual

Derived classes may do additional postprocessing.

Called even if the event handler does not exist, or if an error occurred during execution.

Exceptions
css::uno::RuntimeException

Referenced by processVbaEvent().

◆ implPrepareEvent()

virtual bool VbaEventsHelperBase::implPrepareEvent ( EventQueue rEventQueue,
const EventHandlerInfo rInfo,
const css::uno::Sequence< css::uno::Any > &  rArgs 
)
protectedpure virtual

Derived classes do additional preparations and return whether the event handler has to be called.

Exceptions
css::uno::RuntimeException

Referenced by processVbaEvent().

◆ notifyEvent()

void SAL_CALL VbaEventsHelperBase::notifyEvent ( const css::document::EventObject &  rEvent)
overridevirtual

◆ processVbaEvent()

sal_Bool SAL_CALL VbaEventsHelperBase::processVbaEvent ( sal_Int32  nEventId,
const css::uno::Sequence< css::uno::Any > &  rArgs 
)
overridevirtual

◆ processVbaEventNoThrow()

void VbaEventsHelperBase::processVbaEventNoThrow ( sal_Int32  nEventId,
const css::uno::Sequence< css::uno::Any > &  rArgs 
)

Helper to execute event handlers without throwing any exceptions.

Definition at line 194 of file vbaeventshelperbase.cxx.

References processVbaEvent().

◆ registerEventHandler()

void VbaEventsHelperBase::registerEventHandler ( sal_Int32  nEventId,
sal_Int32  nModuleType,
const char *  pcMacroName,
sal_Int32  nCancelIndex = -1,
const css::uno::Any &  rUserData = css::uno::Any() 
)
protected

Registers a supported event handler.

Parameters
nEventIdEvent identifier from com.sun.star.script.vba.VBAEventId.
nModuleTypeType of the module containing the event handler.
pcMacroNameName of the associated VBA event handler macro.
nCancelIndex0-based index of Cancel parameter, or -1.
rUserDataUser data for free usage in derived implementations.

Definition at line 207 of file vbaeventshelperbase.cxx.

References maEventInfos, VbaEventsHelperBase::EventHandlerInfo::maMacroName, VbaEventsHelperBase::EventHandlerInfo::maUserData, VbaEventsHelperBase::EventHandlerInfo::mnCancelIndex, VbaEventsHelperBase::EventHandlerInfo::mnEventId, and VbaEventsHelperBase::EventHandlerInfo::mnModuleType.

◆ startListening()

void VbaEventsHelperBase::startListening ( )
private

Starts listening at the document model.

Definition at line 220 of file vbaeventshelperbase.cxx.

References mbDisposed, and mxModel.

Referenced by VbaEventsHelperBase().

◆ stopListening()

void VbaEventsHelperBase::stopListening ( )
private

Stops listening at the document model.

Definition at line 230 of file vbaeventshelperbase.cxx.

References maEventInfos, mbDisposed, mpShell, and mxModel.

Referenced by disposing(), ensureVBALibrary(), and notifyEvent().

◆ supportsService()

sal_Bool VbaEventsHelperBase::supportsService ( OUString const &  ServiceName)
override

Definition at line 189 of file vbaeventshelperbase.cxx.

References ServiceName, and cppu::supportsService().

◆ updateModulePathMap()

VbaEventsHelperBase::ModulePathMap & VbaEventsHelperBase::updateModulePathMap ( const OUString &  rModuleName)
private

Member Data Documentation

◆ maEventInfos

EventHandlerInfoMap VbaEventsHelperBase::maEventInfos
private

◆ maEventPaths

EventHandlerPathMap VbaEventsHelperBase::maEventPaths
private

◆ maLibraryName

OUString VbaEventsHelperBase::maLibraryName
private

Definition at line 223 of file vbaeventshelperbase.hxx.

Referenced by ensureVBALibrary(), and updateModulePathMap().

◆ mbDisposed

bool VbaEventsHelperBase::mbDisposed
private

◆ mpShell

SfxObjectShell* VbaEventsHelperBase::mpShell
protected

◆ mxModel

css::uno::Reference< css::frame::XModel > VbaEventsHelperBase::mxModel
protected

◆ mxModuleInfos

css::uno::Reference< css::script::vba::XVBAModuleInfo > VbaEventsHelperBase::mxModuleInfos
private

The documentation for this class was generated from the following files: