#81114# new tree search algorithm ...

This commit is contained in:
Andreas Schlüns 2001-03-09 13:42:26 +00:00
parent 9f4fd9ccf0
commit 250b51da7d
12 changed files with 1345 additions and 1259 deletions

View File

@ -2,9 +2,9 @@
*
* $RCSfile: framecontainer.hxx,v $
*
* $Revision: 1.6 $
* $Revision: 1.7 $
*
* last change: $Author: svesik $ $Date: 2001-02-12 13:12:34 $
* last change: $Author: as $ $Date: 2001-03-09 14:42:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -66,6 +66,10 @@
// my own includes
//_________________________________________________________________________________________________________________
#ifndef __FRAMEWORK_CLASSES_TARGETFINDER_HXX_
#include <classes/targetfinder.hxx>
#endif
#ifndef __FRAMEWORK_CLASSES_ASYNCQUIT_HXX_
#include <classes/asyncquit.hxx>
#endif
@ -98,6 +102,14 @@
#include <vos/ref.hxx>
#endif
#ifndef _RTL_USTRING_
#include <rtl/ustring>
#endif
#include <vector>
#include <stdexcept>
#include <algorithm>
//_________________________________________________________________________________________________________________
// namespace
//_________________________________________________________________________________________________________________
@ -107,8 +119,8 @@ namespace framework{
#define OREF ::vos::ORef
#define REFERENCE ::com::sun::star::uno::Reference
#define SEQUENCE ::com::sun::star::uno::Sequence
#define STLVECTOR ::std::vector
#define XFRAME ::com::sun::star::frame::XFrame
#define OUSTRING ::rtl::OUString
//_________________________________________________________________________________________________________________
// exported const
@ -118,6 +130,10 @@ namespace framework{
// exported definitions
//_________________________________________________________________________________________________________________
typedef ::std::vector< REFERENCE< XFRAME > > TFrameContainer ;
typedef TFrameContainer::iterator TFrameIterator ;
typedef TFrameContainer::const_iterator TConstFrameIterator ;
/*-************************************************************************************************************//**
@short implement a container to hold childs of frame, task or desktop
@descr Every object of frame, task or desktop hold reference to his childs. These container is used as helper
@ -222,7 +238,7 @@ class FrameContainer
@onerror We return sal_False.
*//*-*****************************************************************************************************/
sal_Bool exist( const REFERENCE< XFRAME >& xFrame );
sal_Bool exist( const REFERENCE< XFRAME >& xFrame ) const;
/*-****************************************************************************************************//**
@short clear the container and free memory
@ -381,6 +397,26 @@ class FrameContainer
void enableQuitTimer( const REFERENCE< XDESKTOP >& xDesktop );
void disableQuitTimer();
/*-****************************************************************************************************//**
@short implements default searches at children ...
@descr You CAN use these implementation or write your own code!
With these method we support a search for a target at your children.
@ATTENTION These methods never create a new tree node!
If searched target not exist we return NULL.
@seealso -
@param "sTargetName" This must be a non special target name. (_blank _self ... are not allowed! _beamer is a valid name!)
@return A reference to an existing frame or null if search failed.
@onerror A null reference is returned.
*//*-*****************************************************************************************************/
REFERENCE< XFRAME > searchDeepDown ( const OUSTRING& sName );
REFERENCE< XFRAME > searchFlatDown ( const OUSTRING& sName );
REFERENCE< XFRAME > searchDirectChildren ( const OUSTRING& sName );
//-------------------------------------------------------------------------------------------------------------
// protected methods
//-------------------------------------------------------------------------------------------------------------
@ -416,17 +452,120 @@ class FrameContainer
private:
sal_Bool impldbg_checkParameter_append ( const REFERENCE< XFRAME >& xFrame ) const;
sal_Bool impldbg_checkParameter_remove ( const REFERENCE< XFRAME >& xFrame ) const;
sal_Bool impldbg_checkParameter_exist ( const REFERENCE< XFRAME >& xFrame ) const;
sal_Bool impldbg_checkParameter_IndexOperator ( sal_uInt32 nIndex ) const;
sal_Bool impldbg_checkParameter_setActive ( const REFERENCE< XFRAME >& xFrame ) const;
//*********************************************************************************************************
// - check for NULL pointer or invalid references
inline sal_Bool implcp_append( const REFERENCE< XFRAME >& xFrame ) const
{
return (
( &xFrame == NULL ) ||
( xFrame.is() == sal_False )
);
}
// These method search for empty frames in our container.
// It's a programming error if someone found.
// But no error if given frame is the empty one(!) ...
// because it's allowed to "remove()" or "append()" (FOR A SHORT TIME!) a zombie but not to HAVE it already in container.
sal_Bool impldbg_lookForZombieFrames ( const REFERENCE< XFRAME >& xFrame ) const;
//*********************************************************************************************************
// - check for NULL pointer or invalid references only
// Don't look for Zombies here!
inline sal_Bool implcp_remove( const REFERENCE< XFRAME >& xFrame ) const
{
return (
( &xFrame == NULL ) ||
( xFrame.is() == sal_False )
);
}
//*********************************************************************************************************
// - check for NULL pointer or invalid references
inline sal_Bool implcp_exist( const REFERENCE< XFRAME >& xFrame ) const
{
return (
( &xFrame == NULL ) ||
( xFrame.is() == sal_False )
);
}
//*********************************************************************************************************
// - check if index out of range
inline sal_Bool implcp_IndexOperator( sal_uInt32 nIndex, sal_uInt32 nMax ) const
{
return (
( nIndex < 0 ) ||
( nIndex >= nMax )
);
}
//*********************************************************************************************************
// - check for NULL pointer or invalid references
inline sal_Bool implcp_setActive( const REFERENCE< XFRAME >& xFrame ) const
{
return (
( &xFrame == NULL ) ||
( xFrame.is() == sal_False )
);
}
//*********************************************************************************************************
// - check for null pointer
// - look for special target names ... some of them are not allowed as valid frame name
// Attention: "_beamer" is a valid name.
inline sal_Bool implcp_searchDeepDown( const OUSTRING& sName ) const
{
return (
( &sName == NULL ) ||
( sName == SPECIALTARGET_BLANK ) ||
( sName == SPECIALTARGET_SELF ) ||
( sName == SPECIALTARGET_TOP ) ||
( sName == SPECIALTARGET_PARENT )
);
}
//*********************************************************************************************************
// - check for null pointer
// - look for special target names ... some of them are not allowed as valid frame name
// Attention: "_beamer" is a valid name.
inline sal_Bool implcp_searchFlatDown( const OUSTRING& sName ) const
{
return (
( &sName == NULL ) ||
( sName == SPECIALTARGET_BLANK ) ||
( sName == SPECIALTARGET_SELF ) ||
( sName == SPECIALTARGET_TOP ) ||
( sName == SPECIALTARGET_PARENT )
);
}
//*********************************************************************************************************
// - check for null pointer
// - look for special target names ... some of them are not allowed as valid frame name
// Attention: "_beamer" is a valid name.
inline sal_Bool implcp_searchDirectChildren( const OUSTRING& sName ) const
{
return (
( &sName == NULL ) ||
( sName == SPECIALTARGET_BLANK ) ||
( sName == SPECIALTARGET_SELF ) ||
( sName == SPECIALTARGET_TOP ) ||
( sName == SPECIALTARGET_PARENT )
);
}
//*********************************************************************************************************
// Special debug mode.
// If these container closed - we should search for created zombie frames before.
// Sometimes a frame was inserted which hold no component inside!
// They are created by failed dispatch calls ...
inline sal_Bool impldbg_existZombie() const
{
sal_Bool bZombieExist = sal_False;
for( TConstFrameIterator pItem=m_aContainer.begin(); pItem!=m_aContainer.end(); ++pItem )
{
if( (*pItem)->getComponentWindow().is() == sal_False )
{
bZombieExist = sal_True;
break;
}
}
return bZombieExist;
}
#endif // #ifdef ENABLE_ASSERTIONS
@ -437,10 +576,10 @@ class FrameContainer
private:
sal_Bool m_bLock ; /// lock to block append()-, remove()- or clear()-calls
STLVECTOR< REFERENCE< XFRAME > > m_aContainer ; /// list to hold all frames
REFERENCE< XFRAME > m_xActiveFrame ; /// one container item can be the current active frame. Its neccessary for Desktop or Frame implementation.
OREF< AsyncQuit > m_rQuitTimer ; /// if an instance of these class used by desktop and last frame will be removed we must terminate the desktop
sal_Bool m_bLock ; /// lock to block append()-, remove()- or clear()-calls
TFrameContainer m_aContainer ; /// list to hold all frames
REFERENCE< XFRAME > m_xActiveFrame ; /// one container item can be the current active frame. Its neccessary for Desktop or Frame implementation.
OREF< AsyncQuit > m_rQuitTimer ; /// if an instance of these class used by desktop and last frame will be removed we must terminate the desktop
}; // class FrameContainer

View File

@ -2,9 +2,9 @@
*
* $RCSfile: targetfinder.hxx,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: as $ $Date: 2000-10-23 13:55:34 $
* last change: $Author: as $ $Date: 2001-03-09 14:42:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -82,10 +82,6 @@
#include <com/sun/star/frame/XFrame.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XFRAMES_HPP_
#include <com/sun/star/frame/XFrames.hpp>
#endif
//_________________________________________________________________________________________________________________
// other includes
//_________________________________________________________________________________________________________________
@ -107,7 +103,6 @@ namespace framework{
#define OUSTRING ::rtl::OUString
#define REFERENCE ::com::sun::star::uno::Reference
#define XFRAME ::com::sun::star::frame::XFrame
#define XFRAMES ::com::sun::star::frame::XFrames
//_________________________________________________________________________________________________________________
// declarations
@ -118,12 +113,12 @@ namespace framework{
(Frame/Task/PlugInFrame/Desktop ...)
*//*-*************************************************************************************************************/
enum IMPL_EFrameType
enum EFrameType
{
eFRAME ,
eTASK ,
ePLUGINFRAME ,
eDESKTOP
E_DESKTOP ,
E_PLUGINFRAME ,
E_TASK ,
E_FRAME
};
/*-************************************************************************************************************//**
@ -134,9 +129,9 @@ enum IMPL_EFrameType
#define SPECIALTARGET_SELF DECLARE_ASCII("_self" )
#define SPECIALTARGET_PARENT DECLARE_ASCII("_parent" )
#define SPECIALTARGET_TOP DECLARE_ASCII("_top" )
/* not supported in moment!
#define SPECIALTARGET_DOCUMENT DECLARE_ASCII("_document" )
#define SPECIALTARGET_BEAMER DECLARE_ASCII("_beamer" )
/* not supported yet!
#define SPECIALTARGET_DOCUMENT DECLARE_ASCII("_document" )
#define SPECIALTARGET_EXPLORER DECLARE_ASCII("_explorer" )
#define SPECIALTARGET_PARTWINDOW DECLARE_ASCII("_partwindow" )
*/
@ -145,16 +140,19 @@ enum IMPL_EFrameType
@short valid result values to classify targeting
*//*-*************************************************************************************************************/
enum IMPL_ETargetClass
enum ETargetClass
{
eUNKNOWN , /// given parameter are invalid - there is no chance to find these target!
eCREATE , /// a new target must create
eSELF , /// you are the target himself
ePARENT , /// your direct parent is the target!
eUP , /// search target at parents only
eDOWN , /// search target at childrens only
eSIBLINGS , /// search target at parents and his childrens ... but not at your children!
eALL /// react first for eCHILDRENS and then for eSIBLINGS! (protect your code against recursive calls from bottom or top!)
E_UNKNOWN , /// occure if you call us without valid flag combinations!
E_CREATETASK , /// create new task (supported by desktop only!)
E_SELF , /// you are the target himself
E_PARENT , /// your parent is the target
E_BEAMER , /// an existing beamer is the target (create new one if it not already exist!)
E_TASKS , /// special (but exclusiv) search for tasks only (supported at desktop only - but can combined with CREATE!)
E_FORWARD_UP , /// forward call to your parent
E_DEEP_DOWN , /// search at your children (search children of direct children before another direcht children!)
E_FLAT_DOWN , /// search at your children (search at all direct children first; children of direcht children then!)
E_DEEP_BOTH , /// combination of E_DEEP_DOWN and E_FORWARD_UP ( search down first!)
E_FLAT_BOTH /// combination of E_FLAT_DOWN and E_FORWARD_UP ( search down first!)
};
/*-************************************************************************************************************//**
@ -207,41 +205,79 @@ class TargetFinder
@short get a recommendation for searching right target
@descr Our caller search for a target which match with given parameter.
Give him a direction to find the right one.
These method never create or return a tree node! Thats your job!
We say: go up, go down or give you the permission to create new frame if search will fail!
@seealso -
@param "xOwner"; We need a reference to our caller to get some special informations about his environment
@param "sTargetName"; This is the search parameter to find right frame by name or special value!
@param "nSearchFlags"; These are optional parameter to regulate search direction.
@param "eFrameType" Give us your node type (desktop, task ,frame) Its neccessary to select right search algorithm.
@param "sTargetName" This is the search parameter to find right frame by name or special value!
@param "nSearchFlags" This value is an optional parameter to regulate search direction if no special target name was given.
@param "bCreationAllowed" We set it TRUE if flag TASKS is set. You must search for given target, but could create a new tree node if search will fail!
@param "bChildrenExist" Say us - if some children exist. Otherwise down search is ignored!
@param "bParentExist" Say us - if a parent exist. Otherwise upper search is ignored!
@param "sFrameName" If SELF flag is set we can break search earlier if this name is the target!
@param "sParentName" If PARENT flag is set we can break search earlier if this name is the target!
@return An enum value to classify the direction for searching.
@onerror eUNKNOWN is returned.
@onerror E_UNKNOWN is returned.
*//*-*****************************************************************************************************/
static IMPL_ETargetClass classify( const REFERENCE< XFRAME >& xOwner ,
const OUSTRING& sTargetName ,
sal_Int32 nSearchFlags );
static ETargetClass classify( EFrameType eFrameType ,
const OUSTRING& sTargetName ,
sal_Int32 nSearchFlags ,
sal_Bool& bCreationAllowed ,
sal_Bool bChildrenExist ,
const OUSTRING& sFrameName = OUSTRING() ,
sal_Bool bParentExist = sal_False ,
const OUSTRING& sParentName = OUSTRING() );
//---------------------------------------------------------------------------------------------------------
// private methods
//---------------------------------------------------------------------------------------------------------
/*-****************************************************************************************************//**
@short implement default search at children ...
@descr You CAN use these implementation or write your own code!
With these method we support a search for a target at your children.
We search direct children first and subframes of these direct one then.
@short helper methods for classify()
@descr Every tree node (desktop, frame, task ...) has another preference shares to search a target.
With these helper methods we differ between these search algorithm!
@ATTENTION We don't accept inpossible calling parameter - like special target names!
We search for realy named targets only.
@seealso method classify()
@seealso -
@param "bParentExist" set if a parent exist for caller tree node
@param "bChildrenExist" set if some children exist for caller tree node
@param "sFrameName" name of current tree node (used for SELF flag to break search earlier!)
@param "sParentName" name of current tree node (used for PARENT flag to break search earlier!)
@param "sTargetName" name of searched target tree node
@param "nSearchFlags" flags to regulate search in tree
@param "bTopFrame" used to break upper searches at a top frame if search outside current task isnt allowed!
@param "xChildFrameAccess"; Access to container with child frames of our caller
@param "sTargetName"; This is the search parameter to find right frame by name or special value!
@return A reference to an existing frame or null if search failed.
@onerror A null reference is returned.
*//*-*****************************************************************************************************/
static REFERENCE< XFRAME > helpDownSearch( const REFERENCE< XFRAMES >& xChildFrameAccess ,
const OUSTRING& sTargetName );
static ETargetClass impl_classifyForDesktop ( sal_Bool bChildrenExist ,
const OUSTRING& sTargetName ,
sal_Int32 nSearchFlags );
static ETargetClass impl_classifyForPlugInFrame ( sal_Bool bParentExist ,
sal_Bool bChildrenExist ,
const OUSTRING& sFrameName ,
const OUSTRING& sTargetName ,
sal_Int32 nSearchFlags );
static ETargetClass impl_classifyForTask ( sal_Bool bParentExist ,
sal_Bool bChildrenExist ,
const OUSTRING& sFrameName ,
const OUSTRING& sTargetName ,
sal_Int32 nSearchFlags );
static ETargetClass impl_classifyForFrame ( sal_Bool bParentExist ,
sal_Bool bChildrenExist ,
const OUSTRING& sFrameName ,
const OUSTRING& sParentName ,
const OUSTRING& sTargetName ,
sal_Int32 nSearchFlags );
//---------------------------------------------------------------------------------------------------------
// debug and test methods
@ -266,11 +302,41 @@ class TargetFinder
private:
static sal_Bool impldbg_checkParameter_classify ( const REFERENCE< XFRAME >& xOwner ,
const OUSTRING& sTargetName ,
sal_Int32 nSearchFlags );
static sal_Bool impldbg_checkParameter_helpDownSearch ( const REFERENCE< XFRAMES >& xChildFrameAccess ,
const OUSTRING& sTargetName );
//*********************************************************************************************************
// - check invalid references, misused booleans, wrong flags or for an unknown frame type
// - value of bCreationAllowed will set by classify() - existing value isn't important
// - empty strings are allowed
static inline sal_Bool implcp_classify( EFrameType eFrameType ,
const OUSTRING& sTargetName ,
sal_Int32 nSearchFlags ,
sal_Bool& bCreationAllowed ,
sal_Bool bChildrenExist ,
const OUSTRING& sFrameName ,
sal_Bool bParentExist ,
const OUSTRING& sParentName )
{
return (
( &sTargetName == NULL ) ||
( &sFrameName == NULL ) ||
( &sParentName == NULL ) ||
( &bCreationAllowed == NULL ) ||
( nSearchFlags < 0 ) ||
(
( bChildrenExist!= sal_False ) &&
( bChildrenExist!= sal_True )
) ||
(
( bParentExist != sal_False ) &&
( bParentExist != sal_True )
) ||
(
( eFrameType != E_DESKTOP ) &&
( eFrameType != E_PLUGINFRAME ) &&
( eFrameType != E_TASK ) &&
( eFrameType != E_FRAME )
)
);
}
#endif // #ifdef ENABLE_ASSERTIONS

View File

@ -2,9 +2,9 @@
*
* $RCSfile: taskcreator.hxx,v $
*
* $Revision: 1.1.1.1 $
* $Revision: 1.2 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:29:22 $
* last change: $Author: as $ $Date: 2001-03-09 14:42:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -66,6 +66,10 @@
// my own includes
//_________________________________________________________________________________________________________________
#ifndef __FRAMEWORK_CLASSES_TARGETFINDER_HXX_
#include <classes/targetfinder.hxx>
#endif
#ifndef __FRAMEWORK_MACROS_GENERIC_HXX_
#include <macros/generic.hxx>
#endif
@ -196,6 +200,8 @@ class TaskCreator
private:
OUSTRING impl_filterNames( const OUSTRING& sName );
//-------------------------------------------------------------------------------------------------------------
// debug methods
// (should be private everyway!)

View File

@ -2,9 +2,9 @@
*
* $RCSfile: assertion.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: as $ $Date: 2001-02-01 09:15:03 $
* last change: $Author: as $ $Date: 2001-03-09 14:42:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -64,6 +64,11 @@
//*****************************************************************************************************************
// special macros for assertion handling
// 2) LOGTYPE use it to define the output of all assertions, errors, exception infos
// 1) LOGFILE_ASSERTIONS use it to define the file name of log file if LOGTYPE=LOGTYPE_FILE...
// 3) LOG_ASSERT( BCONDITION, STEXT ) show/log an assertion if BCONDITION == false (depends from LOGTYPE)
// 4) LOG_ERROR( STEXT ) show/log an error (depends from LOGTYPE)
// 5) LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE ) show/log an error (depends from LOGTYPE)
//*****************************************************************************************************************
#ifdef ENABLE_ASSERTIONS
@ -76,8 +81,8 @@
#include <osl/diagnose.h>
#endif
#ifndef _RTL_USTRBUF_HXX_
#include <rtl/ustrbuf.hxx>
#ifndef _RTL_STRBUF_HXX_
#include <rtl/strbuf.hxx>
#endif
/*_____________________________________________________________________________________________________________
@ -87,12 +92,9 @@
_____________________________________________________________________________________________________________*/
#ifndef LOGFILE_ASSERTIONS
#define LOGFILE_ASSERTIONS \
"assertions.log"
#define LOGFILE_ASSERTIONS "assertions.log"
#endif
#if LOGTYPE==LOGTYPE_FILECONTINUE
/*_____________________________________________________________________________________________________________
LOG_ASSERT( BCONDITION, STEXT )
@ -100,6 +102,7 @@
Set LOGTYPE to LOGTYPE_FILECONTINUE to do this.
BCONDITION is inserted in "(...)" because user can call this macro with an complex expression!
_____________________________________________________________________________________________________________*/
#if LOGTYPE==LOGTYPE_FILECONTINUE
#define LOG_ASSERT( BCONDITION, STEXT ) \
if ( ( BCONDITION ) == sal_False ) \
@ -107,29 +110,20 @@
WRITE_LOGFILE( LOGFILE_ASSERTIONS, STEXT ) \
}
/*_____________________________________________________________________________________________________________
LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE )
Forward information about occured exception into logfile and continue with program.
Set LOGTYPE to LOGTYPE_FILECONTINUE to do this.
_____________________________________________________________________________________________________________*/
#define LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE ) \
#define LOG_ASSERT2( BCONDITION, SMETHOD, STEXT ) \
if ( ( BCONDITION ) == sal_True ) \
{ \
::rtl::OUStringBuffer sBuffer( 1000 ); \
sBuffer.appendAscii ( SMETHOD ); \
sBuffer.appendAscii ( "\n" ); \
sBuffer.appendAscii ( SOWNMESSAGE ); \
sBuffer.appendAscii ( "\n" ); \
sBuffer.append ( SEXCEPTIONMESSAGE ); \
sBuffer.appendAscii ( "\n" ); \
WRITE_LOGFILE( LOGFILE_ASSERTIONS, U2B(sBuffer.makeStringAndClear()).getStr() ) \
::rtl::OStringBuffer sBuffer( 256 ); \
sBuffer.append( "ASSERT:\n\t" ); \
sBuffer.append( SMETHOD ); \
sBuffer.append( "\n\t\"" ); \
sBuffer.append( STEXT ); \
sBuffer.append( "\"\n" ); \
WRITE_LOGFILE( LOGFILE_ASSERTIONS, sBuffer.makeStringAndClear().getStr() ) \
}
#endif
#if LOGTYPE==LOGTYPE_FILEXIT
/*_____________________________________________________________________________________________________________
LOG_ASSERT( BCONDITION, STEXT )
@ -137,6 +131,7 @@
Set LOGTYPE to LOGTYPE_FILEEXIT to do this.
BCONDITION is inserted in "(...)" because user can call this macro with an complex expression!
_____________________________________________________________________________________________________________*/
#if LOGTYPE==LOGTYPE_FILEXIT
#define LOG_ASSERT( BCONDITION, STEXT ) \
if ( ( BCONDITION ) == sal_False ) \
@ -145,30 +140,21 @@
exit(-1); \
}
/*_____________________________________________________________________________________________________________
LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE )
Forward information about occured exception into logfile and exit the program.
Set LOGTYPE to LOGTYPE_FILECONTINUE to do this.
_____________________________________________________________________________________________________________*/
#define LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE ) \
#define LOG_ASSERT2( BCONDITION, SMETHODE, STEXT ) \
if ( ( BCONDITION ) == sal_True ) \
{ \
::rtl::OUStringBuffer sBuffer( 1000 ); \
sBuffer.appendAscii ( SMETHOD ); \
sBuffer.appendAscii ( "\n" ); \
sBuffer.appendAscii ( SOWNMESSAGE ); \
sBuffer.appendAscii ( "\n" ); \
sBuffer.append ( SEXCEPTIONMESSAGE ); \
sBuffer.appendAscii ( "\n" ); \
WRITE_LOGFILE( LOGFILE_ASSERTIONS, U2B(sBuffer.makeStringAndClear()).getStr() ) \
::rtl::OStringBuffer sBuffer( 256 ); \
sBuffer.append( "ASSERT:\n\t" ); \
sBuffer.append( SMETHOD ); \
sBuffer.append( "\n\t\"" ); \
sBuffer.append( STEXT ); \
sBuffer.append( "\"\n" ); \
WRITE_LOGFILE( LOGFILE_ASSERTIONS, sBuffer.makeStringAndClear().getStr() ) \
exit(-1); \
}
#endif
#if LOGTYPE==LOGTYPE_MESSAGEBOX
/*_____________________________________________________________________________________________________________
LOG_ASSERT( BCONDITION, STEXT )
@ -176,31 +162,49 @@
Set LOGTYPE to LOGTYPE_MESSAGEBOX to do this.
BCONDITION is inserted in "(...)" because user can call this macro with an complex expression!
_____________________________________________________________________________________________________________*/
#if LOGTYPE==LOGTYPE_MESSAGEBOX
#define LOG_ASSERT( BCONDITION, STEXT ) \
OSL_ENSHURE( ( BCONDITION ), STEXT );
/*_____________________________________________________________________________________________________________
LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE )
Forward information about occured exception into messagebox.
Set LOGTYPE to LOGTYPE_FILECONTINUE to do this.
_____________________________________________________________________________________________________________*/
#define LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE ) \
#define LOG_ASSERT2( BCONDITION, SMETHOD, STEXT ) \
{ \
::rtl::OUStringBuffer sBuffer( 1000 ); \
sBuffer.appendAscii ( SMETHOD ); \
sBuffer.appendAscii ( "\n" ); \
sBuffer.appendAscii ( SOWNMESSAGE ); \
sBuffer.appendAscii ( "\n" ); \
sBuffer.append ( SEXCEPTIONMESSAGE ); \
sBuffer.appendAscii ( "\n" ); \
OSL_ENSHURE( sal_False, U2B(sBuffer.makeStringAndClear()).getStr() ); \
::rtl::OStringBuffer sBuffer( 256 ); \
sBuffer.append( "ASSERT:\n\t" ); \
sBuffer.append( SMETHOD ); \
sBuffer.append( "\n\t\"" ); \
sBuffer.append( STEXT ); \
sBuffer.append( "\"\n" ); \
OSL_ENSHURE( !( BCONDITION ), sBuffer.makeStringAndClear().getStr() ); \
}
#endif
/*_____________________________________________________________________________________________________________
LOG_ERROR( STEXT )
Show an error by using current set output mode by define LOGTYPE!
_____________________________________________________________________________________________________________*/
#define LOG_ERROR( SMETHOD, STEXT ) \
LOG_ASSERT2( sal_True, SMETHOD, STEXT )
/*_____________________________________________________________________________________________________________
LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE )
Show some exception info by using current set output mode by define LOGTYPE!
We use a seperated scope {} do protect us against multiple variable definitions.
_____________________________________________________________________________________________________________*/
#define LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE ) \
{ \
::rtl::OStringBuffer sBuffer( 256 ); \
sBuffer.append( SOWNMESSAGE ); \
sBuffer.append( "\n" ); \
sBuffer.append( U2B(SEXCEPTIONMESSAGE) ); \
LOG_ERROR( SMETHOD, sBuffer.makeStringAndClear().getStr() ) \
}
#else // #ifdef ENABLE_ASSERTIONS
/*_____________________________________________________________________________________________________________
@ -209,6 +213,8 @@
#undef LOGFILE_ASSERTIONS
#define LOG_ASSERT( BCONDITION, STEXT )
#define LOG_ASSERT2( BCONDITION, SMETHOD, STEXT )
#define LOG_ERROR( SMETHOD, STEXT )
#define LOG_EXCEPTION( SMETHOD, SOWNMESSAGE, SEXCEPTIONMESSAGE )
#endif // #ifdef ENABLE_ASSERTIONS

View File

@ -2,9 +2,9 @@
*
* $RCSfile: targeting.hxx,v $
*
* $Revision: 1.1.1.1 $
* $Revision: 1.2 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:29:23 $
* last change: $Author: as $ $Date: 2001-03-09 14:42:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -83,32 +83,37 @@
_____________________________________________________________________________________________________________*/
#ifndef LOGFILE_TARGETING
#define LOGFILE_TARGETING \
"targeting.log"
#define LOGFILE_TARGETSTEPS "targetsteps.log"
#define LOGFILE_TARGETPARAM "targetparam.log"
#endif
/*_____________________________________________________________________________________________________________
LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS )
Log format for parameter e.g.: Desktop::findFrame( "frame1", 23 ) my name is "desktop"
Log format for steps e.g.: desktop--
With this macro you can log informations about search parameter of method "findFrame()" of an service.
Use it at beginning of search only!
_____________________________________________________________________________________________________________*/
#define LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS ) \
/* Use new scope to prevent code against multiple variable defines! */ \
{ \
::rtl::OStringBuffer sBuffer(1024); \
sBuffer.append( "\n************************************************\n" ); \
sBuffer.append( "[ " ); \
sBuffer.append( U2B( SFRAMENAME ) ); \
sBuffer.append( "] " ); \
sBuffer.append( SSERVICE ); \
sBuffer.append( "::findFrame( \"" ); \
sBuffer.append( U2B( STARGETNAME ) ); \
sBuffer.append( "\", " ); \
sBuffer.append( ::rtl::OString::valueOf( sal_Int32( NSEARCHFLAGS ) ) ); \
sBuffer.append( " )\n" ); \
WRITE_LOGFILE( LOGFILE_TARGETING, sBuffer.makeStringAndClear().getStr() ) \
#define LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS ) \
/* Use new scope to prevent code against multiple variable defines! */ \
{ \
::rtl::OStringBuffer sBufferParam(256); \
::rtl::OStringBuffer sBufferSteps(256); \
sBufferParam.append( SSERVICE ); \
sBufferParam.append( "::findFrame( \"" ); \
sBufferParam.append( U2B( STARGETNAME ) ); \
sBufferParam.append( "\", " ); \
sBufferParam.append( ::rtl::OString::valueOf( sal_Int32( NSEARCHFLAGS ) ) ); \
sBufferParam.append( " ) my name is \"" ); \
sBufferParam.append( U2B( SFRAMENAME ) ); \
sBufferParam.append( "\"\n" ); \
sBufferSteps.append( U2B( SFRAMENAME ) ); \
sBufferSteps.append( "--" ); \
WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBufferParam.makeStringAndClear().getStr() ) \
WRITE_LOGFILE( LOGFILE_TARGETSTEPS, sBufferSteps.makeStringAndClear().getStr() ) \
}
/*_____________________________________________________________________________________________________________
@ -133,7 +138,7 @@
sBuffer.append( "\", " ); \
sBuffer.append( ::rtl::OString::valueOf( sal_Int32( NSEARCHFLAGS ) ) ); \
sBuffer.append( " )\n" ); \
WRITE_LOGFILE( LOGFILE_TARGETING, sBuffer.makeStringAndClear().getStr() ) \
WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear().getStr() ) \
}
/*_____________________________________________________________________________________________________________
@ -168,27 +173,7 @@
} \
} \
sBuffer.append( " )\n" ); \
WRITE_LOGFILE( LOGFILE_TARGETING, sBuffer.makeStringAndClear().getStr() ) \
}
/*_____________________________________________________________________________________________________________
LOG_TARGETINGSTEP( SSERVICE, SFRAMENAME, SINFOMESSAGE )
With this macro you can log informations about search steps.
_____________________________________________________________________________________________________________*/
#define LOG_TARGETINGSTEP( SSERVICE, SFRAMENAME, SINFOMESSAGE ) \
/* Use new scope to prevent code against multiple variable defines! */ \
{ \
::rtl::OStringBuffer sBuffer(1024); \
sBuffer.append( "\t[ " ); \
sBuffer.append( U2B( SFRAMENAME ) ); \
sBuffer.append( "] " ); \
sBuffer.append( SSERVICE ); \
sBuffer.append( ": \"" ); \
sBuffer.append( SINFOMESSAGE ); \
sBuffer.append( "\"\n" ); \
WRITE_LOGFILE( LOGFILE_TARGETING, sBuffer.makeStringAndClear().getStr() ) \
WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear().getStr() ) \
}
/*_____________________________________________________________________________________________________________
@ -201,21 +186,26 @@
#define LOG_RESULT_FINDFRAME( SSERVICE, SFRAMENAME, XFRAME ) \
/* Use new scope to prevent code against multiple variable defines! */ \
{ \
::rtl::OStringBuffer sBuffer(1024); \
sBuffer.append( "[ " ); \
sBuffer.append( U2B( SFRAMENAME ) ); \
sBuffer.append( "] " ); \
sBuffer.append( SSERVICE ); \
::rtl::OStringBuffer sBufferParam(256); \
::rtl::OStringBuffer sBufferSteps(256); \
sBufferParam.append( SSERVICE ); \
sBufferParam.append( "::findFrame() at \"" ); \
sBufferParam.append( U2B( SFRAMENAME ) ); \
sBufferParam.append( "\" " ); \
if( XFRAME.is() == sal_True ) \
{ \
sBuffer.append( "::findframe() return with valid frame."); \
sBufferParam.append( "return with valid frame.\n" ); \
sBufferSteps.append( "OK [" ); \
sBufferSteps.append( U2B( XFRAME->getName() ).getStr() ); \
sBufferSteps.append( "]\n" ); \
} \
else \
{ \
sBuffer.append( "::findframe() return with NULL frame!" ); \
sBufferParam.append( "return with NULL frame!\n"); \
sBufferSteps.append( "??\n" ); \
} \
sBuffer.append( "\n" ); \
WRITE_LOGFILE( LOGFILE_TARGETING, sBuffer.makeStringAndClear().getStr() ) \
WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBufferParam.makeStringAndClear().getStr() ) \
WRITE_LOGFILE( LOGFILE_TARGETSTEPS, sBufferSteps.makeStringAndClear().getStr() ) \
}
/*_____________________________________________________________________________________________________________
@ -242,7 +232,7 @@
sBuffer.append( "::queryDispatch() return with NULL dispatcher!" ); \
} \
sBuffer.append( "\n" ); \
WRITE_LOGFILE( LOGFILE_TARGETING, sBuffer.makeStringAndClear().getStr() ) \
WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear().getStr() ) \
}
/*_____________________________________________________________________________________________________________
@ -269,7 +259,7 @@
sBuffer.append( "::loadComponentFromURL() return with NULL component!" ); \
} \
sBuffer.append( "\n" ); \
WRITE_LOGFILE( LOGFILE_TARGETING, sBuffer.makeStringAndClear().getStr() ) \
WRITE_LOGFILE( LOGFILE_TARGETPARAM, sBuffer.makeStringAndClear().getStr() ) \
}
#else // #ifdef ENABLE_TARGETINGDEBUG
@ -278,11 +268,11 @@
If right testmode is'nt set - implements these macro empty!
_____________________________________________________________________________________________________________*/
#undef LOGFILE_TARGETING
#undef LOGFILE_TARGETPARAM
#undef LOGFILE_TARGETSTEPS
#define LOG_PARAMETER_FINDFRAME( SSERVICE, SFRAMENAME, STARGETNAME, NSEARCHFLAGS )
#define LOG_PARAMETER_QUERYDISPATCH( SSERVICE, SFRAMENAME, AURL, STARGETNAME, NSEARCHFLAGS )
#define LOG_PARAMETER_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, SURL, STARGETNAME, NSEARCHFLAGS, SEQPARAMETER )
#define LOG_TARGETINGSTEP( SSERVICE, SFRAMENAME, SINFOMESSAGE )
#define LOG_RESULT_FINDFRAME( SSERVICE, SFRAMENAME, XFRAME )
#define LOG_RESULT_QUERYDISPATCH( SSERVICE, SFRAMENAME, XDISPATCHER )
#define LOG_RESULT_LOADCOMPONENTFROMURL( SSERVICE, SFRAMENAME, XCOMPONENT )

View File

@ -2,9 +2,9 @@
*
* $RCSfile: task.hxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: as $ $Date: 2000-10-23 13:56:42 $
* last change: $Author: as $ $Date: 2001-03-09 14:42:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -419,10 +419,10 @@ class Task : public XTASK , // => XFrame => XComponent
}
virtual REFERENCE< XFRAME > SAL_CALL findFrame( const OUSTRING& sTargetFrameName ,
sal_Int32 nSearchFlags ) throw( RUNTIMEEXCEPTION )
{
return Frame::findFrame( sTargetFrameName, nSearchFlags );
}
sal_Int32 nSearchFlags ) throw( RUNTIMEEXCEPTION );
// {
// return Frame::findFrame( sTargetFrameName, nSearchFlags );
// }
//---------------------------------------------------------------------------------------------------------
// XTopWindowListener

View File

@ -2,9 +2,9 @@
*
* $RCSfile: framecontainer.cxx,v $
*
* $Revision: 1.8 $
* $Revision: 1.9 $
*
* last change: $Author: as $ $Date: 2001-03-05 12:55:44 $
* last change: $Author: as $ $Date: 2001-03-09 14:42:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -68,13 +68,14 @@
#include <classes/framecontainer.hxx>
#endif
#include <vector>
#include <stdexcept>
#include <algorithm>
//_________________________________________________________________________________________________________________
// interface includes
//_________________________________________________________________________________________________________________
#ifndef _COM_SUN_STAR_FRAME_FRAMESEARCH_FLAG_HPP_
#include <com/sun/star/frame/FrameSearchFlag.hpp>
#endif
//_________________________________________________________________________________________________________________
// includes of other projects
//_________________________________________________________________________________________________________________
@ -86,6 +87,7 @@
namespace framework{
using namespace ::std ;
using namespace ::rtl ;
using namespace ::com::sun::star::uno ;
using namespace ::com::sun::star::frame ;
@ -129,11 +131,12 @@ void FrameContainer::append( const Reference< XFrame >& xFrame )
{
// Safe impossible cases
// This method is not defined for ALL incoming parameters!
LOG_ASSERT( impldbg_checkParameter_append( xFrame ), "FrameContainer::append()\nInvalid parameter detected!\n" )
LOG_ASSERT2( implcp_append( xFrame ), "FrameContainer::append()", "Invalid parameter detected!" )
// Warn programmer at already existing elements in container.
LOG_ASSERT( !(exist(xFrame)==sal_True), "FrameContainer::append()\nNew frame already exist in container!\n" )
// We search for hidden tasks which have no component!
LOG_ASSERT( impldbg_lookForZombieFrames( xFrame ), "FrameContainer::append()\nZombie frame detected!\n" )
LOG_ASSERT2( exist(xFrame)==sal_True, "FrameContainer::append()", "New frame already exist in container!" )
// Warn programmer if an already existing frame has no component inside!
// These frames are created (e.g. by dispatch()) but not used ...
LOG_ASSERT2( impldbg_existZombie(), "FrameContainer::append()", "Zombie frame detected!" )
// Work only, if container not locked!
if ( m_bLock == LOCK_OFF )
@ -152,17 +155,15 @@ void FrameContainer::remove( const Reference< XFrame >& xFrame )
{
// Safe impossible cases
// This method is not defined for ALL incoming parameters!
LOG_ASSERT( impldbg_checkParameter_remove( xFrame ), "FrameContainer::remove()\nInvalid parameter detected!\n" )
LOG_ASSERT2( implcp_remove( xFrame ), "FrameContainer::remove()", "Invalid parameter detected!" )
// Warn programmer at non existing elements in container.
LOG_ASSERT( !(exist(xFrame)==sal_False), "FrameContainer::remove()\nFrame to remove not exist in container!\n" )
// Safe impossible cases.
// LOG_ASSERT( impldbg_lookForZombieFrames( xFrame ), "FrameContainer::remove()\nZombie frame detected!\n" )
LOG_ASSERT2( exist(xFrame)==sal_False, "FrameContainer::remove()", "Frame to remove not exist in container!" )
// Work only, if container not locked!
if ( m_bLock == LOCK_OFF )
{
// Search frame and remove it from container ...
vector< Reference< XFrame > >::iterator aSearchedItem = find( m_aContainer.begin(), m_aContainer.end(), xFrame );
TFrameIterator aSearchedItem = find( m_aContainer.begin(), m_aContainer.end(), xFrame );
// ... if it exist.
if ( aSearchedItem != m_aContainer.end() )
{
@ -184,24 +185,24 @@ void FrameContainer::remove( const Reference< XFrame >& xFrame )
}
}
// Else; Warn programmer.
LOG_ASSERT( !(m_bLock==LOCK_ON), "FrameContainer::remove()\nContainer is locked! You can't remove frame.\n" )
LOG_ASSERT2( m_bLock==LOCK_ON, "FrameContainer::remove()", "Container is locked! You can't remove frame." )
}
//*****************************************************************************************************************
// public method
//*****************************************************************************************************************
sal_Bool FrameContainer::exist( const REFERENCE< XFRAME >& xFrame )
sal_Bool FrameContainer::exist( const REFERENCE< XFRAME >& xFrame ) const
{
// Safe impossible cases
// This method is not defined for ALL incoming parameters!
LOG_ASSERT( impldbg_checkParameter_exist( xFrame ), "FrameContainer::exist()\nInvalid parameter detected!\n" )
LOG_ASSERT2( implcp_exist( xFrame ), "FrameContainer::exist()", "Invalid parameter detected!" )
// Set default return value.
sal_Bool bExist = sal_False;
// We ignore the lock, because we do not change the content of container!
// Search frame.
vector< Reference< XFrame > >::iterator aSearchedItem = find( m_aContainer.begin(), m_aContainer.end(), xFrame );
TConstFrameIterator aSearchedItem = find( m_aContainer.begin(), m_aContainer.end(), xFrame );
// If it exist ...
if ( aSearchedItem != m_aContainer.end() )
{
@ -217,16 +218,13 @@ sal_Bool FrameContainer::exist( const REFERENCE< XFRAME >& xFrame )
//*****************************************************************************************************************
void FrameContainer::clear()
{
// Safe impossible cases.
// We search for hidden tasks which have no component!
LOG_ASSERT( impldbg_lookForZombieFrames( Reference< XFrame >() ), "FrameContainer::clear()\nZombie frame detected!\n" )
// This method is only allowed, if no lock is set!
// Warn programmer, if its not true.
LOG_ASSERT( !(m_bLock==LOCK_ON), "FrameContainer::clear()\nContainer is locked! You can't clear it.\n" )
LOG_ASSERT2( m_bLock==LOCK_ON, "FrameContainer::clear()", "Container is locked! You can't clear it." )
if ( m_bLock == LOCK_OFF )
{
// Clear the container ...
m_aContainer.erase( m_aContainer.begin(), m_aContainer.end() );
m_aContainer.clear();
// ... and don't forget to reset the active frame.
// Its an reference to a valid container-item.
@ -277,14 +275,14 @@ Reference< XFrame > FrameContainer::operator[]( sal_uInt32 nIndex ) const
{
// Safe impossible cases
// This method is not defined for ALL incoming parameters!
LOG_ASSERT( impldbg_checkParameter_IndexOperator( nIndex ), "FrameContainer::operator[]()\nInvalid parameter detected!\n" )
LOG_ASSERT2( implcp_IndexOperator( nIndex, getCount() ), "FrameContainer::operator[]()", "Invalid parameter detected!" )
// Set default return value.
Reference< XFrame > xFrame;
// This operation is allowed only, if lock is set.
// Warn programmer, if this not true.
LOG_ASSERT( !(m_bLock==LOCK_OFF), "FrameContainer::operator[]()\nContainer is not locked! You can't do this.\n" )
LOG_ASSERT2( m_bLock==LOCK_OFF, "FrameContainer::operator[]()", "Container is not locked! You can't do this." )
if ( m_bLock == LOCK_ON )
{
@ -352,10 +350,10 @@ void FrameContainer::setActive( const Reference< XFrame >& xFrame )
// Safe impossible cases
// This method is not defined for ALL incoming parameters!
// BUT we accept null refrences for reset active state. => No frame is active then.
LOG_ASSERT( impldbg_checkParameter_setActive( xFrame ), "FrameContainer::setActive()\nInvalid parameter detected!\n" )
LOG_ASSERT2( implcp_setActive( xFrame ), "FrameContainer::setActive()", "Invalid parameter detected!" )
// The new active frame MUST exist in container.
// Control this.
LOG_ASSERT( !(xFrame.is()==sal_True && exist(xFrame)==sal_False), "FrameContainer::setActive()\nThe new active frame is not a member of current container!You cant activate it.\n" )
LOG_ASSERT2( xFrame.is()==sal_True && exist(xFrame)==sal_False, "FrameContainer::setActive()", "The new active frame is not a member of current container!You cant activate it." )
// All incoming parameters are controlled.
// We have a new active frame or a null reference to reset this state.
@ -399,136 +397,124 @@ void FrameContainer::disableQuitTimer()
}
}
//_________________________________________________________________________________________________________________
// debug methods
//_________________________________________________________________________________________________________________
/*-----------------------------------------------------------------------------------------------------------------
The follow methods checks the parameter for other functions. If a parameter or his value is non valid,
we return "sal_False". (else sal_True) This mechanism is used to throw an ASSERT!
ATTENTION
If you miss a test for one of this parameters, contact the autor or add it himself !(?)
But ... look for right testing! See using of this methods!
-----------------------------------------------------------------------------------------------------------------*/
#ifdef ENABLE_ASSERTIONS
//*****************************************************************************************************************
// We accept valid references for working with container only.
sal_Bool FrameContainer::impldbg_checkParameter_append( const Reference< XFrame >& xFrame ) const
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xFrame == NULL ) ||
( xFrame.is() == sal_False )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
// public method
//*****************************************************************************************************************
// We accept valid references for working with container only.
sal_Bool FrameContainer::impldbg_checkParameter_remove( const Reference< XFrame >& xFrame ) const
Reference< XFrame > FrameContainer::searchDeepDown( const OUString& sName )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xFrame == NULL ) ||
( xFrame.is() == sal_False )
)
// Check incoming parameter.
LOG_ASSERT2( implcp_searchDeepDown( sName ), "FrameContainer::searchDeepDown()", "Invalid parameter detected!" )
// Set default return value if search failed.
Reference< XFrame > xSearchedFrame;
// Use snapshot for search ...
// because these search could be a longer process.
// We must protect us against deleting references.
// In our multithreaded environment it could be that some new frames are appended or other are removed
// during this operation - but we hold valid references to it!
// Step over all child frames. But if direct child isnt the right one search on his children first - before
// you go to next direct child of this container!
Sequence< Reference< XFrame > > lFrames = getAllElements();
sal_Int32 nCount = lFrames.getLength();
for( sal_Int32 nFrame=0; nFrame<nCount; ++nFrame )
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
// We accept valid references for working with container only.
sal_Bool FrameContainer::impldbg_checkParameter_exist( const Reference< XFrame >& xFrame ) const
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xFrame == NULL ) ||
( xFrame.is() == sal_False )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
// The index in to the container must be in range of 0 and count-1!
sal_Bool FrameContainer::impldbg_checkParameter_IndexOperator( sal_uInt32 nIndex ) const
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( nIndex >= (sal_uInt32)m_aContainer.size() )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
// setActive accept valid- or null-reference but no null-pointer!
sal_Bool FrameContainer::impldbg_checkParameter_setActive( const Reference< XFrame >& xFrame ) const
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xFrame == NULL )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
sal_Bool FrameContainer::impldbg_lookForZombieFrames( const Reference< XFrame >& xFrame ) const
{
// Step over all container items and search for a frame which contains no component.
// (He has no component window!)
// Use return value directly for an assert ...
sal_Bool bSuppressAssert = sal_True;
sal_Int32 nCount = m_aContainer.size();
for( sal_Int32 nPosition=0; nPosition<nCount; ++nPosition )
{
Reference< XFrame > xZombieFrame = m_aContainer.at(nPosition);
if (
( xZombieFrame.is() == sal_True ) &&
( xZombieFrame != xFrame ) &&
( xZombieFrame->getComponentWindow().is() == sal_False )
)
if( lFrames[nFrame]->getName() == sName )
{
bSuppressAssert = sal_False;
xSearchedFrame = lFrames[nFrame];
break;
}
else
{
xSearchedFrame = lFrames[nFrame]->findFrame( sName, FrameSearchFlag::CHILDREN );
if( xSearchedFrame.is() == sal_True )
{
break;
}
}
}
return bSuppressAssert;
return xSearchedFrame;
}
#endif // #ifdef ENABLE_ASSERTIONS
//*****************************************************************************************************************
// public method
//*****************************************************************************************************************
Reference< XFrame > FrameContainer::searchFlatDown( const OUString& sName )
{
// Check incoming parameter.
LOG_ASSERT2( implcp_searchFlatDown( sName ), "FrameContainer::searchFlatDown()", "Invalid parameter detected!" )
// Set default return value if search failed.
Reference< XFrame > xSearchedFrame;
// Use snapshot for search ...
// because these search could be a longer process.
// We must protect us against deleting references.
// In our multithreaded environment it could be that some new frames are appended or other are removed
// during this operation - but we hold valid references to it!
// Step over all direct child frames first.
// Even right frame wasn't found start search at children of direct children.
Sequence< Reference< XFrame > > lFrames = getAllElements();
sal_Int32 nCount = lFrames.getLength();
sal_Int32 nFrame = 0;
for( nFrame=0; nFrame<nCount; ++nFrame )
{
if( lFrames[nFrame]->getName() == sName )
{
xSearchedFrame = lFrames[nFrame];
break;
}
}
if( xSearchedFrame.is() == sal_False )
{
nCount = lFrames.getLength();
for( sal_Int32 nFrame=0; nFrame<nCount; ++nFrame )
{
xSearchedFrame = lFrames[nFrame]->findFrame( sName, FrameSearchFlag::CHILDREN | FrameSearchFlag::SIBLINGS );
if( xSearchedFrame.is() == sal_True )
{
break;
}
}
}
return xSearchedFrame;
}
//*****************************************************************************************************************
// public method
//*****************************************************************************************************************
Reference< XFrame > FrameContainer::searchDirectChildren( const OUString& sName )
{
// Check incoming parameter.
LOG_ASSERT2( implcp_searchDirectChildren( sName ), "FrameContainer::searchDirectChildren()", "Invalid parameter detected!" )
// Set default return value if search failed.
Reference< XFrame > xSearchedFrame;
// Use snapshot for search ...
// because these search could be a longer process.
// We must protect us against deleting references.
// In our multithreaded environment it could be that some new frames are appended or other are removed
// during this operation - but we hold valid references to it!
// Step over all current container items and search for right target.
Sequence< Reference< XFrame > > lFrames = getAllElements();
sal_Int32 nCount = lFrames.getLength();
for( sal_Int32 nFrame=0; nFrame<nCount; ++nFrame )
{
if( lFrames[nFrame]->getName() == sName )
{
xSearchedFrame = lFrames[nFrame];
break;
}
}
return xSearchedFrame;
}
} // namespace framework

View File

@ -2,9 +2,9 @@
*
* $RCSfile: targetfinder.cxx,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: as $ $Date: 2000-10-23 13:55:34 $
* last change: $Author: as $ $Date: 2001-03-09 14:42:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -75,22 +75,6 @@
#include <com/sun/star/frame/FrameSearchFlag.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_
#include <com/sun/star/frame/XDesktop.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XTASK_HPP_
#include <com/sun/star/frame/XTask.hpp>
#endif
#ifndef _COM_SUN_STAR_MOZILLA_XPLUGININSTANCE_HPP_
#include <com/sun/star/mozilla/XPluginInstance.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XELEMENTACCESS_HPP_
#include <com/sun/star/container/XElementAccess.hpp>
#endif
//_________________________________________________________________________________________________________________
// other includes
//_________________________________________________________________________________________________________________
@ -108,8 +92,6 @@ namespace framework{
using namespace ::rtl ;
using namespace ::com::sun::star::uno ;
using namespace ::com::sun::star::frame ;
using namespace ::com::sun::star::mozilla ;
using namespace ::com::sun::star::container ;
//_________________________________________________________________________________________________________________
// non exported const
@ -140,369 +122,473 @@ TargetFinder::~TargetFinder()
//*****************************************************************************************************************
// interface
//*****************************************************************************************************************
IMPL_ETargetClass TargetFinder::classify( const Reference< XFrame >& xOwner ,
const OUString& sTargetName ,
sal_Int32 nSearchFlags )
ETargetClass TargetFinder::classify( EFrameType eFrameType ,
const OUString& sTargetName ,
sal_Int32 nSearchFlags ,
sal_Bool& bCreationAllowed ,
sal_Bool bChildrenExist ,
const OUString& sFrameName ,
sal_Bool bParentExist ,
const OUString& sParentName )
{
/*Attention
// Check incoming parameter
LOG_ASSERT2( implcp_classify( eFrameType, sTargetName, nSearchFlags, bCreationAllowed, bChildrenExist, sFrameName, bParentExist, sParentName ), "TargetFinder::classify()", "Invalid parameter detected!" )
The desktop is a special object - the root of our frame tree ...
but he can't handle components!
I think he could'nt be a realy supported target any time!!!
Never return it as SELF or PARENT or TOP ...
// Initialize start values.
ETargetClass eResult = E_UNKNOWN ; // default result of method
bCreationAllowed = (( nSearchFlags & FrameSearchFlag::CREATE ) == FrameSearchFlag::CREATE ); // if search failed we must caller allow to create new task/frame
*/
// Safe impossible cases.
// These method is not defined for all incoming parameter!
LOG_ASSERT( impldbg_checkParameter_classify( xOwner, sTargetName, nSearchFlags ), "TargetFinder::classify()\nInvalid parameter detected!\n" )
// Set return value if method failed.
IMPL_ETargetClass eResult = eUNKNOWN;
// Get some special informations about our caller.
// We need his name, his type ... and something else.
IMPL_EFrameType eFrameType ;
sal_Bool bParentExist ;
sal_Bool bChildrenExist ;
OUString sFrameName ;
// Children can exist for every frame implementation.
Reference< XFramesSupplier > xSupplier( xOwner , UNO_QUERY );
Reference< XElementAccess > xAccess ( xSupplier->getFrames() , UNO_QUERY );
bChildrenExist = xAccess->hasElements();
// But all other informations are optional or defaults!
if( Reference< XDesktop >( xOwner, UNO_QUERY ).is() == sal_True )
// Use some helper methods for different classes of tree nodes to get the result.
switch( eFrameType )
{
// a) Our desktop is a special implementation!
// He has no parent and no name.
eFrameType = eDESKTOP ;
bParentExist = sal_False ;
sFrameName = OUString() ;
case E_DESKTOP : eResult = impl_classifyForDesktop( bChildrenExist, sTargetName, nSearchFlags );
break;
case E_PLUGINFRAME : eResult = impl_classifyForPlugInFrame( bParentExist, bChildrenExist, sFrameName, sTargetName, nSearchFlags );
break;
case E_TASK : eResult = impl_classifyForTask( bParentExist, bChildrenExist, sFrameName, sTargetName, nSearchFlags );
break;
case E_FRAME : eResult = impl_classifyForFrame( bParentExist, bChildrenExist, sFrameName, sParentName, sTargetName, nSearchFlags );
break;
}
else
// It doesnt matter if CREATE flag is set or not ...
// If follow results are returned by our helper methods - the result will be clear!
// In these cases we dont can allow (or must!) creation of new frames/tasks...
if (
( eResult == E_UNKNOWN ) ||
( eResult == E_CREATETASK ) ||
( eResult == E_SELF ) ||
( eResult == E_PARENT ) ||
( eResult == E_BEAMER )
)
{
// b) All other implementations has a parent and it's own name.
// We set frame type to default eFRAME ...
eFrameType = eFRAME ;
bParentExist = xOwner->getCreator().is() ;
sFrameName = xOwner->getName() ;
if( Reference< XTask >( xOwner, UNO_QUERY ).is() == sal_True )
{
// c) ... but it can be that our caller is a task ...
eFrameType = eTASK;
}
else
if( Reference< XPluginInstance >( xOwner, UNO_QUERY ).is() == sal_True )
{
// d) ... or a plug-in frame!
eFrameType = ePLUGINFRAME;
}
bCreationAllowed = sal_False;
}
return eResult;
}
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
ETargetClass TargetFinder::impl_classifyForDesktop( sal_Bool bChildrenExist ,
const OUSTRING& sTargetName ,
sal_Int32 nSearchFlags )
{
ETargetClass eResult = E_UNKNOWN;
//*************************************************************************************************************
// 1) Look for "_blank"
// These is the most used case and must be fast!
// FrameSearchFlag::CREATE can be used at least if no other parameter match the given one!!!
// Return "eUP" for all normaly frames/tasks/plugins ... These implementations don't must known something about
// creation(!) ... The desktop only can do it - and we return right recommendation for it.
// I) Handle special target names.
// Make an exclusiv search: if() else if() ...
//
// I.I) Look for "_blank"
// Only the desktop can create new tasks.
//*************************************************************************************************************
if( sTargetName == SPECIALTARGET_BLANK )
{
if( eFrameType == eDESKTOP )
eResult = E_CREATETASK;
}
else
{
//*********************************************************************************************************
// II) Special target names was handled ...
// Now look for right flags.
// Combine search results: if(); if() ...
//
// II.I) Special and exclusiv mode for search at our desktop!
// Normaly TASKS flag is used to restrict upper searches inside current task tree!
// All searches stop at a top frame if these flag isnt set.
// For down search it doesnt matter ...
// but I think we can use it to search at all direct(!) childrens of our desktop.
// These can be useful to create new tasks by name if it not already exist.
// => These flag cant combinde with CHILDREN or SIBLINGS or somethings else.
// We ignore such constructs. If you combine it with the CREATE flag - a new task will created
// if no existing one can be found.
//*********************************************************************************************************
if (
( nSearchFlags & FrameSearchFlag::TASKS ) &&
(
!( nSearchFlags & FrameSearchFlag::CHILDREN ) &&
!( nSearchFlags & FrameSearchFlag::SIBLINGS ) &&
!( nSearchFlags & FrameSearchFlag::PARENT ) &&
!( nSearchFlags & FrameSearchFlag::SELF )
)
)
{
eResult = eCREATE;
eResult = E_TASKS;
}
else
{
eResult = eUP;
//*****************************************************************************************************
// II.I) Look for CHILDREN.
// Ignore flag if no childrens exist!
//*****************************************************************************************************
if (
( nSearchFlags & FrameSearchFlag::CHILDREN ) &&
( bChildrenExist == sal_True )
)
{
eResult = E_DEEP_DOWN;
}
//*****************************************************************************************************
// II.II) Look for SIBLINGS.
// These change a deep to a flat search!
// Otherwise ... flag can be ignored - because the desktop has no siblings!
//*****************************************************************************************************
if( nSearchFlags & FrameSearchFlag::SIBLINGS )
{
switch( eResult )
{
case E_DEEP_DOWN : eResult = E_FLAT_DOWN;
break;
}
}
}
}
//*************************************************************************************************************
// possible results:
// E_UNKNOWN
// E_CREATETASK
// E_TASKS
// E_DEEP_DOWN
// E_FLAT_DOWN
//*************************************************************************************************************
return eResult;
}
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
ETargetClass TargetFinder::impl_classifyForPlugInFrame ( sal_Bool bParentExist ,
sal_Bool bChildrenExist ,
const OUString& sFrameName ,
const OUString& sTargetName ,
sal_Int32 nSearchFlags )
{
// At the moment a PlugInFrame is a special task ... but we can use the same search algorithm!
return impl_classifyForTask( bParentExist, bChildrenExist, sFrameName, sTargetName, nSearchFlags );
}
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
ETargetClass TargetFinder::impl_classifyForTask( sal_Bool bParentExist ,
sal_Bool bChildrenExist ,
const OUString& sFrameName ,
const OUString& sTargetName ,
sal_Int32 nSearchFlags )
{
ETargetClass eResult = E_UNKNOWN ;
sal_Bool bLeaveTask = (( nSearchFlags & FrameSearchFlag::TASKS ) == FrameSearchFlag::TASKS ); // we must know if we can search outside current task
//*************************************************************************************************************
// I) Handle special target names.
// Make an exclusiv search: if() else if() ...
//
// I.I) Look for "_blank"
// Only the desktop can create new tasks. Forward search to parent!
//*************************************************************************************************************
if( sTargetName == SPECIALTARGET_BLANK )
{
if( bParentExist == sal_True )
{
eResult = E_FORWARD_UP;
}
}
else
//*************************************************************************************************************
// 2) Look for "_self", "". Its the same like "_self"!
// I.II) Look for "_self"
// Handle "" in the same way!
//*************************************************************************************************************
if (
( sTargetName == SPECIALTARGET_SELF ) || // "_self"
( sTargetName.getLength() < 1 ) // ""
( sTargetName == SPECIALTARGET_SELF ) ||
( sTargetName.getLength() < 1 )
)
{
eResult = eSELF;
eResult = E_SELF;
}
else
//*************************************************************************************************************
// 3) Look for "_top".
// We must do it before "_parent" because it can a be combination of existing parent - frame type and ...
// I.III) Look for "_top"
// A task is top everytime!
//*************************************************************************************************************
if( sTargetName == SPECIALTARGET_TOP )
{
switch( eFrameType )
{
// a) A normal frame without a parent is TOP and must handle it by himself.
case eFRAME : {
if( bParentExist == sal_False )
{
eResult = eSELF;
}
}
break;
// b) A task is TOP every time and must handle it by himself.
// c) A plugin frame ... too.
case eTASK :
case ePLUGINFRAME : {
eResult = eSELF;
}
break;
}
eResult = E_SELF;
}
else
//*************************************************************************************************************
// 4) Look for "_parent". We must handle these as DIRECT parent only. It's not a flag to search at parents ...
//
// Attention: If a parent exist we return ePARENT as recommendation ...
// but don't do it if frame type different from eFRAME(!) ...
// because; otherwise the parent is the desktop automaticly!!!
// (see ATTENTION a beginning of these function for further informations)
// I.IV) Look for "_beamer"
//*************************************************************************************************************
if (
( sTargetName == SPECIALTARGET_PARENT ) &&
( bParentExist == sal_True ) &&
( eFrameType == eFRAME )
)
if( sTargetName == SPECIALTARGET_BEAMER )
{
eResult = ePARENT;
eResult = E_BEAMER;
}
else
//*************************************************************************************************************
// ATTENTION!
// We have searched for special targets only before ... and it was an exclusive search.
// [ if() else if() else ... ]
// But now we must search for any named frames and use search flags to do that in different combinations!
// Look for any untested flag before if no result exist at that time!
// [ if_no_result(); if_no_result(); return result ]
//*************************************************************************************************************
{
//*****************************************************************************************************
// 5) Look for SELF. Check right name.
// We don't must look for an empty target name "" (!)
// because we have already done it in 2).
// Dont handle SELF for desktop!
//*****************************************************************************************************
//*********************************************************************************************************
// II) Special target names was handled ...
// Now look for right flags.
// Combine search results: if(); if() ...
//
// II.I) Look for SELF.
// Use given frame name to do that. It couldn't be empty(!) - because this was handled in step I.II).
//*********************************************************************************************************
if (
( eFrameType != eDESKTOP ) &&
( nSearchFlags & FrameSearchFlag::SELF ) &&
( sTargetName == sFrameName )
)
{
eResult = eSELF;
eResult = E_SELF;
}
//*****************************************************************************************************
// 6) Look for PARENT.
// You can do it for our desktop ... because he mst support search on his children!
// Our implementation will protect us against SELF/_self/"" on the desktop ...
//*****************************************************************************************************
//*********************************************************************************************************
// II.II) Look for PARENT.
// Is allowed on tasks if outside search of it is allowed!
// Don't check name of parent here - otherwise we return the desktop as result ...
//*********************************************************************************************************
if (
( eResult == eUNKNOWN ) &&
( eResult != E_SELF ) &&
( nSearchFlags & FrameSearchFlag::PARENT ) &&
( bParentExist == sal_True ) &&
( eFrameType != eDESKTOP )
( bLeaveTask == sal_True )
)
{
eResult = eUP;
eResult = E_FORWARD_UP;
}
//*************************************************************************************************************
// 7) Look for CHILDREN.
// Attention: In 6) we set return value to eUP ... but other flags can combined with these one!
// zB CHILDREN
// In these case we must correct our result to eALL, I think!
//*************************************************************************************************************
//*********************************************************************************************************
// II.II) Look for CHILDREN.
// Ignore flag if no childrens exist!
//*********************************************************************************************************
if (
( eResult != E_SELF ) &&
( nSearchFlags & FrameSearchFlag::CHILDREN ) &&
( bChildrenExist == sal_True )
)
{
switch( eResult )
{
case eUNKNOWN : {
eResult = eDOWN;
}
break;
case eUP : {
eResult = eALL;
}
break;
case E_UNKNOWN : eResult = E_DEEP_DOWN;
break;
case E_FORWARD_UP : eResult = E_DEEP_BOTH;
break;
}
}
//*************************************************************************************************************
// 8) Search for SIBLINGS.
// We must check for existing parents because we can search our siblings as children of our parent only!
//*************************************************************************************************************
//*********************************************************************************************************
// II.III) Look for SIBLINGS.
// These change a deep to a flat search!
//*********************************************************************************************************
if (
( eResult == eUNKNOWN ) &&
( nSearchFlags & FrameSearchFlag::SIBLINGS ) &&
( bParentExist == sal_True ) &&
( eFrameType != eDESKTOP )
( eResult != E_SELF ) &&
( nSearchFlags & FrameSearchFlag::SIBLINGS )
)
{
eResult = eSIBLINGS;
}
//*************************************************************************************************************
// 9) Search for TASKS.
// If CREATE is set we must forward call to desktop. He is the only one, who can do that!
//*************************************************************************************************************
if (
( eResult == eUNKNOWN ) &&
( nSearchFlags & FrameSearchFlag::TASKS )
)
{
if( nSearchFlags & FrameSearchFlag::CREATE )
switch( eResult )
{
switch( eFrameType )
{
case eTASK :
case ePLUGINFRAME :
case eFRAME : {
eResult = eUP;
}
break;
case eDESKTOP : {
eResult = eCREATE;
}
break;
}
}
else
{
switch( eFrameType )
{
case eTASK :
case ePLUGINFRAME : {
eResult = eSELF;
}
break;
case eFRAME : {
eResult = eUP;
}
break;
case eDESKTOP : {
eResult = eDOWN;
}
break;
}
case E_DEEP_DOWN : eResult = E_FLAT_DOWN;
break;
case E_DEEP_BOTH : eResult = E_FLAT_BOTH;
break;
}
}
}
// Return result of operation.
//*************************************************************************************************************
// possible results:
// E_UNKNOWN
// E_SELF
// E_BEAMER
// E_FORWARD_UP
// E_DEEP_DOWN
// E_DEEP_BOTH
// E_FLAT_DOWN
// E_FLAT_BOTH
//*************************************************************************************************************
return eResult;
}
//*****************************************************************************************************************
// interface
// private method
//*****************************************************************************************************************
Reference< XFrame > TargetFinder::helpDownSearch( const Reference< XFrames >& xChildFrameAccess ,
const OUString& sTargetName )
ETargetClass TargetFinder::impl_classifyForFrame( sal_Bool bParentExist ,
sal_Bool bChildrenExist ,
const OUString& sFrameName ,
const OUString& sParentName ,
const OUString& sTargetName ,
sal_Int32 nSearchFlags )
{
// Safe impossible cases.
// We don't accept all incoming parameter!
LOG_ASSERT( impldbg_checkParameter_helpDownSearch( xChildFrameAccess, sTargetName ), "TargetFinder::helpDownSearch()\nInvalid parameter detected!\n" )
ETargetClass eResult = E_UNKNOWN;
// Set default return value if method failed.
Reference< XFrame > xResult;
// Get a collection of all childs of our owner frame,
// and search given target name in these list.
Sequence< Reference< XFrame > > seqChilds = xChildFrameAccess->queryFrames( FrameSearchFlag::CHILDREN );
sal_uInt32 nCount = seqChilds.getLength();
sal_uInt32 nPosition = 0;
for( nPosition=0; nPosition<nCount; ++nPosition )
//*************************************************************************************************************
// I) Handle special target names.
// Make an exclusiv search: if() else if() ...
//
// I.I) Look for "_blank"
// Only the desktop can create new tasks. Forward search to parent!
//*************************************************************************************************************
if( sTargetName == SPECIALTARGET_BLANK )
{
if( seqChilds[nPosition]->getName() == sTargetName )
if( bParentExist == sal_True )
{
xResult = seqChilds[nPosition];
break;
eResult = E_FORWARD_UP;
}
}
else
//*************************************************************************************************************
// I.II) Look for "_self"
// Handle "" in the same way!
//*************************************************************************************************************
if (
( sTargetName == SPECIALTARGET_SELF ) ||
( sTargetName.getLength() < 1 )
)
{
eResult = E_SELF;
}
else
//*************************************************************************************************************
// I.III) Look for "_top"
// A frame without a parent is top - otherwhise it's one of his parents!
//*************************************************************************************************************
if( sTargetName == SPECIALTARGET_TOP )
{
if( bParentExist == sal_False )
{
eResult = E_SELF;
}
else
{
eResult = E_FORWARD_UP;
}
}
else
//*************************************************************************************************************
// I.IV) Look for "_parent"
// Ignore it if no parent exist!
//*************************************************************************************************************
if( sTargetName == SPECIALTARGET_PARENT )
{
if( bParentExist == sal_True )
{
eResult = E_PARENT;
}
}
else
//*************************************************************************************************************
// I.V) Look for "_beamer"
// Only a task can handle or create the beamer!
//*************************************************************************************************************
if (
( sTargetName == SPECIALTARGET_BEAMER ) &&
( bParentExist == sal_True )
)
{
eResult = E_FORWARD_UP;
}
else
{
//*********************************************************************************************************
// II) Special target names was handled ...
// Now look for right flags.
// Combine search results: if(); if() ...
//
// II.I) Look for SELF.
// Use given frame name to do that. It couldn't be empty(!) - because this was handled in step I.II).
//*********************************************************************************************************
if (
( nSearchFlags & FrameSearchFlag::SELF ) &&
( sTargetName == sFrameName )
)
{
eResult = E_SELF;
}
//*********************************************************************************************************
// II.II) Look for PARENT.
// Ignore flag if no parent exist! Check his name here to break search erlier!
// Ignore flag if we are a top frame and search outside current task isnt allowed.
//*********************************************************************************************************
if (
( eResult != E_SELF ) &&
( nSearchFlags & FrameSearchFlag::PARENT ) &&
( bParentExist == sal_True )
)
{
if( sParentName == sTargetName )
{
eResult = E_PARENT;
}
else
{
eResult = E_FORWARD_UP;
}
}
//*********************************************************************************************************
// II.III) Look for CHILDREN.
// Ignore flag if no childrens exist! Combine it with already set decisions!
//*********************************************************************************************************
if (
( eResult != E_SELF ) &&
( eResult != E_PARENT ) &&
( nSearchFlags & FrameSearchFlag::CHILDREN ) &&
( bChildrenExist == sal_True )
)
{
switch( eResult )
{
case E_UNKNOWN : eResult = E_DEEP_DOWN;
break;
case E_FORWARD_UP : eResult = E_DEEP_BOTH;
break;
}
}
//*********************************************************************************************************
// II.IV) Look for SIBLINGS.
// These change a deep to a flat search!
//*********************************************************************************************************
if (
( eResult != E_SELF ) &&
( eResult != E_PARENT ) &&
( nSearchFlags & FrameSearchFlag::SIBLINGS )
)
{
switch( eResult )
{
case E_DEEP_DOWN : eResult = E_FLAT_DOWN;
break;
case E_DEEP_BOTH : eResult = E_FLAT_BOTH;
break;
}
}
}
return xResult;
//*************************************************************************************************************
// possible results:
// E_UNKNOWN
// E_SELF
// E_PARENT
// E_FORWARD_UP
// E_DEEP_DOWN
// E_DEEP_BOTH
// E_FLAT_DOWN
// E_FLAT_BOTH
//*************************************************************************************************************
return eResult;
}
//_________________________________________________________________________________________________________________
// debug methods
//_________________________________________________________________________________________________________________
/*-----------------------------------------------------------------------------------------------------------------
The follow methods check parameter for other functions. If a parameter or his value is non valid,
we return "sal_False". (else sal_True) This mechanism is used to throw an ASSERT!
ATTENTION
If you miss a test for one of this parameters, contact the autor or add it himself !(?)
But ... look for right testing! See using of this methods!
-----------------------------------------------------------------------------------------------------------------*/
#ifdef ENABLE_ASSERTIONS
//*****************************************************************************************************************
// Check for valid pointer only in the moment - I think to control all combinations of flags is'nt a good idea ...
// The target name can be empty but we must look for valid enum values.
sal_Bool TargetFinder::impldbg_checkParameter_classify( const Reference< XFrame >& xOwner ,
const OUString& sTargetName ,
sal_Int32 nSearchFlags )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xOwner == NULL ) ||
( xOwner.is() == sal_False ) ||
( &sTargetName == NULL )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
//*****************************************************************************************************************
// We can't work with invalid references and don't accept special target names!
// We search for realy named frames only.
sal_Bool TargetFinder::impldbg_checkParameter_helpDownSearch( const Reference< XFrames >& xChildFrameAccess ,
const OUSTRING& sTargetName )
{
// Set default return value.
sal_Bool bOK = sal_True;
// Check parameter.
if (
( &xChildFrameAccess == NULL ) ||
( xChildFrameAccess.is()== sal_False ) ||
( &sTargetName == NULL ) ||
( sTargetName == SPECIALTARGET_BLANK ) ||
( sTargetName == SPECIALTARGET_SELF ) ||
( sTargetName == SPECIALTARGET_PARENT ) ||
( sTargetName == SPECIALTARGET_TOP )
)
{
bOK = sal_False ;
}
// Return result of check.
return bOK ;
}
#endif // #ifdef ENABLE_ASSERTIONS
} // namespace framework

View File

@ -2,9 +2,9 @@
*
* $RCSfile: taskcreator.cxx,v $
*
* $Revision: 1.2 $
* $Revision: 1.3 $
*
* last change: $Author: mba $ $Date: 2000-12-05 17:42:02 $
* last change: $Author: as $ $Date: 2001-03-09 14:42:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -166,6 +166,8 @@ Reference< XFrame > TaskCreator::createNewSystemTask( const OUString& sName )
// Method is not designed for all incoming parameter!
LOG_ASSERT( impldbg_checkParameter_createNewSystemTask( sName ), "TaskCreator::createNewSystemTask()\nInvalid parameter detected!\n" )
OUString sFrameName = impl_filterNames( sName );
// We must append a new task at our desktop.
// If no desktop exist we cant work correctly.
// Desktop is an one instance service. We will get a reference to it only!
@ -206,14 +208,11 @@ Reference< XFrame > TaskCreator::createNewSystemTask( const OUString& sName )
// Don't forget to create tree-bindings! Set this desktop as parent of new task ...
// ... and append it to his container.
// (Parent will automaticly set by "append()"!)
xTask->setName( sName );
xTask->setName( sFrameName );
xDesktop->getFrames()->append( xTask );
// Set window on task.
xTask->initialize( xWindow );
/* HACK for VCL */
// xWindow->setPosSize ( 0, 0, 500, 500, PosSize::POSSIZE );
xWindow->setEnable ( sal_True );
/* HACK for VCL */
xWindow->setEnable( sal_True );
}
}
@ -232,12 +231,36 @@ Reference< XFrame > TaskCreator::createNewBrowserTask( const OUString& sName )
// Set default return value if method failed.
Reference< XFrame > xPlugInFrame;
OUString sFrameName = impl_filterNames( sName );
LOG_ASSERT( sal_False, "TaskCreator::createNewBrowserTask()\nNot supported yet! Return empty reference.\n" )
// Return result of operation.
return xPlugInFrame;
}
//*****************************************************************************************************************
// private method
//*****************************************************************************************************************
OUString TaskCreator::impl_filterNames( const OUString& sName )
{
// Filter special names which can't be a valid frame name!
// Attention: "_beamer" is a valid name - because:
// It exist one beamer for one task tree only.
// If he exist we can find it - otherwhise he will be created by our task-frame!
OUString sReturn = sName;
if (
( sName == SPECIALTARGET_BLANK ) ||
( sName == SPECIALTARGET_SELF ) ||
( sName == SPECIALTARGET_PARENT ) ||
( sName == SPECIALTARGET_TOP )
)
{
sReturn = OUString();
}
return sReturn;
}
//_________________________________________________________________________________________________________________
// debug methods
//_________________________________________________________________________________________________________________

View File

@ -2,9 +2,9 @@
*
* $RCSfile: desktop.cxx,v $
*
* $Revision: 1.7 $
* $Revision: 1.8 $
*
* last change: $Author: as $ $Date: 2001-03-05 09:02:19 $
* last change: $Author: as $ $Date: 2001-03-09 14:42:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -780,79 +780,27 @@ Reference< XDispatch > SAL_CALL Desktop::queryDispatch( const URL& aURL
// Safe impossible cases
// Method not defined for all incoming parameter.
LOG_ASSERT( impldbg_checkParameter_queryDispatch( aURL, sTargetFrameName, nSearchFlags ), "Desktop::queryDispatch()\nInvalid parameter detected!\n" )
LOG_PARAMETER_QUERYDISPATCH( "Desktop", m_sName, aURL, sTargetFrameName, nSearchFlags )
// Set default return value.
Reference< XDispatch > xReturn;
Reference< XDispatch > xDispatcher;
// Use helper to classify search direction.
IMPL_ETargetClass eDirection = TargetFinder::classify( this ,
sTargetFrameName ,
nSearchFlags );
// Use returned recommendation to search right frame!
switch( eDirection )
if( sTargetFrameName == SPECIALTARGET_BLANK )
{
case eCREATE : {
xReturn = m_xDispatchHelper;
}
break;
case eDOWN : {
Reference< XDispatchProvider > xTarget( TargetFinder::helpDownSearch( m_xFramesHelper, sTargetFrameName ), UNO_QUERY );
if( xTarget.is() == sal_True )
{
xReturn = xTarget->queryDispatch( aURL, SPECIALTARGET_SELF, 0 );
}
}
break;
}
/* TODO
If new implementation of findFrame/queryDispatch works correctly we can delete these code!
//*************************************************************************************************************
// 1) Handle special mode "_blank"/CREATE TASK!
// We create a special dispatcher which create new tasks on demand if a new dispatch() is called.
//*************************************************************************************************************
// Praeprozessor Bug!
// Wenn nach CREATE ein Space steht wird versucht es durch das Define CREATE aus tools/rtti.hxx zu ersetzen
// was fehlschlaegt und die naechsten 3 Klammern ")){" unterschlaegt!
// Dann meckert der Compiler das natuerlich an ...
if((sTargetFrameName==FRAMETYPE_BLANK)||(nSearchFlags&FrameSearchFlag::CREATE))
{
xReturn = m_xDispatchHelper;
xDispatcher = m_xDispatchHelper;
}
else
//*************************************************************************************************************
// 2) We search for an existing frame to dispatch this URL.
//*************************************************************************************************************
{
// Forbid creation of new tasks at follow calls! We have handled this before.
// OUString sNewTargetFrameName;
// if( sTargetFrameName != FRAMETYPE_BLANK )
// {
// sNewTargetFrameName = sTargetFrameName;
// }
// nSearchFlags |= UNMASK_CREATE ;
// Try to find right frame in current hierarchy to dispatch given URL to it.
Reference< XFrame > xDispatchFrame = findFrame( sTargetFrameName, nSearchFlags );
// Do the follow only, if we have any valid frame for dispatch!
// Otherwise ouer return value will be empty ...
if ( xDispatchFrame.is() == sal_True )
Reference< XFrame > xTarget = findFrame( sTargetFrameName, nSearchFlags );
if( xTarget.is() == sal_True )
{
// Dispatch given URL on found frame.
Reference< XDispatchProvider > xDispatchProvider( xDispatchFrame, UNO_QUERY );
// Safe impossible cases.
// A frame of ouer hierarchy must support XDispatchProvider interface.
LOG_ASSERT( !(xDispatchProvider.is()==sal_False), "Desktop::queryDispatch()\nEvery frame of ouer hieararchy must support XDispatchProvider interface. But I have found a negative example ...!\n" )
xReturn = xDispatchProvider->queryDispatch( aURL, OUString(), FrameSearchFlag::SELF );
xDispatcher = Reference< XDispatchProvider >( xTarget, UNO_QUERY )->queryDispatch( aURL, SPECIALTARGET_SELF, FrameSearchFlag::SELF );
}
}
*/
LOG_RESULT_QUERYDISPATCH( "Desktop", m_sName, xDispatcher )
// Return dispatcher for given URL.
return xReturn;
return xDispatcher;
}
//*****************************************************************************************************************
@ -1030,171 +978,55 @@ Reference< XFrame > SAL_CALL Desktop::findFrame( const OUString& sTargetF
LOCK_MUTEX( aGuard, m_aMutex, "Desktop::findFrame()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_findFrame( sTargetFrameName, nSearchFlags ), "Desktop::findFrame()\nInvalid parameter detected.\n" )
LOG_PARAMETER_FINDFRAME( "Desktop", m_sName, sTargetFrameName, nSearchFlags )
// Set default return value if method failed.
Reference< XFrame > xSearchedFrame;
// Use helper to classify search direction.
IMPL_ETargetClass eDirection = TargetFinder::classify( this ,
sTargetFrameName,
nSearchFlags );
// Use returned recommendation to search right frame or create a new one!
switch( eDirection )
// Ask helper for right decision for given parameter.
sal_Bool bCreationAllowed = sal_False;
ETargetClass eResult = TargetFinder::classify( E_DESKTOP ,
sTargetFrameName ,
nSearchFlags ,
bCreationAllowed ,
m_aChildTaskContainer.hasElements() );
switch( eResult )
{
case eDOWN : {
xSearchedFrame = TargetFinder::helpDownSearch( m_xFramesHelper, sTargetFrameName );
}
break;
case eCREATE : {
OUString sFrameName = sTargetFrameName;
if( sFrameName == SPECIALTARGET_BLANK )
{
sFrameName = OUString();
case E_CREATETASK : {
xSearchedFrame = m_aTaskCreator.createNewSystemTask( sTargetFrameName );
}
xSearchedFrame = m_aTaskCreator.createNewSystemTask( sFrameName );
}
break;
break;
case E_TASKS : {
xSearchedFrame = m_aChildTaskContainer.searchDirectChildren( sTargetFrameName );
}
break;
case E_DEEP_DOWN : {
xSearchedFrame = m_aChildTaskContainer.searchDeepDown( sTargetFrameName );
}
break;
case E_FLAT_DOWN : {
xSearchedFrame = m_aChildTaskContainer.searchFlatDown( sTargetFrameName );
}
break;
#ifdef ENABLE_ASSERTIONS
default: LOG_ERROR( "Desktop::findFrame()", "Unexpected result of TargetFinder::classify() detected!" )
#endif
}
// If no right target could be found - but CREATE flag was set ... do it; create a new task.
if (
( xSearchedFrame.is() == sal_False ) &&
( bCreationAllowed == sal_True )
)
{
xSearchedFrame = m_aTaskCreator.createNewSystemTask( sTargetFrameName );
}
LOG_RESULT_FINDFRAME( "Desktop", m_sName, xSearchedFrame )
// return result of operation.
return xSearchedFrame;
}
/* TODO
If new implementation of findFrame/queryDispatch works correctly we can delete these code!
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
Reference< XFrame > SAL_CALL Desktop::findFrame( const OUString& sTargetFrameName ,
sal_Int32 nSearchFlags ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Desktop::findFrame()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_findFrame( sTargetFrameName, nSearchFlags ), "Desktop::findFrame()\nInvalid parameter detected.\n" )
// Log some special informations about search. (Active in debug version only, if special mode is set!)
LOG_PARAMETER_FINDFRAME( "Desktop", m_sName, sTargetFrameName, nSearchFlags )
// Set default return Value, if method failed
Reference< XFrame > xReturn = Reference< XFrame >();
//*************************************************************************************************************
// 1) If "_blank" searched we must create a new task!
// Attention:
// Don't set a name at new created frame! sTargetFrameName is not a normal name yet.
// "_blank" is not allowed as frame name.
// The helper method will create the new task, initialize it with an empty window and append it on
// ouer frame-hierarchy.
//*************************************************************************************************************
if( sTargetFrameName == FRAMETYPE_BLANK )
{
LOG_TARGETINGSTEP( "Desktop", m_sName, "react to \"_blank\"" )
//xReturn = impl_createNewTask( OUString() );
xReturn = m_aTaskCreator.createNewSystemTask( OUString() );
}
else
//*************************************************************************************************************
// ATTENTION!
// We have searched for special targets only ... but now we must search for any named frames and use search
// flags to do that!
//*************************************************************************************************************
{
//*********************************************************************************************************
// At first we must filter all other special target names!
// You can disable this statement if all these cases are handled before ...
//*********************************************************************************************************
if (
( sTargetFrameName != FRAMETYPE_SELF ) &&
( sTargetFrameName != FRAMETYPE_PARENT) &&
( sTargetFrameName != FRAMETYPE_TOP ) &&
( sTargetFrameName.getLength() > 0 )
)
{
//*****************************************************************************************************
// 2) Search for TASKS.
//*****************************************************************************************************
if (
( nSearchFlags & FrameSearchFlag::TASKS ) &&
( m_aChildTaskContainer.hasElements() == sal_True )
)
{
LOG_TARGETINGSTEP( "Desktop", m_sName, "react to TASKS" )
// Step over all direct childtasks and search in it.
// Lock container for exclusiv access.
// The container is not threadsafe and shared with some helper classes.
// It must be! But don't forget to unlock it.
m_aChildTaskContainer.lock();
sal_uInt32 nCount = m_aChildTaskContainer.getCount();
sal_uInt32 nPosition = 0;
while (
( nPosition < nCount ) &&
( xReturn.is() == sal_False )
)
{
// Get next child and compare with searched name.
// But allow task to search at himself only!
xReturn = m_aChildTaskContainer[nPosition]->findFrame( sTargetFrameName, FrameSearchFlag::SELF );
++nPosition;
}
// Unlock the container.
m_aChildTaskContainer.unlock();
}
//*************************************************************************************************************
// 3) Search for CHILDREN
// Attention:
// We search for ouer childs and his subtrees. That is the reason for using of SELF and CHILDREN as searchflags.
// Never use SIBLINGS for searching. We step over ouer own container. Search for brothers at ouer direct
// childs will do the same and it can be a problem ... RECURSIVE SEARCH ...!
//*************************************************************************************************************
if (
( xReturn.is() == sal_False ) &&
( nSearchFlags & FrameSearchFlag::CHILDREN ) &&
( m_aChildTaskContainer.hasElements() == sal_True )
)
{
LOG_TARGETINGSTEP( "Desktop", m_sName, "react to CHILDREN" )
// Lock container for exclusiv access.
// The container is not threadsafe and shared with some helper classes.
// It must be! But don't forget to unlock it.
m_aChildTaskContainer.lock();
sal_uInt32 nCount = m_aChildTaskContainer.getCount();
sal_uInt32 nPosition = 0;
while (
( nPosition < nCount ) &&
( xReturn.is() == sal_False )
)
{
// Get next child and search on it for subframes with searched name.
xReturn = m_aChildTaskContainer[nPosition]->findFrame( sTargetFrameName, FrameSearchFlag::SELF | FrameSearchFlag::CHILDREN );
++nPosition;
}
m_aChildTaskContainer.unlock();
}
//*************************************************************************************************************
// 4) If we have the license to create a new task then we do it.
// Create a new task, initialize it with an empty window, set default parameters and append it on desktop!
//*************************************************************************************************************
// Praeprozessor Bug!
// Wenn nach CREATE ein Space steht wird versucht es durch das Define CREATE aus tools/rtti.hxx zu ersetzen
// was fehlschlaegt und die naechsten 3 Klammern ")){" unterschlaegt!
// Dann meckert der Compiler das natuerlich an ...
if((xReturn.is()==sal_False)&&(nSearchFlags&FrameSearchFlag::CREATE))
{
LOG_TARGETINGSTEP( "Desktop", m_sName, "react to CREATE" )
//xReturn = impl_createNewTask( sTargetFrameName );
xReturn = m_aTaskCreator.createNewSystemTask( sTargetFrameName );
}
}
}
// Log some special informations about search. (Active in debug version only, if special mode is set!)
LOG_RESULT_FINDFRAME( "Desktop", m_sName, xReturn )
// Return with result of operation.
return xReturn;
}
*/
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************

View File

@ -2,9 +2,9 @@
*
* $RCSfile: frame.cxx,v $
*
* $Revision: 1.15 $
* $Revision: 1.16 $
*
* last change: $Author: mba $ $Date: 2001-02-15 08:49:10 $
* last change: $Author: as $ $Date: 2001-03-09 14:42:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -680,331 +680,76 @@ Reference< XFrame > SAL_CALL Frame::findFrame( const OUString& sTargetFrame
// Protection against recursion while searching in parent frames!
// See switch-statement eSIBLINGS, eALL for further informations.
if ( m_bRecursiveSearchProtection == sal_False )
if( m_bRecursiveSearchProtection == sal_False )
{
LOG_PARAMETER_FINDFRAME( "Frame", m_sName, sTargetFrameName, nSearchFlags )
// Use helper to classify search direction.
IMPL_ETargetClass eDirection = TargetFinder::classify( this ,
sTargetFrameName ,
nSearchFlags );
// Use returned recommendation to search right frame!
switch( eDirection )
// Attention: If he return ...BOTH -> please search down first; upper then!
Reference< XFrame > xParent ( m_xParent, UNO_QUERY ) ;
sal_Bool bCreationAllowed = sal_False ;
ETargetClass eResult = TargetFinder::classify( E_FRAME ,
sTargetFrameName ,
nSearchFlags ,
bCreationAllowed ,
m_aChildFrameContainer.hasElements() ,
m_sName ,
xParent.is() ,
xParent.is() ? xParent->getName() : OUString() );
switch( eResult )
{
case eSELF : {
xSearchedFrame = this;
}
break;
case ePARENT : {
xSearchedFrame = Reference< XFrame >( m_xParent, UNO_QUERY );
}
break;
case eUP : {
xSearchedFrame = m_xParent->findFrame( sTargetFrameName, nSearchFlags );
}
break;
case eDOWN : {
xSearchedFrame = TargetFinder::helpDownSearch( m_xFramesHelper, sTargetFrameName );
}
break;
case eSIBLINGS : {
m_bRecursiveSearchProtection = sal_True;
xSearchedFrame = m_xParent->findFrame( sTargetFrameName, FrameSearchFlag::CHILDREN );
m_bRecursiveSearchProtection = sal_False;
}
break;
case eALL : {
m_bRecursiveSearchProtection = sal_True;
xSearchedFrame = TargetFinder::helpDownSearch( m_xFramesHelper, sTargetFrameName );
if( xSearchedFrame.is() == sal_False )
{
xSearchedFrame = m_xParent->findFrame( sTargetFrameName, nSearchFlags );
case E_SELF : {
xSearchedFrame = this;
}
m_bRecursiveSearchProtection = sal_False;
}
break;
break;
case E_PARENT : {
xSearchedFrame = xParent;
}
break;
case E_FORWARD_UP : {
m_bRecursiveSearchProtection = sal_True;
xSearchedFrame = m_xParent->findFrame( sTargetFrameName, nSearchFlags );
m_bRecursiveSearchProtection = sal_False;
}
break;
case E_DEEP_DOWN : {
xSearchedFrame = m_aChildFrameContainer.searchDeepDown( sTargetFrameName );
}
break;
case E_DEEP_BOTH : {
xSearchedFrame = m_aChildFrameContainer.searchDeepDown( sTargetFrameName );
if( xSearchedFrame.is() == sal_False )
{
m_bRecursiveSearchProtection = sal_True;
xSearchedFrame = m_xParent->findFrame( sTargetFrameName, nSearchFlags );
m_bRecursiveSearchProtection = sal_False;
}
}
break;
case E_FLAT_DOWN : {
xSearchedFrame = m_aChildFrameContainer.searchFlatDown( sTargetFrameName );
}
break;
case E_FLAT_BOTH : {
xSearchedFrame = m_aChildFrameContainer.searchFlatDown( sTargetFrameName );
if( xSearchedFrame.is() == sal_False )
{
m_bRecursiveSearchProtection = sal_True;
xSearchedFrame = m_xParent->findFrame( sTargetFrameName, nSearchFlags );
m_bRecursiveSearchProtection = sal_False;
}
}
break;
#ifdef ENABLE_ASSERTIONS
default: LOG_ERROR( "Frame::findFrame()", "Unexpected result of TargetFinder::classify() detected!" )
break;
#endif
}
LOG_RESULT_FINDFRAME( "Frame", m_sName, xSearchedFrame )
}
// Return result of operation.
return xSearchedFrame;
}
/*TODO
If new implementation of findFrame/queryDispatch works correctly we can delete these old code!
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
Reference< XFrame > SAL_CALL Frame::findFrame( const OUString& sTargetFrameName ,
sal_Int32 nSearchFlags ) throw( RuntimeException )
{
// Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::findFrame()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_findFrame( sTargetFrameName, nSearchFlags ), "Frame::findFrame()\nInvalid parameter detected.\n" )
// Log some special informations about search. (Active in debug version only, if special mode is set!)
LOG_PARAMETER_FINDFRAME( "Frame", m_sName, sTargetFrameName, nSearchFlags )
// Set default return Value, if method failed
Reference< XFrame > xReturn = Reference< XFrame >();
// Protection against recursion while searching in parent frames!
// See search for PARENT for further informations.
if ( m_bRecursiveSearchProtection == sal_False )
{
//*************************************************************************************************************
// 1) Search for "_self" or ""!. We handle this as self too!
//*************************************************************************************************************
if (
( sTargetFrameName == FRAMETYPE_SELF ) ||
( sTargetFrameName.getLength() < 1 )
)
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to \"_self\" or \"\"" )
xReturn = Reference< XFrame >( static_cast< OWeakObject* >( this ), UNO_QUERY );
}
else
//*************************************************************************************************************
// 2) If "_top" searched and we have no parent set us for return himself.
//*************************************************************************************************************
if( sTargetFrameName == FRAMETYPE_TOP )
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to \"_top\"" )
if( m_xParent.is() == sal_False )
{
// If no parent well known we are the top frame!
LOG_TARGETINGSTEP( "Frame", m_sName, "no parent exist!" )
xReturn = Reference< XFrame >( static_cast< OWeakObject* >( this ), UNO_QUERY );
}
else
{
// If parent well kwnown we must forward searching to it.
LOG_TARGETINGSTEP( "Frame", m_sName, "parent exist!" )
xReturn = m_xParent->findFrame( FRAMETYPE_TOP, 0 );
}
}
else
//*************************************************************************************************************
// 3) If "_parent" searched and we have any one, set it for return.
//*************************************************************************************************************
if( sTargetFrameName == FRAMETYPE_PARENT )
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to \"_parent\"" )
if( m_xParent.is() == sal_True )
{
// If parent well kwnown we must return it as result.
LOG_TARGETINGSTEP( "Frame", m_sName, "parent exist!" )
xReturn = Reference< XFrame >( m_xParent, UNO_QUERY );
}
else
{
// Else we can't return anything and our default is used!
LOG_TARGETINGSTEP( "Frame", m_sName, "no parent exist!" )
}
}
else
//*************************************************************************************************************
// 4) Forward "_blank" to desktop. He can create new task only!
// (Look for existing parent!)
//*************************************************************************************************************
if( sTargetFrameName == FRAMETYPE_BLANK )
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to \"_blank\"" )
if( m_xParent.is() == sal_True )
{
LOG_TARGETINGSTEP( "Frame", m_sName, "forward \"_blank\" to parent" )
xReturn = m_xParent->findFrame( FRAMETYPE_BLANK, 0 );
}
else
{
// Else we cant create this new frame!
LOG_TARGETINGSTEP( "Frame", m_sName, "can create new frame for \"_blank\"" )
}
}
else
//*************************************************************************************************************
// ATTENTION!
// We have searched for special targets only ... but now we must search for any named frames and use search
// flags to do that!
//*************************************************************************************************************
{
//*********************************************************************************************************
// At first we must filter all other special target names!
// You can disable this statement if all these cases are handled before ...
//*********************************************************************************************************
// if (
// ( sTargetFrameName != FRAMETYPE_SELF ) &&
// ( sTargetFrameName != FRAMETYPE_PARENT) &&
// ( sTargetFrameName != FRAMETYPE_TOP ) &&
// ( sTargetFrameName != FRAMETYPE_BLANK ) &&
// ( sTargetFrameName.getLength() > 0 )
// )
{
//*****************************************************************************************************
// 5) If SELF searched and given name is the right one, we can return us as result.
//*****************************************************************************************************
if (
( nSearchFlags & FrameSearchFlag::SELF ) &&
( sTargetFrameName == m_sName )
)
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to SELF" )
xReturn = Reference< XFrame >( static_cast< OWeakObject* >( this ), UNO_QUERY );
}
//*****************************************************************************************************
// 6) If SELF searched and given name is the right one, we can return us as result.
//*****************************************************************************************************
if (
( xReturn.is() == sal_False ) &&
( nSearchFlags & FrameSearchFlag::PARENT ) &&
( m_xParent.is() == sal_True )
)
{
// We must protect us against searching from top to bottom!
m_bRecursiveSearchProtection = sal_True ;
LOG_TARGETINGSTEP( "Frame", m_sName, "forward PARENT to parent" )
xReturn = m_xParent->findFrame( sTargetFrameName, nSearchFlags );
m_bRecursiveSearchProtection = sal_False ;
}
//*************************************************************************************************************
// 7) Search for CHILDREN.
//*************************************************************************************************************
if (
( xReturn.is() == sal_False ) &&
( nSearchFlags & FrameSearchFlag::CHILDREN ) &&
( m_aChildFrameContainer.hasElements() == sal_True )
)
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to CHILDREN" )
// Search at own container of childframes if allowed.
// Lock the container. Nobody should append or remove elements during next time.
// But don't forget to unlock it again!
m_aChildFrameContainer.lock();
// First search only for direct subframes.
// Break loop, if something was found or all container items was compared.
sal_uInt32 nCount = m_aChildFrameContainer.getCount();
sal_uInt32 nPosition = 0;
while (
( xReturn.is() == sal_False ) &&
( nPosition < nCount )
)
{
xReturn = m_aChildFrameContainer[nPosition]->findFrame( sTargetFrameName, FrameSearchFlag::SELF );
++nPosition;
}
// If no direct subframe was found, search now subframes of subframes.
nPosition = 0;
while (
( xReturn.is() == sal_False ) &&
( nPosition < nCount )
)
{
xReturn = m_aChildFrameContainer[nPosition]->findFrame( sTargetFrameName, FrameSearchFlag::CHILDREN );
++nPosition;
}
// Don't forget to unlock the container!
m_aChildFrameContainer.unlock();
}
//*************************************************************************************************************
// 8) Search for SIBLINGS.
// Attention:
// Continue search on brothers ( subframes of parent ) but don't let them search their brothers too ...
// If FrameSearchFlag_CHILDREN is set, the children of the brothers will be searched also, otherwise not.
//*************************************************************************************************************
if (
( xReturn.is() == sal_False ) &&
( nSearchFlags & FrameSearchFlag::SIBLINGS ) &&
( m_xParent.is() == sal_True )
)
{
LOG_TARGETINGSTEP( "Frame", m_sName, "react to SIBLINGS" )
// Get all siblings from ouer parent and collect some informations about result set.
// Count of siblings, access to list ...
Reference< XFrames > xFrames = m_xParent->getFrames();
Sequence< Reference< XFrame > > seqFrames = xFrames->queryFrames( FrameSearchFlag::CHILDREN );
Reference< XFrame >* pArray = seqFrames.getArray();
sal_uInt16 nCount = (sal_uInt16)seqFrames.getLength();
Reference< XFrame > xThis ( (OWeakObject*)this, UNO_QUERY );
Reference< XFrame > xSearchFrame;
// Search siblings "pure" - no search on brothers of brothers - no search at children of siblings!
// Break loop, if something was found or all items was threated.
sal_uInt16 nPosition = 0;
while (
( xReturn.is() == sal_False ) &&
( nPosition < nCount )
)
{
// Exclude THIS frame! We are a child of ouer parent and exist in result list of "queryFrames()" too.
if ( pArray[nPosition] != xThis )
{
xReturn = pArray[nPosition]->findFrame( sTargetFrameName, FrameSearchFlag::SELF );
}
++nPosition;
}
// If no sibling match ouer search, try it again with children of ouer siblings.
nPosition = 0;
while (
( xReturn.is() == sal_False ) &&
( nPosition < nCount )
)
{
// Exclude THIS frame again.
if ( pArray[nPosition] != xThis )
{
xReturn = pArray[nPosition]->findFrame( sTargetFrameName, FrameSearchFlag::CHILDREN );
}
++nPosition;
}
}
//*************************************************************************************************************
// 9) Search for TASKS.
// Attention:
// The Task-implementation control these flag too! But if search started from the bottom of the tree, we must
// forward it to ouer parents. They can be tasks only!
//*************************************************************************************************************
if (
( xReturn.is() == sal_False ) &&
( nSearchFlags & FrameSearchFlag::TASKS ) &&
( m_xParent.is() == sal_True )
)
{
// We must protect us against recursive calls from top to bottom.
m_bRecursiveSearchProtection = sal_True ;
LOG_TARGETINGSTEP( "Frame", m_sName, "forward TASKS to parent" )
xReturn = m_xParent->findFrame( sTargetFrameName, nSearchFlags );
m_bRecursiveSearchProtection = sal_False;
}
//*************************************************************************************************************
// 10) If CREATE is set we must forward call to desktop. He is the only one, who can do that.
//*************************************************************************************************************
// Praeprozessor Bug!
// Wenn nach CREATE ein Space steht wird versucht es durch das Define CREATE aus tools/rtti.hxx zu ersetzen
// was fehlschlaegt und die naechsten 3 Klammern ")){" unterschlaegt!
// Dann meckert der Compiler das natuerlich an ...
if((xReturn.is()==sal_False)&&(nSearchFlags&FrameSearchFlag::CREATE)&&(m_xParent.is()==sal_True))
{
LOG_TARGETINGSTEP( "Frame", m_sName, "forward CREATE to parent" )
xReturn = m_xParent->findFrame( sTargetFrameName, FrameSearchFlag::CREATE );
}
}
}
}
// Log some special informations about search. (Active in debug version only, if special mode is set!)
LOG_RESULT_FINDFRAME( "Frame", m_sName, xReturn )
// Return with result of operation.
return xReturn;
}
*/
//*****************************************************************************************************************
// XFrame
//*****************************************************************************************************************
@ -1466,11 +1211,11 @@ void SAL_CALL Frame::focusGained( const awt::FocusEvent& aEvent ) throw( Runtime
//*****************************************************************************************************************
void SAL_CALL Frame::focusLost( const awt::FocusEvent& aEvent ) throw( RuntimeException )
{
// Ready for multithreading
/* // Ready for multithreading
LOCK_MUTEX( aGuard, m_aMutex, "Frame::focusLost()" )
// Safe impossible cases
LOG_ASSERT( impldbg_checkParameter_focusLost( aEvent ), "Frame::focusLost()\nInvalid parameter detected.\n" )
/*
// We must send UI_DEACTIVATING to our listener and forget our current FOCUS state!
m_eActiveState = ACTIVE;
impl_sendFrameActionEvent( FrameAction_FRAME_UI_DEACTIVATING );

View File

@ -2,9 +2,9 @@
*
* $RCSfile: test.cxx,v $
*
* $Revision: 1.5 $
* $Revision: 1.6 $
*
* last change: $Author: as $ $Date: 2001-02-26 08:45:23 $
* last change: $Author: as $ $Date: 2001-03-09 14:42:26 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -274,6 +274,7 @@ class TestApplication : public Application
void impl_testDesktop ( const Reference< XDesktop >& xDesktop );
void impl_buildTree ( const Reference< XDesktop >& xDesktop );
void impl_logTree ( const Reference< XDesktop >& xDesktop );
#endif
#ifdef TEST_PLUGIN
@ -298,6 +299,13 @@ class TestApplication : public Application
#endif
#endif
#ifdef TEST_TREESEARCH
sal_Bool impl_testTreeSearch();
#endif
//*************************************************************************************************************
private:
//*************************************************************************************************************
private:
@ -325,7 +333,7 @@ void TestApplication::Main()
// Init global servicemanager and set it.
ServiceManager aManager;
m_xFactory = aManager.getPrivateUNOServiceManager( DECLARE_ASCII("test.rdb") );
m_xFactory = aManager.getGlobalUNOServiceManager();
setProcessServiceFactory( m_xFactory );
// Control sucess of operation.
@ -339,6 +347,8 @@ void TestApplication::Main()
test area
**************************************************************************************************************/
sal_Bool bState = sal_True;
//-------------------------------------------------------------------------------------------------------------
#ifdef TEST_FILTERCACHE
impl_testFilterCache();
@ -374,91 +384,22 @@ void TestApplication::Main()
impl_testFilterRegistration();
#endif
/*
Reference< XDispatchProvider > xProvider( xDesktop, UNO_QUERY );
URL aURL;
aURL.Complete = OUString(RTL_CONSTASCII_USTRINGPARAM("file://d|/bla.htm"));
Reference< XDispatch > xDispatcher = xProvider->queryDispatch( aURL, OUString(RTL_CONSTASCII_USTRINGPARAM("_blank")), 0 );
if( xDispatcher.is()==sal_True )
{
xDispatcher->dispatch(aURL, Sequence< PropertyValue >() );
aURL.Complete = OUString(RTL_CONSTASCII_USTRINGPARAM("file://d|/bla.htm"));
xDispatcher->dispatch(aURL, Sequence< PropertyValue >() );
aURL.Complete = OUString(RTL_CONSTASCII_USTRINGPARAM("file://d|/bla.html"));
xDispatcher->dispatch(aURL, Sequence< PropertyValue >() );
aURL.Complete = OUString(RTL_CONSTASCII_USTRINGPARAM("file://d|/test.txt"));
xDispatcher->dispatch(aURL, Sequence< PropertyValue >() );
}
*/
/*
Reference< XMultiServiceFactory > xFrameLoaderFactory( xGlobalServiceManager->createInstance( SERVICENAME_FRAMELOADERFACTORY ), UNO_QUERY );
LOG_ASSERT( !(xFrameLoaderFactory.is()==sal_False), "TestApplication::Main()\nServicename of FrameLoaderFactory is unknown.\n\n" );
Sequence< OUString > seqFilterNames = xFrameLoaderFactory->getAvailableServiceNames();
if (seqFilterNames.getLength()>0)
{
Sequence< Any > seqArguments(1);
seqArguments[0] <<= seqFilterNames[0];
//-------------------------------------------------------------------------------------------------------------
#ifdef TEST_TREESEARCH
bState = impl_testTreeSearch();
#endif
Reference< XPropertySet > xPropertySet( xFrameLoaderFactory->createInstanceWithArguments( OUString(), seqArguments ), UNO_QUERY );
if ( xPropertySet.is()==sal_True )
{
Sequence< OUString > seqPattern ;
Sequence< OUString > seqExtension ;
sal_Int32 nFlags ;
sal_Int32 nFormat ;
OUString sMimeType ;
OUString sFilterName ;
OUString sDetectService ;
Reference< XInterface > xLoader ;
OUString sURL ;
PropertyValue aPropertyValue ;
Any aValue ;
aValue = xPropertySet->getPropertyValue( PROPERTYNAME_PATTERN );
aValue >>= seqPattern;
aValue = xPropertySet->getPropertyValue( PROPERTYNAME_EXTENSION );
aValue >>= seqExtension;
aValue = xPropertySet->getPropertyValue( PROPERTYNAME_FLAGS );
aValue >>= nFlags;
aValue = xPropertySet->getPropertyValue( PROPERTYNAME_FORMAT );
aValue >>= nFormat;
aValue = xPropertySet->getPropertyValue( PROPERTYNAME_MIMETYPE );
aValue >>= sMimeType;
aValue = xPropertySet->getPropertyValue( PROPERTYNAME_FILTERNAME );
aValue >>= sFilterName;
aValue = xPropertySet->getPropertyValue( PROPERTYNAME_DETECTSERVICE );
aValue >>= sDetectService;
sURL = OUString(RTL_CONSTASCII_USTRINGPARAM("file://d|bla.htm")) ;
aPropertyValue.Name = PROPERTYNAME_FILTERNAME ;
aPropertyValue.Value <<= sFilterName ;
seqArguments.realloc(1);
seqArguments[0] <<= aPropertyValue ;
xLoader = xFrameLoaderFactory->createInstanceWithArguments( sURL, seqArguments );
LOG_ASSERT( !(xLoader.is()==sal_False), "TestApplication::Main()\nCreation of loader 1 failed.\n\n" );
sURL = OUString(RTL_CONSTASCII_USTRINGPARAM("file://d|bla.htm")) ;
aPropertyValue.Name = PROPERTYNAME_MIMETYPE ;
aPropertyValue.Value <<= sMimeType ;
seqArguments.realloc(1);
seqArguments[0] <<= aPropertyValue ;
xLoader = xFrameLoaderFactory->createInstanceWithArguments( sURL, seqArguments );
LOG_ASSERT( !(xLoader.is()==sal_False), "TestApplication::Main()\nCreation of loader 2 failed.\n\n" );
sURL = OUString(RTL_CONSTASCII_USTRINGPARAM("file://d|bla.htm")) ;
aPropertyValue.Name = PROPERTYNAME_FORMAT ;
aPropertyValue.Value <<= nFormat ;
seqArguments.realloc(1);
seqArguments[0] <<= aPropertyValue ;
xLoader = xFrameLoaderFactory->createInstanceWithArguments( sURL, seqArguments );
LOG_ASSERT( !(xLoader.is()==sal_False), "TestApplication::Main()\nCreation of loader 3 failed.\n\n" );
}
}
*/
// Execute();
// xFrame->dispose();
// delete pMainWindow;
LOG_ASSERT( sal_False, "TestApplication: test successful ..." )
if( bState = sal_True )
{
LOG_ERROR( "TestApplication::Main()", "Test successful ..." )
}
else
{
LOG_ERROR( "TestApplication::Main()", "Test failed ..." )
}
}
//_________________________________________________________________________________________________________________
@ -1292,3 +1233,269 @@ void TestApplication::impl_testFilterRegistration()
}
}
#endif
//_________________________________________________________________________________________________________________
// test method for search mechanism in our frame tree
//_________________________________________________________________________________________________________________
#ifdef TEST_TREESEARCH
sal_Bool TestApplication::impl_testTreeSearch()
{
// Build an example tree.
Reference< XFrame > xD ( m_xFactory->createInstance( SERVICENAME_DESKTOP ), UNO_QUERY );
Reference< XFrame > xT1 ( m_xFactory->createInstance( SERVICENAME_TASK ), UNO_QUERY );
Reference< XFrame > xT2 ( m_xFactory->createInstance( SERVICENAME_TASK ), UNO_QUERY );
Reference< XFrame > xT3 ( m_xFactory->createInstance( SERVICENAME_TASK ), UNO_QUERY );
Reference< XFrame > xF11 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF12 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF21 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF22 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF211 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF212 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF221 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF2111 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF2112 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF2121 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF2122 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF2211 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF21111 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF21112 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF21121 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF21122 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF21211 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF21212 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF21221 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF21222 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
Reference< XFrame > xF22111 ( m_xFactory->createInstance( SERVICENAME_FRAME ), UNO_QUERY );
xD->setName ( DECLARE_ASCII("D" ) );
xT1->setName ( DECLARE_ASCII("T1" ) );
xT2->setName ( DECLARE_ASCII("T2" ) );
xT3->setName ( DECLARE_ASCII("T3" ) );
xF11->setName ( DECLARE_ASCII("F11" ) );
xF12->setName ( DECLARE_ASCII("F12" ) );
xF21->setName ( DECLARE_ASCII("F21" ) );
xF22->setName ( DECLARE_ASCII("F22" ) );
xF211->setName ( DECLARE_ASCII("F211" ) );
xF212->setName ( DECLARE_ASCII("F212" ) );
xF221->setName ( DECLARE_ASCII("F221" ) );
xF2111->setName ( DECLARE_ASCII("F2111" ) );
xF2112->setName ( DECLARE_ASCII("F2112" ) );
xF2121->setName ( DECLARE_ASCII("F2121" ) );
xF2122->setName ( DECLARE_ASCII("F2122" ) );
xF2211->setName ( DECLARE_ASCII("F2211" ) );
xF21111->setName( DECLARE_ASCII("F21111") );
xF21112->setName( DECLARE_ASCII("F21112") );
xF21121->setName( DECLARE_ASCII("F21121") );
xF21122->setName( DECLARE_ASCII("F21122") );
xF21211->setName( DECLARE_ASCII("F21211") );
xF21212->setName( DECLARE_ASCII("F21212") );
xF21221->setName( DECLARE_ASCII("F21221") );
xF21222->setName( DECLARE_ASCII("F21222") );
xF22111->setName( DECLARE_ASCII("F22111") );
Reference< XFramesSupplier > xSD ( xD , UNO_QUERY );
Reference< XFramesSupplier > xST1 ( xT1 , UNO_QUERY );
Reference< XFramesSupplier > xST2 ( xT2 , UNO_QUERY );
Reference< XFramesSupplier > xST3 ( xT3 , UNO_QUERY );
Reference< XFramesSupplier > xSF11 ( xF11 , UNO_QUERY );
Reference< XFramesSupplier > xSF12 ( xF12 , UNO_QUERY );
Reference< XFramesSupplier > xSF21 ( xF21 , UNO_QUERY );
Reference< XFramesSupplier > xSF22 ( xF22 , UNO_QUERY );
Reference< XFramesSupplier > xSF211 ( xF211 , UNO_QUERY );
Reference< XFramesSupplier > xSF212 ( xF212 , UNO_QUERY );
Reference< XFramesSupplier > xSF221 ( xF221 , UNO_QUERY );
Reference< XFramesSupplier > xSF2111 ( xF2111 , UNO_QUERY );
Reference< XFramesSupplier > xSF2112 ( xF2112 , UNO_QUERY );
Reference< XFramesSupplier > xSF2121 ( xF2121 , UNO_QUERY );
Reference< XFramesSupplier > xSF2122 ( xF2122 , UNO_QUERY );
Reference< XFramesSupplier > xSF2211 ( xF2211 , UNO_QUERY );
Reference< XFramesSupplier > xSF21111 ( xF21111 , UNO_QUERY );
Reference< XFramesSupplier > xSF21112 ( xF21112 , UNO_QUERY );
Reference< XFramesSupplier > xSF21121 ( xF21121 , UNO_QUERY );
Reference< XFramesSupplier > xSF21122 ( xF21122 , UNO_QUERY );
Reference< XFramesSupplier > xSF21211 ( xF21211 , UNO_QUERY );
Reference< XFramesSupplier > xSF21212 ( xF21212 , UNO_QUERY );
Reference< XFramesSupplier > xSF21221 ( xF21221 , UNO_QUERY );
Reference< XFramesSupplier > xSF21222 ( xF21222 , UNO_QUERY );
Reference< XFramesSupplier > xSF22111 ( xF22111 , UNO_QUERY );
xSD->getFrames()->append ( xT1 );
xSD->getFrames()->append ( xT2 );
xSD->getFrames()->append ( xT3 );
xST1->getFrames()->append ( xF11 );
xST1->getFrames()->append ( xF12 );
xST2->getFrames()->append ( xF21 );
xST2->getFrames()->append ( xF22 );
xSF21->getFrames()->append ( xF211 );
xSF21->getFrames()->append ( xF212 );
xSF211->getFrames()->append ( xF2111 );
xSF211->getFrames()->append ( xF2112 );
xSF212->getFrames()->append ( xF2121 );
xSF212->getFrames()->append ( xF2122 );
xSF2111->getFrames()->append ( xF21111 );
xSF2111->getFrames()->append ( xF21112 );
xSF2112->getFrames()->append ( xF21121 );
xSF2112->getFrames()->append ( xF21122 );
xSF2121->getFrames()->append ( xF21211 );
xSF2121->getFrames()->append ( xF21212 );
xSF2122->getFrames()->append ( xF21221 );
xSF2122->getFrames()->append ( xF21222 );
xSF22->getFrames()->append ( xF221 );
xSF221->getFrames()->append ( xF2211 );
xSF2211->getFrames()->append ( xF22111 );
sal_Int32 nFlags = 0;
// Test deep down search
nFlags = FrameSearchFlag::CHILDREN;
if (
( xD->findFrame( DECLARE_ASCII("T1" ), nFlags ) != xT1 ) ||
( xD->findFrame( DECLARE_ASCII("T2" ), nFlags ) != xT2 ) ||
( xD->findFrame( DECLARE_ASCII("T3" ), nFlags ) != xT3 ) ||
( xD->findFrame( DECLARE_ASCII("F11" ), nFlags ) != xF11 ) ||
( xD->findFrame( DECLARE_ASCII("F12" ), nFlags ) != xF12 ) ||
( xD->findFrame( DECLARE_ASCII("F21" ), nFlags ) != xF21 ) ||
( xD->findFrame( DECLARE_ASCII("F22" ), nFlags ) != xF22 ) ||
( xD->findFrame( DECLARE_ASCII("F211" ), nFlags ) != xF211 ) ||
( xD->findFrame( DECLARE_ASCII("F212" ), nFlags ) != xF212 ) ||
( xD->findFrame( DECLARE_ASCII("F2111" ), nFlags ) != xF2111 ) ||
( xD->findFrame( DECLARE_ASCII("F2112" ), nFlags ) != xF2112 ) ||
( xD->findFrame( DECLARE_ASCII("F2121" ), nFlags ) != xF2121 ) ||
( xD->findFrame( DECLARE_ASCII("F2122" ), nFlags ) != xF2122 ) ||
( xD->findFrame( DECLARE_ASCII("F21111" ), nFlags ) != xF21111 ) ||
( xD->findFrame( DECLARE_ASCII("F21112" ), nFlags ) != xF21112 ) ||
( xD->findFrame( DECLARE_ASCII("F21121" ), nFlags ) != xF21121 ) ||
( xD->findFrame( DECLARE_ASCII("F21122" ), nFlags ) != xF21122 ) ||
( xD->findFrame( DECLARE_ASCII("F21211" ), nFlags ) != xF21211 ) ||
( xD->findFrame( DECLARE_ASCII("F21212" ), nFlags ) != xF21212 ) ||
( xD->findFrame( DECLARE_ASCII("F21221" ), nFlags ) != xF21221 ) ||
( xD->findFrame( DECLARE_ASCII("F21222" ), nFlags ) != xF21222 ) ||
( xD->findFrame( DECLARE_ASCII("F221" ), nFlags ) != xF221 ) ||
( xD->findFrame( DECLARE_ASCII("F2211" ), nFlags ) != xF2211 ) ||
( xD->findFrame( DECLARE_ASCII("F22111" ), nFlags ) != xF22111 )
)
{
LOG_ERROR( "TestApplikation::impl_testTreeSearch()", "deep down search failed" )
return sal_False;
}
// Test flat down search
nFlags = FrameSearchFlag::CHILDREN | FrameSearchFlag::SIBLINGS;
if (
( xD->findFrame( DECLARE_ASCII("T1" ), nFlags ) != xT1 ) ||
( xD->findFrame( DECLARE_ASCII("T2" ), nFlags ) != xT2 ) ||
( xD->findFrame( DECLARE_ASCII("T3" ), nFlags ) != xT3 ) ||
( xD->findFrame( DECLARE_ASCII("F11" ), nFlags ) != xF11 ) ||
( xD->findFrame( DECLARE_ASCII("F12" ), nFlags ) != xF12 ) ||
( xD->findFrame( DECLARE_ASCII("F21" ), nFlags ) != xF21 ) ||
( xD->findFrame( DECLARE_ASCII("F22" ), nFlags ) != xF22 ) ||
( xD->findFrame( DECLARE_ASCII("F211" ), nFlags ) != xF211 ) ||
( xD->findFrame( DECLARE_ASCII("F212" ), nFlags ) != xF212 ) ||
( xD->findFrame( DECLARE_ASCII("F2111" ), nFlags ) != xF2111 ) ||
( xD->findFrame( DECLARE_ASCII("F2112" ), nFlags ) != xF2112 ) ||
( xD->findFrame( DECLARE_ASCII("F2121" ), nFlags ) != xF2121 ) ||
( xD->findFrame( DECLARE_ASCII("F2122" ), nFlags ) != xF2122 ) ||
( xD->findFrame( DECLARE_ASCII("F21111" ), nFlags ) != xF21111 ) ||
( xD->findFrame( DECLARE_ASCII("F21112" ), nFlags ) != xF21112 ) ||
( xD->findFrame( DECLARE_ASCII("F21121" ), nFlags ) != xF21121 ) ||
( xD->findFrame( DECLARE_ASCII("F21122" ), nFlags ) != xF21122 ) ||
( xD->findFrame( DECLARE_ASCII("F21211" ), nFlags ) != xF21211 ) ||
( xD->findFrame( DECLARE_ASCII("F21212" ), nFlags ) != xF21212 ) ||
( xD->findFrame( DECLARE_ASCII("F21221" ), nFlags ) != xF21221 ) ||
( xD->findFrame( DECLARE_ASCII("F21222" ), nFlags ) != xF21222 ) ||
( xD->findFrame( DECLARE_ASCII("F221" ), nFlags ) != xF221 ) ||
( xD->findFrame( DECLARE_ASCII("F2211" ), nFlags ) != xF2211 ) ||
( xD->findFrame( DECLARE_ASCII("F22111" ), nFlags ) != xF22111 )
)
{
LOG_ERROR( "TestApplikation::impl_testTreeSearch()", "flat down search failed" )
return sal_False;
}
// Test deep up search
// All targets must be found. Control search steps in log files!
nFlags = FrameSearchFlag::PARENT;
if (
( xF11->findFrame ( DECLARE_ASCII("T1"), nFlags ) != xT1 ) || // search for valid targets
( xF12->findFrame ( DECLARE_ASCII("T1"), nFlags ) != xT1 ) ||
( xF21->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF22->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF211->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF212->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF221->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF2111->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF2121->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF2122->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF2211->findFrame ( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF21111->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF21112->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF21121->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF21122->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF21211->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF21212->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF21221->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF21222->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF22111->findFrame( DECLARE_ASCII("T2"), nFlags ) != xT2 ) ||
( xF11->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) || // search for existing but non valid targets
( xF12->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF21->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF22->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF211->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF212->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF221->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF2111->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF2121->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF2122->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF2211->findFrame ( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF21111->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF21112->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF21121->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF21122->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF21211->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF21212->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF21221->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF21222->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True ) ||
( xF22111->findFrame( DECLARE_ASCII("T3"), nFlags ).is() == sal_True )
)
{
LOG_ERROR( "TestApplikation::impl_testTreeSearch()", "deep up search failed" )
return sal_False;
}
// Test inside/outside tasks search
// No frames outside current task should be found if TASKS flag isnt set.
// Otherwise he must be found!
if (
( xF21211->findFrame( DECLARE_ASCII("F12" ), FrameSearchFlag::ALL ) == xF12 ) ||
( xF21211->findFrame( DECLARE_ASCII("F22111"), FrameSearchFlag::GLOBAL ) != xF22111 ) ||
( xF21211->findFrame( DECLARE_ASCII("T4" ), FrameSearchFlag::GLOBAL | FrameSearchFlag::CREATE ).is() == sal_False)
)
{
LOG_ERROR( "TestApplikation::impl_testTreeSearch()", "inside/outside task search failed" )
return sal_False;
}
// Test SELF
// Use the desktop, one task and one frame node to do that.
// The desktop must ignore these question ... all other must return himself.
LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII(""), FrameSearchFlag::SELF ) == xD ), "TestApplication::impl_testTreeSearch()", "SELF search for D failed\n" )
LOG_ASSERT2( (xT1->findFrame ( DECLARE_ASCII(""), FrameSearchFlag::SELF ) != xT1 ), "TestApplication::impl_testTreeSearch()", "SELF search for T1 failed\n" )
LOG_ASSERT2( (xF12->findFrame ( DECLARE_ASCII(""), FrameSearchFlag::SELF ) != xF12 ), "TestApplication::impl_testTreeSearch()", "SELF search for F12 failed\n" )
// Test special task search at desktop
// These search allow TASKS and CREATE flags only!
// We make no deep search - we work on direct children of desktop only.
// Supported for desktop only.
LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII("T1"), FrameSearchFlag::TASKS ) != xT1 ), "TestApplication::impl_testTreeSearch()", "special TASKS search for T1 failed\n" )
LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII("T2"), FrameSearchFlag::TASKS ) != xT2 ), "TestApplication::impl_testTreeSearch()", "special TASKS search for T2 failed\n" )
LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII("T3"), FrameSearchFlag::TASKS ) != xT3 ), "TestApplication::impl_testTreeSearch()", "special TASKS search for T3 failed\n" )
// Attention: T4 was created before!
LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII("T5"), FrameSearchFlag::TASKS ).is() == sal_True ), "TestApplication::impl_testTreeSearch()", "special TASKS search for T5 failed\n" )
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" )
LOG_ASSERT2( (xD->findFrame ( DECLARE_ASCII("F12"), FrameSearchFlag::TASKS ).is() == sal_True ), "TestApplication::impl_testTreeSearch()", "special TASKS search for F12 failed\n" )
LOG_ASSERT2( (xF12->findFrame ( DECLARE_ASCII("T1"), FrameSearchFlag::TASKS ).is() == sal_True ), "TestApplication::impl_testTreeSearch()", "special TASKS search for T1 from F12 failed\n" )
LOG_ASSERT2( (xF22111->findFrame( DECLARE_ASCII("T1"), FrameSearchFlag::TASKS ).is() == sal_True ), "TestApplication::impl_testTreeSearch()", "special TASKS search for T1 from F22111 failed\n" )
return sal_True;
}
#endif