Mathias Bauer ha scritto:
> news.gmane.org schrieb:
>
>> Mathias Bauer ha scritto:
>>> news.gmane.org wrote:
>>>
>>>> XModel oModel =
>>>>
(XModel)UnoRuntime.queryInterface(XModel.class,oEvent.Source
);
>>>> if (oModel!=null) {
>>>> System.out.println("Document URL
is: " + oModel.getURL());
>>>> }
>>>> }
>>> You should be aware that getURL() will return
an empty string if the
>>> document is an untitled one and as you can have
more than of untitled
>>> document it doesn't qualify as an identifier.
>>>
>>> You could use the document (reference) itself
as a unique identifier.
>>> You then must register as a listener so you get
a notification when the
>>> document is disposed so that you can release
your reference.
>> The problem is: how do I get the document refernce
from the EventObject?
>> I've tried this:
>>
>> OfficeDocument oDocument =
>>
(OfficeDocument)UnoRuntime.queryInterface(OfficeDocument.cla
ss,oEvent.Source);
>>
>> but I'm getting a ClassCastException.
>
> OfficeDocument is not a valid type here. You have to
use any interface
> from our documents - I would recommend to use
com.sun.star.XModel.
The problem comes to a higher level: when I'm calling
oBean.loadFromUrl
I don't have my document yet, what should I compare the
event source to?
My intention was to use the url so that I'm sure that the
document being
loaded is the same as the one I'm listening to.
Moreover if I query the XModel interface from the
EventSource and then I
compare it with oBean.getController().getModel() , I get
that the
references are not equal.
The problem comes also on storeAsUrl(). If I create a new
document and
then save it, the event on the listener comes with a source
URL which is
an empty string, because, as you said, the new document has
no URL.
I'm really in trouble with that, and I'm very sorry to
bother you with
this issue.
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|