diff options
author | Jan Holesovsky <kendy@collabora.com> | 2016-03-11 20:45:02 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2016-03-11 20:45:02 +0100 |
commit | 8547c89c317dbfa3c4cbace8851c10573a7f21cd (patch) | |
tree | 6731f0e2f7555d1a0500c9751f79732f77b74adf /svx | |
parent | 3ad66fb1c410d5f954904dddd4883807f2dc8c93 (diff) |
lok: Avoid dereferencing nullptr.
Change-Id: I40a53cf08e2a789299cd7a05d531b4f920653989
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/table/tablecontroller.cxx | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx index 64b40da926c2..7a4462c36972 100644 --- a/svx/source/table/tablecontroller.cxx +++ b/svx/source/table/tablecontroller.cxx @@ -244,9 +244,17 @@ bool SvxTableController::onKeyInput(const KeyEvent& rKEvt, vcl::Window* pWindow return executeAction( nAction, rKEvt.GetKeyCode().IsShift(), pWindow ); } +namespace { -// ::com::sun::star::awt::XMouseClickHandler: +Point pixelToLogic(const Point& rPoint, vcl::Window* pWindow) +{ + if (!pWindow) + return rPoint; + + return pWindow->PixelToLogic(rPoint); +} +} bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window* pWindow ) { @@ -267,7 +275,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window* if( !rMEvt.IsRight() && mpView->PickAnything(rMEvt,SdrMouseEventKind::BUTTONDOWN, aVEvt) == SDRHIT_HANDLE ) return false; - TableHitKind eHit = static_cast< SdrTableObj* >(mxTableObj.get())->CheckTableHit( pWindow->PixelToLogic(rMEvt.GetPosPixel()), maMouseDownPos.mnCol, maMouseDownPos.mnRow, 0 ); + TableHitKind eHit = static_cast< SdrTableObj* >(mxTableObj.get())->CheckTableHit(pixelToLogic(rMEvt.GetPosPixel(), pWindow), maMouseDownPos.mnCol, maMouseDownPos.mnRow, 0); mbLeftButtonDown = (rMEvt.GetClicks() == 1) && rMEvt.IsLeft(); @@ -285,11 +293,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window* { RemoveSelection(); - Point aPnt(rMEvt.GetPosPixel()); - if (pWindow!=NULL) - aPnt=pWindow->PixelToLogic(aPnt); - - SdrHdl* pHdl = mpView->PickHandle(aPnt); + SdrHdl* pHdl = mpView->PickHandle(pixelToLogic(rMEvt.GetPosPixel(), pWindow)); if( pHdl ) { @@ -346,8 +350,6 @@ bool SvxTableController::onMouseButtonUp(const MouseEvent& rMEvt, vcl::Window* / return false; } - - bool SvxTableController::onMouseMove(const MouseEvent& rMEvt, vcl::Window* pWindow ) { if( !checkTableObject() ) @@ -355,7 +357,7 @@ bool SvxTableController::onMouseMove(const MouseEvent& rMEvt, vcl::Window* pWind SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >( mxTableObj.get() ); CellPos aPos; - if( mbLeftButtonDown && pTableObj && pTableObj->CheckTableHit( pWindow->PixelToLogic(rMEvt.GetPosPixel()), aPos.mnCol, aPos.mnRow, 0 ) != SDRTABLEHIT_NONE ) + if (mbLeftButtonDown && pTableObj && pTableObj->CheckTableHit(pixelToLogic(rMEvt.GetPosPixel(), pWindow), aPos.mnCol, aPos.mnRow, 0 ) != SDRTABLEHIT_NONE) { if(aPos != maMouseDownPos) { |