1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0 29*cdf0e10cSrcweir # undef OSL_DEBUG_LEVEL 30*cdf0e10cSrcweir # define OSL_DEBUG_LEVEL 2 31*cdf0e10cSrcweir #endif 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 34*cdf0e10cSrcweir #include "precompiled_cppuhelper.hxx" 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <stdio.h> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 39*cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx> 40*cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx> 41*cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx> 42*cdf0e10cSrcweir #include <cppuhelper/implbase5.hxx> 43*cdf0e10cSrcweir #include <cppuhelper/implbase6.hxx> 44*cdf0e10cSrcweir #include <cppuhelper/implbase7.hxx> 45*cdf0e10cSrcweir #include <cppuhelper/implbase8.hxx> 46*cdf0e10cSrcweir #include <cppuhelper/implbase9.hxx> 47*cdf0e10cSrcweir #include <cppuhelper/implbase10.hxx> 48*cdf0e10cSrcweir #include <cppuhelper/implbase11.hxx> 49*cdf0e10cSrcweir #include <cppuhelper/implbase12.hxx> 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx> 52*cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx> 53*cdf0e10cSrcweir #include <cppuhelper/compbase3.hxx> 54*cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx> 55*cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx> 56*cdf0e10cSrcweir #include <cppuhelper/compbase6.hxx> 57*cdf0e10cSrcweir #include <cppuhelper/compbase7.hxx> 58*cdf0e10cSrcweir #include <cppuhelper/compbase8.hxx> 59*cdf0e10cSrcweir #include <cppuhelper/compbase9.hxx> 60*cdf0e10cSrcweir #include <cppuhelper/compbase10.hxx> 61*cdf0e10cSrcweir #include <cppuhelper/compbase11.hxx> 62*cdf0e10cSrcweir #include <cppuhelper/compbase12.hxx> 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #include <osl/diagnose.h> 65*cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx> 66*cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx> 67*cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx> 68*cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx> 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir #include <test/A.hpp> 71*cdf0e10cSrcweir #include <test/BA.hpp> 72*cdf0e10cSrcweir #include <test/CA.hpp> 73*cdf0e10cSrcweir #include <test/DBA.hpp> 74*cdf0e10cSrcweir #include <test/E.hpp> 75*cdf0e10cSrcweir #include <test/FE.hpp> 76*cdf0e10cSrcweir #include <test/G.hpp> 77*cdf0e10cSrcweir #include <test/H.hpp> 78*cdf0e10cSrcweir #include <test/I.hpp> 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir #include <com/sun/star/lang/IllegalAccessException.hpp> 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir using namespace test; 83*cdf0e10cSrcweir using namespace rtl; 84*cdf0e10cSrcweir using namespace osl; 85*cdf0e10cSrcweir using namespace cppu; 86*cdf0e10cSrcweir using namespace com::sun::star; 87*cdf0e10cSrcweir using namespace com::sun::star::uno; 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir //================================================================================================== 90*cdf0e10cSrcweir struct TestImpl : public ImplHelper4< CA, DBA, FE, G > 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir sal_Int32 nRef; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir virtual ~TestImpl() 95*cdf0e10cSrcweir { OSL_TRACE( "> TestImpl dtor called... <\n" ); } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir virtual Any SAL_CALL queryInterface( const Type & rType ) throw(RuntimeException) 98*cdf0e10cSrcweir { return ImplHelper4< CA, DBA, FE, G >::queryInterface( rType ); } 99*cdf0e10cSrcweir virtual void SAL_CALL acquire( ) throw() 100*cdf0e10cSrcweir { ++nRef; } 101*cdf0e10cSrcweir virtual void SAL_CALL release( ) throw() 102*cdf0e10cSrcweir { if (! --nRef) delete this; } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir // A 105*cdf0e10cSrcweir virtual OUString SAL_CALL a() throw(RuntimeException) 106*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); } 107*cdf0e10cSrcweir // BA 108*cdf0e10cSrcweir virtual OUString SAL_CALL ba() throw(RuntimeException) 109*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); } 110*cdf0e10cSrcweir // CA 111*cdf0e10cSrcweir virtual OUString SAL_CALL ca() throw(RuntimeException) 112*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); } 113*cdf0e10cSrcweir // DBA 114*cdf0e10cSrcweir virtual OUString SAL_CALL dba() throw(RuntimeException) 115*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); } 116*cdf0e10cSrcweir // E 117*cdf0e10cSrcweir virtual OUString SAL_CALL e() throw(RuntimeException) 118*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); } 119*cdf0e10cSrcweir // FE 120*cdf0e10cSrcweir virtual OUString SAL_CALL fe() throw(RuntimeException) 121*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); } 122*cdf0e10cSrcweir // G 123*cdf0e10cSrcweir virtual OUString SAL_CALL g() throw(RuntimeException) 124*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); } 125*cdf0e10cSrcweir }; 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir //================================================================================================== 128*cdf0e10cSrcweir struct TestWeakAggImpl : public WeakAggImplHelper4< CA, DBA, FE, G > 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir virtual ~TestWeakAggImpl() 131*cdf0e10cSrcweir { OSL_TRACE( "> TestWeakAggImpl dtor called... <\n" ); } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir // A 134*cdf0e10cSrcweir virtual OUString SAL_CALL a() throw(RuntimeException) 135*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); } 136*cdf0e10cSrcweir // BA 137*cdf0e10cSrcweir virtual OUString SAL_CALL ba() throw(RuntimeException) 138*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); } 139*cdf0e10cSrcweir // CA 140*cdf0e10cSrcweir virtual OUString SAL_CALL ca() throw(RuntimeException) 141*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); } 142*cdf0e10cSrcweir // DBA 143*cdf0e10cSrcweir virtual OUString SAL_CALL dba() throw(RuntimeException) 144*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); } 145*cdf0e10cSrcweir // E 146*cdf0e10cSrcweir virtual OUString SAL_CALL e() throw(RuntimeException) 147*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); } 148*cdf0e10cSrcweir // FE 149*cdf0e10cSrcweir virtual OUString SAL_CALL fe() throw(RuntimeException) 150*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); } 151*cdf0e10cSrcweir // G 152*cdf0e10cSrcweir virtual OUString SAL_CALL g() throw(RuntimeException) 153*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); } 154*cdf0e10cSrcweir }; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir //================================================================================================== 157*cdf0e10cSrcweir struct TestWeakImpl : public WeakImplHelper4< CA, DBA, FE, G > 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir TestWeakImpl() {} 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir virtual ~TestWeakImpl() 162*cdf0e10cSrcweir { OSL_TRACE( "> TestWeakImpl dtor called... <\n" ); } 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir // A 165*cdf0e10cSrcweir virtual OUString SAL_CALL a() throw(RuntimeException) 166*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); } 167*cdf0e10cSrcweir // BA 168*cdf0e10cSrcweir virtual OUString SAL_CALL ba() throw(RuntimeException) 169*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); } 170*cdf0e10cSrcweir // CA 171*cdf0e10cSrcweir virtual OUString SAL_CALL ca() throw(RuntimeException) 172*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); } 173*cdf0e10cSrcweir // DBA 174*cdf0e10cSrcweir virtual OUString SAL_CALL dba() throw(RuntimeException) 175*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); } 176*cdf0e10cSrcweir // E 177*cdf0e10cSrcweir virtual OUString SAL_CALL e() throw(RuntimeException) 178*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); } 179*cdf0e10cSrcweir // FE 180*cdf0e10cSrcweir virtual OUString SAL_CALL fe() throw(RuntimeException) 181*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); } 182*cdf0e10cSrcweir // G 183*cdf0e10cSrcweir virtual OUString SAL_CALL g() throw(RuntimeException) 184*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); } 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir protected: 187*cdf0e10cSrcweir TestWeakImpl(int) {} 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir TestWeakImpl(int, int) {} 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir TestWeakImpl(int, int, int) {} 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir TestWeakImpl(int, int, int, int) {} 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir TestWeakImpl(int, int, int, int, int) {} 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir TestWeakImpl(int, int, int, int, int, int, int = 0) {} 198*cdf0e10cSrcweir }; 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir //================================================================================================== 201*cdf0e10cSrcweir struct TestWeakComponentImpl : public WeakComponentImplHelper4< CA, DBA, FE, G > 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir Mutex m; 204*cdf0e10cSrcweir TestWeakComponentImpl() 205*cdf0e10cSrcweir : WeakComponentImplHelper4< CA, DBA, FE, G >( m ) 206*cdf0e10cSrcweir {} 207*cdf0e10cSrcweir virtual ~TestWeakComponentImpl() 208*cdf0e10cSrcweir { OSL_TRACE( "> TestWeakComponentImpl dtor called... <\n" ); } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir void SAL_CALL disposing() 211*cdf0e10cSrcweir { OSL_TRACE( "> TestWeakComponentImpl disposing called... <\n" ); } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir // A 214*cdf0e10cSrcweir virtual OUString SAL_CALL a() throw(RuntimeException) 215*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); } 216*cdf0e10cSrcweir // BA 217*cdf0e10cSrcweir virtual OUString SAL_CALL ba() throw(RuntimeException) 218*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); } 219*cdf0e10cSrcweir // CA 220*cdf0e10cSrcweir virtual OUString SAL_CALL ca() throw(RuntimeException) 221*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); } 222*cdf0e10cSrcweir // DBA 223*cdf0e10cSrcweir virtual OUString SAL_CALL dba() throw(RuntimeException) 224*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); } 225*cdf0e10cSrcweir // E 226*cdf0e10cSrcweir virtual OUString SAL_CALL e() throw(RuntimeException) 227*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); } 228*cdf0e10cSrcweir // FE 229*cdf0e10cSrcweir virtual OUString SAL_CALL fe() throw(RuntimeException) 230*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); } 231*cdf0e10cSrcweir // G 232*cdf0e10cSrcweir virtual OUString SAL_CALL g() throw(RuntimeException) 233*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); } 234*cdf0e10cSrcweir }; 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir //================================================================================================== 237*cdf0e10cSrcweir struct TestWeakAggComponentImpl : public WeakAggComponentImplHelper4< CA, DBA, FE, G > 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir Mutex m; 240*cdf0e10cSrcweir TestWeakAggComponentImpl() 241*cdf0e10cSrcweir : WeakAggComponentImplHelper4< CA, DBA, FE, G >( m ) 242*cdf0e10cSrcweir {} 243*cdf0e10cSrcweir virtual ~TestWeakAggComponentImpl() 244*cdf0e10cSrcweir { OSL_TRACE( "> TestWeakAggComponentImpl dtor called... <\n" ); } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir void SAL_CALL disposing() 247*cdf0e10cSrcweir { OSL_TRACE( "> TestWeakAggComponentImpl disposing called... <\n" ); } 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir // A 250*cdf0e10cSrcweir virtual OUString SAL_CALL a() throw(RuntimeException) 251*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); } 252*cdf0e10cSrcweir // BA 253*cdf0e10cSrcweir virtual OUString SAL_CALL ba() throw(RuntimeException) 254*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); } 255*cdf0e10cSrcweir // CA 256*cdf0e10cSrcweir virtual OUString SAL_CALL ca() throw(RuntimeException) 257*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); } 258*cdf0e10cSrcweir // DBA 259*cdf0e10cSrcweir virtual OUString SAL_CALL dba() throw(RuntimeException) 260*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); } 261*cdf0e10cSrcweir // E 262*cdf0e10cSrcweir virtual OUString SAL_CALL e() throw(RuntimeException) 263*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); } 264*cdf0e10cSrcweir // FE 265*cdf0e10cSrcweir virtual OUString SAL_CALL fe() throw(RuntimeException) 266*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); } 267*cdf0e10cSrcweir // G 268*cdf0e10cSrcweir virtual OUString SAL_CALL g() throw(RuntimeException) 269*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); } 270*cdf0e10cSrcweir }; 271*cdf0e10cSrcweir 272*cdf0e10cSrcweir //================================================================================================== 273*cdf0e10cSrcweir struct TestImplInh : public ImplInheritanceHelper2< TestWeakImpl, H, I > 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir TestImplInh() {} 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir explicit TestImplInh(int): 278*cdf0e10cSrcweir ImplInheritanceHelper2< TestWeakImpl, H, I >(1) {} 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir TestImplInh(int, int): 281*cdf0e10cSrcweir ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2) {} 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir TestImplInh(int, int, int): 284*cdf0e10cSrcweir ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3) {} 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir TestImplInh(int, int, int, int): 287*cdf0e10cSrcweir ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4) {} 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir TestImplInh(int, int, int, int, int): 290*cdf0e10cSrcweir ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4, 5) {} 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir TestImplInh(int, int, int, int, int, int): 293*cdf0e10cSrcweir ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4, 5, 6) {} 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir virtual ~TestImplInh() 296*cdf0e10cSrcweir { OSL_TRACE( "> TestWeakImplInh dtor called... <\n" ); } 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir // H 299*cdf0e10cSrcweir virtual OUString SAL_CALL h() throw(RuntimeException) 300*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("h") ); } 301*cdf0e10cSrcweir // I 302*cdf0e10cSrcweir virtual OUString SAL_CALL i() throw(RuntimeException) 303*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("i") ); } 304*cdf0e10cSrcweir }; 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir //================================================================================================== 307*cdf0e10cSrcweir struct TestAggImplInh : public AggImplInheritanceHelper2< TestWeakAggImpl, H, I > 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir virtual ~TestAggImplInh() 310*cdf0e10cSrcweir { OSL_TRACE( "> TestAggImplInh dtor called... <\n" ); } 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir // H 313*cdf0e10cSrcweir virtual OUString SAL_CALL h() throw(RuntimeException) 314*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("h2") ); } 315*cdf0e10cSrcweir // I 316*cdf0e10cSrcweir virtual OUString SAL_CALL i() throw(RuntimeException) 317*cdf0e10cSrcweir { return OUString( RTL_CONSTASCII_USTRINGPARAM("i2") ); } 318*cdf0e10cSrcweir }; 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir static bool isIn( Sequence< Type > const & rTypes, char const * name ) 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir OUString str( OUString::createFromAscii( name ) ); 324*cdf0e10cSrcweir Type const * pTypes = rTypes.getConstArray(); 325*cdf0e10cSrcweir for ( sal_Int32 nPos = rTypes.getLength(); nPos--; ) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir if (pTypes[ nPos ].getTypeName().equals( str )) 328*cdf0e10cSrcweir return true; 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir return false; 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir //================================================================================================== 334*cdf0e10cSrcweir static void dotest( const Reference< XInterface > & xOriginal ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir Reference< lang::XTypeProvider > xTP( xOriginal, UNO_QUERY ); 337*cdf0e10cSrcweir Sequence< sal_Int8 > id( xTP->getImplementationId() ); 338*cdf0e10cSrcweir Sequence< Type > types( xTP->getTypes() ); 339*cdf0e10cSrcweir ::fprintf( stderr, "> supported types: " ); 340*cdf0e10cSrcweir long n = 0; 341*cdf0e10cSrcweir for ( ; n < types.getLength(); ++n ) 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir OString str( OUStringToOString( types[ n ].getTypeName(), RTL_TEXTENCODING_ASCII_US ) ); 344*cdf0e10cSrcweir ::fprintf( stderr, (n < (types.getLength()-1)) ? "%s, " : "%s; type-id=\n", str.getStr() ); 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir for ( n = 0; n < 16; ++n ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir ::fprintf( stderr, n < 15 ? "%x " : "%x \n", id[ n ] ); 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir Reference< A > xa( xOriginal, UNO_QUERY ); 352*cdf0e10cSrcweir OSL_ENSURE( xa->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### A failed!" ); 353*cdf0e10cSrcweir Reference< BA > xba( xa, UNO_QUERY ); 354*cdf0e10cSrcweir OSL_ENSURE( xba->ba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ba") ), "### BA failed!" ); 355*cdf0e10cSrcweir OSL_ENSURE( xba->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### BA failed!" ); 356*cdf0e10cSrcweir Reference< CA > xca( xba, UNO_QUERY ); 357*cdf0e10cSrcweir OSL_ENSURE( xca->ca().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ca") ), "### CA failed!" ); 358*cdf0e10cSrcweir OSL_ENSURE( xca->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### CA failed!" ); 359*cdf0e10cSrcweir Reference< DBA > xdba( xca, UNO_QUERY ); 360*cdf0e10cSrcweir OSL_ENSURE( xdba->dba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dba") ), "### DBA failed!" ); 361*cdf0e10cSrcweir OSL_ENSURE( xdba->ba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ba") ), "### DBA failed!" ); 362*cdf0e10cSrcweir OSL_ENSURE( xdba->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### DBA failed!" ); 363*cdf0e10cSrcweir Reference< E > xe( xdba, UNO_QUERY ); 364*cdf0e10cSrcweir OSL_ENSURE( xe->e().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("e") ), "### E failed!" ); 365*cdf0e10cSrcweir Reference< FE > xfe( xe, UNO_QUERY ); 366*cdf0e10cSrcweir OSL_ENSURE( xfe->fe().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("fe") ), "### FE failed!" ); 367*cdf0e10cSrcweir Reference< G > xg( xfe, UNO_QUERY ); 368*cdf0e10cSrcweir OSL_ENSURE( xg->g().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("g") ), "### G failed!" ); 369*cdf0e10cSrcweir OSL_ENSURE( xg->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### G failed!" ); 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir // type provider 372*cdf0e10cSrcweir Reference< lang::XTypeProvider > xProv( xg, UNO_QUERY ); 373*cdf0e10cSrcweir Sequence< Type > aTypes( xProv->getTypes() ); 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir // CA, DBA, FE, G, XTypeProvider 376*cdf0e10cSrcweir OSL_ASSERT( isIn( aTypes, "test.CA" ) ); 377*cdf0e10cSrcweir OSL_ASSERT( isIn( aTypes, "test.DBA" ) ); 378*cdf0e10cSrcweir OSL_ASSERT( isIn( aTypes, "test.FE") ); 379*cdf0e10cSrcweir OSL_ASSERT( isIn( aTypes, "test.G") ); 380*cdf0e10cSrcweir OSL_ASSERT( isIn( aTypes, "com.sun.star.lang.XTypeProvider") ); 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir Reference< XWeak > xWeak( xg, UNO_QUERY ); 383*cdf0e10cSrcweir if (xWeak.is()) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir OSL_ASSERT( isIn( aTypes, "com.sun.star.uno.XWeak") ); 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir Reference< lang::XComponent > xComp( xg, UNO_QUERY ); 388*cdf0e10cSrcweir if (xComp.is()) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir OSL_ASSERT( isIn( aTypes, "com.sun.star.lang.XComponent") ); 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir Reference< XAggregation > xAgg( xg, UNO_QUERY ); 394*cdf0e10cSrcweir if (xAgg.is()) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir OSL_ASSERT( isIn( aTypes, "com.sun.star.uno.XAggregation") ); 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir Reference< H > xH( xg, UNO_QUERY ); 399*cdf0e10cSrcweir if (xH.is()) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir OSL_ASSERT( isIn( aTypes, "test.H") ); 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir Reference< I > xI( xg, UNO_QUERY ); 404*cdf0e10cSrcweir if (xI.is()) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir OSL_ASSERT( isIn( aTypes, "test.I") ); 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir OSL_ENSURE( xg == xOriginal, "### root!" ); 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir void rethrow() 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir throw; 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir void throw_one( 418*cdf0e10cSrcweir lang::IllegalAccessException exc ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir try 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir throw exc; 423*cdf0e10cSrcweir } 424*cdf0e10cSrcweir catch (...) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir rethrow(); 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir //================================================================================================== 432*cdf0e10cSrcweir void test_ImplHelper( const Reference< lang::XMultiServiceFactory > & /*xSF*/ ) 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir Reference< XInterface > xImpl( (lang::XTypeProvider *)new TestImpl() ); 435*cdf0e10cSrcweir Reference< lang::XTypeProvider > xTP1( xImpl, UNO_QUERY ); 436*cdf0e10cSrcweir Reference< XInterface > xWeakImpl( (OWeakObject *)new TestWeakImpl() ); 437*cdf0e10cSrcweir Reference< lang::XTypeProvider > xTP2( xWeakImpl, UNO_QUERY ); 438*cdf0e10cSrcweir Reference< XInterface > xWeakAggImpl( (OWeakObject *)new TestWeakAggImpl() ); 439*cdf0e10cSrcweir Reference< lang::XTypeProvider > xTP3( xWeakAggImpl, UNO_QUERY ); 440*cdf0e10cSrcweir Reference< XInterface > xWeakComponentImpl( (OWeakObject *)new TestWeakComponentImpl() ); 441*cdf0e10cSrcweir Reference< lang::XTypeProvider > xTP4( xWeakComponentImpl, UNO_QUERY ); 442*cdf0e10cSrcweir Reference< XInterface > xWeakAggComponentImpl( (OWeakObject *)new TestWeakAggComponentImpl() ); 443*cdf0e10cSrcweir Reference< lang::XTypeProvider > xTP5( xWeakAggComponentImpl, UNO_QUERY ); 444*cdf0e10cSrcweir // 445*cdf0e10cSrcweir OSL_ASSERT( 446*cdf0e10cSrcweir xTP1->getImplementationId() != xTP2->getImplementationId() && 447*cdf0e10cSrcweir xTP1->getImplementationId() != xTP3->getImplementationId() && 448*cdf0e10cSrcweir xTP1->getImplementationId() != xTP4->getImplementationId() && 449*cdf0e10cSrcweir xTP1->getImplementationId() != xTP5->getImplementationId() && 450*cdf0e10cSrcweir xTP2->getImplementationId() != xTP3->getImplementationId() && 451*cdf0e10cSrcweir xTP2->getImplementationId() != xTP4->getImplementationId() && 452*cdf0e10cSrcweir xTP2->getImplementationId() != xTP5->getImplementationId() && 453*cdf0e10cSrcweir xTP3->getImplementationId() != xTP4->getImplementationId() && 454*cdf0e10cSrcweir xTP3->getImplementationId() != xTP5->getImplementationId() && 455*cdf0e10cSrcweir xTP4->getImplementationId() != xTP5->getImplementationId() ); 456*cdf0e10cSrcweir // 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir dotest( xImpl ); 459*cdf0e10cSrcweir dotest( xWeakImpl ); 460*cdf0e10cSrcweir dotest( xWeakAggImpl ); 461*cdf0e10cSrcweir dotest( xWeakComponentImpl ); 462*cdf0e10cSrcweir dotest( xWeakAggComponentImpl ); 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir xWeakImpl = (OWeakObject *)new TestImplInh(); 465*cdf0e10cSrcweir Reference< lang::XTypeProvider > xTP6( xWeakImpl, UNO_QUERY ); 466*cdf0e10cSrcweir dotest( xWeakImpl ); 467*cdf0e10cSrcweir Reference< H > xH( xWeakImpl, UNO_QUERY ); 468*cdf0e10cSrcweir Reference< I > xI( xH, UNO_QUERY ); 469*cdf0e10cSrcweir OSL_ASSERT( xH->h().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("h") ) ); 470*cdf0e10cSrcweir OSL_ASSERT( xI->i().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("i") ) ); 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir xWeakAggImpl = (OWeakObject *)new TestAggImplInh(); 473*cdf0e10cSrcweir Reference< lang::XTypeProvider > xTP7( xWeakAggImpl, UNO_QUERY ); 474*cdf0e10cSrcweir dotest( xWeakAggImpl ); 475*cdf0e10cSrcweir xH.set( xWeakAggImpl, UNO_QUERY ); 476*cdf0e10cSrcweir xI.set( xH, UNO_QUERY ); 477*cdf0e10cSrcweir OSL_ASSERT( xH->h().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("h2") ) ); 478*cdf0e10cSrcweir OSL_ASSERT( xI->i().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("i2") ) ); 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir // 481*cdf0e10cSrcweir OSL_ASSERT( 482*cdf0e10cSrcweir xTP6->getImplementationId() != xTP1->getImplementationId() && 483*cdf0e10cSrcweir xTP6->getImplementationId() != xTP2->getImplementationId() && 484*cdf0e10cSrcweir xTP6->getImplementationId() != xTP3->getImplementationId() && 485*cdf0e10cSrcweir xTP6->getImplementationId() != xTP4->getImplementationId() && 486*cdf0e10cSrcweir xTP6->getImplementationId() != xTP5->getImplementationId() && 487*cdf0e10cSrcweir xTP6->getImplementationId() != xTP7->getImplementationId() && 488*cdf0e10cSrcweir xTP7->getImplementationId() != xTP1->getImplementationId() && 489*cdf0e10cSrcweir xTP7->getImplementationId() != xTP2->getImplementationId() && 490*cdf0e10cSrcweir xTP7->getImplementationId() != xTP3->getImplementationId() && 491*cdf0e10cSrcweir xTP7->getImplementationId() != xTP4->getImplementationId() && 492*cdf0e10cSrcweir xTP7->getImplementationId() != xTP5->getImplementationId() ); 493*cdf0e10cSrcweir // 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir bool exc_succ = false; 496*cdf0e10cSrcweir lang::IllegalAccessException exc( 497*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("testtest") ), 498*cdf0e10cSrcweir xWeakAggImpl ); 499*cdf0e10cSrcweir // exception helper tests 500*cdf0e10cSrcweir try 501*cdf0e10cSrcweir { 502*cdf0e10cSrcweir throw exc; 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir catch (Exception &) 505*cdf0e10cSrcweir { 506*cdf0e10cSrcweir Any a( getCaughtException() ); 507*cdf0e10cSrcweir OSL_ASSERT( a == exc ); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir try 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir throwException( a ); 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir catch (lang::IllegalAccessException & e) 514*cdf0e10cSrcweir { 515*cdf0e10cSrcweir OSL_ASSERT( exc.Message == e.Message && exc.Context == e.Context ); 516*cdf0e10cSrcweir 517*cdf0e10cSrcweir try 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir throw_one( exc ); 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir catch (Exception &) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir Any a2( getCaughtException() ); 524*cdf0e10cSrcweir OSL_ASSERT( (a2 == a) && (a2 == exc) ); 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir try 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir throw_one( exc ); 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir catch (lang::IllegalAccessException &) 531*cdf0e10cSrcweir { 532*cdf0e10cSrcweir Any a3( getCaughtException() ); 533*cdf0e10cSrcweir OSL_ASSERT( (a3 == a) && (a3 == a2) && (a3 == exc) ); 534*cdf0e10cSrcweir exc_succ = true; 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir } 537*cdf0e10cSrcweir } 538*cdf0e10cSrcweir } 539*cdf0e10cSrcweir OSL_ASSERT( exc_succ ); 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir try 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir throwException( makeAny( RuntimeException( 544*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("runtime exc") ), xImpl ) ) ); 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir catch (RuntimeException & rExc) 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir OSL_ENSURE( rExc.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("runtime exc") ) && rExc.Context == xImpl, 549*cdf0e10cSrcweir "### unexpected exception content!" ); 550*cdf0e10cSrcweir try 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir throwException( makeAny( Exception( 553*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("exc") ), rExc.Context ) ) ); 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir catch (lang::IllegalAccessException &) 556*cdf0e10cSrcweir { 557*cdf0e10cSrcweir OSL_ENSURE( sal_False, "### unexpected IllegalAccessException exception caught!" ); 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir catch (Exception & rExc2) 560*cdf0e10cSrcweir { 561*cdf0e10cSrcweir OSL_ENSURE( rExc2.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("exc") ) && rExc2.Context == xImpl, 562*cdf0e10cSrcweir "### unexpected exception content!" ); 563*cdf0e10cSrcweir try 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir throwException( makeAny( lang::IllegalAccessException( 566*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("axxess exc") ), rExc2.Context ) ) ); 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir catch (lang::IllegalAccessException & rExc3) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir OSL_ENSURE( rExc3.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("axxess exc") ) && rExc3.Context == xImpl, 571*cdf0e10cSrcweir "### unexpected exception content!" ); 572*cdf0e10cSrcweir return; 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir } 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir catch (...) 577*cdf0e10cSrcweir { 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir OSL_ENSURE( sal_False, "### exception test failed!" ); 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir 582