Page 1 of 1

[Solved] Who can be TextTable's parents?

Posted: Wed Sep 14, 2022 10:53 am
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?

Re: Who can be TextTable's parents?

Posted: Wed Sep 14, 2022 11:35 am
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

Re: Who can be TextTable's parents?

Posted: Thu Sep 15, 2022 9:23 am
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.