To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=54374
                  Issue #:|54374
                  Summary:|NumberFormat not properly preserved on a save
                Component:|framework
                  Version:|680m126
                 Platform:|All
                      URL:|
               OS/Version:|All
                   Status:|NEW
        Status whiteboard:|
                 Keywords:|
               Resolution:|
               Issue type:|DEFECT
                 Priority:|P3
             Subcomponent:|code
              Assigned to:|tm
              Reported by:|pitonyak





------- Additional comments from [EMAIL PROTECTED] Thu Sep  8 11:47:38 -0700 
2005 -------
I created a numeric property 

0 (###) ### ## ##

I saved the document, loaded the document, and then the numeric property is
shown as:

#" ("###") "###" "##" "#0


This is true in both 1.1.4 and 1.95.126. Next, I inspected the numeric format
and noticed that the number of leading zeros is set to 1. From my perspective,
this makes the two different numeric formats identical. The problem is that the
number is NOT properly displayed when the document is reloaded.

To test this, 
1. Create a Write document with a text table. 
2. Add the text 123456789 into a cell.
3. Select the text 123456789.
4. Run the following macro:

Sub SetFormat
  Dim i%
  Dim oSels, oSel
  oSels = ThisComponent.getCurrentController().getSelection()
  For i = 0 To oSels.getCount()-1
    oSel = oSels.getByIndex(i)
    If NOT IsEmpty(oSel.Cell) Then 
      oSel.Cell.NumberFormat = FindCreateNumberFormatStyle("0 (###) ### ## ##")
      Print "Set to " & oSel.Cell.NumberFormat
    End if
  Next
End Sub

'******************************************************************
'Author: Andrew Pitonyak
'email:   [EMAIL PROTECTED]
Function FindCreateNumberFormatStyle (_
  sFormat As String, Optional doc, Optional locale)
  Dim oDocument As Object
  Dim aLocale as new com.sun.star.lang.Locale
  Dim oFormats As Object
  Dim formatNum As Integer
  oDocument = IIf(IsMissing(doc), ThisComponent, doc)
  oFormats = oDocument.getNumberFormats()
  'If you choose to query on types, you need to use the type
  'com.sun.star.util.NumberFormat.DATE
  'I could set the locale from values stored at
  'http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt
  'http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html
  'I use a NULL locale and let it use what ever it likes.
  'First, see if the number format exists
  If ( Not IsMissing(locale)) Then
    aLocale = locale
  End If
  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
    formatNum = oFormats.addNew(sFormat, aLocale)
    If (formatNum = -1) Then formatNum = 0
    MsgBox "new Format number is " & formatNum
  End If
  FindCreateNumberFormatStyle = formatNum
End Function 

Now, inspect the number format that was created. You can use the following macro
if you desire: Be certain to place the cursor outside of the table before
running this macro.

Sub enumFormats()
  'Author : Laurent Godard
  'e-mail : [EMAIL PROTECTED]
  'Modified : Andrew Pitonyak
  Dim vText
  Dim vFormats, vFormat
  Dim vTextCursor, vViewCursor
  Dim iMax As Integer, i As Integer
  Dim s$
  Dim PrevChaine$, Chaine$
  Dim aLocale as new com.sun.star.lang.Locale
 
  vFormats = ThisComponent.getNumberFormats()
  'RunSimpleObjectBrowser(vFormats)
  vText = ThisComponent.Text
  vViewCursor = ThisComponent.CurrentController.getViewCursor()
  vTextCursor = vText.createTextCursorByRange(vViewCursor.getStart())
  Dim v
  v = vFormats.queryKeys(com.sun.star.util.NumberFormat.ALL, aLocale, False)
  For i = LBound(v) To UBound(v)
    vFormat=vFormats.getbykey(v(i))
    chaine=VFormat.FormatString
    If Chaine<>Prevchaine Then
      PrevChaine=Chaine
      chaine=CStr(v(i)) & CHR$(9) & CHR$(9) & chaine & CHR$(10)
      vText.insertString(vTextCursor, Chaine, FALSE)
    End If
  Next
  MsgBox "Finished"
End Sub 

If you save the document, close the document, and open the document, the number
format will change (acceptable), but the displayed number will also change (not
acceptable).

---------------------------------------------------------------------
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