merged tag ooo/OOO330_m14
[LibreOffice.git] / extensions / test / ole / cpnt / cpnt.cxx
blob2a72552d2024bb6291d48e8d5bb990e686299a7d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include <windows.h>
31 #include <atlbase.h>
32 #include <stdio.h>
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/registry/XRegistryKey.hpp>
35 #include <osl/diagnose.h>
36 #include <uno/environment.h>
37 #include <cppuhelper/factory.hxx>
38 // OPTIONAL is a constant in com.sun.star.beans.PropertyAttributes but it must be
39 // undef'd in some header files
40 #define OPTIONAL OPTIONAL
41 #include <com/sun/star/beans/PropertyAttribute.hpp>
42 #include <com/sun/star/script/XInvocation.hpp>
43 #include <com/sun/star/reflection/XIdlReflection.hpp>
44 #include <com/sun/star/lang/XEventListener.hpp>
46 #include <cppuhelper/implbase7.hxx>
47 #include <cppuhelper/implbase1.hxx>
48 #include <com/sun/star/uno/Reference.h>
49 #include <rtl/ustring.h>
50 #include <com/sun/star/uno/Reference.hxx>
51 #include <oletest/XTestSequence.hpp>
52 #include <oletest/XTestStruct.hpp>
53 #include <oletest/XTestOther.hpp>
54 #include <oletest/XTestInterfaces.hpp>
55 #include <oletest/XSimple.hpp>
56 #include <oletest/XSimple2.hpp>
57 #include <oletest/XSimple3.hpp>
58 #include <oletest/XTestInParameters.hpp>
59 //#include <oletest/XTestOutParameters.hpp>
60 #include <oletest/XIdentity.hpp>
61 #include <com/sun/star/beans/Property.hpp>
62 using namespace cppu;
63 using namespace osl;
64 using namespace oletest;
65 using namespace rtl;
66 using namespace com::sun::star::uno;
67 using namespace com::sun::star::lang;
68 using namespace com::sun::star::beans;
69 using namespace com::sun::star::registry;
70 using namespace com::sun::star::script;
71 using namespace com::sun::star::reflection;
74 #define IMPL_NAME L"oletest.OleTestImpl" // oletest.OleTestImpl in applicat.rdb
75 #define SERVICE_NAME L"oletest.OleTest"
76 #define KEY1 L"/oletest.OleTestImpl/UNO/SERVICES"
77 #define KEY2 L"oletest.OleTest"
79 class OComponent : public WeakImplHelper7<
80 XTestSequence, XTestStruct, XTestOther, XTestInterfaces,
81 XSimple, XTestInParameters, XIdentity >
83 Reference<XInterface> m_xIntIdentity;
84 sal_Int32 m_arrayConstructor;
85 Reference<XMultiServiceFactory> m_rFactory;
87 Sequence<sal_Int8> m_seqByte;
88 Sequence<float> m_seqFloat;
89 Sequence<double> m_seqDouble;
90 Sequence<sal_Bool> m_seqBool;
91 Sequence<sal_Int16> m_seqShort;
92 Sequence<sal_uInt16> m_seqUShort;
93 Sequence<sal_Int32> m_seqLong;
94 Sequence<sal_uInt32> m_seqULong;
95 Sequence<sal_Unicode> m_seqChar;
96 Sequence<OUString> m_seqString;
97 Sequence<Any> m_seqAny;
98 Sequence<Type> m_seqType;
99 Sequence<Sequence< sal_Int32> > m_seq1;
100 Sequence<Sequence< Sequence< sal_Int32> > > m_seq2;
101 Any m_any;
102 Type m_type;
103 Sequence<Reference< XInterface > > m_seqxInterface;
105 sal_Int8 m_int8;
106 sal_uInt8 m_uint8;
107 sal_Int16 m_int16;
108 sal_uInt16 m_uint16;
109 sal_Int32 m_int32;
110 sal_uInt32 m_uint32;
111 sal_Int64 m_int64;
112 sal_uInt64 m_uint64;
113 float m_float;
114 double m_double;
115 OUString m_string;
116 sal_Unicode m_char;
117 sal_Bool m_bool;
118 Reference<XInterface> m_xinterface;
120 sal_Int8 m_attr_int8;
121 sal_uInt8 m_attr_uint8;
122 sal_Int16 m_attr_int16;
123 sal_uInt16 m_attr_uint16;
124 sal_Int32 m_attr_int32;
125 sal_uInt32 m_attr_uint32;
126 sal_Int64 m_attr_int64;
127 sal_uInt64 m_attr_uint64;
128 float m_attr_float;
129 double m_attr_double;
130 OUString m_attr_string;
131 sal_Unicode m_attr_char;
132 sal_Bool m_attr_bool;
133 Any m_attr_any;
134 Type m_attr_type;
135 Reference<XInterface> m_attr_xinterface;
136 Reference<XInvocation> m_attr_xinvocation;
138 public:
139 OComponent( const Reference<XMultiServiceFactory> & rFactory ) :
140 m_rFactory( rFactory ), m_arrayConstructor(0) {}
141 ~OComponent();
142 public: // XTestSequence
143 virtual Sequence<sal_Int8> SAL_CALL methodByte(const Sequence< sal_Int8 >& aSeq) throw( RuntimeException );
144 virtual Sequence<float> SAL_CALL methodFloat(const Sequence< float >& aSeq) throw( RuntimeException );
145 virtual Sequence< double > SAL_CALL methodDouble(const Sequence< double >& aSeq) throw( RuntimeException);
146 virtual Sequence< sal_Bool > SAL_CALL methodBool(const Sequence< sal_Bool >& aSeq) throw( RuntimeException );
147 virtual Sequence< sal_Int16 > SAL_CALL methodShort(const Sequence< sal_Int16 >& aSeq) throw( RuntimeException );
148 virtual Sequence< sal_uInt16 > SAL_CALL methodUShort(const Sequence< sal_uInt16 >& aSeq) throw( RuntimeException );
149 virtual Sequence< sal_Int32 > SAL_CALL methodLong(const Sequence< sal_Int32 >& aSeq) throw( RuntimeException) ;
150 virtual Sequence< sal_uInt32 > SAL_CALL methodULong(const Sequence< sal_uInt32 >& aSeq) throw( RuntimeException );
151 virtual Sequence< OUString > SAL_CALL methodString(const Sequence< OUString >& aSeq) throw( RuntimeException );
152 virtual Sequence< sal_Unicode > SAL_CALL methodChar(const Sequence< sal_Unicode >& aSeq) throw( RuntimeException );
153 virtual Sequence< Any > SAL_CALL methodAny(const Sequence< Any >& aSeq) throw( RuntimeException );
154 virtual Sequence< Type > SAL_CALL methodType(const Sequence< Type >& aSeq) throw( RuntimeException );
155 virtual Sequence< Reference< XInterface > > SAL_CALL methodXInterface( const Sequence< Reference< XInterface > >& aSeq ) throw(RuntimeException) ;
156 virtual Sequence< Sequence< sal_Int32 > > SAL_CALL methodSequence(const Sequence< Sequence< sal_Int32 > >& aSeq) throw( RuntimeException );
157 virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL methodSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq) throw( RuntimeException );
158 virtual Sequence< Reference<XEventListener> > SAL_CALL methodXEventListeners( const Sequence<Reference<XEventListener> >& aSeq) throw( RuntimeException);
159 virtual Sequence< Sequence<Reference<XEventListener > > > SAL_CALL methodXEventListenersMul( const Sequence<Sequence<Reference<XEventListener > > >& aSeq ) throw (RuntimeException);
161 virtual Sequence< sal_Int8 > SAL_CALL getAttrByte(void) throw( RuntimeException );
162 virtual void SAL_CALL setAttrByte(const Sequence< sal_Int8 >& AttrByte_) throw( RuntimeException );
163 virtual Sequence< float > SAL_CALL getAttrFloat(void) throw( RuntimeException) ;
164 virtual void SAL_CALL setAttrFloat(const Sequence< float >& AttrFloat_) throw( RuntimeException );
165 virtual Sequence< double > SAL_CALL getAttrDouble(void) throw( RuntimeException) ;
166 virtual void SAL_CALL setAttrDouble(const Sequence< double >& AttrDouble_) throw( RuntimeException );
167 virtual Sequence< sal_Bool > SAL_CALL getAttrBool(void) throw( RuntimeException );
168 virtual void SAL_CALL setAttrBool(const Sequence< sal_Bool >& AttrBool_) throw( RuntimeException );
169 virtual Sequence< sal_Int16 > SAL_CALL getAttrShort(void) throw( RuntimeException );
170 virtual void SAL_CALL setAttrShort(const Sequence< sal_Int16 >& AttrShort_) throw( RuntimeException );
171 virtual Sequence< sal_uInt16 > SAL_CALL getAttrUShort(void) throw( RuntimeException );
172 virtual void SAL_CALL setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_) throw( RuntimeException );
173 virtual Sequence< sal_Int32 > SAL_CALL getAttrLong(void) throw( RuntimeException );
174 virtual void SAL_CALL setAttrLong(const Sequence< sal_Int32 >& AttrLong_) throw( RuntimeException );
175 virtual Sequence< sal_uInt32 > SAL_CALL getAttrULong(void) throw( RuntimeException );
176 virtual void SAL_CALL setAttrULong(const Sequence< sal_uInt32 >& AttrULong_) throw( RuntimeException );
177 virtual Sequence< OUString > SAL_CALL getAttrString(void) throw(RuntimeException );
178 virtual void SAL_CALL setAttrString(const Sequence< OUString >& AttrString_) throw( RuntimeException );
179 virtual Sequence< sal_Unicode > SAL_CALL getAttrChar(void) throw( RuntimeException );
180 virtual void SAL_CALL setAttrChar(const Sequence< sal_Unicode >& AttrChar_) throw( RuntimeException );
181 virtual Sequence< Any > SAL_CALL getAttrAny(void) throw( RuntimeException );
182 virtual void SAL_CALL setAttrAny(const Sequence< Any >& AttrAny_) throw( RuntimeException );
183 virtual Sequence< Type > SAL_CALL getAttrType(void) throw( RuntimeException );
184 virtual void SAL_CALL setAttrType( const Sequence< Type >& _attrtype ) throw (RuntimeException);
185 virtual Sequence< Sequence< sal_Int32 > > SAL_CALL getAttrSequence(void) throw( RuntimeException );
186 virtual void SAL_CALL setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence_) throw( RuntimeException );
187 virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL getAttrSequence2(void) throw( RuntimeException );
188 virtual void SAL_CALL setAttrSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& AttrSequence2_) throw ( RuntimeException );
189 virtual Sequence< Reference< XInterface > > SAL_CALL getAttrXInterface() throw(RuntimeException);
190 virtual void SAL_CALL setAttrXInterface( const Sequence< Reference< XInterface > >& _attrxinterface ) throw(RuntimeException);
192 virtual ::sal_Int8 SAL_CALL getAByte() throw (RuntimeException);
193 virtual void SAL_CALL setAByte( ::sal_Int8 _abyte ) throw (RuntimeException);
194 virtual float SAL_CALL getAFloat() throw (RuntimeException);
195 virtual void SAL_CALL setAFloat( float _afloat ) throw (RuntimeException);
196 virtual double SAL_CALL getADouble() throw (RuntimeException);
197 virtual void SAL_CALL setADouble( double _adouble ) throw (RuntimeException);
198 virtual ::sal_Bool SAL_CALL getABool() throw (RuntimeException);
199 virtual void SAL_CALL setABool( ::sal_Bool _abool ) throw (RuntimeException);
200 virtual ::sal_Int16 SAL_CALL getAShort() throw (RuntimeException);
201 virtual void SAL_CALL setAShort( ::sal_Int16 _ashort ) throw (RuntimeException);
202 virtual ::sal_uInt16 SAL_CALL getAUShort() throw (RuntimeException);
203 virtual void SAL_CALL setAUShort( ::sal_uInt16 _aushort ) throw (RuntimeException);
204 virtual ::sal_Int32 SAL_CALL getALong() throw (RuntimeException);
205 virtual void SAL_CALL setALong( ::sal_Int32 _along ) throw (RuntimeException);
206 virtual ::sal_uInt32 SAL_CALL getAULong() throw (RuntimeException);
207 virtual void SAL_CALL setAULong( ::sal_uInt32 _aulong ) throw (RuntimeException);
208 virtual ::rtl::OUString SAL_CALL getAString() throw (RuntimeException);
209 virtual void SAL_CALL setAString( const ::rtl::OUString& _astring ) throw (RuntimeException);
210 virtual ::sal_Unicode SAL_CALL getAChar() throw (RuntimeException);
211 virtual void SAL_CALL setAChar( ::sal_Unicode _achar ) throw (RuntimeException);
212 virtual Any SAL_CALL getAAny() throw (RuntimeException);
213 virtual void SAL_CALL setAAny( const Any& _aany ) throw (RuntimeException);
214 virtual Type SAL_CALL getAType() throw (RuntimeException);
215 virtual void SAL_CALL setAType( const Type& _atype ) throw (RuntimeException);
216 virtual Reference< XInterface > SAL_CALL getAXInterface() throw (RuntimeException);
217 virtual void SAL_CALL setAXInterface( const Reference<XInterface >& _axinterface ) throw (RuntimeException);
218 virtual Reference<XInvocation > SAL_CALL getAXInvocation() throw (RuntimeException);
219 virtual void SAL_CALL setAXInvocation( const Reference< XInvocation >& _axinvocation ) throw (RuntimeException);
221 virtual void SAL_CALL testout_methodByte(sal_Int8& rOut) throw( RuntimeException );
222 virtual void SAL_CALL testout_methodFloat(float& rOut) throw( RuntimeException );
223 virtual void SAL_CALL testout_methodDouble(double& rOut) throw( RuntimeException );
224 virtual void SAL_CALL testout_methodBool(sal_Bool& rOut) throw( RuntimeException );
225 virtual void SAL_CALL testout_methodShort(sal_Int16& rOut) throw( RuntimeException );
226 virtual void SAL_CALL testout_methodUShort(sal_uInt16& rOut) throw( RuntimeException );
227 virtual void SAL_CALL testout_methodLong(sal_Int32& rOut) throw( RuntimeException );
228 virtual void SAL_CALL testout_methodULong(sal_uInt32& rOut) throw( RuntimeException );
229 virtual void SAL_CALL testout_methodHyper(sal_Int64& rOut) throw( RuntimeException );
230 virtual void SAL_CALL testout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException );
231 virtual void SAL_CALL testout_methodString(OUString& rOut) throw( RuntimeException );
232 virtual void SAL_CALL testout_methodChar(sal_Unicode& rOut) throw( RuntimeException );
233 virtual void SAL_CALL testout_methodAny(Any& rOut) throw( RuntimeException );
234 virtual void SAL_CALL testout_methodType(Type& rOut) throw( RuntimeException );
235 virtual void SAL_CALL testout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException );
236 virtual void SAL_CALL testout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException );
237 virtual void SAL_CALL testout_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException );
238 virtual void SAL_CALL testout_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException );
239 virtual void SAL_CALL testout_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException );
240 virtual void SAL_CALL testout_methodMulParams4( float in1, float& out1, sal_Int32 in2, sal_Int32& out2, sal_Int32 in3 ) throw(RuntimeException);
241 virtual void SAL_CALL testout_methodXInterface( Reference< XInterface >& rOut ) throw(RuntimeException);
243 virtual void SAL_CALL testinout_methodByte(sal_Int8& rOut) throw( RuntimeException );
244 virtual void SAL_CALL testinout_methodFloat(float& rOut) throw( RuntimeException );
245 virtual void SAL_CALL testinout_methodDouble(double& rOut) throw( RuntimeException );
246 virtual void SAL_CALL testinout_methodBool(sal_Bool& rOut) throw( RuntimeException );
247 virtual void SAL_CALL testinout_methodShort(sal_Int16& rOut) throw( RuntimeException );
248 virtual void SAL_CALL testinout_methodUShort(sal_uInt16& rOut) throw( RuntimeException );
249 virtual void SAL_CALL testinout_methodLong(sal_Int32& rOut) throw( RuntimeException );
250 virtual void SAL_CALL testinout_methodULong(sal_uInt32& rOut) throw( RuntimeException );
251 virtual void SAL_CALL testinout_methodHyper(sal_Int64& rOut) throw( RuntimeException );
252 virtual void SAL_CALL testinout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException );
253 virtual void SAL_CALL testinout_methodString(OUString& rOut) throw( RuntimeException );
254 virtual void SAL_CALL testinout_methodChar(sal_Unicode& rOut) throw( RuntimeException );
255 virtual void SAL_CALL testinout_methodAny(Any& rOut) throw( RuntimeException );
256 virtual void SAL_CALL testinout_methodType(Type& rOut) throw( RuntimeException );
257 virtual void SAL_CALL testinout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException );
258 virtual void SAL_CALL testinout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException );
259 virtual void SAL_CALL testinout_methodXInterface( Reference< XInvocation >& rOut ) throw(RuntimeException);
260 virtual void SAL_CALL testinout_methodXInterface2( Reference< XInterface > & rOut) throw( RuntimeException);
261 virtual Any SAL_CALL methodAnyTest1(const Any& rIn) throw( RuntimeException ) ;
262 virtual Any SAL_CALL getAttrAny2(void) throw( RuntimeException ) ;
263 virtual void SAL_CALL setAttrAny2(const Any& AttrAny2_) throw( RuntimeException ) ;
266 // XTestStruct
267 virtual void SAL_CALL methodStruct(const Property& aProp) throw( RuntimeException );
269 virtual Property SAL_CALL retMethodStruct(void) throw( RuntimeException );
271 virtual Property SAL_CALL getAttrStruct(void) throw( RuntimeException );
272 virtual void SAL_CALL setAttrStruct(const Property& AttrStruct_) throw( RuntimeException );
273 virtual Property SAL_CALL methodStruct2( const Property& aProp ) throw (RuntimeException);
275 // XTestOther
276 virtual void SAL_CALL other_methodAnyIn(const Any& rAny) throw( RuntimeException );
277 virtual void SAL_CALL other_methodAnyOut(Any& rAny) throw( RuntimeException );
278 virtual Any SAL_CALL other_methodAnyRet(void) throw( RuntimeException );
279 virtual void SAL_CALL in_float( float val) throw ( RuntimeException);
280 virtual Any SAL_CALL other_methodAny( const Any& rAny, const OUString& typeInAny )
281 throw (RuntimeException);
284 // XTestOutParameters ------------------------------------------------------------------------
285 // virtual void SAL_CALL out_test(sal_Int8 rIn) throw( RuntimeException );
287 // virtual void SAL_CALL out_methodByte(sal_Int8& rOut) throw( RuntimeException );
288 // virtual void SAL_CALL out_methodFloat(float& rOut) throw( RuntimeException );
289 // virtual void SAL_CALL out_methodDouble(double& rOut) throw( RuntimeException );
290 // virtual void SAL_CALL out_methodBool(sal_Bool& rOut) throw( RuntimeException );
291 // virtual void SAL_CALL out_methodShort(sal_Int16& rOut) throw( RuntimeException );
292 // virtual void SAL_CALL out_methodUShort(sal_uInt16& rOut) throw( RuntimeException );
293 // virtual void SAL_CALL out_methodLong(sal_Int32& rOut) throw( RuntimeException );
294 // virtual void SAL_CALL out_methodULong(sal_uInt32& rOut) throw( RuntimeException );
295 // virtual void SAL_CALL out_methodHyper(sal_Int64& rOut) throw( RuntimeException );
296 // virtual void SAL_CALL out_methodUHyper(sal_uInt64& rOut) throw( RuntimeException );
297 // virtual void SAL_CALL out_methodString(OUString& rOut) throw( RuntimeException );
298 // virtual void SAL_CALL out_methodChar(sal_Unicode& rOut) throw( RuntimeException );
299 // virtual void SAL_CALL out_methodAny(Any& rOut) throw( RuntimeException );
300 // virtual void SAL_CALL out_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException );
301 // virtual void SAL_CALL out_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException );
302 // virtual void SAL_CALL out_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException );
303 // virtual void SAL_CALL out_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException );
304 // virtual void SAL_CALL out_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException );
306 // XTestInParameters
307 virtual sal_Int8 SAL_CALL in_methodByte( sal_Int8 rIn ) throw (RuntimeException);
308 virtual float SAL_CALL in_methodFloat( float rIn ) throw (RuntimeException);
309 virtual double SAL_CALL in_methodDouble( double rIn ) throw (RuntimeException);
310 virtual sal_Bool SAL_CALL in_methodBool( sal_Bool rIn ) throw (RuntimeException);
311 virtual sal_Int16 SAL_CALL in_methodShort( sal_Int16 rIn ) throw (RuntimeException);
312 virtual sal_uInt16 SAL_CALL in_methodUShort( sal_uInt16 rIn ) throw (RuntimeException);
313 virtual sal_Int32 SAL_CALL in_methodLong( sal_Int32 rIn ) throw (RuntimeException);
314 virtual sal_uInt32 SAL_CALL in_methodULong( sal_uInt32 rIn ) throw (RuntimeException);
315 virtual sal_Int64 SAL_CALL in_methodHyper( sal_Int64 rIn ) throw (RuntimeException);
316 virtual sal_uInt64 SAL_CALL in_methodUHyper( sal_uInt64 rIn ) throw (RuntimeException);
317 virtual OUString SAL_CALL in_methodString( const OUString& rIn ) throw (RuntimeException);
318 virtual sal_Unicode SAL_CALL in_methodChar( sal_Unicode rIn ) throw (RuntimeException);
319 virtual Any SAL_CALL in_methodAny( const Any& rIn ) throw (RuntimeException);
320 virtual Type SAL_CALL in_methodType( const Type& rIn ) throw (RuntimeException);
321 virtual Reference<XInterface> SAL_CALL in_methodXInterface( const Reference< XInterface >& rIn ) throw (RuntimeException);
322 virtual Reference<XInvocation > SAL_CALL in_methodInvocation( const Reference< XInvocation >& inv ) throw (RuntimeException);
323 virtual SimpleStruct SAL_CALL in_methodStruct( const SimpleStruct& aStruct ) throw (RuntimeException);
324 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);
326 // XTestInterfaces --------------------------------------------------------------------------
327 virtual void SAL_CALL testInterface( const Reference< XCallback >& xCallback, sal_Int32 mode ) throw(RuntimeException);
328 virtual void SAL_CALL testInterface2( const Reference< XSimple >& xSimple, sal_Int32 mode ) throw(RuntimeException);
329 // XSimple --------------------------------------------------------------------------
330 void SAL_CALL func( const OUString &message) throw(::com::sun::star::uno::RuntimeException);
331 OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
333 // XIdentity
334 virtual void SAL_CALL setObject( const Reference< XInterface >& val ) throw (RuntimeException);
335 virtual sal_Bool SAL_CALL isSame( const Reference< XInterface >& val ) throw (RuntimeException);
336 virtual Reference< XInterface > SAL_CALL getThis( ) throw (RuntimeException);
339 class EventListener: public WeakImplHelper1<XEventListener>
341 public:
342 EventListener::EventListener(): bCalled( sal_False)
344 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (RuntimeException);
346 sal_Bool bCalled;
350 OComponent::~OComponent()
355 // Funktions ==============================================================================
357 Reference<XInterface> SAL_CALL OComponent_CreateInstance( const Reference<XMultiServiceFactory> & rSMgr ) throw(RuntimeException)
359 // Reference<XInterface> xService(static_cast<XWeak*>(new OComponent( rSMgr )), UNO_QUERY);
360 OComponent* o= new OComponent( rSMgr );
361 Reference<XInterface> xService(static_cast<XIdentity*>(o), UNO_QUERY);
362 return xService;
365 Sequence<OUString> OComponent_getSupportedServiceNames(void)
367 Sequence<OUString> aRet(1);
368 aRet.getArray()[0] = SERVICE_NAME;//ODataInputStream_getImplementationName();
370 return aRet;
374 extern "C" sal_Bool SAL_CALL component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey )
376 if(pRegistryKey)
380 Reference<XRegistryKey> xNewKey =
381 reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(KEY1);
382 xNewKey->createKey( KEY2);
383 return sal_True;
386 catch(InvalidRegistryException &)
388 OSL_ENSURE( sal_False, "### InvalidRegistryException!\n");
391 return sal_False;
394 extern "C" void * SAL_CALL component_getFactory(
395 const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
397 static void * pRet= NULL;
398 if( ! pRet)
400 OUString aImplName( OUString::createFromAscii( pImplName ) );
401 if (pServiceManager && aImplName.equals( IMPL_NAME ))
403 Reference<XMultiServiceFactory> xMulFac(
404 reinterpret_cast< XMultiServiceFactory*>(pServiceManager));
406 Sequence<OUString> seqServiceNames;
407 Reference<XSingleServiceFactory> xFactory = createOneInstanceFactory( xMulFac, SERVICE_NAME,
408 OComponent_CreateInstance, seqServiceNames);
410 if (xFactory.is())
412 xFactory->acquire();
413 pRet = xFactory.get();
417 return pRet;
420 extern "C" void SAL_CALL component_getImplementationEnvironment(
421 const sal_Char ** ppEnvTypeName, uno_Environment ** )
423 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
427 // XTestSequence ============================================================================
428 Sequence<sal_Int8> SAL_CALL OComponent::methodByte(const Sequence< sal_Int8 >& aSeq) throw( RuntimeException )
430 sal_Int8 _x;
431 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
432 _x= aSeq.getConstArray()[i];
434 return aSeq;
436 Sequence<float> SAL_CALL OComponent::methodFloat(const Sequence< float>& aSeq) throw( RuntimeException )
438 float _x;
439 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
440 _x= aSeq.getConstArray()[i];
442 return aSeq;
444 Sequence<double> SAL_CALL OComponent::methodDouble(const Sequence< double >& aSeq) throw( RuntimeException)
446 double _x;
447 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
448 _x= aSeq.getConstArray()[i];
450 return aSeq;
452 Sequence< sal_Bool > SAL_CALL OComponent::methodBool(const Sequence< sal_Bool >& aSeq) throw( RuntimeException)
454 sal_Bool _x;
455 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
456 _x= aSeq.getConstArray()[i];
458 return aSeq;
460 Sequence< sal_Int16 > SAL_CALL OComponent::methodShort(const Sequence< sal_Int16 >& aSeq) throw( RuntimeException )
462 sal_Int16 _x;
463 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
464 _x= aSeq.getConstArray()[i];
466 return aSeq;
468 Sequence< sal_uInt16 > SAL_CALL OComponent::methodUShort(const Sequence< sal_uInt16 >& aSeq) throw( RuntimeException )
470 sal_uInt16 _x;
471 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
472 _x= aSeq.getConstArray()[i];
474 return aSeq;
476 Sequence< sal_Int32 > SAL_CALL OComponent::methodLong(const Sequence< sal_Int32 >& aSeq) throw( RuntimeException)
478 sal_Int32 _x;
479 for( sal_Int16 i= 0; i < aSeq.getLength(); i++) {
480 _x= aSeq.getConstArray()[i];
482 return aSeq;
484 Sequence< sal_uInt32 > SAL_CALL OComponent::methodULong(const Sequence< sal_uInt32 >& aSeq) throw( RuntimeException)
486 sal_uInt32 _x;
487 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
488 _x= aSeq.getConstArray()[i];
490 return aSeq;
492 Sequence< OUString > SAL_CALL OComponent::methodString(const Sequence< OUString >& aSeq) throw( RuntimeException)
494 OUString _x;
495 for( sal_Int16 i= 0; i < aSeq.getLength(); i++) {
496 _x= aSeq.getConstArray()[i];
498 return aSeq;
500 Sequence< sal_Unicode > SAL_CALL OComponent::methodChar(const Sequence< sal_Unicode >& aSeq) throw( RuntimeException)
502 sal_Unicode _x;
503 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
504 _x= aSeq.getConstArray()[i];
506 return aSeq;
508 Sequence< Any > SAL_CALL OComponent::methodAny(const Sequence< Any >& aSeq) throw( RuntimeException)
510 Any _x;
511 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
512 _x= aSeq.getConstArray()[i];
513 TypeClass _t= _x.getValueTypeClass();
514 if( _t== TypeClass_STRING)
515 OUString s(* (rtl_uString**)_x.getValue());
517 return aSeq;
521 Sequence< Type > SAL_CALL OComponent::methodType(const Sequence< Type >& aSeq) throw( RuntimeException )
523 Type _x;
524 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
525 _x= aSeq.getConstArray()[i];
527 return aSeq;
529 //Sequence< Reference< XInterface> > SAL_CALL methodXInterface ( const Sequence< Reference < XInterface> >& aSeq)
530 // throw (RuntimeException)
531 Sequence< Reference< XInterface > > SAL_CALL OComponent::methodXInterface( const Sequence< Reference< XInterface > >& aSeq ) throw(RuntimeException)
533 for( sal_Int32 i= 0; i < aSeq.getLength(); i++)
535 Reference<XInterface> xInt= aSeq[i];
536 Reference<XEventListener> xList( xInt, UNO_QUERY);
537 if( xList.is())
538 xList->disposing( EventObject());
540 return aSeq;
543 Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::methodSequence(const Sequence< Sequence< sal_Int32 > >& aSeq) throw( RuntimeException)
545 sal_Int32 value;
546 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
547 const Sequence<sal_Int32>& rseq2= aSeq.getConstArray()[i];
548 for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
549 value= rseq2.getConstArray()[j];
552 return aSeq;
554 Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL OComponent::methodSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq)
555 throw( RuntimeException )
557 sal_Int32 value;
558 sal_Int32 len= aSeq.getLength();
559 for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
560 const Sequence< Sequence<sal_Int32> >& rseq2= aSeq.getConstArray()[i];
561 len= rseq2.getLength();
563 for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
564 const Sequence<sal_Int32> & rseq3= rseq2.getConstArray()[j];
565 len= rseq3.getLength();
567 for (sal_Int16 k= 0; k < rseq3.getLength(); k++)
568 value= rseq3.getConstArray()[k];
571 return aSeq;
574 Sequence< Reference< XEventListener> > SAL_CALL OComponent::methodXEventListeners( const Sequence< Reference <XEventListener> >& aSeq) throw( RuntimeException)
576 Reference<XEventListener> listener;
577 for( int i= 0; i < aSeq.getLength(); i++)
579 listener= aSeq[i];
581 listener->disposing( EventObject() );
584 return aSeq;
587 Sequence< Sequence<Reference<XEventListener > > > SAL_CALL OComponent::methodXEventListenersMul( const Sequence<Sequence<Reference<XEventListener > > >& aSeq ) throw (RuntimeException)
589 Reference<XEventListener> listener;
590 for( int i= 0; i < aSeq.getLength(); i++)
592 Sequence<Reference<XEventListener> > seqInner= aSeq[i];
593 for( int j= 0; j < seqInner.getLength(); j++)
595 listener= seqInner[j];
596 listener->disposing( EventObject() );
599 return aSeq;
602 //---------------------------------------------------------------------------------------------
604 Sequence< sal_Int8 > SAL_CALL OComponent::getAttrByte(void) throw( RuntimeException)
606 return m_seqByte;
608 void SAL_CALL OComponent::setAttrByte(const Sequence< sal_Int8 >& AttrByte_) throw( RuntimeException )
610 m_seqByte= AttrByte_;
612 Sequence< float > SAL_CALL OComponent::getAttrFloat(void) throw( RuntimeException )
614 return m_seqFloat;
616 void SAL_CALL OComponent::setAttrFloat(const Sequence< float >& AttrFloat_) throw( RuntimeException )
618 m_seqFloat= AttrFloat_;
621 Sequence< double > SAL_CALL OComponent::getAttrDouble(void) throw( RuntimeException )
623 return m_seqDouble;
625 void SAL_CALL OComponent::setAttrDouble(const Sequence< double >& AttrDouble_) throw( RuntimeException )
627 m_seqDouble= AttrDouble_;
630 Sequence< sal_Bool > SAL_CALL OComponent::getAttrBool(void) throw( RuntimeException)
632 return m_seqBool;
635 void SAL_CALL OComponent::setAttrBool(const Sequence< sal_Bool >& AttrBool_) throw (RuntimeException )
637 m_seqBool= AttrBool_;
640 Sequence< sal_Int16 > SAL_CALL OComponent::getAttrShort(void) throw( RuntimeException)
642 return m_seqShort;
644 void SAL_CALL OComponent::setAttrShort(const Sequence< sal_Int16 >& AttrShort_) throw( RuntimeException )
646 m_seqShort= AttrShort_;
649 Sequence< sal_uInt16 > SAL_CALL OComponent::getAttrUShort(void) throw( RuntimeException )
651 return m_seqUShort;
653 void SAL_CALL OComponent::setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_) throw( RuntimeException )
655 m_seqUShort= AttrUShort_;
658 Sequence< sal_Int32 > SAL_CALL OComponent::getAttrLong(void) throw( RuntimeException)
660 return m_seqLong;
662 void SAL_CALL OComponent::setAttrLong(const Sequence< sal_Int32 >& AttrLong_) throw( RuntimeException )
664 m_seqLong= AttrLong_;
667 Sequence< sal_uInt32 > SAL_CALL OComponent::getAttrULong(void) throw( RuntimeException )
669 return m_seqULong;
671 void SAL_CALL OComponent::setAttrULong(const Sequence< sal_uInt32 >& AttrULong_) throw( RuntimeException )
673 m_seqULong= AttrULong_;
676 Sequence< OUString > SAL_CALL OComponent::getAttrString(void) throw( RuntimeException )
678 return m_seqString;
680 void SAL_CALL OComponent::setAttrString(const Sequence< OUString >& AttrString_) throw( RuntimeException )
682 m_seqString= AttrString_;
685 Sequence< sal_Unicode > SAL_CALL OComponent::getAttrChar(void) throw( RuntimeException )
687 return m_seqChar;
689 void SAL_CALL OComponent::setAttrChar(const Sequence< sal_Unicode >& AttrChar_) throw( RuntimeException)
691 m_seqChar= AttrChar_;
694 Sequence< Any > SAL_CALL OComponent::getAttrAny(void) throw( RuntimeException)
696 return m_seqAny;
698 void SAL_CALL OComponent::setAttrAny(const Sequence< Any >& AttrAny_) throw( RuntimeException )
700 m_seqAny= AttrAny_;
703 Sequence< Type > SAL_CALL OComponent::getAttrType(void) throw( RuntimeException )
705 return m_seqType;
708 void SAL_CALL OComponent::setAttrType( const Sequence< Type >& AttrType_) throw( RuntimeException )
710 m_seqType = AttrType_;
714 Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::getAttrSequence(void) throw( RuntimeException)
716 return m_seq1;
718 void SAL_CALL OComponent::setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence) throw(RuntimeException )
720 sal_Int32 x= 0;
721 for( sal_Int32 i=0; i < AttrSequence.getLength(); i++)
723 Sequence< sal_Int32 > seq= AttrSequence[i];
725 for ( sal_Int32 j=0; j < seq.getLength(); j++)
727 x= seq[j];
731 m_seq1= AttrSequence;
734 Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL OComponent::getAttrSequence2(void) throw( RuntimeException )
736 return m_seq2;
738 void SAL_CALL OComponent::setAttrSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& AttrSequence2_)
739 throw( RuntimeException )
741 m_seq2= AttrSequence2_;
744 Sequence< Reference< XInterface > > SAL_CALL OComponent::getAttrXInterface() throw(RuntimeException)
746 return m_seqxInterface;
748 void SAL_CALL OComponent::setAttrXInterface( const Sequence< Reference< XInterface > >& _attrxinterface ) throw(RuntimeException)
750 m_seqxInterface= _attrxinterface;
753 // ----------------------------------------------------------------------------
755 ::sal_Int8 SAL_CALL OComponent::getAByte() throw (RuntimeException)
757 return m_attr_int8;
760 void SAL_CALL OComponent::setAByte( ::sal_Int8 _abyte ) throw (RuntimeException)
762 m_attr_int8 = _abyte;
765 float SAL_CALL OComponent::getAFloat() throw (RuntimeException)
767 return m_attr_float;
770 void SAL_CALL OComponent::setAFloat( float _afloat ) throw (RuntimeException)
772 m_attr_float = _afloat;
775 double SAL_CALL OComponent::getADouble() throw (RuntimeException)
777 return m_attr_double;
780 void SAL_CALL OComponent::setADouble( double _adouble ) throw (RuntimeException)
782 m_attr_double = _adouble;
785 ::sal_Bool SAL_CALL OComponent::getABool() throw (RuntimeException)
787 return m_attr_bool;
790 void SAL_CALL OComponent::setABool( ::sal_Bool _abool ) throw (RuntimeException)
792 m_attr_bool = _abool;
795 ::sal_Int16 SAL_CALL OComponent::getAShort() throw (RuntimeException)
797 return m_attr_int16;
800 void SAL_CALL OComponent::setAShort( ::sal_Int16 _ashort ) throw (RuntimeException)
802 m_attr_int16 = _ashort;
805 ::sal_uInt16 SAL_CALL OComponent::getAUShort() throw (RuntimeException)
807 return m_attr_uint16;
810 void SAL_CALL OComponent::setAUShort( ::sal_uInt16 _aushort ) throw (RuntimeException)
812 m_attr_uint16 = _aushort;
815 ::sal_Int32 SAL_CALL OComponent::getALong() throw (RuntimeException)
817 return m_attr_int32;
820 void SAL_CALL OComponent::setALong( ::sal_Int32 _along ) throw (RuntimeException)
822 m_attr_int32 = _along;
825 ::sal_uInt32 SAL_CALL OComponent::getAULong() throw (RuntimeException)
827 return m_attr_uint32;;
830 void SAL_CALL OComponent::setAULong( ::sal_uInt32 _aulong ) throw (RuntimeException)
832 m_attr_uint32 = _aulong;
835 ::rtl::OUString SAL_CALL OComponent::getAString() throw (RuntimeException)
837 return m_attr_string;
840 void SAL_CALL OComponent::setAString( const ::rtl::OUString& _astring ) throw (RuntimeException)
842 m_attr_string = _astring;
845 ::sal_Unicode SAL_CALL OComponent::getAChar() throw (RuntimeException)
847 return m_attr_char;
850 void SAL_CALL OComponent::setAChar( ::sal_Unicode _achar ) throw (RuntimeException)
852 m_attr_char = _achar;
855 Any SAL_CALL OComponent::getAAny() throw (RuntimeException)
857 return m_attr_any;
860 void SAL_CALL OComponent::setAAny( const Any& _aany ) throw (RuntimeException)
862 m_attr_any = _aany;
865 Type SAL_CALL OComponent::getAType() throw (RuntimeException)
867 return m_attr_type;
870 void SAL_CALL OComponent::setAType( const Type& _atype ) throw (RuntimeException)
872 m_attr_type = _atype;
875 Reference< XInterface > SAL_CALL OComponent::getAXInterface() throw (RuntimeException)
877 return m_attr_xinterface;
880 void SAL_CALL OComponent::setAXInterface( const Reference<XInterface >& _axinterface ) throw (RuntimeException)
882 m_attr_xinterface = _axinterface;
885 Reference<XInvocation > SAL_CALL OComponent::getAXInvocation() throw (RuntimeException)
887 return m_attr_xinvocation;
890 void SAL_CALL OComponent::setAXInvocation( const Reference< XInvocation >& _axinvocation ) throw (RuntimeException)
892 m_attr_xinvocation = _axinvocation;
894 //-----------------------------------------------------------------------------------
895 void SAL_CALL OComponent::testout_methodByte(sal_Int8& rOut) throw( RuntimeException )
897 rOut= m_int8;
899 void SAL_CALL OComponent::testout_methodFloat(float& rOut) throw( RuntimeException )
901 rOut= m_float;
903 void SAL_CALL OComponent::testout_methodDouble(double& rOut) throw( RuntimeException )
905 rOut= m_double;
908 void SAL_CALL OComponent::testout_methodBool(sal_Bool& rOut) throw( RuntimeException )
910 rOut= m_bool;
912 void SAL_CALL OComponent::testout_methodShort(sal_Int16& rOut) throw( RuntimeException )
914 rOut= m_int16;
916 void SAL_CALL OComponent::testout_methodUShort(sal_uInt16& rOut) throw( RuntimeException )
918 rOut= m_uint16;
920 void SAL_CALL OComponent::testout_methodLong(sal_Int32& rOut) throw( RuntimeException )
922 rOut = m_int32;
924 void SAL_CALL OComponent::testout_methodULong(sal_uInt32& rOut) throw( RuntimeException )
926 rOut= m_uint32;
928 void SAL_CALL OComponent::testout_methodHyper(sal_Int64& rOut) throw( RuntimeException )
930 rOut = m_int64;
933 void SAL_CALL OComponent::testout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException )
935 rOut = m_uint64;
938 void SAL_CALL OComponent::testout_methodString(OUString& rOut) throw( RuntimeException )
940 rOut= m_string;
942 void SAL_CALL OComponent::testout_methodChar(sal_Unicode& rOut) throw( RuntimeException )
944 rOut= m_char;
946 void SAL_CALL OComponent::testout_methodAny(Any& rOut) throw( RuntimeException)
948 rOut = m_any;
951 void SAL_CALL OComponent::testout_methodType(Type& rOut) throw( RuntimeException )
953 rOut = m_type;
956 void SAL_CALL OComponent::testout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException)
958 rOut.realloc(10);
959 for( sal_Int16 i= 0; i < rOut.getLength(); i++) rOut.getArray()[i]= i;
961 void SAL_CALL OComponent::testout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException )
963 rOut.realloc( 10);
964 for( sal_Int16 i= 0; i < rOut.getLength(); i++){
965 Sequence<sal_Int32>& rseq2= rOut.getArray()[i];
966 rseq2.realloc( 10);
967 for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
968 rseq2.getArray()[j]= j;
972 void SAL_CALL OComponent::testout_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException )
974 rout1= 999;
975 rout2= 1111;
977 void SAL_CALL OComponent::testout_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException )
979 rout1= 1111;
980 rout2= 1222;
981 rout3= L" another string";
983 void SAL_CALL OComponent::testout_methodMulParams3(const OUString&, OUString& sout) throw( RuntimeException )
985 sout= L"Out Hallo!";
987 void SAL_CALL OComponent::testout_methodMulParams4( float in1, float& out1, sal_Int32 in2, sal_Int32& out2, sal_Int32 ) throw(RuntimeException)
989 out1= in1 + 1;
990 out2= in2 + 1;
993 void SAL_CALL OComponent::testout_methodXInterface( Reference< XInterface >& rOut ) throw(RuntimeException)
995 rOut = m_xinterface;
996 // OUString string( L"Property Any");
997 // m_any <<= string;
998 // rOut= Reference<XInterface> (static_cast<XTestSequence*>(this), UNO_QUERY);
1001 // XTestInParameters ------------------------------------------------------------
1002 sal_Int8 SAL_CALL OComponent::in_methodByte( sal_Int8 rIn ) throw (RuntimeException)
1004 m_int8 = rIn;
1005 return rIn;
1007 float SAL_CALL OComponent::in_methodFloat( float rIn ) throw (RuntimeException)
1009 m_float = rIn;
1010 return rIn;
1012 double SAL_CALL OComponent::in_methodDouble( double rIn ) throw (RuntimeException)
1014 m_double = rIn;
1015 return rIn;
1017 sal_Bool SAL_CALL OComponent::in_methodBool( sal_Bool rIn ) throw (RuntimeException)
1019 m_bool = rIn;
1020 return rIn;
1022 sal_Int16 SAL_CALL OComponent::in_methodShort( sal_Int16 rIn ) throw (RuntimeException)
1024 m_int16 = rIn;
1025 return rIn;
1027 sal_uInt16 SAL_CALL OComponent::in_methodUShort( sal_uInt16 rIn ) throw (RuntimeException)
1029 m_uint16 = rIn;
1030 return rIn;
1032 sal_Int32 SAL_CALL OComponent::in_methodLong( sal_Int32 rIn ) throw (RuntimeException)
1034 m_int32 = rIn;
1035 return rIn;
1037 sal_uInt32 SAL_CALL OComponent::in_methodULong( sal_uInt32 rIn ) throw (RuntimeException)
1039 m_uint32 = rIn;
1040 return rIn;
1042 sal_Int64 SAL_CALL OComponent::in_methodHyper( sal_Int64 rIn ) throw (RuntimeException)
1044 m_int64 = rIn;
1045 return rIn;
1048 sal_uInt64 SAL_CALL OComponent::in_methodUHyper( sal_uInt64 rIn ) throw (RuntimeException)
1050 m_uint64 = rIn;
1051 return rIn;
1054 OUString SAL_CALL OComponent::in_methodString( const OUString& rIn ) throw (RuntimeException)
1056 m_string = rIn;
1057 return rIn;
1059 sal_Unicode SAL_CALL OComponent::in_methodChar( sal_Unicode rIn ) throw (RuntimeException)
1061 m_char = rIn;
1062 return rIn;
1064 Any SAL_CALL OComponent::in_methodAny( const Any& rIn ) throw (RuntimeException)
1066 m_any = rIn;
1067 return rIn;
1070 Type SAL_CALL OComponent::in_methodType( const Type& rIn ) throw (RuntimeException)
1072 m_type = rIn;
1073 return rIn;
1076 Reference<XInvocation > SAL_CALL OComponent::in_methodInvocation( const Reference< XInvocation >& inv )
1077 throw (RuntimeException)
1079 //We expect the invocation results from a conversion of VBasicEventListener.VBEventListener
1080 //which implements XEventListener
1081 // extensions/test/ole/EventListenerSample
1082 EventObject event( Reference<XInterface>(static_cast<XTestInParameters*>(this),UNO_QUERY));
1083 Any anyParam;
1084 anyParam <<= event;
1085 Sequence<Any> params( &anyParam, 1);
1086 Sequence<sal_Int16> outIndex;
1087 Sequence<Any> outParams;
1088 try{
1089 inv->invoke( OUString(RTL_CONSTASCII_USTRINGPARAM("disposing")),
1090 params, outIndex, outParams);
1091 }catch(IllegalArgumentException &) {
1093 catch(CannotConvertException &){
1095 catch(InvocationTargetException&) {
1097 return inv;
1099 Reference<XInterface> SAL_CALL OComponent::in_methodXInterface( const Reference<XInterface >& rIn ) throw (RuntimeException)
1101 m_xinterface = rIn;
1102 return rIn;
1105 SimpleStruct SAL_CALL OComponent::in_methodStruct( const SimpleStruct& aStruct )
1106 throw (RuntimeException)
1108 SimpleStruct& s= const_cast<SimpleStruct&>(aStruct);
1109 s.message= s.message + OUString(RTL_CONSTASCII_USTRINGPARAM(
1110 "This string was set in OleTest"));
1111 return aStruct;
1113 void SAL_CALL OComponent::in_methodAll(
1114 sal_Int8, float, double, sal_Bool, sal_Int16, sal_uInt16,
1115 sal_Int32, sal_uInt32, const OUString&, sal_Unicode,
1116 const Any&, const Type&, const Reference<XInvocation>&) throw (RuntimeException)
1120 // INOUT -----------------------------------------------------------------------------------
1121 void SAL_CALL OComponent::testinout_methodByte(sal_Int8& rOut) throw( RuntimeException )
1123 sal_Int8 tmp = rOut;
1124 rOut = m_int8;
1125 m_int8 = tmp;
1127 void SAL_CALL OComponent::testinout_methodFloat(float& rOut) throw( RuntimeException )
1129 float tmp = rOut;
1130 rOut = m_float;
1131 m_float = tmp;
1134 void SAL_CALL OComponent::testinout_methodDouble(double& rOut) throw( RuntimeException )
1136 double tmp = rOut;
1137 rOut = m_double;
1138 m_double = tmp;
1140 void SAL_CALL OComponent::testinout_methodBool(sal_Bool& rOut) throw( RuntimeException )
1142 sal_Bool tmp = rOut;
1143 rOut = m_bool;
1144 m_bool = tmp;
1146 void SAL_CALL OComponent::testinout_methodShort(sal_Int16& rOut) throw( RuntimeException )
1148 sal_Int16 tmp= rOut;
1149 rOut = m_int16;
1150 m_int16 = tmp;
1152 void SAL_CALL OComponent::testinout_methodUShort(sal_uInt16& rOut) throw( RuntimeException )
1154 sal_uInt16 tmp = rOut;
1155 rOut = m_uint16;
1156 m_uint16 = tmp;
1158 void SAL_CALL OComponent::testinout_methodLong(sal_Int32& rOut) throw( RuntimeException )
1160 sal_Int32 tmp = rOut;
1161 rOut = m_int32;
1162 m_int32 = tmp;
1164 void SAL_CALL OComponent::testinout_methodULong(sal_uInt32& rOut) throw( RuntimeException )
1166 sal_uInt32 tmp = rOut;
1167 rOut = m_uint32;
1168 m_uint32 = tmp;
1170 void SAL_CALL OComponent::testinout_methodHyper(sal_Int64& rOut) throw( RuntimeException )
1172 sal_Int64 tmp = rOut;
1173 rOut = m_int64;
1174 m_int64 = tmp;
1177 void SAL_CALL OComponent::testinout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException )
1179 sal_uInt64 tmp = rOut;
1180 rOut = m_uint64;
1181 m_uint64 = tmp;
1184 void SAL_CALL OComponent::testinout_methodString(OUString& rOut) throw( RuntimeException )
1186 OUString tmp = rOut;
1187 rOut = m_string;
1188 m_string = tmp;
1190 void SAL_CALL OComponent::testinout_methodChar(sal_Unicode& rOut) throw( RuntimeException)
1192 sal_Unicode tmp = rOut;
1193 rOut = m_char;
1194 m_char = tmp;
1196 void SAL_CALL OComponent::testinout_methodAny(Any& rOut) throw( RuntimeException)
1198 Any tmp = rOut;
1199 rOut = m_any;
1200 m_any = tmp;
1202 void SAL_CALL OComponent::testinout_methodType(Type& rOut) throw( RuntimeException)
1204 Type tmp = rOut;
1205 rOut = m_type;
1206 m_type = tmp;
1210 void SAL_CALL OComponent::testinout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException)
1213 sal_Int32* arr= rOut.getArray();
1214 for ( sal_Int32 i=0; i < rOut.getLength(); i++)
1216 rOut.getArray()[i] += 1;
1219 void SAL_CALL OComponent::testinout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException )
1221 for( sal_Int32 i=0; i < rOut.getLength(); i++)
1223 Sequence< sal_Int32 >& seq= rOut.getArray()[i];
1225 for ( sal_Int32 j=0; j < seq.getLength(); j++)
1227 seq.getArray()[j] += seq.getArray()[j];
1232 // The parameter should implement XInvocation and a Property "value"
1233 void SAL_CALL OComponent::testinout_methodXInterface( Reference< XInvocation >& rOut ) throw(RuntimeException)
1235 Any any;
1236 any= rOut->getValue( OUString( L"value"));
1237 OUString _s;
1238 any >>= _s;
1239 OUString string(L"out");
1240 any <<= string;
1241 rOut->setValue( OUString(L"value"), any);
1243 any= rOut->getValue( OUString( L"value"));
1244 any >>= _s;
1248 void SAL_CALL OComponent::testinout_methodXInterface2( Reference< XInterface > & rOut) throw( RuntimeException)
1250 Reference<XInterface> tmp = rOut;
1251 rOut = m_xinterface;
1252 m_xinterface = tmp;
1253 // Reference<XTestSequence> xTest( rOut, UNO_QUERY);
1254 // if( xTest.is())
1255 // {
1256 // Any any= xTest->getAttrAny2();
1257 // OUString _s;
1258 // any >>= _s;
1259 // OUString string= _s + OUString((L" this string was written in the UNO component to the inout pararmeter"));
1260 // any <<= string;
1261 // xTest->setAttrAny2( any);
1262 // }
1265 Any SAL_CALL OComponent::methodAnyTest1(const Any& rIn) throw( RuntimeException )
1267 return rIn;
1269 Any SAL_CALL OComponent::getAttrAny2(void) throw( RuntimeException )
1271 return m_any;
1273 void SAL_CALL OComponent::setAttrAny2(const Any& AttrAny2_) throw( RuntimeException )
1275 m_any= AttrAny2_;
1280 // XTestStruct =======================================================================================
1282 void SAL_CALL OComponent::methodStruct(const Property& aProp) throw( RuntimeException )
1284 char buff[1024];
1285 buff[0]= 0;
1286 sprintf( buff,"Property::Attribute : %d \n Property::Handle : %d \n Property::Name : %S",
1287 aProp.Attributes, aProp.Handle, (const sal_Unicode*)aProp.Name);
1288 MessageBox( NULL, A2T(buff), _T("OleTest: methodStruct"), MB_OK);
1291 Property SAL_CALL OComponent::retMethodStruct(void) throw( RuntimeException )
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;
1300 Property SAL_CALL OComponent::getAttrStruct(void) throw( RuntimeException)
1302 Property a(L"OleTest_Property", 255, getCppuType( (Reference<XInterface>*)0), PropertyAttribute::MAYBEVOID |
1303 PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED |
1304 PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY |
1305 PropertyAttribute::MAYBEAMBIGUOUS | PropertyAttribute::MAYBEDEFAULT );
1306 return a;
1310 void SAL_CALL OComponent::setAttrStruct(const Property& AttrStruct_) throw( RuntimeException )
1312 char buff[1024];
1313 buff[0]= 0;
1314 sprintf( buff,"Property::Attribute : %d \n Property::Handle : %d \n Property::Name : %S",
1315 AttrStruct_.Attributes, AttrStruct_.Handle, (const sal_Unicode*)AttrStruct_.Name);
1316 // MessageBox( NULL, A2T(buff), _T("OleTest: setAttrStruct"), MB_OK);
1319 Property SAL_CALL OComponent::methodStruct2( const Property& aProp ) throw (RuntimeException)
1321 return aProp;
1324 // XTestOther ==================================================================================
1325 void SAL_CALL OComponent::other_methodAnyIn(const Any& ) throw( RuntimeException )
1328 void SAL_CALL OComponent::other_methodAnyOut(Any& rAny) throw( RuntimeException )
1330 rAny <<= OUString(L"Ein Any");
1333 Any SAL_CALL OComponent::other_methodAnyRet(void) throw(RuntimeException )
1335 Any a;
1336 a <<= OUString(L"Ein Any");
1337 return a;
1339 void SAL_CALL OComponent::in_float( float val) throw ( RuntimeException)
1341 USES_CONVERSION;
1342 char buff[256];
1343 sprintf( buff, "parameter : %f", val);
1344 MessageBox( NULL, A2T(buff), _T("OleTest"), MB_OK);
1346 Any SAL_CALL OComponent::other_methodAny( const Any& rAny, const OUString& typeInAny )
1347 throw (RuntimeException)
1349 Type expectedType;
1350 typelib_TypeDescription * pDesc= NULL;
1351 typelib_typedescription_getByName( &pDesc, typeInAny.pData );
1352 if( pDesc)
1354 expectedType = Type( pDesc->pWeakRef );
1355 typelib_typedescription_release( pDesc);
1357 if (rAny.getValueType() != expectedType)
1358 throw RuntimeException();
1360 return rAny;
1363 // XTestOutParameters ============================================================================
1364 // void SAL_CALL OComponent::out_test(sal_Int8 rIn) throw( RuntimeException )
1365 // {
1366 // }
1368 // void SAL_CALL OComponent::out_methodByte(sal_Int8& rOut) throw( RuntimeException )
1369 // {
1370 // rOut= 100;
1371 // }
1373 // void SAL_CALL OComponent::out_methodDouble(double& rOut) throw( RuntimeException )
1374 // {
1375 // rOut= 3.14;
1376 // }
1377 // void SAL_CALL OComponent::out_methodFloat(float& rOut) throw( RuntimeException )
1378 // {
1379 // rOut= 3.14;
1380 // }
1381 // void SAL_CALL OComponent::out_methodBool(sal_Bool& rOut) throw( RuntimeException )
1382 // {
1383 // rOut= sal_True;
1384 // }
1385 // void SAL_CALL OComponent::out_methodShort(sal_Int16& rOut) throw( RuntimeException )
1386 // {
1387 // rOut= -100;
1388 // }
1389 // void SAL_CALL OComponent::out_methodUShort(sal_uInt16& rOut) throw( RuntimeException )
1390 // {
1391 // rOut= 100;
1392 // }
1393 // void SAL_CALL OComponent::out_methodLong(sal_Int32& rOut) throw( RuntimeException )
1394 // {
1395 // rOut= -100;
1396 // }
1398 // void SAL_CALL OComponent::out_methodULong(sal_uInt32& rOut) throw( RuntimeException )
1399 // {
1400 // rOut= 100;
1401 // }
1402 // void SAL_CALL OComponent::out_methodHyper(sal_Int64& rOut) throw( RuntimeException )
1403 // {
1405 // }
1407 // void SAL_CALL OComponent::out_methodUHyper(sal_uInt64& rOut) throw( RuntimeException )
1408 // {
1409 // }
1411 // void SAL_CALL OComponent::out_methodString(OUString& rOut) throw( RuntimeException )
1412 // {
1413 // rOut= L"I'm a string";
1414 // }
1415 // void SAL_CALL OComponent::out_methodChar(sal_Unicode& rOut) throw( RuntimeException )
1416 // {
1417 // rOut= 'A';
1418 // }
1419 // void SAL_CALL OComponent::out_methodAny(Any& rOut) throw( RuntimeException)
1420 // {
1421 // Any a;
1422 // a <<= OUString( L"Hi");
1423 // rOut= a;
1424 // }
1425 // void SAL_CALL OComponent::out_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException )
1426 // {
1427 // Sequence< sal_Int32 > aseq(10);
1428 // for( sal_Int16 i= 0; i < aseq.getLength(); i++) aseq.getArray()[i]= i;
1429 // rOut= aseq;
1430 // }
1431 // void SAL_CALL OComponent::out_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException )
1432 // {
1433 // rOut= Sequence< Sequence< sal_Int32 > >();
1434 // }
1435 // void SAL_CALL OComponent::out_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException )
1436 // {
1437 // rout1= 111;
1438 // rout2= 222;
1439 // }
1440 // void SAL_CALL OComponent::out_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException )
1441 // {
1442 // rout1= 111;
1443 // rout2= 222;
1444 // rout3= L"this is a neet little string";
1445 // }
1446 // void SAL_CALL OComponent::out_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException )
1447 // {
1448 // sout= L"this is a neet little string";
1449 // }
1451 // XTestInterfaces -------------------------------------------------------------------------------------
1452 void SAL_CALL OComponent::testInterface( const Reference< XCallback >& xCallback, sal_Int32 mode ) throw(RuntimeException)
1454 USES_CONVERSION;
1455 sal_Int32 i=0;
1456 OUString aString;
1457 char buff[1024];
1459 Reference<XSimple> xSimple;
1460 SimpleStruct aSimpleStruct;
1461 SimpleEnum aSimpleEnum;
1462 Sequence<Any> seqAny;
1463 Sequence< sal_Int8 > seqByte;
1464 Any outAny;
1465 sal_Bool aBool;
1466 sal_Unicode aChar;
1467 float aFloat;
1468 double aDouble;
1469 sal_Int8 aByte;
1470 sal_Int16 aShort;
1471 sal_Int32 aLong;
1472 // sal_uInt16 aUShort;
1473 // sal_uInt32 aULong;
1475 switch( mode)
1477 case 1:
1478 xCallback->func1(); break;
1479 case 2:
1480 xSimple= xCallback->returnInterface();
1481 xSimple->func(L"XCallback::returnInterface");
1482 break;
1485 case 3:
1486 xCallback->outInterface( xSimple);
1487 sprintf( buff, "XCallback::outInterface, value: %x", xSimple.get());
1488 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1489 xSimple->func(L"XCallback::outInterface works");
1490 break;
1491 case 4:
1492 xCallback->outStruct( aSimpleStruct);
1493 sprintf( buff,"XCallback::outStruct, SimpleStruct::message: %s", OLE2A( aSimpleStruct.message));
1494 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1495 break;
1496 case 5:
1497 xCallback->outEnum( aSimpleEnum);
1498 sprintf( buff,"XCallback::outEnum, SimpleEnum: %d", aSimpleEnum);
1499 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1500 break;
1501 case 6:
1502 xCallback->outSeqAny( seqAny);
1503 sprintf( buff,"XCallback::outSeqAny, length: %d )", seqAny.getLength());
1504 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1505 for( i=0; i < seqAny.getLength(); i++)
1507 Any any= seqAny[i];
1508 if( any.getValueTypeClass() == TypeClass_STRING)
1510 any >>= aString;
1511 OutputDebugStringW( aString);
1515 break;
1516 case 7:
1517 xCallback->outAny( outAny);
1518 if( outAny.getValueTypeClass() == TypeClass_STRING)
1519 outAny >>= aString;
1520 sprintf( buff,"XCallback::outAny, Any : %s", W2A( aString));
1521 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1522 break;
1523 case 8:
1524 xCallback->outBool( aBool);
1525 sprintf( buff,"XCallback::outBool, value: %d", aBool);
1526 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1527 break;
1528 case 9:
1529 xCallback->outChar( aChar);
1530 sprintf( buff,"XCallback::outChar, value: %C", aChar);
1531 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1532 break;
1533 case 10:
1534 xCallback->outString( aString);
1535 sprintf( buff,"XCallback::outString, value: %s", W2A( aString));
1536 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1537 break;
1538 case 11:
1539 xCallback->outFloat( aFloat);
1540 sprintf( buff,"XCallback::outFloat, value: %f", aFloat);
1541 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1542 break;
1543 case 12:
1544 xCallback->outDouble( aDouble);
1545 sprintf( buff,"XCallback::outDouble, value: %f", aDouble);
1546 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1547 break;
1548 case 13:
1549 xCallback->outByte( aByte);
1550 sprintf( buff,"XCallback::outByte, value: %d", aByte);
1551 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1552 break;
1553 case 14:
1554 xCallback->outShort( aShort);
1555 sprintf( buff,"XCallback::outShort, value: %d", aShort);
1556 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1557 break;
1558 case 15:
1559 xCallback->outLong( aLong);
1560 sprintf( buff,"XCallback::outLong, value: %d", aLong);
1561 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1562 break;
1563 case 18:
1564 case 19:
1565 case 30:
1568 long outLong= 0;
1569 xCallback->outValuesMixed( 1111, outLong, OUString( L"in string") );
1571 sprintf( buff, "oletest.testInterface: outValue: %d", outLong);
1572 MessageBox( NULL, A2T(buff), _T("OleTest"), MB_OK);
1573 break;
1576 case 31:
1578 Reference< XSimple > xSimple;
1579 SimpleStruct aSimpleStruct;
1580 SimpleEnum aSimpleEnum;
1581 Sequence<Any> seqAny;
1582 Any aAny;
1583 sal_Bool aBool;
1584 sal_Unicode aChar;
1585 OUString aString;
1586 float aFloat;
1587 double aDouble;
1588 sal_Int8 aByte;
1589 sal_Int16 aShort;
1590 sal_Int32 aLong;
1591 // sal_uInt16 aUShort;
1592 // sal_uInt32 aULong;
1593 xCallback->outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool,
1594 aChar, aString,
1595 aFloat, aDouble,
1596 aByte,
1597 aShort, aLong);
1599 MessageBox( NULL, _T("XCallback::outValuesAll returned"), _T("OleTest::testInterface"), MB_OK);
1600 break;
1602 case 32:
1605 xCallback->outSeqByte( seqByte);
1606 sprintf( buff,"XCallback::outSeqAny, length: %d )", seqAny.getLength());
1607 MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
1608 for( i=0; i < seqAny.getLength(); i++)
1610 Any any= seqAny[i];
1611 if( any.getValueTypeClass() == TypeClass_STRING)
1613 any >>= aString;
1614 OutputDebugStringW( aString);
1617 break;
1619 // ############################################################################
1620 // IN OUT parameter
1621 // ############################################################################
1622 case 100:
1624 Reference<XSimple> xSimple= static_cast<XSimple*>(this);
1625 xCallback->inoutInterface( xSimple);
1626 xSimple->func(L"XSimple called from OleTest");
1627 break;
1629 case 101:
1631 Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
1632 if( xRefl.is())
1634 Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
1635 Any any;
1636 if( xClass.is())
1637 xClass->createObject( any);
1639 if( any.getValueTypeClass() == TypeClass_STRUCT)
1641 SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
1642 pStruct->message= OUString::createFromAscii("This struct was created in OleTest");
1644 SimpleStruct aStruct;
1645 any >>= aStruct;
1646 xCallback->inoutStruct( aStruct);
1647 // a Struct should now contain a different message
1648 MessageBox( NULL, W2T(aStruct.message), _T("OleTest in out parameter"), MB_OK);
1652 break;
1654 case 102:
1656 SimpleEnum aEnum= SimpleEnum_B;
1657 xCallback->inoutEnum( aEnum);
1658 char buff[1024];
1659 sprintf( buff, "Enum: %d", aEnum);
1660 MessageBox( NULL, A2T(buff), _T("OleTest in out parameter"), MB_OK);
1661 break;
1663 case 103:
1665 Any arAny[3];
1666 arAny[0] <<= OUString( L"string 0");
1667 arAny[1] <<= OUString( L"string 1");
1668 arAny[2] <<= OUString( L"string 2");
1670 Sequence< Any >seqAny( arAny, 3);
1671 xCallback->inoutSeqAny( seqAny);
1672 char buff[1023];
1673 sprintf( buff, "Sequence length: %d", seqAny.getLength());
1674 MessageBox( NULL,A2T(buff) , _T("OleTest in out parameter"), MB_OK);
1676 for( int i=0; i < seqAny.getLength(); i++)
1678 Any any;
1679 any <<= seqAny[i];
1680 if(any.getValueTypeClass() == TypeClass_STRING)
1682 OUString str;
1683 any >>= str;
1688 break;
1690 case 104:
1692 Any any;
1693 OUString s(L" OleTest");
1694 any <<= s;
1695 xCallback->inoutAny(any);
1696 if( any.getValueTypeClass() == TypeClass_STRING)
1698 OUString s= *( rtl_uString**) any.getValue();
1699 MessageBox( NULL, W2T( s), _T("OleTest: inout value any"), MB_OK);
1701 break;
1703 case 105:
1705 sal_Bool b= sal_True;
1706 xCallback->inoutBool( b);
1707 char buff[1024];
1708 sprintf( buff, "out value bool: %d", b);
1709 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1710 break;
1712 case 106:
1714 sal_Unicode uc= L'A';
1715 xCallback->inoutChar( uc);
1716 char buff[1024];
1717 sprintf( buff, "out value sal_Unicode: %C", uc);
1718 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1719 break;
1721 case 107:
1723 OUString s(L"OleTest");
1724 xCallback->inoutString( s);
1725 char buff[1024];
1726 sprintf( buff, "out value string: %S", s.getStr());
1727 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1728 break;
1730 case 108:
1732 float f= 3.14f;
1733 xCallback->inoutFloat(f);
1734 char buff[1024];
1735 sprintf( buff, "out value float: %f", f);
1736 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1737 break;
1739 case 109:
1741 double f= 3.145;
1742 xCallback->inoutDouble( f);
1743 char buff[1024];
1744 sprintf( buff, "out value double: %g", f);
1745 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1746 break;
1748 case 110:
1750 sal_Int8 aByte= 0xf;
1751 xCallback->inoutByte( aByte);
1752 char buff[1024];
1753 sprintf( buff, "out value sal_Int8: %d", aByte);
1754 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1755 break;
1757 case 111:
1759 sal_Int16 aShort= 0xff;
1760 xCallback->inoutShort( aShort);
1761 char buff[1024];
1762 sprintf( buff, "out value sal_Int16: %d", aShort);
1763 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1764 break;
1766 case 112:
1768 sal_Int32 aLong= 0xfffe;
1769 xCallback->inoutLong( aLong);
1770 char buff[1024];
1771 sprintf( buff, "out value sal_Int32: %d", aLong);
1772 MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
1773 break;
1775 case 120:
1777 Reference<XSimple> aXSimple= static_cast<XSimple*>(this);
1779 SimpleStruct aStruct;
1780 Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
1781 if( xRefl.is())
1783 Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
1784 Any any;
1785 if( xClass.is())
1786 xClass->createObject( any);
1788 if( any.getValueTypeClass() == TypeClass_STRUCT)
1790 SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
1791 pStruct->message= OUString::createFromAscii("This struct was created in OleTest");
1792 any >>= aStruct;
1796 SimpleEnum aEnum= SimpleEnum_B;
1798 Sequence< Any > aSeq;
1799 Any arAny[3];
1800 arAny[0] <<= OUString( L"string 0");
1801 arAny[1] <<= OUString( L"string 1");
1802 arAny[2] <<= OUString( L"string 2");
1803 aSeq = Sequence< Any >( arAny, 3);
1805 Any aAny;
1806 OUString s(L" OleTest");
1807 aAny <<= s;
1809 sal_Bool aBool= sal_True;
1810 sal_Unicode aChar= L'A';
1811 OUString aString( L"OleTest");
1812 float aFloat=3.14f;
1813 double aDouble= 3.145;
1814 sal_Int8 aByte= 0xf;
1815 sal_Int16 aShort= 0xff;
1816 sal_Int32 aLong= 0xffe;
1818 xCallback->inoutValuesAll( aXSimple, aStruct, aEnum, aSeq,
1819 aAny, aBool, aChar, aString, aFloat, aDouble,
1820 aByte, aShort, aLong );
1822 aXSimple->func(L"XSimple called from OleTest");
1823 MessageBox( NULL, W2T(aStruct.message), _T("OleTest"), MB_OK);
1825 for( int i=0; i < aSeq.getLength(); i++)
1827 Any any;
1828 any <<= aSeq[i];
1829 if(any.getValueTypeClass() == TypeClass_STRING)
1831 OUString str;
1832 any >>= str;
1836 break;
1839 // ############################################################################
1840 // IN parameter
1841 // ############################################################################
1843 case 200:
1845 xCallback->inValues( L'a', 0xffffL, OUString(L" a string from OleTest"));
1846 break;
1847 case 201:
1849 sal_Int8 arbyte[3]= { 1,2,3};
1850 Sequence< sal_Int8 > seq( arbyte, 3);
1851 xCallback->inSeqByte( seq);
1852 break;
1854 case 202:
1856 const int LISTENERS= 3;
1857 Reference<XEventListener> arListeners[LISTENERS];
1858 EventObject arEvents[LISTENERS];
1860 for( int i= 0; i < LISTENERS; i++)
1862 Reference<XInterface> aList= static_cast<XWeak*>( new EventListener());
1863 arListeners[i]= Reference<XEventListener>( aList, UNO_QUERY);
1866 xCallback->inSeqXEventListener(Sequence<Reference<XEventListener> > (arListeners, LISTENERS),
1867 Sequence<EventObject>(arEvents, LISTENERS));
1868 break;
1871 // ############################################################################
1872 // Call a COM object that has not been passed as parameter to a UNO component and
1873 // hence no type information are available in the COM wrapper
1874 // ############################################################################
1875 case 300:
1877 Reference<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.oleautomation.Factory");
1879 Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
1881 Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
1882 Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
1883 //Any SAL_CALL invoke( const OUString& aFunctionName, const Sequence<Any >& aParams,Sequence< sal_Int16 >& aOutParamIndex,
1884 // Sequence<Any >& aOutParam );
1885 Sequence<sal_Int16> seqIndizes;
1886 Sequence<Any> seqOutParams;
1887 xInv->invoke( OUString( L"outValuesAll"), Sequence<Any>(), seqIndizes, seqOutParams);
1889 // void outValuesAll( [out] oletest::XSimple outInterface,
1890 // [out] SimpleStruct outStruct ,
1891 // [out] SimpleEnum outEnum,
1892 // [out] sequence<any> outSeqAny,
1893 // [out] any outAny,
1894 // [out] boolean outBool,
1895 // [out] char outChar,
1896 // [out] string outString,
1897 // [out] float outFloat,
1898 // [out] double outDouble,
1899 // [out] byte outByte,
1900 // [out] short outShort,
1901 // [out] long outLong);
1902 if( seqOutParams.getLength() == 12)
1904 Reference<XSimple> xSimple= *(XSimple**)seqOutParams[0].getValue();
1905 xSimple->func( L"Call from OleTest on XSimple");
1906 SimpleStruct aStruct;
1907 seqOutParams[1] >>= aStruct;
1908 SimpleEnum aEnum= *(SimpleEnum*)seqOutParams[2].getValue();
1910 Sequence<Any> seqAny;
1911 seqOutParams[3] >>= seqAny;
1912 for( int i=0; i<seqAny.getLength(); i++)
1914 OUString _s;
1915 seqAny[i] >>= _s;
1918 Any _any= *(Any*)seqOutParams[4].getValue();
1919 sal_Bool _bool= *(sal_Bool*)seqOutParams[5].getValue();
1920 sal_Unicode _char= *( sal_Unicode*) seqOutParams[6].getValue();
1921 OUString _str= *( rtl_uString**)seqOutParams[7].getValue();
1923 float _f= *( float*)seqOutParams[8].getValue();
1924 double _d= *( double*) seqOutParams[9].getValue();
1925 sal_Int8 _byte= *( sal_Int8*) seqOutParams[10].getValue();
1926 sal_Int16 _short= *( sal_Int16*) seqOutParams[11].getValue();
1928 sal_Int32 _long= *( sal_Int32*) seqOutParams[12].getValue();
1931 break;
1933 case 301:
1934 // in / out parameter
1936 Reference<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.oleautomation.Factory");
1938 Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
1940 Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
1941 Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
1942 Sequence<sal_Int16> seqIndizes;
1943 Sequence<Any> seqOutParams;
1946 Any arAny[13];
1947 Reference<XSimple> xSimple= static_cast<XSimple*>( this);
1949 arAny[0] <<= xSimple;
1950 SimpleStruct aStruct;
1951 Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
1952 if( xRefl.is())
1954 Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
1955 Any any;
1956 if( xClass.is())
1957 xClass->createObject( any);
1959 if( any.getValueTypeClass() == TypeClass_STRUCT)
1961 SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
1962 pStruct->message= OUString::createFromAscii("This struct was created in OleTest");
1963 any >>= aStruct;
1966 arAny[1] <<= aStruct;
1967 arAny[2] <<= SimpleEnum_C;
1969 Any arSeqAny[3];
1970 arSeqAny[0] <<= OUString( L"string 0");
1971 arSeqAny[1] <<= OUString( L"string 1");
1972 arSeqAny[2] <<= OUString( L"string 2");
1974 arAny[3] <<= Sequence< Any >( arAny, 3);
1976 OUString str(L" Ein Any param");
1977 arAny[4] <<= str;
1978 arAny[5] <<= sal_False;
1979 arAny[6] <<= L'B';
1980 OUString stringParam(L" a string parameter");
1981 arAny[7] <<= stringParam;
1982 float _float= 3.14f;
1983 arAny[8] <<= _float;
1984 double _double= 3.145;
1985 arAny[9] <<= _double;
1986 sal_Int8 _byte= -1;
1987 arAny[10] <<= _byte;
1988 sal_Int16 _short= -1;
1989 arAny[11] <<= _short;
1990 sal_Int32 _long= -1;
1991 arAny[12] <<= _long;
1993 Sequence<Any> params( arAny, 13);
1995 xInv->invoke( OUString( L"inoutValuesAll"), params, seqIndizes, seqOutParams);
1997 if( seqOutParams.getLength() == 12)
1999 Reference<XSimple> xSimple= *(XSimple**)seqOutParams[0].getValue();
2000 xSimple->func( L"Call from OleTest on XSimple");
2001 SimpleStruct aStruct;
2002 seqOutParams[1] >>= aStruct;
2003 SimpleEnum aEnum= *(SimpleEnum*)seqOutParams[2].getValue();
2005 Sequence<Any> seqAny;
2006 seqOutParams[3] >>= seqAny;
2007 for( int i=0; i<seqAny.getLength(); i++)
2009 OUString _s;
2010 seqAny[i] >>= _s;
2013 Any _any= *(Any*)seqOutParams[4].getValue();
2014 sal_Bool _bool= *(sal_Bool*)seqOutParams[5].getValue();
2015 sal_Unicode _char= *( sal_Unicode*) seqOutParams[6].getValue();
2016 OUString _str= *( rtl_uString**)seqOutParams[7].getValue();
2018 float _f= *( float*)seqOutParams[8].getValue();
2019 double _d= *( double*) seqOutParams[9].getValue();
2020 sal_Int8 _byte= *( sal_Int8*) seqOutParams[10].getValue();
2021 sal_Int16 _short= *( sal_Int16*) seqOutParams[11].getValue();
2023 sal_Int32 _long= *( sal_Int32*) seqOutParams[12].getValue();
2026 break;
2028 case 303:
2029 // in parameter
2030 // void inValues( [in] char aChar, [in] long aLong, [in] string aString);
2032 Reference<XInterface> xIntFact = m_rFactory->createInstance(
2033 L"com.sun.star.bridge.oleautomation.Factory");
2035 Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
2037 Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
2038 Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
2039 Sequence<sal_Int16> seqIndizes;
2040 Sequence<Any> seqOutParams;
2042 Any arAny[3];
2043 sal_Unicode aChar=L'a';
2044 arAny[0] <<= aChar;
2045 sal_Int32 aLong= 0xffffffff;
2046 arAny[1] <<= aLong;
2047 OUString aString(L" a string parameter");
2048 arAny[2] <<= aString;
2050 xInv->invoke( OUString( L"inValues"), Sequence<Any>(arAny,3), seqIndizes, seqOutParams);
2052 break;
2054 // ############################################################################
2055 // Attributes
2056 // ############################################################################
2058 case 400:
2059 Reference<XSimple> simple= xCallback->getsimple();
2060 simple->func(L"OleTest calls on XSimple");
2061 break;
2070 void SAL_CALL OComponent::setObject( const Reference< XInterface >& val ) throw (RuntimeException)
2072 m_xIntIdentity= val;
2075 sal_Bool SAL_CALL OComponent::isSame( const Reference< XInterface >& val ) throw (RuntimeException)
2077 if( m_xIntIdentity == val)
2078 return sal_True;
2079 else
2080 return sal_False;
2083 Reference< XInterface > SAL_CALL OComponent::getThis( ) throw (RuntimeException)
2085 // return Reference<XInterface>(static_cast<XIdentity*>(this), UNO_QUERY);
2086 Reference<XInterface> ret(static_cast<XIdentity*>(this), UNO_QUERY);
2087 return ret;
2090 void SAL_CALL EventListener::disposing( const ::com::sun::star::lang::EventObject& ) throw (RuntimeException)
2092 bCalled= sal_True;
2095 // XSimple --------------------------------------------------------------------------
2096 void SAL_CALL OComponent::func( const OUString &message)throw(::com::sun::star::uno::RuntimeException)
2098 USES_CONVERSION;
2100 MessageBox( NULL, W2T( message.getStr()), _T("OleTest: XSimple::func"), MB_OK);
2102 // XSimple --------------------------------------------------------------------------
2103 OUString SAL_CALL OComponent::getName()throw(::com::sun::star::uno::RuntimeException)
2105 return L"XSimple";
2107 void SAL_CALL OComponent::testInterface2( const Reference< XSimple >& xSimple, sal_Int32 mode ) throw(RuntimeException)
2109 switch( mode)
2111 case 0:
2113 xSimple->func( L"OleTest is calling XSimple");
2114 Reference<XSimple2> xSimple2( xSimple, UNO_QUERY);
2115 if( xSimple2.is())
2116 xSimple2->func2( L"OleTest is calling XSimple2");
2117 Reference<XSimple3> xSimple3( xSimple, UNO_QUERY);
2118 if( xSimple3.is())
2119 xSimple3->func3( L"OleTest is calling XSimple3");
2121 break;