21.08.2013 Views

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - OpenOffice.org wiki

OpenOffice.org BASIC Guide - OpenOffice.org wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

More Than Just Text<br />

Here are the central methods of the com.sun.star.table.XtableRows interface:<br />

getByIndex(Integer)<br />

returns a row object for the specified index.<br />

getCount()<br />

returns the number of row objects.<br />

insertByIndex(Index, Count)<br />

inserts Count rows in the table as of the Index position.<br />

removeByIndex(Index, Count)<br />

deletes Count rows from the table as of the Index position.<br />

Whereas the getByIndex and getCount methods are available in all tables, the insertByIndex and<br />

removeByIndex methods can only be used in tables that do not contain merged cells.<br />

The com.sun.star.text.TextTableRow service provides the following properties:<br />

BackColor (Long)<br />

background color of row.<br />

Height (Long)<br />

height of line in 100ths of a millimeter.<br />

IsAutoHeight (Boolean)<br />

table height is dynamically adapted to the content.<br />

VertOrient (const)<br />

vertical orientation of the text frame — details on vertical orientation of the text within the table (values in<br />

accordance with com.sun.star.text.VertOrientation)<br />

Columns<br />

Columns are accessed in the same way as rows, using the getByIndex, getCount, insertByIndex, and<br />

removeByIndex methods on the Column object, which is reached through getColumns. They can, however,<br />

only be used in tables that do not contain merged table cells. Cells cannot be formatted by column in<br />

<strong>OpenOffice</strong>.<strong>org</strong> Basic. To do so, the method of formatting individual table cells must be used.<br />

Cells<br />

Each cell of a <strong>OpenOffice</strong>.<strong>org</strong> document has a unique name. If the cursor of <strong>OpenOffice</strong>.<strong>org</strong> is in a cell, then the<br />

name of that cell can be seen in the status bar. The top left cell is usually called A1 and the bottom right row is<br />

usually called Xn, where X stands for the letters of the top column and n for the numbers of the last row. The cell<br />

objects are available through the getCellByName() method of the table object. The following example shows a<br />

loop that passes through all the cells of a table and enters the corresponding row and column numbers into the<br />

cells.<br />

Dim Doc As Object<br />

Dim Table As Object<br />

Dim Cursor As Object<br />

Dim Rows As Object<br />

Dim RowIndex As Integer<br />

Dim Cols As Object<br />

Dim ColIndex As Integer<br />

Dim CellName As String<br />

Dim Cell As Object<br />

Doc = ThisComponent<br />

Cursor = Doc.Text.createTextCursor()<br />

Table = Doc.createInstance("com.sun.star.text.TextTable")<br />

Table.initialize(5, 4)<br />

84 <strong>OpenOffice</strong>.<strong>org</strong> 3.2 <strong>BASIC</strong> <strong>Guide</strong> · March 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!