OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
OpenOffice.org BASIC Guide - OpenOffice.org wiki
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
More Than Just Text<br />
Note – Text tables are available in <strong>OpenOffice</strong>.<strong>org</strong> through the TextTables list of the document object. The<br />
previous example shows how a text table can be created. The options for accessing text tables are described in the<br />
following section.<br />
Editing Tables<br />
A table consists of individual rows. These in turn contain the various cells. Strictly speaking, there are no table<br />
columns in <strong>OpenOffice</strong>.<strong>org</strong>. These are produced implicitly by arranging the rows (one under another) next to one<br />
another. To simplify access to the tables, <strong>OpenOffice</strong>.<strong>org</strong>, however, provides some methods which operate using<br />
columns. These are useful if no cells have been merged in the table.<br />
Let us first take the properties of the table itself. These are defined in the com.sun.star.text.TextTable service.<br />
Here is an list of the most important properties of the table object:<br />
BackColor (Long)<br />
background color of table.<br />
BottomMargin (Long)<br />
bottom margin in 100ths of a millimeter.<br />
LeftMargin (Long)<br />
left margin in 100ths of a millimeter.<br />
RightMargin (Long)<br />
right margin in 100ths of a millimeter.<br />
TopMargin (Long)<br />
top margin in 100ths of a millimeter.<br />
RepeatHeadline (Boolean)<br />
table header is repeated on every page.<br />
Width (Long)<br />
Rows<br />
absolute width of the table in 100ths of a millimeter.<br />
A table consists of a list containing rows. The following example shows how the rows of a table can be retrieved<br />
and formatted.<br />
Dim Doc As Object<br />
Dim Table As Object<br />
Dim Cursor As Object<br />
Dim Rows As Object<br />
Dim Row As Object<br />
Dim I As Integer<br />
Doc = ThisComponent<br />
Cursor = Doc.Text.createTextCursor()<br />
Table = Doc.createInstance("com.sun.star.text.TextTable")<br />
Table.initialize(5, 4)<br />
Doc.Text.insertTextContent(Cursor, Table, False)<br />
Rows = Table.getRows<br />
For I = 0 To Rows.getCount() - 1<br />
Row = Rows.getByIndex(I)<br />
Row.BackColor = &HFF00FF<br />
Next<br />
The example first creates a list containing all rows using a Table.getRows call. The getCount and getByIndex<br />
methods allow the list to be further processed and belongs to the com.sun.star.table.XtableRows interface.<br />
The getByIndex method returns a row object, which supports the com.sun.star.text.TextTableRow service.<br />
Chapter 6 · Text Documents 83