Bug Summary

File:stoc/source/invocation/invocation.cxx
Location:line 942, column 19
Description:Called C++ object pointer is null

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