| View previous topic :: View next topic |
| Author |
Message |
avantman42 Super User

Joined: 28 Jul 2003 Posts: 751 Location: Staffordshire, UK
|
Posted: Wed Oct 15, 2003 12:23 pm Post subject: Width of columns in a Writer table |
|
|
Using the following code, I can create a table in a Writer document which has three columns and one row. So far, so good. However, I need to change the width of the two outer columns, and I can't seem to find out how to do it. Can anyone help?
| Code: | Sub rppInsertTable
'Get view cursor
vCursor = ThisComponent.CurrentController.getViewCursor ()
'Create a table
oTable = ThisComponent.createInstance ("com.sun.star.text.TextTable")
'Initialise table to have one row, three columns
oTable.initialize (1, 3)
'Insert table at current cursor position
ThisComponent.Text.insertTextContent (vCursor, oTable, False)
End Sub |
Russ |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Wed Oct 15, 2003 1:41 pm Post subject: |
|
|
Here is my best guess so far, but still, not complete success.
| Code: |
'Get view cursor
vCursor = ThisComponent.CurrentController.getViewCursor()
'Create a table
oTable = ThisComponent.createInstance ("com.sun.star.text.TextTable")
'Initialise table to have one row, three columns
oTable.initialize(1, 3)
'Insert table at current cursor position
ThisComponent.Text.insertTextContent (vCursor, oTable, False)
' Get the property TableColumnSeparators.
' This is a property of the TextTable.
oTblColSeps = oTable.TableColumnSeparators
' oTblColSeps is now an array of TableColumSeparator.
' Show me the bounds of the array.
' Zero to one. So there are only two separators for
' a three column table.
Print LBound( oTblColSeps ), UBound( oTblColSeps )
' Show the two positions: 3333, and 6666
Print oTblColSeps( 0 ).Position, oTblColSeps( 1 ).Position
' Change the positions of the two separators.
oTblColSeps( 0 ).Position = 2000
oTblColSeps( 1 ).Position = 8000
|
See these...
http://api.openoffice.org/docs/common/ref/com/sun/star/text/TextTable.html#TableColumnSeparators
http://api.openoffice.org/docs/common/ref/com/sun/star/text/TableColumnSeparator.html _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Wed Oct 15, 2003 7:04 pm Post subject: |
|
|
Now that I've gone out to dinner, come home relaxed, and took another look before going to bed, the reason I did not have success earlier is completely obvious. I only needed one final line to make it all work.
Here is a complete working example.
Comment out the Print statements as they were just part of the learning experience. (Remember, I don't know Writer very well.)
| Code: |
'Get view cursor
vCursor = ThisComponent.CurrentController.getViewCursor()
'Create a table
oTable = ThisComponent.createInstance ("com.sun.star.text.TextTable")
'Initialise table to have one row, three columns
oTable.initialize(1, 3)
'Insert table at current cursor position
ThisComponent.Text.insertTextContent (vCursor, oTable, False)
' Get the property TableColumnSeparators.
' This is a property of the TextTable.
oTblColSeps = oTable.TableColumnSeparators
' oTblColSeps is now an array of TableColumSeparator.
' Show me the bounds of the array.
' Zero to one. So there are only two separators for
' a three column table.
Print LBound( oTblColSeps ), UBound( oTblColSeps )
' Show the two positions: 3333, and 6666
Print oTblColSeps( 0 ).Position, oTblColSeps( 1 ).Position
' Change the positions of the two separators.
oTblColSeps( 0 ).Position = 2000
oTblColSeps( 1 ).Position = 8000
oTable.TableColumnSeparators = oTblColSeps
|
I just needed a line to assign the modified array back to the table.
There was another property in the two URL's I gave you above that described the Total width of the table. i suspect the two Position properties are relative to this total width property.
Each array element has another property besides the Position property. It has another property to control whether the seperator is visible or not.
Good night. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
avantman42 Super User

Joined: 28 Jul 2003 Posts: 751 Location: Staffordshire, UK
|
Posted: Thu Oct 16, 2003 1:24 am Post subject: |
|
|
Thanks Danny.
I'd found the TableColumnSeperators but couldn't seem to work out how to use them
As with so many things, of course, it's easy when you know how
Russ |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|