[Libreoffice-commits] core.git: svx/source
Jan Holesovsky
kendy at collabora.com
Fri Mar 11 19:55:09 UTC 2016
svx/source/table/tablecontroller.cxx | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
New commits:
commit 97c872d015350810fb0180ffdb10de7f039363a4
Author: Jan Holesovsky <kendy at collabora.com>
Date: Fri Mar 11 20:45:02 2016 +0100
lok: Avoid dereferencing nullptr.
Change-Id: I40a53cf08e2a789299cd7a05d531b4f920653989
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index 73e33df..afb4229 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -243,9 +243,17 @@ bool SvxTableController::onKeyInput(const KeyEvent& rKEvt, vcl::Window* pWindow
return executeAction( nAction, rKEvt.GetKeyCode().IsShift(), pWindow );
}
+namespace {
-// css::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 )
{
@@ -266,7 +274,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();
@@ -284,11 +292,7 @@ bool SvxTableController::onMouseButtonDown(const MouseEvent& rMEvt, vcl::Window*
{
RemoveSelection();
- Point aPnt(rMEvt.GetPosPixel());
- if (pWindow!=nullptr)
- aPnt=pWindow->PixelToLogic(aPnt);
-
- SdrHdl* pHdl = mpView->PickHandle(aPnt);
+ SdrHdl* pHdl = mpView->PickHandle(pixelToLogic(rMEvt.GetPosPixel(), pWindow));
if( pHdl )
{
@@ -352,7 +356,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)
{
More information about the Libreoffice-commits
mailing list