Kent Gibson wrote:

> argh. please help. this is driving me batty. 
> 
> Ok i have an empty frame,
> 
> XWindow xWindow = ( XWindow )
> UnoRuntime.queryInterface( XWindow.class,
> officeWindow.getUNOWindowPeer() );
> object = serviceFactory.createInstance(
> "com.sun.star.frame.Frame" );
> XFrame documentFrame = ( XFrame )
> UnoRuntime.queryInterface( XFrame.class, object );
> documentFrame.initialize( xWindow );
> documentFrame.setName( documentFrame.toString() );
> 
> // Register frame at the desktop
> XFrames xFrames = ( ( XFramesSupplier )
> UnoRuntime.queryInterface( XFramesSupplier.class,
> desktop ) ).getFrames();
> xFrames.append( documentFrame );
> 
> then I go and create a blank document and put it into
> my frame:
> 
> XComponentLoader frameComponentLoader = (
> XComponentLoader ) UnoRuntime.queryInterface(
> XComponentLoader.class, documentFrame);
> loadedComponent =
> frameComponentLoader.loadComponentFromURL( url,
> "_self", 0, args ); 
> 
> the purpose so that I can see a nice blank doc.
> 
> then I go and create another blank doc. I do some
> rendering and I want
> to replace my first doc with the second doc.

This isn't possible so easily. There are several other options, but I
don't know which I should recommend because I don't know what your goal
is. You could:

- not create the first document at all (why do you?)
- add the model of the second document to a MediaDescriptor and use
loadComponentFromURL at the first frame, thus replacing the first doc
- perhaps even don't create a second frame and only use a standalone
model that you insert in the same way into your frame

It's hard do make a good suggestion without knowing your intended
workflow or functionality.

> for example this does not work:
> documentFrame.setComponent(
> documentFrame.getContainerWindow(),officeDocument.getCurrentController());

Yes, this is not possible, a controller is owned by a frame as soon as
you have created it and it can be only in one frame at a time. This
means once you remove it from a frame to put it into another one the
frame will dispose of the controller.

You only can move the *model* from one frame to another (or have it in
more than one frame at the same time), thus creating a new controller
each time you insert the model into a frame.
Currently this needs the way mentioned above (use a "Model" parameter in
MediaDescriptor, see DevGuide), we are working on an API to make this
easier and more elegant.

> The guide says"Currently, the only way for clients to
> construct a frame and insert a OpenOffice.org document
> into it, is to use the
> com.sun.star.frame.XComponentLoader interface of the
> com.sun.star.frame.Desktop" but this is not
> clear to me.

Yes, as I said: Controllers can't be moved between frames, the only way
to get a model into a frame is to create a new Controller. And the only
way to achieve this currently is loadComponentFromURL.

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