Bug 60878 - Passing an address to MakePropertyValue() works on LO 3.5, breaks on LO 4.0.0.3
Summary: Passing an address to MakePropertyValue() works on LO 3.5, breaks on LO 4.0.0.3
Status: RESOLVED DUPLICATE of bug 60117
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
4.0.0.3 release
Hardware: x86 (IA32) macOS (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-15 08:41 UTC by Andrew Beattie
Modified: 2013-11-18 12:15 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Spreadsheet that fails in LO 4.0 (8.45 KB, application/vnd.oasis.opendocument.spreadsheet)
2013-02-15 08:41 UTC, Andrew Beattie
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Beattie 2013-02-15 08:41:41 UTC
Created attachment 74856 [details]
Spreadsheet that fails in LO 4.0

This sample code silently completes on LO Calc 3.5 but fails on 4.0.0.3

We pass an address in the second argument to MakePropertyValue()
in 3.5, this works.  In 4.0, the address is empty.

The comments in-line help to explain.

Sub Main

Rem This script is designed to work on the default, empty spreadsheet
oSheet = ThisComponent.Sheets.getByName("Sheet1")
Dim aAddress as New com.sun.star.table.CellAddress

rem get the address of a cell (any cell):
aAddress =  oSheet.getCellByPosition(5, 5).getCellAddress()

Rem prove that the address is valid
Msgbox "Address of this cell: Column=" & aAddress.Column & "; Row=" & aAddress.Row & "; Sheet=" + aAddress.Sheet

Rem Call a popular function with the address
MakePropertyValue( "SourcePosition", aAddress )

End Sub

Rem MakePropertyValue() is a common function used by many
Rem in 4.0, the stack trace shows that the second argument is an address but it has no value
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
   Dim oPropertyValue As New com.sun.star.beans.PropertyValue
   If Not IsMissing( cName ) Then
      oPropertyValue.Name = cName
   EndIf
   Rem This is where things go wrong.  In 4.0, uValue is not missing (it is an address) but it has no value:
   If Not IsMissing( uValue ) Then
      Rem in 4.0 the script stops here with the error "Object Variable not set"
      oPropertyValue.Value = uValue
   EndIf
   MakePropertyValue() = oPropertyValue
End Function
Comment 1 Joel Madero 2013-03-21 19:05:06 UTC
@Noel - I think I was told you're the go to for macros - any ideas on this one?
Comment 2 Noel Power 2013-03-22 10:12:01 UTC
please check latest libreoffice releases before reporting, this has been fixed for a while and is working as expected in 4.0.1

*** This bug has been marked as a duplicate of bug 60117 ***
Comment 3 Andrew Beattie 2013-03-25 16:33:10 UTC
For my own honour, I would point out that this bug was checked against the latest release available at the time when it was reported.