Apache OpenOffice (AOO) Bugzilla – Issue 105683
A numberformat can disappear when saving
Last modified: 2017-05-20 11:33:26 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
.
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 ...
CCed: oc
Reset assigne to the default "issues@openoffice.apache.org".