1*9d7e27acSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*9d7e27acSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*9d7e27acSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*9d7e27acSAndrew Rist * distributed with this work for additional information
6*9d7e27acSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*9d7e27acSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*9d7e27acSAndrew Rist * "License"); you may not use this file except in compliance
9*9d7e27acSAndrew Rist * with the License. You may obtain a copy of the License at
10*9d7e27acSAndrew Rist *
11*9d7e27acSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*9d7e27acSAndrew Rist *
13*9d7e27acSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*9d7e27acSAndrew Rist * software distributed under the License is distributed on an
15*9d7e27acSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9d7e27acSAndrew Rist * KIND, either express or implied. See the License for the
17*9d7e27acSAndrew Rist * specific language governing permissions and limitations
18*9d7e27acSAndrew Rist * under the License.
19*9d7e27acSAndrew Rist *
20*9d7e27acSAndrew Rist *************************************************************/
21*9d7e27acSAndrew Rist
22*9d7e27acSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cppuhelper.hxx"
26cdf0e10cSrcweir #include <sal/alloca.h>
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <string.h>
29cdf0e10cSrcweir #include <osl/diagnose.h>
30cdf0e10cSrcweir #include <rtl/byteseq.hxx>
31cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
32cdf0e10cSrcweir #include <rtl/uuid.h>
33cdf0e10cSrcweir #include <cppuhelper/compbase_ex.hxx>
34cdf0e10cSrcweir
35cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp"
36cdf0e10cSrcweir
37cdf0e10cSrcweir using namespace ::cppu;
38cdf0e10cSrcweir using namespace ::osl;
39cdf0e10cSrcweir using namespace ::rtl;
40cdf0e10cSrcweir using namespace ::com::sun::star;
41cdf0e10cSrcweir using namespace ::com::sun::star::uno;
42cdf0e10cSrcweir
43cdf0e10cSrcweir namespace cppu
44cdf0e10cSrcweir {
45cdf0e10cSrcweir
46cdf0e10cSrcweir /** Shared mutex for implementation helper initialization.
47cdf0e10cSrcweir Not for public use.
48cdf0e10cSrcweir */
49cdf0e10cSrcweir ::osl::Mutex & SAL_CALL getImplHelperInitMutex(void) SAL_THROW( () );
50cdf0e10cSrcweir
51cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
checkInterface(Type const & rType)52cdf0e10cSrcweir static inline void checkInterface( Type const & rType )
53cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
54cdf0e10cSrcweir {
55cdf0e10cSrcweir if (TypeClass_INTERFACE != rType.getTypeClass())
56cdf0e10cSrcweir {
57cdf0e10cSrcweir OUStringBuffer buf( 64 );
58cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("querying for interface \"") );
59cdf0e10cSrcweir buf.append( rType.getTypeName() );
60cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\": no interface type!") );
61cdf0e10cSrcweir OUString msg( buf.makeStringAndClear() );
62cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
63cdf0e10cSrcweir OString str( OUStringToOString( msg, RTL_TEXTENCODING_ASCII_US ) );
64cdf0e10cSrcweir OSL_ENSURE( 0, str.getStr() );
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir throw RuntimeException( msg, Reference< XInterface >() );
67cdf0e10cSrcweir }
68cdf0e10cSrcweir }
69cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
isXInterface(rtl_uString * pStr)70cdf0e10cSrcweir static inline bool isXInterface( rtl_uString * pStr ) SAL_THROW( () )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir return (((OUString const *)&pStr)->equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.XInterface") ) != sal_False);
73cdf0e10cSrcweir }
74cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
makeInterface(sal_IntPtr nOffset,void * that)75cdf0e10cSrcweir static inline void * makeInterface( sal_IntPtr nOffset, void * that ) SAL_THROW( () )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir return (((char *)that) + nOffset);
78cdf0e10cSrcweir }
79cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
__td_equals(typelib_TypeDescriptionReference const * pTDR1,typelib_TypeDescriptionReference const * pTDR2)80cdf0e10cSrcweir static inline bool __td_equals(
81cdf0e10cSrcweir typelib_TypeDescriptionReference const * pTDR1,
82cdf0e10cSrcweir typelib_TypeDescriptionReference const * pTDR2 )
83cdf0e10cSrcweir SAL_THROW( () )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir return ((pTDR1 == pTDR2) ||
86cdf0e10cSrcweir ((OUString const *)&pTDR1->pTypeName)->equals( *(OUString const *)&pTDR2->pTypeName ) != sal_False);
87cdf0e10cSrcweir }
88cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
__getTypeEntries(class_data * cd)89cdf0e10cSrcweir static inline type_entry * __getTypeEntries( class_data * cd )
90cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir type_entry * pEntries = cd->m_typeEntries;
93cdf0e10cSrcweir if (! cd->m_storedTypeRefs) // not inited?
94cdf0e10cSrcweir {
95cdf0e10cSrcweir MutexGuard guard( getImplHelperInitMutex() );
96cdf0e10cSrcweir if (! cd->m_storedTypeRefs) // not inited?
97cdf0e10cSrcweir {
98cdf0e10cSrcweir // get all types
99cdf0e10cSrcweir for ( sal_Int32 n = cd->m_nTypes; n--; )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir type_entry * pEntry = &pEntries[ n ];
102cdf0e10cSrcweir Type const & rType = (*pEntry->m_type.getCppuType)( 0 );
103cdf0e10cSrcweir OSL_ENSURE( rType.getTypeClass() == TypeClass_INTERFACE, "### wrong helper init: expected interface!" );
104cdf0e10cSrcweir OSL_ENSURE( ! isXInterface( rType.getTypeLibType()->pTypeName ), "### want to implement XInterface: template argument is XInterface?!?!?!" );
105cdf0e10cSrcweir if (rType.getTypeClass() != TypeClass_INTERFACE)
106cdf0e10cSrcweir {
107cdf0e10cSrcweir OUStringBuffer buf( 48 );
108cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("type \"") );
109cdf0e10cSrcweir buf.append( rType.getTypeName() );
110cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\" is no interface type!") );
111cdf0e10cSrcweir OUString msg( buf.makeStringAndClear() );
112cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
113cdf0e10cSrcweir OString str( OUStringToOString( msg, RTL_TEXTENCODING_ASCII_US ) );
114cdf0e10cSrcweir OSL_ENSURE( 0, str.getStr() );
115cdf0e10cSrcweir #endif
116cdf0e10cSrcweir throw RuntimeException( msg, Reference< XInterface >() );
117cdf0e10cSrcweir }
118cdf0e10cSrcweir // ref is statically held by getCppuType()
119cdf0e10cSrcweir pEntry->m_type.typeRef = rType.getTypeLibType();
120cdf0e10cSrcweir }
121cdf0e10cSrcweir cd->m_storedTypeRefs = sal_True;
122cdf0e10cSrcweir }
123cdf0e10cSrcweir }
124cdf0e10cSrcweir return pEntries;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
__fillTypes(Type * types,class_data * cd)127cdf0e10cSrcweir static inline void __fillTypes( Type * types, class_data * cd )
128cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir type_entry * pEntries = __getTypeEntries( cd );
131cdf0e10cSrcweir for ( sal_Int32 n = cd->m_nTypes; n--; )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir types[ n ] = pEntries[ n ].m_type.typeRef;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir }
136cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
137cdf0e10cSrcweir namespace {
138cdf0e10cSrcweir
recursivelyFindType(typelib_TypeDescriptionReference const * demandedType,typelib_InterfaceTypeDescription const * type,sal_IntPtr * offset)139cdf0e10cSrcweir bool recursivelyFindType(
140cdf0e10cSrcweir typelib_TypeDescriptionReference const * demandedType,
141cdf0e10cSrcweir typelib_InterfaceTypeDescription const * type, sal_IntPtr * offset)
142cdf0e10cSrcweir {
143cdf0e10cSrcweir // This code assumes that the vtables of a multiple-inheritance class (the
144cdf0e10cSrcweir // offset amount by which to adjust the this pointer) follow one another in
145cdf0e10cSrcweir // the object layout, and that they contain slots for the inherited classes
146cdf0e10cSrcweir // in a specifc order. In theory, that need not hold for any given
147cdf0e10cSrcweir // platform; in practice, it seems to work well on all supported platforms:
148cdf0e10cSrcweir next:
149cdf0e10cSrcweir for (sal_Int32 i = 0; i < type->nBaseTypes; ++i) {
150cdf0e10cSrcweir if (i > 0) {
151cdf0e10cSrcweir *offset += sizeof (void *);
152cdf0e10cSrcweir }
153cdf0e10cSrcweir typelib_InterfaceTypeDescription const * base = type->ppBaseTypes[i];
154cdf0e10cSrcweir // ignore XInterface:
155cdf0e10cSrcweir if (base->nBaseTypes > 0) {
156cdf0e10cSrcweir if (__td_equals(
157cdf0e10cSrcweir reinterpret_cast<
158cdf0e10cSrcweir typelib_TypeDescriptionReference const * >(base),
159cdf0e10cSrcweir demandedType))
160cdf0e10cSrcweir {
161cdf0e10cSrcweir return true;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir // Profiling showed that it is important to speed up the common case
164cdf0e10cSrcweir // of only one base:
165cdf0e10cSrcweir if (type->nBaseTypes == 1) {
166cdf0e10cSrcweir type = base;
167cdf0e10cSrcweir goto next;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir if (recursivelyFindType(demandedType, base, offset)) {
170cdf0e10cSrcweir return true;
171cdf0e10cSrcweir }
172cdf0e10cSrcweir }
173cdf0e10cSrcweir }
174cdf0e10cSrcweir return false;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir
177cdf0e10cSrcweir }
178cdf0e10cSrcweir
__queryDeepNoXInterface(typelib_TypeDescriptionReference * pDemandedTDR,class_data * cd,void * that)179cdf0e10cSrcweir static inline void * __queryDeepNoXInterface(
180cdf0e10cSrcweir typelib_TypeDescriptionReference * pDemandedTDR, class_data * cd, void * that )
181cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir type_entry * pEntries = __getTypeEntries( cd );
184cdf0e10cSrcweir sal_Int32 nTypes = cd->m_nTypes;
185cdf0e10cSrcweir sal_Int32 n;
186cdf0e10cSrcweir
187cdf0e10cSrcweir // try top interfaces without getting td
188cdf0e10cSrcweir for ( n = 0; n < nTypes; ++n )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir if (__td_equals( pEntries[ n ].m_type.typeRef, pDemandedTDR ))
191cdf0e10cSrcweir {
192cdf0e10cSrcweir return makeInterface( pEntries[ n ].m_offset, that );
193cdf0e10cSrcweir }
194cdf0e10cSrcweir }
195cdf0e10cSrcweir // query deep getting td
196cdf0e10cSrcweir for ( n = 0; n < nTypes; ++n )
197cdf0e10cSrcweir {
198cdf0e10cSrcweir typelib_TypeDescription * pTD = 0;
199cdf0e10cSrcweir TYPELIB_DANGER_GET( &pTD, pEntries[ n ].m_type.typeRef );
200cdf0e10cSrcweir if (pTD)
201cdf0e10cSrcweir {
202cdf0e10cSrcweir // exclude top (already tested) and bottom (XInterface) interface
203cdf0e10cSrcweir OSL_ENSURE(
204cdf0e10cSrcweir reinterpret_cast< typelib_InterfaceTypeDescription * >(pTD)->
205cdf0e10cSrcweir nBaseTypes > 0,
206cdf0e10cSrcweir "### want to implement XInterface:"
207cdf0e10cSrcweir " template argument is XInterface?!?!?!" );
208cdf0e10cSrcweir sal_IntPtr offset = pEntries[n].m_offset;
209cdf0e10cSrcweir bool found = recursivelyFindType(
210cdf0e10cSrcweir pDemandedTDR,
211cdf0e10cSrcweir reinterpret_cast< typelib_InterfaceTypeDescription * >(pTD),
212cdf0e10cSrcweir &offset);
213cdf0e10cSrcweir TYPELIB_DANGER_RELEASE( pTD );
214cdf0e10cSrcweir if (found) {
215cdf0e10cSrcweir return makeInterface( offset, that );
216cdf0e10cSrcweir }
217cdf0e10cSrcweir }
218cdf0e10cSrcweir else
219cdf0e10cSrcweir {
220cdf0e10cSrcweir OUStringBuffer buf( 64 );
221cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("cannot get type description for type \"") );
222cdf0e10cSrcweir buf.append( pEntries[ n ].m_type.typeRef->pTypeName );
223cdf0e10cSrcweir buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\"!") );
224cdf0e10cSrcweir OUString msg( buf.makeStringAndClear() );
225cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0
226cdf0e10cSrcweir OString str( OUStringToOString( msg, RTL_TEXTENCODING_ASCII_US ) );
227cdf0e10cSrcweir OSL_ENSURE( 0, str.getStr() );
228cdf0e10cSrcweir #endif
229cdf0e10cSrcweir throw RuntimeException( msg, Reference< XInterface >() );
230cdf0e10cSrcweir }
231cdf0e10cSrcweir }
232cdf0e10cSrcweir return 0;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
235cdf0e10cSrcweir // ImplHelper
236cdf0e10cSrcweir //==================================================================================================
ImplHelper_query(Type const & rType,class_data * cd,void * that)237cdf0e10cSrcweir Any SAL_CALL ImplHelper_query(
238cdf0e10cSrcweir Type const & rType, class_data * cd, void * that )
239cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
240cdf0e10cSrcweir {
241cdf0e10cSrcweir checkInterface( rType );
242cdf0e10cSrcweir typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
243cdf0e10cSrcweir
244cdf0e10cSrcweir void * p;
245cdf0e10cSrcweir // shortcut for XInterface
246cdf0e10cSrcweir if (isXInterface( pTDR->pTypeName ))
247cdf0e10cSrcweir {
248cdf0e10cSrcweir // take first one
249cdf0e10cSrcweir p = makeInterface( cd->m_typeEntries[ 0 ].m_offset, that );
250cdf0e10cSrcweir }
251cdf0e10cSrcweir else
252cdf0e10cSrcweir {
253cdf0e10cSrcweir p = __queryDeepNoXInterface( pTDR, cd, that );
254cdf0e10cSrcweir if (! p)
255cdf0e10cSrcweir {
256cdf0e10cSrcweir return Any();
257cdf0e10cSrcweir }
258cdf0e10cSrcweir }
259cdf0e10cSrcweir return Any( &p, pTDR );
260cdf0e10cSrcweir }
261cdf0e10cSrcweir //==================================================================================================
ImplHelper_queryNoXInterface(Type const & rType,class_data * cd,void * that)262cdf0e10cSrcweir Any SAL_CALL ImplHelper_queryNoXInterface(
263cdf0e10cSrcweir Type const & rType, class_data * cd, void * that )
264cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
265cdf0e10cSrcweir {
266cdf0e10cSrcweir checkInterface( rType );
267cdf0e10cSrcweir typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
268cdf0e10cSrcweir
269cdf0e10cSrcweir void * p = __queryDeepNoXInterface( pTDR, cd, that );
270cdf0e10cSrcweir if (p)
271cdf0e10cSrcweir {
272cdf0e10cSrcweir return Any( &p, pTDR );
273cdf0e10cSrcweir }
274cdf0e10cSrcweir else
275cdf0e10cSrcweir {
276cdf0e10cSrcweir return Any();
277cdf0e10cSrcweir }
278cdf0e10cSrcweir }
279cdf0e10cSrcweir //==================================================================================================
ImplHelper_getImplementationId(class_data * cd)280cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL ImplHelper_getImplementationId( class_data * cd )
281cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir if (! cd->m_createdId)
284cdf0e10cSrcweir {
285cdf0e10cSrcweir sal_uInt8 * id = (sal_uInt8 *)alloca( 16 );
286cdf0e10cSrcweir ::rtl_createUuid( (sal_uInt8 *)id, 0, sal_True );
287cdf0e10cSrcweir
288cdf0e10cSrcweir MutexGuard guard( getImplHelperInitMutex() );
289cdf0e10cSrcweir if (! cd->m_createdId)
290cdf0e10cSrcweir {
291cdf0e10cSrcweir memcpy( cd->m_id, id, 16 );
292cdf0e10cSrcweir cd->m_createdId = sal_True;
293cdf0e10cSrcweir }
294cdf0e10cSrcweir }
295cdf0e10cSrcweir
296cdf0e10cSrcweir sal_Sequence * seq = 0;
297cdf0e10cSrcweir ::rtl_byte_sequence_constructFromArray( &seq, cd->m_id, 16 );
298cdf0e10cSrcweir return Sequence< sal_Int8 >( seq, SAL_NO_ACQUIRE );
299cdf0e10cSrcweir }
300cdf0e10cSrcweir //==================================================================================================
ImplHelper_getTypes(class_data * cd)301cdf0e10cSrcweir Sequence< Type > SAL_CALL ImplHelper_getTypes(
302cdf0e10cSrcweir class_data * cd )
303cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
304cdf0e10cSrcweir {
305cdf0e10cSrcweir Sequence< Type > types( cd->m_nTypes );
306cdf0e10cSrcweir Type * pTypes = types.getArray();
307cdf0e10cSrcweir __fillTypes( pTypes, cd );
308cdf0e10cSrcweir return types;
309cdf0e10cSrcweir }
310cdf0e10cSrcweir //==================================================================================================
ImplInhHelper_getTypes(class_data * cd,Sequence<Type> const & rAddTypes)311cdf0e10cSrcweir Sequence< Type > SAL_CALL ImplInhHelper_getTypes(
312cdf0e10cSrcweir class_data * cd, Sequence< Type > const & rAddTypes )
313cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
314cdf0e10cSrcweir {
315cdf0e10cSrcweir sal_Int32 nImplTypes = cd->m_nTypes;
316cdf0e10cSrcweir sal_Int32 nAddTypes = rAddTypes.getLength();
317cdf0e10cSrcweir Sequence< Type > types( nImplTypes + nAddTypes );
318cdf0e10cSrcweir Type * pTypes = types.getArray();
319cdf0e10cSrcweir __fillTypes( pTypes, cd );
320cdf0e10cSrcweir // append base types
321cdf0e10cSrcweir Type const * pAddTypes = rAddTypes.getConstArray();
322cdf0e10cSrcweir while (nAddTypes--)
323cdf0e10cSrcweir {
324cdf0e10cSrcweir pTypes[ nImplTypes + nAddTypes ] = pAddTypes[ nAddTypes ];
325cdf0e10cSrcweir }
326cdf0e10cSrcweir return types;
327cdf0e10cSrcweir }
328cdf0e10cSrcweir
329cdf0e10cSrcweir // WeakImplHelper
330cdf0e10cSrcweir //==================================================================================================
WeakImplHelper_query(Type const & rType,class_data * cd,void * that,OWeakObject * pBase)331cdf0e10cSrcweir Any SAL_CALL WeakImplHelper_query(
332cdf0e10cSrcweir Type const & rType, class_data * cd, void * that, OWeakObject * pBase )
333cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
334cdf0e10cSrcweir {
335cdf0e10cSrcweir checkInterface( rType );
336cdf0e10cSrcweir typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
337cdf0e10cSrcweir
338cdf0e10cSrcweir // shortcut XInterface to OWeakObject
339cdf0e10cSrcweir if (! isXInterface( pTDR->pTypeName ))
340cdf0e10cSrcweir {
341cdf0e10cSrcweir void * p = __queryDeepNoXInterface( pTDR, cd, that );
342cdf0e10cSrcweir if (p)
343cdf0e10cSrcweir {
344cdf0e10cSrcweir return Any( &p, pTDR );
345cdf0e10cSrcweir }
346cdf0e10cSrcweir }
347cdf0e10cSrcweir return pBase->OWeakObject::queryInterface( rType );
348cdf0e10cSrcweir }
349cdf0e10cSrcweir //==================================================================================================
WeakImplHelper_getTypes(class_data * cd)350cdf0e10cSrcweir Sequence< Type > SAL_CALL WeakImplHelper_getTypes(
351cdf0e10cSrcweir class_data * cd )
352cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
353cdf0e10cSrcweir {
354cdf0e10cSrcweir sal_Int32 nTypes = cd->m_nTypes;
355cdf0e10cSrcweir Sequence< Type > types( nTypes +1 );
356cdf0e10cSrcweir Type * pTypes = types.getArray();
357cdf0e10cSrcweir __fillTypes( pTypes, cd );
358cdf0e10cSrcweir pTypes[ nTypes ] = ::getCppuType( (Reference< XWeak > const *)0 );
359cdf0e10cSrcweir return types;
360cdf0e10cSrcweir }
361cdf0e10cSrcweir
362cdf0e10cSrcweir // WeakAggImplHelper
363cdf0e10cSrcweir //==================================================================================================
WeakAggImplHelper_queryAgg(Type const & rType,class_data * cd,void * that,OWeakAggObject * pBase)364cdf0e10cSrcweir Any SAL_CALL WeakAggImplHelper_queryAgg(
365cdf0e10cSrcweir Type const & rType, class_data * cd, void * that, OWeakAggObject * pBase )
366cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
367cdf0e10cSrcweir {
368cdf0e10cSrcweir checkInterface( rType );
369cdf0e10cSrcweir typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
370cdf0e10cSrcweir
371cdf0e10cSrcweir // shortcut XInterface to OWeakAggObject
372cdf0e10cSrcweir if (! isXInterface( pTDR->pTypeName ))
373cdf0e10cSrcweir {
374cdf0e10cSrcweir void * p = __queryDeepNoXInterface( pTDR, cd, that );
375cdf0e10cSrcweir if (p)
376cdf0e10cSrcweir {
377cdf0e10cSrcweir return Any( &p, pTDR );
378cdf0e10cSrcweir }
379cdf0e10cSrcweir }
380cdf0e10cSrcweir return pBase->OWeakAggObject::queryAggregation( rType );
381cdf0e10cSrcweir }
382cdf0e10cSrcweir //==================================================================================================
WeakAggImplHelper_getTypes(class_data * cd)383cdf0e10cSrcweir Sequence< Type > SAL_CALL WeakAggImplHelper_getTypes(
384cdf0e10cSrcweir class_data * cd )
385cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
386cdf0e10cSrcweir {
387cdf0e10cSrcweir sal_Int32 nTypes = cd->m_nTypes;
388cdf0e10cSrcweir Sequence< Type > types( nTypes +2 );
389cdf0e10cSrcweir Type * pTypes = types.getArray();
390cdf0e10cSrcweir __fillTypes( pTypes, cd );
391cdf0e10cSrcweir pTypes[ nTypes++ ] = ::getCppuType( (Reference< XWeak > const *)0 );
392cdf0e10cSrcweir pTypes[ nTypes ] = ::getCppuType( (const Reference< XAggregation > *)0 );
393cdf0e10cSrcweir return types;
394cdf0e10cSrcweir }
395cdf0e10cSrcweir
396cdf0e10cSrcweir // WeakComponentImplHelper
397cdf0e10cSrcweir //==================================================================================================
WeakComponentImplHelper_query(Type const & rType,class_data * cd,void * that,WeakComponentImplHelperBase * pBase)398cdf0e10cSrcweir Any SAL_CALL WeakComponentImplHelper_query(
399cdf0e10cSrcweir Type const & rType, class_data * cd, void * that, WeakComponentImplHelperBase * pBase )
400cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
401cdf0e10cSrcweir {
402cdf0e10cSrcweir checkInterface( rType );
403cdf0e10cSrcweir typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
404cdf0e10cSrcweir
405cdf0e10cSrcweir // shortcut XInterface to WeakComponentImplHelperBase
406cdf0e10cSrcweir if (! isXInterface( pTDR->pTypeName ))
407cdf0e10cSrcweir {
408cdf0e10cSrcweir void * p = __queryDeepNoXInterface( pTDR, cd, that );
409cdf0e10cSrcweir if (p)
410cdf0e10cSrcweir {
411cdf0e10cSrcweir return Any( &p, pTDR );
412cdf0e10cSrcweir }
413cdf0e10cSrcweir }
414cdf0e10cSrcweir return pBase->WeakComponentImplHelperBase::queryInterface( rType );
415cdf0e10cSrcweir }
416cdf0e10cSrcweir //==================================================================================================
WeakComponentImplHelper_getTypes(class_data * cd)417cdf0e10cSrcweir Sequence< Type > SAL_CALL WeakComponentImplHelper_getTypes(
418cdf0e10cSrcweir class_data * cd )
419cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
420cdf0e10cSrcweir {
421cdf0e10cSrcweir sal_Int32 nTypes = cd->m_nTypes;
422cdf0e10cSrcweir Sequence< Type > types( nTypes +2 );
423cdf0e10cSrcweir Type * pTypes = types.getArray();
424cdf0e10cSrcweir __fillTypes( pTypes, cd );
425cdf0e10cSrcweir pTypes[ nTypes++ ] = ::getCppuType( (Reference< XWeak > const *)0 );
426cdf0e10cSrcweir pTypes[ nTypes ] = ::getCppuType( (Reference< lang::XComponent > const *)0 );
427cdf0e10cSrcweir return types;
428cdf0e10cSrcweir }
429cdf0e10cSrcweir
430cdf0e10cSrcweir // WeakAggComponentImplHelper
431cdf0e10cSrcweir //==================================================================================================
WeakAggComponentImplHelper_queryAgg(Type const & rType,class_data * cd,void * that,WeakAggComponentImplHelperBase * pBase)432cdf0e10cSrcweir Any SAL_CALL WeakAggComponentImplHelper_queryAgg(
433cdf0e10cSrcweir Type const & rType, class_data * cd, void * that, WeakAggComponentImplHelperBase * pBase )
434cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir checkInterface( rType );
437cdf0e10cSrcweir typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType();
438cdf0e10cSrcweir
439cdf0e10cSrcweir // shortcut XInterface to WeakAggComponentImplHelperBase
440cdf0e10cSrcweir if (! isXInterface( pTDR->pTypeName ))
441cdf0e10cSrcweir {
442cdf0e10cSrcweir void * p = __queryDeepNoXInterface( pTDR, cd, that );
443cdf0e10cSrcweir if (p)
444cdf0e10cSrcweir {
445cdf0e10cSrcweir return Any( &p, pTDR );
446cdf0e10cSrcweir }
447cdf0e10cSrcweir }
448cdf0e10cSrcweir return pBase->WeakAggComponentImplHelperBase::queryAggregation( rType );
449cdf0e10cSrcweir }
450cdf0e10cSrcweir //==================================================================================================
WeakAggComponentImplHelper_getTypes(class_data * cd)451cdf0e10cSrcweir Sequence< Type > SAL_CALL WeakAggComponentImplHelper_getTypes(
452cdf0e10cSrcweir class_data * cd )
453cdf0e10cSrcweir SAL_THROW( (RuntimeException) )
454cdf0e10cSrcweir {
455cdf0e10cSrcweir sal_Int32 nTypes = cd->m_nTypes;
456cdf0e10cSrcweir Sequence< Type > types( nTypes +3 );
457cdf0e10cSrcweir Type * pTypes = types.getArray();
458cdf0e10cSrcweir __fillTypes( pTypes, cd );
459cdf0e10cSrcweir pTypes[ nTypes++ ] = ::getCppuType( (Reference< XWeak > const *)0 );
460cdf0e10cSrcweir pTypes[ nTypes++ ] = ::getCppuType( (const Reference< XAggregation > *)0 );
461cdf0e10cSrcweir pTypes[ nTypes ] = ::getCppuType( (const Reference< lang::XComponent > *)0 );
462cdf0e10cSrcweir return types;
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
465cdf0e10cSrcweir }
466