[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - svx/source

Jan Holesovsky kendy at collabora.com
Fri Mar 11 19:47:03 UTC 2016


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

New commits:
commit 8547c89c317dbfa3c4cbace8851c10573a7f21cd
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 64b40da..7a4462c 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)
         {


More information about the Libreoffice-commits mailing list