Tobias Krais wrote:

> 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...");
                                            ^^^^^^^^^^^^^^^^
I assume you copied this from somewhere else... :-)

>     }
>     XModel xModel = (XModel) UnoRuntime.queryInterface (
>             XModel.class, openDocument);
>     XController xController = xModel.getCurrentController();

Theoretically it is possible that you don't get a "current Controller"
in case the document was loaded without creating a view, but I assume
that you know where you got it from. "loadComponentFromURL" always
creates a view so it is safe to rely on a "current Controller".

>     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);
> }

Looks fine to me.

> I will post it soon as a snippet. Please review it and add
> comments/corrections.

Done. :-)

Best regards,
Mathias

-- 
Mathias Bauer - OpenOffice.org Application Framework Project Lead
Please reply to the list only, [EMAIL PROTECTED] is a spam sink.

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

Reply via email to