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