Ask Your Question

4.1 Writer Basic - retrieve TextTable from TextTableCursor

asked 2013-11-05 16:00:22 +0200

Yimin Rong gravatar image

updated 2015-08-24 09:32:45 +0200

Alex Kemp gravatar image

I would like to write a macro that works on the selected table. When I select a table, the object that ThisComponent.CurrentSelection returns is of type SwXTextTableCursor (will refer to it generically as TextTableCursor). According to DBG_methods it provides methods to traverse through the selected cells and merge or split the cells, but it doesn't seem to provide a way to access the actual table itself. Conversely, ThisComponent.TextTables returns the tables, but as far as I can tell, no way to determine if any or all of a table is selected.

Is there any way to retrieve the TextTable(s) from TextTableCursor?

Thanks for reading.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2015-07-21 08:40:20 +0200

doug gravatar image

Here are the equivalent objects.

This object is retrieved without reference to the cursor:

SwXTextTable = ThisComponent.TextTables.getByIndex(0)

This object is derived from the cursor:

cntrllr = ThisComponent.CurrentController
cursor = cntrllr.ViewCursor
SwXTextTable = cursor.TextTable

You can test this with the following operation, which will print out the contents of the top left cell of whichever text table you have invoked:

oCell = SwXTextTable.getCellByPosition(0,0)
MsgBox oCell.String
edit flag offensive delete link more

answered 2015-07-23 14:34:38 +0200

pierre-yves samyn gravatar image


I do not know if this is helpful but could complete doug's response on "determine if a table is selected":

dim oCursor as object

oCursor = thiscomponent.currentcontroller.viewcursor

if isempty(oCursor.TextTable) then  
    msgbox "Current selection: no table"
    msgbox "Current selection:  " &
end if


edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2013-11-05 16:00:22 +0200

Seen: 612 times

Last updated: Jul 23 '15