New way to modify nested uno structs in LibreOffice BASIC

Noel Power nopower at
Wed Jul 4 12:23:50 PDT 2012

a long standing wrinkle with modifying nested structs in basic should be 

before this change the following macro snippet would not work.

    Dim b0 as new ""
    MsgBox b0.HorizontalLine.OuterLineWidth 'HorizontalLine member is 
itself a "" struct
    b0.HorizontalLine.OuterLineWidth = 9
    'the following line unexpectedly displays '0' because 
'b0.HorizontalLine' returns a new but temporary copy of 
    MsgBox b0.HorizontalLine.OuterLineWidth

the unfortunate non obvious workaround to modify the contents of 
'b0.HorizontalLine.OuterLineWidth' is....
    a) create a new "" instance
    b) clone it with the contents of 'b0.HorizontalLine'
    c) modify the 'OuterLineWidth' member of the new 
"" instance
    d) set the value b0.HorizontalLine' with the newly modified 
"" instance

Although I have test this pretty well [*]  ( and fixed lots of issues 
already before committing ) changes to the basic runtime are always 
perilous ;-) so.. please please be on the lookout for any strange 
behaviour regarding handling of uno structs in basic


[*] have to admit I only tested one level of indirection. I didn't find 
a suitable structure that contains a structure that contains a structure 
to test, if you know of one off hand let me know :-) Also I have yet to 
write some unit tests for this ( but will do )

More information about the LibreOffice mailing list