I want to run some code as soon as a frame current height changes, so as soon as thiscomponent.textframes.getByIndex(0).LayoutSize.Height value changes.
My first idea was doing an infinite loop, checking for my frame height every 50 milliseconds
Code: Select all
sub autogrow
oDoc = thiscomponent
oItem = oDoc.textframes.getByIndex(0)
hgt = oItem.LayoutSize.Height
Do
updated_height = oItem.LayoutSize.Height
if not (updated_height = hgt) then
hgt = updated_height
msgbox "The height has changed!"
end if
Wait 50
Loop Until 0=1
end sub
I guess the LayoutSize method consumes too much ressources to be run every 50 milliseconds. And I need to use myFrame.LayoutSize.Height over myFrame.height, because this last one gives me the minimal height of the frame instead of the current height of the frame on the screen.
-> Is there a way to add an event listenner on my frame, to run some code as soon as the layoutsize changes?
I have found this on the API doc but I am clueless about how to use it :
https://www.openoffice.org/api/docs/com ... tener.html
https://www.openoffice.org/api/docs/com ... aster.html