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