Branch data 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/diagnose.h>
21 : : #include <rtl/ustrbuf.hxx>
22 : : #include <com/sun/star/beans/PropertyAttribute.hpp>
23 : : #include "com/sun/star/uno/RuntimeException.hpp"
24 : :
25 : : #include "registry/reader.hxx"
26 : : #include "registry/version.h"
27 : : #include "base.hxx"
28 : : #include "methoddescription.hxx"
29 : :
30 : : #include <memory>
31 : :
32 : : using namespace com::sun::star;
33 : : using ::rtl::OUStringBuffer;
34 : :
35 : : namespace {
36 : :
37 : : class Constructor:
38 : : public cppu::WeakImplHelper1< XServiceConstructorDescription >
39 : : {
40 : : public:
41 : 0 : Constructor(
42 : : Reference< XHierarchicalNameAccess > const & manager,
43 : : rtl::OUString const & name, Sequence< sal_Int8 > const & bytes,
44 : : sal_uInt16 index):
45 [ # # ]: 0 : m_desc(manager, name, bytes, index) {}
46 : :
47 [ # # ][ # # ]: 0 : virtual ~Constructor() {}
48 : :
49 : 0 : virtual sal_Bool SAL_CALL isDefaultConstructor() throw (RuntimeException)
50 : 0 : { return m_desc.getName().isEmpty(); }
51 : :
52 : 0 : virtual rtl::OUString SAL_CALL getName() throw (RuntimeException)
53 : 0 : { return m_desc.getName(); }
54 : :
55 : 0 : virtual Sequence< Reference< XParameter > > SAL_CALL getParameters()
56 : : throw (RuntimeException)
57 : 0 : { return m_desc.getParameters(); }
58 : :
59 : : virtual Sequence< Reference<XCompoundTypeDescription > > SAL_CALL
60 : 0 : getExceptions() throw (RuntimeException)
61 : 0 : { return m_desc.getExceptions(); }
62 : :
63 : : private:
64 : : Constructor(Constructor &); // not implemented
65 : : void operator =(Constructor); // not implemented
66 : :
67 : : stoc::registry_tdprovider::MethodDescription m_desc;
68 : : };
69 : :
70 : : }
71 : :
72 : : namespace stoc_rdbtdp
73 : : {
74 : :
75 : : //==================================================================================================
76 : : //
77 : : // class PropertyTypeDescriptionImpl
78 : : //
79 : : //==================================================================================================
80 : : class PropertyTypeDescriptionImpl : public WeakImplHelper1< XPropertyTypeDescription >
81 : : {
82 : : OUString _aName;
83 : : Reference< XTypeDescription > _xTD;
84 : : sal_Int16 _nFlags;
85 : :
86 : : public:
87 : 0 : PropertyTypeDescriptionImpl( const OUString & rName,
88 : : const Reference< XTypeDescription > & xTD,
89 : : sal_Int16 nFlags )
90 : 0 : : _aName( rName ), _xTD( xTD ), _nFlags( nFlags )
91 : : {
92 [ # # ]: 0 : g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
93 : 0 : }
94 : : virtual ~PropertyTypeDescriptionImpl();
95 : :
96 : : // XTypeDescription
97 : : virtual TypeClass SAL_CALL getTypeClass()
98 : : throw( RuntimeException );
99 : : virtual OUString SAL_CALL getName()
100 : : throw( RuntimeException );
101 : :
102 : : // XPropertyTypeDescription
103 : : virtual sal_Int16 SAL_CALL getPropertyFlags()
104 : : throw ( RuntimeException );
105 : : virtual Reference< XTypeDescription > SAL_CALL getPropertyTypeDescription()
106 : : throw ( RuntimeException );
107 : : };
108 : :
109 : : //__________________________________________________________________________________________________
110 : : // virtual
111 : 0 : PropertyTypeDescriptionImpl::~PropertyTypeDescriptionImpl()
112 : : {
113 [ # # ]: 0 : g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
114 [ # # ]: 0 : }
115 : :
116 : : // XTypeDescription
117 : : //__________________________________________________________________________________________________
118 : : // virtual
119 : 0 : TypeClass PropertyTypeDescriptionImpl::getTypeClass()
120 : : throw ( RuntimeException )
121 : : {
122 : 0 : return TypeClass_PROPERTY;
123 : : }
124 : : //__________________________________________________________________________________________________
125 : : // virtual
126 : 0 : OUString PropertyTypeDescriptionImpl::getName()
127 : : throw ( RuntimeException )
128 : : {
129 : 0 : return _aName;
130 : : }
131 : :
132 : : // XPropertyTypeDescription
133 : : //__________________________________________________________________________________________________
134 : : // virtual
135 : 0 : sal_Int16 SAL_CALL PropertyTypeDescriptionImpl::getPropertyFlags()
136 : : throw ( RuntimeException )
137 : : {
138 : 0 : return _nFlags;
139 : : }
140 : :
141 : : //__________________________________________________________________________________________________
142 : : // virtual
143 : : Reference< XTypeDescription > SAL_CALL
144 : 0 : PropertyTypeDescriptionImpl::getPropertyTypeDescription()
145 : : throw ( RuntimeException )
146 : : {
147 : 0 : return _xTD;
148 : : }
149 : :
150 : : //==================================================================================================
151 : : //
152 : : // ServiceTypeDescriptionImpl implementation
153 : : //
154 : : //==================================================================================================
155 : :
156 : : //__________________________________________________________________________________________________
157 : : // virtual
158 [ # # ][ # # ]: 0 : ServiceTypeDescriptionImpl::~ServiceTypeDescriptionImpl()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
159 : : {
160 [ # # ]: 0 : g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
161 [ # # ]: 0 : }
162 : :
163 : : // XTypeDescription
164 : : //__________________________________________________________________________________________________
165 : : // virtual
166 : 0 : TypeClass ServiceTypeDescriptionImpl::getTypeClass()
167 : : throw(::com::sun::star::uno::RuntimeException)
168 : : {
169 : 0 : return TypeClass_SERVICE;
170 : : }
171 : : //__________________________________________________________________________________________________
172 : : // virtual
173 : 0 : OUString ServiceTypeDescriptionImpl::getName()
174 : : throw(::com::sun::star::uno::RuntimeException)
175 : : {
176 : 0 : return _aName;
177 : : }
178 : :
179 : : // XServiceTypeDescription
180 : : //__________________________________________________________________________________________________
181 : : // virtual
182 : : Sequence< Reference< XServiceTypeDescription > > SAL_CALL
183 : 0 : ServiceTypeDescriptionImpl::getMandatoryServices()
184 : : throw ( RuntimeException )
185 : : {
186 : 0 : getReferences();
187 : 0 : return _aMandatoryServices;
188 : : }
189 : :
190 : : //__________________________________________________________________________________________________
191 : : // virtual
192 : : Sequence< Reference< XServiceTypeDescription > > SAL_CALL
193 : 0 : ServiceTypeDescriptionImpl::getOptionalServices()
194 : : throw ( RuntimeException )
195 : : {
196 : 0 : getReferences();
197 : 0 : return _aOptionalServices;
198 : : }
199 : :
200 : : //__________________________________________________________________________________________________
201 : : // virtual
202 : : Sequence< Reference< XInterfaceTypeDescription > > SAL_CALL
203 : 0 : ServiceTypeDescriptionImpl::getMandatoryInterfaces()
204 : : throw ( RuntimeException )
205 : : {
206 : 0 : getReferences();
207 : 0 : return _aMandatoryInterfaces;
208 : : }
209 : :
210 : : //__________________________________________________________________________________________________
211 : : // virtual
212 : : Sequence< Reference< XInterfaceTypeDescription > > SAL_CALL
213 : 0 : ServiceTypeDescriptionImpl::getOptionalInterfaces()
214 : : throw ( RuntimeException )
215 : : {
216 : 0 : getReferences();
217 : 0 : return _aOptionalInterfaces;
218 : : }
219 : :
220 : : //__________________________________________________________________________________________________
221 : : // virtual
222 : : Sequence< Reference< XPropertyTypeDescription > > SAL_CALL
223 : 0 : ServiceTypeDescriptionImpl::getProperties()
224 : : throw ( RuntimeException )
225 : : {
226 : : {
227 [ # # ][ # # ]: 0 : MutexGuard guard(getMutex());
228 [ # # ]: 0 : if (_pProps.get() != 0) {
229 [ # # ]: 0 : return *_pProps;
230 [ # # ][ # # ]: 0 : }
231 : : }
232 : :
233 : : typereg::Reader aReader(
234 [ # # ]: 0 : _aBytes.getConstArray(), _aBytes.getLength(), false, TYPEREG_VERSION_1);
235 : :
236 : 0 : sal_uInt16 nFields = (sal_uInt16)aReader.getFieldCount();
237 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
238 : : std::auto_ptr< Sequence< Reference< XPropertyTypeDescription > > >
239 : : pTempProps(
240 [ # # ]: 0 : new Sequence< Reference< XPropertyTypeDescription > >(nFields));
241 : : SAL_WNODEPRECATED_DECLARATIONS_POP
242 [ # # ]: 0 : Reference< XPropertyTypeDescription > * pProps = pTempProps->getArray();
243 : :
244 [ # # ]: 0 : while ( nFields-- )
245 : : {
246 : : // name
247 [ # # ]: 0 : OUStringBuffer aName( _aName );
248 [ # # ]: 0 : aName.appendAscii( "." );
249 [ # # ][ # # ]: 0 : aName.append( aReader.getFieldName( nFields ) );
250 : :
251 : : // type description
252 : 0 : Reference< XTypeDescription > xTD;
253 : : try
254 : : {
255 [ # # ]: 0 : _xTDMgr->getByHierarchicalName(
256 : 0 : aReader.getFieldTypeName( nFields ).replace( '/', '.' ) )
257 [ # # ][ # # ]: 0 : >>= xTD;
[ # # ][ # # ]
258 : : }
259 [ # # ]: 0 : catch ( NoSuchElementException const & )
260 : : {
261 : : }
262 : : OSL_ENSURE( xTD.is(), "### no type description for property!" );
263 : :
264 : : // flags
265 : 0 : RTFieldAccess nFlags = aReader.getFieldFlags( nFields );
266 : :
267 : 0 : sal_Int16 nAttribs = 0;
268 [ # # ]: 0 : if ( nFlags & RT_ACCESS_READONLY )
269 : 0 : nAttribs |= beans::PropertyAttribute::READONLY;
270 [ # # ]: 0 : if ( nFlags & RT_ACCESS_OPTIONAL )
271 : 0 : nAttribs |= beans::PropertyAttribute::OPTIONAL;
272 [ # # ]: 0 : if ( nFlags & RT_ACCESS_MAYBEVOID )
273 : 0 : nAttribs |= beans::PropertyAttribute::MAYBEVOID;
274 [ # # ]: 0 : if ( nFlags & RT_ACCESS_BOUND )
275 : 0 : nAttribs |= beans::PropertyAttribute::BOUND;
276 [ # # ]: 0 : if ( nFlags & RT_ACCESS_CONSTRAINED )
277 : 0 : nAttribs |= beans::PropertyAttribute::CONSTRAINED;
278 [ # # ]: 0 : if ( nFlags & RT_ACCESS_TRANSIENT )
279 : 0 : nAttribs |= beans::PropertyAttribute::TRANSIENT;
280 [ # # ]: 0 : if ( nFlags & RT_ACCESS_MAYBEAMBIGUOUS )
281 : 0 : nAttribs |= beans::PropertyAttribute::MAYBEAMBIGUOUS;
282 [ # # ]: 0 : if ( nFlags & RT_ACCESS_MAYBEDEFAULT )
283 : 0 : nAttribs |= beans::PropertyAttribute::MAYBEDEFAULT;
284 [ # # ]: 0 : if ( nFlags & RT_ACCESS_REMOVEABLE )
285 : 0 : nAttribs |= beans::PropertyAttribute::REMOVEABLE;
286 : :
287 : : OSL_ENSURE( !(nFlags & RT_ACCESS_PROPERTY),
288 : : "### RT_ACCESS_PROPERTY is unexpected here!" );
289 : : OSL_ENSURE( !(nFlags & RT_ACCESS_ATTRIBUTE),
290 : : "### RT_ACCESS_ATTRIBUTE is unexpected here!" );
291 : : OSL_ENSURE( !(nFlags & RT_ACCESS_CONST),
292 : : "### RT_ACCESS_CONST is unexpected here!" );
293 : : // always set, unless RT_ACCESS_READONLY is set.
294 : : //OSL_ENSURE( !(nFlags & RT_ACCESS_READWRITE),
295 : : // "### RT_ACCESS_READWRITE is unexpected here" );
296 : : OSL_ENSURE( !(nFlags & RT_ACCESS_DEFAULT),
297 : : "### RT_ACCESS_DEAFAULT is unexpected here" );
298 : :
299 : : pProps[ nFields ]
300 : : = new PropertyTypeDescriptionImpl( aName.makeStringAndClear(),
301 : : xTD,
302 [ # # ][ # # ]: 0 : nAttribs );
[ # # ][ # # ]
303 : 0 : }
304 : :
305 [ # # ][ # # ]: 0 : MutexGuard guard(getMutex());
306 [ # # ]: 0 : if (_pProps.get() == 0) {
307 : 0 : _pProps = pTempProps;
308 : : }
309 [ # # ][ # # ]: 0 : return *_pProps;
[ # # ]
310 : : }
311 : :
312 : 0 : sal_Bool ServiceTypeDescriptionImpl::isSingleInterfaceBased()
313 : : throw (RuntimeException)
314 : : {
315 : 0 : getReferences();
316 : 0 : return _xInterfaceTD.is();
317 : : }
318 : :
319 : 0 : Reference< XTypeDescription > ServiceTypeDescriptionImpl::getInterface()
320 : : throw (RuntimeException)
321 : : {
322 : 0 : getReferences();
323 : 0 : return _xInterfaceTD;
324 : : }
325 : :
326 : : Sequence< Reference< XServiceConstructorDescription > >
327 : 0 : ServiceTypeDescriptionImpl::getConstructors() throw (RuntimeException) {
328 [ # # ][ # # ]: 0 : MutexGuard guard(getMutex());
329 [ # # ]: 0 : if (_pCtors.get() == 0) {
330 : : typereg::Reader reader(
331 : 0 : _aBytes.getConstArray(), _aBytes.getLength(), false,
332 [ # # ]: 0 : TYPEREG_VERSION_1);
333 : 0 : sal_uInt16 ctorCount = reader.getMethodCount();
334 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
335 : : std::auto_ptr< Sequence< Reference< XServiceConstructorDescription > > >
336 : : ctors(
337 : : new Sequence< Reference< XServiceConstructorDescription > >(
338 [ # # ]: 0 : ctorCount));
339 : : SAL_WNODEPRECATED_DECLARATIONS_POP
340 [ # # ]: 0 : for (sal_uInt16 i = 0; i < ctorCount; ++i) {
341 [ # # ]: 0 : rtl::OUString name(reader.getMethodName(i));
342 [ # # # # : 0 : if (reader.getMethodFlags(i) != RT_MODE_TWOWAY
# # ][ # #
# # # # ]
[ # # ]
343 [ # # ][ # # ]: 0 : || (reader.getMethodReturnTypeName(i) != "void")
[ # # ]
344 : 0 : || (name.isEmpty()
345 : 0 : && (ctorCount != 1 || reader.getMethodParameterCount(i) != 0
346 : 0 : || reader.getMethodExceptionCount(i) != 0)))
347 : : {
348 : : throw RuntimeException(
349 : : rtl::OUString(
350 : : RTL_CONSTASCII_USTRINGPARAM(
351 : : "Service has bad constructors")),
352 [ # # ][ # # ]: 0 : static_cast< OWeakObject * >(this));
[ # # ]
353 : : }
354 [ # # ]: 0 : (*ctors)[i] = new Constructor(
355 [ # # ][ # # ]: 0 : _xTDMgr, reader.getMethodName(i), _aBytes, i);
[ # # ][ # # ]
356 : 0 : }
357 [ # # ]: 0 : _pCtors = ctors;
358 : : }
359 [ # # ][ # # ]: 0 : return *_pCtors;
360 : : }
361 : :
362 : : //__________________________________________________________________________________________________
363 : 0 : void ServiceTypeDescriptionImpl::getReferences()
364 : : throw ( RuntimeException )
365 : : {
366 : : {
367 [ # # ][ # # ]: 0 : MutexGuard guard(getMutex());
368 [ # # ]: 0 : if (_bInitReferences) {
369 : 0 : return;
370 [ # # ][ # # ]: 0 : }
371 : : }
372 : : typereg::Reader aReader(
373 [ # # ]: 0 : _aBytes.getConstArray(), _aBytes.getLength(), false, TYPEREG_VERSION_1);
374 : 0 : sal_uInt16 superTypes = aReader.getSuperTypeCount();
375 [ # # ]: 0 : if (superTypes > 1) {
376 : : throw RuntimeException(
377 : : rtl::OUString(
378 : : RTL_CONSTASCII_USTRINGPARAM(
379 : : "Service has more than one supertype")),
380 [ # # ][ # # ]: 0 : static_cast< OWeakObject * >(this));
[ # # ]
381 : : }
382 [ # # ]: 0 : if (superTypes == 1) {
383 [ # # ]: 0 : OUString aBaseName( aReader.getSuperTypeName(0).replace( '/', '.' ) );
384 [ # # ]: 0 : if ( aReader.getReferenceCount() != 0
[ # # # # ]
385 : 0 : || aReader.getFieldCount() != 0 )
386 : : throw RuntimeException(
387 : : OUString(
388 : : RTL_CONSTASCII_USTRINGPARAM(
389 : : "Service is single-interface--based but also has"
390 : : " references and/or properties" ) ),
391 [ # # ][ # # ]: 0 : static_cast< OWeakObject * >( this ) );
[ # # ]
392 : 0 : Reference< XTypeDescription > ifc;
393 : : try
394 : : {
395 [ # # ][ # # ]: 0 : _xTDMgr->getByHierarchicalName( aBaseName ) >>= ifc;
[ # # ]
396 : : }
397 [ # # ]: 0 : catch ( NoSuchElementException const & e )
398 : : {
399 : : throw RuntimeException(
400 : : OUString(
401 : : RTL_CONSTASCII_USTRINGPARAM(
402 : : "com.sun.star.container.NoSuchElementException: " ) )
403 : : + e.Message,
404 [ # # # # : 0 : static_cast< OWeakObject * >( this ) );
# # ]
405 : : }
406 : : OSL_ASSERT(ifc.is());
407 [ # # ][ # # ]: 0 : if (resolveTypedefs(ifc)->getTypeClass() != TypeClass_INTERFACE) {
[ # # ][ # # ]
408 : : throw RuntimeException(
409 : : OUString(
410 : : RTL_CONSTASCII_USTRINGPARAM(
411 : : "Single-interface--based service is not based on"
412 : : " interface type" ) ),
413 [ # # ][ # # ]: 0 : static_cast< OWeakObject * >( this ) );
[ # # ]
414 : : }
415 [ # # ][ # # ]: 0 : MutexGuard guard(getMutex());
416 [ # # ]: 0 : if (!_bInitReferences) {
417 [ # # ]: 0 : _xInterfaceTD = ifc;
418 : 0 : _bInitReferences = true;
419 [ # # ]: 0 : }
420 : : }
421 : : else
422 : : {
423 : 0 : sal_uInt16 nRefs = aReader.getReferenceCount();
424 : : Sequence< Reference< XServiceTypeDescription > > aMandatoryServices(
425 [ # # ]: 0 : nRefs);
426 : : Sequence< Reference< XServiceTypeDescription > > aOptionalServices(
427 [ # # ]: 0 : nRefs);
428 : : Sequence< Reference< XInterfaceTypeDescription > > aMandatoryInterfaces(
429 [ # # ]: 0 : nRefs);
430 : : Sequence< Reference< XInterfaceTypeDescription > > aOptionalInterfaces(
431 [ # # ]: 0 : nRefs);
432 : 0 : sal_uInt32 nMS = 0;
433 : 0 : sal_uInt32 nOS = 0;
434 : 0 : sal_uInt32 nMI = 0;
435 : 0 : sal_uInt32 nOI = 0;
436 : :
437 [ # # ]: 0 : for ( sal_uInt16 nPos = 0; nPos < nRefs; ++nPos )
438 : : {
439 : 0 : RTReferenceType eType = aReader.getReferenceSort( nPos );
440 [ # # # # ]: 0 : switch ( eType )
441 : : {
442 : : case RT_REF_EXPORTS: // service
443 : : {
444 : 0 : uno::Any aTypeDesc;
445 : : try
446 : : {
447 [ # # ]: 0 : aTypeDesc = _xTDMgr->getByHierarchicalName(
448 : : aReader.getReferenceTypeName( nPos ).replace(
449 [ # # ][ # # ]: 0 : '/', '.' ) );
450 : : }
451 [ # # ]: 0 : catch ( NoSuchElementException const & e )
452 : : {
453 : : throw RuntimeException(
454 : : OUString(
455 : : RTL_CONSTASCII_USTRINGPARAM(
456 : : "com.sun.star.container."
457 : : "NoSuchElementException: " ) )
458 : : + e.Message,
459 [ # # # # : 0 : static_cast< OWeakObject * >( this ) );
# # ]
460 : : }
461 : :
462 : 0 : RTFieldAccess nAccess = aReader.getReferenceFlags( nPos );
463 [ # # ]: 0 : if ( nAccess & RT_ACCESS_OPTIONAL )
464 : : {
465 : : // optional service
466 [ # # ][ # # ]: 0 : if ( !( aTypeDesc >>= aOptionalServices[ nOS ] ) )
[ # # ]
467 : : throw RuntimeException(
468 : : OUString(
469 : : RTL_CONSTASCII_USTRINGPARAM(
470 : : "Service 'export' is not a service" ) ),
471 [ # # ][ # # ]: 0 : static_cast< OWeakObject * >( this ) );
[ # # ]
472 : 0 : nOS++;
473 : : }
474 : : else
475 : : {
476 : : // mandatory service
477 [ # # ][ # # ]: 0 : if ( !( aTypeDesc >>= aMandatoryServices[ nMS ] ) )
[ # # ]
478 : : throw RuntimeException(
479 : : OUString(
480 : : RTL_CONSTASCII_USTRINGPARAM(
481 : : "Service 'export' is not a service" ) ),
482 [ # # ][ # # ]: 0 : static_cast< OWeakObject * >( this ) );
[ # # ]
483 : 0 : nMS++;
484 : : }
485 : 0 : break;
486 : : }
487 : : case RT_REF_SUPPORTS: // interface
488 : : {
489 : 0 : uno::Any aTypeDesc;
490 : : try
491 : : {
492 [ # # ]: 0 : aTypeDesc = _xTDMgr->getByHierarchicalName(
493 : : aReader.getReferenceTypeName( nPos ).replace(
494 [ # # ][ # # ]: 0 : '/', '.' ) );
495 : : }
496 [ # # ]: 0 : catch ( NoSuchElementException const & e )
497 : : {
498 : : throw RuntimeException(
499 : : OUString(
500 : : RTL_CONSTASCII_USTRINGPARAM(
501 : : "com.sun.star.container."
502 : : "NoSuchElementException: " ) )
503 : : + e.Message,
504 [ # # # # : 0 : static_cast< OWeakObject * >( this ) );
# # ]
505 : : }
506 : :
507 : 0 : RTFieldAccess nAccess = aReader.getReferenceFlags( nPos );
508 [ # # ]: 0 : if ( nAccess & RT_ACCESS_OPTIONAL )
509 : : {
510 : : // optional interface
511 [ # # ][ # # ]: 0 : if ( !( aTypeDesc >>= aOptionalInterfaces[ nOI ] ) )
[ # # ]
512 : : throw RuntimeException(
513 : : OUString(
514 : : RTL_CONSTASCII_USTRINGPARAM(
515 : : "Service 'supports' is not an"
516 : : " interface" ) ),
517 [ # # ][ # # ]: 0 : static_cast< OWeakObject * >( this ) );
[ # # ]
518 : 0 : nOI++;
519 : : }
520 : : else
521 : : {
522 : : // mandatory interface
523 [ # # ][ # # ]: 0 : if ( !( aTypeDesc >>= aMandatoryInterfaces[ nMI ] ) )
[ # # ]
524 : : throw RuntimeException(
525 : : OUString(
526 : : RTL_CONSTASCII_USTRINGPARAM(
527 : : "Service 'supports' is not an"
528 : : " interface" ) ),
529 [ # # ][ # # ]: 0 : static_cast< OWeakObject * >( this ) );
[ # # ]
530 : 0 : nMI++;
531 : : }
532 : 0 : break;
533 : : }
534 : : case RT_REF_OBSERVES:
535 : : case RT_REF_NEEDS:
536 : 0 : break;
537 : : default:
538 : : OSL_FAIL( "### unsupported reference type!" );
539 : 0 : break;
540 : : }
541 : : }
542 [ # # ]: 0 : aMandatoryServices.realloc( nMS );
543 [ # # ]: 0 : aOptionalServices.realloc( nOS );
544 [ # # ]: 0 : aMandatoryInterfaces.realloc( nMI );
545 [ # # ]: 0 : aOptionalInterfaces.realloc( nOI );
546 : :
547 [ # # ][ # # ]: 0 : MutexGuard guard(getMutex());
548 [ # # ]: 0 : if (!_bInitReferences) {
549 [ # # ]: 0 : _aMandatoryServices = aMandatoryServices;
550 [ # # ]: 0 : _aOptionalServices = aOptionalServices;
551 [ # # ]: 0 : _aMandatoryInterfaces = aMandatoryInterfaces;
552 [ # # ]: 0 : _aOptionalInterfaces = aOptionalInterfaces;
553 : 0 : _bInitReferences = true;
554 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ]
555 : 0 : }
556 : : }
557 : :
558 : :
559 : : }
560 : :
561 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|