1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_extensions.hxx"
26 #include <windows.h>
27 #include <atlbase.h>
28 #include <stdio.h>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/registry/XRegistryKey.hpp>
31 #include <osl/diagnose.h>
32 #include <uno/environment.h>
33 #include <cppuhelper/factory.hxx>
34 // OPTIONAL is a constant in com.sun.star.beans.PropertyAttributes but it must be
35 // undef'd in some header files
36 #define OPTIONAL OPTIONAL
37 #include <com/sun/star/beans/PropertyAttribute.hpp>
38 #include <com/sun/star/script/XInvocation.hpp>
39 #include <com/sun/star/reflection/XIdlReflection.hpp>
40 #include <com/sun/star/lang/XEventListener.hpp>
41
42 #include <cppuhelper/implbase7.hxx>
43 #include <cppuhelper/implbase1.hxx>
44 #include <com/sun/star/uno/Reference.h>
45 #include <rtl/ustring.h>
46 #include <com/sun/star/uno/Reference.hxx>
47 #include <oletest/XTestSequence.hpp>
48 #include <oletest/XTestStruct.hpp>
49 #include <oletest/XTestOther.hpp>
50 #include <oletest/XTestInterfaces.hpp>
51 #include <oletest/XSimple.hpp>
52 #include <oletest/XSimple2.hpp>
53 #include <oletest/XSimple3.hpp>
54 #include <oletest/XTestInParameters.hpp>
55 //#include <oletest/XTestOutParameters.hpp>
56 #include <oletest/XIdentity.hpp>
57 #include <com/sun/star/beans/Property.hpp>
58 using namespace cppu;
59 using namespace osl;
60 using namespace oletest;
61 using namespace rtl;
62 using namespace com::sun::star::uno;
63 using namespace com::sun::star::lang;
64 using namespace com::sun::star::beans;
65 using namespace com::sun::star::registry;
66 using namespace com::sun::star::script;
67 using namespace com::sun::star::reflection;
68
69
70 #define IMPL_NAME L"oletest.OleTestImpl" // oletest.OleTestImpl in applicat.rdb
71 #define SERVICE_NAME L"oletest.OleTest"
72 #define KEY1 L"/oletest.OleTestImpl/UNO/SERVICES"
73 #define KEY2 L"oletest.OleTest"
74
75 class OComponent : public WeakImplHelper7<
76 XTestSequence, XTestStruct, XTestOther, XTestInterfaces,
77 XSimple, XTestInParameters, XIdentity >
78 {
79 Reference<XInterface> m_xIntIdentity;
80 sal_Int32 m_arrayConstructor;
81 Reference<XMultiServiceFactory> m_rFactory;
82
83 Sequence<sal_Int8> m_seqByte;
84 Sequence<float> m_seqFloat;
85 Sequence<double> m_seqDouble;
86 Sequence<sal_Bool> m_seqBool;
87 Sequence<sal_Int16> m_seqShort;
88 Sequence<sal_uInt16> m_seqUShort;
89 Sequence<sal_Int32> m_seqLong;
90 Sequence<sal_uInt32> m_seqULong;
91 Sequence<sal_Unicode> m_seqChar;
92 Sequence<OUString> m_seqString;
93 Sequence<Any> m_seqAny;
94 Sequence<Type> m_seqType;
95 Sequence<Sequence< sal_Int32> > m_seq1;
96 Sequence<Sequence< Sequence< sal_Int32> > > m_seq2;
97 Any m_any;
98 Type m_type;
99 Sequence<Reference< XInterface > > m_seqxInterface;
100
101 sal_Int8 m_int8;
102 sal_uInt8 m_uint8;
103 sal_Int16 m_int16;
104 sal_uInt16 m_uint16;
105 sal_Int32 m_int32;
106 sal_uInt32 m_uint32;
107 sal_Int64 m_int64;
108 sal_uInt64 m_uint64;
109 float m_float;
110 double m_double;
111 OUString m_string;
112 sal_Unicode m_char;
113 sal_Bool m_bool;
114 Reference<XInterface> m_xinterface;
115
116 sal_Int8 m_attr_int8;
117 sal_uInt8 m_attr_uint8;
118 sal_Int16 m_attr_int16;
119 sal_uInt16 m_attr_uint16;
120 sal_Int32 m_attr_int32;
121 sal_uInt32 m_attr_uint32;
122 sal_Int64 m_attr_int64;
123 sal_uInt64 m_attr_uint64;
124 float m_attr_float;
125 double m_attr_double;
126 OUString m_attr_string;
127 sal_Unicode m_attr_char;
128 sal_Bool m_attr_bool;
129 Any m_attr_any;
130 Type m_attr_type;
131 Reference<XInterface> m_attr_xinterface;
132 Reference<XInvocation> m_attr_xinvocation;
133
134 public:
OComponent(const Reference<XMultiServiceFactory> & rFactory)135 OComponent( const Reference<XMultiServiceFactory> & rFactory ) :
136 m_rFactory( rFactory ), m_arrayConstructor(0) {}
137 ~OComponent();
138 public: // XTestSequence
139 virtual Sequence<sal_Int8> SAL_CALL methodByte(const Sequence< sal_Int8 >& aSeq);
140 virtual Sequence<float> SAL_CALL methodFloat(const Sequence< float >& aSeq);
141 virtual Sequence< double > SAL_CALL methodDouble(const Sequence< double >& aSeq);
142 virtual Sequence< sal_Bool > SAL_CALL methodBool(const Sequence< sal_Bool >& aSeq);
143 virtual Sequence< sal_Int16 > SAL_CALL methodShort(const Sequence< sal_Int16 >& aSeq);
144 virtual Sequence< sal_uInt16 > SAL_CALL methodUShort(const Sequence< sal_uInt16 >& aSeq);
145 virtual Sequence< sal_Int32 > SAL_CALL methodLong(const Sequence< sal_Int32 >& aSeq) ;
146 virtual Sequence< sal_uInt32 > SAL_CALL methodULong(const Sequence< sal_uInt32 >& aSeq);
147 virtual Sequence< OUString > SAL_CALL methodString(const Sequence< OUString >& aSeq);
148 virtual Sequence< sal_Unicode > SAL_CALL methodChar(const Sequence< sal_Unicode >& aSeq);
149 virtual Sequence< Any > SAL_CALL methodAny(const Sequence< Any >& aSeq);
150 virtual Sequence< Type > SAL_CALL methodType(const Sequence< Type >& aSeq);
151 virtual Sequence< Reference< XInterface > > SAL_CALL methodXInterface( const Sequence< Reference< XInterface > >& aSeq ) ;
152 virtual Sequence< Sequence< sal_Int32 > > SAL_CALL methodSequence(const Sequence< Sequence< sal_Int32 > >& aSeq);
153 virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL methodSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq);
154 virtual Sequence< Reference<XEventListener> > SAL_CALL methodXEventListeners( const Sequence<Reference<XEventListener> >& aSeq);
155 virtual Sequence< Sequence<Reference<XEventListener > > > SAL_CALL methodXEventListenersMul( const Sequence<Sequence<Reference<XEventListener > > >& aSeq );
156
157 virtual Sequence< sal_Int8 > SAL_CALL getAttrByte(void);
158 virtual void SAL_CALL setAttrByte(const Sequence< sal_Int8 >& AttrByte_);
159 virtual Sequence< float > SAL_CALL getAttrFloat(void) ;
160 virtual void SAL_CALL setAttrFloat(const Sequence< float >& AttrFloat_);
161 virtual Sequence< double > SAL_CALL getAttrDouble(void) ;
162 virtual void SAL_CALL setAttrDouble(const Sequence< double >& AttrDouble_);
163 virtual Sequence< sal_Bool > SAL_CALL getAttrBool(void);
164 virtual void SAL_CALL setAttrBool(const Sequence< sal_Bool >& AttrBool_);
165 virtual Sequence< sal_Int16 > SAL_CALL getAttrShort(void);
166 virtual void SAL_CALL setAttrShort(const Sequence< sal_Int16 >& AttrShort_);
167 virtual Sequence< sal_uInt16 > SAL_CALL getAttrUShort(void);
168 virtual void SAL_CALL setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_);
169 virtual Sequence< sal_Int32 > SAL_CALL getAttrLong(void);
170 virtual void SAL_CALL setAttrLong(const Sequence< sal_Int32 >& AttrLong_);
171 virtual Sequence< sal_uInt32 > SAL_CALL getAttrULong(void);
172 virtual void SAL_CALL setAttrULong(const Sequence< sal_uInt32 >& AttrULong_);
173 virtual Sequence< OUString > SAL_CALL getAttrString(void);
174 virtual void SAL_CALL setAttrString(const Sequence< OUString >& AttrString_);
175 virtual Sequence< sal_Unicode > SAL_CALL getAttrChar(void);
176 virtual void SAL_CALL setAttrChar(const Sequence< sal_Unicode >& AttrChar_);
177 virtual Sequence< Any > SAL_CALL getAttrAny(void);
178 virtual void SAL_CALL setAttrAny(const Sequence< Any >& AttrAny_);
179 virtual Sequence< Type > SAL_CALL getAttrType(void);
180 virtual void SAL_CALL setAttrType( const Sequence< Type >& _attrtype );
181 virtual Sequence< Sequence< sal_Int32 > > SAL_CALL getAttrSequence(void);
182 virtual void SAL_CALL setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence_);
183 virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL getAttrSequence2(void);
184 virtual void SAL_CALL setAttrSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& AttrSequence2_);
185 virtual Sequence< Reference< XInterface > > SAL_CALL getAttrXInterface();
186 virtual void SAL_CALL setAttrXInterface( const Sequence< Reference< XInterface > >& _attrxinterface );
187
188 virtual ::sal_Int8 SAL_CALL getAByte();
189 virtual void SAL_CALL setAByte( ::sal_Int8 _abyte );
190 virtual float SAL_CALL getAFloat();
191 virtual void SAL_CALL setAFloat( float _afloat );
192 virtual double SAL_CALL getADouble();
193 virtual void SAL_CALL setADouble( double _adouble );
194 virtual ::sal_Bool SAL_CALL getABool();
195 virtual void SAL_CALL setABool( ::sal_Bool _abool );
196 virtual ::sal_Int16 SAL_CALL getAShort();
197 virtual void SAL_CALL setAShort( ::sal_Int16 _ashort );
198 virtual ::sal_uInt16 SAL_CALL getAUShort();
199 virtual void SAL_CALL setAUShort( ::sal_uInt16 _aushort );
200 virtual ::sal_Int32 SAL_CALL getALong();
201 virtual void SAL_CALL setALong( ::sal_Int32 _along );
202 virtual ::sal_uInt32 SAL_CALL getAULong();
203 virtual void SAL_CALL setAULong( ::sal_uInt32 _aulong );
204 virtual ::rtl::OUString SAL_CALL getAString();
205 virtual void SAL_CALL setAString( const ::rtl::OUString& _astring );
206 virtual ::sal_Unicode SAL_CALL getAChar();
207 virtual void SAL_CALL setAChar( ::sal_Unicode _achar );
208 virtual Any SAL_CALL getAAny();
209 virtual void SAL_CALL setAAny( const Any& _aany );
210 virtual Type SAL_CALL getAType();
211 virtual void SAL_CALL setAType( const Type& _atype );
212 virtual Reference< XInterface > SAL_CALL getAXInterface();
213 virtual void SAL_CALL setAXInterface( const Reference<XInterface >& _axinterface );
214 virtual Reference<XInvocation > SAL_CALL getAXInvocation();
215 virtual void SAL_CALL setAXInvocation( const Reference< XInvocation >& _axinvocation );
216
217 virtual void SAL_CALL testout_methodByte(sal_Int8& rOut);
218 virtual void SAL_CALL testout_methodFloat(float& rOut);
219 virtual void SAL_CALL testout_methodDouble(double& rOut);
220 virtual void SAL_CALL testout_methodBool(sal_Bool& rOut);
221 virtual void SAL_CALL testout_methodShort(sal_Int16& rOut);
222 virtual void SAL_CALL testout_methodUShort(sal_uInt16& rOut);
223 virtual void SAL_CALL testout_methodLong(sal_Int32& rOut);
224 virtual void SAL_CALL testout_methodULong(sal_uInt32& rOut);
225 virtual void SAL_CALL testout_methodHyper(sal_Int64& rOut);
226 virtual void SAL_CALL testout_methodUHyper(sal_uInt64& rOut);
227 virtual void SAL_CALL testout_methodString(OUString& rOut);
228 virtual void SAL_CALL testout_methodChar(sal_Unicode& rOut);
229 virtual void SAL_CALL testout_methodAny(Any& rOut);
230 virtual void SAL_CALL testout_methodType(Type& rOut);
231 virtual void SAL_CALL testout_methodSequence(Sequence< sal_Int32 >& rOut);
232 virtual void SAL_CALL testout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut);
233 virtual void SAL_CALL testout_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2);
234 virtual void SAL_CALL testout_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3);
235 virtual void SAL_CALL testout_methodMulParams3(const OUString& sin, OUString& sout);
236 virtual void SAL_CALL testout_methodMulParams4( float in1, float& out1, sal_Int32 in2, sal_Int32& out2, sal_Int32 in3 );
237 virtual void SAL_CALL testout_methodXInterface( Reference< XInterface >& rOut );
238
239 virtual void SAL_CALL testinout_methodByte(sal_Int8& rOut);
240 virtual void SAL_CALL testinout_methodFloat(float& rOut);
241 virtual void SAL_CALL testinout_methodDouble(double& rOut);
242 virtual void SAL_CALL testinout_methodBool(sal_Bool& rOut);
243 virtual void SAL_CALL testinout_methodShort(sal_Int16& rOut);
244 virtual void SAL_CALL testinout_methodUShort(sal_uInt16& rOut);
245 virtual void SAL_CALL testinout_methodLong(sal_Int32& rOut);
246 virtual void SAL_CALL testinout_methodULong(sal_uInt32& rOut);
247 virtual void SAL_CALL testinout_methodHyper(sal_Int64& rOut);
248 virtual void SAL_CALL testinout_methodUHyper(sal_uInt64& rOut);
249 virtual void SAL_CALL testinout_methodString(OUString& rOut);
250 virtual void SAL_CALL testinout_methodChar(sal_Unicode& rOut);
251 virtual void SAL_CALL testinout_methodAny(Any& rOut);
252 virtual void SAL_CALL testinout_methodType(Type& rOut);
253 virtual void SAL_CALL testinout_methodSequence(Sequence< sal_Int32 >& rOut);
254 virtual void SAL_CALL testinout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut);
255 virtual void SAL_CALL testinout_methodXInterface( Reference< XInvocation >& rOut );
256 virtual void SAL_CALL testinout_methodXInterface2( Reference< XInterface > & rOut);
257 virtual Any SAL_CALL methodAnyTest1(const Any& rIn) ;
258 virtual Any SAL_CALL getAttrAny2(void) ;
259 virtual void SAL_CALL setAttrAny2(const Any& AttrAny2_) ;
260
261
262 // XTestStruct
263 virtual void SAL_CALL methodStruct(const Property& aProp);
264
265 virtual Property SAL_CALL retMethodStruct(void);
266
267 virtual Property SAL_CALL getAttrStruct(void);
268 virtual void SAL_CALL setAttrStruct(const Property& AttrStruct_);
269 virtual Property SAL_CALL methodStruct2( const Property& aProp );
270
271 // XTestOther
272 virtual void SAL_CALL other_methodAnyIn(const Any& rAny);
273 virtual void SAL_CALL other_methodAnyOut(Any& rAny);
274 virtual Any SAL_CALL other_methodAnyRet(void);
275 virtual void SAL_CALL in_float( float val);
276 virtual Any SAL_CALL other_methodAny( const Any& rAny, const OUString& typeInAny );
277
278
279 // XTestOutParameters ------------------------------------------------------------------------
280 // virtual void SAL_CALL out_test(sal_Int8 rIn) throw( RuntimeException );
281
282 // virtual void SAL_CALL out_methodByte(sal_Int8& rOut) throw( RuntimeException );
283 // virtual void SAL_CALL out_methodFloat(float& rOut) throw( RuntimeException );
284 // virtual void SAL_CALL out_methodDouble(double& rOut) throw( RuntimeException );
285 // virtual void SAL_CALL out_methodBool(sal_Bool& rOut) throw( RuntimeException );
286 // virtual void SAL_CALL out_methodShort(sal_Int16& rOut) throw( RuntimeException );
287 // virtual void SAL_CALL out_methodUShort(sal_uInt16& rOut) throw( RuntimeException );
288 // virtual void SAL_CALL out_methodLong(sal_Int32& rOut) throw( RuntimeException );
289 // virtual void SAL_CALL out_methodULong(sal_uInt32& rOut) throw( RuntimeException );
290 // virtual void SAL_CALL out_methodHyper(sal_Int64& rOut) throw( RuntimeException );
291 // virtual void SAL_CALL out_methodUHyper(sal_uInt64& rOut) throw( RuntimeException );
292 // virtual void SAL_CALL out_methodString(OUString& rOut) throw( RuntimeException );
293 // virtual void SAL_CALL out_methodChar(sal_Unicode& rOut) throw( RuntimeException );
294 // virtual void SAL_CALL out_methodAny(Any& rOut) throw( RuntimeException );
295 // virtual void SAL_CALL out_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException );
296 // virtual void SAL_CALL out_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException );
297 // virtual void SAL_CALL out_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException );
298 // virtual void SAL_CALL out_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException );
299 // virtual void SAL_CALL out_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException );
300
301 // XTestInParameters
302 virtual sal_Int8 SAL_CALL in_methodByte( sal_Int8 rIn );
303 virtual float SAL_CALL in_methodFloat( float rIn );
304 virtual double SAL_CALL in_methodDouble( double rIn );
305 virtual sal_Bool SAL_CALL in_methodBool( sal_Bool rIn );
306 virtual sal_Int16 SAL_CALL in_methodShort( sal_Int16 rIn );
307 virtual sal_uInt16 SAL_CALL in_methodUShort( sal_uInt16 rIn );
308 virtual sal_Int32 SAL_CALL in_methodLong( sal_Int32 rIn );
309 virtual sal_uInt32 SAL_CALL in_methodULong( sal_uInt32 rIn );
310 virtual sal_Int64 SAL_CALL in_methodHyper( sal_Int64 rIn );
311 virtual sal_uInt64 SAL_CALL in_methodUHyper( sal_uInt64 rIn );
312 virtual OUString SAL_CALL in_methodString( const OUString& rIn );
313 virtual sal_Unicode SAL_CALL in_methodChar( sal_Unicode rIn );
314 virtual Any SAL_CALL in_methodAny( const Any& rIn );
315 virtual Type SAL_CALL in_methodType( const Type& rIn );
316 virtual Reference<XInterface> SAL_CALL in_methodXInterface( const Reference< XInterface >& rIn );
317 virtual Reference<XInvocation > SAL_CALL in_methodInvocation( const Reference< XInvocation >& inv );
318 virtual SimpleStruct SAL_CALL in_methodStruct( const SimpleStruct& aStruct );
319 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 );
320
321 // XTestInterfaces --------------------------------------------------------------------------
322 virtual void SAL_CALL testInterface( const Reference< XCallback >& xCallback, sal_Int32 mode );
323 virtual void SAL_CALL testInterface2( const Reference< XSimple >& xSimple, sal_Int32 mode );
324 // XSimple --------------------------------------------------------------------------
325 void SAL_CALL func( const OUString &message);
326 OUString SAL_CALL getName();
327
328 // XIdentity
329 virtual void SAL_CALL setObject( const Reference< XInterface >& val );
330 virtual sal_Bool SAL_CALL isSame( const Reference< XInterface >& val );
331 virtual Reference< XInterface > SAL_CALL getThis( );
332 };
333
334 class EventListener: public WeakImplHelper1<XEventListener>
335 {
336 public:
EventListener()337 EventListener::EventListener(): bCalled( sal_False)
338 {}
339 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source );
340
341 sal_Bool bCalled;
342 };
343
344
~OComponent()345 OComponent::~OComponent()
346 {
347 }
348
349
350 // Funktions ==============================================================================
351
OComponent_CreateInstance(const Reference<XMultiServiceFactory> & rSMgr)352 Reference<XInterface> SAL_CALL OComponent_CreateInstance( const Reference<XMultiServiceFactory> & rSMgr )
353 {
354 // Reference<XInterface> xService(static_cast<XWeak*>(new OComponent( rSMgr )), UNO_QUERY);
355 OComponent* o= new OComponent( rSMgr );
356 Reference<XInterface> xService(static_cast<XIdentity*>(o), UNO_QUERY);
357 return xService;
358 }
359
OComponent_getSupportedServiceNames(void)360 Sequence<OUString> OComponent_getSupportedServiceNames(void)
361 {
362 Sequence<OUString> aRet(1);
363 aRet.getArray()[0] = SERVICE_NAME;//ODataInputStream_getImplementationName();
364
365 return aRet;
366 }
367
368
component_writeInfo(void *,void * pRegistryKey)369 extern "C" sal_Bool SAL_CALL component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey )
370 {
371 if(pRegistryKey)
372 {
373 try
374 {
375 Reference<XRegistryKey> xNewKey =
376 reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(KEY1);
377 xNewKey->createKey( KEY2);
378 return sal_True;
379
380 }
381 catch(InvalidRegistryException &)
382 {
383 OSL_ENSURE( sal_False, "### InvalidRegistryException!\n");
384 }
385 }
386 return sal_False;
387 }
388
component_getFactory(const sal_Char * pImplName,void * pServiceManager,void *)389 extern "C" void * SAL_CALL component_getFactory(
390 const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
391 {
392 static void * pRet= NULL;
393 if( ! pRet)
394 {
395 OUString aImplName( OUString::createFromAscii( pImplName ) );
396 if (pServiceManager && aImplName.equals( IMPL_NAME ))
397 {
398 Reference<XMultiServiceFactory> xMulFac(
399 reinterpret_cast< XMultiServiceFactory*>(pServiceManager));
400
401 Sequence<OUString> seqServiceNames;
402 Reference<XSingleServiceFactory> xFactory = createOneInstanceFactory( xMulFac, SERVICE_NAME,
403 OComponent_CreateInstance, seqServiceNames);
404
405 if (xFactory.is())
406 {
407 xFactory->acquire();
408 pRet = xFactory.get();
409 }
410 }
411 }
412 return pRet;
413 }
414
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)415 extern "C" void SAL_CALL component_getImplementationEnvironment(
416 const sal_Char ** ppEnvTypeName, uno_Environment ** )
417 {
418 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
419 }
420
421
422 // XTestSequence ============================================================================
methodByte(const Sequence<sal_Int8> & aSeq)423 Sequence<sal_Int8> SAL_CALL OComponent::methodByte(const Sequence< sal_Int8 >& aSeq)
424 {
425 sal_Int8 _x;
426 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
427 _x= aSeq.getConstArray()[i];
428 }
429 return aSeq;
430 }
methodFloat(const Sequence<float> & aSeq)431 Sequence<float> SAL_CALL OComponent::methodFloat(const Sequence< float>& aSeq)
432 {
433 float _x;
434 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
435 _x= aSeq.getConstArray()[i];
436 }
437 return aSeq;
438 }
methodDouble(const Sequence<double> & aSeq)439 Sequence<double> SAL_CALL OComponent::methodDouble(const Sequence< double >& aSeq)
440 {
441 double _x;
442 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
443 _x= aSeq.getConstArray()[i];
444 }
445 return aSeq;
446 }
methodBool(const Sequence<sal_Bool> & aSeq)447 Sequence< sal_Bool > SAL_CALL OComponent::methodBool(const Sequence< sal_Bool >& aSeq)
448 {
449 sal_Bool _x;
450 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
451 _x= aSeq.getConstArray()[i];
452 }
453 return aSeq;
454 }
methodShort(const Sequence<sal_Int16> & aSeq)455 Sequence< sal_Int16 > SAL_CALL OComponent::methodShort(const Sequence< sal_Int16 >& aSeq)
456 {
457 sal_Int16 _x;
458 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
459 _x= aSeq.getConstArray()[i];
460 }
461 return aSeq;
462 }
methodUShort(const Sequence<sal_uInt16> & aSeq)463 Sequence< sal_uInt16 > SAL_CALL OComponent::methodUShort(const Sequence< sal_uInt16 >& aSeq)
464 {
465 sal_uInt16 _x;
466 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
467 _x= aSeq.getConstArray()[i];
468 }
469 return aSeq;
470 }
methodLong(const Sequence<sal_Int32> & aSeq)471 Sequence< sal_Int32 > SAL_CALL OComponent::methodLong(const Sequence< sal_Int32 >& aSeq)
472 {
473 sal_Int32 _x;
474 for( sal_Int16 i= 0; i < aSeq.getLength(); i++) {
475 _x= aSeq.getConstArray()[i];
476 }
477 return aSeq;
478 }
methodULong(const Sequence<sal_uInt32> & aSeq)479 Sequence< sal_uInt32 > SAL_CALL OComponent::methodULong(const Sequence< sal_uInt32 >& aSeq)
480 {
481 sal_uInt32 _x;
482 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
483 _x= aSeq.getConstArray()[i];
484 }
485 return aSeq;
486 }
methodString(const Sequence<OUString> & aSeq)487 Sequence< OUString > SAL_CALL OComponent::methodString(const Sequence< OUString >& aSeq)
488 {
489 OUString _x;
490 for( sal_Int16 i= 0; i < aSeq.getLength(); i++) {
491 _x= aSeq.getConstArray()[i];
492 }
493 return aSeq;
494 }
methodChar(const Sequence<sal_Unicode> & aSeq)495 Sequence< sal_Unicode > SAL_CALL OComponent::methodChar(const Sequence< sal_Unicode >& aSeq)
496 {
497 sal_Unicode _x;
498 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
499 _x= aSeq.getConstArray()[i];
500 }
501 return aSeq;
502 }
methodAny(const Sequence<Any> & aSeq)503 Sequence< Any > SAL_CALL OComponent::methodAny(const Sequence< Any >& aSeq)
504 {
505 Any _x;
506 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
507 _x= aSeq.getConstArray()[i];
508 TypeClass _t= _x.getValueTypeClass();
509 if( _t== TypeClass_STRING)
510 OUString s(* (rtl_uString**)_x.getValue());
511 }
512 return aSeq;
513
514 }
515
methodType(const Sequence<Type> & aSeq)516 Sequence< Type > SAL_CALL OComponent::methodType(const Sequence< Type >& aSeq)
517 {
518 Type _x;
519 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
520 _x= aSeq.getConstArray()[i];
521 }
522 return aSeq;
523 }
524 //Sequence< Reference< XInterface> > SAL_CALL methodXInterface ( const Sequence< Reference < XInterface> >& aSeq)
525 // throw (RuntimeException)
methodXInterface(const Sequence<Reference<XInterface>> & aSeq)526 Sequence< Reference< XInterface > > SAL_CALL OComponent::methodXInterface( const Sequence< Reference< XInterface > >& aSeq )
527 {
528 for( sal_Int32 i= 0; i < aSeq.getLength(); i++)
529 {
530 Reference<XInterface> xInt= aSeq[i];
531 Reference<XEventListener> xList( xInt, UNO_QUERY);
532 if( xList.is())
533 xList->disposing( EventObject());
534 }
535 return aSeq;
536 }
537
methodSequence(const Sequence<Sequence<sal_Int32>> & aSeq)538 Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::methodSequence(const Sequence< Sequence< sal_Int32 > >& aSeq)
539 {
540 sal_Int32 value;
541 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
542 const Sequence<sal_Int32>& rseq2= aSeq.getConstArray()[i];
543 for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
544 value= rseq2.getConstArray()[j];
545 }
546 }
547 return aSeq;
548 }
methodSequence2(const Sequence<Sequence<Sequence<sal_Int32>>> & aSeq)549 Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL OComponent::methodSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq)
550 {
551 sal_Int32 value;
552 sal_Int32 len= aSeq.getLength();
553 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
554 const Sequence< Sequence<sal_Int32> >& rseq2= aSeq.getConstArray()[i];
555 len= rseq2.getLength();
556
557 for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
558 const Sequence<sal_Int32> & rseq3= rseq2.getConstArray()[j];
559 len= rseq3.getLength();
560
561 for (sal_Int16 k= 0; k < rseq3.getLength(); k++)
562 value= rseq3.getConstArray()[k];
563 }
564 }
565 return aSeq;
566 }
567
methodXEventListeners(const Sequence<Reference<XEventListener>> & aSeq)568 Sequence< Reference< XEventListener> > SAL_CALL OComponent::methodXEventListeners( const Sequence< Reference <XEventListener> >& aSeq)
569 {
570 Reference<XEventListener> listener;
571 for( int i= 0; i < aSeq.getLength(); i++)
572 {
573 listener= aSeq[i];
574
575 listener->disposing( EventObject() );
576 }
577
578 return aSeq;
579 }
580
methodXEventListenersMul(const Sequence<Sequence<Reference<XEventListener>>> & aSeq)581 Sequence< Sequence<Reference<XEventListener > > > SAL_CALL OComponent::methodXEventListenersMul( const Sequence<Sequence<Reference<XEventListener > > >& aSeq )
582 {
583 Reference<XEventListener> listener;
584 for( int i= 0; i < aSeq.getLength(); i++)
585 {
586 Sequence<Reference<XEventListener> > seqInner= aSeq[i];
587 for( int j= 0; j < seqInner.getLength(); j++)
588 {
589 listener= seqInner[j];
590 listener->disposing( EventObject() );
591 }
592 }
593 return aSeq;
594 }
595
596 //---------------------------------------------------------------------------------------------
597
getAttrByte(void)598 Sequence< sal_Int8 > SAL_CALL OComponent::getAttrByte(void)
599 {
600 return m_seqByte;
601 }
setAttrByte(const Sequence<sal_Int8> & AttrByte_)602 void SAL_CALL OComponent::setAttrByte(const Sequence< sal_Int8 >& AttrByte_)
603 {
604 m_seqByte= AttrByte_;
605 }
getAttrFloat(void)606 Sequence< float > SAL_CALL OComponent::getAttrFloat(void)
607 {
608 return m_seqFloat;
609 }
setAttrFloat(const Sequence<float> & AttrFloat_)610 void SAL_CALL OComponent::setAttrFloat(const Sequence< float >& AttrFloat_)
611 {
612 m_seqFloat= AttrFloat_;
613 }
614
getAttrDouble(void)615 Sequence< double > SAL_CALL OComponent::getAttrDouble(void)
616 {
617 return m_seqDouble;
618 }
setAttrDouble(const Sequence<double> & AttrDouble_)619 void SAL_CALL OComponent::setAttrDouble(const Sequence< double >& AttrDouble_)
620 {
621 m_seqDouble= AttrDouble_;
622 }
623
getAttrBool(void)624 Sequence< sal_Bool > SAL_CALL OComponent::getAttrBool(void)
625 {
626 return m_seqBool;
627 }
628
setAttrBool(const Sequence<sal_Bool> & AttrBool_)629 void SAL_CALL OComponent::setAttrBool(const Sequence< sal_Bool >& AttrBool_)
630 {
631 m_seqBool= AttrBool_;
632 }
633
getAttrShort(void)634 Sequence< sal_Int16 > SAL_CALL OComponent::getAttrShort(void)
635 {
636 return m_seqShort;
637 }
setAttrShort(const Sequence<sal_Int16> & AttrShort_)638 void SAL_CALL OComponent::setAttrShort(const Sequence< sal_Int16 >& AttrShort_)
639 {
640 m_seqShort= AttrShort_;
641 }
642
getAttrUShort(void)643 Sequence< sal_uInt16 > SAL_CALL OComponent::getAttrUShort(void)
644 {
645 return m_seqUShort;
646 }
setAttrUShort(const Sequence<sal_uInt16> & AttrUShort_)647 void SAL_CALL OComponent::setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_)
648 {
649 m_seqUShort= AttrUShort_;
650 }
651
getAttrLong(void)652 Sequence< sal_Int32 > SAL_CALL OComponent::getAttrLong(void)
653 {
654 return m_seqLong;
655 }
setAttrLong(const Sequence<sal_Int32> & AttrLong_)656 void SAL_CALL OComponent::setAttrLong(const Sequence< sal_Int32 >& AttrLong_)
657 {
658 m_seqLong= AttrLong_;
659 }
660
getAttrULong(void)661 Sequence< sal_uInt32 > SAL_CALL OComponent::getAttrULong(void)
662 {
663 return m_seqULong;
664 }
setAttrULong(const Sequence<sal_uInt32> & AttrULong_)665 void SAL_CALL OComponent::setAttrULong(const Sequence< sal_uInt32 >& AttrULong_)
666 {
667 m_seqULong= AttrULong_;
668 }
669
getAttrString(void)670 Sequence< OUString > SAL_CALL OComponent::getAttrString(void)
671 {
672 return m_seqString;
673 }
setAttrString(const Sequence<OUString> & AttrString_)674 void SAL_CALL OComponent::setAttrString(const Sequence< OUString >& AttrString_)
675 {
676 m_seqString= AttrString_;
677 }
678
getAttrChar(void)679 Sequence< sal_Unicode > SAL_CALL OComponent::getAttrChar(void)
680 {
681 return m_seqChar;
682 }
setAttrChar(const Sequence<sal_Unicode> & AttrChar_)683 void SAL_CALL OComponent::setAttrChar(const Sequence< sal_Unicode >& AttrChar_)
684 {
685 m_seqChar= AttrChar_;
686 }
687
getAttrAny(void)688 Sequence< Any > SAL_CALL OComponent::getAttrAny(void)
689 {
690 return m_seqAny;
691 }
setAttrAny(const Sequence<Any> & AttrAny_)692 void SAL_CALL OComponent::setAttrAny(const Sequence< Any >& AttrAny_)
693 {
694 m_seqAny= AttrAny_;
695 }
696
getAttrType(void)697 Sequence< Type > SAL_CALL OComponent::getAttrType(void)
698 {
699 return m_seqType;
700 }
701
setAttrType(const Sequence<Type> & AttrType_)702 void SAL_CALL OComponent::setAttrType( const Sequence< Type >& AttrType_)
703 {
704 m_seqType = AttrType_;
705 }
706
707
getAttrSequence(void)708 Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::getAttrSequence(void)
709 {
710 return m_seq1;
711 }
setAttrSequence(const Sequence<Sequence<sal_Int32>> & AttrSequence)712 void SAL_CALL OComponent::setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence)
713 {
714 sal_Int32 x= 0;
715 for( sal_Int32 i=0; i < AttrSequence.getLength(); i++)
716 {
717 Sequence< sal_Int32 > seq= AttrSequence[i];
718
719 for ( sal_Int32 j=0; j < seq.getLength(); j++)
720 {
721 x= seq[j];
722 }
723 }
724
725 m_seq1= AttrSequence;
726 }
727
getAttrSequence2(void)728 Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL OComponent::getAttrSequence2(void)
729 {
730 return m_seq2;
731 }
setAttrSequence2(const Sequence<Sequence<Sequence<sal_Int32>>> & AttrSequence2_)732 void SAL_CALL OComponent::setAttrSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& AttrSequence2_)
733 {
734 m_seq2= AttrSequence2_;
735 }
736
getAttrXInterface()737 Sequence< Reference< XInterface > > SAL_CALL OComponent::getAttrXInterface()
738 {
739 return m_seqxInterface;
740 }
setAttrXInterface(const Sequence<Reference<XInterface>> & _attrxinterface)741 void SAL_CALL OComponent::setAttrXInterface( const Sequence< Reference< XInterface > >& _attrxinterface )
742 {
743 m_seqxInterface= _attrxinterface;
744 }
745
746 // ----------------------------------------------------------------------------
747
getAByte()748 ::sal_Int8 SAL_CALL OComponent::getAByte()
749 {
750 return m_attr_int8;
751 }
752
setAByte(::sal_Int8 _abyte)753 void SAL_CALL OComponent::setAByte( ::sal_Int8 _abyte )
754 {
755 m_attr_int8 = _abyte;
756 }
757
getAFloat()758 float SAL_CALL OComponent::getAFloat()
759 {
760 return m_attr_float;
761 }
762
setAFloat(float _afloat)763 void SAL_CALL OComponent::setAFloat( float _afloat )
764 {
765 m_attr_float = _afloat;
766 }
767
getADouble()768 double SAL_CALL OComponent::getADouble()
769 {
770 return m_attr_double;
771 }
772
setADouble(double _adouble)773 void SAL_CALL OComponent::setADouble( double _adouble )
774 {
775 m_attr_double = _adouble;
776 }
777
getABool()778 ::sal_Bool SAL_CALL OComponent::getABool()
779 {
780 return m_attr_bool;
781 }
782
setABool(::sal_Bool _abool)783 void SAL_CALL OComponent::setABool( ::sal_Bool _abool )
784 {
785 m_attr_bool = _abool;
786 }
787
getAShort()788 ::sal_Int16 SAL_CALL OComponent::getAShort()
789 {
790 return m_attr_int16;
791 }
792
setAShort(::sal_Int16 _ashort)793 void SAL_CALL OComponent::setAShort( ::sal_Int16 _ashort )
794 {
795 m_attr_int16 = _ashort;
796 }
797
getAUShort()798 ::sal_uInt16 SAL_CALL OComponent::getAUShort()
799 {
800 return m_attr_uint16;
801 }
802
setAUShort(::sal_uInt16 _aushort)803 void SAL_CALL OComponent::setAUShort( ::sal_uInt16 _aushort )
804 {
805 m_attr_uint16 = _aushort;
806 }
807
getALong()808 ::sal_Int32 SAL_CALL OComponent::getALong()
809 {
810 return m_attr_int32;
811 }
812
setALong(::sal_Int32 _along)813 void SAL_CALL OComponent::setALong( ::sal_Int32 _along )
814 {
815 m_attr_int32 = _along;
816 }
817
getAULong()818 ::sal_uInt32 SAL_CALL OComponent::getAULong()
819 {
820 return m_attr_uint32;
821 }
822
setAULong(::sal_uInt32 _aulong)823 void SAL_CALL OComponent::setAULong( ::sal_uInt32 _aulong )
824 {
825 m_attr_uint32 = _aulong;
826 }
827
getAString()828 ::rtl::OUString SAL_CALL OComponent::getAString()
829 {
830 return m_attr_string;
831 }
832
setAString(const::rtl::OUString & _astring)833 void SAL_CALL OComponent::setAString( const ::rtl::OUString& _astring )
834 {
835 m_attr_string = _astring;
836 }
837
getAChar()838 ::sal_Unicode SAL_CALL OComponent::getAChar()
839 {
840 return m_attr_char;
841 }
842
setAChar(::sal_Unicode _achar)843 void SAL_CALL OComponent::setAChar( ::sal_Unicode _achar )
844 {
845 m_attr_char = _achar;
846 }
847
getAAny()848 Any SAL_CALL OComponent::getAAny()
849 {
850 return m_attr_any;
851 }
852
setAAny(const Any & _aany)853 void SAL_CALL OComponent::setAAny( const Any& _aany )
854 {
855 m_attr_any = _aany;
856 }
857
getAType()858 Type SAL_CALL OComponent::getAType()
859 {
860 return m_attr_type;
861 }
862
setAType(const Type & _atype)863 void SAL_CALL OComponent::setAType( const Type& _atype )
864 {
865 m_attr_type = _atype;
866 }
867
getAXInterface()868 Reference< XInterface > SAL_CALL OComponent::getAXInterface()
869 {
870 return m_attr_xinterface;
871 }
872
setAXInterface(const Reference<XInterface> & _axinterface)873 void SAL_CALL OComponent::setAXInterface( const Reference<XInterface >& _axinterface )
874 {
875 m_attr_xinterface = _axinterface;
876 }
877
getAXInvocation()878 Reference<XInvocation > SAL_CALL OComponent::getAXInvocation()
879 {
880 return m_attr_xinvocation;
881 }
882
setAXInvocation(const Reference<XInvocation> & _axinvocation)883 void SAL_CALL OComponent::setAXInvocation( const Reference< XInvocation >& _axinvocation )
884 {
885 m_attr_xinvocation = _axinvocation;
886 }
887 //-----------------------------------------------------------------------------------
testout_methodByte(sal_Int8 & rOut)888 void SAL_CALL OComponent::testout_methodByte(sal_Int8& rOut)
889 {
890 rOut= m_int8;
891 }
testout_methodFloat(float & rOut)892 void SAL_CALL OComponent::testout_methodFloat(float& rOut)
893 {
894 rOut= m_float;
895 }
testout_methodDouble(double & rOut)896 void SAL_CALL OComponent::testout_methodDouble(double& rOut)
897 {
898 rOut= m_double;
899 }
900
testout_methodBool(sal_Bool & rOut)901 void SAL_CALL OComponent::testout_methodBool(sal_Bool& rOut)
902 {
903 rOut= m_bool;
904 }
testout_methodShort(sal_Int16 & rOut)905 void SAL_CALL OComponent::testout_methodShort(sal_Int16& rOut)
906 {
907 rOut= m_int16;
908 }
testout_methodUShort(sal_uInt16 & rOut)909 void SAL_CALL OComponent::testout_methodUShort(sal_uInt16& rOut)
910 {
911 rOut= m_uint16;
912 }
testout_methodLong(sal_Int32 & rOut)913 void SAL_CALL OComponent::testout_methodLong(sal_Int32& rOut)
914 {
915 rOut = m_int32;
916 }
testout_methodULong(sal_uInt32 & rOut)917 void SAL_CALL OComponent::testout_methodULong(sal_uInt32& rOut)
918 {
919 rOut= m_uint32;
920 }
testout_methodHyper(sal_Int64 & rOut)921 void SAL_CALL OComponent::testout_methodHyper(sal_Int64& rOut)
922 {
923 rOut = m_int64;
924 }
925
testout_methodUHyper(sal_uInt64 & rOut)926 void SAL_CALL OComponent::testout_methodUHyper(sal_uInt64& rOut)
927 {
928 rOut = m_uint64;
929 }
930
testout_methodString(OUString & rOut)931 void SAL_CALL OComponent::testout_methodString(OUString& rOut)
932 {
933 rOut= m_string;
934 }
testout_methodChar(sal_Unicode & rOut)935 void SAL_CALL OComponent::testout_methodChar(sal_Unicode& rOut)
936 {
937 rOut= m_char;
938 }
testout_methodAny(Any & rOut)939 void SAL_CALL OComponent::testout_methodAny(Any& rOut)
940 {
941 rOut = m_any;
942 }
943
testout_methodType(Type & rOut)944 void SAL_CALL OComponent::testout_methodType(Type& rOut)
945 {
946 rOut = m_type;
947 }
948
testout_methodSequence(Sequence<sal_Int32> & rOut)949 void SAL_CALL OComponent::testout_methodSequence(Sequence< sal_Int32 >& rOut)
950 {
951 rOut.realloc(10);
952 for( sal_Int16 i= 0; i < rOut.getLength(); i++) rOut.getArray()[i]= i;
953 }
testout_methodSequence2(Sequence<Sequence<sal_Int32>> & rOut)954 void SAL_CALL OComponent::testout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut)
955 {
956 rOut.realloc( 10);
957 for( sal_Int16 i= 0; i < rOut.getLength(); i++){
958 Sequence<sal_Int32>& rseq2= rOut.getArray()[i];
959 rseq2.realloc( 10);
960 for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
961 rseq2.getArray()[j]= j;
962 }
963 }
964 }
testout_methodMulParams1(sal_Int32 & rout1,sal_Int32 & rout2)965 void SAL_CALL OComponent::testout_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2)
966 {
967 rout1= 999;
968 rout2= 1111;
969 }
testout_methodMulParams2(sal_Int32 & rout1,sal_Int32 & rout2,OUString & rout3)970 void SAL_CALL OComponent::testout_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3)
971 {
972 rout1= 1111;
973 rout2= 1222;
974 rout3= L" another string";
975 }
testout_methodMulParams3(const OUString &,OUString & sout)976 void SAL_CALL OComponent::testout_methodMulParams3(const OUString&, OUString& sout)
977 {
978 sout= L"Out Hallo!";
979 }
testout_methodMulParams4(float in1,float & out1,sal_Int32 in2,sal_Int32 & out2,sal_Int32)980 void SAL_CALL OComponent::testout_methodMulParams4( float in1, float& out1, sal_Int32 in2, sal_Int32& out2, sal_Int32 )
981 {
982 out1= in1 + 1;
983 out2= in2 + 1;
984 }
985
testout_methodXInterface(Reference<XInterface> & rOut)986 void SAL_CALL OComponent::testout_methodXInterface( Reference< XInterface >& rOut )
987 {
988 rOut = m_xinterface;
989 // OUString string( L"Property Any");
990 // m_any <<= string;
991 // rOut= Reference<XInterface> (static_cast<XTestSequence*>(this), UNO_QUERY);
992 }
993
994 // XTestInParameters ------------------------------------------------------------
in_methodByte(sal_Int8 rIn)995 sal_Int8 SAL_CALL OComponent::in_methodByte( sal_Int8 rIn )
996 {
997 m_int8 = rIn;
998 return rIn;
999 }
in_methodFloat(float rIn)1000 float SAL_CALL OComponent::in_methodFloat( float rIn )
1001 {
1002 m_float = rIn;
1003 return rIn;
1004 }
in_methodDouble(double rIn)1005 double SAL_CALL OComponent::in_methodDouble( double rIn )
1006 {
1007 m_double = rIn;
1008 return rIn;
1009 }
in_methodBool(sal_Bool rIn)1010 sal_Bool SAL_CALL OComponent::in_methodBool( sal_Bool rIn )
1011 {
1012 m_bool = rIn;
1013 return rIn;
1014 }
in_methodShort(sal_Int16 rIn)1015 sal_Int16 SAL_CALL OComponent::in_methodShort( sal_Int16 rIn )
1016 {
1017 m_int16 = rIn;
1018 return rIn;
1019 }
in_methodUShort(sal_uInt16 rIn)1020 sal_uInt16 SAL_CALL OComponent::in_methodUShort( sal_uInt16 rIn )
1021 {
1022 m_uint16 = rIn;
1023 return rIn;
1024 }
in_methodLong(sal_Int32 rIn)1025 sal_Int32 SAL_CALL OComponent::in_methodLong( sal_Int32 rIn )
1026 {
1027 m_int32 = rIn;
1028 return rIn;
1029 }
in_methodULong(sal_uInt32 rIn)1030 sal_uInt32 SAL_CALL OComponent::in_methodULong( sal_uInt32 rIn )
1031 {
1032 m_uint32 = rIn;
1033 return rIn;
1034 }
in_methodHyper(sal_Int64 rIn)1035 sal_Int64 SAL_CALL OComponent::in_methodHyper( sal_Int64 rIn )
1036 {
1037 m_int64 = rIn;
1038 return rIn;
1039 }
1040
in_methodUHyper(sal_uInt64 rIn)1041 sal_uInt64 SAL_CALL OComponent::in_methodUHyper( sal_uInt64 rIn )
1042 {
1043 m_uint64 = rIn;
1044 return rIn;
1045 }
1046
in_methodString(const OUString & rIn)1047 OUString SAL_CALL OComponent::in_methodString( const OUString& rIn )
1048 {
1049 m_string = rIn;
1050 return rIn;
1051 }
in_methodChar(sal_Unicode rIn)1052 sal_Unicode SAL_CALL OComponent::in_methodChar( sal_Unicode rIn )
1053 {
1054 m_char = rIn;
1055 return rIn;
1056 }
in_methodAny(const Any & rIn)1057 Any SAL_CALL OComponent::in_methodAny( const Any& rIn )
1058 {
1059 m_any = rIn;
1060 return rIn;
1061 }
1062
in_methodType(const Type & rIn)1063 Type SAL_CALL OComponent::in_methodType( const Type& rIn )
1064 {
1065 m_type = rIn;
1066 return rIn;
1067 }
1068
in_methodInvocation(const Reference<XInvocation> & inv)1069 Reference<XInvocation > SAL_CALL OComponent::in_methodInvocation( const Reference< XInvocation >& inv )
1070 {
1071 //We expect the invocation results from a conversion of VBasicEventListener.VBEventListener
1072 //which implements XEventListener
1073 // extensions/test/ole/EventListenerSample
1074 EventObject event( Reference<XInterface>(static_cast<XTestInParameters*>(this),UNO_QUERY));
1075 Any anyParam;
1076 anyParam <<= event;
1077 Sequence<Any> params( &anyParam, 1);
1078 Sequence<sal_Int16> outIndex;
1079 Sequence<Any> outParams;
1080 try{
1081 inv->invoke( OUString(RTL_CONSTASCII_USTRINGPARAM("disposing")),
1082 params, outIndex, outParams);
1083 }catch(IllegalArgumentException &) {
1084 }
1085 catch(CannotConvertException &){
1086 }
1087 catch(InvocationTargetException&) {
1088 }
1089 return inv;
1090 }
in_methodXInterface(const Reference<XInterface> & rIn)1091 Reference<XInterface> SAL_CALL OComponent::in_methodXInterface( const Reference<XInterface >& rIn )
1092 {
1093 m_xinterface = rIn;
1094 return rIn;
1095 }
1096
in_methodStruct(const SimpleStruct & aStruct)1097 SimpleStruct SAL_CALL OComponent::in_methodStruct( const SimpleStruct& aStruct )
1098 {
1099 SimpleStruct& s= const_cast<SimpleStruct&>(aStruct);
1100 s.message= s.message + OUString(RTL_CONSTASCII_USTRINGPARAM(
1101 "This string was set in OleTest"));
1102 return aStruct;
1103 }
in_methodAll(sal_Int8,float,double,sal_Bool,sal_Int16,sal_uInt16,sal_Int32,sal_uInt32,const OUString &,sal_Unicode,const Any &,const Type &,const Reference<XInvocation> &)1104 void SAL_CALL OComponent::in_methodAll(
1105 sal_Int8, float, double, sal_Bool, sal_Int16, sal_uInt16,
1106 sal_Int32, sal_uInt32, const OUString&, sal_Unicode,
1107 const Any&, const Type&, const Reference<XInvocation>&)
1108 {
1109 }
1110
1111 // INOUT -----------------------------------------------------------------------------------
testinout_methodByte(sal_Int8 & rOut)1112 void SAL_CALL OComponent::testinout_methodByte(sal_Int8& rOut)
1113 {
1114 sal_Int8 tmp = rOut;
1115 rOut = m_int8;
1116 m_int8 = tmp;
1117 }
testinout_methodFloat(float & rOut)1118 void SAL_CALL OComponent::testinout_methodFloat(float& rOut)
1119 {
1120 float tmp = rOut;
1121 rOut = m_float;
1122 m_float = tmp;
1123 }
1124
testinout_methodDouble(double & rOut)1125 void SAL_CALL OComponent::testinout_methodDouble(double& rOut)
1126 {
1127 double tmp = rOut;
1128 rOut = m_double;
1129 m_double = tmp;
1130 }
testinout_methodBool(sal_Bool & rOut)1131 void SAL_CALL OComponent::testinout_methodBool(sal_Bool& rOut)
1132 {
1133 sal_Bool tmp = rOut;
1134 rOut = m_bool;
1135 m_bool = tmp;
1136 }
testinout_methodShort(sal_Int16 & rOut)1137 void SAL_CALL OComponent::testinout_methodShort(sal_Int16& rOut)
1138 {
1139 sal_Int16 tmp= rOut;
1140 rOut = m_int16;
1141 m_int16 = tmp;
1142 }
testinout_methodUShort(sal_uInt16 & rOut)1143 void SAL_CALL OComponent::testinout_methodUShort(sal_uInt16& rOut)
1144 {
1145 sal_uInt16 tmp = rOut;
1146 rOut = m_uint16;
1147 m_uint16 = tmp;
1148 }
testinout_methodLong(sal_Int32 & rOut)1149 void SAL_CALL OComponent::testinout_methodLong(sal_Int32& rOut)
1150 {
1151 sal_Int32 tmp = rOut;
1152 rOut = m_int32;
1153 m_int32 = tmp;
1154 }
testinout_methodULong(sal_uInt32 & rOut)1155 void SAL_CALL OComponent::testinout_methodULong(sal_uInt32& rOut)
1156 {
1157 sal_uInt32 tmp = rOut;
1158 rOut = m_uint32;
1159 m_uint32 = tmp;
1160 }
testinout_methodHyper(sal_Int64 & rOut)1161 void SAL_CALL OComponent::testinout_methodHyper(sal_Int64& rOut)
1162 {
1163 sal_Int64 tmp = rOut;
1164 rOut = m_int64;
1165 m_int64 = tmp;
1166 }
1167
testinout_methodUHyper(sal_uInt64 & rOut)1168 void SAL_CALL OComponent::testinout_methodUHyper(sal_uInt64& rOut)
1169 {
1170 sal_uInt64 tmp = rOut;
1171 rOut = m_uint64;
1172 m_uint64 = tmp;
1173 }
1174
testinout_methodString(OUString & rOut)1175 void SAL_CALL OComponent::testinout_methodString(OUString& rOut)
1176 {
1177 OUString tmp = rOut;
1178 rOut = m_string;
1179 m_string = tmp;
1180 }
testinout_methodChar(sal_Unicode & rOut)1181 void SAL_CALL OComponent::testinout_methodChar(sal_Unicode& rOut)
1182 {
1183 sal_Unicode tmp = rOut;
1184 rOut = m_char;
1185 m_char = tmp;
1186 }
testinout_methodAny(Any & rOut)1187 void SAL_CALL OComponent::testinout_methodAny(Any& rOut)
1188 {
1189 Any tmp = rOut;
1190 rOut = m_any;
1191 m_any = tmp;
1192 }
testinout_methodType(Type & rOut)1193 void SAL_CALL OComponent::testinout_methodType(Type& rOut)
1194 {
1195 Type tmp = rOut;
1196 rOut = m_type;
1197 m_type = tmp;
1198 }
1199
1200
testinout_methodSequence(Sequence<sal_Int32> & rOut)1201 void SAL_CALL OComponent::testinout_methodSequence(Sequence< sal_Int32 >& rOut)
1202 {
1203
1204 sal_Int32* arr= rOut.getArray();
1205 for ( sal_Int32 i=0; i < rOut.getLength(); i++)
1206 {
1207 rOut.getArray()[i] += 1;
1208 }
1209 }
testinout_methodSequence2(Sequence<Sequence<sal_Int32>> & rOut)1210 void SAL_CALL OComponent::testinout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut)
1211 {
1212 for( sal_Int32 i=0; i < rOut.getLength(); i++)
1213 {
1214 Sequence< sal_Int32 >& seq= rOut.getArray()[i];
1215
1216 for ( sal_Int32 j=0; j < seq.getLength(); j++)
1217 {
1218 seq.getArray()[j] += seq.getArray()[j];
1219 }
1220 }
1221 }
1222
1223 // The parameter should implement XInvocation and a Property "value"
testinout_methodXInterface(Reference<XInvocation> & rOut)1224 void SAL_CALL OComponent::testinout_methodXInterface( Reference< XInvocation >& rOut )
1225 {
1226 Any any;
1227 any= rOut->getValue( OUString( L"value"));
1228 OUString _s;
1229 any >>= _s;
1230 OUString string(L"out");
1231 any <<= string;
1232 rOut->setValue( OUString(L"value"), any);
1233
1234 any= rOut->getValue( OUString( L"value"));
1235 any >>= _s;
1236
1237 }
1238
testinout_methodXInterface2(Reference<XInterface> & rOut)1239 void SAL_CALL OComponent::testinout_methodXInterface2( Reference< XInterface > & rOut)
1240 {
1241 Reference<XInterface> tmp = rOut;
1242 rOut = m_xinterface;
1243 m_xinterface = tmp;
1244 // Reference<XTestSequence> xTest( rOut, UNO_QUERY);
1245 // if( xTest.is())
1246 // {
1247 // Any any= xTest->getAttrAny2();
1248 // OUString _s;
1249 // any >>= _s;
1250 // OUString string= _s + OUString((L" this string was written in the UNO component to the inout parameter"));
1251 // any <<= string;
1252 // xTest->setAttrAny2( any);
1253 // }
1254
1255 }
methodAnyTest1(const Any & rIn)1256 Any SAL_CALL OComponent::methodAnyTest1(const Any& rIn)
1257 {
1258 return rIn;
1259 }
getAttrAny2(void)1260 Any SAL_CALL OComponent::getAttrAny2(void)
1261 {
1262 return m_any;
1263 }
setAttrAny2(const Any & AttrAny2_)1264 void SAL_CALL OComponent::setAttrAny2(const Any& AttrAny2_)
1265 {
1266 m_any= AttrAny2_;
1267 }
1268
1269
1270
1271 // XTestStruct =======================================================================================
1272
methodStruct(const Property & aProp)1273 void SAL_CALL OComponent::methodStruct(const Property& aProp)
1274 {
1275 char buff[1024];
1276 buff[0]= 0;
1277 sprintf( buff,"Property::Attribute : %d \n Property::Handle : %d \n Property::Name : %S",
1278 aProp.Attributes, aProp.Handle, (const sal_Unicode*)aProp.Name);
1279 MessageBox( NULL, A2T(buff), _T("OleTest: methodStruct"), MB_OK);
1280 }
1281
retMethodStruct(void)1282 Property SAL_CALL OComponent::retMethodStruct(void)
1283 {
1284 Property a(L"OleTest_Property", 255, getCppuType( (Reference<XInterface>*)0), PropertyAttribute::MAYBEVOID |
1285 PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED |
1286 PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY |
1287 PropertyAttribute::MAYBEAMBIGUOUS | PropertyAttribute::MAYBEDEFAULT );
1288 return a;
1289 }
1290
getAttrStruct(void)1291 Property SAL_CALL OComponent::getAttrStruct(void)
1292 {
1293 Property a(L"OleTest_Property", 255, getCppuType( (Reference<XInterface>*)0), PropertyAttribute::MAYBEVOID |
1294 PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED |
1295 PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY |
1296 PropertyAttribute::MAYBEAMBIGUOUS | PropertyAttribute::MAYBEDEFAULT );
1297 return a;
1298
1299 }
1300
setAttrStruct(const Property & AttrStruct_)1301 void SAL_CALL OComponent::setAttrStruct(const Property& AttrStruct_)
1302 {
1303 char buff[1024];
1304 buff[0]= 0;
1305 sprintf( buff,"Property::Attribute : %d \n Property::Handle : %d \n Property::Name : %S",
1306 AttrStruct_.Attributes, AttrStruct_.Handle, (const sal_Unicode*)AttrStruct_.Name);
1307 // MessageBox( NULL, A2T(buff), _T("OleTest: setAttrStruct"), MB_OK);
1308 }
1309
methodStruct2(const Property & aProp)1310 Property SAL_CALL OComponent::methodStruct2( const Property& aProp )
1311 {
1312 return aProp;
1313 }
1314
1315 // XTestOther ==================================================================================
other_methodAnyIn(const Any &)1316 void SAL_CALL OComponent::other_methodAnyIn(const Any& )
1317 {
1318 }
other_methodAnyOut(Any & rAny)1319 void SAL_CALL OComponent::other_methodAnyOut(Any& rAny)
1320 {
1321 rAny <<= OUString(L"Ein Any");
1322 }
1323
other_methodAnyRet(void)1324 Any SAL_CALL OComponent::other_methodAnyRet(void)
1325 {
1326 Any a;
1327 a <<= OUString(L"Ein Any");
1328 return a;
1329 }
in_float(float val)1330 void SAL_CALL OComponent::in_float( float val)
1331 {
1332 USES_CONVERSION;
1333 char buff[256];
1334 sprintf( buff, "parameter : %f", val);
1335 MessageBox( NULL, A2T(buff), _T("OleTest"), MB_OK);
1336 }
other_methodAny(const Any & rAny,const OUString & typeInAny)1337 Any SAL_CALL OComponent::other_methodAny( const Any& rAny, const OUString& typeInAny )
1338 {
1339 Type expectedType;
1340 typelib_TypeDescription * pDesc= NULL;
1341 typelib_typedescription_getByName( &pDesc, typeInAny.pData );
1342 if( pDesc)
1343 {
1344 expectedType = Type( pDesc->pWeakRef );
1345 typelib_typedescription_release( pDesc);
1346 }
1347 if (rAny.getValueType() != expectedType)
1348 throw RuntimeException();
1349
1350 return rAny;
1351 }
1352
1353 // XTestOutParameters ============================================================================
1354 // void SAL_CALL OComponent::out_test(sal_Int8 rIn) throw( RuntimeException )
1355 // {
1356 // }
1357
1358 // void SAL_CALL OComponent::out_methodByte(sal_Int8& rOut) throw( RuntimeException )
1359 // {
1360 // rOut= 100;
1361 // }
1362
1363 // void SAL_CALL OComponent::out_methodDouble(double& rOut) throw( RuntimeException )
1364 // {
1365 // rOut= 3.14;
1366 // }
1367 // void SAL_CALL OComponent::out_methodFloat(float& rOut) throw( RuntimeException )
1368 // {
1369 // rOut= 3.14;
1370 // }
1371 // void SAL_CALL OComponent::out_methodBool(sal_Bool& rOut) throw( RuntimeException )
1372 // {
1373 // rOut= sal_True;
1374 // }
1375 // void SAL_CALL OComponent::out_methodShort(sal_Int16& rOut) throw( RuntimeException )
1376 // {
1377 // rOut= -100;
1378 // }
1379 // void SAL_CALL OComponent::out_methodUShort(sal_uInt16& rOut) throw( RuntimeException )
1380 // {
1381 // rOut= 100;
1382 // }
1383 // void SAL_CALL OComponent::out_methodLong(sal_Int32& rOut) throw( RuntimeException )
1384 // {
1385 // rOut= -100;
1386 // }
1387
1388 // void SAL_CALL OComponent::out_methodULong(sal_uInt32& rOut) throw( RuntimeException )
1389 // {
1390 // rOut= 100;
1391 // }
1392 // void SAL_CALL OComponent::out_methodHyper(sal_Int64& rOut) throw( RuntimeException )
1393 // {
1394
1395 // }
1396
1397 // void SAL_CALL OComponent::out_methodUHyper(sal_uInt64& rOut) throw( RuntimeException )
1398 // {
1399 // }
1400
1401 // void SAL_CALL OComponent::out_methodString(OUString& rOut) throw( RuntimeException )
1402 // {
1403 // rOut= L"I'm a string";
1404 // }
1405 // void SAL_CALL OComponent::out_methodChar(sal_Unicode& rOut) throw( RuntimeException )
1406 // {
1407 // rOut= 'A';
1408 // }
1409 // void SAL_CALL OComponent::out_methodAny(Any& rOut) throw( RuntimeException)
1410 // {
1411 // Any a;
1412 // a <<= OUString( L"Hi");
1413 // rOut= a;
1414 // }
1415 // void SAL_CALL OComponent::out_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException )
1416 // {
1417 // Sequence< sal_Int32 > aseq(10);
1418 // for( sal_Int16 i= 0; i < aseq.getLength(); i++) aseq.getArray()[i]= i;
1419 // rOut= aseq;
1420 // }
1421 // void SAL_CALL OComponent::out_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException )
1422 // {
1423 // rOut= Sequence< Sequence< sal_Int32 > >();
1424 // }
1425 // void SAL_CALL OComponent::out_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException )
1426 // {
1427 // rout1= 111;
1428 // rout2= 222;
1429 // }
1430 // void SAL_CALL OComponent::out_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException )
1431 // {
1432 // rout1= 111;
1433 // rout2= 222;
1434 // rout3= L"this is a neet little string";
1435 // }
1436 // void SAL_CALL OComponent::out_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException )
1437 // {
1438 // sout= L"this is a neet little string";
1439 // }
1440
1441 // XTestInterfaces -------------------------------------------------------------------------------------
testInterface(const Reference<XCallback> & xCallback,sal_Int32 mode)1442 void SAL_CALL OComponent::testInterface( const Reference< XCallback >& xCallback, sal_Int32 mode )
1443 {
1444 USES_CONVERSION;
1445 sal_Int32 i=0;
1446 OUString aString;
1447 char buff[1024];
1448
1449 Reference<XSimple> xSimple;
1450 SimpleStruct aSimpleStruct;
1451 SimpleEnum aSimpleEnum;
1452 Sequence<Any> seqAny;
1453 Sequence< sal_Int8 > seqByte;
1454 Any outAny;
1455 sal_Bool aBool;
1456 sal_Unicode aChar;
1457 float aFloat;
1458 double aDouble;
1459 sal_Int8 aByte;
1460 sal_Int16 aShort;
1461 sal_Int32 aLong;
1462 // sal_uInt16 aUShort;
1463 // sal_uInt32 aULong;
1464
1465 switch( mode)
1466 {
1467 case 1:
1468 xCallback->func1(); break;
1469 case 2:
1470 xSimple= xCallback->returnInterface();
1471 xSimple->func(L"XCallback::returnInterface");
1472 break;
1473
1474
1475 case 3:
1476 xCallback->outInterface( xSimple);
1477 sprintf( buff, "XCallback::outInterface, value: %x", xSimple.get());
1478 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1479 xSimple->func(L"XCallback::outInterface works");
1480 break;
1481 case 4:
1482 xCallback->outStruct( aSimpleStruct);
1483 sprintf( buff,"XCallback::outStruct, SimpleStruct::message: %s", OLE2A( aSimpleStruct.message));
1484 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1485 break;
1486 case 5:
1487 xCallback->outEnum( aSimpleEnum);
1488 sprintf( buff,"XCallback::outEnum, SimpleEnum: %d", aSimpleEnum);
1489 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1490 break;
1491 case 6:
1492 xCallback->outSeqAny( seqAny);
1493 sprintf( buff,"XCallback::outSeqAny, length: %d )", seqAny.getLength());
1494 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1495 for( i=0; i < seqAny.getLength(); i++)
1496 {
1497 Any any= seqAny[i];
1498 if( any.getValueTypeClass() == TypeClass_STRING)
1499 {
1500 any >>= aString;
1501 OutputDebugStringW( aString);
1502 }
1503
1504 }
1505 break;
1506 case 7:
1507 xCallback->outAny( outAny);
1508 if( outAny.getValueTypeClass() == TypeClass_STRING)
1509 outAny >>= aString;
1510 sprintf( buff,"XCallback::outAny, Any : %s", W2A( aString));
1511 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1512 break;
1513 case 8:
1514 xCallback->outBool( aBool);
1515 sprintf( buff,"XCallback::outBool, value: %d", aBool);
1516 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1517 break;
1518 case 9:
1519 xCallback->outChar( aChar);
1520 sprintf( buff,"XCallback::outChar, value: %C", aChar);
1521 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1522 break;
1523 case 10:
1524 xCallback->outString( aString);
1525 sprintf( buff,"XCallback::outString, value: %s", W2A( aString));
1526 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1527 break;
1528 case 11:
1529 xCallback->outFloat( aFloat);
1530 sprintf( buff,"XCallback::outFloat, value: %f", aFloat);
1531 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1532 break;
1533 case 12:
1534 xCallback->outDouble( aDouble);
1535 sprintf( buff,"XCallback::outDouble, value: %f", aDouble);
1536 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1537 break;
1538 case 13:
1539 xCallback->outByte( aByte);
1540 sprintf( buff,"XCallback::outByte, value: %d", aByte);
1541 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1542 break;
1543 case 14:
1544 xCallback->outShort( aShort);
1545 sprintf( buff,"XCallback::outShort, value: %d", aShort);
1546 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1547 break;
1548 case 15:
1549 xCallback->outLong( aLong);
1550 sprintf( buff,"XCallback::outLong, value: %d", aLong);
1551 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1552 break;
1553 case 18:
1554 case 19:
1555 case 30:
1556 {
1557
1558 long outLong= 0;
1559 xCallback->outValuesMixed( 1111, outLong, OUString( L"in string") );
1560
1561 sprintf( buff, "oletest.testInterface: outValue: %d", outLong);
1562 MessageBox( NULL, A2T(buff), _T("OleTest"), MB_OK);
1563 break;
1564 }
1565
1566 case 31:
1567 {
1568 Reference< XSimple > xSimple;
1569 SimpleStruct aSimpleStruct;
1570 SimpleEnum aSimpleEnum;
1571 Sequence<Any> seqAny;
1572 Any aAny;
1573 sal_Bool aBool;
1574 sal_Unicode aChar;
1575 OUString aString;
1576 float aFloat;
1577 double aDouble;
1578 sal_Int8 aByte;
1579 sal_Int16 aShort;
1580 sal_Int32 aLong;
1581 // sal_uInt16 aUShort;
1582 // sal_uInt32 aULong;
1583 xCallback->outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool,
1584 aChar, aString,
1585 aFloat, aDouble,
1586 aByte,
1587 aShort, aLong);
1588
1589 MessageBox( NULL, _T("XCallback::outValuesAll returned"), _T("OleTest::testInterface"), MB_OK);
1590 break;
1591 }
1592 case 32:
1593 {
1594
1595 xCallback->outSeqByte( seqByte);
1596 sprintf( buff,"XCallback::outSeqAny, length: %d )", seqAny.getLength());
1597 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1598 for( i=0; i < seqAny.getLength(); i++)
1599 {
1600 Any any= seqAny[i];
1601 if( any.getValueTypeClass() == TypeClass_STRING)
1602 {
1603 any >>= aString;
1604 OutputDebugStringW( aString);
1605 }
1606 }
1607 break;
1608 }
1609 // ############################################################################
1610 // IN OUT parameter
1611 // ############################################################################
1612 case 100:
1613 {
1614 Reference<XSimple> xSimple= static_cast<XSimple*>(this);
1615 xCallback->inoutInterface( xSimple);
1616 xSimple->func(L"XSimple called from OleTest");
1617 break;
1618 }
1619 case 101:
1620 {
1621 Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
1622 if( xRefl.is())
1623 {
1624 Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
1625 Any any;
1626 if( xClass.is())
1627 xClass->createObject( any);
1628
1629 if( any.getValueTypeClass() == TypeClass_STRUCT)
1630 {
1631 SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
1632 pStruct->message= OUString::createFromAscii("This struct was created in OleTest");
1633
1634 SimpleStruct aStruct;
1635 any >>= aStruct;
1636 xCallback->inoutStruct( aStruct);
1637 // a Struct should now contain a different message
1638 MessageBox( NULL, W2T(aStruct.message), _T("OleTest in out parameter"), MB_OK);
1639 }
1640
1641 }
1642 break;
1643 }
1644 case 102:
1645 {
1646 SimpleEnum aEnum= SimpleEnum_B;
1647 xCallback->inoutEnum( aEnum);
1648 char buff[1024];
1649 sprintf( buff, "Enum: %d", aEnum);
1650 MessageBox( NULL, A2T(buff), _T("OleTest in out parameter"), MB_OK);
1651 break;
1652 }
1653 case 103:
1654 {
1655 Any arAny[3];
1656 arAny[0] <<= OUString( L"string 0");
1657 arAny[1] <<= OUString( L"string 1");
1658 arAny[2] <<= OUString( L"string 2");
1659
1660 Sequence< Any >seqAny( arAny, 3);
1661 xCallback->inoutSeqAny( seqAny);
1662 char buff[1023];
1663 sprintf( buff, "Sequence length: %d", seqAny.getLength());
1664 MessageBox( NULL,A2T(buff) , _T("OleTest in out parameter"), MB_OK);
1665
1666 for( int i=0; i < seqAny.getLength(); i++)
1667 {
1668 Any any;
1669 any <<= seqAny[i];
1670 if(any.getValueTypeClass() == TypeClass_STRING)
1671 {
1672 OUString str;
1673 any >>= str;
1674
1675 }
1676 }
1677
1678 break;
1679 }
1680 case 104:
1681 {
1682 Any any;
1683 OUString s(L" OleTest");
1684 any <<= s;
1685 xCallback->inoutAny(any);
1686 if( any.getValueTypeClass() == TypeClass_STRING)
1687 {
1688 OUString s= *( rtl_uString**) any.getValue();
1689 MessageBox( NULL, W2T( s), _T("OleTest: inout value any"), MB_OK);
1690 }
1691 break;
1692 }
1693 case 105:
1694 {
1695 sal_Bool b= sal_True;
1696 xCallback->inoutBool( b);
1697 char buff[1024];
1698 sprintf( buff, "out value bool: %d", b);
1699 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1700 break;
1701 }
1702 case 106:
1703 {
1704 sal_Unicode uc= L'A';
1705 xCallback->inoutChar( uc);
1706 char buff[1024];
1707 sprintf( buff, "out value sal_Unicode: %C", uc);
1708 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1709 break;
1710 }
1711 case 107:
1712 {
1713 OUString s(L"OleTest");
1714 xCallback->inoutString( s);
1715 char buff[1024];
1716 sprintf( buff, "out value string: %S", s.getStr());
1717 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1718 break;
1719 }
1720 case 108:
1721 {
1722 float f= 3.14f;
1723 xCallback->inoutFloat(f);
1724 char buff[1024];
1725 sprintf( buff, "out value float: %f", f);
1726 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1727 break;
1728 }
1729 case 109:
1730 {
1731 double f= 3.145;
1732 xCallback->inoutDouble( f);
1733 char buff[1024];
1734 sprintf( buff, "out value double: %g", f);
1735 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1736 break;
1737 }
1738 case 110:
1739 {
1740 sal_Int8 aByte= 0xf;
1741 xCallback->inoutByte( aByte);
1742 char buff[1024];
1743 sprintf( buff, "out value sal_Int8: %d", aByte);
1744 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1745 break;
1746 }
1747 case 111:
1748 {
1749 sal_Int16 aShort= 0xff;
1750 xCallback->inoutShort( aShort);
1751 char buff[1024];
1752 sprintf( buff, "out value sal_Int16: %d", aShort);
1753 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1754 break;
1755 }
1756 case 112:
1757 {
1758 sal_Int32 aLong= 0xfffe;
1759 xCallback->inoutLong( aLong);
1760 char buff[1024];
1761 sprintf( buff, "out value sal_Int32: %d", aLong);
1762 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1763 break;
1764 }
1765 case 120:
1766 {
1767 Reference<XSimple> aXSimple= static_cast<XSimple*>(this);
1768
1769 SimpleStruct aStruct;
1770 Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
1771 if( xRefl.is())
1772 {
1773 Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
1774 Any any;
1775 if( xClass.is())
1776 xClass->createObject( any);
1777
1778 if( any.getValueTypeClass() == TypeClass_STRUCT)
1779 {
1780 SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
1781 pStruct->message= OUString::createFromAscii("This struct was created in OleTest");
1782 any >>= aStruct;
1783 }
1784 }
1785
1786 SimpleEnum aEnum= SimpleEnum_B;
1787
1788 Sequence< Any > aSeq;
1789 Any arAny[3];
1790 arAny[0] <<= OUString( L"string 0");
1791 arAny[1] <<= OUString( L"string 1");
1792 arAny[2] <<= OUString( L"string 2");
1793 aSeq = Sequence< Any >( arAny, 3);
1794
1795 Any aAny;
1796 OUString s(L" OleTest");
1797 aAny <<= s;
1798
1799 sal_Bool aBool= sal_True;
1800 sal_Unicode aChar= L'A';
1801 OUString aString( L"OleTest");
1802 float aFloat=3.14f;
1803 double aDouble= 3.145;
1804 sal_Int8 aByte= 0xf;
1805 sal_Int16 aShort= 0xff;
1806 sal_Int32 aLong= 0xffe;
1807
1808 xCallback->inoutValuesAll( aXSimple, aStruct, aEnum, aSeq,
1809 aAny, aBool, aChar, aString, aFloat, aDouble,
1810 aByte, aShort, aLong );
1811
1812 aXSimple->func(L"XSimple called from OleTest");
1813 MessageBox( NULL, W2T(aStruct.message), _T("OleTest"), MB_OK);
1814
1815 for( int i=0; i < aSeq.getLength(); i++)
1816 {
1817 Any any;
1818 any <<= aSeq[i];
1819 if(any.getValueTypeClass() == TypeClass_STRING)
1820 {
1821 OUString str;
1822 any >>= str;
1823
1824 }
1825 }
1826 break;
1827 }
1828
1829 // ############################################################################
1830 // IN parameter
1831 // ############################################################################
1832
1833 case 200:
1834
1835 xCallback->inValues( L'a', 0xffffL, OUString(L" a string from OleTest"));
1836 break;
1837 case 201:
1838 {
1839 sal_Int8 arbyte[3]= { 1,2,3};
1840 Sequence< sal_Int8 > seq( arbyte, 3);
1841 xCallback->inSeqByte( seq);
1842 break;
1843 }
1844 case 202:
1845 {
1846 const int LISTENERS= 3;
1847 Reference<XEventListener> arListeners[LISTENERS];
1848 EventObject arEvents[LISTENERS];
1849
1850 for( int i= 0; i < LISTENERS; i++)
1851 {
1852 Reference<XInterface> aList= static_cast<XWeak*>( new EventListener());
1853 arListeners[i]= Reference<XEventListener>( aList, UNO_QUERY);
1854 }
1855
1856 xCallback->inSeqXEventListener(Sequence<Reference<XEventListener> > (arListeners, LISTENERS),
1857 Sequence<EventObject>(arEvents, LISTENERS));
1858 break;
1859 }
1860
1861 // ############################################################################
1862 // Call a COM object that has not been passed as parameter to a UNO component and
1863 // hence no type information are available in the COM wrapper
1864 // ############################################################################
1865 case 300:
1866 {
1867 Reference<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.oleautomation.Factory");
1868
1869 Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
1870
1871 Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
1872 Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
1873 //Any SAL_CALL invoke( const OUString& aFunctionName, const Sequence<Any >& aParams,Sequence< sal_Int16 >& aOutParamIndex,
1874 // Sequence<Any >& aOutParam );
1875 Sequence<sal_Int16> seqIndizes;
1876 Sequence<Any> seqOutParams;
1877 xInv->invoke( OUString( L"outValuesAll"), Sequence<Any>(), seqIndizes, seqOutParams);
1878
1879 // void outValuesAll( [out] oletest::XSimple outInterface,
1880 // [out] SimpleStruct outStruct ,
1881 // [out] SimpleEnum outEnum,
1882 // [out] sequence<any> outSeqAny,
1883 // [out] any outAny,
1884 // [out] boolean outBool,
1885 // [out] char outChar,
1886 // [out] string outString,
1887 // [out] float outFloat,
1888 // [out] double outDouble,
1889 // [out] byte outByte,
1890 // [out] short outShort,
1891 // [out] long outLong);
1892 if( seqOutParams.getLength() == 12)
1893 {
1894 Reference<XSimple> xSimple= *(XSimple**)seqOutParams[0].getValue();
1895 xSimple->func( L"Call from OleTest on XSimple");
1896 SimpleStruct aStruct;
1897 seqOutParams[1] >>= aStruct;
1898 SimpleEnum aEnum= *(SimpleEnum*)seqOutParams[2].getValue();
1899
1900 Sequence<Any> seqAny;
1901 seqOutParams[3] >>= seqAny;
1902 for( int i=0; i<seqAny.getLength(); i++)
1903 {
1904 OUString _s;
1905 seqAny[i] >>= _s;
1906 }
1907
1908 Any _any= *(Any*)seqOutParams[4].getValue();
1909 sal_Bool _bool= *(sal_Bool*)seqOutParams[5].getValue();
1910 sal_Unicode _char= *( sal_Unicode*) seqOutParams[6].getValue();
1911 OUString _str= *( rtl_uString**)seqOutParams[7].getValue();
1912
1913 float _f= *( float*)seqOutParams[8].getValue();
1914 double _d= *( double*) seqOutParams[9].getValue();
1915 sal_Int8 _byte= *( sal_Int8*) seqOutParams[10].getValue();
1916 sal_Int16 _short= *( sal_Int16*) seqOutParams[11].getValue();
1917
1918 sal_Int32 _long= *( sal_Int32*) seqOutParams[12].getValue();
1919
1920 }
1921 break;
1922 }
1923 case 301:
1924 // in / out parameter
1925 {
1926 Reference<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.oleautomation.Factory");
1927
1928 Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
1929
1930 Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
1931 Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
1932 Sequence<sal_Int16> seqIndizes;
1933 Sequence<Any> seqOutParams;
1934
1935
1936 Any arAny[13];
1937 Reference<XSimple> xSimple= static_cast<XSimple*>( this);
1938
1939 arAny[0] <<= xSimple;
1940 SimpleStruct aStruct;
1941 Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
1942 if( xRefl.is())
1943 {
1944 Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
1945 Any any;
1946 if( xClass.is())
1947 xClass->createObject( any);
1948
1949 if( any.getValueTypeClass() == TypeClass_STRUCT)
1950 {
1951 SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
1952 pStruct->message= OUString::createFromAscii("This struct was created in OleTest");
1953 any >>= aStruct;
1954 }
1955 }
1956 arAny[1] <<= aStruct;
1957 arAny[2] <<= SimpleEnum_C;
1958
1959 Any arSeqAny[3];
1960 arSeqAny[0] <<= OUString( L"string 0");
1961 arSeqAny[1] <<= OUString( L"string 1");
1962 arSeqAny[2] <<= OUString( L"string 2");
1963
1964 arAny[3] <<= Sequence< Any >( arAny, 3);
1965
1966 OUString str(L" Ein Any param");
1967 arAny[4] <<= str;
1968 arAny[5] <<= sal_False;
1969 arAny[6] <<= L'B';
1970 OUString stringParam(L" a string parameter");
1971 arAny[7] <<= stringParam;
1972 float _float= 3.14f;
1973 arAny[8] <<= _float;
1974 double _double= 3.145;
1975 arAny[9] <<= _double;
1976 sal_Int8 _byte= -1;
1977 arAny[10] <<= _byte;
1978 sal_Int16 _short= -1;
1979 arAny[11] <<= _short;
1980 sal_Int32 _long= -1;
1981 arAny[12] <<= _long;
1982 //
1983 Sequence<Any> params( arAny, 13);
1984
1985 xInv->invoke( OUString( L"inoutValuesAll"), params, seqIndizes, seqOutParams);
1986
1987 if( seqOutParams.getLength() == 12)
1988 {
1989 Reference<XSimple> xSimple= *(XSimple**)seqOutParams[0].getValue();
1990 xSimple->func( L"Call from OleTest on XSimple");
1991 SimpleStruct aStruct;
1992 seqOutParams[1] >>= aStruct;
1993 SimpleEnum aEnum= *(SimpleEnum*)seqOutParams[2].getValue();
1994
1995 Sequence<Any> seqAny;
1996 seqOutParams[3] >>= seqAny;
1997 for( int i=0; i<seqAny.getLength(); i++)
1998 {
1999 OUString _s;
2000 seqAny[i] >>= _s;
2001 }
2002
2003 Any _any= *(Any*)seqOutParams[4].getValue();
2004 sal_Bool _bool= *(sal_Bool*)seqOutParams[5].getValue();
2005 sal_Unicode _char= *( sal_Unicode*) seqOutParams[6].getValue();
2006 OUString _str= *( rtl_uString**)seqOutParams[7].getValue();
2007
2008 float _f= *( float*)seqOutParams[8].getValue();
2009 double _d= *( double*) seqOutParams[9].getValue();
2010 sal_Int8 _byte= *( sal_Int8*) seqOutParams[10].getValue();
2011 sal_Int16 _short= *( sal_Int16*) seqOutParams[11].getValue();
2012
2013 sal_Int32 _long= *( sal_Int32*) seqOutParams[12].getValue();
2014
2015 }
2016 break;
2017 }
2018 case 303:
2019 // in parameter
2020 // void inValues( [in] char aChar, [in] long aLong, [in] string aString);
2021 {
2022 Reference<XInterface> xIntFact = m_rFactory->createInstance(
2023 L"com.sun.star.bridge.oleautomation.Factory");
2024
2025 Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
2026
2027 Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
2028 Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
2029 Sequence<sal_Int16> seqIndizes;
2030 Sequence<Any> seqOutParams;
2031
2032 Any arAny[3];
2033 sal_Unicode aChar=L'a';
2034 arAny[0] <<= aChar;
2035 sal_Int32 aLong= 0xffffffff;
2036 arAny[1] <<= aLong;
2037 OUString aString(L" a string parameter");
2038 arAny[2] <<= aString;
2039
2040 xInv->invoke( OUString( L"inValues"), Sequence<Any>(arAny,3), seqIndizes, seqOutParams);
2041
2042 break;
2043 }
2044 // ############################################################################
2045 // Attributes
2046 // ############################################################################
2047
2048 case 400:
2049 Reference<XSimple> simple= xCallback->getsimple();
2050 simple->func(L"OleTest calls on XSimple");
2051 break;
2052
2053
2054
2055
2056 }
2057
2058 }
2059
setObject(const Reference<XInterface> & val)2060 void SAL_CALL OComponent::setObject( const Reference< XInterface >& val )
2061 {
2062 m_xIntIdentity= val;
2063 }
2064
isSame(const Reference<XInterface> & val)2065 sal_Bool SAL_CALL OComponent::isSame( const Reference< XInterface >& val )
2066 {
2067 if( m_xIntIdentity == val)
2068 return sal_True;
2069 else
2070 return sal_False;
2071 }
2072
getThis()2073 Reference< XInterface > SAL_CALL OComponent::getThis( )
2074 {
2075 // return Reference<XInterface>(static_cast<XIdentity*>(this), UNO_QUERY);
2076 Reference<XInterface> ret(static_cast<XIdentity*>(this), UNO_QUERY);
2077 return ret;
2078 }
2079
disposing(const::com::sun::star::lang::EventObject &)2080 void SAL_CALL EventListener::disposing( const ::com::sun::star::lang::EventObject& )
2081 {
2082 bCalled= sal_True;
2083 }
2084
2085 // XSimple --------------------------------------------------------------------------
func(const OUString & message)2086 void SAL_CALL OComponent::func( const OUString &message)
2087 {
2088 USES_CONVERSION;
2089
2090 MessageBox( NULL, W2T( message.getStr()), _T("OleTest: XSimple::func"), MB_OK);
2091 }
2092 // XSimple --------------------------------------------------------------------------
getName()2093 OUString SAL_CALL OComponent::getName()
2094 {
2095 return L"XSimple";
2096 }
testInterface2(const Reference<XSimple> & xSimple,sal_Int32 mode)2097 void SAL_CALL OComponent::testInterface2( const Reference< XSimple >& xSimple, sal_Int32 mode )
2098 {
2099 switch( mode)
2100 {
2101 case 0:
2102 {
2103 xSimple->func( L"OleTest is calling XSimple");
2104 Reference<XSimple2> xSimple2( xSimple, UNO_QUERY);
2105 if( xSimple2.is())
2106 xSimple2->func2( L"OleTest is calling XSimple2");
2107 Reference<XSimple3> xSimple3( xSimple, UNO_QUERY);
2108 if( xSimple3.is())
2109 xSimple3->func3( L"OleTest is calling XSimple3");
2110
2111 break;
2112 }
2113 }
2114 }
2115