Apache OpenOffice (AOO) Bugzilla – Issue 120346
Cannot read property TableName from a table using UNO
Last modified: 2012-07-23 13:18:00 UTC
When trying to read property TableName from an XTextTable, a user program receives a RuntimeException. SAMPLE CODE: XComponent xTemplateComponent = client.getComponentLoader(). loadComponentFromURL("file:///home/zinal/Desktop/test1.odt", "_blank", 0, new PropertyValue[0]); XTextTablesSupplier tablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, xTemplateComponent); XIndexAccess indexedTables = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, tablesSupplier.getTextTables()); for ( int i=0; i<indexedTables.getCount(); ++i ) { Object table = indexedTables.getByIndex(i); XPropertySet xTableProps = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, table); System.out.println(" Table name: " + xTableProps.getPropertyValue("TableName")); } EXCEPTION BACKTRACE: com.sun.star.uno.RuntimeException: at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:173) at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:139) at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:334) at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:303) at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:87) at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:636) at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:146) at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:128) at $Proxy3.getPropertyValue(Unknown Source) at ru.pg.asmrp.tests.ooo.BasicTest.testWordTables(BasicTest.java:62) at ru.pg.asmrp.tests.ooo.BasicTest.main(BasicTest.java:32)
It's OpenOffice.org 3.4.0 in Debian/GNU Linux 6.0.5, if that matters.
I do not find a property "TableName". You can get the name from ElementNames(<Index>) from TextTables, if you know the index of the table or from the property "Name", from the table itself.
(In reply to comment #2) > I do not find a property "TableName". > > You can get the name from ElementNames(<Index>) from TextTables, if you know > the index of the table or from the property "Name", from the table itself. This property name is returned via XPropertySet, as the following code snippet illustrates: CODE EXAMPLE: XTextTablesSupplier tablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, xTemplateComponent); XIndexAccess indexedTables = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, tablesSupplier.getTextTables()); for ( int i=0; i<indexedTables.getCount(); ++i ) { log.info("------------- Next table -------------"); Object table = indexedTables.getByIndex(i); XPropertySet xTableProps = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, table); for ( Property p : xTableProps.getPropertySetInfo().getProperties() ) { System.out.println(" Property: "+p.Name); try { System.out.println(" Value: " + xTableProps.getPropertyValue(p.Name)); } catch(Throwable x) { x.printStackTrace(System.out); } } } CODE OUTPUT: ------------- Next table ------------- Property: EndRedline Value: Any[Type[void], null] Property: TableBorder Value: com.sun.star.table.TableBorder@9e29fb Property: TextSection Value: Any[Type[void], null] Property: ChartRowAsLabel Value: false Property: Width Value: 17004 Property: ShadowFormat Value: com.sun.star.table.ShadowFormat@1d64c37 Property: BackGraphicLocation Value: com.sun.star.style.GraphicLocation@25d2b2 Property: BreakType Value: com.sun.star.style.BreakType@12be1bd Property: TableColumnSeparators Value: [Lcom.sun.star.text.TableColumnSeparator;@1f17e77 Property: ChartColumnAsLabel Value: false Property: Split Value: true Property: PageDescName Value: Standard Property: StartRedline Value: Any[Type[void], null] Property: BottomMargin Value: 0 Property: AnchorTypes Value: [Lcom.sun.star.text.TextContentAnchorType;@1a5f739 Property: PageStyleName Value: Standard Property: PageNumberOffset Value: 0 Property: TextWrap Value: com.sun.star.text.WrapTextMode@109fd93 Property: HeaderRowCount Value: 0 Property: LinkDisplayName Value: Таблица1 Property: RightMargin Value: 0 Property: RepeatHeadline Value: false Property: BackColor Value: -1 Property: TableName <--- The TableName property and it's exception com.sun.star.uno.RuntimeException: at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:173) at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:139) at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:334) at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:303) at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:87) at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:636) at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:146) at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:128) at $Proxy3.getPropertyValue(Unknown Source) at ru.pg.asmrp.tests.ooo.BasicTest.testWordTables(BasicTest.java:66) at ru.pg.asmrp.tests.ooo.BasicTest.main(BasicTest.java:32) Property: KeepTogether Value: false Property: BackGraphicFilter Value: Property: UserDefinedAttributes Value: Any[Type[com.sun.star.container.XNameContainer], [Proxy:12170552,-50aec4cc;gcc3[0];40752e82c67a406586d18d81772935a9,Type[com.sun.star.container.XNameContainer]]] Property: WritingMode Value: 0 Property: AnchorType Value: com.sun.star.text.TextContentAnchorType@288051 Property: CollapsingBorders Value: true Property: TableColumnRelativeSum Value: 10000 Property: BackTransparent Value: true Property: HoriOrient Value: 3 Property: TopMargin Value: 0 Property: RelativeWidth Value: 0 Property: BackGraphicURL Value: Property: TableBorderDistances Value: com.sun.star.table.TableBorderDistances@10045eb Property: LeftMargin Value: 0 Property: IsWidthRelative Value: false
I see the property "TableName" in Xray too, there too with an error. Examining the table in Basic IDE, there exists no property "TableName" but only the property "Name". I guess, that the property "TableName" should not exist in sw/source/core/unocore/unoprnms.cxx