filter/source/msfilter/msdffimp.cxx | 38 +++++++++++++++++++++++++++++++- include/filter/msfilter/msdffimp.hxx | 2 + include/svtools/editbrowsebox.hxx | 13 +++++++++++ svtools/source/brwbox/ebbcontrols.cxx | 18 ++++++++++++--- svx/source/fmcomp/gridcell.cxx | 40 ++++++++++++---------------------- svx/source/inc/gridcell.hxx | 6 +---- 6 files changed, 84 insertions(+), 33 deletions(-)
New commits: commit f49ffc2ca908712831d9b7b3432b053728e541e0 Author: Caolán McNamara <[email protected]> AuthorDate: Mon Dec 19 11:55:05 2022 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Tue Dec 20 08:22:42 2022 +0000 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 <[email protected]> diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx index aa6b72441373..2297c45a63a8 100644 --- a/include/svtools/editbrowsebox.hxx +++ b/include/svtools/editbrowsebox.hxx @@ -202,8 +202,19 @@ namespace svt m_aMouseMoveHdl = rHdl; } + void SetKeyInputHdl(const Link<const KeyEvent&,void>& rHdl) + { + m_aKeyInputHdl = rHdl; + } + + void SetKeyReleaseHdl(const Link<const KeyEvent&,void>& rHdl) + { + m_aKeyReleaseHdl = rHdl; + } + protected: DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent&, bool); + DECL_DLLPRIVATE_LINK(KeyReleaseHdl, const KeyEvent&, bool); DECL_DLLPRIVATE_LINK(FocusInHdl, weld::Widget&, void); DECL_DLLPRIVATE_LINK(FocusOutHdl, weld::Widget&, void); DECL_DLLPRIVATE_LINK(MousePressHdl, const MouseEvent&, bool); @@ -215,6 +226,8 @@ namespace svt Link<const MouseEvent&,void> m_aMousePressHdl; Link<const MouseEvent&,void> m_aMouseReleaseHdl; Link<const MouseEvent&,void> m_aMouseMoveHdl; + Link<const KeyEvent&,void> m_aKeyInputHdl; + Link<const KeyEvent&,void> m_aKeyReleaseHdl; }; class SVT_DLLPUBLIC EditControlBase : public ControlBase diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx index b6a27a2567f4..b0a2ad1bbcc3 100644 --- a/svtools/source/brwbox/ebbcontrols.cxx +++ b/svtools/source/brwbox/ebbcontrols.cxx @@ -30,6 +30,7 @@ namespace svt m_xWidget->set_entry_width_chars(1); // so a smaller than default width can be used m_xWidget->connect_changed(LINK(this, ComboBoxControl, SelectHdl)); m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl)); + m_xWidget->connect_key_release(LINK(this, ControlBase, KeyReleaseHdl)); m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl)); m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl)); m_xWidget->connect_mouse_press(LINK(this, ControlBase, MousePressHdl)); @@ -125,6 +126,7 @@ namespace svt m_xWidget->set_size_request(42, -1); // so a later narrow size request can stick m_xWidget->connect_changed(LINK(this, ListBoxControl, SelectHdl)); m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl)); + m_xWidget->connect_key_release(LINK(this, ControlBase, KeyReleaseHdl)); m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl)); m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl)); m_xWidget->connect_mouse_press(LINK(this, ControlBase, MousePressHdl)); @@ -203,6 +205,7 @@ namespace svt m_aModeState.bTriStateEnabled = true; InitControlBase(m_xBox.get()); m_xBox->connect_key_press(LINK(this, ControlBase, KeyInputHdl)); + m_xBox->connect_key_release(LINK(this, ControlBase, KeyReleaseHdl)); m_xBox->connect_focus_in(LINK(this, ControlBase, FocusInHdl)); m_xBox->connect_focus_out(LINK(this, ControlBase, FocusOutHdl)); m_xBox->connect_mouse_press(LINK(this, ControlBase, MousePressHdl)); @@ -362,9 +365,10 @@ namespace svt m_pEntry = pEntry; m_pEntry->show(); m_pEntry->set_width_chars(1); // so a smaller than default width can be used - connect_key_press(LINK(this, ControlBase, KeyInputHdl)); - connect_focus_in(LINK(this, ControlBase, FocusInHdl)); - connect_focus_out(LINK(this, ControlBase, FocusOutHdl)); + connect_focus_in(LINK(this, ControlBase, FocusInHdl)); // need to chain with pattern handler + connect_focus_out(LINK(this, ControlBase, FocusOutHdl)); // need to chain with pattern handler + connect_key_press(LINK(this, ControlBase, KeyInputHdl)); // need to chain with pattern handler + m_pEntry->connect_key_release(LINK(this, ControlBase, KeyReleaseHdl)); m_pEntry->connect_mouse_press(LINK(this, ControlBase, MousePressHdl)); m_pEntry->connect_mouse_release(LINK(this, ControlBase, MouseReleaseHdl)); m_pEntry->connect_mouse_move(LINK(this, ControlBase, MouseMoveHdl)); @@ -377,9 +381,16 @@ namespace svt IMPL_LINK(ControlBase, KeyInputHdl, const KeyEvent&, rKEvt, bool) { + m_aKeyInputHdl.Call(rKEvt); return ProcessKey(rKEvt); } + IMPL_LINK(ControlBase, KeyReleaseHdl, const KeyEvent&, rKEvt, bool) + { + m_aKeyReleaseHdl.Call(rKEvt); + return false; + } + IMPL_LINK_NOARG(ControlBase, FocusInHdl, weld::Widget&, void) { m_aFocusInHdl.Call(nullptr); @@ -703,6 +714,7 @@ namespace svt { InitControlBase(m_xWidget.get()); m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl)); + m_xWidget->connect_key_release(LINK(this, ControlBase, KeyReleaseHdl)); m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl)); m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl)); m_xWidget->connect_mouse_press(LINK(this, ControlBase, MousePressHdl)); 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); }; commit b476027308a3be3459f1f499573848ee700fa607 Author: Caolán McNamara <[email protected]> AuthorDate: Mon Dec 19 11:04:59 2022 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Tue Dec 20 08:22:32 2022 +0000 crashtesting: asserts with outsized object positions seen during import of: forums/forum-mso-en4-187408.xls forums/forum-mso-en4-187900.xls forums/forum-mso-en4-187890.xls Change-Id: Id15e9c1ea98d761225d41850b9b2aa58d9c9e407 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144466 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit d968061f008b954f55ab9a4dd51efd5d0844b543) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144482 diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index fe5cd766811b..cdcad2778f6f 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -54,8 +54,9 @@ // SvxItem-Mapping. Is needed to successfully include the SvxItem-Header #include <editeng/eeitem.hxx> #include <editeng/editdata.hxx> -#include <tools/stream.hxx> +#include <tools/bigint.hxx> #include <tools/debug.hxx> +#include <tools/stream.hxx> #include <tools/zcodec.hxx> #include <filter/msfilter/escherex.hxx> #include <basegfx/numeric/ftools.hxx> @@ -3152,7 +3153,22 @@ bool CompareSvxMSDffShapeInfoByTxBxComp::operator() ( void SvxMSDffManager::Scale( sal_Int32& rVal ) const { if ( bNeedMap ) + { + if (rVal > nMaxAllowedVal) + { + SAL_WARN("filter.ms", "Cannot scale value: " << rVal); + rVal = SAL_MAX_INT32; + return; + } + else if (rVal < nMinAllowedVal) + { + SAL_WARN("filter.ms", "Cannot scale value: " << rVal); + rVal = SAL_MAX_INT32; + return; + } + rVal = BigMulDiv( rVal, nMapMul, nMapDiv ); + } } void SvxMSDffManager::Scale( Point& rPos ) const @@ -3235,6 +3251,26 @@ void SvxMSDffManager::SetModel(SdrModel* pModel, tools::Long nApplicationScale) nMapMul = nMapDiv = nMapXOfs = nMapYOfs = nEmuMul = nEmuDiv = nPntMul = nPntDiv = 0; bNeedMap = false; } + + if (bNeedMap) + { + assert(nMapMul > nMapDiv); + + BigInt aMinVal(SAL_MIN_INT32); + aMinVal /= nMapMul; + aMinVal *= nMapDiv; + nMinAllowedVal = aMinVal; + + BigInt aMaxVal(SAL_MAX_INT32); + aMaxVal /= nMapMul; + aMaxVal *= nMapDiv; + nMaxAllowedVal = aMaxVal; + } + else + { + nMinAllowedVal = SAL_MIN_INT32; + nMaxAllowedVal = SAL_MAX_INT32; + } } bool SvxMSDffManager::SeekToShape( SvStream& rSt, SvxMSDffClientData* /* pClientData */, sal_uInt32 nId ) const diff --git a/include/filter/msfilter/msdffimp.hxx b/include/filter/msfilter/msdffimp.hxx index da1dc29fe442..7f2c5a2763d0 100644 --- a/include/filter/msfilter/msdffimp.hxx +++ b/include/filter/msfilter/msdffimp.hxx @@ -455,6 +455,8 @@ protected: tools::Long nPntMul; tools::Long nPntDiv; bool bNeedMap; + sal_Int32 nMinAllowedVal; + sal_Int32 nMaxAllowedVal; sal_uInt32 nSvxMSDffSettings; sal_uInt32 nSvxMSDffOLEConvFlags;
