New way to modify nested uno structs in LibreOffice BASIC

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


with 
http://cgit.freedesktop.org/libreoffice/core/commit/?id=1720641bf36306fc296635925e571556ced8a302 
a long standing wrinkle with modifying nested structs in basic should be 
eliminated

before this change the following macro snippet would not work.

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

the unfortunate non obvious workaround to modify the contents of 
'b0.HorizontalLine.OuterLineWidth' is....
    a) create a new "com.sun.star.table.BorderLine" instance
    b) clone it with the contents of 'b0.HorizontalLine'
    c) modify the 'OuterLineWidth' member of the new 
"com.sun.star.table.BorderLine" instance
    d) set the value b0.HorizontalLine' with the newly modified 
"com.sun.star.table.BorderLine" 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

Noel

[*] 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