How can I get TextFrame Objects already has been added to Text Document with JAVA?
I didn't found a relevant tutorials with this topic.
Please show me with non scripting language!
Thank you very much!
[Solved] Get TextFrames in Text Document with Java?
[Solved] Get TextFrames in Text Document with Java?
Last edited by wanglong on Fri Sep 09, 2022 4:36 pm, edited 1 time in total.
Libre Office 7.6 on Windows 11.
Re: How can I get TextFrames in Text Document with JAVA?
I do not use Java but I recorded the following code with the MRI extension. The oInitialTarget is the text document, the object you would get with ThisComponent in Basic.
Code: Select all
import com.sun.star.container.NoSuchElementException;
import com.sun.star.container.XNameAccess;
import com.sun.star.lang.WrappedTargetException;
import com.sun.star.text.XTextFrame;
import com.sun.star.text.XTextFramesSupplier;
import com.sun.star.uno.RuntimeException;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
public static void snippet(XComponentContext xComponentContext, Object oInitialTarget)
{
try
{
XTextFramesSupplier xTextFramesSupplier = UnoRuntime.queryInterface(
XTextFramesSupplier.class, oInitialTarget);
XNameAccess xNameAccess = xTextFramesSupplier.getTextFrames();
XTextFrame xTextFrame = UnoRuntime.queryInterface(
XTextFrame.class, xNameAccess.getByName("FlowerImage"));
}
catch (NoSuchElementException e1)
{
// getByName
e1.printStackTrace();
}
catch (WrappedTargetException e2)
{
// getByName
e2.printStackTrace();
}
catch (RuntimeException e3)
{
// getByName
e3.printStackTrace();
}
}
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: How can I get TextFrames in Text Document with JAVA?
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
Re: How can I get TextFrames in Text Document with JAVA?
Thanks for your reply so quickly!
Libre Office 7.6 on Windows 11.