try {
if (xNumberFormatter == null) {
IServiceProvider serviceProvider = textDocument
.getServiceProvider();
if (serviceProvider == null)
throw new UtilException(
"No service provider available in document.");
Object formatter = serviceProvider
.createServiceWithContext("com.sun.star.util.NumberFormatter");
xNumberFormatter = (XNumberFormatter) UnoRuntime
.queryInterface(XNumberFormatter.class, formatter);
xNumberFormatter
.attachNumberFormatsSupplier(xNumberFormatsSupplier);
}
return xNumberFormatter.convertNumberToString(key, number);
} catch (Exception exception) {
UtilException utilException = new UtilException(exception
.getMessage());
utilException.initCause(exception);
throw utilException;
}
}