#i4835# disable quit timer for some more command line arguments
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: framecontainer.cxx,v $
|
||||
*
|
||||
* $Revision: 1.16 $
|
||||
* $Revision: 1.17 $
|
||||
*
|
||||
* last change: $Author: as $ $Date: 2002-05-23 12:51:21 $
|
||||
* last change: $Author: as $ $Date: 2002-07-02 07:25:01 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -67,10 +67,6 @@
|
||||
#include <classes/framecontainer.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef __FRAMEWORK_THREADHELP_TRANSACTIONGUARD_HXX_
|
||||
#include <threadhelp/transactionguard.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef __FRAMEWORK_THREADHELP_WRITEGUARD_HXX_
|
||||
#include <threadhelp/writeguard.hxx>
|
||||
#endif
|
||||
@@ -79,6 +75,10 @@
|
||||
#include <threadhelp/readguard.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef __FRAMEWORK_COMMANDS_HXX_
|
||||
#include <commands.h>
|
||||
#endif
|
||||
|
||||
//_________________________________________________________________________________________________________________
|
||||
// interface includes
|
||||
//_________________________________________________________________________________________________________________
|
||||
@@ -101,11 +101,6 @@
|
||||
|
||||
namespace framework{
|
||||
|
||||
using namespace ::std ;
|
||||
using namespace ::rtl ;
|
||||
using namespace ::com::sun::star::uno ;
|
||||
using namespace ::com::sun::star::frame ;
|
||||
|
||||
//_________________________________________________________________________________________________________________
|
||||
// non exported const
|
||||
//_________________________________________________________________________________________________________________
|
||||
@@ -118,94 +113,85 @@ using namespace ::com::sun::star::frame ;
|
||||
// declarations
|
||||
//_________________________________________________________________________________________________________________
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// constructor
|
||||
//*****************************************************************************************************************
|
||||
/**-***************************************************************************************************************
|
||||
@short initialize an empty container
|
||||
@descr The container will be empty then - special features (e.g. the async quit timer) are disabled.
|
||||
|
||||
@threadsafe not neccessary - its not a singleton
|
||||
@modified 01.07.2002 14:42,as96863
|
||||
*****************************************************************************************************************/
|
||||
FrameContainer::FrameContainer()
|
||||
// initialize base classes first.
|
||||
// Order is neccessary for right initilization of his and OUR member ... m_aLock, m_aTransactionManager ...
|
||||
// Order is neccessary for right initilization of his and OUR member ... m_aLock
|
||||
: ThreadHelpBase ( &Application::GetSolarMutex() )
|
||||
, TransactionBase( )
|
||||
{
|
||||
// Make object ready for working.
|
||||
// change working mode from E_INIT to E_WORK
|
||||
// We don't must look for current set modi -
|
||||
// a ctor couldn't be called more then ones ... I think so :-)
|
||||
m_aTransactionManager.setWorkingMode( E_WORK );
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// destructor
|
||||
//*****************************************************************************************************************
|
||||
/**-***************************************************************************************************************
|
||||
@short deinitialize may a filled container
|
||||
@descr Special features (if the currently are running) will be dsiabled and we free all used other ressources.
|
||||
|
||||
@threadsafe not neccessary - its not a singleton
|
||||
@modified 01.07.2002 14:43,as96863
|
||||
*****************************************************************************************************************/
|
||||
FrameContainer::~FrameContainer()
|
||||
{
|
||||
// Disable object for working!
|
||||
// All further requests will be refused ...
|
||||
// but I think it's alittle bit superflous by using in dtor ...
|
||||
// May be - it's neccessary?
|
||||
// So we wait for current working reader/writer till they finish her work.
|
||||
m_aTransactionManager.setWorkingMode( E_BEFORECLOSE );
|
||||
|
||||
// Disable possible active quit timer!
|
||||
// He can be active for owner=desktop only.
|
||||
impl_disableQuitTimer();
|
||||
disableQuitTimer();
|
||||
// Don't forget to free memory!
|
||||
impl_clear();
|
||||
|
||||
m_aTransactionManager.setWorkingMode( E_CLOSE );
|
||||
clear();
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
void FrameContainer::append( const Reference< XFrame >& xFrame )
|
||||
/**-***************************************************************************************************************
|
||||
@short append a new frame to the container
|
||||
@descr We accept the incoming frame only, if it is a valid reference and dosnt exist already.
|
||||
|
||||
@param xFrame
|
||||
frame, which should be added to this container
|
||||
Must be a valid reference.
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 14:44,as96863
|
||||
*****************************************************************************************************************/
|
||||
void FrameContainer::append( const css::uno::Reference< css::frame::XFrame >& xFrame )
|
||||
{
|
||||
// Safe impossible cases
|
||||
// a) This method is not defined for ALL incoming parameters!
|
||||
// b) Warn programmer at already existing elements in container.
|
||||
// c) Warn programmer if an already existing frame has no component inside!
|
||||
// These frames are created (e.g. by dispatch()) but not used ...
|
||||
LOG_ASSERT2( implcp_append( xFrame ), "FrameContainer::append()", "Invalid parameter detected!" )
|
||||
LOG_ASSERT2( exist(xFrame)==sal_True, "FrameContainer::append()", "New frame already exist in container!" )
|
||||
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
WriteGuard aWriteLock( m_aLock );
|
||||
|
||||
// Append new frame to container.
|
||||
m_aContainer.push_back( xFrame );
|
||||
if (xFrame.is() && ! exist(xFrame))
|
||||
{
|
||||
/* SAFE { */
|
||||
WriteGuard aWriteLock( m_aLock );
|
||||
m_aContainer.push_back( xFrame );
|
||||
aWriteLock.unlock();
|
||||
/* } SAFE */
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
void FrameContainer::remove( const Reference< XFrame >& xFrame )
|
||||
/**-***************************************************************************************************************
|
||||
@short remove a frame from the container
|
||||
@descr In case we remove the last frame and our internal special feature (the async quit timer)
|
||||
was enabled by the desktop instance, we start it.
|
||||
|
||||
@param xFrame
|
||||
frame, which should be deleted from this container
|
||||
Must be a valid reference.
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 14:52,as96863
|
||||
*****************************************************************************************************************/
|
||||
void FrameContainer::remove( const css::uno::Reference< css::frame::XFrame >& xFrame )
|
||||
{
|
||||
// Safe impossible cases
|
||||
// a) This method is not defined for ALL incoming parameters!
|
||||
// b) Warn programmer at non existing elements in container.
|
||||
LOG_ASSERT2( implcp_remove( xFrame ) , "FrameContainer::remove()", "Invalid parameter detected!" )
|
||||
LOG_ASSERT2( exist(xFrame)==sal_False , "FrameContainer::remove()", "Frame to remove not exist in container!" )
|
||||
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
/* SAFE { */
|
||||
// write lock neccessary for follwing erase()!
|
||||
WriteGuard aWriteLock( m_aLock );
|
||||
|
||||
// Search frame and remove it from container if he exist.
|
||||
TFrameIterator aSearchedItem = find( m_aContainer.begin(), m_aContainer.end(), xFrame );
|
||||
if( aSearchedItem != m_aContainer.end() )
|
||||
TFrameIterator aSearchedItem = ::std::find( m_aContainer.begin(), m_aContainer.end(), xFrame );
|
||||
if (aSearchedItem!=m_aContainer.end())
|
||||
{
|
||||
m_aContainer.erase( aSearchedItem );
|
||||
|
||||
// If removed frame the current active frame - reset state variable.
|
||||
if( m_xActiveFrame == xFrame )
|
||||
{
|
||||
m_xActiveFrame = Reference< XFrame >();
|
||||
}
|
||||
// If removed frame was the current active frame - reset state variable.
|
||||
if (m_xActiveFrame==xFrame)
|
||||
m_xActiveFrame = css::uno::Reference< css::frame::XFrame >();
|
||||
|
||||
// We don't need the write lock any longer ...
|
||||
// downgrade to read access.
|
||||
@@ -213,84 +199,110 @@ void FrameContainer::remove( const Reference< XFrame >& xFrame )
|
||||
|
||||
// If last frame was removed and special quit timer is enabled by the desktop
|
||||
// we must terminate the desktop by using this timer!
|
||||
if (
|
||||
( m_aContainer.size() < 1 ) &&
|
||||
( m_rQuitTimer.isValid() == sal_True )
|
||||
)
|
||||
{
|
||||
if (m_aContainer.size()<1 && m_rQuitTimer.isValid())
|
||||
m_rQuitTimer->start();
|
||||
}
|
||||
}
|
||||
|
||||
aWriteLock.unlock();
|
||||
/* } SAFE */
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
sal_Bool FrameContainer::exist( const Reference< XFrame >& xFrame ) const
|
||||
/**-***************************************************************************************************************
|
||||
@short check if the given frame currently exist inside the container
|
||||
@descr -
|
||||
|
||||
@param xFrame
|
||||
reference to the queried frame
|
||||
|
||||
@return <TRUE/> if frame is oart of this container
|
||||
<FALSE/> otherwhise
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 14:55,as96863
|
||||
*****************************************************************************************************************/
|
||||
sal_Bool FrameContainer::exist( const css::uno::Reference< css::frame::XFrame >& xFrame ) const
|
||||
{
|
||||
// Safe impossible cases
|
||||
// This method is not defined for ALL incoming parameters!
|
||||
LOG_ASSERT2( implcp_exist( xFrame ), "FrameContainer::exist()", "Invalid parameter detected!" )
|
||||
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
/* SAFE { */
|
||||
ReadGuard aReadLock( m_aLock );
|
||||
|
||||
// Search for given frame.
|
||||
return( find( m_aContainer.begin(), m_aContainer.end(), xFrame ) != m_aContainer.end() );
|
||||
return( ::std::find( m_aContainer.begin(), m_aContainer.end(), xFrame ) != m_aContainer.end() );
|
||||
/* } SAFE */
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
/**-***************************************************************************************************************
|
||||
@short delete all existing items of the container
|
||||
@descr -
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 15:00,as96863
|
||||
*****************************************************************************************************************/
|
||||
void FrameContainer::clear()
|
||||
{
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
/* SAFE { */
|
||||
WriteGuard aWriteLock( m_aLock );
|
||||
|
||||
impl_clear();
|
||||
// Clear the container ...
|
||||
m_aContainer.clear();
|
||||
// ... and don't forget to reset the active frame.
|
||||
// Its an reference to a valid container-item.
|
||||
// But no container item => no active frame!
|
||||
m_xActiveFrame = css::uno::Reference< css::frame::XFrame >();
|
||||
// If special quit timer is used - we must terminate the desktop.
|
||||
// He is the owner of this container and can't work without any visible tasks/frames!
|
||||
if (m_rQuitTimer.isValid())
|
||||
m_rQuitTimer->start();
|
||||
|
||||
aWriteLock.unlock();
|
||||
/* } SAFE */
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
/**-***************************************************************************************************************
|
||||
@short returns count of all current existing frames
|
||||
@descr -
|
||||
|
||||
@deprecated This value can't be guaranteed for multithreading environments.
|
||||
So it will be marked as deprecated and should be replaced by "getAllElements()".
|
||||
|
||||
@return the count of existing container items
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 15:00,as96863
|
||||
*****************************************************************************************************************/
|
||||
sal_uInt32 FrameContainer::getCount() const
|
||||
{
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
/* SAFE { */
|
||||
ReadGuard aReadLock( m_aLock );
|
||||
|
||||
return( (sal_uInt32)m_aContainer.size() );
|
||||
/* } SAFE */
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
Reference< XFrame > FrameContainer::operator[]( sal_uInt32 nIndex ) const
|
||||
/**-***************************************************************************************************************
|
||||
@short returns one item of this container
|
||||
@descr -
|
||||
|
||||
@deprecated This value can't be guaranteed for multithreading environments.
|
||||
So it will be marked as deprecated and should be replaced by "getAllElements()".
|
||||
|
||||
@param nIndex
|
||||
a valud between 0 and (getCount()-1) to adress one container item
|
||||
|
||||
@return a reference to a frame inside the container, which match with given index
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 15:03,as96863
|
||||
*****************************************************************************************************************/
|
||||
css::uno::Reference< css::frame::XFrame > FrameContainer::operator[]( sal_uInt32 nIndex ) const
|
||||
{
|
||||
// Safe impossible cases
|
||||
// a) This method is not defined for ALL incoming parameters!
|
||||
LOG_ASSERT2( implcp_IndexOperator( nIndex, getCount() ), "FrameContainer::operator[]()", "Invalid parameter detected!" )
|
||||
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
ReadGuard aReadLock( m_aLock );
|
||||
|
||||
Reference< XFrame > xFrame;
|
||||
css::uno::Reference< css::frame::XFrame > xFrame;
|
||||
try
|
||||
{
|
||||
// Get element form container WITH automatic test of ranges!
|
||||
// If index not valid, a out_of_range exception is thrown.
|
||||
/* SAFE { */
|
||||
ReadGuard aReadLock( m_aLock );
|
||||
xFrame = m_aContainer.at( nIndex );
|
||||
aReadLock.unlock();
|
||||
/* } SAFE */
|
||||
}
|
||||
catch( std::out_of_range& )
|
||||
{
|
||||
@@ -301,249 +313,254 @@ Reference< XFrame > FrameContainer::operator[]( sal_uInt32 nIndex ) const
|
||||
return xFrame;
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
Sequence< Reference< XFrame > > FrameContainer::getAllElements() const
|
||||
{
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
/**-***************************************************************************************************************
|
||||
@short returns a snapshot of all currently existing frames inside this container
|
||||
@descr Should be used to replace the deprecated functions getCount()/operator[]!
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
@return a list of all frame refrences inside this container
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 15:09,as96863
|
||||
*****************************************************************************************************************/
|
||||
css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > FrameContainer::getAllElements() const
|
||||
{
|
||||
/* SAFE { */
|
||||
ReadGuard aReadLock( m_aLock );
|
||||
|
||||
sal_uInt32 nCount = (sal_uInt32)m_aContainer.size();
|
||||
Sequence< Reference< XFrame > > lElements ( nCount );
|
||||
sal_Int32 nPosition = 0;
|
||||
css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > lElements ( (sal_uInt32)m_aContainer.size() );
|
||||
for (TConstFrameIterator pItem=m_aContainer.begin(); pItem!=m_aContainer.end(); ++pItem)
|
||||
lElements[nPosition++] = *pItem;
|
||||
|
||||
for( sal_uInt32 nPosition=0; nPosition<nCount; ++nPosition )
|
||||
{
|
||||
lElements[nPosition] = m_aContainer[nPosition];
|
||||
}
|
||||
aReadLock.unlock();
|
||||
/* } SAFE */
|
||||
|
||||
return lElements;
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
/**-***************************************************************************************************************
|
||||
@short return state information, if container is empty or not
|
||||
@descr -
|
||||
|
||||
@return <TRUE/> if container is filled or <FALSE/> if he is empty.
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 15:09,as96863
|
||||
*****************************************************************************************************************/
|
||||
sal_Bool FrameContainer::hasElements() const
|
||||
{
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
/* SAFE { */
|
||||
ReadGuard aReadLock( m_aLock );
|
||||
|
||||
return( m_aContainer.size()>0 );
|
||||
/* } SAFE */
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
void FrameContainer::setActive( const Reference< XFrame >& xFrame )
|
||||
/**-***************************************************************************************************************
|
||||
@short set the given frame as the new active one inside this container
|
||||
@descr We accept this frame only, if it's already a part of this container.
|
||||
|
||||
@param xFrame
|
||||
reference to the new active frame
|
||||
Must be a valid reference and already part of this container.
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 15:11,as96863
|
||||
*****************************************************************************************************************/
|
||||
void FrameContainer::setActive( const css::uno::Reference< css::frame::XFrame >& xFrame )
|
||||
{
|
||||
// Safe impossible cases
|
||||
// a) This method is not defined for ALL incoming parameters!
|
||||
// b) The new active frame MUST exist in container.
|
||||
LOG_ASSERT2( implcp_setActive( xFrame ) , "FrameContainer::setActive()", "Invalid parameter detected!" )
|
||||
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." )
|
||||
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
WriteGuard aWriteLock( m_aLock );
|
||||
|
||||
m_xActiveFrame = xFrame;
|
||||
if (xFrame.is() && exist(xFrame))
|
||||
{
|
||||
/* SAFE { */
|
||||
WriteGuard aWriteLock( m_aLock );
|
||||
m_xActiveFrame = xFrame;
|
||||
aWriteLock.unlock();
|
||||
/* } SAFE */
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
Reference< XFrame > FrameContainer::getActive() const
|
||||
{
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
/**-***************************************************************************************************************
|
||||
@short return sthe current active frame of this container
|
||||
@descr Value can be null in case the frame was removed from the container and nobody
|
||||
from outside decide which of all others should be the new one ...
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
@return a reference to the current active frame
|
||||
Value can be NULL!
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 15:11,as96863
|
||||
*****************************************************************************************************************/
|
||||
css::uno::Reference< css::frame::XFrame > FrameContainer::getActive() const
|
||||
{
|
||||
/* SAFE { */
|
||||
ReadGuard aReadLock( m_aLock );
|
||||
|
||||
return m_xActiveFrame;
|
||||
/* } SAFE */
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
void FrameContainer::enableQuitTimer( const Reference< XDesktop >& xDesktop )
|
||||
{
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
/**-***************************************************************************************************************
|
||||
@short enables the async quit timer, which terminates the office if last task will be closed
|
||||
@descr If the last visible task will gone, nobody shows any UI then. But without any UI the user
|
||||
has no chance to quit the application realy. So we must shutdown by ourself.
|
||||
We do that by an async quit timer, which will be initialized and check after hi times out,
|
||||
if any new task was opened. In case it wasn't ... it calls Desktop::terminate().
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
But note: It's not neccessary to start this timer if using the office doesn't require it.
|
||||
e.g. the command line parameters "-invisible", -headless" starts the office in a server mode.
|
||||
In this case the outside user controls the lifetime of it and must terminate it manually.
|
||||
|
||||
@param xDesktop
|
||||
only the child frame container of the desktop instance can use this special quit timer
|
||||
Because only top level frames are used for cehcking.
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 14:30,as96863
|
||||
*****************************************************************************************************************/
|
||||
void FrameContainer::enableQuitTimer( const css::uno::Reference< css::frame::XDesktop >& xDesktop )
|
||||
{
|
||||
/* SAFE { */
|
||||
WriteGuard aWriteLock( m_aLock );
|
||||
|
||||
// If no current timer exist - create a new one.
|
||||
if( m_rQuitTimer.isEmpty() == sal_True )
|
||||
{
|
||||
m_rQuitTimer.bind( new AsyncQuit( xDesktop ) );
|
||||
// How can we distinguish between the different office modes?
|
||||
// a) Office is plugged if command argument "-plugin" could be detected. => timeout = 2 min
|
||||
// b) Office runs in special "server" mode if "-headless", "-invisible" or "-server" could be detected. => timout disabled!
|
||||
// c) Otherwise office runs in normal mode. => timeout = 5 sec
|
||||
|
||||
// Parse command line for right parameter.
|
||||
if( c_existCommand( COMMAND_PLUGIN ) == sal_True )
|
||||
{
|
||||
m_rQuitTimer.bind( new AsyncQuit( xDesktop, E_PLUGIN ) );
|
||||
}
|
||||
else
|
||||
if(
|
||||
! c_existCommand( COMMAND_HEADLESS ) &&
|
||||
! c_existCommand( COMMAND_INVISIBLE ) &&
|
||||
! c_existCommand( COMMAND_SERVER )
|
||||
)
|
||||
{
|
||||
m_rQuitTimer.bind( new AsyncQuit( xDesktop, E_FATOFFICE ) );
|
||||
}
|
||||
}
|
||||
/* } SAFE */
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
/**-***************************************************************************************************************
|
||||
@short disable the async quit timer again
|
||||
@descr Delete current quit timer.
|
||||
If user wish to create it again he must do it with "enableQuitTimer()".
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 14:37,as96863
|
||||
*****************************************************************************************************************/
|
||||
void FrameContainer::disableQuitTimer()
|
||||
{
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
/* SAFE { */
|
||||
WriteGuard aWriteLock( m_aLock );
|
||||
|
||||
// Delete current quit timer.
|
||||
// If user wish to create it again he must do it with "enableQuitTimer()".
|
||||
impl_disableQuitTimer();
|
||||
if (m_rQuitTimer.isValid())
|
||||
m_rQuitTimer.unbind();
|
||||
/* } SAFE */
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
Reference< XFrame > FrameContainer::searchOnAllChildrens( const OUString& sName ) const
|
||||
/**-***************************************************************************************************************
|
||||
@short implements a simple search based on current container items
|
||||
@descr It can be used for findFrame() and implements a deep down search.
|
||||
|
||||
@param sName
|
||||
target name, which is searched
|
||||
|
||||
@return reference to the found frame or NULL if not.
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 15:22,as96863
|
||||
*****************************************************************************************************************/
|
||||
css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnAllChildrens( const ::rtl::OUString& sName ) const
|
||||
{
|
||||
// Check incoming parameter.
|
||||
LOG_ASSERT2( implcp_searchDeepDown( sName ), "FrameContainer::searchDeepDown()", "Invalid parameter detected!" )
|
||||
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
/* SAFE { */
|
||||
ReadGuard aReadLock( m_aLock );
|
||||
|
||||
// Step over all child frames. But if direct child isn't the right one search on his children first - before
|
||||
// you go to next direct child of this container!
|
||||
Reference< XFrame > xSearchedFrame;
|
||||
css::uno::Reference< css::frame::XFrame > xSearchedFrame;
|
||||
for( TConstFrameIterator pIterator=m_aContainer.begin(); pIterator!=m_aContainer.end(); ++pIterator )
|
||||
{
|
||||
if( (*pIterator)->getName() == sName )
|
||||
if ((*pIterator)->getName()==sName)
|
||||
{
|
||||
xSearchedFrame = *pIterator;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
xSearchedFrame = (*pIterator)->findFrame( sName, FrameSearchFlag::CHILDREN );
|
||||
if( xSearchedFrame.is() == sal_True )
|
||||
{
|
||||
xSearchedFrame = (*pIterator)->findFrame( sName, css::frame::FrameSearchFlag::CHILDREN );
|
||||
if (xSearchedFrame.is())
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
aReadLock.unlock();
|
||||
/* } SAFE */
|
||||
return xSearchedFrame;
|
||||
}
|
||||
/*
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
Reference< XFrame > FrameContainer::searchFlatDown( const OUString& sName ) const
|
||||
|
||||
/**-***************************************************************************************************************
|
||||
@short implements a simple search based on current container items
|
||||
@descr It can be used for findFrame() and search on members of this container only!
|
||||
|
||||
@param sName
|
||||
target name, which is searched
|
||||
|
||||
@return reference to the found frame or NULL if not.
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 15:22,as96863
|
||||
*****************************************************************************************************************/
|
||||
css::uno::Reference< css::frame::XFrame > FrameContainer::searchOnDirectChildrens( const ::rtl::OUString& sName ) const
|
||||
{
|
||||
// Check incoming parameter.
|
||||
LOG_ASSERT2( implcp_searchFlatDown( sName ), "FrameContainer::searchFlatDown()", "Invalid parameter detected!" )
|
||||
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
|
||||
/* SAFE { */
|
||||
ReadGuard aReadLock( m_aLock );
|
||||
|
||||
// Step over all direct child frames first.
|
||||
// Even right frame wasn't found, start search at children of direct children.
|
||||
Reference< XFrame > xSearchedFrame;
|
||||
css::uno::Reference< css::frame::XFrame > xSearchedFrame;
|
||||
for( TConstFrameIterator pIterator=m_aContainer.begin(); pIterator!=m_aContainer.end(); ++pIterator )
|
||||
{
|
||||
if( (*pIterator)->getName() == sName )
|
||||
if ((*pIterator)->getName()==sName)
|
||||
{
|
||||
xSearchedFrame = *pIterator;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( xSearchedFrame.is() == sal_False )
|
||||
{
|
||||
for( pIterator=m_aContainer.begin(); pIterator!=m_aContainer.end(); ++pIterator )
|
||||
{
|
||||
xSearchedFrame = (*pIterator)->findFrame( sName, FrameSearchFlag::CHILDREN | FrameSearchFlag::SIBLINGS );
|
||||
if( xSearchedFrame.is() == sal_True )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
aReadLock.unlock();
|
||||
/* } SAFE */
|
||||
return xSearchedFrame;
|
||||
}
|
||||
*/
|
||||
//*****************************************************************************************************************
|
||||
// public method
|
||||
//*****************************************************************************************************************
|
||||
Reference< XFrame > FrameContainer::searchOnDirectChildrens( const OUString& sName ) const
|
||||
|
||||
|
||||
/**-***************************************************************************************************************
|
||||
@short special debug mode!
|
||||
@descr Sometimes frames will be inserted in this container which hold no component inside!
|
||||
Or they will be empty after inserting. ALLOWED FOR DEBUG ONLY!
|
||||
We show assertion then.
|
||||
|
||||
@threadsafe yes
|
||||
@modified 01.07.2002 15:39,as96863
|
||||
*****************************************************************************************************************/
|
||||
|
||||
#ifdef ENABLE_ASSERTIONS
|
||||
void FrameContainer::impldbg_checkForZombie() const
|
||||
{
|
||||
// Check incoming parameter.
|
||||
LOG_ASSERT2( implcp_searchDirectChildren( sName ), "FrameContainer::searchDirectChildren()", "Invalid parameter detected!" )
|
||||
|
||||
// Register transaction. Reject wrong calls.
|
||||
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
|
||||
|
||||
/* SAFE AREA ----------------------------------------------------------------------------------------------- */
|
||||
ReadGuard aReadLock( m_aLock );
|
||||
|
||||
// Step over all current container items and search for right target.
|
||||
Reference< XFrame > xSearchedFrame;
|
||||
for( TConstFrameIterator pIterator=m_aContainer.begin(); pIterator!=m_aContainer.end(); ++pIterator )
|
||||
/* SAFE { */
|
||||
ReadGuard aReadLock(m_aLock);
|
||||
for (TConstFrameIterator pItem=m_aContainer.begin(); pItem!=m_aContainer.end(); ++pItem)
|
||||
{
|
||||
if( (*pIterator)->getName() == sName )
|
||||
if ((*pItem)->getComponentWindow().is())
|
||||
{
|
||||
xSearchedFrame = *pIterator;
|
||||
LOG_WARNING("FrameContainer::impldbg_checkForZombie()", "Zombie found! Please check your frame tree ...")
|
||||
break;
|
||||
}
|
||||
}
|
||||
return xSearchedFrame;
|
||||
aReadLock.unlock();
|
||||
/* } SAFE */
|
||||
}
|
||||
#endif // #ifdef ENABLE_ASSERTIONS
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// private method
|
||||
//*****************************************************************************************************************
|
||||
void FrameContainer::impl_clear()
|
||||
{
|
||||
/*ATTENTION:
|
||||
Don't use any lock here ... because our "owner" should make it threadsafe!
|
||||
*/
|
||||
|
||||
// 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.
|
||||
// But no container item => no active frame!
|
||||
m_xActiveFrame = Reference< XFrame >();
|
||||
// If special quit timer is used - we must terminate the desktop.
|
||||
// He is the owner of this container and can't work without any visible tasks/frames!
|
||||
if( m_rQuitTimer.isValid() == sal_True )
|
||||
{
|
||||
m_rQuitTimer->start();
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************************************************
|
||||
// private method
|
||||
//*****************************************************************************************************************
|
||||
void FrameContainer::impl_disableQuitTimer()
|
||||
{
|
||||
/*ATTENTION:
|
||||
Don't use any lock here ... because our "owner" should make it threadsafe!
|
||||
*/
|
||||
|
||||
if( m_rQuitTimer.isValid() == sal_True )
|
||||
{
|
||||
m_rQuitTimer.unbind();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace framework
|
||||
} // namespace framework
|
||||
|
Reference in New Issue
Block a user