Hello allirpa, On Friday 20 March 2009, 02:42, allirpa wrote: > how do i get the xscriptcontext? :)
you get it from the Scripting Framewrok when the Java "macro" is invoked http://api.openoffice.org/docs/common/ref/com/sun/star/script/provider/XScriptContext.html "This interface is provided to scripts, and provides a means of access to the various interfaces which they might need to perform some action on a document. It is required to be passed as the first argument for any Java scripts." http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Scripting/Implementation "All of the Java based reference LanguagesScriptProvider provided with OpenOffice.org make this information available to the running macro in the form of an object implementing the interface com.sun.star.script.provider.XScriptContext. This provides accessor methods to get the current document, the desktop and the component context. Depending on the constraints of the language this information is passed to the macros in different ways, for example in Beanshell and JavaScript this is available as an environment variable and in the case of Java it is passed as the first argument to the macro. " If you want to "translate" XScriptContext.getDocument() to use the code in an *extension*, that added a menu item (== a ProtocolHandler impl.), then you get a css.frame.XFrame and from this you can access the css.frame.XController and (if any) its css.frame.XModel. If you want to use the code in a client application, you will have to load a document (accessing the current component is error prone, that's why I like to use the Scripting Framewrok to direct access an existing document model from Java). Could you try the demo following the instructions in the Wiki page I quoted? If so, this should be easy for you to translate it to your real use case. Regards -- Ariel Constenla-Haile La Plata, Argentina "Aus der Kriegsschule des Lebens - Was mich nicht umbringt, macht mich härter." Nietzsche Götzendämmerung, Sprüche und Pfeile, 8. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
