23#include <com/sun/star/awt/MouseButton.hpp>
24#include <com/sun/star/awt/MouseEvent.hpp>
25#include <com/sun/star/awt/InputEvent.hpp>
26#include <com/sun/star/awt/KeyEvent.hpp>
27#include <com/sun/star/awt/KeyModifier.hpp>
28#include <com/sun/star/awt/XKeyHandler.hpp>
29#include <com/sun/star/awt/XMouseClickHandler.hpp>
30#include <com/sun/star/awt/XVclWindowPeer.hpp>
31#include <com/sun/star/uno/XInterface.hpp>
37#include <osl/diagnose.h>
43 using ::com::sun::star::uno::Reference;
44 using ::com::sun::star::uno::XInterface;
45 using ::com::sun::star::uno::Exception;
46 using ::com::sun::star::uno::RuntimeException;
47 using ::com::sun::star::awt::MouseEvent;
48 using ::com::sun::star::awt::KeyEvent;
49 using ::com::sun::star::awt::InputEvent;
50 using ::com::sun::star::awt::XKeyHandler;
51 using ::com::sun::star::awt::XMouseClickHandler;
52 using ::com::sun::star::lang::DisposedException;
54 namespace MouseButton = ::com::sun::star::awt::MouseButton;
55 namespace KeyModifier = ::com::sun::star::awt::KeyModifier;
75 template<
class VCLEVENT >
76 void lcl_initModifiers( InputEvent& _rEvent,
const VCLEVENT& _rVclEvent )
78 _rEvent.Modifiers = 0;
80 if ( _rVclEvent.IsShift() )
81 _rEvent.Modifiers |= KeyModifier::SHIFT;
82 if ( _rVclEvent.IsMod1() )
83 _rEvent.Modifiers |= KeyModifier::MOD1;
84 if ( _rVclEvent.IsMod2() )
85 _rEvent.Modifiers |= KeyModifier::MOD2;
86 if ( _rVclEvent.IsMod3() )
87 _rEvent.Modifiers |= KeyModifier::MOD3;
90 void lcl_initKeyEvent(
KeyEvent& rEvent, const ::KeyEvent& rEvt )
92 lcl_initModifiers( rEvent, rEvt.GetKeyCode() );
96 rEvent.KeyFunc = sal::static_int_cast< sal_Int16 >( rEvt.GetKeyCode().GetFunction());
99 void lcl_initMouseEvent(
MouseEvent& rEvent, const ::MouseEvent& rEvt )
101 lcl_initModifiers( rEvent, rEvt );
105 rEvent.Buttons |= MouseButton::LEFT;
106 if ( rEvt.IsRight() )
107 rEvent.Buttons |= MouseButton::RIGHT;
108 if ( rEvt.IsMiddle() )
109 rEvent.Buttons |= MouseButton::MIDDLE;
114 rEvent.PopupTrigger =
false;
136 if ( _rxHandler.is() )
137 m_pData->m_aKeyHandlers.addInterface( _rxHandler );
143 m_pData->m_aKeyHandlers.removeInterface( _rxHandler );
149 if ( _rxHandler.is() )
150 m_pData->m_aMouseClickHandlers.addInterface( _rxHandler );
156 m_pData->m_aMouseClickHandlers.removeInterface( _rxHandler );
162 return m_pData->m_aKeyHandlers.getLength() > 0;
168 return m_pData->m_aMouseClickHandlers.getLength() > 0;
174 Reference < XInterface > xHoldAlive(
m_pData->m_rControllerImpl );
177 bool bHandled =
false;
181 case NotifyEventType::KEYINPUT:
182 case NotifyEventType::KEYUP:
192 Reference< XKeyHandler > xHandler( aIterator.
next() );
195 if (
nType == NotifyEventType::KEYINPUT )
196 bHandled = xHandler->keyPressed(
aEvent );
198 bHandled = xHandler->keyReleased(
aEvent );
200 catch(
const DisposedException& e )
202 if ( e.Context == xHandler )
216 case NotifyEventType::MOUSEBUTTONDOWN:
217 case NotifyEventType::MOUSEBUTTONUP:
227 Reference< XMouseClickHandler > xHandler( aIterator.
next() );
230 if (
nType == NotifyEventType::MOUSEBUTTONDOWN )
231 bHandled = xHandler->mousePressed(
aEvent );
233 bHandled = xHandler->mouseReleased(
aEvent );
235 catch(
const DisposedException& e )
237 if ( e.Context == xHandler )
252 OSL_FAIL(
"UserInputInterception::handleNotifyEvent: illegal event type!" );
sal_Unicode GetCharCode() const
const vcl::KeyCode & GetKeyCode() const
sal_uInt16 GetClicks() const
const Point & GetPosPixel() const
const KeyEvent * GetKeyEvent() const
vcl::Window * GetWindow() const
const MouseEvent * GetMouseEvent() const
NotifyEventType GetType() const
constexpr tools::Long Y() const
constexpr tools::Long X() const
bool hasMoreElements() const
css::uno::Reference< ListenerT > const & next()
sal_uInt16 GetCode() const
virtual css::uno::Reference< css::awt::XVclWindowPeer > GetComponentInterface(bool bCreate=true)