Hi Mathias,
>> But now I want to write a second component: it should be the same as
>> already exists: ".uno:SaveAs". But the functionality should be
>> different: it should store the object's persistent data to a URL and
>> continues to be a representation of the old URL.
>>
>> It is the same difference as in XStorable.storeAsURL() and
>> XStorable.storeToURL().
>>
>> My question: is it the easiest way to develop a complete new component
>> or can I reuse the main parts of ".uno:SaveAs"?
>
> You can reuse everything. You can dispatch the ".uno:SaveAs" command but
> with an additional argument, a boolean PropertyValue named "SaveTo".
>
> The drawback of this approach is that you will only get the filters that
> are available in "SaveAs", but not the ones you get in "Export", e.g. PDF.
I solved it as you described. Here is the code:
-----%<-----
public void saveTo()
{
PropertyValue[] saveProperties = new PropertyValue[1];
saveProperties[0] = new PropertyValue();
saveProperties[0].Name = "SaveTo";
saveProperties[0].Value = true;
XMultiServiceFactory xMultiServiceManager = (XMultiServiceFactory)
UnoRuntime.queryInterface( XMultiServiceFactory.class,
xRemoteServiceManager);
Object oDispatchHandler = null;
try{
oDispatchHandler = xMultiServiceManager.createInstance(
"com.sun.star.frame.DispatchHelper");
}
catch(Exception e)
{
System.out.println("Can't get the Protocol Handler Object...");
}
XModel xModel = (XModel) UnoRuntime.queryInterface (
XModel.class, openDocument);
XController xController = xModel.getCurrentController();
XFrame xFrame = xController.getFrame();
XDispatchProvider xDispatchProvider = (XDispatchProvider)
UnoRuntime.queryInterface (XDispatchProvider.class, xFrame);
XDispatchHelper xDispatchHelper = (XDispatchHelper)
UnoRuntime.queryInterface(XDispatchHelper.class,
oDispatchHandler);
xDispatchHelper.executeDispatch(xDispatchProvider,
".uno:SaveAs",
"_self",
0,
saveProperties);
}
-----%<-----
I will post it soon as a snippet. Please review it and add
comments/corrections.
Greetings, Tobias
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]