Page 1 of 1

AutoWidth / AutoSize ListBox ???

Posted: Mon Jan 14, 2008 11:40 pm
by deeno
hello everybody!
first of all, i do not know if this is the right forum, but i'll try, as i havent found anything about my problem in other forums or inside the documentation... if i am wrong in here, please move this thread into the right forum!

the problem
i am starting my first steps with base and i want to accomplish the following:

i created a writer.document and inserted a ListBox element inside a text,
linked this element to the small DB i created with base, in order to be able to select
names of customers from this DB to be inserted inside this document (which happens to be an invoice),
exporting it as a PDF and sending it to them. SO FAR IT ALL WORKS GREAT!
...but!
yeah, there is always a "but"...
i have set the size of this ListBox to lets say 5 cm, "but" selecting a name with only a smal size of lets say 3 cm leaves a big gap after the name on the exported PDF, which is kind of "ugly"... (see attached file)
AutoSizeListBox.jpg
the question
is it possible to AutoSize the width of this ListBox after selecting a name, so its size is adjusted according to the length of this name?
maybe some kind of macro initiated on the "Changed" Event?

or maybe there is another, much simpler solution to this, i havent come accorss yet...

any help will be appreciated!!!

many thanks in advance!
deeno

Re: AutoWidth / AutoSize ListBox ???

Posted: Tue Jan 15, 2008 7:08 am
by Villeroy
http://api.openoffice.org/docs/common/r ... rains.html

getMinimumSize returns the minimum size for this component.
getPreferredSize returns the preferred size for this component.
calcAdjustedSize(size) calculates the adjusted size for a given maximum size.

All methods return a struct com.sun.star.awt.Size with elements Width and Height.
http://api.openoffice.org/docs/common/r ... /Size.html

Re: AutoWidth / AutoSize ListBox ???

Posted: Tue Jan 15, 2008 12:40 pm
by deeno
thanks villeroy,

trouble is, i aint got no clue what to do with those infos...
do i need to program a macro? in what language? can i do that? how easy is it?
(i am skilled in actionscript, javascript, php, html...)
any tutorial on this?
i would then need also the length of the chars in the listbox i selected...
or even better the width of all selected chars together?

i never did any programming for openoffice, isnt there a different way to solve this problem?

Re: AutoWidth / AutoSize ListBox ???

Posted: Sun Jan 20, 2008 10:35 pm
by deeno
hm, seems that villeroy is on vacations...
anybody else on my questions?