Hi Joel,

What you're trying to do is something complex: if there was an example
for adding a context menu entry via an extension, and we should set a
level of knowledge required to understand it, I'd set the level to
DIFFICULT/COMPLEX and the like; so you will have to be patient and study
gradually.

I'd summarize the requirements as follow:

* knowledge about how a context menu interceptor works (this includes
handling the document selection)
* knowledge about ProtocolHandler implementation
* knowledge about Job implementation
* obviously a general knowledge about how extension work in OOo
(configuration files, etc.)

So said that...

Joel Cordeiro escribió:
Hi,

i still cant make it work with the jobs or protocol handler, but for now i
dont care,

sorry, but you *have* to care, because...

i'm trying to make the api of the extension i want, using client
application, and then i change. Know i got another doubt: how does i add a
action for the entry to the context menu i added? That is, when the user
click in the menu item from the context menu, and that menu item is one of
those i added, how can i create a action to process what i want? I see that


you need a ProtocolHandler for that.
I quote myself in
http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=21148


My question is: How do I implement a context menu item and stick my
own callback to it so that the item is still visible.

For this, you have to implement a ProtocolHandler. The Dev's Guide
explains how to do this.

Some quotes about what a protocol handler is:

"The dispatch framework binds user interface controls, such as menu or
toolbar items, to the functionality of OpenOffice.org.
Every function that is reachable in the user interface is described by a
command URL and corresponding parameters.
The protocol handler mechanism is an API that enables programmers to
add arbitrary URL schemas to the existing set of command URLs
by writing additional protocol handlers for them.
Such a protocol handler must be implemented as a UNO component and
registered in the OpenOffice.org configuration for the new URL schema."

This means, you need a UNO component implementing a protocol handler,
registered at OOo config. using a file ProtocolHandler.xcu,
for example:

<?xml version='1.0' encoding='UTF-8'?>
<oor:component-data
     oor:package="org.openoffice.Office"
     oor:name="ProtocolHandler"
     xmlns:oor="http://openoffice.org/2001/registry";
     xmlns:xs="http://www.w3.org/2001/XMLSchema";
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>

     <node oor:name="HandlerSet">
         <node
oor:name="ar.com.arielconstenlahaile.openoffice.menuinterceptor.ProtocolHandlerImpl"
oor:op="replace">
             <prop oor:name="Protocols" oor:type="oor:string-list">
<value>ar.com.arielconstenlahaile.openoffice.Menuinterceptor:*</value>
             </prop>
         </node>
     </node>
</oor:component-data>


In this example:
ar.com.arielconstenlahaile.openoffice.menuinterceptor.ProtocolHandlerImpl
is the name of the Java class with the implementation of the
ProtocolHandler (in Java the implementation name is/can be the same as
the class name). The JAR must be indicated with an entry in the manifest of the extension.

ar.com.arielconstenlahaile.openoffice.Menuinterceptor:*
is the URL schema I've chosen. I use a place holder "*" so I use the
same schema in every menu item, for example:

"ar.com.arielconstenlahaile.openoffice.Menuinterceptor:openCalcDoc"
"ar.com.arielconstenlahaile.openoffice.Menuinterceptor:openWriterDoc"

As my URL schema is registered in OOo configuration registry, if I use
this CommandURLs for my new items, they are enabled, and when the user
chooses the menu item, the Dispatch Framework will process this request and look in the chain of responsability for a component willing to handle it: my ProtocolHandler implementation will be asked to dispatch it.



Besides, if you want your menu item to have an image, you will have to
bind an image to the command URL in the configuration file named Addons.xcu.

Study a version of the SDK example at
http://www.ArielConstenlaHaile.com.ar/ooo/temp/ProtocolHandlerAddon.zip

Pay attention to:

* ProtocolHandler.xcu
* Addons.xcu, in particular the "Images" node
* ProtocolHandlerAddonImpl.java, in particular the
com.sun.star.frame.XDispatchProvider and com.sun.star.frame.XDispatch
implementation (in com.sun.star.frame.XDispatch.dispatch() is where you
"dispatch" the URL [answer to "how can i create a action to process what
i want?"]).

Regards
Ariel.





--
Ariel Constenla-Haile
La Plata, Argentina

[EMAIL PROTECTED]
http://www.ArielConstenlaHaile.com.ar/ooo/



"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]

Reply via email to