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 #if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0
25cdf0e10cSrcweir # undef OSL_DEBUG_LEVEL
26cdf0e10cSrcweir # define OSL_DEBUG_LEVEL 2
27cdf0e10cSrcweir #endif
28cdf0e10cSrcweir 
29cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
30cdf0e10cSrcweir #include "precompiled_cppuhelper.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <stdio.h>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
35cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
36cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
37cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx>
38cdf0e10cSrcweir #include <cppuhelper/implbase5.hxx>
39cdf0e10cSrcweir #include <cppuhelper/implbase6.hxx>
40cdf0e10cSrcweir #include <cppuhelper/implbase7.hxx>
41cdf0e10cSrcweir #include <cppuhelper/implbase8.hxx>
42cdf0e10cSrcweir #include <cppuhelper/implbase9.hxx>
43cdf0e10cSrcweir #include <cppuhelper/implbase10.hxx>
44cdf0e10cSrcweir #include <cppuhelper/implbase11.hxx>
45cdf0e10cSrcweir #include <cppuhelper/implbase12.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx>
48cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
49cdf0e10cSrcweir #include <cppuhelper/compbase3.hxx>
50cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
51cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx>
52cdf0e10cSrcweir #include <cppuhelper/compbase6.hxx>
53cdf0e10cSrcweir #include <cppuhelper/compbase7.hxx>
54cdf0e10cSrcweir #include <cppuhelper/compbase8.hxx>
55cdf0e10cSrcweir #include <cppuhelper/compbase9.hxx>
56cdf0e10cSrcweir #include <cppuhelper/compbase10.hxx>
57cdf0e10cSrcweir #include <cppuhelper/compbase11.hxx>
58cdf0e10cSrcweir #include <cppuhelper/compbase12.hxx>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #include <osl/diagnose.h>
61cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx>
62cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx>
63cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
64cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx>
65cdf0e10cSrcweir 
66cdf0e10cSrcweir #include <test/A.hpp>
67cdf0e10cSrcweir #include <test/BA.hpp>
68cdf0e10cSrcweir #include <test/CA.hpp>
69cdf0e10cSrcweir #include <test/DBA.hpp>
70cdf0e10cSrcweir #include <test/E.hpp>
71cdf0e10cSrcweir #include <test/FE.hpp>
72cdf0e10cSrcweir #include <test/G.hpp>
73cdf0e10cSrcweir #include <test/H.hpp>
74cdf0e10cSrcweir #include <test/I.hpp>
75cdf0e10cSrcweir 
76cdf0e10cSrcweir #include <com/sun/star/lang/IllegalAccessException.hpp>
77cdf0e10cSrcweir 
78cdf0e10cSrcweir using namespace test;
79cdf0e10cSrcweir using namespace rtl;
80cdf0e10cSrcweir using namespace osl;
81cdf0e10cSrcweir using namespace cppu;
82cdf0e10cSrcweir using namespace com::sun::star;
83cdf0e10cSrcweir using namespace com::sun::star::uno;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir //==================================================================================================
86cdf0e10cSrcweir struct TestImpl : public ImplHelper4< CA, DBA, FE, G >
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 	sal_Int32 nRef;
89cdf0e10cSrcweir 
~TestImplTestImpl90cdf0e10cSrcweir 	virtual ~TestImpl()
91cdf0e10cSrcweir 		{ OSL_TRACE( "> TestImpl dtor called... <\n" ); }
92cdf0e10cSrcweir 
queryInterfaceTestImpl93cdf0e10cSrcweir     virtual Any SAL_CALL queryInterface( const Type & rType ) throw(RuntimeException)
94cdf0e10cSrcweir 		{ return ImplHelper4< CA, DBA, FE, G >::queryInterface( rType ); }
acquireTestImpl95cdf0e10cSrcweir     virtual void SAL_CALL acquire(  ) throw()
96cdf0e10cSrcweir 		{ ++nRef; }
releaseTestImpl97cdf0e10cSrcweir     virtual void SAL_CALL release(  ) throw()
98cdf0e10cSrcweir 		{ if (! --nRef) delete this; }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	// A
aTestImpl101cdf0e10cSrcweir 	virtual OUString SAL_CALL a() throw(RuntimeException)
102cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
103cdf0e10cSrcweir 	// BA
baTestImpl104cdf0e10cSrcweir 	virtual OUString SAL_CALL ba() throw(RuntimeException)
105cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
106cdf0e10cSrcweir 	// CA
caTestImpl107cdf0e10cSrcweir 	virtual OUString SAL_CALL ca() throw(RuntimeException)
108cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
109cdf0e10cSrcweir 	// DBA
dbaTestImpl110cdf0e10cSrcweir 	virtual OUString SAL_CALL dba() throw(RuntimeException)
111cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
112cdf0e10cSrcweir 	// E
eTestImpl113cdf0e10cSrcweir 	virtual OUString SAL_CALL e() throw(RuntimeException)
114cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
115cdf0e10cSrcweir 	// FE
feTestImpl116cdf0e10cSrcweir 	virtual OUString SAL_CALL fe() throw(RuntimeException)
117cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
118cdf0e10cSrcweir 	// G
gTestImpl119cdf0e10cSrcweir 	virtual OUString SAL_CALL g() throw(RuntimeException)
120cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
121cdf0e10cSrcweir };
122cdf0e10cSrcweir 
123cdf0e10cSrcweir //==================================================================================================
124cdf0e10cSrcweir struct TestWeakAggImpl : public WeakAggImplHelper4< CA, DBA, FE, G >
125cdf0e10cSrcweir {
~TestWeakAggImplTestWeakAggImpl126cdf0e10cSrcweir 	virtual ~TestWeakAggImpl()
127cdf0e10cSrcweir 		{ OSL_TRACE( "> TestWeakAggImpl dtor called... <\n" ); }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	// A
aTestWeakAggImpl130cdf0e10cSrcweir 	virtual OUString SAL_CALL a() throw(RuntimeException)
131cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
132cdf0e10cSrcweir 	// BA
baTestWeakAggImpl133cdf0e10cSrcweir 	virtual OUString SAL_CALL ba() throw(RuntimeException)
134cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
135cdf0e10cSrcweir 	// CA
caTestWeakAggImpl136cdf0e10cSrcweir 	virtual OUString SAL_CALL ca() throw(RuntimeException)
137cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
138cdf0e10cSrcweir 	// DBA
dbaTestWeakAggImpl139cdf0e10cSrcweir 	virtual OUString SAL_CALL dba() throw(RuntimeException)
140cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
141cdf0e10cSrcweir 	// E
eTestWeakAggImpl142cdf0e10cSrcweir 	virtual OUString SAL_CALL e() throw(RuntimeException)
143cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
144cdf0e10cSrcweir 	// FE
feTestWeakAggImpl145cdf0e10cSrcweir 	virtual OUString SAL_CALL fe() throw(RuntimeException)
146cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
147cdf0e10cSrcweir 	// G
gTestWeakAggImpl148cdf0e10cSrcweir 	virtual OUString SAL_CALL g() throw(RuntimeException)
149cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
150cdf0e10cSrcweir };
151cdf0e10cSrcweir 
152cdf0e10cSrcweir //==================================================================================================
153cdf0e10cSrcweir struct TestWeakImpl : public WeakImplHelper4< CA, DBA, FE, G >
154cdf0e10cSrcweir {
TestWeakImplTestWeakImpl155cdf0e10cSrcweir     TestWeakImpl() {}
156cdf0e10cSrcweir 
~TestWeakImplTestWeakImpl157cdf0e10cSrcweir 	virtual ~TestWeakImpl()
158cdf0e10cSrcweir 		{ OSL_TRACE( "> TestWeakImpl dtor called... <\n" ); }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir 	// A
aTestWeakImpl161cdf0e10cSrcweir 	virtual OUString SAL_CALL a() throw(RuntimeException)
162cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
163cdf0e10cSrcweir 	// BA
baTestWeakImpl164cdf0e10cSrcweir 	virtual OUString SAL_CALL ba() throw(RuntimeException)
165cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
166cdf0e10cSrcweir 	// CA
caTestWeakImpl167cdf0e10cSrcweir 	virtual OUString SAL_CALL ca() throw(RuntimeException)
168cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
169cdf0e10cSrcweir 	// DBA
dbaTestWeakImpl170cdf0e10cSrcweir 	virtual OUString SAL_CALL dba() throw(RuntimeException)
171cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
172cdf0e10cSrcweir 	// E
eTestWeakImpl173cdf0e10cSrcweir 	virtual OUString SAL_CALL e() throw(RuntimeException)
174cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
175cdf0e10cSrcweir 	// FE
feTestWeakImpl176cdf0e10cSrcweir 	virtual OUString SAL_CALL fe() throw(RuntimeException)
177cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
178cdf0e10cSrcweir 	// G
gTestWeakImpl179cdf0e10cSrcweir 	virtual OUString SAL_CALL g() throw(RuntimeException)
180cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir protected:
TestWeakImplTestWeakImpl183cdf0e10cSrcweir     TestWeakImpl(int) {}
184cdf0e10cSrcweir 
TestWeakImplTestWeakImpl185cdf0e10cSrcweir     TestWeakImpl(int, int) {}
186cdf0e10cSrcweir 
TestWeakImplTestWeakImpl187cdf0e10cSrcweir     TestWeakImpl(int, int, int) {}
188cdf0e10cSrcweir 
TestWeakImplTestWeakImpl189cdf0e10cSrcweir     TestWeakImpl(int, int, int, int) {}
190cdf0e10cSrcweir 
TestWeakImplTestWeakImpl191cdf0e10cSrcweir     TestWeakImpl(int, int, int, int, int) {}
192cdf0e10cSrcweir 
TestWeakImplTestWeakImpl193cdf0e10cSrcweir     TestWeakImpl(int, int, int, int, int, int, int = 0) {}
194cdf0e10cSrcweir };
195cdf0e10cSrcweir 
196cdf0e10cSrcweir //==================================================================================================
197cdf0e10cSrcweir struct TestWeakComponentImpl : public WeakComponentImplHelper4< CA, DBA, FE, G >
198cdf0e10cSrcweir {
199cdf0e10cSrcweir 	Mutex m;
TestWeakComponentImplTestWeakComponentImpl200cdf0e10cSrcweir 	TestWeakComponentImpl()
201cdf0e10cSrcweir 		: WeakComponentImplHelper4< CA, DBA, FE, G >( m )
202cdf0e10cSrcweir 		{}
~TestWeakComponentImplTestWeakComponentImpl203cdf0e10cSrcweir 	virtual ~TestWeakComponentImpl()
204cdf0e10cSrcweir 		{ OSL_TRACE( "> TestWeakComponentImpl dtor called... <\n" ); }
205cdf0e10cSrcweir 
disposingTestWeakComponentImpl206cdf0e10cSrcweir 	void SAL_CALL disposing()
207cdf0e10cSrcweir 		{ OSL_TRACE( "> TestWeakComponentImpl disposing called... <\n" ); }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir 	// A
aTestWeakComponentImpl210cdf0e10cSrcweir 	virtual OUString SAL_CALL a() throw(RuntimeException)
211cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
212cdf0e10cSrcweir 	// BA
baTestWeakComponentImpl213cdf0e10cSrcweir 	virtual OUString SAL_CALL ba() throw(RuntimeException)
214cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
215cdf0e10cSrcweir 	// CA
caTestWeakComponentImpl216cdf0e10cSrcweir 	virtual OUString SAL_CALL ca() throw(RuntimeException)
217cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
218cdf0e10cSrcweir 	// DBA
dbaTestWeakComponentImpl219cdf0e10cSrcweir 	virtual OUString SAL_CALL dba() throw(RuntimeException)
220cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
221cdf0e10cSrcweir 	// E
eTestWeakComponentImpl222cdf0e10cSrcweir 	virtual OUString SAL_CALL e() throw(RuntimeException)
223cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
224cdf0e10cSrcweir 	// FE
feTestWeakComponentImpl225cdf0e10cSrcweir 	virtual OUString SAL_CALL fe() throw(RuntimeException)
226cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
227cdf0e10cSrcweir 	// G
gTestWeakComponentImpl228cdf0e10cSrcweir 	virtual OUString SAL_CALL g() throw(RuntimeException)
229cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
230cdf0e10cSrcweir };
231cdf0e10cSrcweir 
232cdf0e10cSrcweir //==================================================================================================
233cdf0e10cSrcweir struct TestWeakAggComponentImpl : public WeakAggComponentImplHelper4< CA, DBA, FE, G >
234cdf0e10cSrcweir {
235cdf0e10cSrcweir 	Mutex m;
TestWeakAggComponentImplTestWeakAggComponentImpl236cdf0e10cSrcweir 	TestWeakAggComponentImpl()
237cdf0e10cSrcweir 		: WeakAggComponentImplHelper4< CA, DBA, FE, G >( m )
238cdf0e10cSrcweir 		{}
~TestWeakAggComponentImplTestWeakAggComponentImpl239cdf0e10cSrcweir 	virtual ~TestWeakAggComponentImpl()
240cdf0e10cSrcweir 		{ OSL_TRACE( "> TestWeakAggComponentImpl dtor called... <\n" ); }
241cdf0e10cSrcweir 
disposingTestWeakAggComponentImpl242cdf0e10cSrcweir 	void SAL_CALL disposing()
243cdf0e10cSrcweir 		{ OSL_TRACE( "> TestWeakAggComponentImpl disposing called... <\n" ); }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 	// A
aTestWeakAggComponentImpl246cdf0e10cSrcweir 	virtual OUString SAL_CALL a() throw(RuntimeException)
247cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
248cdf0e10cSrcweir 	// BA
baTestWeakAggComponentImpl249cdf0e10cSrcweir 	virtual OUString SAL_CALL ba() throw(RuntimeException)
250cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
251cdf0e10cSrcweir 	// CA
caTestWeakAggComponentImpl252cdf0e10cSrcweir 	virtual OUString SAL_CALL ca() throw(RuntimeException)
253cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
254cdf0e10cSrcweir 	// DBA
dbaTestWeakAggComponentImpl255cdf0e10cSrcweir 	virtual OUString SAL_CALL dba() throw(RuntimeException)
256cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
257cdf0e10cSrcweir 	// E
eTestWeakAggComponentImpl258cdf0e10cSrcweir 	virtual OUString SAL_CALL e() throw(RuntimeException)
259cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
260cdf0e10cSrcweir 	// FE
feTestWeakAggComponentImpl261cdf0e10cSrcweir 	virtual OUString SAL_CALL fe() throw(RuntimeException)
262cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
263cdf0e10cSrcweir 	// G
gTestWeakAggComponentImpl264cdf0e10cSrcweir 	virtual OUString SAL_CALL g() throw(RuntimeException)
265cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
266cdf0e10cSrcweir };
267cdf0e10cSrcweir 
268cdf0e10cSrcweir //==================================================================================================
269cdf0e10cSrcweir struct TestImplInh : public ImplInheritanceHelper2< TestWeakImpl, H, I >
270cdf0e10cSrcweir {
TestImplInhTestImplInh271cdf0e10cSrcweir     TestImplInh() {}
272cdf0e10cSrcweir 
TestImplInhTestImplInh273cdf0e10cSrcweir     explicit TestImplInh(int):
274cdf0e10cSrcweir         ImplInheritanceHelper2< TestWeakImpl, H, I >(1) {}
275cdf0e10cSrcweir 
TestImplInhTestImplInh276cdf0e10cSrcweir     TestImplInh(int, int):
277cdf0e10cSrcweir         ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2) {}
278cdf0e10cSrcweir 
TestImplInhTestImplInh279cdf0e10cSrcweir     TestImplInh(int, int, int):
280cdf0e10cSrcweir         ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3) {}
281cdf0e10cSrcweir 
TestImplInhTestImplInh282cdf0e10cSrcweir     TestImplInh(int, int, int, int):
283cdf0e10cSrcweir         ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4) {}
284cdf0e10cSrcweir 
TestImplInhTestImplInh285cdf0e10cSrcweir     TestImplInh(int, int, int, int, int):
286cdf0e10cSrcweir         ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4, 5) {}
287cdf0e10cSrcweir 
TestImplInhTestImplInh288cdf0e10cSrcweir     TestImplInh(int, int, int, int, int, int):
289cdf0e10cSrcweir         ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4, 5, 6) {}
290cdf0e10cSrcweir 
~TestImplInhTestImplInh291cdf0e10cSrcweir 	virtual ~TestImplInh()
292cdf0e10cSrcweir 		{ OSL_TRACE( "> TestWeakImplInh dtor called... <\n" ); }
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 	// H
hTestImplInh295cdf0e10cSrcweir 	virtual OUString SAL_CALL h() throw(RuntimeException)
296cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("h") ); }
297cdf0e10cSrcweir 	// I
iTestImplInh298cdf0e10cSrcweir 	virtual OUString SAL_CALL i() throw(RuntimeException)
299cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("i") ); }
300cdf0e10cSrcweir };
301cdf0e10cSrcweir 
302cdf0e10cSrcweir //==================================================================================================
303cdf0e10cSrcweir struct TestAggImplInh : public AggImplInheritanceHelper2< TestWeakAggImpl, H, I >
304cdf0e10cSrcweir {
~TestAggImplInhTestAggImplInh305cdf0e10cSrcweir 	virtual ~TestAggImplInh()
306cdf0e10cSrcweir 		{ OSL_TRACE( "> TestAggImplInh dtor called... <\n" ); }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 	// H
hTestAggImplInh309cdf0e10cSrcweir 	virtual OUString SAL_CALL h() throw(RuntimeException)
310cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("h2") ); }
311cdf0e10cSrcweir 	// I
iTestAggImplInh312cdf0e10cSrcweir 	virtual OUString SAL_CALL i() throw(RuntimeException)
313cdf0e10cSrcweir 		{ return OUString( RTL_CONSTASCII_USTRINGPARAM("i2") ); }
314cdf0e10cSrcweir };
315cdf0e10cSrcweir 
316cdf0e10cSrcweir 
isIn(Sequence<Type> const & rTypes,char const * name)317cdf0e10cSrcweir static bool isIn( Sequence< Type > const & rTypes, char const * name )
318cdf0e10cSrcweir {
319cdf0e10cSrcweir     OUString str( OUString::createFromAscii( name ) );
320cdf0e10cSrcweir     Type const * pTypes = rTypes.getConstArray();
321cdf0e10cSrcweir     for ( sal_Int32 nPos = rTypes.getLength(); nPos--; )
322cdf0e10cSrcweir     {
323cdf0e10cSrcweir         if (pTypes[ nPos ].getTypeName().equals( str ))
324cdf0e10cSrcweir             return true;
325cdf0e10cSrcweir     }
326cdf0e10cSrcweir     return false;
327cdf0e10cSrcweir }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir //==================================================================================================
dotest(const Reference<XInterface> & xOriginal)330cdf0e10cSrcweir static void dotest( const Reference< XInterface > & xOriginal )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir     Reference< lang::XTypeProvider > xTP( xOriginal, UNO_QUERY );
333cdf0e10cSrcweir     Sequence< sal_Int8 > id( xTP->getImplementationId() );
334cdf0e10cSrcweir     Sequence< Type > types( xTP->getTypes() );
335cdf0e10cSrcweir     ::fprintf( stderr, "> supported types: " );
336cdf0e10cSrcweir     long n = 0;
337cdf0e10cSrcweir     for ( ; n < types.getLength(); ++n )
338cdf0e10cSrcweir     {
339cdf0e10cSrcweir         OString str( OUStringToOString( types[ n ].getTypeName(), RTL_TEXTENCODING_ASCII_US ) );
340cdf0e10cSrcweir         ::fprintf( stderr, (n < (types.getLength()-1)) ? "%s, " : "%s; type-id=\n", str.getStr() );
341cdf0e10cSrcweir     }
342cdf0e10cSrcweir     for ( n = 0; n < 16; ++n )
343cdf0e10cSrcweir     {
344cdf0e10cSrcweir         ::fprintf( stderr, n < 15 ? "%x " : "%x \n", id[ n ] );
345cdf0e10cSrcweir     }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 	Reference< A > xa( xOriginal, UNO_QUERY );
348cdf0e10cSrcweir 	OSL_ENSURE( xa->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### A failed!" );
349cdf0e10cSrcweir 	Reference< BA > xba( xa, UNO_QUERY );
350cdf0e10cSrcweir 	OSL_ENSURE( xba->ba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ba") ), "### BA failed!" );
351cdf0e10cSrcweir 	OSL_ENSURE( xba->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### BA failed!" );
352cdf0e10cSrcweir 	Reference< CA > xca( xba, UNO_QUERY );
353cdf0e10cSrcweir 	OSL_ENSURE( xca->ca().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ca") ), "### CA failed!" );
354cdf0e10cSrcweir 	OSL_ENSURE( xca->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### CA failed!" );
355cdf0e10cSrcweir 	Reference< DBA > xdba( xca, UNO_QUERY );
356cdf0e10cSrcweir 	OSL_ENSURE( xdba->dba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dba") ), "### DBA failed!" );
357cdf0e10cSrcweir 	OSL_ENSURE( xdba->ba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ba") ), "### DBA failed!" );
358cdf0e10cSrcweir 	OSL_ENSURE( xdba->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### DBA failed!" );
359cdf0e10cSrcweir 	Reference< E > xe( xdba, UNO_QUERY );
360cdf0e10cSrcweir 	OSL_ENSURE( xe->e().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("e") ), "### E failed!" );
361cdf0e10cSrcweir 	Reference< FE > xfe( xe, UNO_QUERY );
362cdf0e10cSrcweir 	OSL_ENSURE( xfe->fe().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("fe") ), "### FE failed!" );
363cdf0e10cSrcweir 	Reference< G > xg( xfe, UNO_QUERY );
364cdf0e10cSrcweir 	OSL_ENSURE( xg->g().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("g") ), "### G failed!" );
365cdf0e10cSrcweir 	OSL_ENSURE( xg->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### G failed!" );
366cdf0e10cSrcweir 
367cdf0e10cSrcweir 	// type provider
368cdf0e10cSrcweir 	Reference< lang::XTypeProvider > xProv( xg, UNO_QUERY );
369cdf0e10cSrcweir 	Sequence< Type > aTypes( xProv->getTypes() );
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 	// CA, DBA, FE, G, XTypeProvider
372cdf0e10cSrcweir 	OSL_ASSERT( isIn( aTypes, "test.CA" ) );
373cdf0e10cSrcweir 	OSL_ASSERT( isIn( aTypes, "test.DBA" ) );
374cdf0e10cSrcweir 	OSL_ASSERT( isIn( aTypes, "test.FE") );
375cdf0e10cSrcweir 	OSL_ASSERT( isIn( aTypes, "test.G") );
376cdf0e10cSrcweir 	OSL_ASSERT( isIn( aTypes, "com.sun.star.lang.XTypeProvider") );
377cdf0e10cSrcweir 
378cdf0e10cSrcweir 	Reference< XWeak > xWeak( xg, UNO_QUERY );
379cdf0e10cSrcweir     if (xWeak.is())
380cdf0e10cSrcweir     {
381cdf0e10cSrcweir         OSL_ASSERT( isIn( aTypes, "com.sun.star.uno.XWeak") );
382cdf0e10cSrcweir     }
383cdf0e10cSrcweir 	Reference< lang::XComponent > xComp( xg, UNO_QUERY );
384cdf0e10cSrcweir 	if (xComp.is())
385cdf0e10cSrcweir 	{
386cdf0e10cSrcweir         OSL_ASSERT( isIn( aTypes, "com.sun.star.lang.XComponent") );
387cdf0e10cSrcweir     }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	Reference< XAggregation > xAgg( xg, UNO_QUERY );
390cdf0e10cSrcweir     if (xAgg.is())
391cdf0e10cSrcweir     {
392cdf0e10cSrcweir         OSL_ASSERT( isIn( aTypes, "com.sun.star.uno.XAggregation") );
393cdf0e10cSrcweir 	}
394cdf0e10cSrcweir     Reference< H > xH( xg, UNO_QUERY );
395cdf0e10cSrcweir     if (xH.is())
396cdf0e10cSrcweir     {
397cdf0e10cSrcweir         OSL_ASSERT( isIn( aTypes, "test.H") );
398cdf0e10cSrcweir     }
399cdf0e10cSrcweir     Reference< I > xI( xg, UNO_QUERY );
400cdf0e10cSrcweir     if (xI.is())
401cdf0e10cSrcweir     {
402cdf0e10cSrcweir         OSL_ASSERT( isIn( aTypes, "test.I") );
403cdf0e10cSrcweir     }
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 	OSL_ENSURE( xg == xOriginal, "### root!" );
406cdf0e10cSrcweir }
407cdf0e10cSrcweir 
rethrow()408cdf0e10cSrcweir void rethrow()
409cdf0e10cSrcweir {
410cdf0e10cSrcweir     throw;
411cdf0e10cSrcweir }
412cdf0e10cSrcweir 
throw_one(lang::IllegalAccessException exc)413cdf0e10cSrcweir void throw_one(
414cdf0e10cSrcweir     lang::IllegalAccessException exc )
415cdf0e10cSrcweir {
416cdf0e10cSrcweir     try
417cdf0e10cSrcweir     {
418cdf0e10cSrcweir         throw exc;
419cdf0e10cSrcweir     }
420cdf0e10cSrcweir     catch (...)
421cdf0e10cSrcweir     {
422cdf0e10cSrcweir         rethrow();
423cdf0e10cSrcweir     }
424cdf0e10cSrcweir }
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 
427cdf0e10cSrcweir //==================================================================================================
test_ImplHelper(const Reference<lang::XMultiServiceFactory> &)428cdf0e10cSrcweir void test_ImplHelper( const Reference< lang::XMultiServiceFactory > & /*xSF*/ )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir 	Reference< XInterface > xImpl( (lang::XTypeProvider *)new TestImpl() );
431cdf0e10cSrcweir     Reference< lang::XTypeProvider > xTP1( xImpl, UNO_QUERY );
432cdf0e10cSrcweir 	Reference< XInterface > xWeakImpl( (OWeakObject *)new TestWeakImpl() );
433cdf0e10cSrcweir     Reference< lang::XTypeProvider > xTP2( xWeakImpl, UNO_QUERY );
434cdf0e10cSrcweir 	Reference< XInterface > xWeakAggImpl( (OWeakObject *)new TestWeakAggImpl() );
435cdf0e10cSrcweir     Reference< lang::XTypeProvider > xTP3( xWeakAggImpl, UNO_QUERY );
436cdf0e10cSrcweir 	Reference< XInterface > xWeakComponentImpl( (OWeakObject *)new TestWeakComponentImpl() );
437cdf0e10cSrcweir     Reference< lang::XTypeProvider > xTP4( xWeakComponentImpl, UNO_QUERY );
438cdf0e10cSrcweir 	Reference< XInterface > xWeakAggComponentImpl( (OWeakObject *)new TestWeakAggComponentImpl() );
439cdf0e10cSrcweir     Reference< lang::XTypeProvider > xTP5( xWeakAggComponentImpl, UNO_QUERY );
440cdf0e10cSrcweir 	//
441cdf0e10cSrcweir     OSL_ASSERT(
442cdf0e10cSrcweir         xTP1->getImplementationId() != xTP2->getImplementationId() &&
443cdf0e10cSrcweir         xTP1->getImplementationId() != xTP3->getImplementationId() &&
444cdf0e10cSrcweir         xTP1->getImplementationId() != xTP4->getImplementationId() &&
445cdf0e10cSrcweir         xTP1->getImplementationId() != xTP5->getImplementationId() &&
446cdf0e10cSrcweir         xTP2->getImplementationId() != xTP3->getImplementationId() &&
447cdf0e10cSrcweir         xTP2->getImplementationId() != xTP4->getImplementationId() &&
448cdf0e10cSrcweir         xTP2->getImplementationId() != xTP5->getImplementationId() &&
449cdf0e10cSrcweir         xTP3->getImplementationId() != xTP4->getImplementationId() &&
450cdf0e10cSrcweir         xTP3->getImplementationId() != xTP5->getImplementationId() &&
451cdf0e10cSrcweir         xTP4->getImplementationId() != xTP5->getImplementationId() );
452cdf0e10cSrcweir     //
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 	dotest( xImpl );
455cdf0e10cSrcweir 	dotest( xWeakImpl );
456cdf0e10cSrcweir 	dotest( xWeakAggImpl );
457cdf0e10cSrcweir 	dotest( xWeakComponentImpl );
458cdf0e10cSrcweir 	dotest( xWeakAggComponentImpl );
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 	xWeakImpl = (OWeakObject *)new TestImplInh();
461cdf0e10cSrcweir     Reference< lang::XTypeProvider > xTP6( xWeakImpl, UNO_QUERY );
462cdf0e10cSrcweir     dotest( xWeakImpl );
463cdf0e10cSrcweir     Reference< H > xH( xWeakImpl, UNO_QUERY );
464cdf0e10cSrcweir     Reference< I > xI( xH, UNO_QUERY );
465cdf0e10cSrcweir     OSL_ASSERT( xH->h().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("h") ) );
466cdf0e10cSrcweir     OSL_ASSERT( xI->i().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("i") ) );
467cdf0e10cSrcweir 
468cdf0e10cSrcweir 	xWeakAggImpl = (OWeakObject *)new TestAggImplInh();
469cdf0e10cSrcweir     Reference< lang::XTypeProvider > xTP7( xWeakAggImpl, UNO_QUERY );
470cdf0e10cSrcweir     dotest( xWeakAggImpl );
471cdf0e10cSrcweir     xH.set( xWeakAggImpl, UNO_QUERY );
472cdf0e10cSrcweir     xI.set( xH, UNO_QUERY );
473cdf0e10cSrcweir     OSL_ASSERT( xH->h().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("h2") ) );
474cdf0e10cSrcweir     OSL_ASSERT( xI->i().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("i2") ) );
475cdf0e10cSrcweir 
476cdf0e10cSrcweir     //
477cdf0e10cSrcweir     OSL_ASSERT(
478cdf0e10cSrcweir         xTP6->getImplementationId() != xTP1->getImplementationId() &&
479cdf0e10cSrcweir         xTP6->getImplementationId() != xTP2->getImplementationId() &&
480cdf0e10cSrcweir         xTP6->getImplementationId() != xTP3->getImplementationId() &&
481cdf0e10cSrcweir         xTP6->getImplementationId() != xTP4->getImplementationId() &&
482cdf0e10cSrcweir         xTP6->getImplementationId() != xTP5->getImplementationId() &&
483cdf0e10cSrcweir         xTP6->getImplementationId() != xTP7->getImplementationId() &&
484cdf0e10cSrcweir         xTP7->getImplementationId() != xTP1->getImplementationId() &&
485cdf0e10cSrcweir         xTP7->getImplementationId() != xTP2->getImplementationId() &&
486cdf0e10cSrcweir         xTP7->getImplementationId() != xTP3->getImplementationId() &&
487cdf0e10cSrcweir         xTP7->getImplementationId() != xTP4->getImplementationId() &&
488cdf0e10cSrcweir         xTP7->getImplementationId() != xTP5->getImplementationId() );
489cdf0e10cSrcweir     //
490cdf0e10cSrcweir 
491cdf0e10cSrcweir     bool exc_succ = false;
492cdf0e10cSrcweir     lang::IllegalAccessException exc(
493cdf0e10cSrcweir         OUString( RTL_CONSTASCII_USTRINGPARAM("testtest") ),
494cdf0e10cSrcweir         xWeakAggImpl );
495cdf0e10cSrcweir 	// exception helper tests
496cdf0e10cSrcweir     try
497cdf0e10cSrcweir     {
498cdf0e10cSrcweir         throw exc;
499cdf0e10cSrcweir     }
500cdf0e10cSrcweir     catch (Exception &)
501cdf0e10cSrcweir     {
502cdf0e10cSrcweir         Any a( getCaughtException() );
503cdf0e10cSrcweir         OSL_ASSERT( a == exc );
504cdf0e10cSrcweir 
505cdf0e10cSrcweir         try
506cdf0e10cSrcweir         {
507cdf0e10cSrcweir             throwException( a );
508cdf0e10cSrcweir         }
509cdf0e10cSrcweir         catch (lang::IllegalAccessException & e)
510cdf0e10cSrcweir         {
511cdf0e10cSrcweir             OSL_ASSERT( exc.Message == e.Message && exc.Context == e.Context );
512cdf0e10cSrcweir 
513cdf0e10cSrcweir             try
514cdf0e10cSrcweir             {
515cdf0e10cSrcweir                 throw_one( exc );
516cdf0e10cSrcweir             }
517cdf0e10cSrcweir             catch (Exception &)
518cdf0e10cSrcweir             {
519cdf0e10cSrcweir                 Any a2( getCaughtException() );
520cdf0e10cSrcweir                 OSL_ASSERT( (a2 == a) && (a2 == exc) );
521cdf0e10cSrcweir 
522cdf0e10cSrcweir                 try
523cdf0e10cSrcweir                 {
524cdf0e10cSrcweir                     throw_one( exc );
525cdf0e10cSrcweir                 }
526cdf0e10cSrcweir                 catch (lang::IllegalAccessException &)
527cdf0e10cSrcweir                 {
528cdf0e10cSrcweir                     Any a3( getCaughtException() );
529cdf0e10cSrcweir                     OSL_ASSERT( (a3 == a) && (a3 == a2) && (a3 == exc) );
530cdf0e10cSrcweir                     exc_succ = true;
531cdf0e10cSrcweir                 }
532cdf0e10cSrcweir             }
533cdf0e10cSrcweir         }
534cdf0e10cSrcweir     }
535cdf0e10cSrcweir     OSL_ASSERT( exc_succ );
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 	try
538cdf0e10cSrcweir 	{
539cdf0e10cSrcweir 		throwException( makeAny( RuntimeException(
540cdf0e10cSrcweir 			OUString( RTL_CONSTASCII_USTRINGPARAM("runtime exc") ), xImpl ) ) );
541cdf0e10cSrcweir 	}
542cdf0e10cSrcweir 	catch (RuntimeException & rExc)
543cdf0e10cSrcweir 	{
544cdf0e10cSrcweir 		OSL_ENSURE( rExc.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("runtime exc") ) && rExc.Context == xImpl,
545cdf0e10cSrcweir 					 "### unexpected exception content!" );
546cdf0e10cSrcweir 		try
547cdf0e10cSrcweir 		{
548cdf0e10cSrcweir 			throwException( makeAny( Exception(
549cdf0e10cSrcweir 				OUString( RTL_CONSTASCII_USTRINGPARAM("exc") ), rExc.Context ) ) );
550cdf0e10cSrcweir 		}
551cdf0e10cSrcweir 		catch (lang::IllegalAccessException &)
552cdf0e10cSrcweir 		{
553cdf0e10cSrcweir 			OSL_ENSURE( sal_False, "### unexpected IllegalAccessException exception caught!" );
554cdf0e10cSrcweir 		}
555cdf0e10cSrcweir 		catch (Exception & rExc2)
556cdf0e10cSrcweir 		{
557cdf0e10cSrcweir 			OSL_ENSURE( rExc2.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("exc") ) && rExc2.Context == xImpl,
558cdf0e10cSrcweir 						 "### unexpected exception content!" );
559cdf0e10cSrcweir 			try
560cdf0e10cSrcweir 			{
561cdf0e10cSrcweir 				throwException( makeAny( lang::IllegalAccessException(
562cdf0e10cSrcweir 					OUString( RTL_CONSTASCII_USTRINGPARAM("axxess exc") ), rExc2.Context ) ) );
563cdf0e10cSrcweir 			}
564cdf0e10cSrcweir 			catch (lang::IllegalAccessException & rExc3)
565cdf0e10cSrcweir 			{
566cdf0e10cSrcweir 				OSL_ENSURE( rExc3.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("axxess exc") ) && rExc3.Context == xImpl,
567cdf0e10cSrcweir 							 "### unexpected exception content!" );
568cdf0e10cSrcweir 				return;
569cdf0e10cSrcweir 			}
570cdf0e10cSrcweir 		}
571cdf0e10cSrcweir 	}
572cdf0e10cSrcweir 	catch (...)
573cdf0e10cSrcweir 	{
574cdf0e10cSrcweir 	}
575cdf0e10cSrcweir 	OSL_ENSURE( sal_False, "### exception test failed!" );
576cdf0e10cSrcweir }
577cdf0e10cSrcweir 
578