1*647a425cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*647a425cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*647a425cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*647a425cSAndrew Rist * distributed with this work for additional information
6*647a425cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*647a425cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*647a425cSAndrew Rist * "License"); you may not use this file except in compliance
9*647a425cSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*647a425cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*647a425cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*647a425cSAndrew Rist * software distributed under the License is distributed on an
15*647a425cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*647a425cSAndrew Rist * KIND, either express or implied. See the License for the
17*647a425cSAndrew Rist * specific language governing permissions and limitations
18*647a425cSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*647a425cSAndrew Rist *************************************************************/
21*647a425cSAndrew Rist
22*647a425cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_stoc.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <sal/main.h>
28cdf0e10cSrcweir #include <osl/diagnose.h>
29cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
30cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
33cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
34cdf0e10cSrcweir #include <com/sun/star/script/XTypeConverter.hpp>
35cdf0e10cSrcweir #include <com/sun/star/reflection/FieldAccessMode.hpp>
36cdf0e10cSrcweir #include <com/sun/star/registry/XImplementationRegistration.hpp>
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <float.h>
39cdf0e10cSrcweir #include <stdio.h>
40cdf0e10cSrcweir
41cdf0e10cSrcweir
42cdf0e10cSrcweir using namespace rtl;
43cdf0e10cSrcweir using namespace cppu;
44cdf0e10cSrcweir using namespace osl;
45cdf0e10cSrcweir using namespace com::sun::star::uno;
46cdf0e10cSrcweir using namespace com::sun::star::lang;
47cdf0e10cSrcweir using namespace com::sun::star::script;
48cdf0e10cSrcweir using namespace com::sun::star::reflection;
49cdf0e10cSrcweir using namespace com::sun::star::registry;
50cdf0e10cSrcweir
51cdf0e10cSrcweir const double MIN_DOUBLE = -DBL_MAX;
52cdf0e10cSrcweir const double MAX_DOUBLE = DBL_MAX;
53cdf0e10cSrcweir const double MIN_FLOAT = -FLT_MAX;
54cdf0e10cSrcweir const double MAX_FLOAT = FLT_MAX;
55cdf0e10cSrcweir
56cdf0e10cSrcweir //==================================================================================================
printValue(const Any & rVal)57cdf0e10cSrcweir static void printValue( const Any & rVal )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir // print value
60cdf0e10cSrcweir OString aStr( OUStringToOString( rVal.getValueType().getTypeName(), RTL_TEXTENCODING_ISO_8859_1 ) );
61cdf0e10cSrcweir printf( "(%s)", aStr.getStr() );
62cdf0e10cSrcweir
63cdf0e10cSrcweir switch (rVal.getValueTypeClass())
64cdf0e10cSrcweir {
65cdf0e10cSrcweir case TypeClass_VOID:
66cdf0e10cSrcweir printf( "void" );
67cdf0e10cSrcweir break;
68cdf0e10cSrcweir case TypeClass_ANY:
69cdf0e10cSrcweir if (rVal.hasValue())
70cdf0e10cSrcweir printValue( *(Any *)rVal.getValue() );
71cdf0e10cSrcweir break;
72cdf0e10cSrcweir case TypeClass_BOOLEAN:
73cdf0e10cSrcweir printf( "%s", (*(sal_Bool *)rVal.getValue() ? "true" : "false") );
74cdf0e10cSrcweir break;
75cdf0e10cSrcweir case TypeClass_CHAR:
76cdf0e10cSrcweir {
77cdf0e10cSrcweir char ar[2];
78cdf0e10cSrcweir ar[0] = (char)*(sal_Unicode *)rVal.getValue();
79cdf0e10cSrcweir ar[1] = 0;
80cdf0e10cSrcweir printf( ar );
81cdf0e10cSrcweir break;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir case TypeClass_BYTE:
84cdf0e10cSrcweir printf( "%x", (int)*(sal_Int8 *)rVal.getValue() );
85cdf0e10cSrcweir break;
86cdf0e10cSrcweir case TypeClass_SHORT:
87cdf0e10cSrcweir printf( "%x", *(sal_Int16 *)rVal.getValue() );
88cdf0e10cSrcweir break;
89cdf0e10cSrcweir case TypeClass_UNSIGNED_SHORT:
90cdf0e10cSrcweir printf( "%x", *(sal_uInt16 *)rVal.getValue() );
91cdf0e10cSrcweir break;
92cdf0e10cSrcweir case TypeClass_LONG:
93cdf0e10cSrcweir printf( "%lx", static_cast<long>(*(sal_Int32 *)rVal.getValue()) );
94cdf0e10cSrcweir break;
95cdf0e10cSrcweir case TypeClass_UNSIGNED_LONG:
96cdf0e10cSrcweir printf( "%lx", static_cast<unsigned long>(*(sal_uInt32 *)rVal.getValue()) );
97cdf0e10cSrcweir break;
98cdf0e10cSrcweir case TypeClass_HYPER:
99cdf0e10cSrcweir printf( "%lx", (long)*(sal_Int64 *)rVal.getValue() );
100cdf0e10cSrcweir break;
101cdf0e10cSrcweir case TypeClass_UNSIGNED_HYPER:
102cdf0e10cSrcweir printf( "%lx", (unsigned long)*(sal_uInt64 *)rVal.getValue() );
103cdf0e10cSrcweir break;
104cdf0e10cSrcweir case TypeClass_FLOAT:
105cdf0e10cSrcweir printf( "%f", *(float *)rVal.getValue() );
106cdf0e10cSrcweir break;
107cdf0e10cSrcweir case TypeClass_DOUBLE:
108cdf0e10cSrcweir printf( "%g", *(double *)rVal.getValue() );
109cdf0e10cSrcweir break;
110cdf0e10cSrcweir case TypeClass_STRING:
111cdf0e10cSrcweir {
112cdf0e10cSrcweir OString aStr2( OUStringToOString( *(OUString *)rVal.getValue(), RTL_TEXTENCODING_ISO_8859_1 ) );
113cdf0e10cSrcweir printf( aStr2.getStr() );
114cdf0e10cSrcweir break;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir case TypeClass_ENUM:
117cdf0e10cSrcweir {
118cdf0e10cSrcweir typelib_EnumTypeDescription * pEnumTD = 0;
119cdf0e10cSrcweir TYPELIB_DANGER_GET( (typelib_TypeDescription **)&pEnumTD, rVal.getValueTypeRef() );
120cdf0e10cSrcweir
121cdf0e10cSrcweir for ( sal_Int32 nPos = pEnumTD->nEnumValues; nPos--; )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir if (pEnumTD->pEnumValues[nPos] == *(int *)rVal.getValue())
124cdf0e10cSrcweir {
125cdf0e10cSrcweir printf( OUStringToOString(pEnumTD->ppEnumNames[nPos]->buffer, RTL_TEXTENCODING_ASCII_US).getStr() );
126cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pEnumTD );
127cdf0e10cSrcweir return;
128cdf0e10cSrcweir }
129cdf0e10cSrcweir }
130cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pEnumTD );
131cdf0e10cSrcweir printf( ">ENUM not found!<" );
132cdf0e10cSrcweir break;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir case TypeClass_SEQUENCE:
135cdf0e10cSrcweir {
136cdf0e10cSrcweir uno_Sequence * pSeq = *(uno_Sequence **)rVal.getValue();
137cdf0e10cSrcweir typelib_TypeDescription * pSeqTD = 0;
138cdf0e10cSrcweir TYPELIB_DANGER_GET( &pSeqTD, rVal.getValueTypeRef() );
139cdf0e10cSrcweir typelib_TypeDescription * pElemTD = 0;
140cdf0e10cSrcweir TYPELIB_DANGER_GET( &pElemTD, ((typelib_IndirectTypeDescription *)pSeqTD)->pType );
141cdf0e10cSrcweir
142cdf0e10cSrcweir sal_Int32 nLen = pSeq->nElements;
143cdf0e10cSrcweir if (nLen)
144cdf0e10cSrcweir {
145cdf0e10cSrcweir printf( "{ " );
146cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < nLen; ++nPos )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir printValue( Any( ((char *)pSeq->elements) + (nPos * pElemTD->nSize), pElemTD ) );
149cdf0e10cSrcweir if (nPos < (nLen-1))
150cdf0e10cSrcweir printf( ", " );
151cdf0e10cSrcweir }
152cdf0e10cSrcweir printf( " }" );
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
155cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pElemTD );
156cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pSeqTD );
157cdf0e10cSrcweir break;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
160cdf0e10cSrcweir default:
161cdf0e10cSrcweir printf( ">not printable<" );
162cdf0e10cSrcweir break;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir }
165cdf0e10cSrcweir
166cdf0e10cSrcweir static Reference< XTypeConverter > s_xConverter;
167cdf0e10cSrcweir
168cdf0e10cSrcweir //==================================================================================================
convertTo(const Type & rDestType,const Any & rVal,sal_Bool bExpectSuccess)169cdf0e10cSrcweir static sal_Bool convertTo( const Type & rDestType, const Any & rVal, sal_Bool bExpectSuccess )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir sal_Bool bCanConvert = sal_False;
172cdf0e10cSrcweir Any aRet;
173cdf0e10cSrcweir
174cdf0e10cSrcweir OString aExcMsg;
175cdf0e10cSrcweir
176cdf0e10cSrcweir try
177cdf0e10cSrcweir {
178cdf0e10cSrcweir aRet = s_xConverter->convertTo( rVal, rDestType );
179cdf0e10cSrcweir bCanConvert = sal_True;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir catch (Exception & rExc)
182cdf0e10cSrcweir {
183cdf0e10cSrcweir aExcMsg = OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US );
184cdf0e10cSrcweir }
185cdf0e10cSrcweir
186cdf0e10cSrcweir if (bExpectSuccess && !bCanConvert)
187cdf0e10cSrcweir {
188cdf0e10cSrcweir printf( "# conversion of " );
189cdf0e10cSrcweir printValue( rVal );
190cdf0e10cSrcweir printf( " to " );
191cdf0e10cSrcweir printf( OUStringToOString(rDestType.getTypeName(), RTL_TEXTENCODING_ASCII_US).getStr() );
192cdf0e10cSrcweir printf( " failed, but success was expected! [" );
193cdf0e10cSrcweir printf( aExcMsg.getStr() );
194cdf0e10cSrcweir printf( "]\n" );
195cdf0e10cSrcweir aRet = s_xConverter->convertTo( rVal, rDestType );
196cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
197cdf0e10cSrcweir // for debugging, to trace again
198cdf0e10cSrcweir try
199cdf0e10cSrcweir {
200cdf0e10cSrcweir aRet = s_xConverter->convertTo( rVal, rDestType );
201cdf0e10cSrcweir }
202cdf0e10cSrcweir catch (Exception &)
203cdf0e10cSrcweir {
204cdf0e10cSrcweir }
205cdf0e10cSrcweir #endif
206cdf0e10cSrcweir return sal_False;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir if (!bExpectSuccess && bCanConvert)
209cdf0e10cSrcweir {
210cdf0e10cSrcweir printf( "# conversion of " );
211cdf0e10cSrcweir printValue( rVal );
212cdf0e10cSrcweir printf( " to " );
213cdf0e10cSrcweir printValue( aRet );
214cdf0e10cSrcweir printf( " was successful, but was not expected to be!\n" );
215cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
216cdf0e10cSrcweir // for debugging, to trace again
217cdf0e10cSrcweir aRet = s_xConverter->convertTo( rVal, rDestType );
218cdf0e10cSrcweir #endif
219cdf0e10cSrcweir return sal_False;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
222cdf0e10cSrcweir #ifdef __RECONVERSION_OUTPUT__
223cdf0e10cSrcweir //= re-conversion output =
224cdf0e10cSrcweir if (bCanConvert)
225cdf0e10cSrcweir {
226cdf0e10cSrcweir // re convert to original type
227cdf0e10cSrcweir sal_Bool bReConvert = sal_False;
228cdf0e10cSrcweir Any aRet2;
229cdf0e10cSrcweir
230cdf0e10cSrcweir try
231cdf0e10cSrcweir {
232cdf0e10cSrcweir aRet2 = s_xConverter->convertTo( aRet, rVal.getValueType() );
233cdf0e10cSrcweir bReConvert = sal_True;
234cdf0e10cSrcweir }
235cdf0e10cSrcweir catch (Exception & rExc)
236cdf0e10cSrcweir {
237cdf0e10cSrcweir aExcMsg = OUStringToOString( rExc.Message, RTL_TEXTENCODING_ISO_8859_1 );
238cdf0e10cSrcweir }
239cdf0e10cSrcweir
240cdf0e10cSrcweir if (bReConvert)
241cdf0e10cSrcweir {
242cdf0e10cSrcweir if (rVal != aRet2)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir printf( "# re-conversion of " );
245cdf0e10cSrcweir printValue( rVal );
246cdf0e10cSrcweir printf( " to " );
247cdf0e10cSrcweir printValue( aRet );
248cdf0e10cSrcweir printf( " to " );
249cdf0e10cSrcweir printValue( aRet2 );
250cdf0e10cSrcweir printf( ": first and last do not match!\n" );
251cdf0e10cSrcweir }
252cdf0e10cSrcweir }
253cdf0e10cSrcweir else
254cdf0e10cSrcweir {
255cdf0e10cSrcweir printf( "# re-conversion of " );
256cdf0e10cSrcweir printValue( aRet );
257cdf0e10cSrcweir printf( " to " );
258cdf0e10cSrcweir printf( rVal.getValueType().getTypeName().getStr() );
259cdf0e10cSrcweir printf( " failed! [" );
260cdf0e10cSrcweir printf( aExcMsg.getStr() );
261cdf0e10cSrcweir printf( "]\n" );
262cdf0e10cSrcweir }
263cdf0e10cSrcweir }
264cdf0e10cSrcweir #endif
265cdf0e10cSrcweir
266cdf0e10cSrcweir return sal_True;
267cdf0e10cSrcweir }
268cdf0e10cSrcweir
269cdf0e10cSrcweir
270cdf0e10cSrcweir //==================================================================================================
271cdf0e10cSrcweir typedef struct _ConvBlock
272cdf0e10cSrcweir {
273cdf0e10cSrcweir Any _value;
274cdf0e10cSrcweir sal_Bool _toString, _toDouble, _toFloat;
275cdf0e10cSrcweir sal_Bool _toUINT32, _toINT32, _toUINT16, _toINT16, _toBYTE, _toBOOL, _toChar;
276cdf0e10cSrcweir sal_Bool _toTypeClass, _toSeqINT16, _toSeqAny;
277cdf0e10cSrcweir
_ConvBlock_ConvBlock278cdf0e10cSrcweir _ConvBlock()
279cdf0e10cSrcweir {
280cdf0e10cSrcweir }
_ConvBlock_ConvBlock281cdf0e10cSrcweir _ConvBlock( const Any & rValue_,
282cdf0e10cSrcweir sal_Bool toString_, sal_Bool toDouble_, sal_Bool toFloat_,
283cdf0e10cSrcweir sal_Bool toUINT32_, sal_Bool toINT32_, sal_Bool toUINT16_, sal_Bool toINT16_,
284cdf0e10cSrcweir sal_Bool toBYTE_, sal_Bool toBOOL_, sal_Bool toChar_,
285cdf0e10cSrcweir sal_Bool toTypeClass_, sal_Bool toSeqINT16_, sal_Bool toSeqAny_ )
286cdf0e10cSrcweir : _value( rValue_ )
287cdf0e10cSrcweir , _toString( toString_ ), _toDouble( toDouble_ ), _toFloat( toFloat_ )
288cdf0e10cSrcweir , _toUINT32( toUINT32_ ), _toINT32( toINT32_ ), _toUINT16( toUINT16_ ), _toINT16( toINT16_ )
289cdf0e10cSrcweir , _toBYTE( toBYTE_ ), _toBOOL( toBOOL_ ), _toChar( toChar_ )
290cdf0e10cSrcweir , _toTypeClass( toTypeClass_ ), _toSeqINT16( toSeqINT16_ ), _toSeqAny( toSeqAny_ )
291cdf0e10cSrcweir {
292cdf0e10cSrcweir }
293cdf0e10cSrcweir } ConvBlock;
294cdf0e10cSrcweir
295cdf0e10cSrcweir
296cdf0e10cSrcweir //==================================================================================================
initBlocks(ConvBlock * pTestBlocks)297cdf0e10cSrcweir static sal_Int32 initBlocks( ConvBlock * pTestBlocks )
298cdf0e10cSrcweir {
299cdf0e10cSrcweir Any aVal;
300cdf0e10cSrcweir
301cdf0e10cSrcweir sal_uInt32 nElems = 0;
302cdf0e10cSrcweir
303cdf0e10cSrcweir // ==BYTE==
304cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "0xff" );
305cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
306cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "255" );
307cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
308cdf0e10cSrcweir aVal <<= (sal_Int8)0xffu;
309cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
310cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
311cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "0x80" );
312cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
313cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "128" );
314cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
315cdf0e10cSrcweir aVal <<= (sal_Int8)( 0x80u );
316cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
317cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
318cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "0x7f" );
319cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
320cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "127" );
321cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
322cdf0e10cSrcweir aVal <<= (sal_Int8)( 0x7f );
323cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
324cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
325cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "5" );
326cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0 );
327cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "+5" );
328cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
329cdf0e10cSrcweir aVal <<= (sal_Int8)( 5 );
330cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
331cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
332cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "-5" );
333cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0 );
334cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
335cdf0e10cSrcweir aVal <<= (sal_Int8)( -5 );
336cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
337cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
338cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "256" );
339cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
340cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
341cdf0e10cSrcweir // ==UINT16==
342cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "65535" );
343cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 );
344cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "0xffff" );
345cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 );
346cdf0e10cSrcweir aVal <<= (sal_uInt16)( 0xffff );
347cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 );
348cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
349cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "32768" );
350cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 );
351cdf0e10cSrcweir aVal <<= (sal_uInt16)( 0x8000 );
352cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 );
353cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
354cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "32767" );
355cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
356cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "0x7fff" );
357cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
358cdf0e10cSrcweir aVal <<= (sal_uInt16)( 0x7fff );
359cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 );
360cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
361cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "256" );
362cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
363cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "0x100" );
364cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 );
365cdf0e10cSrcweir aVal <<= (sal_uInt16)( 0x100 );
366cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 );
367cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
368cdf0e10cSrcweir aVal <<= (sal_uInt16)( 5 );
369cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
370cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
371cdf0e10cSrcweir aVal <<= (sal_uInt16)( -5 ); // is 0xfffb
372cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 );
373cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
374cdf0e10cSrcweir // ==INT16==
375cdf0e10cSrcweir aVal <<= (sal_Int16)( -1 );
376cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
377cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
378cdf0e10cSrcweir aVal <<= (sal_Int16)( -0x8000 );
379cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0 );
380cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
381cdf0e10cSrcweir aVal <<= (sal_Int16)( 0x7fff );
382cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 );
383cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
384cdf0e10cSrcweir aVal <<= (sal_Int16)( 0x100 );
385cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0 );
386cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
387cdf0e10cSrcweir aVal <<= (sal_Int16)( 5 );
388cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
389cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
390cdf0e10cSrcweir aVal <<= (sal_Int16)( -5 );
391cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
392cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
393cdf0e10cSrcweir // ==UINT32==
394cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "+4294967295" );
395cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
396cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "4294967295" );
397cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
398cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "0xffffffff" );
399cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
400cdf0e10cSrcweir aVal <<= (sal_uInt32)( 0xffffffff );
401cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
402cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
403cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "-2147483648" );
404cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
405cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "-0x80000000" );
406cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
407cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
408cdf0e10cSrcweir aVal <<= (sal_uInt32)( 0x80000000 );
409cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
410cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
411cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "2147483647" );
412cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
413cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "0x7fffffff" );
414cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
415cdf0e10cSrcweir aVal <<= (sal_uInt32)( 0x7fffffff );
416cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
417cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
418cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "65536" );
419cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
420cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "0x10000" );
421cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 );
422cdf0e10cSrcweir aVal <<= (sal_uInt32)( 0x10000 );
423cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
424cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
425cdf0e10cSrcweir aVal <<= (sal_uInt32)( 0x8000 );
426cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 );
427cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
428cdf0e10cSrcweir aVal <<= (sal_uInt32)( 5 );
429cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
430cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
431cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "0xfffffffb" );
432cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
433cdf0e10cSrcweir aVal <<= (sal_uInt32)( -5 ); // is 0xfffffffb
434cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
435cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
436cdf0e10cSrcweir // ==INT32==
437cdf0e10cSrcweir aVal <<= (sal_Int32)( 0xffffffff ); // is -1
438cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
439cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
440cdf0e10cSrcweir aVal <<= (sal_Int32)( 0x80000000 );
441cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
442cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
443cdf0e10cSrcweir aVal <<= (sal_Int32)( 0x7fffffff );
444cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
445cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
446cdf0e10cSrcweir aVal <<= (sal_Int32)( 0x10000 );
447cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
448cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
449cdf0e10cSrcweir aVal <<= (sal_Int32)( -0x8001 );
450cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
451cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
452cdf0e10cSrcweir aVal <<= (sal_Int32)( 5 );
453cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
454cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
455cdf0e10cSrcweir aVal <<= (sal_Int32)( -5 );
456cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0 );
457cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
458cdf0e10cSrcweir // ==FLOAT==
459cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "-3.4e+38" );
460cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
461cdf0e10cSrcweir aVal <<= (float)( MIN_FLOAT );
462cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
463cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
464cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "+3.4e+38" );
465cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
466cdf0e10cSrcweir aVal <<= (float)( MAX_FLOAT );
467cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
468cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
469cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "9e-20" );
470cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
471cdf0e10cSrcweir aVal <<= (float)( 9e-20 );
472cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
473cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
474cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "+.7071067811865" );
475cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
476cdf0e10cSrcweir aVal <<= (float)( .7071067811865 );
477cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
478cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
479cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "3.14159265359" );
480cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
481cdf0e10cSrcweir aVal <<= (float)( 3.14159265359 );
482cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
483cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
484cdf0e10cSrcweir aVal <<= (float)( 5 );
485cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
486cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
487cdf0e10cSrcweir // ==DOUBLE==
488cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "-1.7976931348623155e+308" );
489cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
490cdf0e10cSrcweir aVal <<= (double)( MIN_DOUBLE );
491cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
492cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
493cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "1.7976931348623155e+308" );
494cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
495cdf0e10cSrcweir aVal <<= (double)( MAX_DOUBLE );
496cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
497cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
498cdf0e10cSrcweir aVal <<= (double)( MIN_FLOAT );
499cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
500cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
501cdf0e10cSrcweir aVal <<= (double)( MAX_FLOAT );
502cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
503cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
504cdf0e10cSrcweir aVal <<= (double)( -((double)0x80000000) );
505cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
506cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
507cdf0e10cSrcweir aVal <<= (double)( -((double)0x80000001) );
508cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
509cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
510cdf0e10cSrcweir aVal <<= (double)( 0x7fffffff );
511cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 );
512cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
513cdf0e10cSrcweir aVal <<= (double)( 0x80000000 );
514cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
515cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
516cdf0e10cSrcweir aVal <<= (double)( 0xffffffff );
517cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
518cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
519cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "0x100000000" );
520cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
521cdf0e10cSrcweir #ifndef OS2
522cdf0e10cSrcweir aVal <<= (double)( SAL_CONST_INT64(0x100000000) );
523cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
524cdf0e10cSrcweir #endif
525cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
526cdf0e10cSrcweir aVal <<= (double)( 5 );
527cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 );
528cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
529cdf0e10cSrcweir // ==CHAR==
530cdf0e10cSrcweir sal_Unicode c = 'A';
531cdf0e10cSrcweir aVal.setValue( &c, ::getCharCppuType() );
532cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
533cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
534cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "A" );
535cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 );
536cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
537cdf0e10cSrcweir // ==BOOL==
538cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "0" );
539cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
540cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
541cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "1" );
542cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
543cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
544cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "False" );
545cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
546cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
547cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "true" );
548cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 );
549cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
550cdf0e10cSrcweir
551cdf0e10cSrcweir sal_Bool bTmp = sal_True;
552cdf0e10cSrcweir aVal.setValue( &bTmp, getBooleanCppuType() );
553cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 );
554cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
555cdf0e10cSrcweir // ==ZERO STRINGS==
556cdf0e10cSrcweir aVal <<= OUString();
557cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
558cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
559cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "-" );
560cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0 );
561cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
562cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "-0" );
563cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
564cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
565cdf0e10cSrcweir // ==TYPECLASS ENUM==
566cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "eNuM" );
567cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 );
568cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
569cdf0e10cSrcweir aVal <<= OUString::createFromAscii( "DOUBLE" );
570cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 );
571cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
572cdf0e10cSrcweir int e = 1;
573cdf0e10cSrcweir aVal.setValue( &e, ::getCppuType( (const TypeClass *)0 ) );
574cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0 );
575cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
576cdf0e10cSrcweir aVal.setValue( &e, ::getCppuType( (const FieldAccessMode *)0 ) );
577cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 );
578cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
579cdf0e10cSrcweir // ==SEQ of INT==
580cdf0e10cSrcweir Sequence< sal_Int32 > aINT32Seq( 3 ), aINT32Seq2( 3 );
581cdf0e10cSrcweir sal_Int32 * pINT32Seq = aINT32Seq.getArray();
582cdf0e10cSrcweir pINT32Seq[0] = -32768;
583cdf0e10cSrcweir pINT32Seq[1] = 0;
584cdf0e10cSrcweir pINT32Seq[2] = 32767;
585cdf0e10cSrcweir aVal <<= aINT32Seq;
586cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 );
587cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
588cdf0e10cSrcweir pINT32Seq = aINT32Seq2.getArray();
589cdf0e10cSrcweir pINT32Seq[0] = -32768;
590cdf0e10cSrcweir pINT32Seq[1] = -32769;
591cdf0e10cSrcweir pINT32Seq[2] = 32767;
592cdf0e10cSrcweir aVal <<= aINT32Seq2;
593cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 );
594cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
595cdf0e10cSrcweir // ==SEQ of ANY==
596cdf0e10cSrcweir Sequence< Any > aAnySeq( 2 ), aAnySeq2( 2 ), aAnySeq3( 2 );
597cdf0e10cSrcweir Any * pAnySeq = aAnySeq.getArray();
598cdf0e10cSrcweir pAnySeq[0] = makeAny( aINT32Seq );
599cdf0e10cSrcweir pAnySeq[1] = makeAny( OUString::createFromAscii("lala") );
600cdf0e10cSrcweir aVal <<= aAnySeq;
601cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 );
602cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
603cdf0e10cSrcweir pAnySeq = aAnySeq2.getArray();
604cdf0e10cSrcweir pAnySeq[0] <<= (sal_Int32)4711;
605cdf0e10cSrcweir pAnySeq[1] <<= OUString::createFromAscii("0815");
606cdf0e10cSrcweir aVal <<= aAnySeq2;
607cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 );
608cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
609cdf0e10cSrcweir pAnySeq = aAnySeq3.getArray();
610cdf0e10cSrcweir pAnySeq[0] <<= OUString::createFromAscii("TypeClass_UNION");
611cdf0e10cSrcweir pAnySeq[1] <<= OUString::createFromAscii("TypeClass_ENUM");
612cdf0e10cSrcweir aVal <<= aAnySeq3;
613cdf0e10cSrcweir pTestBlocks[nElems++] = ConvBlock( aVal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 );
614cdf0e10cSrcweir // st,do,fl,u3,i3,u1,i1,by,bo,ch,tc,si,sa
615cdf0e10cSrcweir return nElems;
616cdf0e10cSrcweir }
617cdf0e10cSrcweir
618cdf0e10cSrcweir //==================================================================================================
test_Conversion(const Reference<XMultiServiceFactory> & xMgr)619cdf0e10cSrcweir static void test_Conversion( const Reference< XMultiServiceFactory > & xMgr )
620cdf0e10cSrcweir {
621cdf0e10cSrcweir printf( "test_Conversion(): start...\n" );
622cdf0e10cSrcweir
623cdf0e10cSrcweir Reference< XTypeConverter > xConverter( xMgr->createInstance(
624cdf0e10cSrcweir OUString::createFromAscii( "com.sun.star.script.Converter" ) ), UNO_QUERY );
625cdf0e10cSrcweir
626cdf0e10cSrcweir ConvBlock * pTestBlocks = new ConvBlock[256];
627cdf0e10cSrcweir sal_Int32 nPos = initBlocks( pTestBlocks );
628cdf0e10cSrcweir
629cdf0e10cSrcweir s_xConverter = xConverter;
630cdf0e10cSrcweir while (nPos--)
631cdf0e10cSrcweir {
632cdf0e10cSrcweir const ConvBlock& rBlock = pTestBlocks[nPos];
633cdf0e10cSrcweir const Any & rVal = rBlock._value;
634cdf0e10cSrcweir
635cdf0e10cSrcweir convertTo( ::getCppuType( (const OUString *)0 ), rVal, rBlock._toString );
636cdf0e10cSrcweir convertTo( ::getCppuType( (const float *)0 ), rVal, rBlock._toFloat );
637cdf0e10cSrcweir convertTo( ::getCppuType( (const double *)0 ), rVal, rBlock._toDouble );
638cdf0e10cSrcweir convertTo( ::getCppuType( (const sal_uInt32 *)0 ), rVal, rBlock._toUINT32 );
639cdf0e10cSrcweir convertTo( ::getCppuType( (const sal_Int32 *)0 ), rVal, rBlock._toINT32 );
640cdf0e10cSrcweir convertTo( ::getCppuType( (const sal_uInt16 *)0 ), rVal, rBlock._toUINT16 );
641cdf0e10cSrcweir convertTo( ::getCppuType( (const sal_Int16 *)0 ), rVal, rBlock._toINT16 );
642cdf0e10cSrcweir convertTo( ::getCppuType( (const sal_Int8 *)0 ), rVal, rBlock._toBYTE );
643cdf0e10cSrcweir convertTo( ::getBooleanCppuType(), rVal, rBlock._toBOOL );
644cdf0e10cSrcweir convertTo( ::getCharCppuType(), rVal, rBlock._toChar );
645cdf0e10cSrcweir convertTo( ::getCppuType( (const TypeClass *)0 ), rVal, rBlock._toTypeClass );
646cdf0e10cSrcweir convertTo( ::getCppuType( (const Sequence< sal_Int16 > *)0 ), rVal, rBlock._toSeqINT16 );
647cdf0e10cSrcweir convertTo( ::getCppuType( (const Sequence< Any > *)0 ), rVal, rBlock._toSeqAny );
648cdf0e10cSrcweir
649cdf0e10cSrcweir convertTo( ::getVoidCppuType(), rVal, sal_True ); // anything converts to void
650cdf0e10cSrcweir }
651cdf0e10cSrcweir s_xConverter.clear();
652cdf0e10cSrcweir
653cdf0e10cSrcweir delete [] pTestBlocks;
654cdf0e10cSrcweir
655cdf0e10cSrcweir Any aRet;
656cdf0e10cSrcweir aRet = xConverter->convertTo( Any( &xMgr, ::getCppuType( (const Reference< XMultiServiceFactory > *)0 ) ),
657cdf0e10cSrcweir ::getCppuType( (const Reference< XServiceInfo > *)0 ) );
658cdf0e10cSrcweir aRet = xConverter->convertTo( aRet, ::getCppuType( (const Reference< XMultiServiceFactory > *)0 ) );
659cdf0e10cSrcweir aRet = xConverter->convertTo( aRet, ::getCppuType( (const Reference< XServiceInfo > *)0 ) );
660cdf0e10cSrcweir aRet <<= SAL_CONST_INT64(0x7fffffffffffffff);
661cdf0e10cSrcweir aRet = xConverter->convertTo( aRet, ::getCppuType( (const sal_uInt64 *)0 ) );
662cdf0e10cSrcweir OSL_ASSERT( *(const sal_uInt64 *)aRet.getValue() == SAL_CONST_UINT64(0x7fffffffffffffff) );
663cdf0e10cSrcweir aRet <<= SAL_CONST_UINT64(0xffffffffffffffff);
664cdf0e10cSrcweir aRet = xConverter->convertTo( aRet, ::getCppuType( (const sal_uInt64 *)0 ) );
665cdf0e10cSrcweir OSL_ASSERT( *(const sal_uInt64 *)aRet.getValue() == SAL_CONST_UINT64(0xffffffffffffffff) );
666cdf0e10cSrcweir aRet <<= SAL_CONST_INT64(-1);
667cdf0e10cSrcweir aRet = xConverter->convertTo( aRet, ::getCppuType( (const sal_Int8 *)0 ) );
668cdf0e10cSrcweir OSL_ASSERT( *(const sal_Int8 *)aRet.getValue() == (-1) );
669cdf0e10cSrcweir printf( "test_Conversion(): end.\n" );
670cdf0e10cSrcweir }
671cdf0e10cSrcweir
SAL_IMPLEMENT_MAIN()672cdf0e10cSrcweir SAL_IMPLEMENT_MAIN()
673cdf0e10cSrcweir {
674cdf0e10cSrcweir Reference< XMultiServiceFactory > xMgr( createRegistryServiceFactory( OUString::createFromAscii("stoctest.rdb") ) );
675cdf0e10cSrcweir
676cdf0e10cSrcweir try
677cdf0e10cSrcweir {
678cdf0e10cSrcweir Reference< XImplementationRegistration > xImplReg(
679cdf0e10cSrcweir xMgr->createInstance( OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration") ), UNO_QUERY );
680cdf0e10cSrcweir OSL_ENSURE( xImplReg.is(), "### no impl reg!" );
681cdf0e10cSrcweir
682cdf0e10cSrcweir OUString aLibName(
683cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("stocservices.uno" SAL_DLLEXTENSION) );
684cdf0e10cSrcweir xImplReg->registerImplementation(
685cdf0e10cSrcweir OUString::createFromAscii("com.sun.star.loader.SharedLibrary"),
686cdf0e10cSrcweir aLibName, Reference< XSimpleRegistry >() );
687cdf0e10cSrcweir
688cdf0e10cSrcweir test_Conversion( xMgr );
689cdf0e10cSrcweir }
690cdf0e10cSrcweir catch (Exception & rExc)
691cdf0e10cSrcweir {
692cdf0e10cSrcweir OSL_ENSURE( sal_False, "### exception occured!" );
693cdf0e10cSrcweir OString aMsg( OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) );
694cdf0e10cSrcweir OSL_TRACE( "### exception occured: " );
695cdf0e10cSrcweir OSL_TRACE( aMsg.getStr() );
696cdf0e10cSrcweir OSL_TRACE( "\n" );
697cdf0e10cSrcweir }
698cdf0e10cSrcweir
699cdf0e10cSrcweir Reference< XComponent >( xMgr, UNO_QUERY )->dispose();
700cdf0e10cSrcweir return 0;
701cdf0e10cSrcweir }
702