Tag: cws_src680_odbmacros2 User: fs Date: 2007-12-19 11:29:42+0000 Modified: dba/dbaccess/source/ui/misc/controllerframe.cxx
Log: thread safety File Changes: Directory: /dba/dbaccess/source/ui/misc/ ======================================== File [changed]: controllerframe.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/controllerframe.cxx?r1=1.1.2.2&r2=1.1.2.3 Delta lines: +46 -26 --------------------- --- controllerframe.cxx 2007-12-18 21:24:51+0000 1.1.2.2 +++ controllerframe.cxx 2007-12-19 11:29:40+0000 1.1.2.3 @@ -4,9 +4,9 @@ * * $RCSfile: controllerframe.cxx,v $ * - * $Revision: 1.1.2.2 $ + * $Revision: 1.1.2.3 $ * - * last change: $Author: fs $ $Date: 2007/12/18 21:24:51 $ + * last change: $Author: fs $ $Date: 2007/12/19 11:29:40 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -37,9 +37,11 @@ #include "IController.hxx" /** === begin UNO includes === **/ +#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> /** === end UNO includes === **/ #include <sfx2/objsh.hxx> +#include <tools/diagnose_ex.h> //........................................................................ namespace dbaui @@ -64,6 +66,8 @@ using ::com::sun::star::frame::FrameAction_FRAME_UI_DEACTIVATING; using ::com::sun::star::frame::XModel; using ::com::sun::star::frame::XController; + using ::com::sun::star::frame::XFramesSupplier; + using ::com::sun::star::sdb::XOfficeDatabaseDocument; /** === end UNO using === **/ //==================================================================== @@ -86,22 +90,33 @@ //-------------------------------------------------------------------- namespace { - static void lcl_updateWorkingDocument( const ControllerFrame_Data& _rData ) + /** updates various global and local states with a new active component + + In particular, the following are updated + * the global working document (aka Basic's ThisComponent in the application + Basic), with our controller's model, or the controller itself if there is no such + model. + * the frames collection of the associated database document, with the frame + of our controller as new active frame (if it actually *is* active) + */ + static void lcl_updateActiveComponents_nothrow( const ControllerFrame_Data& _rData ) + { + try { - Reference< XController > xController( _rData.m_rController.getXController() ); + Reference< XController > xCompController( _rData.m_rController.getXController() ); Reference< XModel > xModel; - if ( xController.is() ) - xModel = xController->getModel(); + if ( xCompController.is() ) + xModel = xCompController->getModel(); if ( _rData.m_bActive ) { Reference< XInterface > xCurrentComponent; if ( xModel.is() ) xCurrentComponent = xModel; - else if ( xController.is() ) - xCurrentComponent = xController; + else if ( xCompController.is() ) + xCurrentComponent = xCompController; - OSL_ENSURE( xCurrentComponent.is(), "lcl_updateWorkingDocument: no model *and* no controller!?" ); + OSL_ENSURE( xCurrentComponent.is(), "lcl_updateActiveComponents_nothrow: no model *and* no controller!?" ); if ( xCurrentComponent.is() ) SfxObjectShell::SetCurrentComponent( xCurrentComponent ); } @@ -109,11 +124,16 @@ { Reference< XInterface > xCurrentComponent = SfxObjectShell::GetCurrentComponent(); if ( ( xModel.is() && ( xModel == xCurrentComponent ) ) - || ( xController.is() && ( xController == xCurrentComponent ) ) + || ( xCompController.is() && ( xCompController == xCurrentComponent ) ) ) SfxObjectShell::SetCurrentComponent( Reference< XInterface >() ); } } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } } //==================================================================== @@ -139,7 +159,7 @@ && m_pData->m_xFrame->isActive(); if ( m_pData->m_bActive ) - lcl_updateWorkingDocument( *m_pData ); + lcl_updateActiveComponents_nothrow( *m_pData ); return m_pData->m_xFrame; } @@ -181,7 +201,7 @@ return; m_pData->m_bActive = bActive; - lcl_updateWorkingDocument( *m_pData ); + lcl_updateActiveComponents_nothrow( *m_pData ); } //........................................................................ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
