[EMAIL PROTECTED] wrote:

> Hello
> 
> Is it possible to create an XModel standalone, i.e. not part of any frame.

Yes. Create the model as a service and either initialize or load it. In
Basic code:

model = createUNOService("com.sun.star.text.TextDocument")
model.initNew()

will create a new empty text document.

dim mediadescriptor(n) as new com.sun.star.beans.PropertyValue
' fill mediadescriptor
model = createUNOService("com.sun.star.text.TextDocument")
model.load( mediadescriptor )

will create and load a document from what you put into the
mediadescriptor. Of course in this case you don't have a type detection
and you must either put the filter name into the mediadescriptor or
manually call the type detection service (not a big deal).

> For example by Desktop.loadComponentfromURL(_blank", "Hidden" ... and then
> keeping a handle to XModel.
> This works fine. I then "load" it into a visible frame by adding a "Model"
> property to the arguments for the loadComponentFromURL of the visible
> frame. This also works (Discussed on an earlier thread).
> 
> Howevwer if I now load a different XModel into this visible frame, any
> current XModel gets disposed automatically - I wan't (under certain
> circumstances) to prevent this, i.e. I want to keep the XModel handle in
> my code for reuse later but still load the new model.

Register a CloseListener at the model and veto against closing as long
as you need the model. Of course then you must keep track of all models
and close them by yourself when you are done with them.

I must confess that I don't remember if this really works in your case
(it definitely works in case of closing the frame) but you could try and
report back. If it doesn't work it's a bug that needs to be fixed.

> Basically I do this because I don't want multiple XFrames open, but still
> want concurrent editing of multiple documents.
> 
> I am trying to reduce the overhead of temporarily writing a stream for the
> XModel I remove from the frame and rereading, parsing etc... the stream
> again later.
> 
> Keeping with this, where is the most overhead in the API, i.e. creating
> the model, or creating the frame and controller and which uses more
> resources?

The most resources are taken by the model, the frame and controller are
much smaller for non-trivial documents. At least that's my guestimation.

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