24 #ifndef INCLUDED_CPPUHELPER_PROPTYPEHLP_HXX 25 #define INCLUDED_CPPUHELPER_PROPTYPEHLP_HXX 28 #include "com/sun/star/lang/IllegalArgumentException.hpp" 29 #include "com/sun/star/uno/TypeClass.hpp" 34 template <
class target >
38 if( !( a >>= value ) ) {
39 throw css::lang::IllegalArgumentException();
48 switch( a.getValueType().getTypeClass() ) {
49 case css::uno::TypeClass_BYTE:
52 case css::uno::TypeClass_SHORT:
53 b = a.get<sal_Int16>() != 0;
55 case css::uno::TypeClass_UNSIGNED_SHORT:
62 case css::uno::TypeClass_LONG:
63 b = a.get<sal_Int32>() != 0;
65 case css::uno::TypeClass_UNSIGNED_LONG:
66 b = a.get<sal_uInt32>() != 0;
68 case css::uno::TypeClass_CHAR:
75 throw css::lang::IllegalArgumentException();
88 switch( a.getValueType().getTypeClass() ) {
89 case css::uno::TypeClass_BOOLEAN:
90 i =
static_cast<sal_Int64
>(a.get<
bool>());
92 case css::uno::TypeClass_CHAR:
95 c = *
static_cast<sal_Unicode const *
>(a.getValue());
96 i =
static_cast<sal_Int64
>(c);
100 throw css::lang::IllegalArgumentException();
109 switch( a.getValueType().getTypeClass() ) {
110 case css::uno::TypeClass_BOOLEAN:
111 i =
static_cast<sal_uInt64
>(a.get<
bool>());
113 case css::uno::TypeClass_CHAR:
116 c = *
static_cast<sal_Unicode const *
>(a.getValue());
117 i =
static_cast<sal_uInt64
>(c);
121 throw css::lang::IllegalArgumentException();
129 switch( a.getValueType().getTypeClass() ) {
130 case css::uno::TypeClass_BOOLEAN:
131 i =
static_cast<sal_Int32
>(a.get<
bool>());
133 case css::uno::TypeClass_CHAR:
136 c = *
static_cast<sal_Unicode const *
>(a.getValue());
137 i =
static_cast<sal_Int32
>(c);
141 throw css::lang::IllegalArgumentException();
149 switch( a.getValueType().getTypeClass() ) {
150 case css::uno::TypeClass_BOOLEAN:
151 i =
static_cast<sal_uInt32
>(a.get<
bool>());
153 case css::uno::TypeClass_CHAR:
156 c = *
static_cast<sal_Unicode const *
>(a.getValue());
157 i =
static_cast<sal_uInt32
>(c);
161 throw css::lang::IllegalArgumentException();
169 switch( a.getValueType().getTypeClass() ) {
170 case css::uno::TypeClass_BOOLEAN:
171 i =
static_cast<sal_Int16
>(a.get<
bool>());
173 case css::uno::TypeClass_CHAR:
176 c = *
static_cast<sal_Unicode const *
>(a.getValue());
177 i =
static_cast<sal_Int16
>(c);
181 throw css::lang::IllegalArgumentException();
189 switch( a.getValueType().getTypeClass() ) {
190 case css::uno::TypeClass_BOOLEAN:
191 i =
static_cast<sal_uInt16
>(a.get<
bool>());
193 case css::uno::TypeClass_CHAR:
196 c = *
static_cast<sal_Unicode const *
>(a.getValue());
197 i =
static_cast<sal_Int16
>(c);
201 throw css::lang::IllegalArgumentException();
209 switch( a.getValueType().getTypeClass() ) {
210 case css::uno::TypeClass_BOOLEAN:
211 i =
static_cast<sal_Int8>(a.get<
bool>());
214 throw css::lang::IllegalArgumentException();
224 switch( a.getValueType().getTypeClass() ) {
225 case css::uno::TypeClass_BOOLEAN:
226 f =
static_cast<float>(a.get<
bool>());
228 case css::uno::TypeClass_LONG:
229 f =
static_cast<float>(a.get<sal_Int32>());
231 case css::uno::TypeClass_UNSIGNED_LONG:
232 f =
static_cast<float>(a.get<sal_uInt32>());
234 case css::uno::TypeClass_HYPER:
235 f =
static_cast<float>(a.get<sal_Int64>());
237 case css::uno::TypeClass_UNSIGNED_HYPER:
238 f =
static_cast<float>(a.get<sal_uInt64>());
240 case css::uno::TypeClass_DOUBLE:
241 f =
static_cast<float>(a.get<
double>());
243 case css::uno::TypeClass_CHAR:
246 c = *
static_cast<sal_Unicode const *
>(a.getValue());
247 f =
static_cast<float>(c);
251 throw css::lang::IllegalArgumentException();
260 switch( a.getValueType().getTypeClass() ) {
261 case css::uno::TypeClass_BOOLEAN:
262 d =
static_cast<double>(a.get<
bool>());
264 case css::uno::TypeClass_HYPER:
265 d =
static_cast<double>(a.get<sal_Int64>());
267 case css::uno::TypeClass_UNSIGNED_HYPER:
268 d =
static_cast<double>(a.get<sal_uInt64>());
270 case css::uno::TypeClass_CHAR:
273 c = *
static_cast<sal_Unicode const *
>(a.getValue());
274 d =
static_cast<double>(c);
278 throw css::lang::IllegalArgumentException();
void convertPropertyValue(target &value, const css::uno::Any &a)
Converts the value stored in an any to a concrete C++ type.
Definition: proptypehlp.hxx:35
signed char sal_Int8
Definition: types.h:43
sal_uInt16 sal_Unicode
Definition: types.h:123
unsigned char sal_Bool
Definition: types.h:38
Definition: Enterable.hxx:30