Tobias Krais wrote:
Hi Carsten,

I don't exactly know what you want to do. Do you want to pass arguments
to a command that you want to dispatch?

Hi Tobias,

I wrote a little UNO component that should be able to print the
document. I registered this component. Then I added a transient menu
item to the menu. If I click on this item, my component is called. I
would like to give my component the name of the printer, it should print on.

Ok, now understand what you want to achieve. I guess you want to set the printer name while creating the menu items.

Sequence< beans::PropertyValue > aArguments(1);
com::sun::star::util::URL aURL;
aURL.Complete = ".uno:Open"

xURLTransformer->parseStrict( aURL );

aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FileName" );
aArgs[0].Value = uno::makeAny( rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "file:///home/test/test.odt" )) );

xDispatch->dispatch( aURL, aArgs )

There is also a way to pass simple types via the URL. Keep in mind that
you have to escape certain characters (e.g. ?,&,' ',...) if you use them
in your arguments.

command?arg1:type1=value2&arg2:type2=value2

".uno:Open?FileName:string=file:///home/test/test.odt"

All of this seems to be very interesting and might solve my problem. But
I don't understand all :-). By the way, I use Java.

As far as I understand, there is one possiblity I can use when I create
the menu item. I just add a PropertyValue like this:
-----%<-----
menuItemProperties[3] = new PropertyValue();
menuItemProperties[3].Name = "Printer";
menuItemProperties[3].Value = new String("LaserJet1100");
-----%<-----
If this is correct, how can I access the properties in my Component.
This way is not possible for your scenario. A menu item cannot store a property value.


Second solution: I can extend the CommandURL:
-----%<-----
menuItemProperties[0] = new PropertyValue();
menuItemProperties[0].Name = "CommandURL";
menuItemProperties[0].Value = ".Judas:PrintTrays?Printer:string=LJ1100";
-----%<-----
Is this correct? But how can I access the values?
This is the way to go for your scenario.

Your protocol handler implements the XDispatch interface. The OpenOffice.org menu uses this interface to call your implementation.

dispatch( const com::sun::star::util::URL aURL, Sequence< beans::PropertyValue > aArgs )

As you can see the dispatch function has two arguments (aURL and aArgs). The arguments inside your command URL are part of aURL. It's a structure containing several members which describe parts of the URL. Your arguments can be found inside aURL.Arguments. You have to parse the string. For more information see the description of com.sun.star.util.URL IDL file.


Do I have to change my ProtocolHandler.xcu?
No.

Regards,
Carsten

--
Carsten Driesner (cd) - Project Lead OpenOffice.org Framework
Framework wiki: http://wiki.services.openoffice.org/wiki/Framework
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS

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

Reply via email to