[Solved] How to get the Width of the first column of a Table

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
brunnerdan
Posts: 43
Joined: Tue Nov 29, 2011 12:41 am

[Solved] How to get the Width of the first column of a Table

Post by brunnerdan »

Let's get a reference of a Table with the following code :

Code: Select all

   myDocument = ThisComponent
   myTable = myDocument.TextTables.getByName( "Table1" )
How can I get the width of the first column in my table ?
Last edited by brunnerdan on Wed Dec 21, 2011 9:41 am, edited 1 time in total.
OOO 3.3 on Solaris/Windows
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: How to get the Width of the first column of a Table ?

Post by JohnSUN-Pensioner »

Code: Select all

Sub WhereIsColumnsDelimiters(Optional numTable%)
Dim oTextTables As Object
Dim oTextTable As Object
Dim oColumns, i%
	If IsMissing(numTable) Then numTable = 0
	oTextTables = ThisComponent.getTextTables()
	If oTextTables.getCount() = 0 Then Exit Sub
	oTextTable = oTextTables.getByIndex(numTable)
	oColumns = oTextTable.getPropertyValue("TableColumnSeparators")
	For i = 0 To UBound(oColumns)
  		print " " & (i+1) & " column finished at " & oColumns(i).Position
  	Next i
End Sub
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
brunnerdan
Posts: 43
Joined: Tue Nov 29, 2011 12:41 am

Re: How to get the Width of the first column of a Table ?

Post by brunnerdan »

Thanks, it seems to work. But in which unit the oColumns(i).Position is returned ? How can I convert the value returned to "centimeters" ?
OOO 3.3 on Solaris/Windows
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: How to get the Width of the first column of a Table ?

Post by JohnSUN-Pensioner »

Oh, sorry! See here
"The real width of a table depends on the environment (page style and number of text columns at the table's position, alignment, and left and right margins). For that reason, the table column separator does not contain metric values for the column widths. The values are relative to the value of the property TextTable::TableColumnRelativeSum."
 Edit: After searching on http://www.oooforum.org/ 
But you can try this topic
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
brunnerdan
Posts: 43
Joined: Tue Nov 29, 2011 12:41 am

Re: How to get the Width of the first column of a Table ?

Post by brunnerdan »

Great, thanks !
OOO 3.3 on Solaris/Windows
Post Reply