Hi Ian,

Alle 06:52, giovedì 8 settembre 2005, Ian Laurenson ha scritto:
> I have two macros that it would be useful to assign to the application
> events: Open Document and Create Document.
>
> While it is possible to do this via "Customize > Events" a lot of end
> users have difficulty in setting this up so I would like to be able to
> automate this process for them.

AFAIK, a general approach for this kind of problems is the "job execution 
environment"
(Dev Guide - 4 Writing UNO Components - 4.7.2 Jobs)

In practice (and if I well understood the whole thing) you should implement 
your own Job component (that must support the service com.sun.star.task.Job 
or com.sun.star.task.AsyncJob)
and then you should package your component with a customized jobs.xcu file, in 
order to inform the "job execution environment" of your job component
In the job.xcu file you can specify the event that will call-back your 
component

Unfortunately this approach is not possible using StarBasic for obvious 
reasons.


> Is it possible to modify:
> .openoffice.org2/user/registry/data/org/openoffice/Office/Events.xcu
>
> by the .xcu file in a uno package? If so some pointers would be useful.

You can, but:

1) I think it will work only for OOo2.0 because AFAIK OOo1.1 doesn't store 
global event bindings in the configuration registry

2) you cannot overwrite registry entries previously added or modified by the 
end-user

>
> And is it possible by a BASIC macro? Again some pointers would be
> useful.

you can assign macros to "global" events using the service:
com.sun.star.frame.GlobalEventBroadcaster"

This is an example:


REM  *****  BASIC  *****

Sub TestGlobalEventSupplier

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:///Gimmicks.Userfields.StartChangesUserfields()"

oGlobalEventBroadcaster = _
createUnoservice("com.sun.star.frame.GlobalEventBroadcaster")
oGlobalEventBroadcaster.Events.ReplaceByName("OnStartApp", mEventProps())

End Sub

You can retrieve all available event names using the method:
oGlobalEventBroadcaster.Events.getElementNames()

anyway this is the list:

OnStartApp
OnCloseApp
OnNew
OnUnload
OnPrepareUnload
OnLoad
OnSave
OnSaveAs
OnSaveDone
OnSaveAsDone
OnFocus
OnUnfocus
OnPrint
OnModifyChanged



> If I can get this sorted out I would like to writeup the instructions in
> the wiki: http://ext.openoffice.org.nz and possibly update Bernard
> Marcelly's excellent Addons1_1en.sxw.

Great!! ...and please, don't forget also a codesnippet for our repository :-)


ciao
Paolo M

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to