https://bugs.freedesktop.org/show_bug.cgi?id=47263

             Bug #: 47263
           Summary: [BASIC] nested UNO structs confusing
    Classification: Unclassified
           Product: LibreOffice
           Version: LibO 3.4.3 release
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
        Depends on: 42819


+++ This bug was initially created as a clone of Bug #42819 +++

(Reconfirmed with 3.5.0)

Nested UNO structs behave in confusing ways.

Consider:

Sub TMP0()
   Dim b0 as new "com.sun.star.table.TableBorder"
   MsgBox b0.HorizontalLine.OuterLineWidth
   b0.HorizontalLine.OuterLineWidth = 9
   MsgBox b0.HorizontalLine.OuterLineWidth
End Sub

Expected result: 0, then 9.
Actual result: 0, then 0.
The value change is *silently* ignored.

The way to achieve changing the value is:

Sub TMP1()
   Dim b0 as new "com.sun.star.table.TableBorder", l as new
"com.sun.star.table.BorderLine"
   MsgBox b0.HorizontalLine.OuterLineWidth
   l = b0.HorizontalLine
   l.OuterLineWidth = 9
   b0.HorizontalLine = l
   MsgBox b0.HorizontalLine.OuterLineWidth
End Sub

My guess (confirmed by Noel Power in bug 42819 comment 2) is that in the
statement "b0.HorizontalLine.OuterLineWidth = 9", the sub-expression
"b0.HorizontalLine" returns a *temporary* fresh *copy* of the sub-struct, and
that this temporary copy is modified instead of the substructure of b0.


I maintain that this is a trap for the programmer, and that StarBasic would be
a better language if TMP0 worked as expected. From a possibly naive POV, Basic
could for example make a distinction between rvalues and lvalues like C does
and use reference instead of value (copy) in an lvalue, and continue using
value (copy) in an rvalue.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to