Issue 105683 - A numberformat can disappear when saving
Summary: A numberformat can disappear when saving
Status: CONFIRMED
Alias: None
Product: Calc
Classification: Application
Component: code (show other issues)
Version: DEV300m60
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-07 14:12 UTC by Joost Andrae
Modified: 2017-05-20 11:33 UTC (History)
3 users (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 Joost Andrae 2009-10-07 14:12:16 UTC
Within a document (which has already been sent to Niklas) you cannot save a
newly added numberformat anymore. 

As far as it has been evaluated the maximum value of user defined numberformats
has been reached. The idea how to fix this issue is to remove UNUSED user
defined numberformats if the maximum number off by one of user defined
numberformats per document locale has been reached and you want to save the
document.

An additional trigger to force removing unused user defined numberformats would
help to repair such documents.

A side effect is that document load performance will be better
Comment 1 Joost Andrae 2009-10-07 15:55:34 UTC
.
Comment 2 Oliver Brinzing 2009-10-07 18:04:20 UTC
IMHO it would be a good idea to have an option to remove unused numberformats
during save, even if the maximum value is not reached.
Maybe this could be an optional feature in Tools - Options ?

AFAIK there is no API to check whether a numberformat is used or not. we can
only check whether a cellstyle is used or not ... but this will not help here. a
numberformat can be removed via api but this can damage the spread- 
sheet document, for example:

Sub removeUserDefinedNumerFormats()

	Dim oLocale as New com.sun.star.lang.Locale
	Dim oKey as Object
	Dim nFormat as Integer
	Dim nSeq() as Long
	Dim s as String
	Dim i as Integer
	
	Dim oDocument as Object
	oDocument = ThisComponent

	nFormat = com.sun.star.util.NumberFormat.DEFINED
	nSeq() = oDocument.getNumberFormats().queryKeys(nFormat, 
                                                                               
                          oLocale, False)

	For i = 0 To uBound(nSeq())
		oKey = oDocument.getNumberFormats().getByKey(nSeq(i))
		s = s & oKey.FormatString & " "  & oKey.Comment &  " " & 
                                                                      
oKey.UserDefined & Chr(13)
		oDocument.getNumberFormats().removeByKey(nSeq(i))
	Next i

	MsgBox s
End Sub

will remove all user defined numberformats. so another option would be
to implement isUsed() for numberformats.

I have a couple of spreadsheets with a huge number of unused numberformats and
don't know how to remove them ... cause i see
no easy way to verify the cleaned document ... Edit - Document compare
will not help here too ...
Comment 3 niklas.nebel 2009-10-08 10:29:10 UTC
CCed: oc
Comment 4 Marcus 2017-05-20 11:33:26 UTC
Reset assigne to the default "issues@openoffice.apache.org".