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