3

I've got Table Control in Libre/OpenOffice Base form which is filled dynamically.
I want to change height of it to match number of rows.
How to do it?

I've tried changing getSize() / setSize(), and height property but I'm getting:

Property or method not found: getSize

My code:

oTable = oForm.GetByName("MySubForm").GetByName("MyTable")
oTable.getSize()

Visualisation: https://i.stack.imgur.com/socUI.png

About this Table Control as it is named in Base - in debugger it's com.star.comp.forms.OGridControlModel, in content.xml it's listed as com.sun.star.form.component.GridControl

Jacek Kaniuk
  • 5,229
  • 26
  • 28

1 Answers1

1

Your problem is the Table object has no height, the height is based on the number of rows (as well as the TopMargin and BottomMargin).

Every row has it's own Height property.

If you want a Table's height you need to sum the Height of all of the rows. Tables have TopMargin and BottomMargin properties that effect ?perceived? height as well.

Rows = Table.getRows
For I = 0 To Rows.getCount() - 1
   Row = Rows.getByIndex(I)
   CurrentHeight = CurrentHeight + Row.Height
Next

If you want to set a Table's height you need to either add/remove rows or change the Height of the current rows.

Rows.insertByIndex(Rows.getCount(), 1)
Row = Rows.getByIndex(Rows.getCount() - 1)
Row.IsAutoHeight = False
Row.Height = 1000

You can look at the full documentation online. http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide/More_Than_Text

Louis Ricci
  • 20,804
  • 5
  • 48
  • 62
  • Table Control it's not usual Writer Table. I could modify `Table.RowHeight` to change all rows at once, but it won't change table height, just white space below rows. There is no `Top/BottomMargin` property either in `Table` or `Table.RowSet`. See: http://i.imgur.com/IHi75.png - it's filled on the fly – Jacek Kaniuk Dec 21 '11 at 16:21
  • 1
    @Jacek_FH - can you change the table height manually with your mouse? If you can there must be some property we're missing, if you can't it may not be possible in the macro language either. Or perhaps you can change the height of the sub-form that surrounds the table. – Louis Ricci Dec 21 '11 at 16:55
  • I can't change it with my mouse (in view). I've looked in content.xml - height is not a property of `` -> ``, but of `` -> `svg:height` – Jacek Kaniuk Dec 21 '11 at 17:46