Problems with LibreOffice 4.0.0

LibreOffice 4 was finally released, and it is in many ways improved over the previous version 3. Unfortunately, it also introduces a bug that seriously affects me, and it may, or may not, affect you.

I wrote an add-on that adds color to source code and XML. Consider the subroutine shown below:

  1. '****************************************************************
  2. '** Create and return a PropertyValue structure.
  3. '****************************************************************
  4. Function CreateProperty( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
  5.    Dim oPropertyValue As New com.sun.star.beans.PropertyValue
  6.    If Not IsMissing( cName ) Then
  7.       oPropertyValue.Name = cName
  8.    EndIf
  9.    If Not IsMissing( uValue ) Then
  10.       oPropertyValue.Value = uValue
  11.    EndIf
  12.    CreateProperty() = oPropertyValue
  13. End Function 

The above code fails....... This has already been fixed for the 4.0.1 release of LO. Note that the code below allows the code to run. See the difference? There is something about assigning a struct to a field in a struct if there is not already a value there. Thanks to Noel Power for fixing this so quickly, but alas, it was not found fast enough to make it into 4.0.

  1. '****************************************************************
  2. '** Create and return a PropertyValue structure.
  3. '****************************************************************
  4. Function CreateProperty( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
  5.    Dim oPropertyValue As New com.sun.star.beans.PropertyValue
  6.    If Not IsMissing( cName ) Then
  7.       oPropertyValue.Name = cName
  8.    EndIf
  9.    If Not IsMissing( uValue ) Then
  10.       If IsUnoStruct(uValue) Then
  11.         oPropertyValue.Value = ThisComponent
  12.       End If
  13.       oPropertyValue.Value = uValue
  14.    EndIf
  15.    CreateProperty() = oPropertyValue
  16. End Function