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