[Solved] [Java] Get current XTextDocument object reference
-
- Posts: 6
- Joined: Wed Sep 01, 2010 6:54 pm
[Solved] [Java] Get current XTextDocument object reference
I would like to see a simple code example which show me how to get com.sun.star.text.XTextDocument in dispatch method of OpenOffice.org AddOn.
Last edited by java1cprog on Tue Sep 07, 2010 10:45 am, edited 9 times in total.
OpenOffice 3.2 on Windows XP SP 2
Re: How to get current XTextDocument object reference?
You should find the answer in any code example, in virtually every little piece of documentation.
The MRI extension can even record Java code.
The MRI extension can even record Java code.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Posts: 6
- Joined: Wed Sep 01, 2010 6:54 pm
Re: How to get current XTextDocument object reference?
Just show me a code. I think it will be few lines of code. Please.
OpenOffice 3.2 on Windows XP SP 2
Re: How to get current XTextDocument object reference with J
Search for xtextdocument using search box top right of forum screen. Then if you have a query, come back and someone will help.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Re: How to get current XTextDocument object reference with J
If you implement your own protocol handler, see:
http://api.openoffice.org/docs/common/r ... ndler.html
http://api.openoffice.org/docs/common/r ... ndler.html
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Apache OpenOffice 4-dev on Xubuntu 14.04
-
- Posts: 6
- Joined: Wed Sep 01, 2010 6:54 pm
Re: How to get current XTextDocument object reference with J
Unfotunatelly, I didn't find any. I saw a lot of examples where new frame is created. It isn't what I want. I would like to get current XTextDocument. I would not like to get new empty XTextDocument. Do you understand me?Villeroy wrote:You should find the answer in any code example, in virtually every little piece of documentation.
The MRI extension can even record Java code.
One of possible ways is:
Code: Select all
...
//retrieve the current component
XComponent xCurrentComponent = xdesktop.getCurrentComponent();
// query its XTextDocument interface
XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(
XTextDocument.class, xCurrentComponent);
How can I do that? I don't understand? Please, don't post links here.
Please, type or copy/paste a working example.
OpenOffice 3.2 on Windows XP SP 2
-
- Posts: 6
- Joined: Wed Sep 01, 2010 6:54 pm
Re: [Java] Get current XTextDocument object reference
Unfortunately, I didn't find answer to my question into present forum's topics. Instead, I carefully read "OpenOffice.org Developer guide" and found answer to my question.
The few strings of code which I have developed by myself is here:
The few strings of code which I have developed by myself is here:
Code: Select all
XTextDocument textDocument = null;
XController controller = m_xContext.getController();
XModel model = controller.getModel();
textDocument = UnoRuntime.queryInterface(XTextDocument.class, model);
OpenOffice 3.2 on Windows XP SP 2
Re: [Java] Get current XTextDocument object reference
Thanks @java1cprog, I was able to make it work. Found a little error in your code though, cf. https://www.openoffice.org/api/docs/com ... Frame.html
java1cprog wrote:Unfortunately, I didn't find answer to my question into present forum's topics. Instead, I carefully read "OpenOffice.org Developer guide" and found answer to my question.
The few strings of code which I have developed by myself is here:
Code: Select all
XTextDocument textDocument = null; XController controller = /* m_xContext.getController(); has to be XFrame --> */ m_xFrame.getController(); XModel model = controller.getModel(); textDocument = UnoRuntime.queryInterface(XTextDocument.class, model);
OpenOffice 4.0 on Windows 10