Issue 72380

Summary: Adding a number format changes the format case.
Product: App Dev Reporter: andrew
Component: apiAssignee: AOO issues mailing list <issues>
Status: CONFIRMED --- QA Contact:
Severity: Trivial    
Priority: P3 CC: issues
Version: 3.3.0 or older (OOo)   
Target Milestone: ---   
Hardware: All   
OS: All   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---

Description andrew 2006-12-08 06:12:11 UTC
I noticed thisproblem when I added a number format containing the text "Red" to
a Calc document. When I searched for the number format, I could not find it. So,
I tried to add the format a second time and this causes my macro to crash
because it already exists. OpenOffice continues to run, but there are two problems:

1. The macro fails.
2. It is not possible to find the key that was added.

If the key is converted to upper case, the search should NOT be case sensitive.

Although I have only tested this macro with a Calc document, the document type
should NOT matter.

Sub DoTheCrash()
  Dim s1$ : s1 = "#,##0.00_);[RED](#,##0.00)"
  Dim s2$ : s2 = "#,##0.00_);[Red](#,##0.000)"
  Print "Add style 1 = " & FormatStyleCrash(s1, ThisComponent)
  Print "Check style 1 = " & FormatStyleCrash(s1, ThisComponent)
  Print "Add style 2 = " & FormatStyleCrash(s2, ThisComponent)
  Print "Check style 2 = " & FormatStyleCrash(s2, ThisComponent)
End Sub

Function FormatStyleCrash(sFormat, oDoc)
  Dim aLocale As New
  Dim oFormats As Object
  Dim formatNum As Integer

  oFormats = oDoc.getNumberFormats()
  formatNum = oFormats.queryKey(sFormat, aLocale, True)
  'MsgBox "Current Format number is" & formatNum
  'If the number format does not exist then add it
  If (formatNum = -1) Then
    'Print "Ready to add format " & sFormat
    formatNum = oFormats.addNew(sFormat, aLocale)
    If (formatNum = -1) Then formatNum = 0
    'MsgBox "new Format number is " & formatNum
  End If
  FormatStyleCrash = formatNum 
End Function
Comment 1 jsc 2006-12-08 07:29:15 UTC
jsc -> nn: can check and comment this please
Comment 2 Marcus 2017-05-20 11:27:39 UTC
Reset assigne to the default "".