Code: Select all
Sub DisplayAvailableEvents
Dim oGEB ' GlobalEventBroadcaster
Dim oDoc
Dim s$
Dim oText
oDoc = ThisComponent
'oDoc = StarDesktop.LoadComponentFromUrl("private:factory/swriter", "", 0, Array())
oGEB = createUnoservice("com.sun.star.frame.GlobalEventBroadcaster")
s = Join(oGEB.Events.getElementNames(), CHR$(10))
oText = oDoc.Text
oText.InsertString(oText.End, "===Global Events" & CHR$(10), False)
oText.InsertString(oText.End, s, False)
s = Join(oDoc.Events.getElementNames(), CHR$(10))
oText.InsertString(oText.End, CHR$(10) & CHR$(10) & "===Writer Events" & CHR$(10), False)
oText.InsertString(oText.End, s, False)
End Sub
- OnStartApp
- OnCloseApp
- OnCreate
- OnNew
- OnLoadFinished
- OnLoad
- OnPrepareUnload
- OnUnload
- OnSave
- OnSaveDone
- OnSaveFailed
- OnSaveAs
- OnSaveAsDone
- OnSaveAsFailed
- OnCopyTo
- OnCopyToDone
- OnCopyToFailed
- OnFocus
- OnUnfocus
- OnPrint
- OnViewCreated
- OnPrepareViewClosing
- OnViewClosed
- OnModifyChanged
- OnTitleChanged
- OnVisAreaChanged
- OnModeChanged
- OnStorageChanged
- OnPageCountChange
- OnMailMerge
- OnMailMergeFinished
- OnFieldMerge
- OnFieldMergeFinished
- OnLayoutFinished
Code: Select all
Sub StealAnEvent
Dim mEventProps(1) as new com.sun.star.beans.PropertyValue
mEventProps(0).Name = "EventType"
mEventProps(0).Value = "StarBasic"
mEventProps(1).Name = "Script"
mEventProps(1).Value = "macro:///Standard.Module1.MySave()"
'oGlobalEventBroadcaster = createUnoservice("com.sun.star.frame.GlobalEventBroadcaster")
'oGlobalEventBroadcaster.Events.ReplaceByName("OnStartApp", mEventProps())
ThisComponent.Events.ReplaceByName("OnSave", mEventProps())
End Sub
Code: Select all
mEventProps(1).Value = "vnd.sun.star.script:Standard.Module1.LocalMySave?language=Basic&location=document"
Code: Select all
mEventProps(1).Value = "macro://MyDocumentName/Standard.Module1.LocalMySave()"
As a side note, even though I do this, the document still saves just fine, which probably would not happen if I tried to intercept the global dispatch. Couple of issues with that. I think that I would need to do my desired behavior, AND, I would also need to trigger the usual save behavior. Oh, and if i did that, I doubt that the change would persist of a document change (but I did not test it, since it is not really what I wanted to do).
Any thoughts?