Update ooo320-m1
[ooovba.git] / extensions / test / ole / cpnt / cpnt.cxx
blob2028823274bcab6084c1afc4e015861fba58725d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cpnt.cxx,v $
10 * $Revision: 1.17 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
33 #include <windows.h>
34 #include <atlbase.h>
35 #include <stdio.h>
36 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37 #include <com/sun/star/registry/XRegistryKey.hpp>
38 #include <osl/diagnose.h>
39 #include <uno/environment.h>
40 #include <cppuhelper/factory.hxx>
41 // OPTIONAL is a constant in com.sun.star.beans.PropertyAttributes but it must be
42 // undef'd in some header files
43 #define OPTIONAL OPTIONAL
44 #include <com/sun/star/beans/PropertyAttribute.hpp>
45 #include <com/sun/star/script/XInvocation.hpp>
46 #include <com/sun/star/reflection/XIdlReflection.hpp>
47 #include <com/sun/star/lang/XEventListener.hpp>
49 #include <cppuhelper/implbase7.hxx>
50 #include <cppuhelper/implbase1.hxx>
51 #include <com/sun/star/uno/Reference.h>
52 #include <rtl/ustring.h>
53 #include <com/sun/star/uno/Reference.hxx>
54 #include <oletest/XTestSequence.hpp>
55 #include <oletest/XTestStruct.hpp>
56 #include <oletest/XTestOther.hpp>
57 #include <oletest/XTestInterfaces.hpp>
58 #include <oletest/XSimple.hpp>
59 #include <oletest/XSimple2.hpp>
60 #include <oletest/XSimple3.hpp>
61 #include <oletest/XTestInParameters.hpp>
62 //#include <oletest/XTestOutParameters.hpp>
63 #include <oletest/XIdentity.hpp>
64 #include <com/sun/star/beans/Property.hpp>
65 using namespace cppu;
66 using namespace osl;
67 using namespace oletest;
68 using namespace rtl;
69 using namespace com::sun::star::uno;
70 using namespace com::sun::star::lang;
71 using namespace com::sun::star::beans;
72 using namespace com::sun::star::registry;
73 using namespace com::sun::star::script;
74 using namespace com::sun::star::reflection;
77 #define IMPL_NAME L"oletest.OleTestImpl" // oletest.OleTestImpl in applicat.rdb
78 #define SERVICE_NAME L"oletest.OleTest"
79 #define KEY1 L"/oletest.OleTestImpl/UNO/SERVICES"
80 #define KEY2 L"oletest.OleTest"
82 class OComponent : public WeakImplHelper7<
83 XTestSequence, XTestStruct, XTestOther, XTestInterfaces,
84 XSimple, XTestInParameters, XIdentity >
86 Reference<XInterface> m_xIntIdentity;
87 sal_Int32 m_arrayConstructor;
88 Reference<XMultiServiceFactory> m_rFactory;
90 Sequence<sal_Int8> m_seqByte;
91 Sequence<float> m_seqFloat;
92 Sequence<double> m_seqDouble;
93 Sequence<sal_Bool> m_seqBool;
94 Sequence<sal_Int16> m_seqShort;
95 Sequence<sal_uInt16> m_seqUShort;
96 Sequence<sal_Int32> m_seqLong;
97 Sequence<sal_uInt32> m_seqULong;
98 Sequence<sal_Unicode> m_seqChar;
99 Sequence<OUString> m_seqString;
100 Sequence<Any> m_seqAny;
101 Sequence<Type> m_seqType;
102 Sequence<Sequence< sal_Int32> > m_seq1;
103 Sequence<Sequence< Sequence< sal_Int32> > > m_seq2;
104 Any m_any;
105 Type m_type;
106 Sequence<Reference< XInterface > > m_seqxInterface;
108 sal_Int8 m_int8;
109 sal_uInt8 m_uint8;
110 sal_Int16 m_int16;
111 sal_uInt16 m_uint16;
112 sal_Int32 m_int32;
113 sal_uInt32 m_uint32;
114 sal_Int64 m_int64;
115 sal_uInt64 m_uint64;
116 float m_float;
117 double m_double;
118 OUString m_string;
119 sal_Unicode m_char;
120 sal_Bool m_bool;
121 Reference<XInterface> m_xinterface;
123 sal_Int8 m_attr_int8;
124 sal_uInt8 m_attr_uint8;
125 sal_Int16 m_attr_int16;
126 sal_uInt16 m_attr_uint16;
127 sal_Int32 m_attr_int32;
128 sal_uInt32 m_attr_uint32;
129 sal_Int64 m_attr_int64;
130 sal_uInt64 m_attr_uint64;
131 float m_attr_float;
132 double m_attr_double;
133 OUString m_attr_string;
134 sal_Unicode m_attr_char;
135 sal_Bool m_attr_bool;
136 Any m_attr_any;
137 Type m_attr_type;
138 Reference<XInterface> m_attr_xinterface;
139 Reference<XInvocation> m_attr_xinvocation;
141 public:
142 OComponent( const Reference<XMultiServiceFactory> & rFactory ) :
143 m_rFactory( rFactory ), m_arrayConstructor(0) {}
144 ~OComponent();
145 public: // XTestSequence
146 virtual Sequence<sal_Int8> SAL_CALL methodByte(const Sequence< sal_Int8 >& aSeq) throw( RuntimeException );
147 virtual Sequence<float> SAL_CALL methodFloat(const Sequence< float >& aSeq) throw( RuntimeException );
148 virtual Sequence< double > SAL_CALL methodDouble(const Sequence< double >& aSeq) throw( RuntimeException);
149 virtual Sequence< sal_Bool > SAL_CALL methodBool(const Sequence< sal_Bool >& aSeq) throw( RuntimeException );
150 virtual Sequence< sal_Int16 > SAL_CALL methodShort(const Sequence< sal_Int16 >& aSeq) throw( RuntimeException );
151 virtual Sequence< sal_uInt16 > SAL_CALL methodUShort(const Sequence< sal_uInt16 >& aSeq) throw( RuntimeException );
152 virtual Sequence< sal_Int32 > SAL_CALL methodLong(const Sequence< sal_Int32 >& aSeq) throw( RuntimeException) ;
153 virtual Sequence< sal_uInt32 > SAL_CALL methodULong(const Sequence< sal_uInt32 >& aSeq) throw( RuntimeException );
154 virtual Sequence< OUString > SAL_CALL methodString(const Sequence< OUString >& aSeq) throw( RuntimeException );
155 virtual Sequence< sal_Unicode > SAL_CALL methodChar(const Sequence< sal_Unicode >& aSeq) throw( RuntimeException );
156 virtual Sequence< Any > SAL_CALL methodAny(const Sequence< Any >& aSeq) throw( RuntimeException );
157 virtual Sequence< Type > SAL_CALL methodType(const Sequence< Type >& aSeq) throw( RuntimeException );
158 virtual Sequence< Reference< XInterface > > SAL_CALL methodXInterface( const Sequence< Reference< XInterface > >& aSeq ) throw(RuntimeException) ;
159 virtual Sequence< Sequence< sal_Int32 > > SAL_CALL methodSequence(const Sequence< Sequence< sal_Int32 > >& aSeq) throw( RuntimeException );
160 virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL methodSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq) throw( RuntimeException );
161 virtual Sequence< Reference<XEventListener> > SAL_CALL methodXEventListeners( const Sequence<Reference<XEventListener> >& aSeq) throw( RuntimeException);
162 virtual Sequence< Sequence<Reference<XEventListener > > > SAL_CALL methodXEventListenersMul( const Sequence<Sequence<Reference<XEventListener > > >& aSeq ) throw (RuntimeException);
164 virtual Sequence< sal_Int8 > SAL_CALL getAttrByte(void) throw( RuntimeException );
165 virtual void SAL_CALL setAttrByte(const Sequence< sal_Int8 >& AttrByte_) throw( RuntimeException );
166 virtual Sequence< float > SAL_CALL getAttrFloat(void) throw( RuntimeException) ;
167 virtual void SAL_CALL setAttrFloat(const Sequence< float >& AttrFloat_) throw( RuntimeException );
168 virtual Sequence< double > SAL_CALL getAttrDouble(void) throw( RuntimeException) ;
169 virtual void SAL_CALL setAttrDouble(const Sequence< double >& AttrDouble_) throw( RuntimeException );
170 virtual Sequence< sal_Bool > SAL_CALL getAttrBool(void) throw( RuntimeException );
171 virtual void SAL_CALL setAttrBool(const Sequence< sal_Bool >& AttrBool_) throw( RuntimeException );
172 virtual Sequence< sal_Int16 > SAL_CALL getAttrShort(void) throw( RuntimeException );
173 virtual void SAL_CALL setAttrShort(const Sequence< sal_Int16 >& AttrShort_) throw( RuntimeException );
174 virtual Sequence< sal_uInt16 > SAL_CALL getAttrUShort(void) throw( RuntimeException );
175 virtual void SAL_CALL setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_) throw( RuntimeException );
176 virtual Sequence< sal_Int32 > SAL_CALL getAttrLong(void) throw( RuntimeException );
177 virtual void SAL_CALL setAttrLong(const Sequence< sal_Int32 >& AttrLong_) throw( RuntimeException );
178 virtual Sequence< sal_uInt32 > SAL_CALL getAttrULong(void) throw( RuntimeException );
179 virtual void SAL_CALL setAttrULong(const Sequence< sal_uInt32 >& AttrULong_) throw( RuntimeException );
180 virtual Sequence< OUString > SAL_CALL getAttrString(void) throw(RuntimeException );
181 virtual void SAL_CALL setAttrString(const Sequence< OUString >& AttrString_) throw( RuntimeException );
182 virtual Sequence< sal_Unicode > SAL_CALL getAttrChar(void) throw( RuntimeException );
183 virtual void SAL_CALL setAttrChar(const Sequence< sal_Unicode >& AttrChar_) throw( RuntimeException );
184 virtual Sequence< Any > SAL_CALL getAttrAny(void) throw( RuntimeException );
185 virtual void SAL_CALL setAttrAny(const Sequence< Any >& AttrAny_) throw( RuntimeException );
186 virtual Sequence< Type > SAL_CALL getAttrType(void) throw( RuntimeException );
187 virtual void SAL_CALL setAttrType( const Sequence< Type >& _attrtype ) throw (RuntimeException);
188 virtual Sequence< Sequence< sal_Int32 > > SAL_CALL getAttrSequence(void) throw( RuntimeException );
189 virtual void SAL_CALL setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence_) throw( RuntimeException );
190 virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL getAttrSequence2(void) throw( RuntimeException );
191 virtual void SAL_CALL setAttrSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& AttrSequence2_) throw ( RuntimeException );
192 virtual Sequence< Reference< XInterface > > SAL_CALL getAttrXInterface() throw(RuntimeException);
193 virtual void SAL_CALL setAttrXInterface( const Sequence< Reference< XInterface > >& _attrxinterface ) throw(RuntimeException);
195 virtual ::sal_Int8 SAL_CALL getAByte() throw (RuntimeException);
196 virtual void SAL_CALL setAByte( ::sal_Int8 _abyte ) throw (RuntimeException);
197 virtual float SAL_CALL getAFloat() throw (RuntimeException);
198 virtual void SAL_CALL setAFloat( float _afloat ) throw (RuntimeException);
199 virtual double SAL_CALL getADouble() throw (RuntimeException);
200 virtual void SAL_CALL setADouble( double _adouble ) throw (RuntimeException);
201 virtual ::sal_Bool SAL_CALL getABool() throw (RuntimeException);
202 virtual void SAL_CALL setABool( ::sal_Bool _abool ) throw (RuntimeException);
203 virtual ::sal_Int16 SAL_CALL getAShort() throw (RuntimeException);
204 virtual void SAL_CALL setAShort( ::sal_Int16 _ashort ) throw (RuntimeException);
205 virtual ::sal_uInt16 SAL_CALL getAUShort() throw (RuntimeException);
206 virtual void SAL_CALL setAUShort( ::sal_uInt16 _aushort ) throw (RuntimeException);
207 virtual ::sal_Int32 SAL_CALL getALong() throw (RuntimeException);
208 virtual void SAL_CALL setALong( ::sal_Int32 _along ) throw (RuntimeException);
209 virtual ::sal_uInt32 SAL_CALL getAULong() throw (RuntimeException);
210 virtual void SAL_CALL setAULong( ::sal_uInt32 _aulong ) throw (RuntimeException);
211 virtual ::rtl::OUString SAL_CALL getAString() throw (RuntimeException);
212 virtual void SAL_CALL setAString( const ::rtl::OUString& _astring ) throw (RuntimeException);
213 virtual ::sal_Unicode SAL_CALL getAChar() throw (RuntimeException);
214 virtual void SAL_CALL setAChar( ::sal_Unicode _achar ) throw (RuntimeException);
215 virtual Any SAL_CALL getAAny() throw (RuntimeException);
216 virtual void SAL_CALL setAAny( const Any& _aany ) throw (RuntimeException);
217 virtual Type SAL_CALL getAType() throw (RuntimeException);
218 virtual void SAL_CALL setAType( const Type& _atype ) throw (RuntimeException);
219 virtual Reference< XInterface > SAL_CALL getAXInterface() throw (RuntimeException);
220 virtual void SAL_CALL setAXInterface( const Reference<XInterface >& _axinterface ) throw (RuntimeException);
221 virtual Reference<XInvocation > SAL_CALL getAXInvocation() throw (RuntimeException);
222 virtual void SAL_CALL setAXInvocation( const Reference< XInvocation >& _axinvocation ) throw (RuntimeException);
224 virtual void SAL_CALL testout_methodByte(sal_Int8& rOut) throw( RuntimeException );
225 virtual void SAL_CALL testout_methodFloat(float& rOut) throw( RuntimeException );
226 virtual void SAL_CALL testout_methodDouble(double& rOut) throw( RuntimeException );
227 virtual void SAL_CALL testout_methodBool(sal_Bool& rOut) throw( RuntimeException );
228 virtual void SAL_CALL testout_methodShort(sal_Int16& rOut) throw( RuntimeException );
229 virtual void SAL_CALL testout_methodUShort(sal_uInt16& rOut) throw( RuntimeException );
230 virtual void SAL_CALL testout_methodLong(sal_Int32& rOut) throw( RuntimeException );
231 virtual void SAL_CALL testout_methodULong(sal_uInt32& rOut) throw( RuntimeException );
232 virtual void SAL_CALL testout_methodHyper(sal_Int64& rOut) throw( RuntimeException );
233 virtual void SAL_CALL testout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException );
234 virtual void SAL_CALL testout_methodString(OUString& rOut) throw( RuntimeException );
235 virtual void SAL_CALL testout_methodChar(sal_Unicode& rOut) throw( RuntimeException );
236 virtual void SAL_CALL testout_methodAny(Any& rOut) throw( RuntimeException );
237 virtual void SAL_CALL testout_methodType(Type& rOut) throw( RuntimeException );
238 virtual void SAL_CALL testout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException );
239 virtual void SAL_CALL testout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException );
240 virtual void SAL_CALL testout_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException );
241 virtual void SAL_CALL testout_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException );
242 virtual void SAL_CALL testout_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException );
243 virtual void SAL_CALL testout_methodMulParams4( float in1, float& out1, sal_Int32 in2, sal_Int32& out2, sal_Int32 in3 ) throw(RuntimeException);
244 virtual void SAL_CALL testout_methodXInterface( Reference< XInterface >& rOut ) throw(RuntimeException);
246 virtual void SAL_CALL testinout_methodByte(sal_Int8& rOut) throw( RuntimeException );
247 virtual void SAL_CALL testinout_methodFloat(float& rOut) throw( RuntimeException );
248 virtual void SAL_CALL testinout_methodDouble(double& rOut) throw( RuntimeException );
249 virtual void SAL_CALL testinout_methodBool(sal_Bool& rOut) throw( RuntimeException );
250 virtual void SAL_CALL testinout_methodShort(sal_Int16& rOut) throw( RuntimeException );
251 virtual void SAL_CALL testinout_methodUShort(sal_uInt16& rOut) throw( RuntimeException );
252 virtual void SAL_CALL testinout_methodLong(sal_Int32& rOut) throw( RuntimeException );
253 virtual void SAL_CALL testinout_methodULong(sal_uInt32& rOut) throw( RuntimeException );
254 virtual void SAL_CALL testinout_methodHyper(sal_Int64& rOut) throw( RuntimeException );
255 virtual void SAL_CALL testinout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException );
256 virtual void SAL_CALL testinout_methodString(OUString& rOut) throw( RuntimeException );
257 virtual void SAL_CALL testinout_methodChar(sal_Unicode& rOut) throw( RuntimeException );
258 virtual void SAL_CALL testinout_methodAny(Any& rOut) throw( RuntimeException );
259 virtual void SAL_CALL testinout_methodType(Type& rOut) throw( RuntimeException );
260 virtual void SAL_CALL testinout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException );
261 virtual void SAL_CALL testinout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException );
262 virtual void SAL_CALL testinout_methodXInterface( Reference< XInvocation >& rOut ) throw(RuntimeException);
263 virtual void SAL_CALL testinout_methodXInterface2( Reference< XInterface > & rOut) throw( RuntimeException);
264 virtual Any SAL_CALL methodAnyTest1(const Any& rIn) throw( RuntimeException ) ;
265 virtual Any SAL_CALL getAttrAny2(void) throw( RuntimeException ) ;
266 virtual void SAL_CALL setAttrAny2(const Any& AttrAny2_) throw( RuntimeException ) ;
269 // XTestStruct
270 virtual void SAL_CALL methodStruct(const Property& aProp) throw( RuntimeException );
272 virtual Property SAL_CALL retMethodStruct(void) throw( RuntimeException );
274 virtual Property SAL_CALL getAttrStruct(void) throw( RuntimeException );
275 virtual void SAL_CALL setAttrStruct(const Property& AttrStruct_) throw( RuntimeException );
276 virtual Property SAL_CALL methodStruct2( const Property& aProp ) throw (RuntimeException);
278 // XTestOther
279 virtual void SAL_CALL other_methodAnyIn(const Any& rAny) throw( RuntimeException );
280 virtual void SAL_CALL other_methodAnyOut(Any& rAny) throw( RuntimeException );
281 virtual Any SAL_CALL other_methodAnyRet(void) throw( RuntimeException );
282 virtual void SAL_CALL in_float( float val) throw ( RuntimeException);
283 virtual Any SAL_CALL other_methodAny( const Any& rAny, const OUString& typeInAny )
284 throw (RuntimeException);
287 // XTestOutParameters ------------------------------------------------------------------------
288 // virtual void SAL_CALL out_test(sal_Int8 rIn) throw( RuntimeException );
290 // virtual void SAL_CALL out_methodByte(sal_Int8& rOut) throw( RuntimeException );
291 // virtual void SAL_CALL out_methodFloat(float& rOut) throw( RuntimeException );
292 // virtual void SAL_CALL out_methodDouble(double& rOut) throw( RuntimeException );
293 // virtual void SAL_CALL out_methodBool(sal_Bool& rOut) throw( RuntimeException );
294 // virtual void SAL_CALL out_methodShort(sal_Int16& rOut) throw( RuntimeException );
295 // virtual void SAL_CALL out_methodUShort(sal_uInt16& rOut) throw( RuntimeException );
296 // virtual void SAL_CALL out_methodLong(sal_Int32& rOut) throw( RuntimeException );
297 // virtual void SAL_CALL out_methodULong(sal_uInt32& rOut) throw( RuntimeException );
298 // virtual void SAL_CALL out_methodHyper(sal_Int64& rOut) throw( RuntimeException );
299 // virtual void SAL_CALL out_methodUHyper(sal_uInt64& rOut) throw( RuntimeException );
300 // virtual void SAL_CALL out_methodString(OUString& rOut) throw( RuntimeException );
301 // virtual void SAL_CALL out_methodChar(sal_Unicode& rOut) throw( RuntimeException );
302 // virtual void SAL_CALL out_methodAny(Any& rOut) throw( RuntimeException );
303 // virtual void SAL_CALL out_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException );
304 // virtual void SAL_CALL out_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException );
305 // virtual void SAL_CALL out_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException );
306 // virtual void SAL_CALL out_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException );
307 // virtual void SAL_CALL out_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException );
309 // XTestInParameters
310 virtual sal_Int8 SAL_CALL in_methodByte( sal_Int8 rIn ) throw (RuntimeException);
311 virtual float SAL_CALL in_methodFloat( float rIn ) throw (RuntimeException);
312 virtual double SAL_CALL in_methodDouble( double rIn ) throw (RuntimeException);
313 virtual sal_Bool SAL_CALL in_methodBool( sal_Bool rIn ) throw (RuntimeException);
314 virtual sal_Int16 SAL_CALL in_methodShort( sal_Int16 rIn ) throw (RuntimeException);
315 virtual sal_uInt16 SAL_CALL in_methodUShort( sal_uInt16 rIn ) throw (RuntimeException);
316 virtual sal_Int32 SAL_CALL in_methodLong( sal_Int32 rIn ) throw (RuntimeException);
317 virtual sal_uInt32 SAL_CALL in_methodULong( sal_uInt32 rIn ) throw (RuntimeException);
318 virtual sal_Int64 SAL_CALL in_methodHyper( sal_Int64 rIn ) throw (RuntimeException);
319 virtual sal_uInt64 SAL_CALL in_methodUHyper( sal_uInt64 rIn ) throw (RuntimeException);
320 virtual OUString SAL_CALL in_methodString( const OUString& rIn ) throw (RuntimeException);
321 virtual sal_Unicode SAL_CALL in_methodChar( sal_Unicode rIn ) throw (RuntimeException);
322 virtual Any SAL_CALL in_methodAny( const Any& rIn ) throw (RuntimeException);
323 virtual Type SAL_CALL in_methodType( const Type& rIn ) throw (RuntimeException);
324 virtual Reference<XInterface> SAL_CALL in_methodXInterface( const Reference< XInterface >& rIn ) throw (RuntimeException);
325 virtual Reference<XInvocation > SAL_CALL in_methodInvocation( const Reference< XInvocation >& inv ) throw (RuntimeException);
326 virtual SimpleStruct SAL_CALL in_methodStruct( const SimpleStruct& aStruct ) throw (RuntimeException);
327 virtual void SAL_CALL in_methodAll( sal_Int8 b, float f, double d, sal_Bool boo, sal_Int16 sh, sal_uInt16 us, sal_Int32 l, sal_uInt32 ul, const OUString& s, sal_Unicode c, const Any& a, const Type& t, const Reference<XInvocation>& inv ) throw (RuntimeException);
329 // XTestInterfaces --------------------------------------------------------------------------
330 virtual void SAL_CALL testInterface( const Reference< XCallback >& xCallback, sal_Int32 mode ) throw(RuntimeException);
331 virtual void SAL_CALL testInterface2( const Reference< XSimple >& xSimple, sal_Int32 mode ) throw(RuntimeException);
332 // XSimple --------------------------------------------------------------------------
333 void SAL_CALL func( const OUString &message) throw(::com::sun::star::uno::RuntimeException);
334 OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
336 // XIdentity
337 virtual void SAL_CALL setObject( const Reference< XInterface >& val ) throw (RuntimeException);
338 virtual sal_Bool SAL_CALL isSame( const Reference< XInterface >& val ) throw (RuntimeException);
339 virtual Reference< XInterface > SAL_CALL getThis( ) throw (RuntimeException);
342 class EventListener: public WeakImplHelper1<XEventListener>
344 public:
345 EventListener::EventListener(): bCalled( sal_False)
347 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (RuntimeException);
349 sal_Bool bCalled;
353 OComponent::~OComponent()
358 // Funktions ==============================================================================
360 Reference<XInterface> SAL_CALL OComponent_CreateInstance( const Reference<XMultiServiceFactory> & rSMgr ) throw(RuntimeException)
362 // Reference<XInterface> xService(static_cast<XWeak*>(new OComponent( rSMgr )), UNO_QUERY);
363 OComponent* o= new OComponent( rSMgr );
364 Reference<XInterface> xService(static_cast<XIdentity*>(o), UNO_QUERY);
365 return xService;
368 Sequence<OUString> OComponent_getSupportedServiceNames(void)
370 Sequence<OUString> aRet(1);
371 aRet.getArray()[0] = SERVICE_NAME;//ODataInputStream_getImplementationName();
373 return aRet;
377 extern "C" sal_Bool SAL_CALL component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey )
379 if(pRegistryKey)
383 Reference<XRegistryKey> xNewKey =
384 reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(KEY1);
385 xNewKey->createKey( KEY2);
386 return sal_True;
389 catch(InvalidRegistryException &)
391 OSL_ENSURE( sal_False, "### InvalidRegistryException!\n");
394 return sal_False;
397 extern "C" void * SAL_CALL component_getFactory(
398 const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
400 static void * pRet= NULL;
401 if( ! pRet)
403 OUString aImplName( OUString::createFromAscii( pImplName ) );
404 if (pServiceManager && aImplName.equals( IMPL_NAME ))
406 Reference<XMultiServiceFactory> xMulFac(
407 reinterpret_cast< XMultiServiceFactory*>(pServiceManager));
409 Sequence<OUString> seqServiceNames;
410 Reference<XSingleServiceFactory> xFactory = createOneInstanceFactory( xMulFac, SERVICE_NAME,
411 OComponent_CreateInstance, seqServiceNames);
413 if (xFactory.is())
415 xFactory->acquire();
416 pRet = xFactory.get();
420 return pRet;
423 extern "C" void SAL_CALL component_getImplementationEnvironment(
424 const sal_Char ** ppEnvTypeName, uno_Environment ** )
426 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
430 // XTestSequence ============================================================================
431 Sequence<sal_Int8> SAL_CALL OComponent::methodByte(const Sequence< sal_Int8 >& aSeq) throw( RuntimeException )
433 sal_Int8 _x;
434 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
435 _x= aSeq.getConstArray()[i];
437 return aSeq;
439 Sequence<float> SAL_CALL OComponent::methodFloat(const Sequence< float>& aSeq) throw( RuntimeException )
441 float _x;
442 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
443 _x= aSeq.getConstArray()[i];
445 return aSeq;
447 Sequence<double> SAL_CALL OComponent::methodDouble(const Sequence< double >& aSeq) throw( RuntimeException)
449 double _x;
450 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
451 _x= aSeq.getConstArray()[i];
453 return aSeq;
455 Sequence< sal_Bool > SAL_CALL OComponent::methodBool(const Sequence< sal_Bool >& aSeq) throw( RuntimeException)
457 sal_Bool _x;
458 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
459 _x= aSeq.getConstArray()[i];
461 return aSeq;
463 Sequence< sal_Int16 > SAL_CALL OComponent::methodShort(const Sequence< sal_Int16 >& aSeq) throw( RuntimeException )
465 sal_Int16 _x;
466 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
467 _x= aSeq.getConstArray()[i];
469 return aSeq;
471 Sequence< sal_uInt16 > SAL_CALL OComponent::methodUShort(const Sequence< sal_uInt16 >& aSeq) throw( RuntimeException )
473 sal_uInt16 _x;
474 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
475 _x= aSeq.getConstArray()[i];
477 return aSeq;
479 Sequence< sal_Int32 > SAL_CALL OComponent::methodLong(const Sequence< sal_Int32 >& aSeq) throw( RuntimeException)
481 sal_Int32 _x;
482 for( sal_Int16 i= 0; i < aSeq.getLength(); i++) {
483 _x= aSeq.getConstArray()[i];
485 return aSeq;
487 Sequence< sal_uInt32 > SAL_CALL OComponent::methodULong(const Sequence< sal_uInt32 >& aSeq) throw( RuntimeException)
489 sal_uInt32 _x;
490 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
491 _x= aSeq.getConstArray()[i];
493 return aSeq;
495 Sequence< OUString > SAL_CALL OComponent::methodString(const Sequence< OUString >& aSeq) throw( RuntimeException)
497 OUString _x;
498 for( sal_Int16 i= 0; i < aSeq.getLength(); i++) {
499 _x= aSeq.getConstArray()[i];
501 return aSeq;
503 Sequence< sal_Unicode > SAL_CALL OComponent::methodChar(const Sequence< sal_Unicode >& aSeq) throw( RuntimeException)
505 sal_Unicode _x;
506 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
507 _x= aSeq.getConstArray()[i];
509 return aSeq;
511 Sequence< Any > SAL_CALL OComponent::methodAny(const Sequence< Any >& aSeq) throw( RuntimeException)
513 Any _x;
514 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
515 _x= aSeq.getConstArray()[i];
516 TypeClass _t= _x.getValueTypeClass();
517 if( _t== TypeClass_STRING)
518 OUString s(* (rtl_uString**)_x.getValue());
520 return aSeq;
524 Sequence< Type > SAL_CALL OComponent::methodType(const Sequence< Type >& aSeq) throw( RuntimeException )
526 Type _x;
527 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
528 _x= aSeq.getConstArray()[i];
530 return aSeq;
532 //Sequence< Reference< XInterface> > SAL_CALL methodXInterface ( const Sequence< Reference < XInterface> >& aSeq)
533 // throw (RuntimeException)
534 Sequence< Reference< XInterface > > SAL_CALL OComponent::methodXInterface( const Sequence< Reference< XInterface > >& aSeq ) throw(RuntimeException)
536 for( sal_Int32 i= 0; i < aSeq.getLength(); i++)
538 Reference<XInterface> xInt= aSeq[i];
539 Reference<XEventListener> xList( xInt, UNO_QUERY);
540 if( xList.is())
541 xList->disposing( EventObject());
543 return aSeq;
546 Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::methodSequence(const Sequence< Sequence< sal_Int32 > >& aSeq) throw( RuntimeException)
548 sal_Int32 value;
549 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
550 const Sequence<sal_Int32>& rseq2= aSeq.getConstArray()[i];
551 for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
552 value= rseq2.getConstArray()[j];
555 return aSeq;
557 Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL OComponent::methodSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq)
558 throw( RuntimeException )
560 sal_Int32 value;
561 sal_Int32 len= aSeq.getLength();
562 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
563 const Sequence< Sequence<sal_Int32> >& rseq2= aSeq.getConstArray()[i];
564 len= rseq2.getLength();
566 for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
567 const Sequence<sal_Int32> & rseq3= rseq2.getConstArray()[j];
568 len= rseq3.getLength();
570 for (sal_Int16 k= 0; k < rseq3.getLength(); k++)
571 value= rseq3.getConstArray()[k];
574 return aSeq;
577 Sequence< Reference< XEventListener> > SAL_CALL OComponent::methodXEventListeners( const Sequence< Reference <XEventListener> >& aSeq) throw( RuntimeException)
579 Reference<XEventListener> listener;
580 for( int i= 0; i < aSeq.getLength(); i++)
582 listener= aSeq[i];
584 listener->disposing( EventObject() );
587 return aSeq;
590 Sequence< Sequence<Reference<XEventListener > > > SAL_CALL OComponent::methodXEventListenersMul( const Sequence<Sequence<Reference<XEventListener > > >& aSeq ) throw (RuntimeException)
592 Reference<XEventListener> listener;
593 for( int i= 0; i < aSeq.getLength(); i++)
595 Sequence<Reference<XEventListener> > seqInner= aSeq[i];
596 for( int j= 0; j < seqInner.getLength(); j++)
598 listener= seqInner[j];
599 listener->disposing( EventObject() );
602 return aSeq;
605 //---------------------------------------------------------------------------------------------
607 Sequence< sal_Int8 > SAL_CALL OComponent::getAttrByte(void) throw( RuntimeException)
609 return m_seqByte;
611 void SAL_CALL OComponent::setAttrByte(const Sequence< sal_Int8 >& AttrByte_) throw( RuntimeException )
613 m_seqByte= AttrByte_;
615 Sequence< float > SAL_CALL OComponent::getAttrFloat(void) throw( RuntimeException )
617 return m_seqFloat;
619 void SAL_CALL OComponent::setAttrFloat(const Sequence< float >& AttrFloat_) throw( RuntimeException )
621 m_seqFloat= AttrFloat_;
624 Sequence< double > SAL_CALL OComponent::getAttrDouble(void) throw( RuntimeException )
626 return m_seqDouble;
628 void SAL_CALL OComponent::setAttrDouble(const Sequence< double >& AttrDouble_) throw( RuntimeException )
630 m_seqDouble= AttrDouble_;
633 Sequence< sal_Bool > SAL_CALL OComponent::getAttrBool(void) throw( RuntimeException)
635 return m_seqBool;
638 void SAL_CALL OComponent::setAttrBool(const Sequence< sal_Bool >& AttrBool_) throw (RuntimeException )
640 m_seqBool= AttrBool_;
643 Sequence< sal_Int16 > SAL_CALL OComponent::getAttrShort(void) throw( RuntimeException)
645 return m_seqShort;
647 void SAL_CALL OComponent::setAttrShort(const Sequence< sal_Int16 >& AttrShort_) throw( RuntimeException )
649 m_seqShort= AttrShort_;
652 Sequence< sal_uInt16 > SAL_CALL OComponent::getAttrUShort(void) throw( RuntimeException )
654 return m_seqUShort;
656 void SAL_CALL OComponent::setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_) throw( RuntimeException )
658 m_seqUShort= AttrUShort_;
661 Sequence< sal_Int32 > SAL_CALL OComponent::getAttrLong(void) throw( RuntimeException)
663 return m_seqLong;
665 void SAL_CALL OComponent::setAttrLong(const Sequence< sal_Int32 >& AttrLong_) throw( RuntimeException )
667 m_seqLong= AttrLong_;
670 Sequence< sal_uInt32 > SAL_CALL OComponent::getAttrULong(void) throw( RuntimeException )
672 return m_seqULong;
674 void SAL_CALL OComponent::setAttrULong(const Sequence< sal_uInt32 >& AttrULong_) throw( RuntimeException )
676 m_seqULong= AttrULong_;
679 Sequence< OUString > SAL_CALL OComponent::getAttrString(void) throw( RuntimeException )
681 return m_seqString;
683 void SAL_CALL OComponent::setAttrString(const Sequence< OUString >& AttrString_) throw( RuntimeException )
685 m_seqString= AttrString_;
688 Sequence< sal_Unicode > SAL_CALL OComponent::getAttrChar(void) throw( RuntimeException )
690 return m_seqChar;
692 void SAL_CALL OComponent::setAttrChar(const Sequence< sal_Unicode >& AttrChar_) throw( RuntimeException)
694 m_seqChar= AttrChar_;
697 Sequence< Any > SAL_CALL OComponent::getAttrAny(void) throw( RuntimeException)
699 return m_seqAny;
701 void SAL_CALL OComponent::setAttrAny(const Sequence< Any >& AttrAny_) throw( RuntimeException )
703 m_seqAny= AttrAny_;
706 Sequence< Type > SAL_CALL OComponent::getAttrType(void) throw( RuntimeException )
708 return m_seqType;
711 void SAL_CALL OComponent::setAttrType( const Sequence< Type >& AttrType_) throw( RuntimeException )
713 m_seqType = AttrType_;
717 Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::getAttrSequence(void) throw( RuntimeException)
719 return m_seq1;
721 void SAL_CALL OComponent::setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence) throw(RuntimeException )
723 sal_Int32 x= 0;
724 for( sal_Int32 i=0; i < AttrSequence.getLength(); i++)
726 Sequence< sal_Int32 > seq= AttrSequence[i];
728 for ( sal_Int32 j=0; j < seq.getLength(); j++)
730 x= seq[j];
734 m_seq1= AttrSequence;
737 Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL OComponent::getAttrSequence2(void) throw( RuntimeException )
739 return m_seq2;
741 void SAL_CALL OComponent::setAttrSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& AttrSequence2_)
742 throw( RuntimeException )
744 m_seq2= AttrSequence2_;
747 Sequence< Reference< XInterface > > SAL_CALL OComponent::getAttrXInterface() throw(RuntimeException)
749 return m_seqxInterface;
751 void SAL_CALL OComponent::setAttrXInterface( const Sequence< Reference< XInterface > >& _attrxinterface ) throw(RuntimeException)
753 m_seqxInterface= _attrxinterface;
756 // ----------------------------------------------------------------------------
758 ::sal_Int8 SAL_CALL OComponent::getAByte() throw (RuntimeException)
760 return m_attr_int8;
763 void SAL_CALL OComponent::setAByte( ::sal_Int8 _abyte ) throw (RuntimeException)
765 m_attr_int8 = _abyte;
768 float SAL_CALL OComponent::getAFloat() throw (RuntimeException)
770 return m_attr_float;
773 void SAL_CALL OComponent::setAFloat( float _afloat ) throw (RuntimeException)
775 m_attr_float = _afloat;
778 double SAL_CALL OComponent::getADouble() throw (RuntimeException)
780 return m_attr_double;
783 void SAL_CALL OComponent::setADouble( double _adouble ) throw (RuntimeException)
785 m_attr_double = _adouble;
788 ::sal_Bool SAL_CALL OComponent::getABool() throw (RuntimeException)
790 return m_attr_bool;
793 void SAL_CALL OComponent::setABool( ::sal_Bool _abool ) throw (RuntimeException)
795 m_attr_bool = _abool;
798 ::sal_Int16 SAL_CALL OComponent::getAShort() throw (RuntimeException)
800 return m_attr_int16;
803 void SAL_CALL OComponent::setAShort( ::sal_Int16 _ashort ) throw (RuntimeException)
805 m_attr_int16 = _ashort;
808 ::sal_uInt16 SAL_CALL OComponent::getAUShort() throw (RuntimeException)
810 return m_attr_uint16;
813 void SAL_CALL OComponent::setAUShort( ::sal_uInt16 _aushort ) throw (RuntimeException)
815 m_attr_uint16 = _aushort;
818 ::sal_Int32 SAL_CALL OComponent::getALong() throw (RuntimeException)
820 return m_attr_int32;
823 void SAL_CALL OComponent::setALong( ::sal_Int32 _along ) throw (RuntimeException)
825 m_attr_int32 = _along;
828 ::sal_uInt32 SAL_CALL OComponent::getAULong() throw (RuntimeException)
830 return m_attr_uint32;;
833 void SAL_CALL OComponent::setAULong( ::sal_uInt32 _aulong ) throw (RuntimeException)
835 m_attr_uint32 = _aulong;
838 ::rtl::OUString SAL_CALL OComponent::getAString() throw (RuntimeException)
840 return m_attr_string;
843 void SAL_CALL OComponent::setAString( const ::rtl::OUString& _astring ) throw (RuntimeException)
845 m_attr_string = _astring;
848 ::sal_Unicode SAL_CALL OComponent::getAChar() throw (RuntimeException)
850 return m_attr_char;
853 void SAL_CALL OComponent::setAChar( ::sal_Unicode _achar ) throw (RuntimeException)
855 m_attr_char = _achar;
858 Any SAL_CALL OComponent::getAAny() throw (RuntimeException)
860 return m_attr_any;
863 void SAL_CALL OComponent::setAAny( const Any& _aany ) throw (RuntimeException)
865 m_attr_any = _aany;
868 Type SAL_CALL OComponent::getAType() throw (RuntimeException)
870 return m_attr_type;
873 void SAL_CALL OComponent::setAType( const Type& _atype ) throw (RuntimeException)
875 m_attr_type = _atype;
878 Reference< XInterface > SAL_CALL OComponent::getAXInterface() throw (RuntimeException)
880 return m_attr_xinterface;
883 void SAL_CALL OComponent::setAXInterface( const Reference<XInterface >& _axinterface ) throw (RuntimeException)
885 m_attr_xinterface = _axinterface;
888 Reference<XInvocation > SAL_CALL OComponent::getAXInvocation() throw (RuntimeException)
890 return m_attr_xinvocation;
893 void SAL_CALL OComponent::setAXInvocation( const Reference< XInvocation >& _axinvocation ) throw (RuntimeException)
895 m_attr_xinvocation = _axinvocation;
897 //-----------------------------------------------------------------------------------
898 void SAL_CALL OComponent::testout_methodByte(sal_Int8& rOut) throw( RuntimeException )
900 rOut= m_int8;
902 void SAL_CALL OComponent::testout_methodFloat(float& rOut) throw( RuntimeException )
904 rOut= m_float;
906 void SAL_CALL OComponent::testout_methodDouble(double& rOut) throw( RuntimeException )
908 rOut= m_double;
911 void SAL_CALL OComponent::testout_methodBool(sal_Bool& rOut) throw( RuntimeException )
913 rOut= m_bool;
915 void SAL_CALL OComponent::testout_methodShort(sal_Int16& rOut) throw( RuntimeException )
917 rOut= m_int16;
919 void SAL_CALL OComponent::testout_methodUShort(sal_uInt16& rOut) throw( RuntimeException )
921 rOut= m_uint16;
923 void SAL_CALL OComponent::testout_methodLong(sal_Int32& rOut) throw( RuntimeException )
925 rOut = m_int32;
927 void SAL_CALL OComponent::testout_methodULong(sal_uInt32& rOut) throw( RuntimeException )
929 rOut= m_uint32;
931 void SAL_CALL OComponent::testout_methodHyper(sal_Int64& rOut) throw( RuntimeException )
933 rOut = m_int64;
936 void SAL_CALL OComponent::testout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException )
938 rOut = m_uint64;
941 void SAL_CALL OComponent::testout_methodString(OUString& rOut) throw( RuntimeException )
943 rOut= m_string;
945 void SAL_CALL OComponent::testout_methodChar(sal_Unicode& rOut) throw( RuntimeException )
947 rOut= m_char;
949 void SAL_CALL OComponent::testout_methodAny(Any& rOut) throw( RuntimeException)
951 rOut = m_any;
954 void SAL_CALL OComponent::testout_methodType(Type& rOut) throw( RuntimeException )
956 rOut = m_type;
959 void SAL_CALL OComponent::testout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException)
961 rOut.realloc(10);
962 for( sal_Int16 i= 0; i < rOut.getLength(); i++) rOut.getArray()[i]= i;
964 void SAL_CALL OComponent::testout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException )
966 rOut.realloc( 10);
967 for( sal_Int16 i= 0; i < rOut.getLength(); i++){
968 Sequence<sal_Int32>& rseq2= rOut.getArray()[i];
969 rseq2.realloc( 10);
970 for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
971 rseq2.getArray()[j]= j;
975 void SAL_CALL OComponent::testout_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException )
977 rout1= 999;
978 rout2= 1111;
980 void SAL_CALL OComponent::testout_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException )
982 rout1= 1111;
983 rout2= 1222;
984 rout3= L" another string";
986 void SAL_CALL OComponent::testout_methodMulParams3(const OUString&, OUString& sout) throw( RuntimeException )
988 sout= L"Out Hallo!";
990 void SAL_CALL OComponent::testout_methodMulParams4( float in1, float& out1, sal_Int32 in2, sal_Int32& out2, sal_Int32 ) throw(RuntimeException)
992 out1= in1 + 1;
993 out2= in2 + 1;
996 void SAL_CALL OComponent::testout_methodXInterface( Reference< XInterface >& rOut ) throw(RuntimeException)
998 rOut = m_xinterface;
999 // OUString string( L"Property Any");
1000 // m_any <<= string;
1001 // rOut= Reference<XInterface> (static_cast<XTestSequence*>(this), UNO_QUERY);
1004 // XTestInParameters ------------------------------------------------------------
1005 sal_Int8 SAL_CALL OComponent::in_methodByte( sal_Int8 rIn ) throw (RuntimeException)
1007 m_int8 = rIn;
1008 return rIn;
1010 float SAL_CALL OComponent::in_methodFloat( float rIn ) throw (RuntimeException)
1012 m_float = rIn;
1013 return rIn;
1015 double SAL_CALL OComponent::in_methodDouble( double rIn ) throw (RuntimeException)
1017 m_double = rIn;
1018 return rIn;
1020 sal_Bool SAL_CALL OComponent::in_methodBool( sal_Bool rIn ) throw (RuntimeException)
1022 m_bool = rIn;
1023 return rIn;
1025 sal_Int16 SAL_CALL OComponent::in_methodShort( sal_Int16 rIn ) throw (RuntimeException)
1027 m_int16 = rIn;
1028 return rIn;
1030 sal_uInt16 SAL_CALL OComponent::in_methodUShort( sal_uInt16 rIn ) throw (RuntimeException)
1032 m_uint16 = rIn;
1033 return rIn;
1035 sal_Int32 SAL_CALL OComponent::in_methodLong( sal_Int32 rIn ) throw (RuntimeException)
1037 m_int32 = rIn;
1038 return rIn;
1040 sal_uInt32 SAL_CALL OComponent::in_methodULong( sal_uInt32 rIn ) throw (RuntimeException)
1042 m_uint32 = rIn;
1043 return rIn;
1045 sal_Int64 SAL_CALL OComponent::in_methodHyper( sal_Int64 rIn ) throw (RuntimeException)
1047 m_int64 = rIn;
1048 return rIn;
1051 sal_uInt64 SAL_CALL OComponent::in_methodUHyper( sal_uInt64 rIn ) throw (RuntimeException)
1053 m_uint64 = rIn;
1054 return rIn;
1057 OUString SAL_CALL OComponent::in_methodString( const OUString& rIn ) throw (RuntimeException)
1059 m_string = rIn;
1060 return rIn;
1062 sal_Unicode SAL_CALL OComponent::in_methodChar( sal_Unicode rIn ) throw (RuntimeException)
1064 m_char = rIn;
1065 return rIn;
1067 Any SAL_CALL OComponent::in_methodAny( const Any& rIn ) throw (RuntimeException)
1069 m_any = rIn;
1070 return rIn;
1073 Type SAL_CALL OComponent::in_methodType( const Type& rIn ) throw (RuntimeException)
1075 m_type = rIn;
1076 return rIn;
1079 Reference<XInvocation > SAL_CALL OComponent::in_methodInvocation( const Reference< XInvocation >& inv )
1080 throw (RuntimeException)
1082 //We expect the invocation results from a conversion of VBasicEventListener.VBEventListener
1083 //which implements XEventListener
1084 // extensions/test/ole/EventListenerSample
1085 EventObject event( Reference<XInterface>(static_cast<XTestInParameters*>(this),UNO_QUERY));
1086 Any anyParam;
1087 anyParam <<= event;
1088 Sequence<Any> params( &anyParam, 1);
1089 Sequence<sal_Int16> outIndex;
1090 Sequence<Any> outParams;
1091 try{
1092 inv->invoke( OUString(RTL_CONSTASCII_USTRINGPARAM("disposing")),
1093 params, outIndex, outParams);
1094 }catch(IllegalArgumentException &) {
1096 catch(CannotConvertException &){
1098 catch(InvocationTargetException&) {
1100 return inv;
1102 Reference<XInterface> SAL_CALL OComponent::in_methodXInterface( const Reference<XInterface >& rIn ) throw (RuntimeException)
1104 m_xinterface = rIn;
1105 return rIn;
1108 SimpleStruct SAL_CALL OComponent::in_methodStruct( const SimpleStruct& aStruct )
1109 throw (RuntimeException)
1111 SimpleStruct& s= const_cast<SimpleStruct&>(aStruct);
1112 s.message= s.message + OUString(RTL_CONSTASCII_USTRINGPARAM(
1113 "This string was set in OleTest"));
1114 return aStruct;
1116 void SAL_CALL OComponent::in_methodAll(
1117 sal_Int8, float, double, sal_Bool, sal_Int16, sal_uInt16,
1118 sal_Int32, sal_uInt32, const OUString&, sal_Unicode,
1119 const Any&, const Type&, const Reference<XInvocation>&) throw (RuntimeException)
1123 // INOUT -----------------------------------------------------------------------------------
1124 void SAL_CALL OComponent::testinout_methodByte(sal_Int8& rOut) throw( RuntimeException )
1126 sal_Int8 tmp = rOut;
1127 rOut = m_int8;
1128 m_int8 = tmp;
1130 void SAL_CALL OComponent::testinout_methodFloat(float& rOut) throw( RuntimeException )
1132 float tmp = rOut;
1133 rOut = m_float;
1134 m_float = tmp;
1137 void SAL_CALL OComponent::testinout_methodDouble(double& rOut) throw( RuntimeException )
1139 double tmp = rOut;
1140 rOut = m_double;
1141 m_double = tmp;
1143 void SAL_CALL OComponent::testinout_methodBool(sal_Bool& rOut) throw( RuntimeException )
1145 sal_Bool tmp = rOut;
1146 rOut = m_bool;
1147 m_bool = tmp;
1149 void SAL_CALL OComponent::testinout_methodShort(sal_Int16& rOut) throw( RuntimeException )
1151 sal_Int16 tmp= rOut;
1152 rOut = m_int16;
1153 m_int16 = tmp;
1155 void SAL_CALL OComponent::testinout_methodUShort(sal_uInt16& rOut) throw( RuntimeException )
1157 sal_uInt16 tmp = rOut;
1158 rOut = m_uint16;
1159 m_uint16 = tmp;
1161 void SAL_CALL OComponent::testinout_methodLong(sal_Int32& rOut) throw( RuntimeException )
1163 sal_Int32 tmp = rOut;
1164 rOut = m_int32;
1165 m_int32 = tmp;
1167 void SAL_CALL OComponent::testinout_methodULong(sal_uInt32& rOut) throw( RuntimeException )
1169 sal_uInt32 tmp = rOut;
1170 rOut = m_uint32;
1171 m_uint32 = tmp;
1173 void SAL_CALL OComponent::testinout_methodHyper(sal_Int64& rOut) throw( RuntimeException )
1175 sal_Int64 tmp = rOut;
1176 rOut = m_int64;
1177 m_int64 = tmp;
1180 void SAL_CALL OComponent::testinout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException )
1182 sal_uInt64 tmp = rOut;
1183 rOut = m_uint64;
1184 m_uint64 = tmp;
1187 void SAL_CALL OComponent::testinout_methodString(OUString& rOut) throw( RuntimeException )
1189 OUString tmp = rOut;
1190 rOut = m_string;
1191 m_string = tmp;
1193 void SAL_CALL OComponent::testinout_methodChar(sal_Unicode& rOut) throw( RuntimeException)
1195 sal_Unicode tmp = rOut;
1196 rOut = m_char;
1197 m_char = tmp;
1199 void SAL_CALL OComponent::testinout_methodAny(Any& rOut) throw( RuntimeException)
1201 Any tmp = rOut;
1202 rOut = m_any;
1203 m_any = tmp;
1205 void SAL_CALL OComponent::testinout_methodType(Type& rOut) throw( RuntimeException)
1207 Type tmp = rOut;
1208 rOut = m_type;
1209 m_type = tmp;
1213 void SAL_CALL OComponent::testinout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException)
1216 sal_Int32* arr= rOut.getArray();
1217 for ( sal_Int32 i=0; i < rOut.getLength(); i++)
1219 rOut.getArray()[i] += 1;
1222 void SAL_CALL OComponent::testinout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException )
1224 for( sal_Int32 i=0; i < rOut.getLength(); i++)
1226 Sequence< sal_Int32 >& seq= rOut.getArray()[i];
1228 for ( sal_Int32 j=0; j < seq.getLength(); j++)
1230 seq.getArray()[j] += seq.getArray()[j];
1235 // The parameter should implement XInvocation and a Property "value"
1236 void SAL_CALL OComponent::testinout_methodXInterface( Reference< XInvocation >& rOut ) throw(RuntimeException)
1238 Any any;
1239 any= rOut->getValue( OUString( L"value"));
1240 OUString _s;
1241 any >>= _s;
1242 OUString string(L"out");
1243 any <<= string;
1244 rOut->setValue( OUString(L"value"), any);
1246 any= rOut->getValue( OUString( L"value"));
1247 any >>= _s;
1251 void SAL_CALL OComponent::testinout_methodXInterface2( Reference< XInterface > & rOut) throw( RuntimeException)
1253 Reference<XInterface> tmp = rOut;
1254 rOut = m_xinterface;
1255 m_xinterface = tmp;
1256 // Reference<XTestSequence> xTest( rOut, UNO_QUERY);
1257 // if( xTest.is())
1258 // {
1259 // Any any= xTest->getAttrAny2();
1260 // OUString _s;
1261 // any >>= _s;
1262 // OUString string= _s + OUString((L" this string was written in the UNO component to the inout pararmeter"));
1263 // any <<= string;
1264 // xTest->setAttrAny2( any);
1265 // }
1268 Any SAL_CALL OComponent::methodAnyTest1(const Any& rIn) throw( RuntimeException )
1270 return rIn;
1272 Any SAL_CALL OComponent::getAttrAny2(void) throw( RuntimeException )
1274 return m_any;
1276 void SAL_CALL OComponent::setAttrAny2(const Any& AttrAny2_) throw( RuntimeException )
1278 m_any= AttrAny2_;
1283 // XTestStruct =======================================================================================
1285 void SAL_CALL OComponent::methodStruct(const Property& aProp) throw( RuntimeException )
1287 char buff[1024];
1288 buff[0]= 0;
1289 sprintf( buff,"Property::Attribute : %d \n Property::Handle : %d \n Property::Name : %S",
1290 aProp.Attributes, aProp.Handle, (const sal_Unicode*)aProp.Name);
1291 MessageBox( NULL, A2T(buff), _T("OleTest: methodStruct"), MB_OK);
1294 Property SAL_CALL OComponent::retMethodStruct(void) throw( RuntimeException )
1296 Property a(L"OleTest_Property", 255, getCppuType( (Reference<XInterface>*)0), PropertyAttribute::MAYBEVOID |
1297 PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED |
1298 PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY |
1299 PropertyAttribute::MAYBEAMBIGUOUS | PropertyAttribute::MAYBEDEFAULT );
1300 return a;
1303 Property SAL_CALL OComponent::getAttrStruct(void) throw( RuntimeException)
1305 Property a(L"OleTest_Property", 255, getCppuType( (Reference<XInterface>*)0), PropertyAttribute::MAYBEVOID |
1306 PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED |
1307 PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY |
1308 PropertyAttribute::MAYBEAMBIGUOUS | PropertyAttribute::MAYBEDEFAULT );
1309 return a;
1313 void SAL_CALL OComponent::setAttrStruct(const Property& AttrStruct_) throw( RuntimeException )
1315 char buff[1024];
1316 buff[0]= 0;
1317 sprintf( buff,"Property::Attribute : %d \n Property::Handle : %d \n Property::Name : %S",
1318 AttrStruct_.Attributes, AttrStruct_.Handle, (const sal_Unicode*)AttrStruct_.Name);
1319 // MessageBox( NULL, A2T(buff), _T("OleTest: setAttrStruct"), MB_OK);
1322 Property SAL_CALL OComponent::methodStruct2( const Property& aProp ) throw (RuntimeException)
1324 return aProp;
1327 // XTestOther ==================================================================================
1328 void SAL_CALL OComponent::other_methodAnyIn(const Any& ) throw( RuntimeException )
1331 void SAL_CALL OComponent::other_methodAnyOut(Any& rAny) throw( RuntimeException )
1333 rAny <<= OUString(L"Ein Any");
1336 Any SAL_CALL OComponent::other_methodAnyRet(void) throw(RuntimeException )
1338 Any a;
1339 a <<= OUString(L"Ein Any");
1340 return a;
1342 void SAL_CALL OComponent::in_float( float val) throw ( RuntimeException)
1344 USES_CONVERSION;
1345 char buff[256];
1346 sprintf( buff, "parameter : %f", val);
1347 MessageBox( NULL, A2T(buff), _T("OleTest"), MB_OK);
1349 Any SAL_CALL OComponent::other_methodAny( const Any& rAny, const OUString& typeInAny )
1350 throw (RuntimeException)
1352 Type expectedType;
1353 typelib_TypeDescription * pDesc= NULL;
1354 typelib_typedescription_getByName( &pDesc, typeInAny.pData );
1355 if( pDesc)
1357 expectedType = Type( pDesc->pWeakRef );
1358 typelib_typedescription_release( pDesc);
1360 if (rAny.getValueType() != expectedType)
1361 throw RuntimeException();
1363 return rAny;
1366 // XTestOutParameters ============================================================================
1367 // void SAL_CALL OComponent::out_test(sal_Int8 rIn) throw( RuntimeException )
1368 // {
1369 // }
1371 // void SAL_CALL OComponent::out_methodByte(sal_Int8& rOut) throw( RuntimeException )
1372 // {
1373 // rOut= 100;
1374 // }
1376 // void SAL_CALL OComponent::out_methodDouble(double& rOut) throw( RuntimeException )
1377 // {
1378 // rOut= 3.14;
1379 // }
1380 // void SAL_CALL OComponent::out_methodFloat(float& rOut) throw( RuntimeException )
1381 // {
1382 // rOut= 3.14;
1383 // }
1384 // void SAL_CALL OComponent::out_methodBool(sal_Bool& rOut) throw( RuntimeException )
1385 // {
1386 // rOut= sal_True;
1387 // }
1388 // void SAL_CALL OComponent::out_methodShort(sal_Int16& rOut) throw( RuntimeException )
1389 // {
1390 // rOut= -100;
1391 // }
1392 // void SAL_CALL OComponent::out_methodUShort(sal_uInt16& rOut) throw( RuntimeException )
1393 // {
1394 // rOut= 100;
1395 // }
1396 // void SAL_CALL OComponent::out_methodLong(sal_Int32& rOut) throw( RuntimeException )
1397 // {
1398 // rOut= -100;
1399 // }
1401 // void SAL_CALL OComponent::out_methodULong(sal_uInt32& rOut) throw( RuntimeException )
1402 // {
1403 // rOut= 100;
1404 // }
1405 // void SAL_CALL OComponent::out_methodHyper(sal_Int64& rOut) throw( RuntimeException )
1406 // {
1408 // }
1410 // void SAL_CALL OComponent::out_methodUHyper(sal_uInt64& rOut) throw( RuntimeException )
1411 // {
1412 // }
1414 // void SAL_CALL OComponent::out_methodString(OUString& rOut) throw( RuntimeException )
1415 // {
1416 // rOut= L"I'm a string";
1417 // }
1418 // void SAL_CALL OComponent::out_methodChar(sal_Unicode& rOut) throw( RuntimeException )
1419 // {
1420 // rOut= 'A';
1421 // }
1422 // void SAL_CALL OComponent::out_methodAny(Any& rOut) throw( RuntimeException)
1423 // {
1424 // Any a;
1425 // a <<= OUString( L"Hi");
1426 // rOut= a;
1427 // }
1428 // void SAL_CALL OComponent::out_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException )
1429 // {
1430 // Sequence< sal_Int32 > aseq(10);
1431 // for( sal_Int16 i= 0; i < aseq.getLength(); i++) aseq.getArray()[i]= i;
1432 // rOut= aseq;
1433 // }
1434 // void SAL_CALL OComponent::out_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException )
1435 // {
1436 // rOut= Sequence< Sequence< sal_Int32 > >();
1437 // }
1438 // void SAL_CALL OComponent::out_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException )
1439 // {
1440 // rout1= 111;
1441 // rout2= 222;
1442 // }
1443 // void SAL_CALL OComponent::out_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException )
1444 // {
1445 // rout1= 111;
1446 // rout2= 222;
1447 // rout3= L"this is a neet little string";
1448 // }
1449 // void SAL_CALL OComponent::out_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException )
1450 // {
1451 // sout= L"this is a neet little string";
1452 // }
1454 // XTestInterfaces -------------------------------------------------------------------------------------
1455 void SAL_CALL OComponent::testInterface( const Reference< XCallback >& xCallback, sal_Int32 mode ) throw(RuntimeException)
1457 USES_CONVERSION;
1458 sal_Int32 i=0;
1459 OUString aString;
1460 char buff[1024];
1462 Reference<XSimple> xSimple;
1463 SimpleStruct aSimpleStruct;
1464 SimpleEnum aSimpleEnum;
1465 Sequence<Any> seqAny;
1466 Sequence< sal_Int8 > seqByte;
1467 Any outAny;
1468 sal_Bool aBool;
1469 sal_Unicode aChar;
1470 float aFloat;
1471 double aDouble;
1472 sal_Int8 aByte;
1473 sal_Int16 aShort;
1474 sal_Int32 aLong;
1475 // sal_uInt16 aUShort;
1476 // sal_uInt32 aULong;
1478 switch( mode)
1480 case 1:
1481 xCallback->func1(); break;
1482 case 2:
1483 xSimple= xCallback->returnInterface();
1484 xSimple->func(L"XCallback::returnInterface");
1485 break;
1488 case 3:
1489 xCallback->outInterface( xSimple);
1490 sprintf( buff, "XCallback::outInterface, value: %x", xSimple.get());
1491 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1492 xSimple->func(L"XCallback::outInterface works");
1493 break;
1494 case 4:
1495 xCallback->outStruct( aSimpleStruct);
1496 sprintf( buff,"XCallback::outStruct, SimpleStruct::message: %s", OLE2A( aSimpleStruct.message));
1497 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1498 break;
1499 case 5:
1500 xCallback->outEnum( aSimpleEnum);
1501 sprintf( buff,"XCallback::outEnum, SimpleEnum: %d", aSimpleEnum);
1502 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1503 break;
1504 case 6:
1505 xCallback->outSeqAny( seqAny);
1506 sprintf( buff,"XCallback::outSeqAny, length: %d )", seqAny.getLength());
1507 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1508 for( i=0; i < seqAny.getLength(); i++)
1510 Any any= seqAny[i];
1511 if( any.getValueTypeClass() == TypeClass_STRING)
1513 any >>= aString;
1514 OutputDebugStringW( aString);
1518 break;
1519 case 7:
1520 xCallback->outAny( outAny);
1521 if( outAny.getValueTypeClass() == TypeClass_STRING)
1522 outAny >>= aString;
1523 sprintf( buff,"XCallback::outAny, Any : %s", W2A( aString));
1524 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1525 break;
1526 case 8:
1527 xCallback->outBool( aBool);
1528 sprintf( buff,"XCallback::outBool, value: %d", aBool);
1529 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1530 break;
1531 case 9:
1532 xCallback->outChar( aChar);
1533 sprintf( buff,"XCallback::outChar, value: %C", aChar);
1534 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1535 break;
1536 case 10:
1537 xCallback->outString( aString);
1538 sprintf( buff,"XCallback::outString, value: %s", W2A( aString));
1539 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1540 break;
1541 case 11:
1542 xCallback->outFloat( aFloat);
1543 sprintf( buff,"XCallback::outFloat, value: %f", aFloat);
1544 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1545 break;
1546 case 12:
1547 xCallback->outDouble( aDouble);
1548 sprintf( buff,"XCallback::outDouble, value: %f", aDouble);
1549 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1550 break;
1551 case 13:
1552 xCallback->outByte( aByte);
1553 sprintf( buff,"XCallback::outByte, value: %d", aByte);
1554 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1555 break;
1556 case 14:
1557 xCallback->outShort( aShort);
1558 sprintf( buff,"XCallback::outShort, value: %d", aShort);
1559 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1560 break;
1561 case 15:
1562 xCallback->outLong( aLong);
1563 sprintf( buff,"XCallback::outLong, value: %d", aLong);
1564 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1565 break;
1566 case 18:
1567 case 19:
1568 case 30:
1571 long outLong= 0;
1572 xCallback->outValuesMixed( 1111, outLong, OUString( L"in string") );
1574 sprintf( buff, "oletest.testInterface: outValue: %d", outLong);
1575 MessageBox( NULL, A2T(buff), _T("OleTest"), MB_OK);
1576 break;
1579 case 31:
1581 Reference< XSimple > xSimple;
1582 SimpleStruct aSimpleStruct;
1583 SimpleEnum aSimpleEnum;
1584 Sequence<Any> seqAny;
1585 Any aAny;
1586 sal_Bool aBool;
1587 sal_Unicode aChar;
1588 OUString aString;
1589 float aFloat;
1590 double aDouble;
1591 sal_Int8 aByte;
1592 sal_Int16 aShort;
1593 sal_Int32 aLong;
1594 // sal_uInt16 aUShort;
1595 // sal_uInt32 aULong;
1596 xCallback->outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool,
1597 aChar, aString,
1598 aFloat, aDouble,
1599 aByte,
1600 aShort, aLong);
1602 MessageBox( NULL, _T("XCallback::outValuesAll returned"), _T("OleTest::testInterface"), MB_OK);
1603 break;
1605 case 32:
1608 xCallback->outSeqByte( seqByte);
1609 sprintf( buff,"XCallback::outSeqAny, length: %d )", seqAny.getLength());
1610 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1611 for( i=0; i < seqAny.getLength(); i++)
1613 Any any= seqAny[i];
1614 if( any.getValueTypeClass() == TypeClass_STRING)
1616 any >>= aString;
1617 OutputDebugStringW( aString);
1620 break;
1622 // ############################################################################
1623 // IN OUT parameter
1624 // ############################################################################
1625 case 100:
1627 Reference<XSimple> xSimple= static_cast<XSimple*>(this);
1628 xCallback->inoutInterface( xSimple);
1629 xSimple->func(L"XSimple called from OleTest");
1630 break;
1632 case 101:
1634 Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
1635 if( xRefl.is())
1637 Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
1638 Any any;
1639 if( xClass.is())
1640 xClass->createObject( any);
1642 if( any.getValueTypeClass() == TypeClass_STRUCT)
1644 SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
1645 pStruct->message= OUString::createFromAscii("This struct was created in OleTest");
1647 SimpleStruct aStruct;
1648 any >>= aStruct;
1649 xCallback->inoutStruct( aStruct);
1650 // a Struct should now contain a different message
1651 MessageBox( NULL, W2T(aStruct.message), _T("OleTest in out parameter"), MB_OK);
1655 break;
1657 case 102:
1659 SimpleEnum aEnum= SimpleEnum_B;
1660 xCallback->inoutEnum( aEnum);
1661 char buff[1024];
1662 sprintf( buff, "Enum: %d", aEnum);
1663 MessageBox( NULL, A2T(buff), _T("OleTest in out parameter"), MB_OK);
1664 break;
1666 case 103:
1668 Any arAny[3];
1669 arAny[0] <<= OUString( L"string 0");
1670 arAny[1] <<= OUString( L"string 1");
1671 arAny[2] <<= OUString( L"string 2");
1673 Sequence< Any >seqAny( arAny, 3);
1674 xCallback->inoutSeqAny( seqAny);
1675 char buff[1023];
1676 sprintf( buff, "Sequence length: %d", seqAny.getLength());
1677 MessageBox( NULL,A2T(buff) , _T("OleTest in out parameter"), MB_OK);
1679 for( int i=0; i < seqAny.getLength(); i++)
1681 Any any;
1682 any <<= seqAny[i];
1683 if(any.getValueTypeClass() == TypeClass_STRING)
1685 OUString str;
1686 any >>= str;
1691 break;
1693 case 104:
1695 Any any;
1696 OUString s(L" OleTest");
1697 any <<= s;
1698 xCallback->inoutAny(any);
1699 if( any.getValueTypeClass() == TypeClass_STRING)
1701 OUString s= *( rtl_uString**) any.getValue();
1702 MessageBox( NULL, W2T( s), _T("OleTest: inout value any"), MB_OK);
1704 break;
1706 case 105:
1708 sal_Bool b= sal_True;
1709 xCallback->inoutBool( b);
1710 char buff[1024];
1711 sprintf( buff, "out value bool: %d", b);
1712 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1713 break;
1715 case 106:
1717 sal_Unicode uc= L'A';
1718 xCallback->inoutChar( uc);
1719 char buff[1024];
1720 sprintf( buff, "out value sal_Unicode: %C", uc);
1721 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1722 break;
1724 case 107:
1726 OUString s(L"OleTest");
1727 xCallback->inoutString( s);
1728 char buff[1024];
1729 sprintf( buff, "out value string: %S", s.getStr());
1730 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1731 break;
1733 case 108:
1735 float f= 3.14f;
1736 xCallback->inoutFloat(f);
1737 char buff[1024];
1738 sprintf( buff, "out value float: %f", f);
1739 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1740 break;
1742 case 109:
1744 double f= 3.145;
1745 xCallback->inoutDouble( f);
1746 char buff[1024];
1747 sprintf( buff, "out value double: %g", f);
1748 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1749 break;
1751 case 110:
1753 sal_Int8 aByte= 0xf;
1754 xCallback->inoutByte( aByte);
1755 char buff[1024];
1756 sprintf( buff, "out value sal_Int8: %d", aByte);
1757 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1758 break;
1760 case 111:
1762 sal_Int16 aShort= 0xff;
1763 xCallback->inoutShort( aShort);
1764 char buff[1024];
1765 sprintf( buff, "out value sal_Int16: %d", aShort);
1766 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1767 break;
1769 case 112:
1771 sal_Int32 aLong= 0xfffe;
1772 xCallback->inoutLong( aLong);
1773 char buff[1024];
1774 sprintf( buff, "out value sal_Int32: %d", aLong);
1775 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1776 break;
1778 case 120:
1780 Reference<XSimple> aXSimple= static_cast<XSimple*>(this);
1782 SimpleStruct aStruct;
1783 Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
1784 if( xRefl.is())
1786 Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
1787 Any any;
1788 if( xClass.is())
1789 xClass->createObject( any);
1791 if( any.getValueTypeClass() == TypeClass_STRUCT)
1793 SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
1794 pStruct->message= OUString::createFromAscii("This struct was created in OleTest");
1795 any >>= aStruct;
1799 SimpleEnum aEnum= SimpleEnum_B;
1801 Sequence< Any > aSeq;
1802 Any arAny[3];
1803 arAny[0] <<= OUString( L"string 0");
1804 arAny[1] <<= OUString( L"string 1");
1805 arAny[2] <<= OUString( L"string 2");
1806 aSeq = Sequence< Any >( arAny, 3);
1808 Any aAny;
1809 OUString s(L" OleTest");
1810 aAny <<= s;
1812 sal_Bool aBool= sal_True;
1813 sal_Unicode aChar= L'A';
1814 OUString aString( L"OleTest");
1815 float aFloat=3.14f;
1816 double aDouble= 3.145;
1817 sal_Int8 aByte= 0xf;
1818 sal_Int16 aShort= 0xff;
1819 sal_Int32 aLong= 0xffe;
1821 xCallback->inoutValuesAll( aXSimple, aStruct, aEnum, aSeq,
1822 aAny, aBool, aChar, aString, aFloat, aDouble,
1823 aByte, aShort, aLong );
1825 aXSimple->func(L"XSimple called from OleTest");
1826 MessageBox( NULL, W2T(aStruct.message), _T("OleTest"), MB_OK);
1828 for( int i=0; i < aSeq.getLength(); i++)
1830 Any any;
1831 any <<= aSeq[i];
1832 if(any.getValueTypeClass() == TypeClass_STRING)
1834 OUString str;
1835 any >>= str;
1839 break;
1842 // ############################################################################
1843 // IN parameter
1844 // ############################################################################
1846 case 200:
1848 xCallback->inValues( L'a', 0xffffL, OUString(L" a string from OleTest"));
1849 break;
1850 case 201:
1852 sal_Int8 arbyte[3]= { 1,2,3};
1853 Sequence< sal_Int8 > seq( arbyte, 3);
1854 xCallback->inSeqByte( seq);
1855 break;
1857 case 202:
1859 const int LISTENERS= 3;
1860 Reference<XEventListener> arListeners[LISTENERS];
1861 EventObject arEvents[LISTENERS];
1863 for( int i= 0; i < LISTENERS; i++)
1865 Reference<XInterface> aList= static_cast<XWeak*>( new EventListener());
1866 arListeners[i]= Reference<XEventListener>( aList, UNO_QUERY);
1869 xCallback->inSeqXEventListener(Sequence<Reference<XEventListener> > (arListeners, LISTENERS),
1870 Sequence<EventObject>(arEvents, LISTENERS));
1871 break;
1874 // ############################################################################
1875 // Call a COM object that has not been passed as parameter to a UNO component and
1876 // hence no type information are available in the COM wrapper
1877 // ############################################################################
1878 case 300:
1880 Reference<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.oleautomation.Factory");
1882 Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
1884 Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
1885 Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
1886 //Any SAL_CALL invoke( const OUString& aFunctionName, const Sequence<Any >& aParams,Sequence< sal_Int16 >& aOutParamIndex,
1887 // Sequence<Any >& aOutParam );
1888 Sequence<sal_Int16> seqIndizes;
1889 Sequence<Any> seqOutParams;
1890 xInv->invoke( OUString( L"outValuesAll"), Sequence<Any>(), seqIndizes, seqOutParams);
1892 // void outValuesAll( [out] oletest::XSimple outInterface,
1893 // [out] SimpleStruct outStruct ,
1894 // [out] SimpleEnum outEnum,
1895 // [out] sequence<any> outSeqAny,
1896 // [out] any outAny,
1897 // [out] boolean outBool,
1898 // [out] char outChar,
1899 // [out] string outString,
1900 // [out] float outFloat,
1901 // [out] double outDouble,
1902 // [out] byte outByte,
1903 // [out] short outShort,
1904 // [out] long outLong);
1905 if( seqOutParams.getLength() == 12)
1907 Reference<XSimple> xSimple= *(XSimple**)seqOutParams[0].getValue();
1908 xSimple->func( L"Call from OleTest on XSimple");
1909 SimpleStruct aStruct;
1910 seqOutParams[1] >>= aStruct;
1911 SimpleEnum aEnum= *(SimpleEnum*)seqOutParams[2].getValue();
1913 Sequence<Any> seqAny;
1914 seqOutParams[3] >>= seqAny;
1915 for( int i=0; i<seqAny.getLength(); i++)
1917 OUString _s;
1918 seqAny[i] >>= _s;
1921 Any _any= *(Any*)seqOutParams[4].getValue();
1922 sal_Bool _bool= *(sal_Bool*)seqOutParams[5].getValue();
1923 sal_Unicode _char= *( sal_Unicode*) seqOutParams[6].getValue();
1924 OUString _str= *( rtl_uString**)seqOutParams[7].getValue();
1926 float _f= *( float*)seqOutParams[8].getValue();
1927 double _d= *( double*) seqOutParams[9].getValue();
1928 sal_Int8 _byte= *( sal_Int8*) seqOutParams[10].getValue();
1929 sal_Int16 _short= *( sal_Int16*) seqOutParams[11].getValue();
1931 sal_Int32 _long= *( sal_Int32*) seqOutParams[12].getValue();
1934 break;
1936 case 301:
1937 // in / out parameter
1939 Reference<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.oleautomation.Factory");
1941 Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
1943 Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
1944 Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
1945 Sequence<sal_Int16> seqIndizes;
1946 Sequence<Any> seqOutParams;
1949 Any arAny[13];
1950 Reference<XSimple> xSimple= static_cast<XSimple*>( this);
1952 arAny[0] <<= xSimple;
1953 SimpleStruct aStruct;
1954 Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
1955 if( xRefl.is())
1957 Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
1958 Any any;
1959 if( xClass.is())
1960 xClass->createObject( any);
1962 if( any.getValueTypeClass() == TypeClass_STRUCT)
1964 SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
1965 pStruct->message= OUString::createFromAscii("This struct was created in OleTest");
1966 any >>= aStruct;
1969 arAny[1] <<= aStruct;
1970 arAny[2] <<= SimpleEnum_C;
1972 Any arSeqAny[3];
1973 arSeqAny[0] <<= OUString( L"string 0");
1974 arSeqAny[1] <<= OUString( L"string 1");
1975 arSeqAny[2] <<= OUString( L"string 2");
1977 arAny[3] <<= Sequence< Any >( arAny, 3);
1979 OUString str(L" Ein Any param");
1980 arAny[4] <<= str;
1981 arAny[5] <<= sal_False;
1982 arAny[6] <<= L'B';
1983 OUString stringParam(L" a string parameter");
1984 arAny[7] <<= stringParam;
1985 float _float= 3.14f;
1986 arAny[8] <<= _float;
1987 double _double= 3.145;
1988 arAny[9] <<= _double;
1989 sal_Int8 _byte= -1;
1990 arAny[10] <<= _byte;
1991 sal_Int16 _short= -1;
1992 arAny[11] <<= _short;
1993 sal_Int32 _long= -1;
1994 arAny[12] <<= _long;
1996 Sequence<Any> params( arAny, 13);
1998 xInv->invoke( OUString( L"inoutValuesAll"), params, seqIndizes, seqOutParams);
2000 if( seqOutParams.getLength() == 12)
2002 Reference<XSimple> xSimple= *(XSimple**)seqOutParams[0].getValue();
2003 xSimple->func( L"Call from OleTest on XSimple");
2004 SimpleStruct aStruct;
2005 seqOutParams[1] >>= aStruct;
2006 SimpleEnum aEnum= *(SimpleEnum*)seqOutParams[2].getValue();
2008 Sequence<Any> seqAny;
2009 seqOutParams[3] >>= seqAny;
2010 for( int i=0; i<seqAny.getLength(); i++)
2012 OUString _s;
2013 seqAny[i] >>= _s;
2016 Any _any= *(Any*)seqOutParams[4].getValue();
2017 sal_Bool _bool= *(sal_Bool*)seqOutParams[5].getValue();
2018 sal_Unicode _char= *( sal_Unicode*) seqOutParams[6].getValue();
2019 OUString _str= *( rtl_uString**)seqOutParams[7].getValue();
2021 float _f= *( float*)seqOutParams[8].getValue();
2022 double _d= *( double*) seqOutParams[9].getValue();
2023 sal_Int8 _byte= *( sal_Int8*) seqOutParams[10].getValue();
2024 sal_Int16 _short= *( sal_Int16*) seqOutParams[11].getValue();
2026 sal_Int32 _long= *( sal_Int32*) seqOutParams[12].getValue();
2029 break;
2031 case 303:
2032 // in parameter
2033 // void inValues( [in] char aChar, [in] long aLong, [in] string aString);
2035 Reference<XInterface> xIntFact = m_rFactory->createInstance(
2036 L"com.sun.star.bridge.oleautomation.Factory");
2038 Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
2040 Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
2041 Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
2042 Sequence<sal_Int16> seqIndizes;
2043 Sequence<Any> seqOutParams;
2045 Any arAny[3];
2046 sal_Unicode aChar=L'a';
2047 arAny[0] <<= aChar;
2048 sal_Int32 aLong= 0xffffffff;
2049 arAny[1] <<= aLong;
2050 OUString aString(L" a string parameter");
2051 arAny[2] <<= aString;
2053 xInv->invoke( OUString( L"inValues"), Sequence<Any>(arAny,3), seqIndizes, seqOutParams);
2055 break;
2057 // ############################################################################
2058 // Attributes
2059 // ############################################################################
2061 case 400:
2062 Reference<XSimple> simple= xCallback->getsimple();
2063 simple->func(L"OleTest calls on XSimple");
2064 break;
2073 void SAL_CALL OComponent::setObject( const Reference< XInterface >& val ) throw (RuntimeException)
2075 m_xIntIdentity= val;
2078 sal_Bool SAL_CALL OComponent::isSame( const Reference< XInterface >& val ) throw (RuntimeException)
2080 if( m_xIntIdentity == val)
2081 return sal_True;
2082 else
2083 return sal_False;
2086 Reference< XInterface > SAL_CALL OComponent::getThis( ) throw (RuntimeException)
2088 // return Reference<XInterface>(static_cast<XIdentity*>(this), UNO_QUERY);
2089 Reference<XInterface> ret(static_cast<XIdentity*>(this), UNO_QUERY);
2090 return ret;
2093 void SAL_CALL EventListener::disposing( const ::com::sun::star::lang::EventObject& ) throw (RuntimeException)
2095 bCalled= sal_True;
2098 // XSimple --------------------------------------------------------------------------
2099 void SAL_CALL OComponent::func( const OUString &message)throw(::com::sun::star::uno::RuntimeException)
2101 USES_CONVERSION;
2103 MessageBox( NULL, W2T( message.getStr()), _T("OleTest: XSimple::func"), MB_OK);
2105 // XSimple --------------------------------------------------------------------------
2106 OUString SAL_CALL OComponent::getName()throw(::com::sun::star::uno::RuntimeException)
2108 return L"XSimple";
2110 void SAL_CALL OComponent::testInterface2( const Reference< XSimple >& xSimple, sal_Int32 mode ) throw(RuntimeException)
2112 switch( mode)
2114 case 0:
2116 xSimple->func( L"OleTest is calling XSimple");
2117 Reference<XSimple2> xSimple2( xSimple, UNO_QUERY);
2118 if( xSimple2.is())
2119 xSimple2->func2( L"OleTest is calling XSimple2");
2120 Reference<XSimple3> xSimple3( xSimple, UNO_QUERY);
2121 if( xSimple3.is())
2122 xSimple3->func3( L"OleTest is calling XSimple3");
2124 break;