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 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_framework.hxx" 30 31 //_________________________________________________________________________________________________________________ 32 // my own includes 33 //_________________________________________________________________________________________________________________ 34 #include <classes/servicemanager.hxx> 35 #include <classes/filtercache.hxx> 36 #include <macros/generic.hxx> 37 #include <macros/debug.hxx> 38 #include <services.h> 39 40 //_________________________________________________________________________________________________________________ 41 // interface includes 42 //_________________________________________________________________________________________________________________ 43 #include <com/sun/star/frame/XDesktop.hpp> 44 #include <com/sun/star/frame/XFrame.hpp> 45 #include <com/sun/star/awt/XWindow.hpp> 46 #include <com/sun/star/frame/XFrameLoader.hpp> 47 #include <com/sun/star/beans/PropertyValue.hpp> 48 #include <com/sun/star/frame/XLoadEventListener.hpp> 49 #include <com/sun/star/frame/XDispatchProvider.hpp> 50 #include <com/sun/star/util/URL.hpp> 51 #include <com/sun/star/frame/FrameSearchFlag.hpp> 52 #include <com/sun/star/frame/XFrames.hpp> 53 #include <com/sun/star/lang/XServiceInfo.hpp> 54 #include <com/sun/star/frame/XComponentLoader.hpp> 55 #include <com/sun/star/frame/XTasksSupplier.hpp> 56 #include <com/sun/star/task/XStatusIndicatorFactory.hpp> 57 #include <com/sun/star/beans/XMultiPropertySet.hpp> 58 #include <com/sun/star/lang/XSingleServiceFactory.hpp> 59 #include <com/sun/star/mozilla/XPluginInstancePeer.hpp> 60 #include <com/sun/star/bridge/XInstanceProvider.hpp> 61 #include <com/sun/star/document/XTypeDetection.hpp> 62 #include <com/sun/star/container/XNameAccess.hpp> 63 #include <com/sun/star/container/XNameContainer.hpp> 64 #include <com/sun/star/container/XElementAccess.hpp> 65 #include <com/sun/star/frame/XConfigManager.hpp> 66 67 //_________________________________________________________________________________________________________________ 68 // other includes 69 //_________________________________________________________________________________________________________________ 70 #include <comphelper/processfactory.hxx> 71 #include <com/sun/star/uno/Reference.h> 72 #include <rtl/ustring.hxx> 73 #include <rtl/ustrbuf.hxx> 74 #include <toolkit/helper/vclunohelper.hxx> 75 #include <svtools/unoiface.hxx> 76 #include <tools/urlobj.hxx> 77 78 #include <vcl/event.hxx> 79 #include <vcl/svapp.hxx> 80 #include <vcl/wrkwin.hxx> 81 #include <vcl/msgbox.hxx> 82 #include <stdio.h> 83 84 //_________________________________________________________________________________________________________________ 85 // const 86 //_________________________________________________________________________________________________________________ 87 88 #define APPLICATIONNAME "FrameWork - Testapplication" 89 90 //_________________________________________________________________________________________________________________ 91 // namespace 92 //_________________________________________________________________________________________________________________ 93 94 using namespace ::rtl ; 95 using namespace ::comphelper ; 96 using namespace ::framework ; 97 using namespace ::cppu ; 98 using namespace ::com::sun::star::uno ; 99 using namespace ::com::sun::star::lang ; 100 using namespace ::com::sun::star::frame ; 101 using namespace ::com::sun::star::awt ; 102 using namespace ::com::sun::star::beans ; 103 using namespace ::com::sun::star::util ; 104 using namespace ::com::sun::star::task ; 105 using namespace ::com::sun::star::mozilla ; 106 using namespace ::com::sun::star::bridge ; 107 using namespace ::com::sun::star::document ; 108 using namespace ::com::sun::star::container ; 109 110 //_________________________________________________________________________________________________________________ 111 // defines 112 //_________________________________________________________________________________________________________________ 113 114 //_________________________________________________________________________________________________________________ 115 // declarations 116 //_________________________________________________________________________________________________________________ 117 118 /*-***************************************************************************************************************/ 119 class TestApplication : public Application 120 { 121 //************************************************************************************************************* 122 public: 123 124 void Main(); 125 126 //************************************************************************************************************* 127 private: 128 129 #ifdef TEST_DESKTOP 130 void impl_testDesktop ( const Reference< XDesktop >& xDesktop ); 131 void impl_buildTree ( const Reference< XDesktop >& xDesktop ); 132 void impl_logTree ( const Reference< XDesktop >& xDesktop ); 133 134 #endif 135 136 #ifdef TEST_PLUGIN 137 void impl_testPlugIn ( const Reference< XDesktop >& xDesktop, const Reference< XMultiServiceFactory >& xFactory ); 138 #endif 139 140 #ifdef TEST_LOGINDIALOG 141 void impl_testLoginDialog(); 142 #endif 143 144 #ifdef TEST_FILTERCACHE 145 void impl_testFilterCache(); 146 #endif 147 148 #ifdef TEST_TYPEDETECTION 149 void impl_testTypeDetection(); 150 #endif 151 152 #ifdef TEST_FILTERREGISTRATION 153 void impl_testFilterRegistration(); 154 #endif 155 156 #ifdef TEST_TREESEARCH 157 sal_Bool impl_testTreeSearch(); 158 #endif 159 160 //************************************************************************************************************* 161 private: 162 163 //************************************************************************************************************* 164 private: 165 166 Reference< XMultiServiceFactory > m_xFactory; 167 168 }; // class TestApplication 169 170 //_________________________________________________________________________________________________________________ 171 // global variables 172 //_________________________________________________________________________________________________________________ 173 174 TestApplication aTestApplication ; 175 176 //_________________________________________________________________________________________________________________ 177 // main 178 //_________________________________________________________________________________________________________________ 179 180 void TestApplication::Main() 181 { 182 // RegistryCache aCache; 183 184 /**-*********************************************************************************************************** 185 initialize program 186 **************************************************************************************************************/ 187 188 // Init global servicemanager and set it. 189 ServiceManager aManager; 190 m_xFactory = aManager.getGlobalUNOServiceManager(); 191 setProcessServiceFactory( m_xFactory ); 192 193 // Control sucess of operation. 194 LOG_ASSERT( !(m_xFactory.is() ==sal_False ), "TestApplication::Main()\nCan't create global service manager.\n\n" ) 195 LOG_ASSERT( !(getProcessServiceFactory()!=m_xFactory), "TestApplication::Main()\nGlobal servicemanager not set in UNOTOOLS.\n\n" ) 196 197 /**-*********************************************************************************************************** 198 test area 199 **************************************************************************************************************/ 200 201 sal_Bool bState = sal_True; 202 203 //------------------------------------------------------------------------------------------------------------- 204 #ifdef TEST_FILTERCACHE 205 impl_testFilterCache(); 206 #endif 207 208 //------------------------------------------------------------------------------------------------------------- 209 #ifdef TEST_TYPEDETECTION 210 impl_testTypeDetection(); 211 #endif 212 213 //------------------------------------------------------------------------------------------------------------- 214 #ifdef TEST_LOGINDIALOG 215 ResMgr* pRessourceManager = CREATEVERSIONRESMGR( lgd ); 216 Resource::SetResManager( pRessourceManager ); 217 impl_testLoginDialog(); 218 #endif 219 220 //------------------------------------------------------------------------------------------------------------- 221 #ifdef TEST_DESKTOP 222 Reference< XDesktop > xDesktop( xGlobalServiceManager->createInstance( SERVICENAME_DESKTOP ), UNO_QUERY ); 223 impl_testDesktop( xDesktop ); 224 #endif 225 226 //------------------------------------------------------------------------------------------------------------- 227 #ifdef TEST_PLUGIN 228 impl_testPlugIn( xDesktop, xGlobalServiceManager ); 229 #endif 230 231 //------------------------------------------------------------------------------------------------------------- 232 #ifdef TEST_FILTERREGISTRATION 233 impl_testFilterRegistration(); 234 #endif 235 236 //------------------------------------------------------------------------------------------------------------- 237 #ifdef TEST_TREESEARCH 238 bState = impl_testTreeSearch(); 239 #endif 240 241 // Execute(); 242 // xFrame->dispose(); 243 // delete pMainWindow; 244 if( bState = sal_True ) 245 { 246 LOG_ERROR( "TestApplication::Main()", "Test successful ..." ) 247 } 248 else 249 { 250 LOG_ERROR( "TestApplication::Main()", "Test failed ..." ) 251 } 252 } 253 254 //_________________________________________________________________________________________________________________ 255 // test method 256 //_________________________________________________________________________________________________________________ 257 #ifdef TEST_TYPEDETECTION 258 void TestApplication::impl_testTypeDetection() 259 { 260 // We use a string buffer to log important informations and search results. 261 // Errors are shown directly by an assert! 262 OUStringBuffer sBuffer( 100000 ); 263 264 // Create a new type detection service. 265 Reference< XTypeDetection > xTypeDetection( getProcessServiceFactory()->createInstance( SERVICENAME_TYPEDETECTION ), UNO_QUERY ); 266 LOG_ASSERT( !(xTypeDetection.is()==sal_False), "TestApplication::impl_testTypeDetection()\nCouldn't create the type detection service.\n" ); 267 268 if( xTypeDetection.is() == sal_True ) 269 { 270 // a) Check his implementation and his supported interfaces first. 271 Reference< XInterface > xInterface ( xTypeDetection, UNO_QUERY ); 272 Reference< XTypeProvider > xTypeProvider ( xTypeDetection, UNO_QUERY ); 273 Reference< XServiceInfo > xServiceInfo ( xTypeDetection, UNO_QUERY ); 274 Reference< XNameAccess > xNameAccess ( xTypeDetection, UNO_QUERY ); 275 Reference< XElementAccess > xElementAccess ( xTypeDetection, UNO_QUERY ); 276 277 LOG_ASSERT( !( xInterface.is() == sal_False || 278 xTypeProvider.is() == sal_False || 279 xServiceInfo.is() == sal_False || 280 xNameAccess.is() == sal_False || 281 xElementAccess.is() == sal_False ), "TestApplication::impl_testTypeDetection()\nMiss supported for searched interface!\n" ) 282 283 // b) Check OneInstance mode of service. 284 Reference< XTypeDetection > xTypeDetection2( getProcessServiceFactory()->createInstance( SERVICENAME_TYPEDETECTION ), UNO_QUERY ); 285 LOG_ASSERT( !(xTypeDetection!=xTypeDetection2), "TestApplication::impl_testTypeDetection()\nService isn't \"OneInstance\" ...!\n" ) 286 xTypeDetection2 = Reference< XTypeDetection >(); 287 288 // c) Check "XTypeDetection" ... flat by URL 289 // Define list of URLs for checking. 290 OUString pURLs[] = 291 { 292 DECLARE_ASCII("file://c|/temp/test.sdw" ), 293 DECLARE_ASCII("private:factory/scalc" ), 294 DECLARE_ASCII("file://c|/temp/test.txt" ), 295 DECLARE_ASCII("slot:5000" ), 296 }; 297 sal_uInt32 nCount = 4; 298 Sequence< OUString > seqURLs( pURLs, nCount ); 299 300 Reference< XMultiServiceFactory > xFilterFactory( getProcessServiceFactory()->createInstance( SERVICENAME_FILTERFACTORY ), UNO_QUERY ); 301 Reference< XMultiServiceFactory > xLoaderFactory( getProcessServiceFactory()->createInstance( SERVICENAME_FRAMELOADERFACTORY), UNO_QUERY ); 302 LOG_ASSERT( !(xFilterFactory.is()==sal_False), "TestApplication::impl_testTypeDetection()\nCouldn't create filter factory!\n" ) 303 LOG_ASSERT( !(xLoaderFactory.is()==sal_False), "TestApplication::impl_testTypeDetection()\nCouldn't create loader factory!\n" ) 304 305 // Step over these list. 306 for( sal_uInt32 nURL=0; nURL<nCount; ++nURL ) 307 { 308 // Try to get a type name for every URL from list and log search result. 309 OUString sTypeName = xTypeDetection->queryTypeByURL( seqURLs[nURL] ); 310 sBuffer.appendAscii ( "queryTypeByURL( \"" ); 311 sBuffer.append ( seqURLs[nURL] ); 312 sBuffer.appendAscii ( "\" ) returns type \"" ); 313 sBuffer.append ( sTypeName ); 314 sBuffer.appendAscii ( "\"\n" ); 315 // If a type was found - try to get a filter and a frame loader for it. 316 if( sTypeName.getLength() > 0 ) 317 { 318 Reference< XInterface > xFilter = xFilterFactory->createInstance( sTypeName ); 319 Reference< XInterface > xLoader = xLoaderFactory->createInstance( sTypeName ); 320 if( xFilter.is() == sal_False ) 321 { 322 sBuffer.appendAscii( "Couldn't find an filter.\n" ); 323 } 324 else 325 { 326 Reference< XPropertySet > xFilterProperties( xFilter, UNO_QUERY ); 327 LOG_ASSERT( !(xFilterProperties.is()==sal_False), "TestApplication::impl_testTypeDetection()\nFilter don't support XPropertySet!\n" ) 328 if( xFilterProperties.is() == sal_True ) 329 { 330 OUString sUIName; 331 xFilterProperties->getPropertyValue( DECLARE_ASCII("UIName") ) >>= sUIName; 332 sBuffer.appendAscii ( "Found filter \"" ); 333 sBuffer.append ( sUIName ); 334 sBuffer.appendAscii ( "\"\n" ); 335 } 336 337 Reference< XPropertySet > xLoaderProperties( xLoader, UNO_QUERY ); 338 LOG_ASSERT( !(xLoaderProperties.is()==sal_False), "TestApplication::impl_testTypeDetection()\nLoader don't support XPropertySet!\n" ) 339 if( xLoaderProperties.is() == sal_True ) 340 { 341 OUString sUIName; 342 xLoaderProperties->getPropertyValue( DECLARE_ASCII("UIName") ) >>= sUIName; 343 sBuffer.appendAscii ( "Found loader \"" ); 344 sBuffer.append ( sUIName ); 345 sBuffer.appendAscii ( "\"\n" ); 346 } 347 } 348 } 349 } 350 } 351 352 WRITE_LOGFILE( "testTypeDetection.log", U2B(sBuffer.makeStringAndClear()) ) 353 } 354 #endif 355 356 //_________________________________________________________________________________________________________________ 357 // test method 358 //_________________________________________________________________________________________________________________ 359 #ifdef TEST_FILTERCACHE 360 void TestApplication::impl_testFilterCache() 361 { 362 FilterCache aCache; 363 364 OUStringBuffer sBuffer( 100000 ); 365 if( aCache.isValid() == sal_False ) 366 { 367 sBuffer.appendAscii( "Cache isn't valid!\n" ); 368 } 369 else 370 { 371 /* 372 // Step over all types and log his values. 373 // These simulate a XNameAccess! 374 const Sequence< OUString > seqAllTypeNames = aCache.getAllTypeNames(); 375 sal_uInt32 nCount = seqAllTypeNames.getLength(); 376 for( sal_uInt32 nPosition=0; nPosition<nCount; ++nPosition ) 377 { 378 sBuffer.appendAscii( "--------------------------------------------------------------------------------\n" ); 379 const TType* pType = aCache.getTypeByName( seqAllTypeNames[nPosition] ); 380 if( pType == NULL ) 381 { 382 sBuffer.appendAscii ( "Type [" ); 383 sBuffer.append ( (sal_Int32)nPosition ); 384 sBuffer.appendAscii ( "] \"" ); 385 sBuffer.append ( seqAllTypeNames[nPosition]); 386 sBuffer.appendAscii ( "\" isn't valid!" ); 387 } 388 else 389 { 390 sBuffer.appendAscii ( "Type [" ); 391 sBuffer.append ( (sal_Int32)nPosition ); 392 sBuffer.appendAscii ( "] \"" ); 393 sBuffer.append ( seqAllTypeNames[nPosition] ); 394 sBuffer.appendAscii ( "\"\n\t\tUIName\t=\t" ); 395 sBuffer.append ( pType->sUIName ); 396 sBuffer.appendAscii ( "\n\t\tMediaType\t=\t" ); 397 sBuffer.append ( pType->sMediaType ); 398 sBuffer.appendAscii ( "\n\t\tClipboardFormat\t=\t" ); 399 sBuffer.append ( pType->sClipboardFormat ); 400 sBuffer.appendAscii ( "\n\t\tURLPattern\t=\t{" ); 401 for( TConstStringIterator aIterator=pType->lURLPattern.begin(); aIterator!=pType->lURLPattern.end(); ++aIterator ) 402 { 403 sBuffer.append ( *aIterator ); 404 sBuffer.appendAscii ( ";\n\t\t" ); 405 } 406 sBuffer.appendAscii( "}\nExtensions\t=\t" ); 407 for( aIterator=pType->lExtensions.begin(); aIterator!=pType->lExtensions.end(); ++aIterator ) 408 { 409 sBuffer.append ( *aIterator ); 410 sBuffer.appendAscii ( ";\n\t\t" ); 411 } 412 sBuffer.appendAscii ( "}\nDocumentIconID\t=\t" ); 413 sBuffer.append ( (sal_Int32)pType->nDocumentIconID ); 414 } 415 } 416 */ 417 // searchFirstType( URL, MediaType, ClipboardFormat, startEntry ) 418 TCheckedTypeIterator aIterator; 419 sBuffer.appendAscii( "search type for \"file://c|/temp/test.sdw\"; no media type; no clipboard format\n" ); 420 OUString sURL = DECLARE_ASCII("file://c|/temp/test.sdw"); 421 const OUString* pType = aCache.searchFirstType( &sURL, NULL, NULL, aIterator ); 422 while( pType != NULL ) 423 { 424 sBuffer.appendAscii ( "\tfound \"" ); 425 sBuffer.append ( *pType ); 426 sBuffer.appendAscii ( "\"\n" ); 427 pType = aCache.searchType( &sURL, NULL, NULL, aIterator ); 428 } 429 } 430 431 WRITE_LOGFILE( "test_FilterCache.log", U2B(sBuffer.makeStringAndClear()) ) 432 } 433 #endif 434 435 //_________________________________________________________________________________________________________________ 436 // test method 437 //_________________________________________________________________________________________________________________ 438 #ifdef TEST_LOGINDIALOG 439 void TestApplication::impl_testLoginDialog() 440 { 441 // Get global servicemanager to create service "LoginDialog". 442 Reference< XMultiServiceFactory > xFactory = getProcessServiceFactory(); 443 LOG_ASSERT( !(xFactory.is()==sal_False), "TestApplication::impl_testLoginDialog()\nServicemanager not valid.\n" ) 444 // Create LoginDialog. 445 Reference< XDialog > xDialog( xFactory->createInstance( DECLARE_ASCII("com.sun.star.framework.LoginDialog") ), UNO_QUERY ); 446 LOG_ASSERT( !(xDialog.is()==sal_False), "TestApplication::impl_testLoginDialog()\nCould not create login dialog.\n" ) 447 // Check set/getTitle() 448 /* not implemented yet! */ 449 // OUString sTitle = DECLARE_ASCII("Login Dialog Test"); 450 // xDialog->setTitle( sTitle ); 451 // LOG_ASSERT( !(xDialog->getTitle()!=sTitle), "TestApplication::impl_testLoginDialog()\nset/getTitle don't work correct.\n" ) 452 453 UniString sInternalURL = DECLARE_ASCII("private:factory/scalc"); 454 UniString sExternalURL = OUString(); 455 456 OString sOut = "internal: "; 457 sOut += OUStringToOString( sInternalURL, RTL_TEXTENCODING_UTF8 ); 458 sOut += "\nexternal: "; 459 sOut += OUStringToOString( sExternalURL, RTL_TEXTENCODING_UTF8 ); 460 sOut += "\n"; 461 LOG_ASSERT( sal_False, sOut ) 462 463 INetURLObject::translateToExternal( sInternalURL, sExternalURL ); 464 sOut = "internal: "; 465 sOut += OUStringToOString( sInternalURL, RTL_TEXTENCODING_UTF8 ); 466 sOut += "\nexternal: "; 467 sOut += OUStringToOString( sExternalURL, RTL_TEXTENCODING_UTF8 ); 468 sOut += "\n"; 469 LOG_ASSERT( sal_False, sOut ) 470 471 INetURLObject::translateToInternal( sExternalURL, sInternalURL ); 472 sOut = "internal: "; 473 sOut += OUStringToOString( sInternalURL, RTL_TEXTENCODING_UTF8 ); 474 sOut += "\nexternal: "; 475 sOut += OUStringToOString( sExternalURL, RTL_TEXTENCODING_UTF8 ); 476 sOut += "\n"; 477 LOG_ASSERT( sal_False, sOut ) 478 479 // Work with properties of dialog. 480 Reference< XPropertySet > xPropertySet( xDialog, UNO_QUERY ); 481 LOG_ASSERT( !(xPropertySet.is()==sal_False), "TestApplication::impl_testLoginDialog()\nCan't cast dialog to XPropertySet interface.\n" ) 482 Any aUserName ; 483 Any aPassword ; 484 Any aServer ; 485 Any aConnectionType ; 486 Any aPort ; 487 aUserName <<= DECLARE_ASCII("Andreas"); 488 aPassword <<= DECLARE_ASCII("Test"); 489 aServer <<= DECLARE_ASCII("www.yahoo.de:7777"); 490 aConnectionType <<= DECLARE_ASCII("Bla"); 491 sal_Int32 nPort = 8081; 492 aPort <<= nPort; 493 try 494 { 495 xPropertySet->setPropertyValue( DECLARE_ASCII("UserName" ), aUserName ); 496 xPropertySet->setPropertyValue( DECLARE_ASCII("Password" ), aPassword ); 497 xPropertySet->setPropertyValue( DECLARE_ASCII("Server" ), aServer ); 498 xPropertySet->setPropertyValue( DECLARE_ASCII("ConnectionType" ), aConnectionType ); 499 xPropertySet->setPropertyValue( DECLARE_ASCII("Compressed" ), aPort ); 500 } 501 catch( ::com::sun::star::beans::UnknownPropertyException& ) 502 { 503 LOG_ASSERT( sal_False, "UnkownPropertyException detected!\n" ) 504 } 505 catch( ::com::sun::star::beans::PropertyVetoException& ) 506 { 507 LOG_ASSERT( sal_False, "PropertyVetoException detected!\n" ) 508 } 509 catch( ::com::sun::star::lang::IllegalArgumentException& ) 510 { 511 LOG_ASSERT( sal_False, "IllegalArgumentException detected!\n" ) 512 } 513 catch( ::com::sun::star::lang::WrappedTargetException& ) 514 { 515 LOG_ASSERT( sal_False, "WrappedTargetException detected!\n" ) 516 } 517 catch( ::com::sun::star::uno::RuntimeException& ) 518 { 519 LOG_ASSERT( sal_False, "RuntimeException detected!\n" ) 520 } 521 522 xDialog->execute(); 523 524 OUString sUserName ; 525 OUString sPassword ; 526 OUString sServer ; 527 OUString sConnectionType ; 528 xPropertySet->getPropertyValue( DECLARE_ASCII("UserName" ) ) >>= sUserName ; 529 xPropertySet->getPropertyValue( DECLARE_ASCII("Password" ) ) >>= sPassword ; 530 xPropertySet->getPropertyValue( DECLARE_ASCII("Server" ) ) >>= sServer ; 531 xPropertySet->getPropertyValue( DECLARE_ASCII("ConnectionType" ) ) >>= sConnectionType ; 532 xPropertySet->getPropertyValue( sConnectionType ) >>= nPort ; 533 534 LOG_ASSERT( sal_False, OUStringToOString( sUserName, RTL_TEXTENCODING_UTF8 ) ) 535 LOG_ASSERT( sal_False, OUStringToOString( sPassword, RTL_TEXTENCODING_UTF8 ) ) 536 LOG_ASSERT( sal_False, OUStringToOString( sServer , RTL_TEXTENCODING_UTF8 ) ) 537 LOG_ASSERT( sal_False, OUStringToOString( sConnectionType , RTL_TEXTENCODING_UTF8 ) ) 538 LOG_ASSERT( sal_False, OString::valueOf( (sal_Int32)nPort ) ) 539 } 540 #endif 541 542 //_________________________________________________________________________________________________________________ 543 // test method 544 //_________________________________________________________________________________________________________________ 545 #ifdef TEST_PLUGIN 546 void TestApplication::impl_testPlugIn( const Reference< XDesktop >& xDesktop, const Reference< XMultiServiceFactory >& xFactory ) 547 { 548 // create instance provider for creation of factories. 549 Reference< XInstanceProvider > xInstanceProvider( (OWeakObject*)(new OInstanceProvider( xFactory )), UNO_QUERY ); 550 LOG_ASSERT( !(xInstanceProvider.is()==sal_False), "TestApplication::impl_testPlugIn()\nCan't create new instance provider!\n" ) 551 552 // try to get factory for create a plugin 553 Reference< XSingleServiceFactory > xPlugInFactory( xInstanceProvider->getInstance( INSTANCENAME_PLUGINFACTORY ), UNO_QUERY ); 554 LOG_ASSERT( !(xPlugInFactory.is()==sal_False), "TestApplication::impl_testPlugIn()\nCan't get PlugInFactory from instance provider!\n" ) 555 556 // initialize parameter for creation of plugin 557 Reference< XPluginInstancePeer > xPlugInDLL =Reference< XPluginInstancePeer >(); 558 Sequence< Any > seqArguments(1); 559 seqArguments[0] <<= xPlugInDLL; 560 561 // create plugin 562 Reference< XFrame > xPlugIn( xPlugInFactory->createInstanceWithArguments( seqArguments ), UNO_QUERY ); 563 LOG_ASSERT( !(xPlugIn.is()==sal_False), "TestApplication::impl_testPlugIn()\nFactory has created no valid plugin!\n" ) 564 565 xPlugIn->setName( OUString(RTL_CONSTASCII_USTRINGPARAM("PlugIn")) ); 566 Reference< XFramesSupplier > xSupplier( xDesktop, UNO_QUERY ); 567 xPlugIn->setCreator( xSupplier ); 568 } 569 #endif 570 571 //_________________________________________________________________________________________________________________ 572 // test method 573 //_________________________________________________________________________________________________________________ 574 #ifdef TEST_DESKTOP 575 #define LOGFILE_TARGETING "targeting.log" 576 void TestApplication::impl_testDesktop( const Reference< XDesktop >& xDesktop ) 577 { 578 //------------------------------------------------------------------------------------------------------------- 579 // 1) Test cast to all supported interfaces of Desktop. 580 581 Reference< XInterface > xDesktopInterface ( xDesktop, UNO_QUERY ); 582 Reference< XTypeProvider > xDesktopTypeProvider ( xDesktop, UNO_QUERY ); 583 Reference< XServiceInfo > xDesktopServiceInfo ( xDesktop, UNO_QUERY ); 584 Reference< XComponentLoader > xDesktopComponentLoader ( xDesktop, UNO_QUERY ); 585 Reference< XTasksSupplier > xDesktopTasksSupplier ( xDesktop, UNO_QUERY ); 586 Reference< XDispatchProvider > xDesktopDispatchProvider ( xDesktop, UNO_QUERY ); 587 Reference< XFramesSupplier > xDesktopFramesSupplier ( xDesktop, UNO_QUERY ); 588 Reference< XFrame > xDesktopFrame ( xDesktop, UNO_QUERY ); 589 Reference< XComponent > xDesktopComponent ( xDesktop, UNO_QUERY ); 590 Reference< XStatusIndicatorFactory > xDesktopStatusIndicatorFactory ( xDesktop, UNO_QUERY ); 591 Reference< XPropertySet > xDesktopPropertySet ( xDesktop, UNO_QUERY ); 592 Reference< XFastPropertySet > xDesktopFastPropertySet ( xDesktop, UNO_QUERY ); 593 Reference< XMultiPropertySet > xDesktopMultiPropertySet ( xDesktop, UNO_QUERY ); 594 595 LOG_ASSERT( !(xDesktopInterface.is() ==sal_False), "TestApplication::impl_testDesktop()\nXInterface not supported by Desktop.\n\n" ) 596 LOG_ASSERT( !(xDesktopTypeProvider.is() ==sal_False), "TestApplication::impl_testDesktop()\nXTypeProvider not supported by Desktop.\n\n" ) 597 LOG_ASSERT( !(xDesktopServiceInfo.is() ==sal_False), "TestApplication::impl_testDesktop()\nXServiceInfo not supported by Desktop.\n\n" ) 598 LOG_ASSERT( !(xDesktop.is() ==sal_False), "TestApplication::impl_testDesktop()\nXDesktop not supported by Desktop.\n\n" ) 599 LOG_ASSERT( !(xDesktopComponentLoader.is() ==sal_False), "TestApplication::impl_testDesktop()\nXComponentLoader not supported by Desktop.\n\n" ) 600 LOG_ASSERT( !(xDesktopTasksSupplier.is() ==sal_False), "TestApplication::impl_testDesktop()\nXTasksSupplier not supported by Desktop.\n\n" ) 601 LOG_ASSERT( !(xDesktopDispatchProvider.is() ==sal_False), "TestApplication::impl_testDesktop()\nXDispatchProvider not supported by Desktop.\n\n" ) 602 LOG_ASSERT( !(xDesktopFramesSupplier.is() ==sal_False), "TestApplication::impl_testDesktop()\nXFramesSupplier not supported by Desktop.\n\n" ) 603 LOG_ASSERT( !(xDesktopFrame.is() ==sal_False), "TestApplication::impl_testDesktop()\nXFrame not supported by Desktop.\n\n" ) 604 LOG_ASSERT( !(xDesktopComponent.is() ==sal_False), "TestApplication::impl_testDesktop()\nXComponent not supported by Desktop.\n\n" ) 605 LOG_ASSERT( !(xDesktopStatusIndicatorFactory.is() ==sal_False), "TestApplication::impl_testDesktop()\nXStatusIndicatorFactory not supported by Desktop.\n\n" ) 606 LOG_ASSERT( !(xDesktopPropertySet.is() ==sal_False), "TestApplication::impl_testDesktop()\nXPropertySet not supported by Desktop.\n\n" ) 607 LOG_ASSERT( !(xDesktopFastPropertySet.is() ==sal_False), "TestApplication::impl_testDesktop()\nXFastPropertySet not supported by Desktop.\n\n" ) 608 LOG_ASSERT( !(xDesktopMultiPropertySet.is() ==sal_False), "TestApplication::impl_testDesktop()\nXMultiPropertySet not supported by Desktop.\n\n" ) 609 610 //------------------------------------------------------------------------------------------------------------- 611 // 2) Test set-/getName(). 612 613 // 2a) Test default value "Desktop". 614 OUString sName( RTL_CONSTASCII_USTRINGPARAM("Desktop") ); 615 LOG_ASSERT( !(xDesktopFrame->getName()!=sName), "TestApplication::impl_testDesktop()\nDefault value of desktop name is invalid.\n\n" ) 616 617 // 2b) Set name and try to get the same name. 618 sName = OUString( RTL_CONSTASCII_USTRINGPARAM("New Desktop") ); 619 xDesktopFrame->setName( sName ); 620 LOG_ASSERT( !(xDesktopFrame->getName()!=sName), "TestApplication::impl_testDesktop()\nSetting of name works not correct on desktop.\n\n" ) 621 622 // Reset name do default! 623 // Its neccessary for follow operations. 624 sName = OUString( RTL_CONSTASCII_USTRINGPARAM("Desktop") ); 625 xDesktopFrame->setName( sName ); 626 627 //------------------------------------------------------------------------------------------------------------- 628 // 3) Test findFrame(). 629 630 // Build new example tree and log initial structure in file. 631 impl_buildTree ( xDesktop ); 632 impl_logTree ( xDesktop ); 633 634 OUString sTargetFrameName; 635 sal_uInt32 nSearchFlags ; 636 Reference< XFrame > xSearchFrame ; 637 Reference< XFrame > xTask_4 ; 638 Reference< XFrame > xFrame_41 ; 639 Reference< XFrame > xFrame_411 ; 640 Reference< XFrame > xFrame_112 ; 641 Reference< XFrame > xFrame_1123 ; 642 Reference< XFrame > xFrame_11231 ; 643 Reference< XFrame > xFrame_11221 ; 644 645 // 3a) Search for Desktop 646 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 647 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with SELF for \"Desktop\" on Desktop\n" ) 648 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 649 sTargetFrameName = OUString(RTL_CONSTASCII_USTRINGPARAM("Desktop")); 650 nSearchFlags = FrameSearchFlag::SELF; 651 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 652 LOG_ASSERT( !(xSearchFrame.is()==sal_False), "TestApplication::impl_testDesktop()\nSearch 3a)-1 invalid\n" ); 653 654 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 655 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with ALL for \"Desktop\" on Desktop\n" ) 656 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 657 nSearchFlags = FrameSearchFlag::ALL; 658 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 659 LOG_ASSERT( !(xSearchFrame.is()==sal_False), "TestApplication::impl_testDesktop()\nSearch 3a)-2 invalid\n" ); 660 661 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 662 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with CHILDREN for \"Desktop\" on Desktop\n" ) 663 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 664 nSearchFlags = FrameSearchFlag::CHILDREN; 665 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 666 LOG_ASSERT( !(xSearchFrame.is()==sal_True), "TestApplication::impl_testDesktop()\nSearch 3a)-3 invalid\n" ); 667 668 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 669 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with SIBLINGS for \"Desktop\" on Desktop\n" ) 670 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 671 nSearchFlags = FrameSearchFlag::SIBLINGS; 672 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 673 LOG_ASSERT( !(xSearchFrame.is()==sal_True), "TestApplication::impl_testDesktop()\nSearch 3a)-4 invalid\n" ); 674 675 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 676 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with AUTO for \"Desktop\" on Desktop\n" ) 677 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 678 nSearchFlags = FrameSearchFlag::AUTO; 679 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 680 LOG_ASSERT( !(xSearchFrame.is()==sal_True), "TestApplication::impl_testDesktop()\nSearch 3a)-5 invalid\n" ); 681 682 // 3b) Search for Task_4 683 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 684 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with SELF for \"Task_4\" on Desktop\n" ) 685 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 686 sTargetFrameName = OUString(RTL_CONSTASCII_USTRINGPARAM("Task_4")); 687 nSearchFlags = FrameSearchFlag::SELF; 688 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 689 LOG_ASSERT( !(xSearchFrame.is()==sal_True), "TestApplication::impl_testDesktop()\nSearch 3b)-1 invalid\n" ); 690 691 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 692 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with SIBLINGS for \"Task_4\" on Desktop\n" ) 693 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 694 nSearchFlags = FrameSearchFlag::SIBLINGS; 695 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 696 LOG_ASSERT( !(xSearchFrame.is()==sal_True), "TestApplication::impl_testDesktop()\nSearch 3b)-2 invalid\n" ); 697 698 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 699 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with CHILDREN for \"Task_4\" on Desktop\n" ) 700 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 701 nSearchFlags = FrameSearchFlag::CHILDREN; 702 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 703 LOG_ASSERT( !(xSearchFrame.is()==sal_False), "TestApplication::impl_testDesktop()\nSearch 3b)-3 invalid\n" ); 704 705 xTask_4 = xSearchFrame; 706 707 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 708 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with ALL for \"Task_4\" on Desktop\n" ) 709 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 710 nSearchFlags = FrameSearchFlag::ALL; 711 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 712 LOG_ASSERT( !(xSearchFrame.is()==sal_False), "TestApplication::impl_testDesktop()\nSearch 3b)-4 invalid\n" ); 713 714 // 3c) Search for Frame_41 715 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 716 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with SELF for \"Frame_41\" on Desktop\n" ) 717 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 718 sTargetFrameName = OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_41")); 719 nSearchFlags = FrameSearchFlag::SELF; 720 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 721 LOG_ASSERT( !(xSearchFrame.is()==sal_True), "TestApplication::impl_testDesktop()\nSearch 3c)-1 invalid\n" ); 722 723 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 724 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with SIBLINGS for \"Frame_41\" on Desktop\n" ) 725 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 726 nSearchFlags = FrameSearchFlag::SIBLINGS; 727 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 728 LOG_ASSERT( !(xSearchFrame.is()==sal_True), "TestApplication::impl_testDesktop()\nSearch 3c)-2 invalid\n" ); 729 730 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 731 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with CHILDREN for \"Frame_41\" on Desktop\n" ) 732 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 733 nSearchFlags = FrameSearchFlag::CHILDREN; 734 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 735 LOG_ASSERT( !(xSearchFrame.is()==sal_False), "TestApplication::impl_testDesktop()\nSearch 3c)-3 invalid\n" ); 736 737 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 738 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with ALL for \"Frame_41\" on Desktop\n" ) 739 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 740 nSearchFlags = FrameSearchFlag::ALL; 741 xSearchFrame = xDesktopFrame->findFrame(sTargetFrameName, nSearchFlags); 742 LOG_ASSERT( !(xSearchFrame.is()==sal_False), "TestApplication::impl_testDesktop()\nSearch 3c)-4 invalid\n" ); 743 744 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 745 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with SELF for \"Frame_41\" on Task_4\n" ) 746 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 747 nSearchFlags = FrameSearchFlag::SELF; 748 xSearchFrame = xTask_4->findFrame(sTargetFrameName, nSearchFlags); 749 LOG_ASSERT( !(xSearchFrame.is()==sal_True), "TestApplication::impl_testDesktop()\nSearch 3c)-5 invalid\n" ); 750 751 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 752 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with SIBLINGS for \"Frame_41\" on Task_4\n" ) 753 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 754 nSearchFlags = FrameSearchFlag::SIBLINGS; 755 xSearchFrame = xTask_4->findFrame(sTargetFrameName, nSearchFlags); 756 LOG_ASSERT( !(xSearchFrame.is()==sal_True), "TestApplication::impl_testDesktop()\nSearch 3c)-6 invalid\n" ); 757 758 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 759 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with CHILDREN for \"Frame_41\" on Task_4\n" ) 760 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 761 nSearchFlags = FrameSearchFlag::CHILDREN; 762 xSearchFrame = xTask_4->findFrame(sTargetFrameName, nSearchFlags); 763 LOG_ASSERT( !(xSearchFrame.is()==sal_False), "TestApplication::impl_testDesktop()\nSearch 3c)-7 invalid\n" ); 764 765 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 766 WRITE_LOGFILE( LOGFILE_TARGETING, " Search with ALL for \"Frame_41\" on Task_4\n" ) 767 WRITE_LOGFILE( LOGFILE_TARGETING, "--------------------------------------------------------------------------------\n" ) 768 nSearchFlags = FrameSearchFlag::ALL; 769 xSearchFrame = xTask_4->findFrame(sTargetFrameName, nSearchFlags); 770 LOG_ASSERT( !(xSearchFrame.is()==sal_False), "TestApplication::impl_testDesktop()\nSearch 3c)-8 invalid\n" ); 771 772 xFrame_41 = xSearchFrame; 773 774 // 3d) Search for Frame_411 775 // 3e) Search for Frame_112 776 // 3f) Search for Frame_1123 777 // 3g) Search for Frame_11231 778 // 3h) Search for Frame_11221 779 } 780 781 //_________________________________________________________________________________________________________________ 782 // helper method to build a new binaer-tree with desktop as top-frame 783 //_________________________________________________________________________________________________________________ 784 void TestApplication::impl_buildTree( const Reference< XDesktop >& xDesktop ) 785 { 786 // You can append and remove frames only on XFRames interface of desktop. 787 // But the desktop support this interface not directly! Use getFrames() instantly. 788 Reference< XFramesSupplier > xDesktopSupplier( xDesktop, UNO_QUERY ); 789 Reference< XFrames > xFrames = xDesktopSupplier->getFrames(); 790 LOG_ASSERT( !(xFrames.is()==sal_False), "TestApplication::impl_buildTree()\nCan't get framesaccess on desktop.\n\n" ) 791 792 // Create some tasks and frames. 793 Reference< XMultiServiceFactory > xServiceManager( getProcessServiceFactory() ); 794 795 Reference< XTask > xTask_1( xServiceManager->createInstance(SERVICENAME_TASK), UNO_QUERY ); 796 Reference< XTask > xTask_2( xServiceManager->createInstance(SERVICENAME_TASK), UNO_QUERY ); 797 Reference< XTask > xTask_3( xServiceManager->createInstance(SERVICENAME_TASK), UNO_QUERY ); 798 Reference< XTask > xTask_4( xServiceManager->createInstance(SERVICENAME_TASK), UNO_QUERY ); 799 Reference< XTask > xTask_5( xServiceManager->createInstance(SERVICENAME_TASK), UNO_QUERY ); 800 Reference< XFrame > xFrame_11( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 801 Reference< XFrame > xFrame_12( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 802 Reference< XFrame > xFrame_21( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 803 Reference< XFrame > xFrame_22( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 804 Reference< XFrame > xFrame_31( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 805 Reference< XFrame > xFrame_32( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 806 Reference< XFrame > xFrame_41( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 807 Reference< XFrame > xFrame_42( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 808 Reference< XFrame > xFrame_51( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 809 Reference< XFrame > xFrame_52( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 810 Reference< XFrame > xFrame_111( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 811 Reference< XFrame > xFrame_112( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 812 Reference< XFrame > xFrame_121( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 813 Reference< XFrame > xFrame_411( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 814 Reference< XFrame > xFrame_1121( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 815 Reference< XFrame > xFrame_1122( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 816 Reference< XFrame > xFrame_1123( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 817 Reference< XFrame > xFrame_4111( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 818 Reference< XFrame > xFrame_4112( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 819 Reference< XFrame > xFrame_4113( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 820 Reference< XFrame > xFrame_11221( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 821 Reference< XFrame > xFrame_11231( xServiceManager->createInstance(SERVICENAME_FRAME), UNO_QUERY ); 822 823 // Initialize tasks and frames with names to support easy finding! 824 Reference< XFrame > xTaskFrame_1( xTask_1, UNO_QUERY ); 825 Reference< XFrame > xTaskFrame_2( xTask_2, UNO_QUERY ); 826 Reference< XFrame > xTaskFrame_3( xTask_3, UNO_QUERY ); 827 Reference< XFrame > xTaskFrame_4( xTask_4, UNO_QUERY ); 828 Reference< XFrame > xTaskFrame_5( xTask_5, UNO_QUERY ); 829 830 xTaskFrame_1->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Task_1"))); 831 xTaskFrame_2->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Task_2"))); 832 xTaskFrame_3->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Task_3"))); 833 xTaskFrame_4->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Task_4"))); 834 xTaskFrame_5->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Task_5"))); 835 xFrame_11->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_11"))); 836 xFrame_12->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_12"))); 837 xFrame_21->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_21"))); 838 xFrame_22->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_22"))); 839 xFrame_31->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_31"))); 840 xFrame_32->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_32"))); 841 xFrame_41->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_41"))); 842 xFrame_42->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_42"))); 843 xFrame_51->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_51"))); 844 xFrame_52->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_52"))); 845 xFrame_111->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_111"))); 846 xFrame_112->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_112"))); 847 xFrame_121->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_121"))); 848 xFrame_411->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_411"))); 849 xFrame_1121->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_1121"))); 850 xFrame_1122->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_1122"))); 851 xFrame_1123->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_1123"))); 852 xFrame_4111->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_4111"))); 853 xFrame_4112->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_4112"))); 854 xFrame_4113->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_4113"))); 855 xFrame_11221->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_11221"))); 856 xFrame_11231->setName(OUString(RTL_CONSTASCII_USTRINGPARAM("Frame_11231"))); 857 858 // Build tree. 859 // Append tasks as childs of desktop. 860 xFrames->append( xTaskFrame_1 ); 861 xFrames->append( xTaskFrame_2 ); 862 xFrames->append( xTaskFrame_3 ); 863 xFrames->append( xTaskFrame_4 ); 864 xFrames->append( xTaskFrame_5 ); 865 866 // Append frames as childs of tasks. 867 Reference< XFramesSupplier > xTaskFramesSupplier_1( xTask_1, UNO_QUERY ); 868 Reference< XFramesSupplier > xTaskFramesSupplier_2( xTask_2, UNO_QUERY ); 869 Reference< XFramesSupplier > xTaskFramesSupplier_3( xTask_3, UNO_QUERY ); 870 Reference< XFramesSupplier > xTaskFramesSupplier_4( xTask_4, UNO_QUERY ); 871 Reference< XFramesSupplier > xTaskFramesSupplier_5( xTask_5, UNO_QUERY ); 872 Reference< XFramesSupplier > xFramesSupplier_11( xFrame_11, UNO_QUERY ); 873 Reference< XFramesSupplier > xFramesSupplier_12( xFrame_12, UNO_QUERY ); 874 Reference< XFramesSupplier > xFramesSupplier_112( xFrame_112, UNO_QUERY ); 875 Reference< XFramesSupplier > xFramesSupplier_1122( xFrame_1122, UNO_QUERY ); 876 Reference< XFramesSupplier > xFramesSupplier_1123( xFrame_1123, UNO_QUERY ); 877 Reference< XFramesSupplier > xFramesSupplier_41( xFrame_41, UNO_QUERY ); 878 Reference< XFramesSupplier > xFramesSupplier_411( xFrame_411, UNO_QUERY ); 879 880 xFrames = xTaskFramesSupplier_1->getFrames(); 881 xFrames->append( xFrame_11 ); 882 xFrames->append( xFrame_12 ); 883 xFrames = xTaskFramesSupplier_2->getFrames(); 884 xFrames->append( xFrame_21 ); 885 xFrames->append( xFrame_22 ); 886 xFrames = xTaskFramesSupplier_3->getFrames(); 887 xFrames->append( xFrame_31 ); 888 xFrames->append( xFrame_32 ); 889 xFrames = xTaskFramesSupplier_4->getFrames(); 890 xFrames->append( xFrame_41 ); 891 xFrames->append( xFrame_42 ); 892 xFrames = xTaskFramesSupplier_5->getFrames(); 893 xFrames->append( xFrame_51 ); 894 xFrames->append( xFrame_52 ); 895 xFrames = xFramesSupplier_11->getFrames(); 896 xFrames->append( xFrame_111 ); 897 xFrames->append( xFrame_112 ); 898 xFrames = xFramesSupplier_12->getFrames(); 899 xFrames->append( xFrame_121 ); 900 xFrames = xFramesSupplier_112->getFrames(); 901 xFrames->append( xFrame_1121 ); 902 xFrames->append( xFrame_1122 ); 903 xFrames->append( xFrame_1123 ); 904 xFrames = xFramesSupplier_1122->getFrames(); 905 xFrames->append( xFrame_11221 ); 906 xFrames = xFramesSupplier_1123->getFrames(); 907 xFrames->append( xFrame_11231 ); 908 xFrames = xFramesSupplier_41->getFrames(); 909 xFrames->append( xFrame_411 ); 910 xFrames = xFramesSupplier_411->getFrames(); 911 xFrames->append( xFrame_4111 ); 912 xFrames->append( xFrame_4112 ); 913 xFrames->append( xFrame_4113 ); 914 915 // Create some active paths. 916 // desktop => task_1 => frame_11 => frame_112 => frame_1122 917 // xDesktopSupplier->setActiveFrame( xTaskFrame_1 ); 918 // xTaskFramesSupplier_1->setActiveFrame( xFrame_11 ); 919 // xFramesSupplier_11->setActiveFrame( xFrame_112 ); 920 // xFramesSupplier_112->setActiveFrame( xFrame_1122 ); 921 // frame_41 => frame_411 => frame_4111 922 // xFramesSupplier_41->setActiveFrame( xFrame_411 ); 923 // xFramesSupplier_411->setActiveFrame( xFrame_4111 ); 924 // task_3 => frame_31 925 // xTaskFramesSupplier_3->setActiveFrame( xFrame_31 ); 926 // frame_1123 => frame_11231 927 // xFramesSupplier_1123->setActiveFrame( xFrame_11231 ); 928 929 // xTask_1->activate(); 930 // impl_logTree( xDesktop ); 931 // xFrame_41->activate(); 932 // impl_logTree( xDesktop ); 933 // xFrame_52->activate(); 934 // impl_logTree( xDesktop ); 935 // WRITE_LOGFILE( LOGFILENAME_TREE, "initiale Hierarchy:" ) 936 impl_logTree( xDesktop ); 937 938 // xFrame_121->activate(); 939 // impl_logTree( xDesktop ); 940 // xFrame_41->activate(); 941 // impl_logTree( xDesktop ); 942 // xFrame_52->activate(); 943 // impl_logTree( xDesktop ); 944 // WRITE_LOGFILE( LOGFILENAME_EVENTS, "nach xFrame_411->activate():" ) 945 xFrame_411->activate(); 946 // WRITE_LOGFILE( LOGFILENAME_TREE, "nach xFrame_411->activate():" ) 947 impl_logTree( xDesktop ); 948 // xFrame_41->deactivate(); 949 // impl_logTree( xDesktop ); 950 // xFrame_4113->activate(); 951 // impl_logTree( xDesktop ); 952 // xFrame_21->activate(); 953 // impl_logTree( xDesktop ); 954 // WRITE_LOGFILE( LOGFILENAME_EVENTS, "nach xFrame_11231->activate():" ) 955 xFrame_11231->activate(); 956 // WRITE_LOGFILE( LOGFILENAME_TREE, "nach xFrame_11231->activate():" ) 957 impl_logTree( xDesktop ); 958 959 // WRITE_LOGFILE( LOGFILENAME_EVENTS, "nach xFrame_11221->activate():" ) 960 xFrame_11221->activate(); 961 // WRITE_LOGFILE( LOGFILENAME_TREE, "nach xFrame_11221->activate():" ) 962 impl_logTree( xDesktop ); 963 964 // WRITE_LOGFILE( LOGFILENAME_EVENTS, "nach xFrame_112->deactivate():" ) 965 // xFrame_112->getCreator()->setActiveFrame( Reference< XFrame >() ); 966 xFrame_112->deactivate(); 967 // WRITE_LOGFILE( LOGFILENAME_TREE, "nach xFrame_112->deactivate():" ) 968 impl_logTree( xDesktop ); 969 970 // WRITE_LOGFILE( LOGFILENAME_EVENTS, "nach xFrame_41->activate():" ) 971 xFrame_41->activate(); 972 // WRITE_LOGFILE( LOGFILENAME_TREE, "nach xFrame_41->activate():" ) 973 impl_logTree( xDesktop ); 974 975 // WRITE_LOGFILE( LOGFILENAME_EVENTS, "nach xTask_4->activate():" ) 976 xTask_4->activate(); 977 // WRITE_LOGFILE( LOGFILENAME_TREE, "nach xTask_4->activate():" ) 978 impl_logTree( xDesktop ); 979 980 // WRITE_LOGFILE( LOGFILENAME_EVENTS, "nach xFrame_1123->deactivate():" ) 981 xFrame_1123->deactivate(); 982 // WRITE_LOGFILE( LOGFILENAME_TREE, "nach xFrame_1123->deactivate():" ) 983 impl_logTree( xDesktop ); 984 } 985 986 //_________________________________________________________________________________________________________________ 987 // helper method to log current tree state 988 //_________________________________________________________________________________________________________________ 989 void TestApplication::impl_logTree( const Reference< XDesktop >& xDesktop ) 990 { 991 #ifdef ENABLE_SERVICEDEBUG 992 // Use special feature of Desktop-implementation. 993 // NEVER USE THIS IN RELEASE VERSIONS!!! 994 Reference< XSPECIALDEBUGINTERFACE > xDebug( xDesktop, UNO_QUERY ); 995 996 // Get a "stream" of all names of frames in tree. 997 OUString sTreeNamesStream = xDebug->dumpVariable( DUMPVARIABLE_TREEINFO, 0 ); 998 // And write it to logfile. 999 OString sOutPut = OUStringToOString( sTreeNamesStream, RTL_TEXTENCODING_UTF8 ); 1000 // WRITE_LOGFILE( LOGFILENAME_TREE, "\nNew tree log:\n\n" ); 1001 // WRITE_LOGFILE( LOGFILENAME_TREE, sOutPut ); 1002 // WRITE_LOGFILE( LOGFILENAME_TREE, "\n" ); 1003 #endif 1004 } 1005 #endif // TEST_DESKTOP 1006 1007 //_________________________________________________________________________________________________________________ 1008 // test method for registration of new filters in configuration 1009 //_________________________________________________________________________________________________________________ 1010 #ifdef TEST_FILTERREGISTRATION 1011 void TestApplication::impl_testFilterRegistration() 1012 { 1013 Reference< XNameContainer > xContainer( m_xFactory->createInstance( SERVICENAME_FILTERFACTORY ), UNO_QUERY ); 1014 LOG_ASSERT( !(xContainer.is()==sal_False), "TestApplication::impl_testFilterRegistration()\nCould not create FilterFactory-service or cast it to XNameContainer.\n" ) 1015 if( xContainer.is() == sal_True ) 1016 { 1017 Sequence< PropertyValue > lProperties( 8 ); 1018 1019 lProperties[0].Name = DECLARE_ASCII("Type" ); 1020 lProperties[0].Value <<= DECLARE_ASCII("component_DB" ); 1021 1022 lProperties[1].Name = DECLARE_ASCII("UIName" ); 1023 lProperties[1].Value <<= DECLARE_ASCII("Ein neuer Filter-Eintrag"); 1024 1025 lProperties[2].Name = DECLARE_ASCII("DocumentService" ); 1026 lProperties[2].Value <<= DECLARE_ASCII("test.document.service" ); 1027 1028 lProperties[3].Name = DECLARE_ASCII("FilterService" ); 1029 lProperties[3].Value <<= DECLARE_ASCII("test.filter.service" ); 1030 1031 lProperties[4].Name = DECLARE_ASCII("Flags" ); 1032 lProperties[4].Value <<= (sal_Int32)100; 1033 1034 Sequence< OUString > lTempData(1); 1035 lTempData[0] = DECLARE_ASCII("meine UserData"); 1036 lProperties[5].Name = DECLARE_ASCII("UserData" ); 1037 lProperties[5].Value <<= lTempData; 1038 1039 lProperties[6].Name = DECLARE_ASCII("FileFormatVersion" ); 1040 lProperties[6].Value <<= (sal_Int32)1; 1041 1042 lProperties[7].Name = DECLARE_ASCII("TemplateName" ); 1043 lProperties[7].Value <<= DECLARE_ASCII("Mein Template Name" ); 1044 1045 Any aProperties; 1046 aProperties <<= lProperties; 1047 xContainer->insertByName( DECLARE_ASCII("mein_eigener_neuer_Filter"), aProperties ); 1048 1049 lProperties[0].Name = DECLARE_ASCII("Type" ); 1050 lProperties[0].Value <<= DECLARE_ASCII("component_DB" ); 1051 1052 lProperties[1].Name = DECLARE_ASCII("UIName" ); 1053 lProperties[1].Value <<= DECLARE_ASCII("Ein neuer Filter-Eintrag 2"); 1054 1055 lProperties[2].Name = DECLARE_ASCII("DocumentService" ); 1056 lProperties[2].Value <<= DECLARE_ASCII("test.document.service 2" ); 1057 1058 lProperties[3].Name = DECLARE_ASCII("FilterService" ); 1059 lProperties[3].Value <<= DECLARE_ASCII("test.filter.service 2" ); 1060 1061 lProperties[4].Name = DECLARE_ASCII("Flags" ); 1062 lProperties[4].Value <<= (sal_Int32)200; 1063 1064 lTempData[0] = DECLARE_ASCII("meine UserData 2"); 1065 lProperties[5].Name = DECLARE_ASCII("UserData" ); 1066 lProperties[5].Value <<= lTempData; 1067 1068 lProperties[6].Name = DECLARE_ASCII("FileFormatVersion" ); 1069 lProperties[6].Value <<= (sal_Int32)2; 1070 1071 lProperties[7].Name = DECLARE_ASCII("TemplateName" ); 1072 lProperties[7].Value <<= DECLARE_ASCII("Mein Template Name 2" ); 1073 1074 aProperties <<= lProperties; 1075 xContainer->insertByName( DECLARE_ASCII("mein_eigener_neuer_Filter_2"), aProperties ); 1076 1077 xContainer->removeByName( DECLARE_ASCII("mein_eigener_neuer_Filter") ); 1078 } 1079 } 1080 #endif 1081 1082 //_________________________________________________________________________________________________________________ 1083 // test method for search mechanism in our frame tree 1084 //_________________________________________________________________________________________________________________ 1085 #ifdef TEST_TREESEARCH 1086 sal_Bool TestApplication::impl_testTreeSearch() 1087 { 1088 // Build an example tree. 1089 Reference< XFrame > xD ( m_xFactory->createInstance( SERVICENAME_DESKTOP ), UNO_QUERY ); 1090 Reference< XFrame > xT1 ( m_xFactory->createInstance( SERVICENAME_TASK ), UNO_QUERY ); 1091 Reference< XFrame > xT2 ( m_xFactory->createInstance( SERVICENAME_TASK ), UNO_QUERY ); 1092 Reference< XFrame > xT3 ( m_xFactory->createInstance( SERVICENAME_TASK ), UNO_QUERY ); 1093 Reference< XFrame > xF11 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1094 Reference< XFrame > xF12 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1095 Reference< XFrame > xF21 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1096 Reference< XFrame > xF22 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1097 Reference< XFrame > xF211 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1098 Reference< XFrame > xF212 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1099 Reference< XFrame > xF221 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1100 Reference< XFrame > xF2111 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1101 Reference< XFrame > xF2112 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1102 Reference< XFrame > xF2121 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1103 Reference< XFrame > xF2122 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1104 Reference< XFrame > xF2211 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1105 Reference< XFrame > xF21111 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1106 Reference< XFrame > xF21112 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1107 Reference< XFrame > xF21121 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1108 Reference< XFrame > xF21122 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1109 Reference< XFrame > xF21211 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1110 Reference< XFrame > xF21212 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1111 Reference< XFrame > xF21221 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1112 Reference< XFrame > xF21222 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1113 Reference< XFrame > xF22111 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY ); 1114 1115 xD->setName ( DECLARE_ASCII("D" ) ); 1116 xT1->setName ( DECLARE_ASCII("T1" ) ); 1117 xT2->setName ( DECLARE_ASCII("T2" ) ); 1118 xT3->setName ( DECLARE_ASCII("T3" ) ); 1119 xF11->setName ( DECLARE_ASCII("F11" ) ); 1120 xF12->setName ( DECLARE_ASCII("F12" ) ); 1121 xF21->setName ( DECLARE_ASCII("F21" ) ); 1122 xF22->setName ( DECLARE_ASCII("F22" ) ); 1123 xF211->setName ( DECLARE_ASCII("F211" ) ); 1124 xF212->setName ( DECLARE_ASCII("F212" ) ); 1125 xF221->setName ( DECLARE_ASCII("F221" ) ); 1126 xF2111->setName ( DECLARE_ASCII("F2111" ) ); 1127 xF2112->setName ( DECLARE_ASCII("F2112" ) ); 1128 xF2121->setName ( DECLARE_ASCII("F2121" ) ); 1129 xF2122->setName ( DECLARE_ASCII("F2122" ) ); 1130 xF2211->setName ( DECLARE_ASCII("F2211" ) ); 1131 xF21111->setName( DECLARE_ASCII("F21111") ); 1132 xF21112->setName( DECLARE_ASCII("F21112") ); 1133 xF21121->setName( DECLARE_ASCII("F21121") ); 1134 xF21122->setName( DECLARE_ASCII("F21122") ); 1135 xF21211->setName( DECLARE_ASCII("F21211") ); 1136 xF21212->setName( DECLARE_ASCII("F21212") ); 1137 xF21221->setName( DECLARE_ASCII("F21221") ); 1138 xF21222->setName( DECLARE_ASCII("F21222") ); 1139 xF22111->setName( DECLARE_ASCII("F22111") ); 1140 1141 Reference< XFramesSupplier > xSD ( xD , UNO_QUERY ); 1142 Reference< XFramesSupplier > xST1 ( xT1 , UNO_QUERY ); 1143 Reference< XFramesSupplier > xST2 ( xT2 , UNO_QUERY ); 1144 Reference< XFramesSupplier > xST3 ( xT3 , UNO_QUERY ); 1145 Reference< XFramesSupplier > xSF11 ( xF11 , UNO_QUERY ); 1146 Reference< XFramesSupplier > xSF12 ( xF12 , UNO_QUERY ); 1147 Reference< XFramesSupplier > xSF21 ( xF21 , UNO_QUERY ); 1148 Reference< XFramesSupplier > xSF22 ( xF22 , UNO_QUERY ); 1149 Reference< XFramesSupplier > xSF211 ( xF211 , UNO_QUERY ); 1150 Reference< XFramesSupplier > xSF212 ( xF212 , UNO_QUERY ); 1151 Reference< XFramesSupplier > xSF221 ( xF221 , UNO_QUERY ); 1152 Reference< XFramesSupplier > xSF2111 ( xF2111 , UNO_QUERY ); 1153 Reference< XFramesSupplier > xSF2112 ( xF2112 , UNO_QUERY ); 1154 Reference< XFramesSupplier > xSF2121 ( xF2121 , UNO_QUERY ); 1155 Reference< XFramesSupplier > xSF2122 ( xF2122 , UNO_QUERY ); 1156 Reference< XFramesSupplier > xSF2211 ( xF2211 , UNO_QUERY ); 1157 Reference< XFramesSupplier > xSF21111 ( xF21111 , UNO_QUERY ); 1158 Reference< XFramesSupplier > xSF21112 ( xF21112 , UNO_QUERY ); 1159 Reference< XFramesSupplier > xSF21121 ( xF21121 , UNO_QUERY ); 1160 Reference< XFramesSupplier > xSF21122 ( xF21122 , UNO_QUERY ); 1161 Reference< XFramesSupplier > xSF21211 ( xF21211 , UNO_QUERY ); 1162 Reference< XFramesSupplier > xSF21212 ( xF21212 , UNO_QUERY ); 1163 Reference< XFramesSupplier > xSF21221 ( xF21221 , UNO_QUERY ); 1164 Reference< XFramesSupplier > xSF21222 ( xF21222 , UNO_QUERY ); 1165 Reference< XFramesSupplier > xSF22111 ( xF22111 , UNO_QUERY ); 1166 1167 xSD->getFrames()->append ( xT1 ); 1168 xSD->getFrames()->append ( xT2 ); 1169 xSD->getFrames()->append ( xT3 ); 1170 xST1->getFrames()->append ( xF11 ); 1171 xST1->getFrames()->append ( xF12 ); 1172 xST2->getFrames()->append ( xF21 ); 1173 xST2->getFrames()->append ( xF22 ); 1174 xSF21->getFrames()->append ( xF211 ); 1175 xSF21->getFrames()->append ( xF212 ); 1176 xSF211->getFrames()->append ( xF2111 ); 1177 xSF211->getFrames()->append ( xF2112 ); 1178 xSF212->getFrames()->append ( xF2121 ); 1179 xSF212->getFrames()->append ( xF2122 ); 1180 xSF2111->getFrames()->append ( xF21111 ); 1181 xSF2111->getFrames()->append ( xF21112 ); 1182 xSF2112->getFrames()->append ( xF21121 ); 1183 xSF2112->getFrames()->append ( xF21122 ); 1184 xSF2121->getFrames()->append ( xF21211 ); 1185 xSF2121->getFrames()->append ( xF21212 ); 1186 xSF2122->getFrames()->append ( xF21221 ); 1187 xSF2122->getFrames()->append ( xF21222 ); 1188 xSF22->getFrames()->append ( xF221 ); 1189 xSF221->getFrames()->append ( xF2211 ); 1190 xSF2211->getFrames()->append ( xF22111 ); 1191 1192 sal_Int32 nFlags = 0; 1193 1194 // Test deep down search 1195 nFlags = FrameSearchFlag::CHILDREN; 1196 if ( 1197 ( xD->findFrame( DECLARE_ASCII("T1" ), nFlags ) != xT1 ) || 1198 ( xD->findFrame( DECLARE_ASCII("T2" ), nFlags ) != xT2 ) || 1199 ( xD->findFrame( DECLARE_ASCII("T3" ), nFlags ) != xT3 ) || 1200 ( xD->findFrame( DECLARE_ASCII("F11" ), nFlags ) != xF11 ) || 1201 ( xD->findFrame( DECLARE_ASCII("F12" ), nFlags ) != xF12 ) || 1202 ( xD->findFrame( DECLARE_ASCII("F21" ), nFlags ) != xF21 ) || 1203 ( xD->findFrame( DECLARE_ASCII("F22" ), nFlags ) != xF22 ) || 1204 ( xD->findFrame( DECLARE_ASCII("F211" ), nFlags ) != xF211 ) || 1205 ( xD->findFrame( DECLARE_ASCII("F212" ), nFlags ) != xF212 ) || 1206 ( xD->findFrame( DECLARE_ASCII("F2111" ), nFlags ) != xF2111 ) || 1207 ( xD->findFrame( DECLARE_ASCII("F2112" ), nFlags ) != xF2112 ) || 1208 ( xD->findFrame( DECLARE_ASCII("F2121" ), nFlags ) != xF2121 ) || 1209 ( xD->findFrame( DECLARE_ASCII("F2122" ), nFlags ) != xF2122 ) || 1210 ( xD->findFrame( DECLARE_ASCII("F21111" ), nFlags ) != xF21111 ) || 1211 ( xD->findFrame( DECLARE_ASCII("F21112" ), nFlags ) != xF21112 ) || 1212 ( xD->findFrame( DECLARE_ASCII("F21121" ), nFlags ) != xF21121 ) || 1213 ( xD->findFrame( DECLARE_ASCII("F21122" ), nFlags ) != xF21122 ) || 1214 ( xD->findFrame( DECLARE_ASCII("F21211" ), nFlags ) != xF21211 ) || 1215 ( xD->findFrame( DECLARE_ASCII("F21212" ), nFlags ) != xF21212 ) || 1216 ( xD->findFrame( DECLARE_ASCII("F21221" ), nFlags ) != xF21221 ) || 1217 ( xD->findFrame( DECLARE_ASCII("F21222" ), nFlags ) != xF21222 ) || 1218 ( xD->findFrame( DECLARE_ASCII("F221" ), nFlags ) != xF221 ) || 1219 ( xD->findFrame( DECLARE_ASCII("F2211" ), nFlags ) != xF2211 ) || 1220 ( xD->findFrame( DECLARE_ASCII("F22111" ), nFlags ) != xF22111 ) 1221 ) 1222 { 1223 LOG_ERROR( "TestApplikation::impl_testTreeSearch()", "deep down search failed" ) 1224 return sal_False; 1225 } 1226 1227 // Test flat down search 1228 nFlags = FrameSearchFlag::CHILDREN | FrameSearchFlag::SIBLINGS; 1229 if ( 1230 ( xD->findFrame( DECLARE_ASCII("T1" ), nFlags ) != xT1 ) || 1231 ( xD->findFrame( DECLARE_ASCII("T2" ), nFlags ) != xT2 ) || 1232 ( xD->findFrame( DECLARE_ASCII("T3" ), nFlags ) != xT3 ) || 1233 ( xD->findFrame( DECLARE_ASCII("F11" ), nFlags ) != xF11 ) || 1234 ( xD->findFrame( DECLARE_ASCII("F12" ), nFlags ) != xF12 ) || 1235 ( xD->findFrame( DECLARE_ASCII("F21" ), nFlags ) != xF21 ) || 1236 ( xD->findFrame( DECLARE_ASCII("F22" ), nFlags ) != xF22 ) || 1237 ( xD->findFrame( DECLARE_ASCII("F211" ), nFlags ) != xF211 ) || 1238 ( xD->findFrame( DECLARE_ASCII("F212" ), nFlags ) != xF212 ) || 1239 ( xD->findFrame( DECLARE_ASCII("F2111" ), nFlags ) != xF2111 ) || 1240 ( xD->findFrame( DECLARE_ASCII("F2112" ), nFlags ) != xF2112 ) || 1241 ( xD->findFrame( DECLARE_ASCII("F2121" ), nFlags ) != xF2121 ) || 1242 ( xD->findFrame( DECLARE_ASCII("F2122" ), nFlags ) != xF2122 ) || 1243 ( xD->findFrame( DECLARE_ASCII("F21111" ), nFlags ) != xF21111 ) || 1244 ( xD->findFrame( DECLARE_ASCII("F21112" ), nFlags ) != xF21112 ) || 1245 ( xD->findFrame( DECLARE_ASCII("F21121" ), nFlags ) != xF21121 ) || 1246 ( xD->findFrame( DECLARE_ASCII("F21122" ), nFlags ) != xF21122 ) || 1247 ( xD->findFrame( DECLARE_ASCII("F21211" ), nFlags ) != xF21211 ) || 1248 ( xD->findFrame( DECLARE_ASCII("F21212" ), nFlags ) != xF21212 ) || 1249 ( xD->findFrame( DECLARE_ASCII("F21221" ), nFlags ) != xF21221 ) || 1250 ( xD->findFrame( DECLARE_ASCII("F21222" ), nFlags ) != xF21222 ) || 1251 ( xD->findFrame( DECLARE_ASCII("F221" ), nFlags ) != xF221 ) || 1252 ( xD->findFrame( DECLARE_ASCII("F2211" ), nFlags ) != xF2211 ) || 1253 ( xD->findFrame( DECLARE_ASCII("F22111" ), nFlags ) != xF22111 ) 1254 ) 1255 { 1256 LOG_ERROR( "TestApplikation::impl_testTreeSearch()", "flat down search failed" ) 1257 return sal_False; 1258 } 1259 1260 // Test deep up search 1261 // All targets must be found. Control search steps in log files! 1262 nFlags = FrameSearchFlag::PARENT; 1263 if ( 1264 ( xF11->findFrame ( DECLARE_ASCII("T1"), nFlags ) != xT1 ) || // search for valid targets 1265 ( xF12->findFrame ( DECLARE_ASCII("T1"), nFlags ) != xT1 ) || 1266 ( xF21->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1267 ( xF22->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1268 ( xF211->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1269 ( xF212->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1270 ( xF221->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1271 ( xF2111->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1272 ( xF2121->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1273 ( xF2122->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1274 ( xF2211->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1275 ( xF21111->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1276 ( xF21112->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1277 ( xF21121->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1278 ( xF21122->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1279 ( xF21211->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1280 ( xF21212->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1281 ( xF21221->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1282 ( xF21222->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1283 ( xF22111->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) || 1284 ( xF11->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || // search for existing but non valid targets 1285 ( xF12->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1286 ( xF21->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1287 ( xF22->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1288 ( xF211->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1289 ( xF212->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1290 ( xF221->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1291 ( xF2111->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1292 ( xF2121->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1293 ( xF2122->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1294 ( xF2211->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1295 ( xF21111->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1296 ( xF21112->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1297 ( xF21121->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1298 ( xF21122->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1299 ( xF21211->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1300 ( xF21212->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1301 ( xF21221->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1302 ( xF21222->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || 1303 ( xF22111->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) 1304 ) 1305 { 1306 LOG_ERROR( "TestApplikation::impl_testTreeSearch()", "deep up search failed" ) 1307 return sal_False; 1308 } 1309 1310 // Test inside/outside tasks search 1311 // No frames outside current task should be found if TASKS flag isnt set. 1312 // Otherwise he must be found! 1313 if ( 1314 ( xF21211->findFrame( DECLARE_ASCII("F12" ), FrameSearchFlag::ALL ) == xF12 ) || 1315 ( xF21211->findFrame( DECLARE_ASCII("F22111"), FrameSearchFlag::GLOBAL ) != xF22111 ) || 1316 ( xF21211->findFrame( DECLARE_ASCII("T4" ), FrameSearchFlag::GLOBAL | FrameSearchFlag::CREATE ).is() == sal_False) 1317 ) 1318 { 1319 LOG_ERROR( "TestApplikation::impl_testTreeSearch()", "inside/outside task search failed" ) 1320 return sal_False; 1321 } 1322 1323 // Test SELF 1324 // Use the desktop, one task and one frame node to do that. 1325 // The desktop must ignore these question ... all other must return himself. 1326 LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII(""), FrameSearchFlag::SELF ) == xD ), "TestApplication::impl_testTreeSearch()", "SELF search for D failed\n" ) 1327 LOG_ASSERT2( (xT1->findFrame ( DECLARE_ASCII(""), FrameSearchFlag::SELF ) != xT1 ), "TestApplication::impl_testTreeSearch()", "SELF search for T1 failed\n" ) 1328 LOG_ASSERT2( (xF12->findFrame ( DECLARE_ASCII(""), FrameSearchFlag::SELF ) != xF12 ), "TestApplication::impl_testTreeSearch()", "SELF search for F12 failed\n" ) 1329 1330 // Test special task search at desktop 1331 // These search allow TASKS and CREATE flags only! 1332 // We make no deep search - we work on direct children of desktop only. 1333 // Supported for desktop only. 1334 LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII("T1"), FrameSearchFlag::TASKS ) != xT1 ), "TestApplication::impl_testTreeSearch()", "special TASKS search for T1 failed\n" ) 1335 LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII("T2"), FrameSearchFlag::TASKS ) != xT2 ), "TestApplication::impl_testTreeSearch()", "special TASKS search for T2 failed\n" ) 1336 LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII("T3"), FrameSearchFlag::TASKS ) != xT3 ), "TestApplication::impl_testTreeSearch()", "special TASKS search for T3 failed\n" ) 1337 // Attention: T4 was created before! 1338 LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII("T5"), FrameSearchFlag::TASKS ).is() == sal_True ), "TestApplication::impl_testTreeSearch()", "special TASKS search for T5 failed\n" ) 1339 LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII("T5"), FrameSearchFlag::TASKS | FrameSearchFlag::CREATE ).is() == sal_False ), "TestApplication::impl_testTreeSearch()", "special TASKS+CREATE search for T5 failed\n" ) 1340 LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII("F12"), FrameSearchFlag::TASKS ).is() == sal_True ), "TestApplication::impl_testTreeSearch()", "special TASKS search for F12 failed\n" ) 1341 LOG_ASSERT2( (xF12->findFrame ( DECLARE_ASCII("T1"), FrameSearchFlag::TASKS ).is() == sal_True ), "TestApplication::impl_testTreeSearch()", "special TASKS search for T1 from F12 failed\n" ) 1342 LOG_ASSERT2( (xF22111->findFrame( DECLARE_ASCII("T1"), FrameSearchFlag::TASKS ).is() == sal_True ), "TestApplication::impl_testTreeSearch()", "special TASKS search for T1 from F22111 failed\n" ) 1343 1344 return sal_True; 1345 } 1346 #endif 1347