svx/source/table/tablecontroller.cxx |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

New commits:
commit 97c872d015350810fb0180ffdb10de7f039363a4
Author: Jan Holesovsky <ke...@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)
         {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to