Thanks Peter!
Hi Matthias,
I'm currently working with the OOoBean from the OOo SDK 1.1, but I guess it works very similar in the new OOoBean.
The bean supplies a method "getDocument()", which returns a com.sun.star.bean.OfficeDocument object, which is a wrapper around the OfficeDocument service which is the document model.
The OfficeDocument class provides a method "queryInterface(...)" which you can use to access the interfaces supported by the TextDocument service.
So, to query for the XTextDocument interface, you'd say:
// Caution! The code below has not been tested and might not even compile. I just points into some general direction ;-)
import com.sun.star.bean.OOoBean; import com.sun.star.uno.Type;
OOoBean bean = new OOoBean();
//...load some document into the bean...
OfficeDocument doc = bean.getDocument();
XTextDocument xTextDocument = doc.queryInterface(new Type(XTextDocument.class));
//...do something with the document...
In some sources I have found this possibility:
xModel = oooBean.getController().getModel();
xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xModel);
Both are running, but what is the difference or what is better???
Matthias
Beware that queryInterface will return 'null' if the currently loaded document is not a text document (but a calc document, for example)
Cheers Peter
-----Ursprüngliche Nachricht-----
Von: Matthias Scholz [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 13. April 2005 11:14
An: dev@api.openoffice.org
Betreff: [api-dev] XTextDocument in OOoBean
Hi,
I use the OOoBean from OO 1.9.91 in a Java application. But i have no plan how do i get the XTextDocument object from the OOoBean, for manipulating the text inside the OOoBean.
Thanks
Matthias
--------------------------------------------------------------------- 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]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]