Hello *, On Sunday 25 January 2009 14:30, Ariel Constenla-Haile wrote: > * 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]
the following TableShape looks nicer: 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 'fixing horrible table layout Dim n% For n = 0 To oColumns.getCount()-1 oColumns.getByIndex(n).Width = aSize.Width / oColumns.getCount() Next For n = 0 To oRows.getCount()-1 oRows.getByIndex(n).Height = aSize.Height / oRows.getCount() Next End Sub Any way, much more work than with the TextTable, not very API-user friendly... 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: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org