23#include <com/sun/star/awt/XTopWindow.hpp>
24#include <com/sun/star/awt/XWindow2.hpp>
25#include <com/sun/star/lang/DisposedException.hpp>
26#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
27#include <com/sun/star/frame/XController2.hpp>
39 using ::com::sun::star::uno::Reference;
40 using ::com::sun::star::uno::XInterface;
41 using ::com::sun::star::uno::UNO_QUERY;
42 using ::com::sun::star::uno::UNO_QUERY_THROW;
43 using ::com::sun::star::uno::UNO_SET_THROW;
44 using ::com::sun::star::uno::Exception;
45 using ::com::sun::star::uno::Any;
46 using ::com::sun::star::frame::XFrame;
47 using ::com::sun::star::frame::FrameAction;
48 using ::com::sun::star::frame::FrameAction_FRAME_ACTIVATED;
49 using ::com::sun::star::frame::FrameAction_FRAME_UI_ACTIVATED;
50 using ::com::sun::star::frame::FrameAction_FRAME_DEACTIVATING;
51 using ::com::sun::star::frame::FrameAction_FRAME_UI_DEACTIVATING;
52 using ::com::sun::star::frame::XModel;
53 using ::com::sun::star::frame::XController;
54 using ::com::sun::star::frame::XController2;
55 using ::com::sun::star::awt::XTopWindow;
56 using ::com::sun::star::awt::XTopWindowListener;
57 using ::com::sun::star::awt::XWindow2;
58 using ::com::sun::star::lang::DisposedException;
59 using ::com::sun::star::lang::EventObject;
60 using ::com::sun::star::document::XDocumentEventBroadcaster;
61 using ::com::sun::star::awt::XWindow;
64 typedef ::cppu::WeakImplHelper< XTopWindowListener
77 virtual ~FrameWindowActivationListener()
override;
80 virtual void SAL_CALL
windowOpened(
const css::lang::EventObject& e )
override;
81 virtual void SAL_CALL
windowClosing(
const css::lang::EventObject& e )
override;
82 virtual void SAL_CALL
windowClosed(
const css::lang::EventObject& e )
override;
83 virtual void SAL_CALL
windowMinimized(
const css::lang::EventObject& e )
override;
84 virtual void SAL_CALL
windowNormalized(
const css::lang::EventObject& e )
override;
85 virtual void SAL_CALL
windowActivated(
const css::lang::EventObject& e )
override;
86 virtual void SAL_CALL
windowDeactivated(
const css::lang::EventObject& e )
override;
89 virtual void SAL_CALL disposing(
const css::lang::EventObject&
Source )
override;
92 void impl_checkDisposed_throw()
const;
93 void impl_registerOnFrameContainerWindow_nothrow(
bool _bRegister );
134 _rData.
m_pListener =
new FrameWindowActivationListener( _rData );
152 bool bIsActive =
false;
158 bIsActive = xWindow->isActive();
181 OSL_ENSURE( xCompController.is(),
"lcl_updateActiveComponents_nothrow: can't do anything without a controller!" );
182 if ( !xCompController.is() )
191 xCurrentComponent =
xModel;
193 xCurrentComponent = xCompController;
211 OUString sEventName = _bActive ? OUString(
"OnFocus") : OUString(
"OnUnfocus");
232 FrameWindowActivationListener::FrameWindowActivationListener( ControllerFrame_Data& _rData )
235 impl_registerOnFrameContainerWindow_nothrow(
true );
238 FrameWindowActivationListener::~FrameWindowActivationListener()
242 void FrameWindowActivationListener::dispose()
244 impl_registerOnFrameContainerWindow_nothrow(
false );
248 void FrameWindowActivationListener::impl_registerOnFrameContainerWindow_nothrow(
bool _bRegister )
250 OSL_ENSURE(
m_pData &&
m_pData->m_xFrame.is(),
"FrameWindowActivationListener::impl_registerOnFrameContainerWindow_nothrow: no frame!" );
256 void ( SAL_CALL XTopWindow::*pListenerAction )(
const Reference< XTopWindowListener >& ) =
257 _bRegister ? &XTopWindow::addTopWindowListener : &XTopWindow::removeTopWindowListener;
259 const Reference< XWindow > xContainerWindow(
m_pData->m_xFrame->getContainerWindow(), UNO_SET_THROW );
263 ENSURE_OR_THROW( pContainerWindow,
"no Window implementation for the frame's container window!" );
265 m_pData->m_bIsTopLevelDocumentWindow = bool( pContainerWindow->
GetExtendedStyle() & WindowExtendedStyle::Document );
268 const Reference< XTopWindow > xFrameContainer( xContainerWindow, UNO_QUERY );
269 if ( xFrameContainer.is() )
270 (xFrameContainer.get()->*pListenerAction)(
this );
272 catch(
const Exception& )
278 void FrameWindowActivationListener::impl_checkDisposed_throw()
const
281 throw DisposedException( OUString(), *
const_cast< FrameWindowActivationListener*
>(
this ) );
284 void SAL_CALL FrameWindowActivationListener::windowOpened(
const EventObject& )
289 void SAL_CALL FrameWindowActivationListener::windowClosing(
const EventObject& )
294 void SAL_CALL FrameWindowActivationListener::windowClosed(
const EventObject& )
299 void SAL_CALL FrameWindowActivationListener::windowMinimized(
const EventObject& )
304 void SAL_CALL FrameWindowActivationListener::windowNormalized(
const EventObject& )
309 void SAL_CALL FrameWindowActivationListener::windowActivated(
const EventObject& )
311 impl_checkDisposed_throw();
315 void SAL_CALL FrameWindowActivationListener::windowDeactivated(
const EventObject& )
317 impl_checkDisposed_throw();
321 void SAL_CALL FrameWindowActivationListener::disposing(
const EventObject& )
366 bool bActive =
m_pData->m_bActive;
370 case FrameAction_FRAME_ACTIVATED:
371 case FrameAction_FRAME_UI_ACTIVATED:
375 case FrameAction_FRAME_DEACTIVATING:
376 case FrameAction_FRAME_UI_DEACTIVATING:
static void SetCurrentComponent(const css::uno::Reference< css::uno::XInterface > &_rxComponent)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
const css::uno::Reference< css::frame::XFrame > & getFrame() const
void frameAction(css::frame::FrameAction _eAction)
notifies the instance that a certain frame action happened with our frame
bool isActive() const
determines whether the frame is currently active
::std::unique_ptr< ControllerFrame_Data > m_pData
const css::uno::Reference< css::frame::XFrame > & attachFrame(const css::uno::Reference< css::frame::XFrame > &_rxFrame)
attaches a new frame
virtual css::uno::Reference< css::frame::XController > getXController()=0
provides access to the model of the controller
WindowExtendedStyle GetExtendedStyle() const
ControllerFrame_Data * m_pData
#define ENSURE_OR_THROW(c, m)
#define DBG_UNHANDLED_EXCEPTION(...)
void SAL_CALL windowClosed(const css::lang::EventObject &e) override
void SAL_CALL windowMinimized(const css::lang::EventObject &e) override
void SAL_CALL windowDeactivated(const css::lang::EventObject &e) override
void SAL_CALL windowActivated(const css::lang::EventObject &e) override
DECL_LISTENERMULTIPLEXER_END void SAL_CALL windowOpened(const css::lang::EventObject &e) override
void SAL_CALL windowClosing(const css::lang::EventObject &e) override
void SAL_CALL windowNormalized(const css::lang::EventObject &e) override
static void lcl_setFrame_nothrow(ControllerFrame_Data &_rData, const Reference< XFrame > &_rxFrame)
static void lcl_updateActiveComponents_nothrow(const ControllerFrame_Data &_rData)
updates various global and local states with a new active component
static void lcl_notifyFocusChange_nothrow(ControllerFrame_Data &_rData, bool _bActive)
broadcasts the OnFocus resp.
static bool lcl_isActive_nothrow(const Reference< XFrame > &_rxFrame)
static void lcl_updateActive_nothrow(ControllerFrame_Data &_rData, bool _bActive)
::cppu::WeakImplHelper< XTopWindowListener > FrameWindowActivationListener_Base
Reference< XFrame > m_xFrame
bool m_bIsTopLevelDocumentWindow
::rtl::Reference< FrameWindowActivationListener > m_pListener
ControllerFrame_Data(IController &_rController)
IController & m_rController
Reference< XDocumentEventBroadcaster > m_xDocEventBroadcaster
Reference< XController > xController
the controller of the sub component. Must not be <NULL>
Reference< XModel > xModel
the model of the sub component. Might be <NULL>