Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <osl/mutex.hxx>
21 : #include <cppuhelper/queryinterface.hxx>
22 : #include <cppuhelper/weak.hxx>
23 : #include <cppuhelper/factory.hxx>
24 : #include <cppuhelper/implementationentry.hxx>
25 : #include <cppuhelper/supportsservice.hxx>
26 : #include <cppuhelper/typeprovider.hxx>
27 : #include <cppuhelper/implbase2.hxx>
28 :
29 : #include <com/sun/star/script/FailReason.hpp>
30 : #include <com/sun/star/script/XTypeConverter.hpp>
31 : #include <com/sun/star/script/XInvocation.hpp>
32 : #include <com/sun/star/script/XInvocation2.hpp>
33 : #include <com/sun/star/reflection/XIdlReflection.hpp>
34 : #include <com/sun/star/reflection/theCoreReflection.hpp>
35 : #include <com/sun/star/container/XNameContainer.hpp>
36 : #include <com/sun/star/container/XIndexContainer.hpp>
37 : #include <com/sun/star/container/XEnumerationAccess.hpp>
38 : #include <com/sun/star/beans/XExactName.hpp>
39 : #include <com/sun/star/beans/XMaterialHolder.hpp>
40 : #include <com/sun/star/beans/theIntrospection.hpp>
41 : #include <com/sun/star/beans/XPropertySet.hpp>
42 : #include <com/sun/star/beans/PropertyAttribute.hpp>
43 : #include <com/sun/star/beans/MethodConcept.hpp>
44 : #include <com/sun/star/beans/PropertyConcept.hpp>
45 : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
46 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
47 : #include <com/sun/star/lang/XServiceInfo.hpp>
48 : #include <com/sun/star/lang/XTypeProvider.hpp>
49 : #include <com/sun/star/registry/XRegistryKey.hpp>
50 :
51 : #include <boost/scoped_array.hpp>
52 : #include <rtl/ustrbuf.hxx>
53 : #include <rtl/strbuf.hxx>
54 :
55 : #define SERVICENAME "com.sun.star.script.Invocation"
56 : #define IMPLNAME "com.sun.star.comp.stoc.Invocation"
57 :
58 : using namespace css::uno;
59 : using namespace css::lang;
60 : using namespace css::script;
61 : using namespace css::reflection;
62 : using namespace css::beans;
63 : using namespace css::registry;
64 : using namespace css::container;
65 : using namespace cppu;
66 : using namespace osl;
67 :
68 : namespace stoc_inv
69 : {
70 8 : static Sequence< OUString > inv_getSupportedServiceNames()
71 : {
72 8 : Sequence< OUString > seqNames(1);
73 8 : seqNames.getArray()[0] = SERVICENAME;
74 8 : return seqNames;
75 : }
76 :
77 8 : static OUString inv_getImplementationName()
78 : {
79 8 : return OUString(IMPLNAME);
80 : }
81 :
82 : // TODO: Zentral implementieren
83 1348 : inline Reference<XIdlClass> TypeToIdlClass( const Type& rType, const Reference< XIdlReflection > & xRefl )
84 : {
85 1348 : return xRefl->forName( rType.getTypeName() );
86 : }
87 :
88 :
89 :
90 : class Invocation_Impl
91 : : public OWeakObject
92 : , public XInvocation2
93 : , public XNameContainer
94 : , public XIndexContainer
95 : , public XEnumerationAccess
96 : , public XExactName
97 : , public XMaterialHolder
98 : , public XTypeProvider
99 : {
100 : public:
101 : Invocation_Impl( const Any & rAdapted, const Reference<XTypeConverter> &,
102 : const Reference<XIntrospection> &,
103 : const Reference<XIdlReflection> & );
104 : virtual ~Invocation_Impl();
105 :
106 : // XInterface
107 : virtual Any SAL_CALL queryInterface( const Type & aType) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
108 6150 : virtual void SAL_CALL acquire() throw() SAL_OVERRIDE { OWeakObject::acquire(); }
109 6130 : virtual void SAL_CALL release() throw() SAL_OVERRIDE { OWeakObject::release(); }
110 :
111 :
112 : // XTypeProvider
113 : virtual Sequence< css::uno::Type > SAL_CALL getTypes( )
114 : throw(RuntimeException, std::exception) SAL_OVERRIDE;
115 : virtual Sequence< sal_Int8 > SAL_CALL getImplementationId( )
116 : throw( RuntimeException, std::exception) SAL_OVERRIDE;
117 :
118 : // Methoden von XMaterialHolder
119 : virtual Any SAL_CALL getMaterial(void) throw(RuntimeException, std::exception) SAL_OVERRIDE;
120 :
121 : // XInvocation
122 : virtual Reference<XIntrospectionAccess> SAL_CALL getIntrospection(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
123 : virtual Any SAL_CALL invoke(const OUString& FunctionName, const Sequence< Any >& Params, Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam)
124 : throw( IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException, std::exception ) SAL_OVERRIDE;
125 : virtual void SAL_CALL setValue(const OUString& PropertyName, const Any& Value)
126 : throw( UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException, std::exception ) SAL_OVERRIDE;
127 : virtual Any SAL_CALL getValue(const OUString& PropertyName)
128 : throw( UnknownPropertyException, RuntimeException, std::exception ) SAL_OVERRIDE;
129 : virtual sal_Bool SAL_CALL hasMethod(const OUString& Name) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
130 : virtual sal_Bool SAL_CALL hasProperty(const OUString& Name) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
131 :
132 : // XInvocation2
133 : virtual Sequence< OUString > SAL_CALL getMemberNames( )
134 : throw( RuntimeException, std::exception ) SAL_OVERRIDE;
135 : virtual Sequence< InvocationInfo > SAL_CALL getInfo( )
136 : throw( RuntimeException, std::exception ) SAL_OVERRIDE;
137 : virtual InvocationInfo SAL_CALL getInfoForName( const OUString& aName, sal_Bool bExact )
138 : throw( IllegalArgumentException, RuntimeException, std::exception ) SAL_OVERRIDE;
139 :
140 : // All Access and Container methods are not thread save
141 : // XElementAccess
142 0 : virtual Type SAL_CALL getElementType(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE
143 0 : { return _xElementAccess->getElementType(); }
144 :
145 0 : virtual sal_Bool SAL_CALL hasElements(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE
146 0 : { return _xElementAccess->hasElements(); }
147 :
148 : // XNameContainer
149 0 : virtual void SAL_CALL insertByName( const OUString& Name, const Any& Element )
150 : throw( IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
151 0 : { _xNameContainer->insertByName( Name, Element ); }
152 :
153 0 : virtual void SAL_CALL replaceByName( const OUString& Name, const Any& Element )
154 : throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
155 0 : { _xNameContainer->replaceByName( Name, Element ); }
156 :
157 0 : virtual void SAL_CALL removeByName( const OUString& Name )
158 : throw( NoSuchElementException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
159 0 : { _xNameContainer->removeByName( Name ); }
160 :
161 : // XNameAccess
162 0 : virtual Any SAL_CALL getByName( const OUString& Name )
163 : throw( NoSuchElementException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
164 0 : { return _xNameAccess->getByName( Name ); }
165 :
166 0 : virtual Sequence<OUString> SAL_CALL getElementNames(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE
167 0 : { return _xNameAccess->getElementNames(); }
168 :
169 0 : virtual sal_Bool SAL_CALL hasByName( const OUString& Name ) throw( RuntimeException, std::exception ) SAL_OVERRIDE
170 0 : { return _xNameAccess->hasByName( Name ); }
171 :
172 : // XIndexContainer
173 0 : virtual void SAL_CALL insertByIndex( sal_Int32 Index, const Any& Element )
174 : throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
175 0 : { _xIndexContainer->insertByIndex( Index, Element ); }
176 :
177 0 : virtual void SAL_CALL replaceByIndex( sal_Int32 Index, const Any& Element )
178 : throw( IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
179 0 : { _xIndexContainer->replaceByIndex( Index, Element ); }
180 :
181 0 : virtual void SAL_CALL removeByIndex( sal_Int32 Index )
182 : throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
183 0 : { _xIndexContainer->removeByIndex( Index ); }
184 :
185 : // XIndexAccess
186 0 : virtual sal_Int32 SAL_CALL getCount(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE
187 0 : { return _xIndexAccess->getCount(); }
188 :
189 0 : virtual Any SAL_CALL getByIndex( sal_Int32 Index )
190 : throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException, std::exception ) SAL_OVERRIDE
191 0 : { return _xIndexAccess->getByIndex( Index ); }
192 :
193 : // XEnumerationAccess
194 0 : virtual Reference<XEnumeration> SAL_CALL createEnumeration(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE
195 0 : { return _xEnumerationAccess->createEnumeration(); }
196 :
197 : // XExactName
198 : virtual OUString SAL_CALL getExactName( const OUString& rApproximateName ) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
199 :
200 :
201 :
202 : private:
203 : void setMaterial( const Any& rMaterial );
204 :
205 : void getInfoSequenceImpl( Sequence< OUString >* pStringSeq, Sequence< InvocationInfo >* pInfoSeq );
206 : void fillInfoForNameAccess( InvocationInfo& rInfo, const OUString& aName );
207 : void fillInfoForProperty( InvocationInfo& rInfo, const Property& rProp );
208 : void fillInfoForMethod( InvocationInfo& rInfo, const Reference< XIdlMethod > xMethod );
209 :
210 : Reference<XTypeConverter> xTypeConverter;
211 : Reference<XIntrospection> xIntrospection;
212 : Reference<XIdlReflection> xCoreReflection;
213 :
214 : Any _aMaterial;
215 : // _xDirect and (_xIntrospectionAccess, xPropertySet) are exclusive
216 : Reference<XInvocation> _xDirect;
217 : Reference<XInvocation2> _xDirect2;
218 : Reference<XPropertySet> _xPropertySet;
219 : Reference<XIntrospectionAccess> _xIntrospectionAccess;
220 :
221 : // supplied Interfaces
222 : Reference<XNameContainer> _xNameContainer;
223 : Reference<XNameAccess> _xNameAccess;
224 : Reference<XIndexContainer> _xIndexContainer;
225 : Reference<XIndexAccess> _xIndexAccess;
226 : Reference<XEnumerationAccess> _xEnumerationAccess;
227 : Reference<XElementAccess> _xElementAccess;
228 :
229 :
230 : Reference<XExactName> _xENDirect, _xENIntrospection, _xENNameAccess;
231 : };
232 :
233 :
234 :
235 :
236 :
237 :
238 :
239 1032 : Invocation_Impl::Invocation_Impl
240 : (
241 : const Any & rAdapted,
242 : const Reference<XTypeConverter> & rTC,
243 : const Reference<XIntrospection> & rI,
244 : const Reference<XIdlReflection> & rCR
245 : )
246 : : xTypeConverter( rTC )
247 : , xIntrospection( rI )
248 1032 : , xCoreReflection( rCR )
249 : {
250 1032 : setMaterial( rAdapted );
251 1032 : }
252 :
253 2024 : Invocation_Impl::~Invocation_Impl() {}
254 :
255 :
256 : //### INTERFACE IMPLEMENTATIONS ####################################################################
257 :
258 :
259 :
260 1110 : Any SAL_CALL Invocation_Impl::queryInterface( const Type & aType )
261 : throw( RuntimeException, std::exception )
262 : {
263 : // PropertySet-Implementation
264 : Any a = ::cppu::queryInterface( aType,
265 : (static_cast< XInvocation* >(this)),
266 : (static_cast< XMaterialHolder* >(this)),
267 1110 : (static_cast< XTypeProvider * >(this)) );
268 1110 : if( a.hasValue() )
269 : {
270 68 : return a;
271 : }
272 :
273 1042 : if( aType == cppu::UnoType<XExactName>::get())
274 : {
275 : // Ivocation does not support XExactName, if direct object supports
276 : // XInvocation, but not XExactName.
277 6 : if ((_xDirect.is() && _xENDirect.is()) ||
278 4 : (!_xDirect.is() && (_xENIntrospection.is() || _xENNameAccess.is())))
279 : {
280 2 : return makeAny( Reference< XExactName >( (static_cast< XExactName* >(this)) ) );
281 : }
282 : }
283 1040 : else if ( aType == cppu::UnoType<XNameContainer>::get())
284 : {
285 0 : if( _xNameContainer.is() )
286 0 : return makeAny( Reference< XNameContainer >( (static_cast< XNameContainer* >(this)) ) );
287 : }
288 1040 : else if ( aType == cppu::UnoType<XNameAccess>::get())
289 : {
290 0 : if( _xNameAccess.is() )
291 0 : return makeAny( Reference< XNameAccess >( (static_cast< XNameAccess* >(this)) ) );
292 : }
293 1040 : else if ( aType == cppu::UnoType<XIndexContainer>::get())
294 : {
295 0 : if (_xIndexContainer.is())
296 0 : return makeAny( Reference< XIndexContainer >( (static_cast< XIndexContainer* >(this)) ) );
297 : }
298 1040 : else if ( aType == cppu::UnoType<XIndexAccess>::get())
299 : {
300 0 : if (_xIndexAccess.is())
301 0 : return makeAny( Reference< XIndexAccess >( (static_cast< XIndexAccess* >(this)) ) );
302 : }
303 1040 : else if ( aType == cppu::UnoType<XEnumerationAccess>::get())
304 : {
305 0 : if (_xEnumerationAccess.is())
306 0 : return makeAny( Reference< XEnumerationAccess >( (static_cast< XEnumerationAccess* >(this)) ) );
307 : }
308 1040 : else if ( aType == cppu::UnoType<XElementAccess>::get())
309 : {
310 0 : if (_xElementAccess.is())
311 : {
312 : return makeAny( Reference< XElementAccess >(
313 0 : (static_cast< XElementAccess* >((static_cast< XNameContainer* >(this))) ) ) );
314 : }
315 : }
316 1040 : else if ( aType == cppu::UnoType<XInvocation2>::get())
317 : {
318 : // Invocation does not support XInvocation2, if direct object supports
319 : // XInvocation, but not XInvocation2.
320 3090 : if ( ( _xDirect.is() && _xDirect2.is()) ||
321 2060 : (!_xDirect.is() && _xIntrospectionAccess.is() ) )
322 : {
323 1030 : return makeAny( Reference< XInvocation2 >( (static_cast< XInvocation2* >(this)) ) );
324 : }
325 : }
326 :
327 10 : return OWeakObject::queryInterface( aType );
328 : }
329 :
330 :
331 :
332 60 : Any Invocation_Impl::getMaterial(void) throw(RuntimeException, std::exception)
333 : {
334 : // AB, 12.2.1999 Sicherstellen, dass das Material wenn moeglich
335 : // aus der direkten Invocation bzw. von der Introspection geholt
336 : // wird, da sonst Structs nicht korrekt behandelt werden
337 60 : Reference<XMaterialHolder> xMaterialHolder;
338 60 : if( _xDirect.is() )
339 : {
340 0 : xMaterialHolder = Reference<XMaterialHolder>::query( _xDirect );
341 : //_xDirect->queryInterface( XMaterialHolder::getSmartUik(), xMaterialHolder );
342 : }
343 60 : else if( _xIntrospectionAccess.is() )
344 : {
345 60 : xMaterialHolder = Reference<XMaterialHolder>::query( _xIntrospectionAccess );
346 : //_xIntrospectionAccess->queryInterface( XMaterialHolder::getSmartUik(), xMaterialHolder );
347 : }
348 60 : if( xMaterialHolder.is() )
349 : {
350 60 : return xMaterialHolder->getMaterial();
351 : }
352 0 : return _aMaterial;
353 : }
354 :
355 :
356 1032 : void Invocation_Impl::setMaterial( const Any& rMaterial )
357 : {
358 : // set the material first and only once
359 1032 : Reference<XInterface> xObj;
360 :
361 1032 : if (rMaterial.getValueType().getTypeClass() == TypeClass_INTERFACE)
362 218 : xObj = *(Reference<XInterface>*)rMaterial.getValue();
363 1032 : _aMaterial = rMaterial;
364 :
365 : // Ersteinmal alles ausserhalb des guards machen
366 1032 : _xDirect = Reference<XInvocation>::query( xObj );
367 :
368 1032 : if( _xDirect.is() )
369 : {
370 : // Objekt direkt befragen
371 0 : _xElementAccess = Reference<XElementAccess>::query( _xDirect );
372 0 : _xEnumerationAccess = Reference<XEnumerationAccess>::query( _xDirect );
373 0 : _xIndexAccess = Reference<XIndexAccess>::query( _xDirect );
374 0 : _xIndexContainer = Reference<XIndexContainer>::query( _xDirect );
375 0 : _xNameAccess = Reference<XNameAccess>::query( _xDirect );
376 0 : _xNameContainer = Reference<XNameContainer>::query( _xDirect );
377 0 : _xENDirect = Reference<XExactName>::query( _xDirect );
378 0 : _xDirect2 = Reference<XInvocation2>::query( _xDirect );
379 :
380 : // only once!!!
381 : //_xIntrospectionAccess = XIntrospectionAccessRef();
382 : //_xPropertySet = XPropertySetRef();
383 : }
384 : else
385 : {
386 : // Invocation ueber die Introspection machen
387 1032 : if (xIntrospection.is())
388 : {
389 1032 : _xIntrospectionAccess = xIntrospection->inspect( _aMaterial );
390 1032 : if( _xIntrospectionAccess.is() )
391 : {
392 :
393 2064 : _xElementAccess = Reference<XElementAccess>::query(
394 1032 : _xIntrospectionAccess->queryAdapter(
395 2064 : cppu::UnoType<XElementAccess>::get()) );
396 :
397 2064 : _xEnumerationAccess = Reference<XEnumerationAccess>::query(
398 1032 : _xIntrospectionAccess->queryAdapter(
399 2064 : cppu::UnoType<XEnumerationAccess>::get()) );
400 :
401 2064 : _xIndexAccess = Reference<XIndexAccess>::query(
402 1032 : _xIntrospectionAccess->queryAdapter(
403 2064 : cppu::UnoType<XIndexAccess>::get()) );
404 :
405 2064 : _xIndexContainer = Reference<XIndexContainer>::query(
406 1032 : _xIntrospectionAccess->queryAdapter(
407 2064 : cppu::UnoType<XIndexContainer>::get()) );
408 :
409 2064 : _xNameAccess = Reference<XNameAccess>::query(
410 1032 : _xIntrospectionAccess->queryAdapter(
411 2064 : cppu::UnoType<XNameAccess>::get()) );
412 :
413 2064 : _xNameContainer = Reference<XNameContainer>::query(
414 1032 : _xIntrospectionAccess->queryAdapter(
415 2064 : cppu::UnoType<XNameContainer>::get()) );
416 :
417 2064 : _xPropertySet = Reference<XPropertySet>::query(
418 1032 : _xIntrospectionAccess->queryAdapter(
419 2064 : cppu::UnoType<XPropertySet>::get()) );
420 :
421 1032 : _xENIntrospection = Reference<XExactName>::query( _xIntrospectionAccess );
422 1032 : if (_xNameAccess.is())
423 48 : _xENNameAccess = Reference<XExactName>::query( _xNameAccess );
424 : }
425 : }
426 : /* only once !!!
427 : _xDirect = XInvocationRef();
428 : if( !_xIntrospectionAccess.is() )
429 : {
430 : // reset
431 : _xElementAccess = XElementAccessRef();
432 : _xEnumerationAccess = XEnumerationAccessRef();
433 : _xIndexAccess = XIndexAccessRef();
434 : _xIndexContainer = XIndexContainerRef();
435 : _xNameAccess = XNameAccessRef();
436 : _xNameContainer = XNameContainerRef();
437 : _xPropertySet = XPropertySetRef();
438 : }
439 : */
440 1032 : }
441 1032 : }
442 :
443 :
444 0 : OUString Invocation_Impl::getExactName( const OUString& rApproximateName )
445 : throw( RuntimeException, std::exception )
446 : {
447 0 : if (_xENDirect.is())
448 0 : return _xENDirect->getExactName( rApproximateName );
449 :
450 0 : OUString aRet;
451 0 : if (_xENIntrospection.is())
452 0 : aRet = _xENIntrospection->getExactName( rApproximateName );
453 0 : if (aRet.isEmpty() && _xENNameAccess.is())
454 0 : aRet = _xENNameAccess->getExactName( rApproximateName );
455 0 : return aRet;
456 : }
457 :
458 :
459 0 : Reference<XIntrospectionAccess> Invocation_Impl::getIntrospection(void)
460 : throw( RuntimeException, std::exception )
461 : {
462 0 : if( _xDirect.is() )
463 0 : return _xDirect->getIntrospection();
464 : else
465 0 : return _xIntrospectionAccess;
466 : }
467 :
468 :
469 1718 : sal_Bool Invocation_Impl::hasMethod( const OUString& Name )
470 : throw( RuntimeException, std::exception )
471 : {
472 1718 : if (_xDirect.is())
473 0 : return _xDirect->hasMethod( Name );
474 1718 : if( _xIntrospectionAccess.is() )
475 1718 : return _xIntrospectionAccess->hasMethod( Name, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
476 0 : return sal_False;
477 : }
478 :
479 :
480 1066 : sal_Bool Invocation_Impl::hasProperty( const OUString& Name )
481 : throw( RuntimeException, std::exception )
482 : {
483 1066 : if (_xDirect.is())
484 0 : return _xDirect->hasProperty( Name );
485 : // PropertySet
486 2132 : if( _xIntrospectionAccess.is()
487 1066 : && _xIntrospectionAccess->hasProperty( Name, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
488 924 : return sal_True;
489 : // NameAccess
490 142 : if( _xNameAccess.is() )
491 2 : return _xNameAccess->hasByName( Name );
492 140 : return sal_False;
493 : }
494 :
495 :
496 910 : Any Invocation_Impl::getValue( const OUString& PropertyName )
497 : throw( UnknownPropertyException, RuntimeException, std::exception )
498 : {
499 910 : if (_xDirect.is())
500 0 : return _xDirect->getValue( PropertyName );
501 : try
502 : {
503 : // PropertySet
504 2730 : if( _xIntrospectionAccess.is() && _xPropertySet.is()
505 2730 : && _xIntrospectionAccess->hasProperty
506 910 : ( PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
507 : {
508 910 : return _xPropertySet->getPropertyValue( PropertyName );
509 : }
510 : // NameAccess
511 0 : if( _xNameAccess.is() && _xNameAccess->hasByName( PropertyName ) )
512 0 : return _xNameAccess->getByName( PropertyName );
513 : }
514 0 : catch (UnknownPropertyException &)
515 : {
516 0 : throw;
517 : }
518 0 : catch (RuntimeException &)
519 : {
520 0 : throw;
521 : }
522 0 : catch (Exception &)
523 : {
524 : }
525 :
526 : throw UnknownPropertyException(
527 0 : OUString("cannot get value ") + PropertyName );
528 : }
529 :
530 :
531 246 : void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value )
532 : throw( UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException, std::exception )
533 : {
534 246 : if (_xDirect.is())
535 0 : _xDirect->setValue( PropertyName, Value );
536 : else
537 : {
538 : try
539 : {
540 : // Properties
541 738 : if( _xIntrospectionAccess.is() && _xPropertySet.is()
542 738 : && _xIntrospectionAccess->hasProperty(
543 246 : PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
544 : {
545 246 : Property aProp = _xIntrospectionAccess->getProperty(
546 246 : PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS );
547 492 : Reference < XIdlClass > r = TypeToIdlClass( aProp.Type, xCoreReflection );
548 246 : if( r->isAssignableFrom( TypeToIdlClass( Value.getValueType(), xCoreReflection ) ) )
549 206 : _xPropertySet->setPropertyValue( PropertyName, Value );
550 40 : else if( xTypeConverter.is() )
551 40 : _xPropertySet->setPropertyValue(
552 40 : PropertyName, xTypeConverter->convertTo( Value, aProp.Type ) );
553 : else
554 246 : throw RuntimeException( "no type converter service!" );
555 : }
556 : // NameContainer
557 0 : else if( _xNameContainer.is() )
558 : {
559 0 : Any aConv;
560 : Reference < XIdlClass > r =
561 0 : TypeToIdlClass( _xNameContainer->getElementType(), xCoreReflection );
562 0 : if( r->isAssignableFrom(TypeToIdlClass( Value.getValueType(), xCoreReflection ) ) )
563 0 : aConv = Value;
564 0 : else if( xTypeConverter.is() )
565 0 : aConv = xTypeConverter->convertTo( Value, _xNameContainer->getElementType() );
566 : else
567 0 : throw RuntimeException( "no type converter service!" );
568 :
569 : // bei Vorhandensein ersetzen, ansonsten einfuegen
570 0 : if (_xNameContainer->hasByName( PropertyName ))
571 0 : _xNameContainer->replaceByName( PropertyName, aConv );
572 : else
573 0 : _xNameContainer->insertByName( PropertyName, aConv );
574 : }
575 : else
576 0 : throw UnknownPropertyException( "no introspection nor name container!" );
577 : }
578 0 : catch (UnknownPropertyException &)
579 : {
580 0 : throw;
581 : }
582 0 : catch (CannotConvertException &)
583 : {
584 0 : throw;
585 : }
586 0 : catch (InvocationTargetException &)
587 : {
588 0 : throw;
589 : }
590 0 : catch (RuntimeException &)
591 : {
592 0 : throw;
593 : }
594 0 : catch (const Exception & exc)
595 : {
596 : throw InvocationTargetException(
597 0 : OUString( "exception occurred in setValue(): " ) +
598 0 : exc.Message, Reference< XInterface >(), makeAny( exc /* though sliced */ ) );
599 : }
600 : }
601 246 : }
602 :
603 :
604 808 : Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>& InParams,
605 : Sequence<sal_Int16>& OutIndices, Sequence<Any>& OutParams )
606 : throw( IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException, std::exception )
607 : {
608 808 : if (_xDirect.is())
609 0 : return _xDirect->invoke( FunctionName, InParams, OutIndices, OutParams );
610 :
611 808 : if (_xIntrospectionAccess.is())
612 : {
613 : // throw NoSuchMethodException if not exist
614 808 : Reference<XIdlMethod> xMethod = _xIntrospectionAccess->getMethod(
615 808 : FunctionName, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
616 :
617 : // ParameterInfos
618 1616 : Sequence<ParamInfo> aFParams = xMethod->getParameterInfos();
619 808 : const ParamInfo* pFParams = aFParams.getConstArray();
620 808 : sal_Int32 nFParamsLen = aFParams.getLength();
621 808 : if (nFParamsLen != InParams.getLength())
622 : {
623 : throw IllegalArgumentException(
624 0 : OUString("incorrect number of parameters passed invoking function ") + FunctionName,
625 0 : (OWeakObject *) this, (sal_Int16) 1 );
626 : }
627 :
628 : // IN Parameter
629 808 : const Any* pInParams = InParams.getConstArray();
630 :
631 : // Introspection Invoke Parameter
632 1616 : Sequence<Any> aInvokeParams( nFParamsLen );
633 808 : Any* pInvokeParams = aInvokeParams.getArray();
634 :
635 : // OUT Indices
636 808 : OutIndices.realloc( nFParamsLen );
637 808 : sal_Int16* pOutIndices = OutIndices.getArray();
638 808 : sal_uInt32 nOutIndex = 0;
639 :
640 1664 : for ( sal_Int32 nPos = 0; nPos < nFParamsLen; ++nPos )
641 : {
642 : try
643 : {
644 856 : const ParamInfo& rFParam = pFParams[nPos];
645 856 : const Reference<XIdlClass>& rDestType = rFParam.aType;
646 :
647 : // is IN/INOUT parameter?
648 856 : if (rFParam.aMode != ParamMode_OUT)
649 : {
650 856 : if (rDestType->isAssignableFrom( TypeToIdlClass( pInParams[nPos].getValueType(), xCoreReflection ) ))
651 : {
652 820 : pInvokeParams[nPos] = pInParams[nPos];
653 : }
654 36 : else if (xTypeConverter.is())
655 : {
656 36 : Type aDestType( rDestType->getTypeClass(), rDestType->getName() );
657 36 : pInvokeParams[nPos] = xTypeConverter->convertTo( pInParams[nPos], aDestType );
658 : }
659 : else
660 : {
661 0 : CannotConvertException aExc;
662 0 : aExc.Context = *this;
663 0 : aExc.Message = "invocation type mismatch!";
664 0 : throw aExc;
665 : }
666 : }
667 :
668 : // is OUT/INOUT parameter?
669 856 : if (rFParam.aMode != ParamMode_IN)
670 : {
671 0 : pOutIndices[nOutIndex] = (sal_Int16)nPos;
672 0 : if (rFParam.aMode == ParamMode_OUT)
673 0 : rDestType->createObject( pInvokeParams[nPos] ); // default init
674 0 : ++nOutIndex;
675 : }
676 : }
677 0 : catch( CannotConvertException& rExc )
678 : {
679 0 : rExc.ArgumentIndex = nPos; // optionalen Parameter Index hinzufuegen
680 0 : throw;
681 : }
682 : }
683 :
684 : // execute Method
685 1612 : Any aRet = xMethod->invoke( _aMaterial, aInvokeParams );
686 :
687 : // OUT Params
688 804 : OutIndices.realloc( nOutIndex );
689 804 : pOutIndices = OutIndices.getArray();
690 804 : OutParams.realloc( nOutIndex );
691 804 : Any* pOutParams = OutParams.getArray();
692 :
693 1608 : while (nOutIndex--)
694 : {
695 0 : pOutParams[nOutIndex] = pInvokeParams[ pOutIndices[nOutIndex] ];
696 : }
697 :
698 1612 : return aRet;
699 : }
700 :
701 0 : RuntimeException aExc;
702 0 : aExc.Context = *this;
703 0 : aExc.Message = "invocation lacking of introspection access!";
704 0 : throw aExc;
705 : }
706 :
707 :
708 :
709 : // Struct to optimize sorting
710 0 : struct MemberItem
711 : {
712 : OUString aName;
713 :
714 : // Defines where the member comes from
715 : enum Mode { NAMEACCESS, PROPERTYSET, METHOD } eMode;
716 :
717 : // Index to respective sequence
718 : // (Index to NameAccess sequence for eMode==NAMEACCESS etc.)
719 : sal_Int32 nIndex;
720 : };
721 :
722 : // Implementation of getting name or info
723 : // String sequence will be filled when pStringSeq != NULL
724 : // Info sequence will be filled when pInfoSeq != NULL
725 0 : void Invocation_Impl::getInfoSequenceImpl
726 : (
727 : Sequence< OUString >* pStringSeq,
728 : Sequence< InvocationInfo >* pInfoSeq
729 : )
730 : {
731 : //Sequence< OUString > aStrSeq;
732 : //if( !pStringSeq )
733 : //pStringSeq = &aStrSeq;
734 :
735 :
736 : // Get all needed sequences
737 0 : Sequence<OUString> aNameAccessNames;
738 0 : Sequence<Property> aPropertySeq;
739 0 : Sequence< Reference< XIdlMethod > > aMethodSeq;
740 :
741 0 : if( _xNameAccess.is() )
742 : {
743 0 : aNameAccessNames = _xNameAccess->getElementNames();
744 : }
745 :
746 0 : if( _xIntrospectionAccess.is() )
747 : {
748 0 : aPropertySeq = _xIntrospectionAccess->getProperties
749 0 : ( PropertyConcept::ALL - PropertyConcept::DANGEROUS );
750 :
751 0 : aMethodSeq = _xIntrospectionAccess->getMethods
752 0 : ( MethodConcept::ALL - MethodConcept::DANGEROUS );
753 : }
754 :
755 0 : sal_Int32 nNameAccessCount = aNameAccessNames.getLength();
756 0 : sal_Int32 nPropertyCount = aPropertySeq.getLength();
757 0 : sal_Int32 nMethodCount = aMethodSeq.getLength();
758 0 : sal_Int32 nTotalCount = nNameAccessCount + nPropertyCount + nMethodCount;
759 :
760 : // Create and fill array of MemberItems
761 0 : boost::scoped_array< MemberItem > pItems( new MemberItem[ nTotalCount ] );
762 0 : const OUString* pStrings = aNameAccessNames.getConstArray();
763 0 : const Property* pProps = aPropertySeq.getConstArray();
764 0 : const Reference< XIdlMethod >* pMethods = aMethodSeq.getConstArray();
765 :
766 : // Fill array of MemberItems
767 0 : sal_Int32 i, iTotal = 0;
768 :
769 : // Name Access
770 0 : for( i = 0 ; i < nNameAccessCount ; i++, iTotal++ )
771 : {
772 0 : MemberItem& rItem = pItems[ iTotal ];
773 0 : rItem.aName = pStrings[ i ];
774 0 : rItem.eMode = MemberItem::NAMEACCESS;
775 0 : rItem.nIndex = i;
776 : }
777 :
778 : // Property set
779 0 : for( i = 0 ; i < nPropertyCount ; i++, iTotal++ )
780 : {
781 0 : MemberItem& rItem = pItems[ iTotal ];
782 0 : rItem.aName = pProps[ i ].Name;
783 0 : rItem.eMode = MemberItem::PROPERTYSET;
784 0 : rItem.nIndex = i;
785 : }
786 :
787 : // Methods
788 0 : for( i = 0 ; i < nMethodCount ; i++, iTotal++ )
789 : {
790 0 : MemberItem& rItem = pItems[ iTotal ];
791 0 : Reference< XIdlMethod > xMethod = pMethods[ i ];
792 0 : rItem.aName = xMethod->getName();
793 0 : rItem.eMode = MemberItem::METHOD;
794 0 : rItem.nIndex = i;
795 0 : }
796 :
797 : // Setting up result sequences
798 0 : OUString* pRetStrings = NULL;
799 0 : if( pStringSeq )
800 : {
801 0 : pStringSeq->realloc( nTotalCount );
802 0 : pRetStrings = pStringSeq->getArray();
803 : }
804 :
805 0 : InvocationInfo* pRetInfos = NULL;
806 0 : if( pInfoSeq )
807 : {
808 0 : pInfoSeq->realloc( nTotalCount );
809 0 : pRetInfos = pInfoSeq->getArray();
810 : }
811 :
812 : // Fill result sequences in the correct order of members
813 0 : for( iTotal = 0 ; iTotal < nTotalCount ; iTotal++ )
814 : {
815 0 : MemberItem& rItem = pItems[ iTotal ];
816 0 : if( pRetStrings )
817 : {
818 0 : pRetStrings[ iTotal ] = rItem.aName;
819 : }
820 :
821 0 : if( pRetInfos )
822 : {
823 0 : if( rItem.eMode == MemberItem::NAMEACCESS )
824 : {
825 0 : fillInfoForNameAccess( pRetInfos[ iTotal ], rItem.aName );
826 : }
827 0 : else if( rItem.eMode == MemberItem::PROPERTYSET )
828 : {
829 0 : fillInfoForProperty( pRetInfos[ iTotal ], pProps[ rItem.nIndex ] );
830 : }
831 0 : else if( rItem.eMode == MemberItem::METHOD )
832 : {
833 0 : fillInfoForMethod( pRetInfos[ iTotal ], pMethods[ rItem.nIndex ] );
834 : }
835 : }
836 0 : }
837 0 : }
838 :
839 : // XInvocation2
840 0 : Sequence< OUString > SAL_CALL Invocation_Impl::getMemberNames( )
841 : throw( RuntimeException, std::exception )
842 : {
843 0 : if( _xDirect2.is() )
844 : {
845 0 : return _xDirect2->getMemberNames();
846 : }
847 0 : Sequence< OUString > aRetSeq;
848 0 : getInfoSequenceImpl( &aRetSeq, NULL );
849 0 : return aRetSeq;
850 : }
851 :
852 0 : Sequence< InvocationInfo > SAL_CALL Invocation_Impl::getInfo( )
853 : throw( RuntimeException, std::exception )
854 : {
855 0 : if( _xDirect2.is() )
856 : {
857 0 : return _xDirect2->getInfo();
858 : }
859 0 : Sequence< InvocationInfo > aRetSeq;
860 0 : getInfoSequenceImpl( NULL, &aRetSeq );
861 0 : return aRetSeq;
862 : }
863 :
864 0 : InvocationInfo SAL_CALL Invocation_Impl::getInfoForName( const OUString& aName, sal_Bool bExact )
865 : throw( IllegalArgumentException, RuntimeException, std::exception )
866 : {
867 0 : if( _xDirect2.is() )
868 : {
869 0 : return _xDirect2->getInfoForName( aName, bExact );
870 : }
871 :
872 0 : bool bFound = false;
873 0 : OUString aExactName = aName;
874 0 : InvocationInfo aRetInfo;
875 :
876 0 : if( bExact )
877 0 : aExactName = getExactName( aName );
878 0 : if( !aExactName.isEmpty() )
879 : {
880 0 : if( _xIntrospectionAccess->hasMethod( aExactName, MethodConcept::ALL ^ MethodConcept::DANGEROUS ) )
881 : {
882 0 : Reference<XIdlMethod> xMethod = _xIntrospectionAccess->getMethod
883 0 : ( aExactName, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
884 0 : fillInfoForMethod( aRetInfo, xMethod );
885 0 : bFound = true;
886 : }
887 : else
888 : {
889 0 : if( _xIntrospectionAccess.is() && _xIntrospectionAccess->hasProperty
890 0 : ( aExactName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
891 : {
892 0 : Property aProp = _xIntrospectionAccess->getProperty
893 0 : ( aExactName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS );
894 0 : fillInfoForProperty( aRetInfo, aProp );
895 0 : bFound = true;
896 : }
897 : // NameAccess
898 0 : else if( _xNameAccess.is() && _xNameAccess->hasByName( aExactName ) )
899 : {
900 0 : fillInfoForNameAccess( aRetInfo, aExactName );
901 0 : bFound = true;
902 : }
903 : }
904 : }
905 0 : if( !bFound )
906 : {
907 : throw IllegalArgumentException(
908 : OUString( "Unknown name, getExactName() failed!" ),
909 0 : (XWeak *)(OWeakObject *)this, 0 );
910 : }
911 0 : return aRetInfo;
912 : }
913 :
914 : // Helper functions to fill InvocationInfo for XNameAccess
915 0 : void Invocation_Impl::fillInfoForNameAccess
916 : (
917 : InvocationInfo& rInfo,
918 : const OUString& aName
919 : )
920 : {
921 0 : rInfo.aName = aName;
922 0 : rInfo.eMemberType = MemberType_PROPERTY;
923 0 : rInfo.PropertyAttribute = 0;
924 0 : if( !_xNameContainer.is() )
925 : {
926 0 : rInfo.PropertyAttribute = PropertyAttribute::READONLY;
927 : }
928 0 : rInfo.aType = _xNameAccess->getElementType();
929 0 : }
930 :
931 0 : void Invocation_Impl::fillInfoForProperty
932 : (
933 : InvocationInfo& rInfo,
934 : const Property& rProp
935 : )
936 : {
937 0 : rInfo.aName = rProp.Name;
938 0 : rInfo.eMemberType = MemberType_PROPERTY;
939 0 : rInfo.PropertyAttribute = rProp.Attributes;
940 0 : rInfo.aType = rProp.Type;
941 0 : }
942 :
943 0 : void Invocation_Impl::fillInfoForMethod
944 : (
945 : InvocationInfo& rInfo,
946 : const Reference< XIdlMethod > xMethod
947 : )
948 : {
949 0 : rInfo.aName = xMethod->getName();
950 0 : rInfo.eMemberType = MemberType_METHOD;
951 0 : Reference< XIdlClass > xReturnClass = xMethod->getReturnType();
952 0 : Type aReturnType( xReturnClass->getTypeClass(), xReturnClass->getName() );
953 0 : rInfo.aType = aReturnType;
954 0 : Sequence<ParamInfo> aParamInfos = xMethod->getParameterInfos();
955 0 : sal_Int32 nParamCount = aParamInfos.getLength();
956 0 : if( nParamCount > 0 )
957 : {
958 0 : const ParamInfo* pInfos = aParamInfos.getConstArray();
959 :
960 0 : rInfo.aParamTypes.realloc( nParamCount );
961 0 : Type* pParamTypes = rInfo.aParamTypes.getArray();
962 0 : rInfo.aParamModes.realloc( nParamCount );
963 0 : ParamMode* pParamModes = rInfo.aParamModes.getArray();
964 :
965 0 : for( sal_Int32 i = 0 ; i < nParamCount ; i++ )
966 : {
967 0 : Reference< XIdlClass > xParamClass = pInfos[i].aType;
968 0 : Type aParamType( xParamClass->getTypeClass(), xParamClass->getName() );
969 0 : pParamTypes[ i ] = aParamType;
970 0 : pParamModes[ i ] = pInfos[i].aMode;
971 0 : }
972 0 : }
973 0 : }
974 :
975 :
976 : // XTypeProvider
977 4 : Sequence< Type > SAL_CALL Invocation_Impl::getTypes(void) throw( RuntimeException, std::exception )
978 : {
979 : static Sequence< Type > const * s_pTypes = 0;
980 4 : if (! s_pTypes)
981 : {
982 2 : Sequence< Type > types( 4 +8 );
983 2 : Type * pTypes = types.getArray();
984 2 : sal_Int32 n = 0;
985 :
986 2 : pTypes[ n++ ] = cppu::UnoType<XTypeProvider>::get();
987 2 : pTypes[ n++ ] = cppu::UnoType<XWeak>::get();
988 2 : pTypes[ n++ ] = cppu::UnoType<XInvocation>::get();
989 2 : pTypes[ n++ ] = cppu::UnoType<XMaterialHolder>::get();
990 :
991 : // Ivocation does not support XExactName, if direct object supports
992 : // XInvocation, but not XExactName.
993 6 : if ((_xDirect.is() && _xENDirect.is()) ||
994 4 : (!_xDirect.is() && (_xENIntrospection.is() || _xENNameAccess.is())))
995 : {
996 2 : pTypes[ n++ ] = cppu::UnoType<XExactName>::get();
997 : }
998 2 : if( _xNameContainer.is() )
999 : {
1000 2 : pTypes[ n++ ] = cppu::UnoType<XNameContainer>::get();
1001 : }
1002 2 : if( _xNameAccess.is() )
1003 : {
1004 2 : pTypes[ n++ ] = cppu::UnoType<XNameAccess>::get();
1005 : }
1006 2 : if (_xIndexContainer.is())
1007 : {
1008 0 : pTypes[ n++ ] = cppu::UnoType<XIndexContainer>::get();
1009 : }
1010 2 : if (_xIndexAccess.is())
1011 : {
1012 0 : pTypes[ n++ ] = cppu::UnoType<XIndexAccess>::get();
1013 : }
1014 2 : if (_xEnumerationAccess.is())
1015 : {
1016 0 : pTypes[ n++ ] = cppu::UnoType<XEnumerationAccess>::get();
1017 : }
1018 2 : if (_xElementAccess.is())
1019 : {
1020 2 : pTypes[ n++ ] = cppu::UnoType<XElementAccess>::get();
1021 : }
1022 : // Invocation does not support XInvocation2, if direct object supports
1023 : // XInvocation, but not XInvocation2.
1024 6 : if ( ( _xDirect.is() && _xDirect2.is()) ||
1025 4 : (!_xDirect.is() && _xIntrospectionAccess.is() ) )
1026 : {
1027 2 : pTypes[ n++ ] = cppu::UnoType<XInvocation2>::get();
1028 : }
1029 :
1030 2 : types.realloc( n );
1031 :
1032 : // store types
1033 4 : MutexGuard guard( Mutex::getGlobalMutex() );
1034 2 : if (! s_pTypes)
1035 : {
1036 2 : static Sequence< Type > s_types( types );
1037 2 : s_pTypes = &s_types;
1038 2 : }
1039 : }
1040 4 : return *s_pTypes;
1041 : }
1042 :
1043 0 : Sequence< sal_Int8 > SAL_CALL Invocation_Impl::getImplementationId( ) throw( RuntimeException, std::exception)
1044 : {
1045 0 : return css::uno::Sequence<sal_Int8>();
1046 : }
1047 :
1048 :
1049 :
1050 :
1051 : class InvocationService
1052 : : public WeakImplHelper2< XSingleServiceFactory, XServiceInfo >
1053 : {
1054 : public:
1055 : InvocationService( const Reference<XComponentContext> & xCtx );
1056 : virtual ~InvocationService();
1057 :
1058 : // XServiceInfo
1059 : OUString SAL_CALL getImplementationName() throw( RuntimeException, std::exception ) SAL_OVERRIDE;
1060 : sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
1061 : Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
1062 :
1063 : // XSingleServiceFactory
1064 : Reference<XInterface> SAL_CALL createInstance(void) throw( Exception, RuntimeException, std::exception ) SAL_OVERRIDE;
1065 : Reference<XInterface> SAL_CALL createInstanceWithArguments(
1066 : const Sequence<Any>& rArguments ) throw( Exception, RuntimeException, std::exception ) SAL_OVERRIDE;
1067 : private:
1068 : Reference<XComponentContext> mxCtx;
1069 : Reference<XMultiComponentFactory> mxSMgr;
1070 : Reference<XTypeConverter> xTypeConverter;
1071 : Reference<XIntrospection> xIntrospection;
1072 : Reference<XIdlReflection> xCoreReflection;
1073 : };
1074 :
1075 10 : InvocationService::InvocationService( const Reference<XComponentContext> & xCtx )
1076 : : mxCtx( xCtx )
1077 10 : , mxSMgr( xCtx->getServiceManager() )
1078 20 : , xCoreReflection( css::reflection::theCoreReflection::get(mxCtx) )
1079 : {
1080 20 : xTypeConverter = Reference<XTypeConverter>(
1081 10 : mxSMgr->createInstanceWithContext(
1082 : OUString("com.sun.star.script.Converter"),
1083 10 : xCtx ),
1084 10 : UNO_QUERY );
1085 10 : xIntrospection = theIntrospection::get(xCtx);
1086 10 : }
1087 :
1088 8 : InvocationService::~InvocationService() {}
1089 :
1090 : // XServiceInfo
1091 0 : OUString InvocationService::getImplementationName() throw( RuntimeException, std::exception )
1092 : {
1093 0 : return inv_getImplementationName();
1094 : }
1095 :
1096 : // XServiceInfo
1097 0 : sal_Bool InvocationService::supportsService(const OUString& ServiceName) throw( RuntimeException, std::exception )
1098 : {
1099 0 : return cppu::supportsService(this, ServiceName);
1100 : }
1101 :
1102 : // XServiceInfo
1103 0 : Sequence< OUString > InvocationService::getSupportedServiceNames(void) throw( RuntimeException, std::exception )
1104 : {
1105 0 : return inv_getSupportedServiceNames();
1106 : }
1107 :
1108 :
1109 0 : Reference<XInterface> InvocationService::createInstance(void) throw( Exception, RuntimeException, std::exception )
1110 : {
1111 : //TODO:throw( Exception("no default construction of invocation adapter possible!", *this) );
1112 0 : return Reference<XInterface>(); // dummy
1113 : }
1114 :
1115 :
1116 1032 : Reference<XInterface> InvocationService::createInstanceWithArguments(
1117 : const Sequence<Any>& rArguments ) throw( Exception, RuntimeException, std::exception )
1118 : {
1119 1032 : if (rArguments.getLength() == 1)
1120 : {
1121 : return Reference< XInterface >
1122 : ( *new Invocation_Impl( *rArguments.getConstArray(),
1123 1032 : xTypeConverter, xIntrospection, xCoreReflection ) );
1124 : }
1125 : else
1126 : {
1127 : //TODO:throw( Exception("no default construction of invocation adapter possible!", *this) );
1128 0 : return Reference<XInterface>();
1129 : }
1130 : }
1131 :
1132 :
1133 :
1134 10 : Reference<XInterface> SAL_CALL InvocationService_CreateInstance( const Reference<XComponentContext> & xCtx )
1135 : throw( RuntimeException )
1136 : {
1137 10 : Reference<XInterface> xService = Reference< XInterface > ( *new InvocationService( xCtx ) );
1138 10 : return xService;
1139 : }
1140 :
1141 : }
1142 :
1143 : using namespace stoc_inv;
1144 : static const struct ImplementationEntry g_entries[] =
1145 : {
1146 : {
1147 : InvocationService_CreateInstance, inv_getImplementationName,
1148 : inv_getSupportedServiceNames, createSingleComponentFactory,
1149 : 0, 0
1150 : },
1151 : { 0, 0, 0, 0, 0, 0 }
1152 : };
1153 :
1154 8 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL invocation_component_getFactory(
1155 : const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
1156 : {
1157 8 : return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries );
1158 : }
1159 :
1160 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|