Issue 72380 - Adding a number format changes the format case.
Summary: Adding a number format changes the format case.
Status: CONFIRMED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-08 06:12 UTC by andrew
Modified: 2017-05-20 11:27 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
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 com.sun.star.lang.Locale
  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 "issues@openoffice.apache.org".