summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-12-19 11:55:05 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-12-20 08:22:42 +0000
commitf49ffc2ca908712831d9b7b3432b053728e541e0 (patch)
tree535a154d7003540089f64d2703581f224cdcb635 /svx
parentb476027308a3be3459f1f499573848ee700fa607 (diff)
Resolves: tdf#146933 wire up keypress events for table control widgets
Change-Id: Idc8cc3c24d061537a76a37f4fa84951a41a42657 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144488 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/fmcomp/gridcell.cxx40
-rw-r--r--svx/source/inc/gridcell.hxx6
2 files changed, 17 insertions, 29 deletions
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index fead2880f100..c231d7415ec6 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -3204,12 +3204,13 @@ void FmXGridCell::init()
svt::ControlBase* pEventWindow( getEventWindow() );
if ( pEventWindow )
{
- pEventWindow->AddEventListener( LINK( this, FmXGridCell, OnWindowEvent ) );
pEventWindow->SetFocusInHdl(LINK( this, FmXGridCell, OnFocusGained));
pEventWindow->SetFocusOutHdl(LINK( this, FmXGridCell, OnFocusLost));
pEventWindow->SetMousePressHdl(LINK( this, FmXGridCell, OnMousePress));
pEventWindow->SetMouseReleaseHdl(LINK( this, FmXGridCell, OnMouseRelease));
pEventWindow->SetMouseMoveHdl(LINK( this, FmXGridCell, OnMouseMove));
+ pEventWindow->SetKeyInputHdl( LINK( this, FmXGridCell, OnKeyInput) );
+ pEventWindow->SetKeyReleaseHdl( LINK( this, FmXGridCell, OnKeyRelease) );
}
}
@@ -3441,12 +3442,6 @@ void SAL_CALL FmXGridCell::removePaintListener( const Reference< awt::XPaintList
OSL_FAIL( "FmXGridCell::removePaintListener: not implemented" );
}
-IMPL_LINK( FmXGridCell, OnWindowEvent, VclWindowEvent&, _rEvent, void )
-{
- ENSURE_OR_THROW( _rEvent.GetWindow(), "illegal window" );
- onWindowEvent(_rEvent.GetId(), _rEvent.GetData());
-}
-
void FmXGridCell::onFocusGained( const awt::FocusEvent& _rEvent )
{
checkDisposed(OComponentHelper::rBHelper.bDisposed);
@@ -3523,25 +3518,23 @@ IMPL_LINK(FmXGridCell, OnMouseMove, const MouseEvent&, rMouseEvent, void)
}
}
-void FmXGridCell::onWindowEvent(const VclEventId _nEventId, const void* _pEventData)
+IMPL_LINK(FmXGridCell, OnKeyInput, const KeyEvent&, rEventData, void)
{
- switch ( _nEventId )
- {
- case VclEventId::WindowKeyInput:
- case VclEventId::WindowKeyUp:
- {
- if ( !m_aKeyListeners.getLength() )
- break;
+ if (!m_aKeyListeners.getLength())
+ return;
- const bool bKeyPressed = ( _nEventId == VclEventId::WindowKeyInput );
- awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent( *static_cast< const ::KeyEvent* >( _pEventData ), *this ) );
- m_aKeyListeners.notifyEach( bKeyPressed ? &awt::XKeyListener::keyPressed: &awt::XKeyListener::keyReleased, aEvent );
- }
- break;
- default: break;
- }
+ awt::KeyEvent aEvent(VCLUnoHelper::createKeyEvent(rEventData, *this));
+ m_aKeyListeners.notifyEach(&awt::XKeyListener::keyPressed, aEvent);
}
+IMPL_LINK(FmXGridCell, OnKeyRelease, const KeyEvent&, rEventData, void)
+{
+ if (!m_aKeyListeners.getLength())
+ return;
+
+ awt::KeyEvent aEvent(VCLUnoHelper::createKeyEvent(rEventData, *this));
+ m_aKeyListeners.notifyEach(&awt::XKeyListener::keyReleased, aEvent);
+}
void FmXDataCell::PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& rRect,
const Reference< css::sdb::XColumn >& _rxField,
@@ -3550,7 +3543,6 @@ void FmXDataCell::PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& r
m_pCellControl->PaintFieldToCell( rDev, rRect, _rxField, xFormatter );
}
-
void FmXDataCell::UpdateFromColumn()
{
Reference< css::sdb::XColumn > xField(m_pColumn->GetCurrentFieldValue());
@@ -3558,14 +3550,12 @@ void FmXDataCell::UpdateFromColumn()
m_pCellControl->UpdateFromField(xField, m_pColumn->GetParent().getNumberFormatter());
}
-
FmXTextCell::FmXTextCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl )
:FmXDataCell( pColumn, std::move(pControl) )
,m_bIsMultiLineText(false)
{
}
-
void FmXTextCell::PaintFieldToCell(OutputDevice& rDev,
const tools::Rectangle& rRect,
const Reference< css::sdb::XColumn >& _rxField,
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index dc30f72802b3..8b62384343f5 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -763,8 +763,6 @@ public:
{ m_pCellControl->AlignControl(nAlignment);}
protected:
- void onWindowEvent(const VclEventId _nEventId, const void* _pEventData);
-
// default implementations call our focus listeners, don't forget to call them if you override this
virtual void onFocusGained( const css::awt::FocusEvent& _rEvent );
virtual void onFocusLost( const css::awt::FocusEvent& _rEvent );
@@ -776,8 +774,8 @@ private:
DECL_LINK(OnMousePress, const MouseEvent&, void);
DECL_LINK(OnMouseRelease, const MouseEvent&, void);
DECL_LINK(OnMouseMove, const MouseEvent&, void);
-
- DECL_LINK( OnWindowEvent, VclWindowEvent&, void );
+ DECL_LINK(OnKeyInput, const KeyEvent&, void);
+ DECL_LINK(OnKeyRelease, const KeyEvent&, void);
};