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

The Application Programming Interface and the OASIS Open Document Format

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

Postby brunnerdan » Mon Dec 19, 2011 8:10 pm

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

Code: Select all   Expand viewCollapse view
   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
brunnerdan
 
Posts: 43
Joined: Tue Nov 29, 2011 12:41 am

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

Postby JohnSUN-Pensioner » Mon Dec 19, 2011 8:27 pm

Code: Select all   Expand viewCollapse view
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.4, LibreOffice 5.4.2.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
JohnSUN-Pensioner
Volunteer
 
Posts: 761
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

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

Postby brunnerdan » Tue Dec 20, 2011 3:34 pm

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
brunnerdan
 
Posts: 43
Joined: Tue Nov 29, 2011 12:41 am

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

Postby JohnSUN-Pensioner » Tue Dec 20, 2011 3:49 pm

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.4, LibreOffice 5.4.2.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
JohnSUN-Pensioner
Volunteer
 
Posts: 761
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

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

Postby brunnerdan » Wed Dec 21, 2011 9:40 am

Great, thanks !
OOO 3.3 on Solaris/Windows
brunnerdan
 
Posts: 43
Joined: Tue Nov 29, 2011 12:41 am


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 2 guests