Hi all,

I'm translating dispatch commands to regular API calls for a project I'm 
currently working on:

I've a 'problem' with the following dispatch command in Calc:

As you can imagine, this command modify the number format in the selected 
cell/range, adding a decimal place.

Tha 'API translation' that I've found is really huge! about 26 rows.
You can see it at the end of this post.

Normally this wouldn't be a problem, but in this case, the code is generated 
from a macro recorder, and the target is the average user, so my concern is 
to keep things as simple as more as it is possible.

So my question is:
Perhaps there is a more convenient way to add/remove decimal places from a 
cell number format via API?

thank you
Paolo Mantovani


' the dispatch command to "translate" :
'Dispatcher.executeDispatch(DocumentFrame,".uno:NumberFormatIncDecimals" ,"" ,0 
' the "translation" :

   ' Retrieve current number format settings
   FormatKey = DocumentView.Selection.NumberFormat
   FormatProperties = DocumentModel.NumberFormats.getByKey(NumberFormatKey)
   ' Create a new format string based on the current one 
   ' (but with a further decimal place)
   FormatString = DocumentModel.NumberFormats.generateFormat( _
      FormatKey, _
      FormatProperties.Locale, _
      FormatProperties.ThousandsSeparator, _
      FormatProperties.NegativeRed, _
      FormatProperties.Decimals + 1, _
      FormatProperties.LeadingZeros _
   ' Retrieve or create a key for the generated format string
   FormatKey = DocumentModel.NumberFormats.queryKey( _
                 FormatString,FormatProperties.Locale, True)
   If FormatKey = - 1 Then 
     FormatKey = DocumentModel.NumberFormats.addNew( _
                    FormatString, FormatProperties.Locale)
   End If
   ' apply the number format to the current selection
   DocumentView.Selection.NumberFormat = FormatKey

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

Reply via email to