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