To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=72380
                 Issue #|72380
                 Summary|Adding a number format changes the format case.
               Component|api
                 Version|OOo 2.0.4
                Platform|All
                     URL|
              OS/Version|All
                  Status|NEW
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P3
            Subcomponent|code
             Assigned to|jsc
             Reported by|pitonyak





------- Additional comments from [EMAIL PROTECTED] Thu Dec  7 22:12:11 -0800 
2006 -------
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

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to