Hi Daniel,

On 02/19/09 03:41, Daniel Brosseau wrote:
Hi,

I have a Frame-Controller-Model structure built through a XDesktop
created through xServiceManager.createInstanceWithContext
    ( "com.sun.star.frame.Desktop", xComponentContext )
and loadComponentFromUrl
    ( "private:factory/swriter", "_blank", 0, openProperties )
with the only openProperty being "Hidden" which delivers a
XComponent that supports the XModel interface (call this xModel_A).

I try to retrieve the XFrame from the XDesktop and it returns null.
I try to retrieve the XController from the XModel with success.
I try to retrieve the XFrame from the XController with success.

Q1: Why can't I retieve the XFrame starting from the top (XDesktop)
    while I can get it starting from the bottom (XModel)?

How do you try to retrieve the frame from Desktop object, which API do you use?


I sucessfully create a second XModel through the service manager
xServiceManager.createInstanceWithContext
    ( "com.sun.star.text.TextDocument", xComponentContext )
Call this xModel_B

Please remember, the model has to be initialized with XLoadable::initNew() or XLoadable::load(). Otherwise it is close to be unusable.


Now what I would like to do is replace xModel_A with xModel_B.
I tried calling the XController.attachModel( xModel_B ) which returns
False meaning the new model was not attached.

Q2: How to I replace xModel_A with xModel_B in the
    Frame-Controller-Model Structure?

If I remember correctly it is possible to reuse the frame but not the controller.

To reuse the frame you can try to call loadComponentFromURL() on the frame object with "_self" target. That should load the new document into the frame.

Please do not forget to call suspend() on the old controller, otherwise the related model will be just closed without storing. Of course if your are sure that the document can not be changed you can let it be closed.

Hope that helps.

Best regards,
Mikhail.


Thank you,

Daniel


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

Reply via email to