21#include <osl/diagnose.h>
23#include <com/sun/star/util/NumberFormat.hpp>
24#include <com/sun/star/util/XNumberFormatter.hpp>
25#include <com/sun/star/beans/XPropertySet.hpp>
31sal_Int16
getNumberFormatType(
const css::uno::Reference<css::util::XNumberFormats>& xFormats, sal_Int32 nKey)
33 sal_Int16 nReturn(css::util::NumberFormat::UNDEFINED);
38 css::uno::Reference<css::beans::XPropertySet> xFormat(xFormats->getByKey(nKey));
40 xFormat->getPropertyValue(
"Type") >>= nReturn;
44 SAL_WARN(
"comphelper",
"getNumberFormatType : invalid key! (maybe created with another formatter ?)");
51sal_Int16
getNumberFormatType(
const css::uno::Reference<css::util::XNumberFormatter>& xFormatter, sal_Int32 nKey)
53 OSL_ENSURE(xFormatter.is(),
"getNumberFormatType : the formatter isn't valid !");
54 css::uno::Reference<css::util::XNumberFormatsSupplier> xSupplier( xFormatter->getNumberFormatsSupplier());
55 OSL_ENSURE(xSupplier.is(),
"getNumberFormatType : the formatter doesn't implement a supplier !");
56 css::uno::Reference<css::util::XNumberFormats> xFormats( xSupplier->getNumberFormats());
67 css::uno::Reference<css::beans::XPropertySet> xFormat( xFormats->getByKey(nKey));
70 return xFormat->getPropertyValue(
"Decimals" );
75 SAL_WARN(
"comphelper",
"getNumberFormatDecimals : invalid key! (may be created with another formatter ?)");
78 return css::uno::Any(sal_Int16(0));
91 OSL_ENSURE( _rxFormatter.is() && !_rPropertyName.isEmpty(),
"getNumberFormatProperty: invalid arguments!" );
94 Reference< XNumberFormatsSupplier > xSupplier;
95 Reference< XNumberFormats > xFormats;
96 Reference< XPropertySet > xFormatProperties;
98 if ( _rxFormatter.is() )
99 xSupplier = _rxFormatter->getNumberFormatsSupplier();
100 if ( xSupplier.is() )
101 xFormats = xSupplier->getNumberFormats();
103 xFormatProperties = xFormats->getByKey( _nKey );
105 if ( xFormatProperties.is() )
106 aReturn = xFormatProperties->getPropertyValue( _rPropertyName );
110 OSL_FAIL(
"::getNumberFormatProperty: caught an exception (did you create the key with another formatter?)!" );
#define SAL_WARN(area, stream)
Any getNumberFormatProperty(const Reference< XNumberFormatter > &_rxFormatter, sal_Int32 _nKey, const OUString &_rPropertyName)
css::uno::Any getNumberFormatDecimals(const css::uno::Reference< css::util::XNumberFormats > &xFormats, sal_Int32 nKey)
returns the decimals of the given numeric number formatunder the given formats
sal_Int16 getNumberFormatType(const css::uno::Reference< css::util::XNumberFormats > &xFormats, sal_Int32 nKey)
returns the css::util::NumberFormat of the given key under the given formats