New way to modify nested uno structs in LibreOffice BASIC
Andrew Douglas Pitonyak
andrew at pitonyak.org
Wed Jul 4 18:47:06 PDT 2012
On 07/04/2012 03:23 PM, Noel Power wrote:
> 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 )
> _______________________________________________
> LibreOffice mailing list
> LibreOffice at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice
>
The behavior change scares me a bit. I seem to remember some time back
that there was a reason for this behavior, but I was given that
information many years back..... I discussed it in Berlin
http://www.pitonyak.org/oooconf/OOoConf_2004_Macro_Presentation.sxi
Do you intend to change UNO so that structures return as a reference
(very dangerous, don't do it), or only when used in basic as
object.structure.property? This may be workable / safe, but may break
some existing code (although I can't think of any code that it would break).
I feel silly asking this, since if you know how to change the behavior,
then you likely know more about this than I (I don't know how to change
the behavior).
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info: http://www.pitonyak.org/oo.php
More information about the LibreOffice
mailing list