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 5 : static Sequence< OUString > inv_getSupportedServiceNames()
71 : {
72 5 : Sequence< OUString > seqNames(1);
73 5 : seqNames.getArray()[0] = SERVICENAME;
74 5 : return seqNames;
75 : }
76 :
77 5 : static OUString inv_getImplementationName()
78 : {
79 5 : return OUString(IMPLNAME);
80 : }
81 :
82 : // TODO: Zentral implementieren
83 909 : inline Reference<XIdlClass> TypeToIdlClass( const Type& rType, const Reference< XIdlReflection > & xRefl )
84 : {
85 909 : 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 4528 : virtual void SAL_CALL acquire() throw() SAL_OVERRIDE { OWeakObject::acquire(); }
109 4505 : 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() throw(RuntimeException, std::exception) SAL_OVERRIDE;
120 :
121 : // XInvocation
122 : virtual Reference<XIntrospectionAccess> SAL_CALL getIntrospection() 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() throw( RuntimeException, std::exception ) SAL_OVERRIDE
143 0 : { return _xElementAccess->getElementType(); }
144 :
145 0 : virtual sal_Bool SAL_CALL hasElements() 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() 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() 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() 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 : static void fillInfoForProperty( InvocationInfo& rInfo, const Property& rProp );
208 : static 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 791 : 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 791 : , xCoreReflection( rCR )
249 : {
250 791 : setMaterial( rAdapted );
251 791 : }
252 :
253 1536 : Invocation_Impl::~Invocation_Impl() {}
254 :
255 :
256 : //### INTERFACE IMPLEMENTATIONS ####################################################################
257 :
258 :
259 :
260 834 : 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 834 : (static_cast< XTypeProvider * >(this)) );
268 834 : if( a.hasValue() )
269 : {
270 38 : return a;
271 : }
272 :
273 796 : if( aType == cppu::UnoType<XExactName>::get())
274 : {
275 : // Ivocation does not support XExactName, if direct object supports
276 : // XInvocation, but not XExactName.
277 3 : if ((_xDirect.is() && _xENDirect.is()) ||
278 2 : (!_xDirect.is() && (_xENIntrospection.is() || _xENNameAccess.is())))
279 : {
280 1 : return makeAny( Reference< XExactName >( (static_cast< XExactName* >(this)) ) );
281 : }
282 : }
283 795 : 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 795 : 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 795 : 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 795 : 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 795 : 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 795 : 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 795 : else if ( aType == cppu::UnoType<XInvocation2>::get())
317 : {
318 : // Invocation does not support XInvocation2, if direct object supports
319 : // XInvocation, but not XInvocation2.
320 2370 : if ( ( _xDirect.is() && _xDirect2.is()) ||
321 1580 : (!_xDirect.is() && _xIntrospectionAccess.is() ) )
322 : {
323 790 : return makeAny( Reference< XInvocation2 >( (static_cast< XInvocation2* >(this)) ) );
324 : }
325 : }
326 :
327 5 : return OWeakObject::queryInterface( aType );
328 : }
329 :
330 :
331 :
332 34 : Any Invocation_Impl::getMaterial() 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 34 : Reference<XMaterialHolder> xMaterialHolder;
338 34 : if( _xDirect.is() )
339 : {
340 0 : xMaterialHolder = Reference<XMaterialHolder>::query( _xDirect );
341 : //_xDirect->queryInterface( XMaterialHolder::getSmartUik(), xMaterialHolder );
342 : }
343 34 : else if( _xIntrospectionAccess.is() )
344 : {
345 34 : xMaterialHolder = Reference<XMaterialHolder>::query( _xIntrospectionAccess );
346 : //_xIntrospectionAccess->queryInterface( XMaterialHolder::getSmartUik(), xMaterialHolder );
347 : }
348 34 : if( xMaterialHolder.is() )
349 : {
350 34 : return xMaterialHolder->getMaterial();
351 : }
352 0 : return _aMaterial;
353 : }
354 :
355 :
356 791 : void Invocation_Impl::setMaterial( const Any& rMaterial )
357 : {
358 : // set the material first and only once
359 791 : Reference<XInterface> xObj;
360 :
361 791 : if (rMaterial.getValueType().getTypeClass() == TypeClass_INTERFACE)
362 191 : xObj = *static_cast<Reference<XInterface> const *>(rMaterial.getValue());
363 791 : _aMaterial = rMaterial;
364 :
365 : // Ersteinmal alles ausserhalb des guards machen
366 791 : _xDirect = Reference<XInvocation>::query( xObj );
367 :
368 791 : 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 791 : if (xIntrospection.is())
388 : {
389 791 : _xIntrospectionAccess = xIntrospection->inspect( _aMaterial );
390 791 : if( _xIntrospectionAccess.is() )
391 : {
392 :
393 1582 : _xElementAccess = Reference<XElementAccess>::query(
394 791 : _xIntrospectionAccess->queryAdapter(
395 1582 : cppu::UnoType<XElementAccess>::get()) );
396 :
397 1582 : _xEnumerationAccess = Reference<XEnumerationAccess>::query(
398 791 : _xIntrospectionAccess->queryAdapter(
399 1582 : cppu::UnoType<XEnumerationAccess>::get()) );
400 :
401 1582 : _xIndexAccess = Reference<XIndexAccess>::query(
402 791 : _xIntrospectionAccess->queryAdapter(
403 1582 : cppu::UnoType<XIndexAccess>::get()) );
404 :
405 1582 : _xIndexContainer = Reference<XIndexContainer>::query(
406 791 : _xIntrospectionAccess->queryAdapter(
407 1582 : cppu::UnoType<XIndexContainer>::get()) );
408 :
409 1582 : _xNameAccess = Reference<XNameAccess>::query(
410 791 : _xIntrospectionAccess->queryAdapter(
411 1582 : cppu::UnoType<XNameAccess>::get()) );
412 :
413 1582 : _xNameContainer = Reference<XNameContainer>::query(
414 791 : _xIntrospectionAccess->queryAdapter(
415 1582 : cppu::UnoType<XNameContainer>::get()) );
416 :
417 1582 : _xPropertySet = Reference<XPropertySet>::query(
418 791 : _xIntrospectionAccess->queryAdapter(
419 1582 : cppu::UnoType<XPropertySet>::get()) );
420 :
421 791 : _xENIntrospection = Reference<XExactName>::query( _xIntrospectionAccess );
422 791 : if (_xNameAccess.is())
423 32 : _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 791 : }
441 791 : }
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()
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 998 : sal_Bool Invocation_Impl::hasMethod( const OUString& Name )
470 : throw( RuntimeException, std::exception )
471 : {
472 998 : if (_xDirect.is())
473 0 : return _xDirect->hasMethod( Name );
474 998 : if( _xIntrospectionAccess.is() )
475 998 : return _xIntrospectionAccess->hasMethod( Name, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
476 0 : return sal_False;
477 : }
478 :
479 :
480 826 : sal_Bool Invocation_Impl::hasProperty( const OUString& Name )
481 : throw( RuntimeException, std::exception )
482 : {
483 826 : if (_xDirect.is())
484 0 : return _xDirect->hasProperty( Name );
485 : // PropertySet
486 1652 : if( _xIntrospectionAccess.is()
487 826 : && _xIntrospectionAccess->hasProperty( Name, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
488 566 : return sal_True;
489 : // NameAccess
490 260 : if( _xNameAccess.is() )
491 1 : return _xNameAccess->hasByName( Name );
492 259 : return sal_False;
493 : }
494 :
495 :
496 524 : Any Invocation_Impl::getValue( const OUString& PropertyName )
497 : throw( UnknownPropertyException, RuntimeException, std::exception )
498 : {
499 524 : if (_xDirect.is())
500 0 : return _xDirect->getValue( PropertyName );
501 : try
502 : {
503 : // PropertySet
504 1572 : if( _xIntrospectionAccess.is() && _xPropertySet.is()
505 1572 : && _xIntrospectionAccess->hasProperty
506 524 : ( PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
507 : {
508 524 : 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 2 : catch (Exception &)
523 : {
524 : }
525 :
526 2 : throw UnknownPropertyException( "cannot get value " + PropertyName );
527 : }
528 :
529 :
530 174 : void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value )
531 : throw( UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException, std::exception )
532 : {
533 174 : if (_xDirect.is())
534 0 : _xDirect->setValue( PropertyName, Value );
535 : else
536 : {
537 : try
538 : {
539 : // Properties
540 522 : if( _xIntrospectionAccess.is() && _xPropertySet.is()
541 522 : && _xIntrospectionAccess->hasProperty(
542 174 : PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
543 : {
544 174 : Property aProp = _xIntrospectionAccess->getProperty(
545 174 : PropertyName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS );
546 348 : Reference < XIdlClass > r = TypeToIdlClass( aProp.Type, xCoreReflection );
547 174 : if( r->isAssignableFrom( TypeToIdlClass( Value.getValueType(), xCoreReflection ) ) )
548 142 : _xPropertySet->setPropertyValue( PropertyName, Value );
549 32 : else if( xTypeConverter.is() )
550 32 : _xPropertySet->setPropertyValue(
551 36 : PropertyName, xTypeConverter->convertTo( Value, aProp.Type ) );
552 : else
553 174 : throw RuntimeException( "no type converter service!" );
554 : }
555 : // NameContainer
556 0 : else if( _xNameContainer.is() )
557 : {
558 0 : Any aConv;
559 : Reference < XIdlClass > r =
560 0 : TypeToIdlClass( _xNameContainer->getElementType(), xCoreReflection );
561 0 : if( r->isAssignableFrom(TypeToIdlClass( Value.getValueType(), xCoreReflection ) ) )
562 0 : aConv = Value;
563 0 : else if( xTypeConverter.is() )
564 0 : aConv = xTypeConverter->convertTo( Value, _xNameContainer->getElementType() );
565 : else
566 0 : throw RuntimeException( "no type converter service!" );
567 :
568 : // bei Vorhandensein ersetzen, ansonsten einfuegen
569 0 : if (_xNameContainer->hasByName( PropertyName ))
570 0 : _xNameContainer->replaceByName( PropertyName, aConv );
571 : else
572 0 : _xNameContainer->insertByName( PropertyName, aConv );
573 : }
574 : else
575 0 : throw UnknownPropertyException( "no introspection nor name container!" );
576 : }
577 0 : catch (UnknownPropertyException &)
578 : {
579 0 : throw;
580 : }
581 0 : catch (CannotConvertException &)
582 : {
583 0 : throw;
584 : }
585 8 : catch (InvocationTargetException &)
586 : {
587 4 : throw;
588 : }
589 0 : catch (RuntimeException &)
590 : {
591 0 : throw;
592 : }
593 0 : catch (const Exception & exc)
594 : {
595 : throw InvocationTargetException(
596 0 : "exception occurred in setValue(): " + exc.Message,
597 0 : Reference< XInterface >(), makeAny( exc /* though sliced */ ) );
598 : }
599 : }
600 170 : }
601 :
602 :
603 474 : Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>& InParams,
604 : Sequence<sal_Int16>& OutIndices, Sequence<Any>& OutParams )
605 : throw( IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException, std::exception )
606 : {
607 474 : if (_xDirect.is())
608 0 : return _xDirect->invoke( FunctionName, InParams, OutIndices, OutParams );
609 :
610 474 : if (_xIntrospectionAccess.is())
611 : {
612 : // throw NoSuchMethodException if not exist
613 474 : Reference<XIdlMethod> xMethod = _xIntrospectionAccess->getMethod(
614 474 : FunctionName, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
615 :
616 : // ParameterInfos
617 948 : Sequence<ParamInfo> aFParams = xMethod->getParameterInfos();
618 474 : const ParamInfo* pFParams = aFParams.getConstArray();
619 474 : sal_Int32 nFParamsLen = aFParams.getLength();
620 474 : if (nFParamsLen != InParams.getLength())
621 : {
622 : throw IllegalArgumentException(
623 0 : "incorrect number of parameters passed invoking function " + FunctionName,
624 0 : static_cast<OWeakObject *>(this), (sal_Int16) 1 );
625 : }
626 :
627 : // IN Parameter
628 474 : const Any* pInParams = InParams.getConstArray();
629 :
630 : // Introspection Invoke Parameter
631 948 : Sequence<Any> aInvokeParams( nFParamsLen );
632 474 : Any* pInvokeParams = aInvokeParams.getArray();
633 :
634 : // OUT Indices
635 474 : OutIndices.realloc( nFParamsLen );
636 474 : sal_Int16* pOutIndices = OutIndices.getArray();
637 474 : sal_uInt32 nOutIndex = 0;
638 :
639 1035 : for ( sal_Int32 nPos = 0; nPos < nFParamsLen; ++nPos )
640 : {
641 : try
642 : {
643 561 : const ParamInfo& rFParam = pFParams[nPos];
644 561 : const Reference<XIdlClass>& rDestType = rFParam.aType;
645 :
646 : // is IN/INOUT parameter?
647 561 : if (rFParam.aMode != ParamMode_OUT)
648 : {
649 561 : if (rDestType->isAssignableFrom( TypeToIdlClass( pInParams[nPos].getValueType(), xCoreReflection ) ))
650 : {
651 539 : pInvokeParams[nPos] = pInParams[nPos];
652 : }
653 22 : else if (xTypeConverter.is())
654 : {
655 22 : Type aDestType( rDestType->getTypeClass(), rDestType->getName() );
656 22 : pInvokeParams[nPos] = xTypeConverter->convertTo( pInParams[nPos], aDestType );
657 : }
658 : else
659 : {
660 0 : CannotConvertException aExc;
661 0 : aExc.Context = *this;
662 0 : aExc.Message = "invocation type mismatch!";
663 0 : throw aExc;
664 : }
665 : }
666 :
667 : // is OUT/INOUT parameter?
668 561 : if (rFParam.aMode != ParamMode_IN)
669 : {
670 0 : pOutIndices[nOutIndex] = (sal_Int16)nPos;
671 0 : if (rFParam.aMode == ParamMode_OUT)
672 0 : rDestType->createObject( pInvokeParams[nPos] ); // default init
673 0 : ++nOutIndex;
674 : }
675 : }
676 0 : catch( CannotConvertException& rExc )
677 : {
678 0 : rExc.ArgumentIndex = nPos; // optionalen Parameter Index hinzufuegen
679 0 : throw;
680 : }
681 : }
682 :
683 : // execute Method
684 946 : Any aRet = xMethod->invoke( _aMaterial, aInvokeParams );
685 :
686 : // OUT Params
687 472 : OutIndices.realloc( nOutIndex );
688 472 : pOutIndices = OutIndices.getArray();
689 472 : OutParams.realloc( nOutIndex );
690 472 : Any* pOutParams = OutParams.getArray();
691 :
692 944 : while (nOutIndex--)
693 : {
694 0 : pOutParams[nOutIndex] = pInvokeParams[ pOutIndices[nOutIndex] ];
695 : }
696 :
697 946 : return aRet;
698 : }
699 :
700 0 : RuntimeException aExc;
701 0 : aExc.Context = *this;
702 0 : aExc.Message = "invocation lacking of introspection access!";
703 0 : throw aExc;
704 : }
705 :
706 :
707 :
708 : // Struct to optimize sorting
709 0 : struct MemberItem
710 : {
711 : OUString aName;
712 :
713 : // Defines where the member comes from
714 : enum Mode { NAMEACCESS, PROPERTYSET, METHOD } eMode;
715 :
716 : // Index to respective sequence
717 : // (Index to NameAccess sequence for eMode==NAMEACCESS etc.)
718 : sal_Int32 nIndex;
719 : };
720 :
721 : // Implementation of getting name or info
722 : // String sequence will be filled when pStringSeq != NULL
723 : // Info sequence will be filled when pInfoSeq != NULL
724 0 : void Invocation_Impl::getInfoSequenceImpl
725 : (
726 : Sequence< OUString >* pStringSeq,
727 : Sequence< InvocationInfo >* pInfoSeq
728 : )
729 : {
730 : //Sequence< OUString > aStrSeq;
731 : //if( !pStringSeq )
732 : //pStringSeq = &aStrSeq;
733 :
734 :
735 : // Get all needed sequences
736 0 : Sequence<OUString> aNameAccessNames;
737 0 : Sequence<Property> aPropertySeq;
738 0 : Sequence< Reference< XIdlMethod > > aMethodSeq;
739 :
740 0 : if( _xNameAccess.is() )
741 : {
742 0 : aNameAccessNames = _xNameAccess->getElementNames();
743 : }
744 :
745 0 : if( _xIntrospectionAccess.is() )
746 : {
747 0 : aPropertySeq = _xIntrospectionAccess->getProperties
748 0 : ( PropertyConcept::ALL - PropertyConcept::DANGEROUS );
749 :
750 0 : aMethodSeq = _xIntrospectionAccess->getMethods
751 0 : ( MethodConcept::ALL - MethodConcept::DANGEROUS );
752 : }
753 :
754 0 : sal_Int32 nNameAccessCount = aNameAccessNames.getLength();
755 0 : sal_Int32 nPropertyCount = aPropertySeq.getLength();
756 0 : sal_Int32 nMethodCount = aMethodSeq.getLength();
757 0 : sal_Int32 nTotalCount = nNameAccessCount + nPropertyCount + nMethodCount;
758 :
759 : // Create and fill array of MemberItems
760 0 : boost::scoped_array< MemberItem > pItems( new MemberItem[ nTotalCount ] );
761 0 : const OUString* pStrings = aNameAccessNames.getConstArray();
762 0 : const Property* pProps = aPropertySeq.getConstArray();
763 0 : const Reference< XIdlMethod >* pMethods = aMethodSeq.getConstArray();
764 :
765 : // Fill array of MemberItems
766 0 : sal_Int32 i, iTotal = 0;
767 :
768 : // Name Access
769 0 : for( i = 0 ; i < nNameAccessCount ; i++, iTotal++ )
770 : {
771 0 : MemberItem& rItem = pItems[ iTotal ];
772 0 : rItem.aName = pStrings[ i ];
773 0 : rItem.eMode = MemberItem::NAMEACCESS;
774 0 : rItem.nIndex = i;
775 : }
776 :
777 : // Property set
778 0 : for( i = 0 ; i < nPropertyCount ; i++, iTotal++ )
779 : {
780 0 : MemberItem& rItem = pItems[ iTotal ];
781 0 : rItem.aName = pProps[ i ].Name;
782 0 : rItem.eMode = MemberItem::PROPERTYSET;
783 0 : rItem.nIndex = i;
784 : }
785 :
786 : // Methods
787 0 : for( i = 0 ; i < nMethodCount ; i++, iTotal++ )
788 : {
789 0 : MemberItem& rItem = pItems[ iTotal ];
790 0 : Reference< XIdlMethod > xMethod = pMethods[ i ];
791 0 : rItem.aName = xMethod->getName();
792 0 : rItem.eMode = MemberItem::METHOD;
793 0 : rItem.nIndex = i;
794 0 : }
795 :
796 : // Setting up result sequences
797 0 : OUString* pRetStrings = NULL;
798 0 : if( pStringSeq )
799 : {
800 0 : pStringSeq->realloc( nTotalCount );
801 0 : pRetStrings = pStringSeq->getArray();
802 : }
803 :
804 0 : InvocationInfo* pRetInfos = NULL;
805 0 : if( pInfoSeq )
806 : {
807 0 : pInfoSeq->realloc( nTotalCount );
808 0 : pRetInfos = pInfoSeq->getArray();
809 : }
810 :
811 : // Fill result sequences in the correct order of members
812 0 : for( iTotal = 0 ; iTotal < nTotalCount ; iTotal++ )
813 : {
814 0 : MemberItem& rItem = pItems[ iTotal ];
815 0 : if( pRetStrings )
816 : {
817 0 : pRetStrings[ iTotal ] = rItem.aName;
818 : }
819 :
820 0 : if( pRetInfos )
821 : {
822 0 : if( rItem.eMode == MemberItem::NAMEACCESS )
823 : {
824 0 : fillInfoForNameAccess( pRetInfos[ iTotal ], rItem.aName );
825 : }
826 0 : else if( rItem.eMode == MemberItem::PROPERTYSET )
827 : {
828 0 : fillInfoForProperty( pRetInfos[ iTotal ], pProps[ rItem.nIndex ] );
829 : }
830 0 : else if( rItem.eMode == MemberItem::METHOD )
831 : {
832 0 : fillInfoForMethod( pRetInfos[ iTotal ], pMethods[ rItem.nIndex ] );
833 : }
834 : }
835 0 : }
836 0 : }
837 :
838 : // XInvocation2
839 0 : Sequence< OUString > SAL_CALL Invocation_Impl::getMemberNames( )
840 : throw( RuntimeException, std::exception )
841 : {
842 0 : if( _xDirect2.is() )
843 : {
844 0 : return _xDirect2->getMemberNames();
845 : }
846 0 : Sequence< OUString > aRetSeq;
847 0 : getInfoSequenceImpl( &aRetSeq, NULL );
848 0 : return aRetSeq;
849 : }
850 :
851 0 : Sequence< InvocationInfo > SAL_CALL Invocation_Impl::getInfo( )
852 : throw( RuntimeException, std::exception )
853 : {
854 0 : if( _xDirect2.is() )
855 : {
856 0 : return _xDirect2->getInfo();
857 : }
858 0 : Sequence< InvocationInfo > aRetSeq;
859 0 : getInfoSequenceImpl( NULL, &aRetSeq );
860 0 : return aRetSeq;
861 : }
862 :
863 0 : InvocationInfo SAL_CALL Invocation_Impl::getInfoForName( const OUString& aName, sal_Bool bExact )
864 : throw( IllegalArgumentException, RuntimeException, std::exception )
865 : {
866 0 : if( _xDirect2.is() )
867 : {
868 0 : return _xDirect2->getInfoForName( aName, bExact );
869 : }
870 :
871 0 : bool bFound = false;
872 0 : OUString aExactName = aName;
873 0 : InvocationInfo aRetInfo;
874 :
875 0 : if( bExact )
876 0 : aExactName = getExactName( aName );
877 0 : if( !aExactName.isEmpty() )
878 : {
879 0 : if( _xIntrospectionAccess->hasMethod( aExactName, MethodConcept::ALL ^ MethodConcept::DANGEROUS ) )
880 : {
881 0 : Reference<XIdlMethod> xMethod = _xIntrospectionAccess->getMethod
882 0 : ( aExactName, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
883 0 : fillInfoForMethod( aRetInfo, xMethod );
884 0 : bFound = true;
885 : }
886 : else
887 : {
888 0 : if( _xIntrospectionAccess.is() && _xIntrospectionAccess->hasProperty
889 0 : ( aExactName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS ) )
890 : {
891 0 : Property aProp = _xIntrospectionAccess->getProperty
892 0 : ( aExactName, PropertyConcept::ALL ^ PropertyConcept::DANGEROUS );
893 0 : fillInfoForProperty( aRetInfo, aProp );
894 0 : bFound = true;
895 : }
896 : // NameAccess
897 0 : else if( _xNameAccess.is() && _xNameAccess->hasByName( aExactName ) )
898 : {
899 0 : fillInfoForNameAccess( aRetInfo, aExactName );
900 0 : bFound = true;
901 : }
902 : }
903 : }
904 0 : if( !bFound )
905 : {
906 : throw IllegalArgumentException(
907 : OUString( "Unknown name, getExactName() failed!" ),
908 0 : static_cast<XWeak *>(static_cast<OWeakObject *>(this)), 0 );
909 : }
910 0 : return aRetInfo;
911 : }
912 :
913 : // Helper functions to fill InvocationInfo for XNameAccess
914 0 : void Invocation_Impl::fillInfoForNameAccess
915 : (
916 : InvocationInfo& rInfo,
917 : const OUString& aName
918 : )
919 : {
920 0 : rInfo.aName = aName;
921 0 : rInfo.eMemberType = MemberType_PROPERTY;
922 0 : rInfo.PropertyAttribute = 0;
923 0 : if( !_xNameContainer.is() )
924 : {
925 0 : rInfo.PropertyAttribute = PropertyAttribute::READONLY;
926 : }
927 0 : rInfo.aType = _xNameAccess->getElementType();
928 0 : }
929 :
930 0 : void Invocation_Impl::fillInfoForProperty
931 : (
932 : InvocationInfo& rInfo,
933 : const Property& rProp
934 : )
935 : {
936 0 : rInfo.aName = rProp.Name;
937 0 : rInfo.eMemberType = MemberType_PROPERTY;
938 0 : rInfo.PropertyAttribute = rProp.Attributes;
939 0 : rInfo.aType = rProp.Type;
940 0 : }
941 :
942 0 : void Invocation_Impl::fillInfoForMethod
943 : (
944 : InvocationInfo& rInfo,
945 : const Reference< XIdlMethod > xMethod
946 : )
947 : {
948 0 : rInfo.aName = xMethod->getName();
949 0 : rInfo.eMemberType = MemberType_METHOD;
950 0 : Reference< XIdlClass > xReturnClass = xMethod->getReturnType();
951 0 : Type aReturnType( xReturnClass->getTypeClass(), xReturnClass->getName() );
952 0 : rInfo.aType = aReturnType;
953 0 : Sequence<ParamInfo> aParamInfos = xMethod->getParameterInfos();
954 0 : sal_Int32 nParamCount = aParamInfos.getLength();
955 0 : if( nParamCount > 0 )
956 : {
957 0 : const ParamInfo* pInfos = aParamInfos.getConstArray();
958 :
959 0 : rInfo.aParamTypes.realloc( nParamCount );
960 0 : Type* pParamTypes = rInfo.aParamTypes.getArray();
961 0 : rInfo.aParamModes.realloc( nParamCount );
962 0 : ParamMode* pParamModes = rInfo.aParamModes.getArray();
963 :
964 0 : for( sal_Int32 i = 0 ; i < nParamCount ; i++ )
965 : {
966 0 : Reference< XIdlClass > xParamClass = pInfos[i].aType;
967 0 : Type aParamType( xParamClass->getTypeClass(), xParamClass->getName() );
968 0 : pParamTypes[ i ] = aParamType;
969 0 : pParamModes[ i ] = pInfos[i].aMode;
970 0 : }
971 0 : }
972 0 : }
973 :
974 :
975 : // XTypeProvider
976 2 : Sequence< Type > SAL_CALL Invocation_Impl::getTypes() throw( RuntimeException, std::exception )
977 : {
978 : static Sequence< Type > const * s_pTypes = 0;
979 2 : if (! s_pTypes)
980 : {
981 1 : Sequence< Type > types( 4 +8 );
982 1 : Type * pTypes = types.getArray();
983 1 : sal_Int32 n = 0;
984 :
985 1 : pTypes[ n++ ] = cppu::UnoType<XTypeProvider>::get();
986 1 : pTypes[ n++ ] = cppu::UnoType<XWeak>::get();
987 1 : pTypes[ n++ ] = cppu::UnoType<XInvocation>::get();
988 1 : pTypes[ n++ ] = cppu::UnoType<XMaterialHolder>::get();
989 :
990 : // Ivocation does not support XExactName, if direct object supports
991 : // XInvocation, but not XExactName.
992 3 : if ((_xDirect.is() && _xENDirect.is()) ||
993 2 : (!_xDirect.is() && (_xENIntrospection.is() || _xENNameAccess.is())))
994 : {
995 1 : pTypes[ n++ ] = cppu::UnoType<XExactName>::get();
996 : }
997 1 : if( _xNameContainer.is() )
998 : {
999 1 : pTypes[ n++ ] = cppu::UnoType<XNameContainer>::get();
1000 : }
1001 1 : if( _xNameAccess.is() )
1002 : {
1003 1 : pTypes[ n++ ] = cppu::UnoType<XNameAccess>::get();
1004 : }
1005 1 : if (_xIndexContainer.is())
1006 : {
1007 0 : pTypes[ n++ ] = cppu::UnoType<XIndexContainer>::get();
1008 : }
1009 1 : if (_xIndexAccess.is())
1010 : {
1011 0 : pTypes[ n++ ] = cppu::UnoType<XIndexAccess>::get();
1012 : }
1013 1 : if (_xEnumerationAccess.is())
1014 : {
1015 0 : pTypes[ n++ ] = cppu::UnoType<XEnumerationAccess>::get();
1016 : }
1017 1 : if (_xElementAccess.is())
1018 : {
1019 1 : pTypes[ n++ ] = cppu::UnoType<XElementAccess>::get();
1020 : }
1021 : // Invocation does not support XInvocation2, if direct object supports
1022 : // XInvocation, but not XInvocation2.
1023 3 : if ( ( _xDirect.is() && _xDirect2.is()) ||
1024 2 : (!_xDirect.is() && _xIntrospectionAccess.is() ) )
1025 : {
1026 1 : pTypes[ n++ ] = cppu::UnoType<XInvocation2>::get();
1027 : }
1028 :
1029 1 : types.realloc( n );
1030 :
1031 : // store types
1032 2 : MutexGuard guard( Mutex::getGlobalMutex() );
1033 1 : if (! s_pTypes)
1034 : {
1035 1 : static Sequence< Type > s_types( types );
1036 1 : s_pTypes = &s_types;
1037 1 : }
1038 : }
1039 2 : return *s_pTypes;
1040 : }
1041 :
1042 0 : Sequence< sal_Int8 > SAL_CALL Invocation_Impl::getImplementationId( ) throw( RuntimeException, std::exception)
1043 : {
1044 0 : return css::uno::Sequence<sal_Int8>();
1045 : }
1046 :
1047 :
1048 :
1049 :
1050 : class InvocationService
1051 : : public WeakImplHelper2< XSingleServiceFactory, XServiceInfo >
1052 : {
1053 : public:
1054 : InvocationService( const Reference<XComponentContext> & xCtx );
1055 : virtual ~InvocationService();
1056 :
1057 : // XServiceInfo
1058 : OUString SAL_CALL getImplementationName() throw( RuntimeException, std::exception ) SAL_OVERRIDE;
1059 : sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( RuntimeException, std::exception ) SAL_OVERRIDE;
1060 : Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( RuntimeException, std::exception ) SAL_OVERRIDE;
1061 :
1062 : // XSingleServiceFactory
1063 : Reference<XInterface> SAL_CALL createInstance() throw( Exception, RuntimeException, std::exception ) SAL_OVERRIDE;
1064 : Reference<XInterface> SAL_CALL createInstanceWithArguments(
1065 : const Sequence<Any>& rArguments ) throw( Exception, RuntimeException, std::exception ) SAL_OVERRIDE;
1066 : private:
1067 : Reference<XComponentContext> mxCtx;
1068 : Reference<XMultiComponentFactory> mxSMgr;
1069 : Reference<XTypeConverter> xTypeConverter;
1070 : Reference<XIntrospection> xIntrospection;
1071 : Reference<XIdlReflection> xCoreReflection;
1072 : };
1073 :
1074 5 : InvocationService::InvocationService( const Reference<XComponentContext> & xCtx )
1075 : : mxCtx( xCtx )
1076 5 : , mxSMgr( xCtx->getServiceManager() )
1077 10 : , xCoreReflection( css::reflection::theCoreReflection::get(mxCtx) )
1078 : {
1079 10 : xTypeConverter = Reference<XTypeConverter>(
1080 5 : mxSMgr->createInstanceWithContext(
1081 : OUString("com.sun.star.script.Converter"),
1082 5 : xCtx ),
1083 5 : UNO_QUERY );
1084 5 : xIntrospection = theIntrospection::get(xCtx);
1085 5 : }
1086 :
1087 4 : InvocationService::~InvocationService() {}
1088 :
1089 : // XServiceInfo
1090 1 : OUString InvocationService::getImplementationName() throw( RuntimeException, std::exception )
1091 : {
1092 1 : return inv_getImplementationName();
1093 : }
1094 :
1095 : // XServiceInfo
1096 0 : sal_Bool InvocationService::supportsService(const OUString& ServiceName) throw( RuntimeException, std::exception )
1097 : {
1098 0 : return cppu::supportsService(this, ServiceName);
1099 : }
1100 :
1101 : // XServiceInfo
1102 1 : Sequence< OUString > InvocationService::getSupportedServiceNames() throw( RuntimeException, std::exception )
1103 : {
1104 1 : return inv_getSupportedServiceNames();
1105 : }
1106 :
1107 :
1108 0 : Reference<XInterface> InvocationService::createInstance() throw( Exception, RuntimeException, std::exception )
1109 : {
1110 : //TODO:throw( Exception("no default construction of invocation adapter possible!", *this) );
1111 0 : return Reference<XInterface>(); // dummy
1112 : }
1113 :
1114 :
1115 791 : Reference<XInterface> InvocationService::createInstanceWithArguments(
1116 : const Sequence<Any>& rArguments ) throw( Exception, RuntimeException, std::exception )
1117 : {
1118 791 : if (rArguments.getLength() == 1)
1119 : {
1120 : return Reference< XInterface >
1121 : ( *new Invocation_Impl( *rArguments.getConstArray(),
1122 791 : xTypeConverter, xIntrospection, xCoreReflection ) );
1123 : }
1124 : else
1125 : {
1126 : //TODO:throw( Exception("no default construction of invocation adapter possible!", *this) );
1127 0 : return Reference<XInterface>();
1128 : }
1129 : }
1130 :
1131 :
1132 :
1133 5 : Reference<XInterface> SAL_CALL InvocationService_CreateInstance( const Reference<XComponentContext> & xCtx )
1134 : throw( RuntimeException )
1135 : {
1136 5 : Reference<XInterface> xService = Reference< XInterface > ( *new InvocationService( xCtx ) );
1137 5 : return xService;
1138 : }
1139 :
1140 : }
1141 :
1142 : using namespace stoc_inv;
1143 : static const struct ImplementationEntry g_entries[] =
1144 : {
1145 : {
1146 : InvocationService_CreateInstance, inv_getImplementationName,
1147 : inv_getSupportedServiceNames, createSingleComponentFactory,
1148 : 0, 0
1149 : },
1150 : { 0, 0, 0, 0, 0, 0 }
1151 : };
1152 :
1153 4 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL invocation_component_getFactory(
1154 : const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
1155 : {
1156 4 : return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries );
1157 : }
1158 :
1159 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|