[Solved] Who can be TextTable's parents?

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
wanglong
Posts: 50
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

[Solved] Who can be TextTable's parents?

Post by wanglong »

Today, I inserted one TextFrame with TextTable in my text document and another two copies of this.
Now, I want to get each TextTables by its own parents' Supplier.But,I found that I can't do this by TextFrame.When I try to get XTextTablesSupplier through TextFrame's object like this,

Code: Select all

com.sun.star.text.xTextFrame = UnoRuntime.queryInterface(
                            XTextFrame.class, xNameAccess.getByName(ele));
com.sun.star.text.XTextTablesSupplier xTextTablesSupplier = (com.sun.star.text.XTextTablesSupplier)
                            UnoRuntime.queryInterface( com.sun.star.text.XTextTablesSupplier.class,
                                   xTextFrame );
code gave me a null return.
I can get all TextTables by XTextDocument object, but I can't identity which TextFrame they are belong to.

Code: Select all

com.sun.star.text.XTextDocument myDoc = (com.sun.star.text.XTextDocument)
                            UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
                                    xComp);
com.sun.star.text.XTextTablesSupplier xTextTablesSupplier = (com.sun.star.text.XTextTablesSupplier)
                            UnoRuntime.queryInterface( com.sun.star.text.XTextTablesSupplier.class,
                                   myDoc);
So,I want to know how can I identity one TextTable belongs to which TextFrame?
Last edited by wanglong on Thu Sep 15, 2022 9:22 am, edited 1 time in total.
Libre Office 7.6 on Windows 11.
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Who can be TextTable's parents?

Post by JeJe »

I just know Basic. The table anchor is the text of the textframe so comparing each textframe's text and the anchor text with equalunoobjects would find a match.

Do you use MRI? (Edit: It may help you find a better way if there is one.)

https://extensions.openoffice.org/en/pr ... ction-tool
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
wanglong
Posts: 50
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

Re: Who can be TextTable's parents?

Post by wanglong »

Thanks for your reply ,JeJe. I solved my question with your suggest.
I could use dot equal in JAVA like this

Code: Select all

if(xTextFrame.getText().equals(xTextTable.getAnchor().getText()) == true){}
instead of EqualUnoObjects in Basic.
Libre Office 7.6 on Windows 11.
Post Reply