1*96de5490SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96de5490SAndrew Rist * distributed with this work for additional information 6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance 9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at 10*96de5490SAndrew Rist * 11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*96de5490SAndrew Rist * 13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96de5490SAndrew Rist * software distributed under the License is distributed on an 15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the 17*96de5490SAndrew Rist * specific language governing permissions and limitations 18*96de5490SAndrew Rist * under the License. 19*96de5490SAndrew Rist * 20*96de5490SAndrew Rist *************************************************************/ 21*96de5490SAndrew Rist 22*96de5490SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "controllerframe.hxx" 25cdf0e10cSrcweir #include "IController.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir /** === begin UNO includes === **/ 28cdf0e10cSrcweir #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> 29cdf0e10cSrcweir #include <com/sun/star/awt/XTopWindow.hpp> 30cdf0e10cSrcweir #include <com/sun/star/awt/XWindow2.hpp> 31cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 32cdf0e10cSrcweir #include <com/sun/star/document/XDocumentEventBroadcaster.hpp> 33cdf0e10cSrcweir #include <com/sun/star/frame/XController2.hpp> 34cdf0e10cSrcweir /** === end UNO includes === **/ 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 37cdf0e10cSrcweir #include <rtl/ref.hxx> 38cdf0e10cSrcweir #include <sfx2/objsh.hxx> 39cdf0e10cSrcweir #include <tools/diagnose_ex.h> 40cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 41cdf0e10cSrcweir #include <vcl/window.hxx> 42cdf0e10cSrcweir 43cdf0e10cSrcweir //........................................................................ 44cdf0e10cSrcweir namespace dbaui 45cdf0e10cSrcweir { 46cdf0e10cSrcweir //........................................................................ 47cdf0e10cSrcweir 48cdf0e10cSrcweir /** === begin UNO using === **/ 49cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 50cdf0e10cSrcweir using ::com::sun::star::uno::XInterface; 51cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 52cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 53cdf0e10cSrcweir using ::com::sun::star::uno::UNO_SET_THROW; 54cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 55cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 56cdf0e10cSrcweir using ::com::sun::star::uno::Any; 57cdf0e10cSrcweir using ::com::sun::star::uno::makeAny; 58cdf0e10cSrcweir using ::com::sun::star::frame::XFrame; 59cdf0e10cSrcweir using ::com::sun::star::frame::FrameAction; 60cdf0e10cSrcweir using ::com::sun::star::frame::FrameAction_FRAME_ACTIVATED; 61cdf0e10cSrcweir using ::com::sun::star::frame::FrameAction_FRAME_UI_ACTIVATED; 62cdf0e10cSrcweir using ::com::sun::star::frame::FrameAction_FRAME_DEACTIVATING; 63cdf0e10cSrcweir using ::com::sun::star::frame::FrameAction_FRAME_UI_DEACTIVATING; 64cdf0e10cSrcweir using ::com::sun::star::frame::XModel; 65cdf0e10cSrcweir using ::com::sun::star::frame::XController; 66cdf0e10cSrcweir using ::com::sun::star::frame::XController2; 67cdf0e10cSrcweir using ::com::sun::star::frame::XFramesSupplier; 68cdf0e10cSrcweir using ::com::sun::star::sdb::XOfficeDatabaseDocument; 69cdf0e10cSrcweir using ::com::sun::star::awt::XTopWindow; 70cdf0e10cSrcweir using ::com::sun::star::awt::XTopWindowListener; 71cdf0e10cSrcweir using ::com::sun::star::awt::XWindow2; 72cdf0e10cSrcweir using ::com::sun::star::lang::DisposedException; 73cdf0e10cSrcweir using ::com::sun::star::lang::EventObject; 74cdf0e10cSrcweir using ::com::sun::star::document::XDocumentEventBroadcaster; 75cdf0e10cSrcweir using ::com::sun::star::awt::XWindow; 76cdf0e10cSrcweir /** === end UNO using === **/ 77cdf0e10cSrcweir 78cdf0e10cSrcweir //==================================================================== 79cdf0e10cSrcweir //= FrameWindowActivationListener 80cdf0e10cSrcweir //==================================================================== 81cdf0e10cSrcweir typedef ::cppu::WeakImplHelper1 < XTopWindowListener 82cdf0e10cSrcweir > FrameWindowActivationListener_Base; 83cdf0e10cSrcweir class FrameWindowActivationListener : public FrameWindowActivationListener_Base 84cdf0e10cSrcweir { 85cdf0e10cSrcweir public: 86cdf0e10cSrcweir FrameWindowActivationListener( ControllerFrame_Data& _rData ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir void dispose(); 89cdf0e10cSrcweir 90cdf0e10cSrcweir protected: 91cdf0e10cSrcweir ~FrameWindowActivationListener(); 92cdf0e10cSrcweir 93cdf0e10cSrcweir // XTopWindowListener 94cdf0e10cSrcweir virtual void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); 95cdf0e10cSrcweir virtual void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); 96cdf0e10cSrcweir virtual void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); 97cdf0e10cSrcweir virtual void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); 98cdf0e10cSrcweir virtual void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); 99cdf0e10cSrcweir virtual void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); 100cdf0e10cSrcweir virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException); 101cdf0e10cSrcweir 102cdf0e10cSrcweir // XEventListener 103cdf0e10cSrcweir virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); 104cdf0e10cSrcweir 105cdf0e10cSrcweir private: 106cdf0e10cSrcweir void impl_checkDisposed_throw() const; 107cdf0e10cSrcweir void impl_registerOnFrameContainerWindow_nothrow( bool _bRegister ); 108cdf0e10cSrcweir 109cdf0e10cSrcweir private: 110cdf0e10cSrcweir ControllerFrame_Data* m_pData; 111cdf0e10cSrcweir }; 112cdf0e10cSrcweir 113cdf0e10cSrcweir //==================================================================== 114cdf0e10cSrcweir //= ControllerFrame_Data 115cdf0e10cSrcweir //==================================================================== 116cdf0e10cSrcweir struct ControllerFrame_Data 117cdf0e10cSrcweir { ControllerFrame_Datadbaui::ControllerFrame_Data118cdf0e10cSrcweir ControllerFrame_Data( IController& _rController ) 119cdf0e10cSrcweir :m_rController( _rController ) 120cdf0e10cSrcweir ,m_xFrame() 121cdf0e10cSrcweir ,m_xDocEventBroadcaster() 122cdf0e10cSrcweir ,m_pListener() 123cdf0e10cSrcweir ,m_bActive( false ) 124cdf0e10cSrcweir ,m_bIsTopLevelDocumentWindow( false ) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir IController& m_rController; 129cdf0e10cSrcweir Reference< XFrame > m_xFrame; 130cdf0e10cSrcweir Reference< XDocumentEventBroadcaster > m_xDocEventBroadcaster; 131cdf0e10cSrcweir ::rtl::Reference< FrameWindowActivationListener > m_pListener; 132cdf0e10cSrcweir bool m_bActive; 133cdf0e10cSrcweir bool m_bIsTopLevelDocumentWindow; 134cdf0e10cSrcweir }; 135cdf0e10cSrcweir 136cdf0e10cSrcweir //==================================================================== 137cdf0e10cSrcweir //= helper 138cdf0e10cSrcweir //==================================================================== 139cdf0e10cSrcweir //-------------------------------------------------------------------- lcl_setFrame_nothrow(ControllerFrame_Data & _rData,const Reference<XFrame> & _rxFrame)140cdf0e10cSrcweir static void lcl_setFrame_nothrow( ControllerFrame_Data& _rData, const Reference< XFrame >& _rxFrame ) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir // release old listener 143cdf0e10cSrcweir if ( _rData.m_pListener.get() ) 144cdf0e10cSrcweir { 145cdf0e10cSrcweir _rData.m_pListener->dispose(); 146cdf0e10cSrcweir _rData.m_pListener = NULL; 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir // remember new frame 150cdf0e10cSrcweir _rData.m_xFrame = _rxFrame; 151cdf0e10cSrcweir 152cdf0e10cSrcweir // create new listener 153cdf0e10cSrcweir if ( _rData.m_xFrame.is() ) 154cdf0e10cSrcweir _rData.m_pListener = new FrameWindowActivationListener( _rData ); 155cdf0e10cSrcweir 156cdf0e10cSrcweir // at this point in time, we can assume the controller also has a model set, if it supports models 157cdf0e10cSrcweir try 158cdf0e10cSrcweir { 159cdf0e10cSrcweir Reference< XController > xController( _rData.m_rController.getXController(), UNO_SET_THROW ); 160cdf0e10cSrcweir Reference< XModel > xModel( xController->getModel() ); 161cdf0e10cSrcweir if ( xModel.is() ) 162cdf0e10cSrcweir _rData.m_xDocEventBroadcaster.set( xModel, UNO_QUERY ); 163cdf0e10cSrcweir } 164cdf0e10cSrcweir catch( const Exception& ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir } 169cdf0e10cSrcweir 170cdf0e10cSrcweir //-------------------------------------------------------------------- lcl_isActive_nothrow(const Reference<XFrame> & _rxFrame)171cdf0e10cSrcweir static bool lcl_isActive_nothrow( const Reference< XFrame >& _rxFrame ) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir bool bIsActive = false; 174cdf0e10cSrcweir try 175cdf0e10cSrcweir { 176cdf0e10cSrcweir if ( _rxFrame.is() ) 177cdf0e10cSrcweir { 178cdf0e10cSrcweir Reference< XWindow2 > xWindow( _rxFrame->getContainerWindow(), UNO_QUERY_THROW ); 179cdf0e10cSrcweir bIsActive = xWindow->isActive(); 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir } 183cdf0e10cSrcweir catch( const Exception& ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 186cdf0e10cSrcweir } 187cdf0e10cSrcweir return bIsActive; 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190cdf0e10cSrcweir //-------------------------------------------------------------------- 191cdf0e10cSrcweir /** updates various global and local states with a new active component 192cdf0e10cSrcweir 193cdf0e10cSrcweir In particular, the following are updated 194cdf0e10cSrcweir * the global working document (aka Basic's ThisComponent in the application 195cdf0e10cSrcweir Basic), with our controller's model, or the controller itself if there is no such 196cdf0e10cSrcweir model. 197cdf0e10cSrcweir */ lcl_updateActiveComponents_nothrow(const ControllerFrame_Data & _rData)198cdf0e10cSrcweir static void lcl_updateActiveComponents_nothrow( const ControllerFrame_Data& _rData ) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir try 201cdf0e10cSrcweir { 202cdf0e10cSrcweir Reference< XController > xCompController( _rData.m_rController.getXController() ); 203cdf0e10cSrcweir OSL_ENSURE( xCompController.is(), "lcl_updateActiveComponents_nothrow: can't do anything without a controller!" ); 204cdf0e10cSrcweir if ( !xCompController.is() ) 205cdf0e10cSrcweir return; 206cdf0e10cSrcweir 207cdf0e10cSrcweir if ( _rData.m_bActive && _rData.m_bIsTopLevelDocumentWindow ) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir // set the "current component" at the SfxObjectShell 210cdf0e10cSrcweir Reference< XModel > xModel( xCompController->getModel() ); 211cdf0e10cSrcweir Reference< XInterface > xCurrentComponent; 212cdf0e10cSrcweir if ( xModel.is() ) 213cdf0e10cSrcweir xCurrentComponent = xModel; 214cdf0e10cSrcweir else 215cdf0e10cSrcweir xCurrentComponent = xCompController; 216cdf0e10cSrcweir SfxObjectShell::SetCurrentComponent( xCurrentComponent ); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir } 219cdf0e10cSrcweir catch( const Exception& ) 220cdf0e10cSrcweir { 221cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 222cdf0e10cSrcweir } 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir //-------------------------------------------------------------------- 226cdf0e10cSrcweir /** broadcasts the OnFocus resp. OnUnfocus event 227cdf0e10cSrcweir */ lcl_notifyFocusChange_nothrow(ControllerFrame_Data & _rData,bool _bActive)228cdf0e10cSrcweir static void lcl_notifyFocusChange_nothrow( ControllerFrame_Data& _rData, bool _bActive ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir try 231cdf0e10cSrcweir { 232cdf0e10cSrcweir if ( _rData.m_xDocEventBroadcaster.is() ) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir ::rtl::OUString sEventName( ::rtl::OUString::createFromAscii( _bActive ? "OnFocus" : "OnUnfocus" ) ); 235cdf0e10cSrcweir Reference< XController2 > xController( _rData.m_rController.getXController(), UNO_QUERY_THROW ); 236cdf0e10cSrcweir _rData.m_xDocEventBroadcaster->notifyDocumentEvent( sEventName, xController, Any() ); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir } 239cdf0e10cSrcweir catch( const Exception& ) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 242cdf0e10cSrcweir } 243cdf0e10cSrcweir } 244cdf0e10cSrcweir 245cdf0e10cSrcweir //-------------------------------------------------------------------- lcl_updateActive_nothrow(ControllerFrame_Data & _rData,bool _bActive)246cdf0e10cSrcweir static void lcl_updateActive_nothrow( ControllerFrame_Data& _rData, bool _bActive ) 247cdf0e10cSrcweir { 248cdf0e10cSrcweir if ( _rData.m_bActive == _bActive ) 249cdf0e10cSrcweir return; 250cdf0e10cSrcweir _rData.m_bActive = _bActive; 251cdf0e10cSrcweir 252cdf0e10cSrcweir lcl_updateActiveComponents_nothrow( _rData ); 253cdf0e10cSrcweir lcl_notifyFocusChange_nothrow( _rData, _bActive ); 254cdf0e10cSrcweir } 255cdf0e10cSrcweir 256cdf0e10cSrcweir //-------------------------------------------------------------------- FrameWindowActivationListener(ControllerFrame_Data & _rData)257cdf0e10cSrcweir FrameWindowActivationListener::FrameWindowActivationListener( ControllerFrame_Data& _rData ) 258cdf0e10cSrcweir :m_pData( &_rData ) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir impl_registerOnFrameContainerWindow_nothrow( true ); 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir //-------------------------------------------------------------------- ~FrameWindowActivationListener()264cdf0e10cSrcweir FrameWindowActivationListener::~FrameWindowActivationListener() 265cdf0e10cSrcweir { 266cdf0e10cSrcweir } 267cdf0e10cSrcweir 268cdf0e10cSrcweir //-------------------------------------------------------------------- dispose()269cdf0e10cSrcweir void FrameWindowActivationListener::dispose() 270cdf0e10cSrcweir { 271cdf0e10cSrcweir impl_registerOnFrameContainerWindow_nothrow( false ); 272cdf0e10cSrcweir m_pData = NULL; 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir //-------------------------------------------------------------------- impl_registerOnFrameContainerWindow_nothrow(bool _bRegister)276cdf0e10cSrcweir void FrameWindowActivationListener::impl_registerOnFrameContainerWindow_nothrow( bool _bRegister ) 277cdf0e10cSrcweir { 278cdf0e10cSrcweir OSL_ENSURE( m_pData && m_pData->m_xFrame.is(), "FrameWindowActivationListener::impl_registerOnFrameContainerWindow_nothrow: no frame!" ); 279cdf0e10cSrcweir if ( !m_pData || !m_pData->m_xFrame.is() ) 280cdf0e10cSrcweir return; 281cdf0e10cSrcweir 282cdf0e10cSrcweir try 283cdf0e10cSrcweir { 284cdf0e10cSrcweir void ( SAL_CALL XTopWindow::*pListenerAction )( const Reference< XTopWindowListener >& ) = 285cdf0e10cSrcweir _bRegister ? &XTopWindow::addTopWindowListener : &XTopWindow::removeTopWindowListener; 286cdf0e10cSrcweir 287cdf0e10cSrcweir const Reference< XWindow > xContainerWindow( m_pData->m_xFrame->getContainerWindow(), UNO_SET_THROW ); 288cdf0e10cSrcweir if ( _bRegister ) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir const Window* pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow ); 291cdf0e10cSrcweir ENSURE_OR_THROW( pContainerWindow, "no Window implementation for the frame's container window!" ); 292cdf0e10cSrcweir 293cdf0e10cSrcweir /*const Window* pContainerParentWindow = pContainerWindow->GetParent(); 294cdf0e10cSrcweir if ( pContainerParentWindow && ( pContainerParentWindow->GetType() == WINDOW_BORDERWINDOW ) ) 295cdf0e10cSrcweir pContainerParentWindow = pContainerParentWindow->GetParent(); 296cdf0e10cSrcweir m_pData->m_bIsTopLevelDocumentWindow = ( pContainerParentWindow == NULL );*/ 297cdf0e10cSrcweir 298cdf0e10cSrcweir m_pData->m_bIsTopLevelDocumentWindow = ( pContainerWindow->GetExtendedStyle() & WB_EXT_DOCUMENT ) != 0; 299cdf0e10cSrcweir } 300cdf0e10cSrcweir 301cdf0e10cSrcweir const Reference< XTopWindow > xFrameContainer( xContainerWindow, UNO_QUERY ); 302cdf0e10cSrcweir if ( xFrameContainer.is() ) 303cdf0e10cSrcweir (xFrameContainer.get()->*pListenerAction)( this ); 304cdf0e10cSrcweir } 305cdf0e10cSrcweir catch( const Exception& ) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 308cdf0e10cSrcweir } 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir //-------------------------------------------------------------------- impl_checkDisposed_throw() const312cdf0e10cSrcweir void FrameWindowActivationListener::impl_checkDisposed_throw() const 313cdf0e10cSrcweir { 314cdf0e10cSrcweir if ( !m_pData ) 315cdf0e10cSrcweir throw DisposedException( ::rtl::OUString(), *const_cast< FrameWindowActivationListener* >( this ) ); 316cdf0e10cSrcweir } 317cdf0e10cSrcweir 318cdf0e10cSrcweir //-------------------------------------------------------------------- windowOpened(const EventObject &)319cdf0e10cSrcweir void SAL_CALL FrameWindowActivationListener::windowOpened( const EventObject& /*_rEvent*/ ) throw (RuntimeException) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir // not interested in 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir //-------------------------------------------------------------------- windowClosing(const EventObject &)325cdf0e10cSrcweir void SAL_CALL FrameWindowActivationListener::windowClosing( const EventObject& /*_rEvent*/ ) throw (RuntimeException) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir // not interested in 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir //-------------------------------------------------------------------- windowClosed(const EventObject &)331cdf0e10cSrcweir void SAL_CALL FrameWindowActivationListener::windowClosed( const EventObject& /*_rEvent*/ ) throw (RuntimeException) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir // not interested in 334cdf0e10cSrcweir } 335cdf0e10cSrcweir 336cdf0e10cSrcweir //-------------------------------------------------------------------- windowMinimized(const EventObject &)337cdf0e10cSrcweir void SAL_CALL FrameWindowActivationListener::windowMinimized( const EventObject& /*_rEvent*/ ) throw (RuntimeException) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir // not interested in 340cdf0e10cSrcweir } 341cdf0e10cSrcweir 342cdf0e10cSrcweir //-------------------------------------------------------------------- windowNormalized(const EventObject &)343cdf0e10cSrcweir void SAL_CALL FrameWindowActivationListener::windowNormalized( const EventObject& /*_rEvent*/ ) throw (RuntimeException) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir // not interested in 346cdf0e10cSrcweir } 347cdf0e10cSrcweir 348cdf0e10cSrcweir //-------------------------------------------------------------------- windowActivated(const EventObject &)349cdf0e10cSrcweir void SAL_CALL FrameWindowActivationListener::windowActivated( const EventObject& /*_rEvent*/ ) throw (RuntimeException) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir impl_checkDisposed_throw(); 352cdf0e10cSrcweir lcl_updateActive_nothrow( *m_pData, true ); 353cdf0e10cSrcweir } 354cdf0e10cSrcweir 355cdf0e10cSrcweir //-------------------------------------------------------------------- windowDeactivated(const EventObject &)356cdf0e10cSrcweir void SAL_CALL FrameWindowActivationListener::windowDeactivated( const EventObject& /*_rEvent*/ ) throw (RuntimeException) 357cdf0e10cSrcweir { 358cdf0e10cSrcweir impl_checkDisposed_throw(); 359cdf0e10cSrcweir lcl_updateActive_nothrow( *m_pData, false ); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir //-------------------------------------------------------------------- disposing(const EventObject &)363cdf0e10cSrcweir void SAL_CALL FrameWindowActivationListener::disposing( const EventObject& /*_rEvent*/ ) throw (RuntimeException) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir dispose(); 366cdf0e10cSrcweir } 367cdf0e10cSrcweir 368cdf0e10cSrcweir //==================================================================== 369cdf0e10cSrcweir //= ControllerFrame 370cdf0e10cSrcweir //==================================================================== 371cdf0e10cSrcweir //-------------------------------------------------------------------- ControllerFrame(IController & _rController)372cdf0e10cSrcweir ControllerFrame::ControllerFrame( IController& _rController ) 373cdf0e10cSrcweir :m_pData( new ControllerFrame_Data( _rController ) ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir } 376cdf0e10cSrcweir 377cdf0e10cSrcweir //-------------------------------------------------------------------- ~ControllerFrame()378cdf0e10cSrcweir ControllerFrame::~ControllerFrame() 379cdf0e10cSrcweir { 380cdf0e10cSrcweir } 381cdf0e10cSrcweir 382cdf0e10cSrcweir //-------------------------------------------------------------------- attachFrame(const Reference<XFrame> & _rxFrame)383cdf0e10cSrcweir const Reference< XFrame >& ControllerFrame::attachFrame( const Reference< XFrame >& _rxFrame ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir // set new frame, including listener handling 386cdf0e10cSrcweir lcl_setFrame_nothrow( *m_pData, _rxFrame ); 387cdf0e10cSrcweir 388cdf0e10cSrcweir // determine whether we're active 389cdf0e10cSrcweir m_pData->m_bActive = lcl_isActive_nothrow( m_pData->m_xFrame ); 390cdf0e10cSrcweir 391cdf0e10cSrcweir // update active component 392cdf0e10cSrcweir if ( m_pData->m_bActive ) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir lcl_updateActiveComponents_nothrow( *m_pData ); 395cdf0e10cSrcweir lcl_notifyFocusChange_nothrow( *m_pData, true ); 396cdf0e10cSrcweir } 397cdf0e10cSrcweir 398cdf0e10cSrcweir return m_pData->m_xFrame; 399cdf0e10cSrcweir } 400cdf0e10cSrcweir 401cdf0e10cSrcweir //-------------------------------------------------------------------- getFrame() const402cdf0e10cSrcweir const Reference< XFrame >& ControllerFrame::getFrame() const 403cdf0e10cSrcweir { 404cdf0e10cSrcweir return m_pData->m_xFrame; 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir //-------------------------------------------------------------------- isActive() const408cdf0e10cSrcweir bool ControllerFrame::isActive() const 409cdf0e10cSrcweir { 410cdf0e10cSrcweir return m_pData->m_bActive; 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 413cdf0e10cSrcweir //-------------------------------------------------------------------- frameAction(FrameAction _eAction)414cdf0e10cSrcweir void ControllerFrame::frameAction( FrameAction _eAction ) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir bool bActive = m_pData->m_bActive; 417cdf0e10cSrcweir 418cdf0e10cSrcweir switch ( _eAction ) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir case FrameAction_FRAME_ACTIVATED: 421cdf0e10cSrcweir case FrameAction_FRAME_UI_ACTIVATED: 422cdf0e10cSrcweir bActive = true; 423cdf0e10cSrcweir break; 424cdf0e10cSrcweir 425cdf0e10cSrcweir case FrameAction_FRAME_DEACTIVATING: 426cdf0e10cSrcweir case FrameAction_FRAME_UI_DEACTIVATING: 427cdf0e10cSrcweir bActive = false; 428cdf0e10cSrcweir break; 429cdf0e10cSrcweir 430cdf0e10cSrcweir default: 431cdf0e10cSrcweir break; 432cdf0e10cSrcweir } 433cdf0e10cSrcweir 434cdf0e10cSrcweir lcl_updateActive_nothrow( *m_pData, bActive ); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir //........................................................................ 438cdf0e10cSrcweir } // namespace dbaui 439cdf0e10cSrcweir //........................................................................ 440