Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / extensions / test / ole / cpnt / cpnt.cxx
blob5ef2e052e563aa45467c3eba3c0ad67113ed3bfa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #if !defined WIN32_LEAN_AND_MEAN
21 # define WIN32_LEAN_AND_MEAN
22 #endif
23 #include <windows.h>
24 #include <atlbase.h>
25 #include <stdio.h>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/registry/XRegistryKey.hpp>
28 #include <osl/diagnose.h>
29 #include <uno/environment.h>
30 #include <comphelper/processfactory.hxx>
31 #include <cppuhelper/factory.hxx>
32 // OPTIONAL is a constant in com.sun.star.beans.PropertyAttributes but it must be
33 // undef'd in some header files
34 #define OPTIONAL OPTIONAL
35 #include <com/sun/star/beans/PropertyAttribute.hpp>
36 #include <com/sun/star/script/XInvocation.hpp>
37 #include <com/sun/star/reflection/theCoreReflection.hpp>
38 #include <com/sun/star/reflection/XIdlReflection.hpp>
39 #include <com/sun/star/lang/XEventListener.hpp>
41 #include <cppuhelper/implbase.hxx>
42 #include <com/sun/star/uno/Reference.h>
43 #include <rtl/ustring.h>
44 #include <com/sun/star/uno/Reference.hxx>
45 #include <oletest/XTestSequence.hpp>
46 #include <oletest/XTestStruct.hpp>
47 #include <oletest/XTestOther.hpp>
48 #include <oletest/XTestInterfaces.hpp>
49 #include <oletest/XSimple.hpp>
50 #include <oletest/XSimple2.hpp>
51 #include <oletest/XSimple3.hpp>
52 #include <oletest/XTestInParameters.hpp>
53 #include <oletest/XIdentity.hpp>
54 #include <com/sun/star/beans/Property.hpp>
55 using namespace cppu;
56 using namespace osl;
57 using namespace oletest;
58 using namespace com::sun::star::uno;
59 using namespace com::sun::star::lang;
60 using namespace com::sun::star::beans;
61 using namespace com::sun::star::registry;
62 using namespace com::sun::star::script;
63 using namespace com::sun::star::reflection;
66 #define IMPL_NAME L"oletest.OleTestImpl" // oletest.OleTestImpl in applicat.rdb
67 #define SERVICE_NAME L"oletest.OleTest"
68 #define KEY1 L"/oletest.OleTestImpl/UNO/SERVICES"
69 #define KEY2 L"oletest.OleTest"
71 class OComponent : public WeakImplHelper<
72 XTestSequence, XTestStruct, XTestOther, XTestInterfaces,
73 XSimple, XTestInParameters, XIdentity >
75 Reference<XInterface> m_xIntIdentity;
76 sal_Int32 m_arrayConstructor;
77 Reference<XMultiServiceFactory> m_rFactory;
79 Sequence<sal_Int8> m_seqByte;
80 Sequence<float> m_seqFloat;
81 Sequence<double> m_seqDouble;
82 Sequence<sal_Bool> m_seqBool;
83 Sequence<sal_Int16> m_seqShort;
84 Sequence<sal_uInt16> m_seqUShort;
85 Sequence<sal_Int32> m_seqLong;
86 Sequence<sal_uInt32> m_seqULong;
87 Sequence<sal_Unicode> m_seqChar;
88 Sequence<OUString> m_seqString;
89 Sequence<Any> m_seqAny;
90 Sequence<Type> m_seqType;
91 Sequence<Sequence< sal_Int32> > m_seq1;
92 Sequence<Sequence< Sequence< sal_Int32> > > m_seq2;
93 Any m_any;
94 Type m_type;
95 Sequence<Reference< XInterface > > m_seqxInterface;
97 sal_Int8 m_int8;
98 sal_uInt8 m_uint8;
99 sal_Int16 m_int16;
100 sal_uInt16 m_uint16;
101 sal_Int32 m_int32;
102 sal_uInt32 m_uint32;
103 sal_Int64 m_int64;
104 sal_uInt64 m_uint64;
105 float m_float;
106 double m_double;
107 OUString m_string;
108 sal_Unicode m_char;
109 sal_Bool m_bool;
110 Reference<XInterface> m_xinterface;
112 sal_Int8 m_attr_int8;
113 sal_uInt8 m_attr_uint8;
114 sal_Int16 m_attr_int16;
115 sal_uInt16 m_attr_uint16;
116 sal_Int32 m_attr_int32;
117 sal_uInt32 m_attr_uint32;
118 sal_Int64 m_attr_int64;
119 sal_uInt64 m_attr_uint64;
120 float m_attr_float;
121 double m_attr_double;
122 OUString m_attr_string;
123 sal_Unicode m_attr_char;
124 sal_Bool m_attr_bool;
125 Any m_attr_any;
126 Type m_attr_type;
127 Reference<XInterface> m_attr_xinterface;
128 Reference<XInvocation> m_attr_xinvocation;
130 public:
131 OComponent( const Reference<XMultiServiceFactory> & rFactory ) :
132 m_rFactory( rFactory ), m_arrayConstructor(0) {}
133 ~OComponent();
134 public: // XTestSequence
135 virtual Sequence<sal_Int8> SAL_CALL methodByte(const Sequence< sal_Int8 >& aSeq) throw( RuntimeException );
136 virtual Sequence<float> SAL_CALL methodFloat(const Sequence< float >& aSeq) throw( RuntimeException );
137 virtual Sequence< double > SAL_CALL methodDouble(const Sequence< double >& aSeq) throw( RuntimeException);
138 virtual Sequence< sal_Bool > SAL_CALL methodBool(const Sequence< sal_Bool >& aSeq) throw( RuntimeException );
139 virtual Sequence< sal_Int16 > SAL_CALL methodShort(const Sequence< sal_Int16 >& aSeq) throw( RuntimeException );
140 virtual Sequence< sal_uInt16 > SAL_CALL methodUShort(const Sequence< sal_uInt16 >& aSeq) throw( RuntimeException );
141 virtual Sequence< sal_Int32 > SAL_CALL methodLong(const Sequence< sal_Int32 >& aSeq) throw( RuntimeException) ;
142 virtual Sequence< sal_uInt32 > SAL_CALL methodULong(const Sequence< sal_uInt32 >& aSeq) throw( RuntimeException );
143 virtual Sequence< OUString > SAL_CALL methodString(const Sequence< OUString >& aSeq) throw( RuntimeException );
144 virtual Sequence< sal_Unicode > SAL_CALL methodChar(const Sequence< sal_Unicode >& aSeq) throw( RuntimeException );
145 virtual Sequence< Any > SAL_CALL methodAny(const Sequence< Any >& aSeq) throw( RuntimeException );
146 virtual Sequence< Type > SAL_CALL methodType(const Sequence< Type >& aSeq) throw( RuntimeException );
147 virtual Sequence< Reference< XInterface > > SAL_CALL methodXInterface( const Sequence< Reference< XInterface > >& aSeq ) throw(RuntimeException) ;
148 virtual Sequence< Sequence< sal_Int32 > > SAL_CALL methodSequence(const Sequence< Sequence< sal_Int32 > >& aSeq) throw( RuntimeException );
149 virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL methodSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq) throw( RuntimeException );
150 virtual Sequence< Reference<XEventListener> > SAL_CALL methodXEventListeners( const Sequence<Reference<XEventListener> >& aSeq) throw( RuntimeException);
151 virtual Sequence< Sequence<Reference<XEventListener > > > SAL_CALL methodXEventListenersMul( const Sequence<Sequence<Reference<XEventListener > > >& aSeq ) throw (RuntimeException);
153 virtual Sequence< sal_Int8 > SAL_CALL getAttrByte() throw( RuntimeException );
154 virtual void SAL_CALL setAttrByte(const Sequence< sal_Int8 >& AttrByte_) throw( RuntimeException );
155 virtual Sequence< float > SAL_CALL getAttrFloat() throw( RuntimeException) ;
156 virtual void SAL_CALL setAttrFloat(const Sequence< float >& AttrFloat_) throw( RuntimeException );
157 virtual Sequence< double > SAL_CALL getAttrDouble() throw( RuntimeException) ;
158 virtual void SAL_CALL setAttrDouble(const Sequence< double >& AttrDouble_) throw( RuntimeException );
159 virtual Sequence< sal_Bool > SAL_CALL getAttrBool() throw( RuntimeException );
160 virtual void SAL_CALL setAttrBool(const Sequence< sal_Bool >& AttrBool_) throw( RuntimeException );
161 virtual Sequence< sal_Int16 > SAL_CALL getAttrShort() throw( RuntimeException );
162 virtual void SAL_CALL setAttrShort(const Sequence< sal_Int16 >& AttrShort_) throw( RuntimeException );
163 virtual Sequence< sal_uInt16 > SAL_CALL getAttrUShort() throw( RuntimeException );
164 virtual void SAL_CALL setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_) throw( RuntimeException );
165 virtual Sequence< sal_Int32 > SAL_CALL getAttrLong() throw( RuntimeException );
166 virtual void SAL_CALL setAttrLong(const Sequence< sal_Int32 >& AttrLong_) throw( RuntimeException );
167 virtual Sequence< sal_uInt32 > SAL_CALL getAttrULong() throw( RuntimeException );
168 virtual void SAL_CALL setAttrULong(const Sequence< sal_uInt32 >& AttrULong_) throw( RuntimeException );
169 virtual Sequence< OUString > SAL_CALL getAttrString() throw(RuntimeException );
170 virtual void SAL_CALL setAttrString(const Sequence< OUString >& AttrString_) throw( RuntimeException );
171 virtual Sequence< sal_Unicode > SAL_CALL getAttrChar() throw( RuntimeException );
172 virtual void SAL_CALL setAttrChar(const Sequence< sal_Unicode >& AttrChar_) throw( RuntimeException );
173 virtual Sequence< Any > SAL_CALL getAttrAny() throw( RuntimeException );
174 virtual void SAL_CALL setAttrAny(const Sequence< Any >& AttrAny_) throw( RuntimeException );
175 virtual Sequence< Type > SAL_CALL getAttrType() throw( RuntimeException );
176 virtual void SAL_CALL setAttrType( const Sequence< Type >& _attrtype ) throw (RuntimeException);
177 virtual Sequence< Sequence< sal_Int32 > > SAL_CALL getAttrSequence() throw( RuntimeException );
178 virtual void SAL_CALL setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence_) throw( RuntimeException );
179 virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL getAttrSequence2() throw( RuntimeException );
180 virtual void SAL_CALL setAttrSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& AttrSequence2_) throw ( RuntimeException );
181 virtual Sequence< Reference< XInterface > > SAL_CALL getAttrXInterface() throw(RuntimeException);
182 virtual void SAL_CALL setAttrXInterface( const Sequence< Reference< XInterface > >& _attrxinterface ) throw(RuntimeException);
184 virtual ::sal_Int8 SAL_CALL getAByte() throw (RuntimeException);
185 virtual void SAL_CALL setAByte( ::sal_Int8 _abyte ) throw (RuntimeException);
186 virtual float SAL_CALL getAFloat() throw (RuntimeException);
187 virtual void SAL_CALL setAFloat( float _afloat ) throw (RuntimeException);
188 virtual double SAL_CALL getADouble() throw (RuntimeException);
189 virtual void SAL_CALL setADouble( double _adouble ) throw (RuntimeException);
190 virtual sal_Bool SAL_CALL getABool() throw (RuntimeException);
191 virtual void SAL_CALL setABool( sal_Bool _abool ) throw (RuntimeException);
192 virtual ::sal_Int16 SAL_CALL getAShort() throw (RuntimeException);
193 virtual void SAL_CALL setAShort( ::sal_Int16 _ashort ) throw (RuntimeException);
194 virtual ::sal_uInt16 SAL_CALL getAUShort() throw (RuntimeException);
195 virtual void SAL_CALL setAUShort( ::sal_uInt16 _aushort ) throw (RuntimeException);
196 virtual ::sal_Int32 SAL_CALL getALong() throw (RuntimeException);
197 virtual void SAL_CALL setALong( ::sal_Int32 _along ) throw (RuntimeException);
198 virtual ::sal_uInt32 SAL_CALL getAULong() throw (RuntimeException);
199 virtual void SAL_CALL setAULong( ::sal_uInt32 _aulong ) throw (RuntimeException);
200 virtual OUString SAL_CALL getAString() throw (RuntimeException);
201 virtual void SAL_CALL setAString( const OUString& _astring ) throw (RuntimeException);
202 virtual ::sal_Unicode SAL_CALL getAChar() throw (RuntimeException);
203 virtual void SAL_CALL setAChar( ::sal_Unicode _achar ) throw (RuntimeException);
204 virtual Any SAL_CALL getAAny() throw (RuntimeException);
205 virtual void SAL_CALL setAAny( const Any& _aany ) throw (RuntimeException);
206 virtual Type SAL_CALL getAType() throw (RuntimeException);
207 virtual void SAL_CALL setAType( const Type& _atype ) throw (RuntimeException);
208 virtual Reference< XInterface > SAL_CALL getAXInterface() throw (RuntimeException);
209 virtual void SAL_CALL setAXInterface( const Reference<XInterface >& _axinterface ) throw (RuntimeException);
210 virtual Reference<XInvocation > SAL_CALL getAXInvocation() throw (RuntimeException);
211 virtual void SAL_CALL setAXInvocation( const Reference< XInvocation >& _axinvocation ) throw (RuntimeException);
213 virtual void SAL_CALL testout_methodByte(sal_Int8& rOut) throw( RuntimeException );
214 virtual void SAL_CALL testout_methodFloat(float& rOut) throw( RuntimeException );
215 virtual void SAL_CALL testout_methodDouble(double& rOut) throw( RuntimeException );
216 virtual void SAL_CALL testout_methodBool(sal_Bool& rOut) throw( RuntimeException );
217 virtual void SAL_CALL testout_methodShort(sal_Int16& rOut) throw( RuntimeException );
218 virtual void SAL_CALL testout_methodUShort(sal_uInt16& rOut) throw( RuntimeException );
219 virtual void SAL_CALL testout_methodLong(sal_Int32& rOut) throw( RuntimeException );
220 virtual void SAL_CALL testout_methodULong(sal_uInt32& rOut) throw( RuntimeException );
221 virtual void SAL_CALL testout_methodHyper(sal_Int64& rOut) throw( RuntimeException );
222 virtual void SAL_CALL testout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException );
223 virtual void SAL_CALL testout_methodString(OUString& rOut) throw( RuntimeException );
224 virtual void SAL_CALL testout_methodChar(sal_Unicode& rOut) throw( RuntimeException );
225 virtual void SAL_CALL testout_methodAny(Any& rOut) throw( RuntimeException );
226 virtual void SAL_CALL testout_methodType(Type& rOut) throw( RuntimeException );
227 virtual void SAL_CALL testout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException );
228 virtual void SAL_CALL testout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException );
229 virtual void SAL_CALL testout_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException );
230 virtual void SAL_CALL testout_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException );
231 virtual void SAL_CALL testout_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException );
232 virtual void SAL_CALL testout_methodMulParams4( float in1, float& out1, sal_Int32 in2, sal_Int32& out2, sal_Int32 in3 ) throw(RuntimeException);
233 virtual void SAL_CALL testout_methodXInterface( Reference< XInterface >& rOut ) throw(RuntimeException);
235 virtual void SAL_CALL testinout_methodByte(sal_Int8& rOut) throw( RuntimeException );
236 virtual void SAL_CALL testinout_methodFloat(float& rOut) throw( RuntimeException );
237 virtual void SAL_CALL testinout_methodDouble(double& rOut) throw( RuntimeException );
238 virtual void SAL_CALL testinout_methodBool(sal_Bool& rOut) throw( RuntimeException );
239 virtual void SAL_CALL testinout_methodShort(sal_Int16& rOut) throw( RuntimeException );
240 virtual void SAL_CALL testinout_methodUShort(sal_uInt16& rOut) throw( RuntimeException );
241 virtual void SAL_CALL testinout_methodLong(sal_Int32& rOut) throw( RuntimeException );
242 virtual void SAL_CALL testinout_methodULong(sal_uInt32& rOut) throw( RuntimeException );
243 virtual void SAL_CALL testinout_methodHyper(sal_Int64& rOut) throw( RuntimeException );
244 virtual void SAL_CALL testinout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException );
245 virtual void SAL_CALL testinout_methodString(OUString& rOut) throw( RuntimeException );
246 virtual void SAL_CALL testinout_methodChar(sal_Unicode& rOut) throw( RuntimeException );
247 virtual void SAL_CALL testinout_methodAny(Any& rOut) throw( RuntimeException );
248 virtual void SAL_CALL testinout_methodType(Type& rOut) throw( RuntimeException );
249 virtual void SAL_CALL testinout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException );
250 virtual void SAL_CALL testinout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException );
251 virtual void SAL_CALL testinout_methodXInterface( Reference< XInvocation >& rOut ) throw(RuntimeException);
252 virtual void SAL_CALL testinout_methodXInterface2( Reference< XInterface > & rOut) throw( RuntimeException);
253 virtual Any SAL_CALL methodAnyTest1(const Any& rIn) throw( RuntimeException ) ;
254 virtual Any SAL_CALL getAttrAny2() throw( RuntimeException ) ;
255 virtual void SAL_CALL setAttrAny2(const Any& AttrAny2_) throw( RuntimeException ) ;
258 // XTestStruct
259 virtual void SAL_CALL methodStruct(const Property& aProp) throw( RuntimeException );
261 virtual Property SAL_CALL retMethodStruct() throw( RuntimeException );
263 virtual Property SAL_CALL getAttrStruct() throw( RuntimeException );
264 virtual void SAL_CALL setAttrStruct(const Property& AttrStruct_) throw( RuntimeException );
265 virtual Property SAL_CALL methodStruct2( const Property& aProp ) throw (RuntimeException);
267 // XTestOther
268 virtual void SAL_CALL other_methodAnyIn(const Any& rAny) throw( RuntimeException );
269 virtual void SAL_CALL other_methodAnyOut(Any& rAny) throw( RuntimeException );
270 virtual Any SAL_CALL other_methodAnyRet() throw( RuntimeException );
271 virtual void SAL_CALL in_float( float val) throw ( RuntimeException);
272 virtual Any SAL_CALL other_methodAny( const Any& rAny, const OUString& typeInAny )
273 throw (RuntimeException);
275 // XTestInParameters
276 virtual sal_Int8 SAL_CALL in_methodByte( sal_Int8 rIn ) throw (RuntimeException);
277 virtual float SAL_CALL in_methodFloat( float rIn ) throw (RuntimeException);
278 virtual double SAL_CALL in_methodDouble( double rIn ) throw (RuntimeException);
279 virtual sal_Bool SAL_CALL in_methodBool( sal_Bool rIn ) throw (RuntimeException);
280 virtual sal_Int16 SAL_CALL in_methodShort( sal_Int16 rIn ) throw (RuntimeException);
281 virtual sal_uInt16 SAL_CALL in_methodUShort( sal_uInt16 rIn ) throw (RuntimeException);
282 virtual sal_Int32 SAL_CALL in_methodLong( sal_Int32 rIn ) throw (RuntimeException);
283 virtual sal_uInt32 SAL_CALL in_methodULong( sal_uInt32 rIn ) throw (RuntimeException);
284 virtual sal_Int64 SAL_CALL in_methodHyper( sal_Int64 rIn ) throw (RuntimeException);
285 virtual sal_uInt64 SAL_CALL in_methodUHyper( sal_uInt64 rIn ) throw (RuntimeException);
286 virtual OUString SAL_CALL in_methodString( const OUString& rIn ) throw (RuntimeException);
287 virtual sal_Unicode SAL_CALL in_methodChar( sal_Unicode rIn ) throw (RuntimeException);
288 virtual Any SAL_CALL in_methodAny( const Any& rIn ) throw (RuntimeException);
289 virtual Type SAL_CALL in_methodType( const Type& rIn ) throw (RuntimeException);
290 virtual Reference<XInterface> SAL_CALL in_methodXInterface( const Reference< XInterface >& rIn ) throw (RuntimeException);
291 virtual Reference<XInvocation > SAL_CALL in_methodInvocation( const Reference< XInvocation >& inv ) throw (RuntimeException);
292 virtual SimpleStruct SAL_CALL in_methodStruct( const SimpleStruct& aStruct ) throw (RuntimeException);
293 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);
295 // XTestInterfaces --------------------------------------------------------------------------
296 virtual void SAL_CALL testInterface( const Reference< XCallback >& xCallback, sal_Int32 mode ) throw(RuntimeException);
297 virtual void SAL_CALL testInterface2( const Reference< XSimple >& xSimple, sal_Int32 mode ) throw(RuntimeException);
298 // XSimple --------------------------------------------------------------------------
299 void SAL_CALL func( const OUString &message) throw(css::uno::RuntimeException);
300 OUString SAL_CALL getName() throw(css::uno::RuntimeException);
302 // XIdentity
303 virtual void SAL_CALL setObject( const Reference< XInterface >& val ) throw (RuntimeException);
304 virtual sal_Bool SAL_CALL isSame( const Reference< XInterface >& val ) throw (RuntimeException);
305 virtual Reference< XInterface > SAL_CALL getThis( ) throw (RuntimeException);
308 class EventListener: public WeakImplHelper<XEventListener>
310 public:
311 EventListener(): bCalled( sal_False)
313 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw (RuntimeException);
315 sal_Bool bCalled;
319 OComponent::~OComponent()
324 // functions ==============================================================================
326 Reference<XInterface> SAL_CALL OComponent_CreateInstance( const Reference<XMultiServiceFactory> & rSMgr ) throw(RuntimeException)
328 // Reference<XInterface> xService(static_cast<XWeak*>(new OComponent( rSMgr )), UNO_QUERY);
329 OComponent* o= new OComponent( rSMgr );
330 Reference<XInterface> xService(static_cast<XIdentity*>(o), UNO_QUERY);
331 return xService;
334 Sequence<OUString> OComponent_getSupportedServiceNames()
336 Sequence<OUString> aRet { SERVICE_NAME;//ODataInputStream_getImplementationName() };
338 return aRet;
342 extern "C" sal_Bool SAL_CALL component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey )
344 if(pRegistryKey)
348 Reference<XRegistryKey> xNewKey =
349 reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(KEY1);
350 xNewKey->createKey( KEY2);
351 return sal_True;
354 catch(InvalidRegistryException &)
356 OSL_FAIL( "### InvalidRegistryException!");
359 return sal_False;
362 extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
363 const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
365 static void * pRet= NULL;
366 if( ! pRet)
368 OUString aImplName( OUString::createFromAscii( pImplName ) );
369 if (pServiceManager && aImplName.equals( IMPL_NAME ))
371 Reference<XMultiServiceFactory> xMulFac(
372 reinterpret_cast< XMultiServiceFactory*>(pServiceManager));
374 Sequence<OUString> seqServiceNames;
375 Reference<XSingleServiceFactory> xFactory = createOneInstanceFactory( xMulFac, SERVICE_NAME,
376 OComponent_CreateInstance, seqServiceNames);
378 if (xFactory.is())
380 xFactory->acquire();
381 pRet = xFactory.get();
385 return pRet;
389 // XTestSequence ============================================================================
390 Sequence<sal_Int8> SAL_CALL OComponent::methodByte(const Sequence< sal_Int8 >& aSeq) throw( RuntimeException )
392 sal_Int8 _x;
393 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
394 _x= aSeq.getConstArray()[i];
396 return aSeq;
398 Sequence<float> SAL_CALL OComponent::methodFloat(const Sequence< float>& aSeq) throw( RuntimeException )
400 float _x;
401 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
402 _x= aSeq.getConstArray()[i];
404 return aSeq;
406 Sequence<double> SAL_CALL OComponent::methodDouble(const Sequence< double >& aSeq) throw( RuntimeException)
408 double _x;
409 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
410 _x= aSeq.getConstArray()[i];
412 return aSeq;
414 Sequence< sal_Bool > SAL_CALL OComponent::methodBool(const Sequence< sal_Bool >& aSeq) throw( RuntimeException)
416 sal_Bool _x;
417 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
418 _x= aSeq.getConstArray()[i];
420 return aSeq;
422 Sequence< sal_Int16 > SAL_CALL OComponent::methodShort(const Sequence< sal_Int16 >& aSeq) throw( RuntimeException )
424 sal_Int16 _x;
425 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
426 _x= aSeq.getConstArray()[i];
428 return aSeq;
430 Sequence< sal_uInt16 > SAL_CALL OComponent::methodUShort(const Sequence< sal_uInt16 >& aSeq) throw( RuntimeException )
432 sal_uInt16 _x;
433 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
434 _x= aSeq.getConstArray()[i];
436 return aSeq;
438 Sequence< sal_Int32 > SAL_CALL OComponent::methodLong(const Sequence< sal_Int32 >& aSeq) throw( RuntimeException)
440 sal_Int32 _x;
441 for( sal_Int16 i= 0; i < aSeq.getLength(); i++) {
442 _x= aSeq.getConstArray()[i];
444 return aSeq;
446 Sequence< sal_uInt32 > SAL_CALL OComponent::methodULong(const Sequence< sal_uInt32 >& aSeq) throw( RuntimeException)
448 sal_uInt32 _x;
449 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
450 _x= aSeq.getConstArray()[i];
452 return aSeq;
454 Sequence< OUString > SAL_CALL OComponent::methodString(const Sequence< OUString >& aSeq) throw( RuntimeException)
456 OUString _x;
457 for( sal_Int16 i= 0; i < aSeq.getLength(); i++) {
458 _x= aSeq.getConstArray()[i];
460 return aSeq;
462 Sequence< sal_Unicode > SAL_CALL OComponent::methodChar(const Sequence< sal_Unicode >& aSeq) throw( RuntimeException)
464 sal_Unicode _x;
465 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
466 _x= aSeq.getConstArray()[i];
468 return aSeq;
470 Sequence< Any > SAL_CALL OComponent::methodAny(const Sequence< Any >& aSeq) throw( RuntimeException)
472 Any _x;
473 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
474 _x= aSeq.getConstArray()[i];
475 TypeClass _t= _x.getValueTypeClass();
476 if( _t== TypeClass_STRING)
477 OUString s(* (rtl_uString**)_x.getValue());
479 return aSeq;
483 Sequence< Type > SAL_CALL OComponent::methodType(const Sequence< Type >& aSeq) throw( RuntimeException )
485 Type _x;
486 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
487 _x= aSeq.getConstArray()[i];
489 return aSeq;
492 Sequence< Reference< XInterface > > SAL_CALL OComponent::methodXInterface( const Sequence< Reference< XInterface > >& aSeq ) throw(RuntimeException)
494 for( sal_Int32 i= 0; i < aSeq.getLength(); i++)
496 Reference<XInterface> xInt= aSeq[i];
497 Reference<XEventListener> xList( xInt, UNO_QUERY);
498 if( xList.is())
499 xList->disposing( EventObject());
501 return aSeq;
504 Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::methodSequence(const Sequence< Sequence< sal_Int32 > >& aSeq) throw( RuntimeException)
506 sal_Int32 value;
507 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
508 const Sequence<sal_Int32>& rseq2= aSeq.getConstArray()[i];
509 for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
510 value= rseq2.getConstArray()[j];
513 return aSeq;
515 Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL OComponent::methodSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq)
516 throw( RuntimeException )
518 sal_Int32 value;
519 sal_Int32 len= aSeq.getLength();
520 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
521 const Sequence< Sequence<sal_Int32> >& rseq2= aSeq.getConstArray()[i];
522 len= rseq2.getLength();
524 for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
525 const Sequence<sal_Int32> & rseq3= rseq2.getConstArray()[j];
526 len= rseq3.getLength();
528 for (sal_Int16 k= 0; k < rseq3.getLength(); k++)
529 value= rseq3.getConstArray()[k];
532 return aSeq;
535 Sequence< Reference< XEventListener> > SAL_CALL OComponent::methodXEventListeners( const Sequence< Reference <XEventListener> >& aSeq) throw( RuntimeException)
537 Reference<XEventListener> listener;
538 for( int i= 0; i < aSeq.getLength(); i++)
540 listener= aSeq[i];
542 listener->disposing( EventObject() );
545 return aSeq;
548 Sequence< Sequence<Reference<XEventListener > > > SAL_CALL OComponent::methodXEventListenersMul( const Sequence<Sequence<Reference<XEventListener > > >& aSeq ) throw (RuntimeException)
550 Reference<XEventListener> listener;
551 for( int i= 0; i < aSeq.getLength(); i++)
553 Sequence<Reference<XEventListener> > seqInner= aSeq[i];
554 for( int j= 0; j < seqInner.getLength(); j++)
556 listener= seqInner[j];
557 listener->disposing( EventObject() );
560 return aSeq;
564 Sequence< sal_Int8 > SAL_CALL OComponent::getAttrByte() throw( RuntimeException)
566 return m_seqByte;
568 void SAL_CALL OComponent::setAttrByte(const Sequence< sal_Int8 >& AttrByte_) throw( RuntimeException )
570 m_seqByte= AttrByte_;
572 Sequence< float > SAL_CALL OComponent::getAttrFloat() throw( RuntimeException )
574 return m_seqFloat;
576 void SAL_CALL OComponent::setAttrFloat(const Sequence< float >& AttrFloat_) throw( RuntimeException )
578 m_seqFloat= AttrFloat_;
581 Sequence< double > SAL_CALL OComponent::getAttrDouble() throw( RuntimeException )
583 return m_seqDouble;
585 void SAL_CALL OComponent::setAttrDouble(const Sequence< double >& AttrDouble_) throw( RuntimeException )
587 m_seqDouble= AttrDouble_;
590 Sequence< sal_Bool > SAL_CALL OComponent::getAttrBool() throw( RuntimeException)
592 return m_seqBool;
595 void SAL_CALL OComponent::setAttrBool(const Sequence< sal_Bool >& AttrBool_) throw (RuntimeException )
597 m_seqBool= AttrBool_;
600 Sequence< sal_Int16 > SAL_CALL OComponent::getAttrShort() throw( RuntimeException)
602 return m_seqShort;
604 void SAL_CALL OComponent::setAttrShort(const Sequence< sal_Int16 >& AttrShort_) throw( RuntimeException )
606 m_seqShort= AttrShort_;
609 Sequence< sal_uInt16 > SAL_CALL OComponent::getAttrUShort() throw( RuntimeException )
611 return m_seqUShort;
613 void SAL_CALL OComponent::setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_) throw( RuntimeException )
615 m_seqUShort= AttrUShort_;
618 Sequence< sal_Int32 > SAL_CALL OComponent::getAttrLong() throw( RuntimeException)
620 return m_seqLong;
622 void SAL_CALL OComponent::setAttrLong(const Sequence< sal_Int32 >& AttrLong_) throw( RuntimeException )
624 m_seqLong= AttrLong_;
627 Sequence< sal_uInt32 > SAL_CALL OComponent::getAttrULong() throw( RuntimeException )
629 return m_seqULong;
631 void SAL_CALL OComponent::setAttrULong(const Sequence< sal_uInt32 >& AttrULong_) throw( RuntimeException )
633 m_seqULong= AttrULong_;
636 Sequence< OUString > SAL_CALL OComponent::getAttrString() throw( RuntimeException )
638 return m_seqString;
640 void SAL_CALL OComponent::setAttrString(const Sequence< OUString >& AttrString_) throw( RuntimeException )
642 m_seqString= AttrString_;
645 Sequence< sal_Unicode > SAL_CALL OComponent::getAttrChar() throw( RuntimeException )
647 return m_seqChar;
649 void SAL_CALL OComponent::setAttrChar(const Sequence< sal_Unicode >& AttrChar_) throw( RuntimeException)
651 m_seqChar= AttrChar_;
654 Sequence< Any > SAL_CALL OComponent::getAttrAny() throw( RuntimeException)
656 return m_seqAny;
658 void SAL_CALL OComponent::setAttrAny(const Sequence< Any >& AttrAny_) throw( RuntimeException )
660 m_seqAny= AttrAny_;
663 Sequence< Type > SAL_CALL OComponent::getAttrType() throw( RuntimeException )
665 return m_seqType;
668 void SAL_CALL OComponent::setAttrType( const Sequence< Type >& AttrType_) throw( RuntimeException )
670 m_seqType = AttrType_;
674 Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::getAttrSequence() throw( RuntimeException)
676 return m_seq1;
678 void SAL_CALL OComponent::setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence) throw(RuntimeException )
680 sal_Int32 x= 0;
681 for( sal_Int32 i=0; i < AttrSequence.getLength(); i++)
683 Sequence< sal_Int32 > seq= AttrSequence[i];
685 for ( sal_Int32 j=0; j < seq.getLength(); j++)
687 x= seq[j];
691 m_seq1= AttrSequence;
694 Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL OComponent::getAttrSequence2() throw( RuntimeException )
696 return m_seq2;
698 void SAL_CALL OComponent::setAttrSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& AttrSequence2_)
699 throw( RuntimeException )
701 m_seq2= AttrSequence2_;
704 Sequence< Reference< XInterface > > SAL_CALL OComponent::getAttrXInterface() throw(RuntimeException)
706 return m_seqxInterface;
708 void SAL_CALL OComponent::setAttrXInterface( const Sequence< Reference< XInterface > >& _attrxinterface ) throw(RuntimeException)
710 m_seqxInterface= _attrxinterface;
714 ::sal_Int8 SAL_CALL OComponent::getAByte() throw (RuntimeException)
716 return m_attr_int8;
719 void SAL_CALL OComponent::setAByte( ::sal_Int8 _abyte ) throw (RuntimeException)
721 m_attr_int8 = _abyte;
724 float SAL_CALL OComponent::getAFloat() throw (RuntimeException)
726 return m_attr_float;
729 void SAL_CALL OComponent::setAFloat( float _afloat ) throw (RuntimeException)
731 m_attr_float = _afloat;
734 double SAL_CALL OComponent::getADouble() throw (RuntimeException)
736 return m_attr_double;
739 void SAL_CALL OComponent::setADouble( double _adouble ) throw (RuntimeException)
741 m_attr_double = _adouble;
744 sal_Bool SAL_CALL OComponent::getABool() throw (RuntimeException)
746 return m_attr_bool;
749 void SAL_CALL OComponent::setABool( sal_Bool _abool ) throw (RuntimeException)
751 m_attr_bool = _abool;
754 ::sal_Int16 SAL_CALL OComponent::getAShort() throw (RuntimeException)
756 return m_attr_int16;
759 void SAL_CALL OComponent::setAShort( ::sal_Int16 _ashort ) throw (RuntimeException)
761 m_attr_int16 = _ashort;
764 ::sal_uInt16 SAL_CALL OComponent::getAUShort() throw (RuntimeException)
766 return m_attr_uint16;
769 void SAL_CALL OComponent::setAUShort( ::sal_uInt16 _aushort ) throw (RuntimeException)
771 m_attr_uint16 = _aushort;
774 ::sal_Int32 SAL_CALL OComponent::getALong() throw (RuntimeException)
776 return m_attr_int32;
779 void SAL_CALL OComponent::setALong( ::sal_Int32 _along ) throw (RuntimeException)
781 m_attr_int32 = _along;
784 ::sal_uInt32 SAL_CALL OComponent::getAULong() throw (RuntimeException)
786 return m_attr_uint32;
789 void SAL_CALL OComponent::setAULong( ::sal_uInt32 _aulong ) throw (RuntimeException)
791 m_attr_uint32 = _aulong;
794 OUString SAL_CALL OComponent::getAString() throw (RuntimeException)
796 return m_attr_string;
799 void SAL_CALL OComponent::setAString( const OUString& _astring ) throw (RuntimeException)
801 m_attr_string = _astring;
804 ::sal_Unicode SAL_CALL OComponent::getAChar() throw (RuntimeException)
806 return m_attr_char;
809 void SAL_CALL OComponent::setAChar( ::sal_Unicode _achar ) throw (RuntimeException)
811 m_attr_char = _achar;
814 Any SAL_CALL OComponent::getAAny() throw (RuntimeException)
816 return m_attr_any;
819 void SAL_CALL OComponent::setAAny( const Any& _aany ) throw (RuntimeException)
821 m_attr_any = _aany;
824 Type SAL_CALL OComponent::getAType() throw (RuntimeException)
826 return m_attr_type;
829 void SAL_CALL OComponent::setAType( const Type& _atype ) throw (RuntimeException)
831 m_attr_type = _atype;
834 Reference< XInterface > SAL_CALL OComponent::getAXInterface() throw (RuntimeException)
836 return m_attr_xinterface;
839 void SAL_CALL OComponent::setAXInterface( const Reference<XInterface >& _axinterface ) throw (RuntimeException)
841 m_attr_xinterface = _axinterface;
844 Reference<XInvocation > SAL_CALL OComponent::getAXInvocation() throw (RuntimeException)
846 return m_attr_xinvocation;
849 void SAL_CALL OComponent::setAXInvocation( const Reference< XInvocation >& _axinvocation ) throw (RuntimeException)
851 m_attr_xinvocation = _axinvocation;
854 void SAL_CALL OComponent::testout_methodByte(sal_Int8& rOut) throw( RuntimeException )
856 rOut= m_int8;
858 void SAL_CALL OComponent::testout_methodFloat(float& rOut) throw( RuntimeException )
860 rOut= m_float;
862 void SAL_CALL OComponent::testout_methodDouble(double& rOut) throw( RuntimeException )
864 rOut= m_double;
867 void SAL_CALL OComponent::testout_methodBool(sal_Bool& rOut) throw( RuntimeException )
869 rOut= m_bool;
871 void SAL_CALL OComponent::testout_methodShort(sal_Int16& rOut) throw( RuntimeException )
873 rOut= m_int16;
875 void SAL_CALL OComponent::testout_methodUShort(sal_uInt16& rOut) throw( RuntimeException )
877 rOut= m_uint16;
879 void SAL_CALL OComponent::testout_methodLong(sal_Int32& rOut) throw( RuntimeException )
881 rOut = m_int32;
883 void SAL_CALL OComponent::testout_methodULong(sal_uInt32& rOut) throw( RuntimeException )
885 rOut= m_uint32;
887 void SAL_CALL OComponent::testout_methodHyper(sal_Int64& rOut) throw( RuntimeException )
889 rOut = m_int64;
892 void SAL_CALL OComponent::testout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException )
894 rOut = m_uint64;
897 void SAL_CALL OComponent::testout_methodString(OUString& rOut) throw( RuntimeException )
899 rOut= m_string;
901 void SAL_CALL OComponent::testout_methodChar(sal_Unicode& rOut) throw( RuntimeException )
903 rOut= m_char;
905 void SAL_CALL OComponent::testout_methodAny(Any& rOut) throw( RuntimeException)
907 rOut = m_any;
910 void SAL_CALL OComponent::testout_methodType(Type& rOut) throw( RuntimeException )
912 rOut = m_type;
915 void SAL_CALL OComponent::testout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException)
917 rOut.realloc(10);
918 for( sal_Int16 i= 0; i < rOut.getLength(); i++) rOut.getArray()[i]= i;
920 void SAL_CALL OComponent::testout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException )
922 rOut.realloc( 10);
923 for( sal_Int16 i= 0; i < rOut.getLength(); i++){
924 Sequence<sal_Int32>& rseq2= rOut.getArray()[i];
925 rseq2.realloc( 10);
926 for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
927 rseq2.getArray()[j]= j;
931 void SAL_CALL OComponent::testout_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException )
933 rout1= 999;
934 rout2= 1111;
936 void SAL_CALL OComponent::testout_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException )
938 rout1= 1111;
939 rout2= 1222;
940 rout3= L" another string";
942 void SAL_CALL OComponent::testout_methodMulParams3(const OUString&, OUString& sout) throw( RuntimeException )
944 sout= L"Out Hallo!";
946 void SAL_CALL OComponent::testout_methodMulParams4( float in1, float& out1, sal_Int32 in2, sal_Int32& out2, sal_Int32 ) throw(RuntimeException)
948 out1= in1 + 1;
949 out2= in2 + 1;
952 void SAL_CALL OComponent::testout_methodXInterface( Reference< XInterface >& rOut ) throw(RuntimeException)
954 rOut = m_xinterface;
957 // XTestInParameters ------------------------------------------------------------
958 sal_Int8 SAL_CALL OComponent::in_methodByte( sal_Int8 rIn ) throw (RuntimeException)
960 m_int8 = rIn;
961 return rIn;
963 float SAL_CALL OComponent::in_methodFloat( float rIn ) throw (RuntimeException)
965 m_float = rIn;
966 return rIn;
968 double SAL_CALL OComponent::in_methodDouble( double rIn ) throw (RuntimeException)
970 m_double = rIn;
971 return rIn;
973 sal_Bool SAL_CALL OComponent::in_methodBool( sal_Bool rIn ) throw (RuntimeException)
975 m_bool = rIn;
976 return rIn;
978 sal_Int16 SAL_CALL OComponent::in_methodShort( sal_Int16 rIn ) throw (RuntimeException)
980 m_int16 = rIn;
981 return rIn;
983 sal_uInt16 SAL_CALL OComponent::in_methodUShort( sal_uInt16 rIn ) throw (RuntimeException)
985 m_uint16 = rIn;
986 return rIn;
988 sal_Int32 SAL_CALL OComponent::in_methodLong( sal_Int32 rIn ) throw (RuntimeException)
990 m_int32 = rIn;
991 return rIn;
993 sal_uInt32 SAL_CALL OComponent::in_methodULong( sal_uInt32 rIn ) throw (RuntimeException)
995 m_uint32 = rIn;
996 return rIn;
998 sal_Int64 SAL_CALL OComponent::in_methodHyper( sal_Int64 rIn ) throw (RuntimeException)
1000 m_int64 = rIn;
1001 return rIn;
1004 sal_uInt64 SAL_CALL OComponent::in_methodUHyper( sal_uInt64 rIn ) throw (RuntimeException)
1006 m_uint64 = rIn;
1007 return rIn;
1010 OUString SAL_CALL OComponent::in_methodString( const OUString& rIn ) throw (RuntimeException)
1012 m_string = rIn;
1013 return rIn;
1015 sal_Unicode SAL_CALL OComponent::in_methodChar( sal_Unicode rIn ) throw (RuntimeException)
1017 m_char = rIn;
1018 return rIn;
1020 Any SAL_CALL OComponent::in_methodAny( const Any& rIn ) throw (RuntimeException)
1022 m_any = rIn;
1023 return rIn;
1026 Type SAL_CALL OComponent::in_methodType( const Type& rIn ) throw (RuntimeException)
1028 m_type = rIn;
1029 return rIn;
1032 Reference<XInvocation > SAL_CALL OComponent::in_methodInvocation( const Reference< XInvocation >& inv )
1033 throw (RuntimeException)
1035 //We expect the invocation results from a conversion of VBasicEventListener.VBEventListener
1036 //which implements XEventListener
1037 // extensions/test/ole/EventListenerSample
1038 EventObject event( Reference<XInterface>(static_cast<XTestInParameters*>(this),UNO_QUERY));
1039 Any anyParam;
1040 anyParam <<= event;
1041 Sequence<Any> params( &anyParam, 1);
1042 Sequence<sal_Int16> outIndex;
1043 Sequence<Any> outParams;
1044 try{
1045 inv->invoke( OUString("disposing"),
1046 params, outIndex, outParams);
1047 }catch(IllegalArgumentException &) {
1049 catch(CannotConvertException &){
1051 catch(InvocationTargetException&) {
1053 return inv;
1055 Reference<XInterface> SAL_CALL OComponent::in_methodXInterface( const Reference<XInterface >& rIn ) throw (RuntimeException)
1057 m_xinterface = rIn;
1058 return rIn;
1061 SimpleStruct SAL_CALL OComponent::in_methodStruct( const SimpleStruct& aStruct )
1062 throw (RuntimeException)
1064 SimpleStruct& s= const_cast<SimpleStruct&>(aStruct);
1065 s.message= s.message + OUString(
1066 "This string was set in OleTest");
1067 return aStruct;
1069 void SAL_CALL OComponent::in_methodAll(
1070 sal_Int8, float, double, sal_Bool, sal_Int16, sal_uInt16,
1071 sal_Int32, sal_uInt32, const OUString&, sal_Unicode,
1072 const Any&, const Type&, const Reference<XInvocation>&) throw (RuntimeException)
1076 // INOUT -----------------------------------------------------------------------------------
1077 void SAL_CALL OComponent::testinout_methodByte(sal_Int8& rOut) throw( RuntimeException )
1079 sal_Int8 tmp = rOut;
1080 rOut = m_int8;
1081 m_int8 = tmp;
1083 void SAL_CALL OComponent::testinout_methodFloat(float& rOut) throw( RuntimeException )
1085 float tmp = rOut;
1086 rOut = m_float;
1087 m_float = tmp;
1090 void SAL_CALL OComponent::testinout_methodDouble(double& rOut) throw( RuntimeException )
1092 double tmp = rOut;
1093 rOut = m_double;
1094 m_double = tmp;
1096 void SAL_CALL OComponent::testinout_methodBool(sal_Bool& rOut) throw( RuntimeException )
1098 sal_Bool tmp = rOut;
1099 rOut = m_bool;
1100 m_bool = tmp;
1102 void SAL_CALL OComponent::testinout_methodShort(sal_Int16& rOut) throw( RuntimeException )
1104 sal_Int16 tmp= rOut;
1105 rOut = m_int16;
1106 m_int16 = tmp;
1108 void SAL_CALL OComponent::testinout_methodUShort(sal_uInt16& rOut) throw( RuntimeException )
1110 sal_uInt16 tmp = rOut;
1111 rOut = m_uint16;
1112 m_uint16 = tmp;
1114 void SAL_CALL OComponent::testinout_methodLong(sal_Int32& rOut) throw( RuntimeException )
1116 sal_Int32 tmp = rOut;
1117 rOut = m_int32;
1118 m_int32 = tmp;
1120 void SAL_CALL OComponent::testinout_methodULong(sal_uInt32& rOut) throw( RuntimeException )
1122 sal_uInt32 tmp = rOut;
1123 rOut = m_uint32;
1124 m_uint32 = tmp;
1126 void SAL_CALL OComponent::testinout_methodHyper(sal_Int64& rOut) throw( RuntimeException )
1128 sal_Int64 tmp = rOut;
1129 rOut = m_int64;
1130 m_int64 = tmp;
1133 void SAL_CALL OComponent::testinout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException )
1135 sal_uInt64 tmp = rOut;
1136 rOut = m_uint64;
1137 m_uint64 = tmp;
1140 void SAL_CALL OComponent::testinout_methodString(OUString& rOut) throw( RuntimeException )
1142 OUString tmp = rOut;
1143 rOut = m_string;
1144 m_string = tmp;
1146 void SAL_CALL OComponent::testinout_methodChar(sal_Unicode& rOut) throw( RuntimeException)
1148 sal_Unicode tmp = rOut;
1149 rOut = m_char;
1150 m_char = tmp;
1152 void SAL_CALL OComponent::testinout_methodAny(Any& rOut) throw( RuntimeException)
1154 Any tmp = rOut;
1155 rOut = m_any;
1156 m_any = tmp;
1158 void SAL_CALL OComponent::testinout_methodType(Type& rOut) throw( RuntimeException)
1160 Type tmp = rOut;
1161 rOut = m_type;
1162 m_type = tmp;
1166 void SAL_CALL OComponent::testinout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException)
1169 sal_Int32* arr= rOut.getArray();
1170 for ( sal_Int32 i=0; i < rOut.getLength(); i++)
1172 rOut.getArray()[i] += 1;
1175 void SAL_CALL OComponent::testinout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException )
1177 for( sal_Int32 i=0; i < rOut.getLength(); i++)
1179 Sequence< sal_Int32 >& seq= rOut.getArray()[i];
1181 for ( sal_Int32 j=0; j < seq.getLength(); j++)
1183 seq.getArray()[j] += seq.getArray()[j];
1188 // The parameter should implement XInvocation and a Property "value"
1189 void SAL_CALL OComponent::testinout_methodXInterface( Reference< XInvocation >& rOut ) throw(RuntimeException)
1191 Any any;
1192 any= rOut->getValue( OUString( L"value"));
1193 OUString _s;
1194 any >>= _s;
1195 OUString string(L"out");
1196 any <<= string;
1197 rOut->setValue( OUString(L"value"), any);
1199 any= rOut->getValue( OUString( L"value"));
1200 any >>= _s;
1204 void SAL_CALL OComponent::testinout_methodXInterface2( Reference< XInterface > & rOut) throw( RuntimeException)
1206 Reference<XInterface> tmp = rOut;
1207 rOut = m_xinterface;
1208 m_xinterface = tmp;
1210 Any SAL_CALL OComponent::methodAnyTest1(const Any& rIn) throw( RuntimeException )
1212 return rIn;
1214 Any SAL_CALL OComponent::getAttrAny2() throw( RuntimeException )
1216 return m_any;
1218 void SAL_CALL OComponent::setAttrAny2(const Any& AttrAny2_) throw( RuntimeException )
1220 m_any= AttrAny2_;
1224 // XTestStruct =======================================================================================
1226 void SAL_CALL OComponent::methodStruct(const Property& aProp) throw( RuntimeException )
1228 char buff[1024];
1229 buff[0]= 0;
1230 sprintf( buff,"Property::Attribute : %d \n Property::Handle : %d \n Property::Name : %S",
1231 aProp.Attributes, aProp.Handle, (const sal_Unicode*)aProp.Name);
1232 MessageBox( NULL, A2T(buff), _T("OleTest: methodStruct"), MB_OK);
1235 Property SAL_CALL OComponent::retMethodStruct() throw( RuntimeException )
1237 Property a(L"OleTest_Property", 255, cppu::UnoType<XInterface>::get(), PropertyAttribute::MAYBEVOID |
1238 PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED |
1239 PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY |
1240 PropertyAttribute::MAYBEAMBIGUOUS | PropertyAttribute::MAYBEDEFAULT );
1241 return a;
1244 Property SAL_CALL OComponent::getAttrStruct() throw( RuntimeException)
1246 Property a(L"OleTest_Property", 255, cppu::UnoType<XInterface>::get(), PropertyAttribute::MAYBEVOID |
1247 PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED |
1248 PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY |
1249 PropertyAttribute::MAYBEAMBIGUOUS | PropertyAttribute::MAYBEDEFAULT );
1250 return a;
1254 void SAL_CALL OComponent::setAttrStruct(const Property& AttrStruct_) throw( RuntimeException )
1256 char buff[1024];
1257 buff[0]= 0;
1258 sprintf( buff,"Property::Attribute : %d \n Property::Handle : %d \n Property::Name : %S",
1259 AttrStruct_.Attributes, AttrStruct_.Handle, (const sal_Unicode*)AttrStruct_.Name);
1260 // MessageBox( NULL, A2T(buff), _T("OleTest: setAttrStruct"), MB_OK);
1263 Property SAL_CALL OComponent::methodStruct2( const Property& aProp ) throw (RuntimeException)
1265 return aProp;
1268 // XTestOther ==================================================================================
1269 void SAL_CALL OComponent::other_methodAnyIn(const Any& ) throw( RuntimeException )
1272 void SAL_CALL OComponent::other_methodAnyOut(Any& rAny) throw( RuntimeException )
1274 rAny <<= OUString(L"Ein Any");
1277 Any SAL_CALL OComponent::other_methodAnyRet() throw(RuntimeException )
1279 Any a;
1280 a <<= OUString(L"Ein Any");
1281 return a;
1283 void SAL_CALL OComponent::in_float( float val) throw ( RuntimeException)
1285 USES_CONVERSION;
1286 char buff[256];
1287 sprintf( buff, "parameter : %f", val);
1288 MessageBox( NULL, A2T(buff), _T("OleTest"), MB_OK);
1290 Any SAL_CALL OComponent::other_methodAny( const Any& rAny, const OUString& typeInAny )
1291 throw (RuntimeException)
1293 Type expectedType;
1294 typelib_TypeDescription * pDesc= NULL;
1295 typelib_typedescription_getByName( &pDesc, typeInAny.pData );
1296 if( pDesc)
1298 expectedType = Type( pDesc->pWeakRef );
1299 typelib_typedescription_release( pDesc);
1301 if (rAny.getValueType() != expectedType)
1302 throw RuntimeException();
1304 return rAny;
1307 // XTestInterfaces -------------------------------------------------------------------------------------
1308 void SAL_CALL OComponent::testInterface( const Reference< XCallback >& xCallback, sal_Int32 mode ) throw(RuntimeException)
1310 USES_CONVERSION;
1311 sal_Int32 i=0;
1312 OUString aString;
1313 char buff[1024];
1315 Reference<XSimple> xSimple;
1316 SimpleStruct aSimpleStruct;
1317 SimpleEnum aSimpleEnum;
1318 Sequence<Any> seqAny;
1319 Sequence< sal_Int8 > seqByte;
1320 Any outAny;
1321 sal_Bool aBool;
1322 sal_Unicode aChar;
1323 float aFloat;
1324 double aDouble;
1325 sal_Int8 aByte;
1326 sal_Int16 aShort;
1327 sal_Int32 aLong;
1329 switch( mode)
1331 case 1:
1332 xCallback->func1(); break;
1333 case 2:
1334 xSimple= xCallback->returnInterface();
1335 xSimple->func(L"XCallback::returnInterface");
1336 break;
1339 case 3:
1340 xCallback->outInterface( xSimple);
1341 sprintf( buff, "XCallback::outInterface, value: %x", xSimple.get());
1342 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1343 xSimple->func(L"XCallback::outInterface works");
1344 break;
1345 case 4:
1346 xCallback->outStruct( aSimpleStruct);
1347 sprintf( buff,"XCallback::outStruct, SimpleStruct::message: %s", OLE2A( aSimpleStruct.message));
1348 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1349 break;
1350 case 5:
1351 xCallback->outEnum( aSimpleEnum);
1352 sprintf( buff,"XCallback::outEnum, SimpleEnum: %d", aSimpleEnum);
1353 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1354 break;
1355 case 6:
1356 xCallback->outSeqAny( seqAny);
1357 sprintf( buff,"XCallback::outSeqAny, length: %d )", seqAny.getLength());
1358 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1359 for( i=0; i < seqAny.getLength(); i++)
1361 Any any= seqAny[i];
1362 if( any.getValueTypeClass() == TypeClass_STRING)
1364 any >>= aString;
1365 OutputDebugStringW( aString);
1369 break;
1370 case 7:
1371 xCallback->outAny( outAny);
1372 if( outAny.getValueTypeClass() == TypeClass_STRING)
1373 outAny >>= aString;
1374 sprintf( buff,"XCallback::outAny, Any : %s", W2A( aString));
1375 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1376 break;
1377 case 8:
1378 xCallback->outBool( aBool);
1379 sprintf( buff,"XCallback::outBool, value: %d", aBool);
1380 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1381 break;
1382 case 9:
1383 xCallback->outChar( aChar);
1384 sprintf( buff,"XCallback::outChar, value: %C", aChar);
1385 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1386 break;
1387 case 10:
1388 xCallback->outString( aString);
1389 sprintf( buff,"XCallback::outString, value: %s", W2A( aString));
1390 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1391 break;
1392 case 11:
1393 xCallback->outFloat( aFloat);
1394 sprintf( buff,"XCallback::outFloat, value: %f", aFloat);
1395 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1396 break;
1397 case 12:
1398 xCallback->outDouble( aDouble);
1399 sprintf( buff,"XCallback::outDouble, value: %f", aDouble);
1400 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1401 break;
1402 case 13:
1403 xCallback->outByte( aByte);
1404 sprintf( buff,"XCallback::outByte, value: %d", aByte);
1405 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1406 break;
1407 case 14:
1408 xCallback->outShort( aShort);
1409 sprintf( buff,"XCallback::outShort, value: %d", aShort);
1410 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1411 break;
1412 case 15:
1413 xCallback->outLong( aLong);
1414 sprintf( buff,"XCallback::outLong, value: %d", aLong);
1415 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1416 break;
1417 case 18:
1418 case 19:
1419 case 30:
1422 long outLong= 0;
1423 xCallback->outValuesMixed( 1111, outLong, OUString( L"in string") );
1425 sprintf( buff, "oletest.testInterface: outValue: %d", outLong);
1426 MessageBox( NULL, A2T(buff), _T("OleTest"), MB_OK);
1427 break;
1430 case 31:
1432 Reference< XSimple > xSimple;
1433 SimpleStruct aSimpleStruct;
1434 SimpleEnum aSimpleEnum;
1435 Sequence<Any> seqAny;
1436 Any aAny;
1437 sal_Bool aBool;
1438 sal_Unicode aChar;
1439 OUString aString;
1440 float aFloat;
1441 double aDouble;
1442 sal_Int8 aByte;
1443 sal_Int16 aShort;
1444 sal_Int32 aLong;
1445 xCallback->outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool,
1446 aChar, aString,
1447 aFloat, aDouble,
1448 aByte,
1449 aShort, aLong);
1451 MessageBox( NULL, _T("XCallback::outValuesAll returned"), _T("OleTest::testInterface"), MB_OK);
1452 break;
1454 case 32:
1457 xCallback->outSeqByte( seqByte);
1458 sprintf( buff,"XCallback::outSeqAny, length: %d )", seqAny.getLength());
1459 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1460 for( i=0; i < seqAny.getLength(); i++)
1462 Any any= seqAny[i];
1463 if( any.getValueTypeClass() == TypeClass_STRING)
1465 any >>= aString;
1466 OutputDebugStringW( aString);
1469 break;
1471 // ############################################################################
1472 // IN OUT parameter
1473 // ############################################################################
1474 case 100:
1476 Reference<XSimple> xSimple= static_cast<XSimple*>(this);
1477 xCallback->inoutInterface( xSimple);
1478 xSimple->func(L"XSimple called from OleTest");
1479 break;
1481 case 101:
1483 Reference<XIdlReflection> xRefl( theCoreReflection::get(comphelper::getComponentContext(m_rFactory)) );
1484 Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
1485 Any any;
1486 if( xClass.is())
1487 xClass->createObject( any);
1489 if( any.getValueTypeClass() == TypeClass_STRUCT)
1491 SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
1492 pStruct->message= "This struct was created in OleTest";
1494 SimpleStruct aStruct;
1495 any >>= aStruct;
1496 xCallback->inoutStruct( aStruct);
1497 // a Struct should now contain a different message
1498 MessageBox( NULL, W2T(aStruct.message), _T("OleTest in out parameter"), MB_OK);
1501 break;
1503 case 102:
1505 SimpleEnum aEnum= SimpleEnum_B;
1506 xCallback->inoutEnum( aEnum);
1507 char buff[1024];
1508 sprintf( buff, "Enum: %d", aEnum);
1509 MessageBox( NULL, A2T(buff), _T("OleTest in out parameter"), MB_OK);
1510 break;
1512 case 103:
1514 Any arAny[3];
1515 arAny[0] <<= OUString( L"string 0");
1516 arAny[1] <<= OUString( L"string 1");
1517 arAny[2] <<= OUString( L"string 2");
1519 Sequence< Any >seqAny( arAny, 3);
1520 xCallback->inoutSeqAny( seqAny);
1521 char buff[1023];
1522 sprintf( buff, "Sequence length: %d", seqAny.getLength());
1523 MessageBox( NULL,A2T(buff) , _T("OleTest in out parameter"), MB_OK);
1525 for( int i=0; i < seqAny.getLength(); i++)
1527 Any any;
1528 any <<= seqAny[i];
1529 if(any.getValueTypeClass() == TypeClass_STRING)
1531 OUString str;
1532 any >>= str;
1537 break;
1539 case 104:
1541 Any any;
1542 OUString s(L" OleTest");
1543 any <<= s;
1544 xCallback->inoutAny(any);
1545 if( any.getValueTypeClass() == TypeClass_STRING)
1547 OUString s= *( rtl_uString**) any.getValue();
1548 MessageBox( NULL, W2T( s), _T("OleTest: inout value any"), MB_OK);
1550 break;
1552 case 105:
1554 sal_Bool b= sal_True;
1555 xCallback->inoutBool( b);
1556 char buff[1024];
1557 sprintf( buff, "out value bool: %d", b);
1558 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1559 break;
1561 case 106:
1563 sal_Unicode uc= L'A';
1564 xCallback->inoutChar( uc);
1565 char buff[1024];
1566 sprintf( buff, "out value sal_Unicode: %C", uc);
1567 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1568 break;
1570 case 107:
1572 OUString s(L"OleTest");
1573 xCallback->inoutString( s);
1574 char buff[1024];
1575 sprintf( buff, "out value string: %S", s.getStr());
1576 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1577 break;
1579 case 108:
1581 float f= 3.14f;
1582 xCallback->inoutFloat(f);
1583 char buff[1024];
1584 sprintf( buff, "out value float: %f", f);
1585 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1586 break;
1588 case 109:
1590 double f= 3.145;
1591 xCallback->inoutDouble( f);
1592 char buff[1024];
1593 sprintf( buff, "out value double: %g", f);
1594 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1595 break;
1597 case 110:
1599 sal_Int8 aByte= 0xf;
1600 xCallback->inoutByte( aByte);
1601 char buff[1024];
1602 sprintf( buff, "out value sal_Int8: %d", aByte);
1603 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1604 break;
1606 case 111:
1608 sal_Int16 aShort= 0xff;
1609 xCallback->inoutShort( aShort);
1610 char buff[1024];
1611 sprintf( buff, "out value sal_Int16: %d", aShort);
1612 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1613 break;
1615 case 112:
1617 sal_Int32 aLong= 0xfffe;
1618 xCallback->inoutLong( aLong);
1619 char buff[1024];
1620 sprintf( buff, "out value sal_Int32: %d", aLong);
1621 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1622 break;
1624 case 120:
1626 Reference<XSimple> aXSimple= static_cast<XSimple*>(this);
1628 SimpleStruct aStruct;
1629 Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
1630 if( xRefl.is())
1632 Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
1633 Any any;
1634 if( xClass.is())
1635 xClass->createObject( any);
1637 if( any.getValueTypeClass() == TypeClass_STRUCT)
1639 SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
1640 pStruct->message= "This struct was created in OleTest";
1641 any >>= aStruct;
1645 SimpleEnum aEnum= SimpleEnum_B;
1647 Sequence< Any > aSeq;
1648 Any arAny[3];
1649 arAny[0] <<= OUString( L"string 0");
1650 arAny[1] <<= OUString( L"string 1");
1651 arAny[2] <<= OUString( L"string 2");
1652 aSeq = Sequence< Any >( arAny, 3);
1654 Any aAny;
1655 OUString s(L" OleTest");
1656 aAny <<= s;
1658 sal_Bool aBool= sal_True;
1659 sal_Unicode aChar= L'A';
1660 OUString aString( L"OleTest");
1661 float aFloat=3.14f;
1662 double aDouble= 3.145;
1663 sal_Int8 aByte= 0xf;
1664 sal_Int16 aShort= 0xff;
1665 sal_Int32 aLong= 0xffe;
1667 xCallback->inoutValuesAll( aXSimple, aStruct, aEnum, aSeq,
1668 aAny, aBool, aChar, aString, aFloat, aDouble,
1669 aByte, aShort, aLong );
1671 aXSimple->func(L"XSimple called from OleTest");
1672 MessageBox( NULL, W2T(aStruct.message), _T("OleTest"), MB_OK);
1674 for( int i=0; i < aSeq.getLength(); i++)
1676 Any any;
1677 any <<= aSeq[i];
1678 if(any.getValueTypeClass() == TypeClass_STRING)
1680 OUString str;
1681 any >>= str;
1685 break;
1688 // ############################################################################
1689 // IN parameter
1690 // ############################################################################
1692 case 200:
1694 xCallback->inValues( L'a', 0xffffL, OUString(L" a string from OleTest"));
1695 break;
1696 case 201:
1698 sal_Int8 arbyte[3]= { 1,2,3};
1699 Sequence< sal_Int8 > seq( arbyte, 3);
1700 xCallback->inSeqByte( seq);
1701 break;
1703 case 202:
1705 const int LISTENERS= 3;
1706 Reference<XEventListener> arListeners[LISTENERS];
1707 EventObject arEvents[LISTENERS];
1709 for( int i= 0; i < LISTENERS; i++)
1711 Reference<XInterface> aList= static_cast<XWeak*>( new EventListener());
1712 arListeners[i].set( aList, UNO_QUERY);
1715 xCallback->inSeqXEventListener(Sequence<Reference<XEventListener> > (arListeners, LISTENERS),
1716 Sequence<EventObject>(arEvents, LISTENERS));
1717 break;
1720 // ############################################################################
1721 // Call a COM object that has not been passed as parameter to a UNO component and
1722 // hence no type information is available in the COM wrapper
1723 // ############################################################################
1724 case 300:
1726 Reference<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.oleautomation.Factory");
1728 Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
1730 Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
1731 Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
1732 Sequence<sal_Int16> seqIndices;
1733 Sequence<Any> seqOutParams;
1734 xInv->invoke( OUString( L"outValuesAll"), Sequence<Any>(), seqIndices, seqOutParams);
1736 if( seqOutParams.getLength() == 12)
1738 Reference<XSimple> xSimple= *(XSimple**)seqOutParams[0].getValue();
1739 xSimple->func( L"Call from OleTest on XSimple");
1740 SimpleStruct aStruct;
1741 seqOutParams[1] >>= aStruct;
1742 SimpleEnum aEnum= *(SimpleEnum*)seqOutParams[2].getValue();
1744 Sequence<Any> seqAny;
1745 seqOutParams[3] >>= seqAny;
1746 for( int i=0; i<seqAny.getLength(); i++)
1748 OUString _s;
1749 seqAny[i] >>= _s;
1752 Any _any= *(Any*)seqOutParams[4].getValue();
1753 sal_Bool _bool= *(sal_Bool*)seqOutParams[5].getValue();
1754 sal_Unicode _char= *( sal_Unicode*) seqOutParams[6].getValue();
1755 OUString _str= *( rtl_uString**)seqOutParams[7].getValue();
1757 float _f= *( float*)seqOutParams[8].getValue();
1758 double _d= *( double*) seqOutParams[9].getValue();
1759 sal_Int8 _byte= *( sal_Int8*) seqOutParams[10].getValue();
1760 sal_Int16 _short= *( sal_Int16*) seqOutParams[11].getValue();
1762 sal_Int32 _long= *( sal_Int32*) seqOutParams[12].getValue();
1765 break;
1767 case 301:
1768 // in / out parameter
1770 Reference<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.oleautomation.Factory");
1772 Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
1774 Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
1775 Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
1776 Sequence<sal_Int16> seqIndices;
1777 Sequence<Any> seqOutParams;
1780 Any arAny[13];
1781 Reference<XSimple> xSimple= static_cast<XSimple*>( this);
1783 arAny[0] <<= xSimple;
1784 SimpleStruct aStruct;
1785 Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
1786 if( xRefl.is())
1788 Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
1789 Any any;
1790 if( xClass.is())
1791 xClass->createObject( any);
1793 if( any.getValueTypeClass() == TypeClass_STRUCT)
1795 SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
1796 pStruct->message = "This struct was created in OleTest";
1797 any >>= aStruct;
1800 arAny[1] <<= aStruct;
1801 arAny[2] <<= SimpleEnum_C;
1803 Any arSeqAny[3];
1804 arSeqAny[0] <<= OUString( L"string 0");
1805 arSeqAny[1] <<= OUString( L"string 1");
1806 arSeqAny[2] <<= OUString( L"string 2");
1808 arAny[3] <<= Sequence< Any >( arAny, 3);
1810 OUString str(L" Ein Any param");
1811 arAny[4] <<= str;
1812 arAny[5] <<= sal_False;
1813 arAny[6] <<= L'B';
1814 OUString stringParam(L" a string parameter");
1815 arAny[7] <<= stringParam;
1816 float _float= 3.14f;
1817 arAny[8] <<= _float;
1818 double _double= 3.145;
1819 arAny[9] <<= _double;
1820 sal_Int8 _byte= -1;
1821 arAny[10] <<= _byte;
1822 sal_Int16 _short= -1;
1823 arAny[11] <<= _short;
1824 sal_Int32 _long= -1;
1825 arAny[12] <<= _long;
1827 Sequence<Any> params( arAny, 13);
1829 xInv->invoke( OUString( L"inoutValuesAll"), params, seqIndices, seqOutParams);
1831 if( seqOutParams.getLength() == 12)
1833 Reference<XSimple> xSimple= *(XSimple**)seqOutParams[0].getValue();
1834 xSimple->func( L"Call from OleTest on XSimple");
1835 SimpleStruct aStruct;
1836 seqOutParams[1] >>= aStruct;
1837 SimpleEnum aEnum= *(SimpleEnum*)seqOutParams[2].getValue();
1839 Sequence<Any> seqAny;
1840 seqOutParams[3] >>= seqAny;
1841 for( int i=0; i<seqAny.getLength(); i++)
1843 OUString _s;
1844 seqAny[i] >>= _s;
1847 Any _any= *(Any*)seqOutParams[4].getValue();
1848 sal_Bool _bool= *(sal_Bool*)seqOutParams[5].getValue();
1849 sal_Unicode _char= *( sal_Unicode*) seqOutParams[6].getValue();
1850 OUString _str= *( rtl_uString**)seqOutParams[7].getValue();
1852 float _f= *( float*)seqOutParams[8].getValue();
1853 double _d= *( double*) seqOutParams[9].getValue();
1854 sal_Int8 _byte= *( sal_Int8*) seqOutParams[10].getValue();
1855 sal_Int16 _short= *( sal_Int16*) seqOutParams[11].getValue();
1857 sal_Int32 _long= *( sal_Int32*) seqOutParams[12].getValue();
1860 break;
1862 case 303:
1864 Reference<XInterface> xIntFact = m_rFactory->createInstance(
1865 L"com.sun.star.bridge.oleautomation.Factory");
1867 Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
1869 Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
1870 Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
1871 Sequence<sal_Int16> seqIndices;
1872 Sequence<Any> seqOutParams;
1874 Any arAny[3];
1875 sal_Unicode aChar=L'a';
1876 arAny[0] <<= aChar;
1877 sal_Int32 aLong= 0xffffffff;
1878 arAny[1] <<= aLong;
1879 OUString aString(L" a string parameter");
1880 arAny[2] <<= aString;
1882 xInv->invoke( OUString( L"inValues"), Sequence<Any>(arAny,3), seqIndices, seqOutParams);
1884 break;
1886 // ############################################################################
1887 // Attributes
1888 // ############################################################################
1890 case 400:
1891 Reference<XSimple> simple= xCallback->getsimple();
1892 simple->func(L"OleTest calls on XSimple");
1893 break;
1900 void SAL_CALL OComponent::setObject( const Reference< XInterface >& val ) throw (RuntimeException)
1902 m_xIntIdentity= val;
1905 sal_Bool SAL_CALL OComponent::isSame( const Reference< XInterface >& val ) throw (RuntimeException)
1907 if( m_xIntIdentity == val)
1908 return sal_True;
1909 else
1910 return sal_False;
1913 Reference< XInterface > SAL_CALL OComponent::getThis( ) throw (RuntimeException)
1915 Reference<XInterface> ret(static_cast<XIdentity*>(this), UNO_QUERY);
1916 return ret;
1919 void SAL_CALL EventListener::disposing( const css::lang::EventObject& ) throw (RuntimeException)
1921 bCalled= sal_True;
1924 // XSimple --------------------------------------------------------------------------
1925 void SAL_CALL OComponent::func( const OUString &message)throw(css::uno::RuntimeException)
1927 USES_CONVERSION;
1929 MessageBox( NULL, W2T( message.getStr()), _T("OleTest: XSimple::func"), MB_OK);
1931 // XSimple --------------------------------------------------------------------------
1932 OUString SAL_CALL OComponent::getName()throw(css::uno::RuntimeException)
1934 return L"XSimple";
1936 void SAL_CALL OComponent::testInterface2( const Reference< XSimple >& xSimple, sal_Int32 mode ) throw(RuntimeException)
1938 switch( mode)
1940 case 0:
1942 xSimple->func( L"OleTest is calling XSimple");
1943 Reference<XSimple2> xSimple2( xSimple, UNO_QUERY);
1944 if( xSimple2.is())
1945 xSimple2->func2( L"OleTest is calling XSimple2");
1946 Reference<XSimple3> xSimple3( xSimple, UNO_QUERY);
1947 if( xSimple3.is())
1948 xSimple3->func3( L"OleTest is calling XSimple3");
1950 break;
1955 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */