Hi *,
I've been playing with the "new" (since 3.0) table shape.
Besides the missing IDL documentation
(http://www.openoffice.org/issues/show_bug.cgi?id=98458), some things don't
seems to work as I would have expected.
Testing with the following code:
Sub TableShapeDemo
Dim oDoc as Object
oDoc = StarDesktop.loadComponentFromURL(_
"private:factory/sdraw", "_default", 0, Array())
Dim oDrawPage as Object
oDrawPage = oDoc.getDrawPages().getByIndex(0)
Dim oTableShape as Object
oTableShape = oDoc.createInstance("com.sun.star.drawing.TableShape")
Dim aSize as New com.sun.star.awt.Size
aSize.Width = 10000
aSize.Height = 8000
Dim aPos as New com.sun.star.awt.Point
aPos.X = oDrawPage.Width / 2 - aSize.Width / 2
aPos.Y = oDrawPage.BorderTop
oTableShape.setSize(aSize)
oTableShape.setPosition(aPos)
oTableShape.UseBandingColumnStyle = False
oTableShape.UseBandingRowStyle = True
oTableShape.UseFirstColumnStyle = True
oTableShape.UseFirstRowStyle = True
oTableShape.UseLastColumnStyle = False
oTableShape.UseLastRowStyle = True
Dim oTableModel as Object, oTableTemplate as Object
'accessible only once added to the draw page!
'oTableModel = oTableShape.getPropertyValue("Model")
'oTableTemplate = oTableShape.getPropertyValue("TableTemplate")
oDrawPage.add(oTableShape)
oTableModel = oTableShape.getPropertyValue("Model")
oTableTemplate = oTableShape.getPropertyValue("TableTemplate")
Dim oTableStyles as Object, oStyle as Object
oTableStyles = oDoc.getStyleFamilies().getByName("table")
If oTableStyles.hasByName("orange") Then
oStyle = oTableStyles.getByName("orange")
Else
oStyle = oTableStyles.getByIndex(0)
End If
oTableShape.setPropertyValue("TableTemplate", oStyle)
Dim oRows as Object
Dim oColumns as Object
'I couldn't find an easier way to instantiate the TableShape
'and initialize it with n rows and n columns...
oRows = oTableModel.getRows()
oColumns = oTableModel.getColumns()
While oTableModel.ColumnCount < 6
oColumns.insertByIndex(0, 1)
Wend
While oTableModel.RowCount < 8
oRows.insertByIndex(0, 1)
Wend
End Sub
* I haven't found a simple way to instantiate the TableShape and indicate the
number of row and columns. The css.text.XTextTable has initialize() for this;
for the TableShape, it seems [==there is no documentation] that one has to
access a read-only property named Model, which is accessible only once the
shape is added to the DrawPage. This property gives you a css.table.XTable
reference, you can use it to insert rows and columns
* if the previous is the way to initialize/insert rows/columns, the result is
rather ugly: while in the css.text.XTextTable adding row and columns does keep
some harmonic order in the table geomerty (width and hight of rows, columns,
table), the method I use in the example creates a table quite useless, and it
seems one has to fix the columns and rows size [if this is possible at all, i
didn't test it yet]
* table styles may have some issues: I try adding one, just like we do with
every other style family, but crashed
If anyone has time to play with it, please report back your findings.
Regards
--
Ariel Constenla-Haile
La Plata, Argentina
"Aus der Kriegsschule des Lebens
- Was mich nicht umbringt,
macht mich härter."
Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]