Writer Table Columns Access via Java API

Thomas Krumbein Thomas.Krumbein at documentfoundation.org
Mon May 6 15:59:57 UTC 2019


Hey Andy,

is is not a bug... the use of writer tables is a little bit different.

the width of a column is not an absolute value, but will be calculated 
in realitionship to the width of the table itself. And the width of the 
table depends on width of your page, textarea and right/left margins.

so... to change the width of a table-column you need to know a lot of 
values and then you can calulate the width of your table istself (a 
texttable will be always expand over the hole width of the textarea 
minus left and right margin (if set).

Column-width will be specified in the struct 
com.sun.star.text.TableColumnSeperator - the array will define all 
tableseperators as value based on the total width of the table itself.

For example:

your textarea may have a width of 14 cm. Your table should have a width 
of 10 cm. So you define a magin left and right of 2 cm.

Now your table will have two colums --- first column should be 3 cm, 
second column is now 7 cm.

Your array TableColumnSeperator needs one element - starting from 
beginning of table the entry will have the value  3/10*10000 = 3000.

so, always starting from beginning of the table, the width of the Table 
is always 10000 (abstarct number, means maybe 100%).

The total width is 10 cm (calculate before), you need 3 cm --so you 
get:  3/10  * 10000  - position of your column-seperator.

it is a little bit complicated and I do not have an code-example in java 
or ruby, only a german-based basic example. But I hope, you get some 
hints so you can search for more informations.

Best regards

Thomas



Am 06.05.2019 um 11:00 schrieb fxruby:
> Hello,
>
> I'm currently writing a program using the libreoffice java api.
> It's a programm controlling the Writer component. I can insert tables,
> place images inside the table and also change the height of table rows.
> Now I want to change the width of a table column. But when I try to get
> a column, I always get an empty object.
>
> Here's what I do (it's JRuby code, but very similar to java):
> [...]
>
> Is this a bug or what am I doing wrong?
>
> kind regards,
>
> Andy
> _______________________________________________
> LibreOffice mailing list
> LibreOffice at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/libreoffice


More information about the LibreOffice mailing list