https://bugs.freedesktop.org/show_bug.cgi?id=42819
Bug #: 42819 Summary: [BASIC] nested UNO structs and UNO object properties of type "a uno struct" 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: libreoffice-bugs@lists.freedesktop.org ReportedBy: lio...@mamane.lu Nested UNO structs and properties of Objects that are 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 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. Now, consider this code which is supposed to change the borders of the table named "someTbl" in document "TST.odt": Sub TMP2() Dim docs as Object, doc as object docs = StarDesktop.Components.createEnumeration() Do While docs.hasMoreElements() doc = docs.nextElement() If doc.title = "TST.odt" Then dim tbl as object tbl = doc.getTextTables().getByName("someTbl") Dim border As new "com.sun.star.table.TableBorder", ligne As new "com.sun.star.table.BorderLine" ligne.OuterLineWidth = 1 border.HorizontalLine = ligne tbl.TableBorder = border MsgBox border.HorizontalLine.OuterLineWidth MsgBox tbl.TableBorder.HorizontalLine.OuterLineWidth End If Loop End Sub Again, the change is silently ignored! I don't really have an idea why. By contrast, this version works: Sub TMP2() Dim docs as Object, doc as object docs = StarDesktop.Components.createEnumeration() Do While docs.hasMoreElements() doc = docs.nextElement() If doc.title = "TST.odt" Then dim tbl as object tbl = doc.getTextTables().getByName("someTbl") Dim border As Object, ligne As new "com.sun.star.table.BorderLine" border = tbl.TableBorder ligne.OuterLineWidth = 1 border.HorizontalLine = ligne tbl.TableBorder = border End If Loop End Sub Also the following fails: Sub TMP3() Dim docs as Object, doc as object docs = StarDesktop.Components.createEnumeration() Do While docs.hasMoreElements() doc = docs.nextElement() If doc.title = "TST.odt" Then dim tbl as object tbl = doc.getTextTables().getByName("someTbl") Dim border As new "com.sun.star.table.TableBorder" ' the following assignment fails; error message "Object Required" border = tbl.TableBorder End If Loop End Sub Why can't "border", having the *right* struct type be assigned (by copy, "obviously") the value of tbl.TableBorder. Especially considering this does work: Sub TMP4() Dim docs as Object, doc as object docs = StarDesktop.Components.createEnumeration() Do While docs.hasMoreElements() doc = docs.nextElement() If doc.title = "Untitled 2" Then dim tbl as object tbl = doc.getTextTables().getByName("someTbl") Dim b0 as Object, border As new "com.sun.star.table.TableBorder" b0 = tbl.TableBorder border = b0 End If Loop End Sub -- 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 Libreoffice-bugs@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs