Hi Peter,
I would strongly advise not to use getCurrentFrame(), especially in this
context.
The AddOn instance must use the own frame that is actually known. Yes,
in most cases the current frame will be the frame the addon is related
to, but not always.
Best regards,
Mikhail.
Peter Eberlein wrote:
Hi yaungmin,
yaungmin schrieb:
Hi Mikhail,
I did not get any exception when I tried to save the document. As you can
see in the saveDocument method, I was basically able to load a
document and
save it as another document with a different name.
All I am trying to do is like say, I have an "Untitled1 document"
opened and
I typed some text on the document. When I click on my Add-on Save
button, I
want to save that document to a certain location. I want the text on the
document to be saved and the title of the document should change from
"Untitled1 document" to the name of the document. What I am trying to
do is
probably exactly the same as the OOo build-in save function. Please
advice.
Thanks,
If you want to save the "Active Document", you must instantiate the
XDesktop Interface from the ServiceManager and then look for the
currentFrame. Every frame as a controller and the controller has a model.
desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop",
xComponentContext);
XDesktop xDesktop = (XDesktop)
UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class, desktop);
XFrame xF = xDesktop.getCurrentFrame();
XController xC = xF.getController();
XModel xmodel = (XModel) UnoRuntime.queryInterface(XModel.class,
xC.getModel());
XComponent xComponent = (XComponent)
UnoRuntime.queryInterface(XComponent.class, xmodel);
XStorable xs = (XStorable) (UnoRuntime.queryInterface(XStorable.class,
xComponent ));
Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]