sd/source/ui/func/fudraw.cxx |  162 ++++++++++++++++---------------------------
 sd/source/ui/inc/fudraw.hxx  |    3 
 2 files changed, 65 insertions(+), 100 deletions(-)

New commits:
commit ae116edc835b025d61bc7f24711c95b68b4016dd
Author: Victor Portella <visporte...@gmail.com>
Date:   Wed Nov 5 17:47:44 2014 -0200

    fdo#84380 Remove repeated mouse handling code
    
    Change-Id: I93d42ad234c4be20a4af0a2d68246699c6653105
    Reviewed-on: https://gerrit.libreoffice.org/12270
    Reviewed-by: Samuel Mehrbrodt <s.mehrbr...@gmail.com>
    Tested-by: Samuel Mehrbrodt <s.mehrbr...@gmail.com>

diff --git a/sd/source/ui/func/fudraw.cxx b/sd/source/ui/func/fudraw.cxx
index 219cd6e..9575516 100644
--- a/sd/source/ui/func/fudraw.cxx
+++ b/sd/source/ui/func/fudraw.cxx
@@ -88,6 +88,65 @@ FuDraw::~FuDraw()
     mpView->BrkAction();
 }
 
+
+/**
+ * Code shared by MouseButtonDown and MouseMove
+ */
+void FuDraw::DoModifiers(const MouseEvent& rMEvt, bool bSnapModPressed)
+{
+    FrameView* pFrameView = mpViewShell->GetFrameView();
+    bool bGridSnap = pFrameView->IsGridSnap();
+    bGridSnap = (bSnapModPressed != bGridSnap);
+
+    if (mpView->IsGridSnap() != bGridSnap)
+        mpView->SetGridSnap(bGridSnap);
+
+    bool bBordSnap = pFrameView->IsBordSnap();
+    bBordSnap = (bSnapModPressed != bBordSnap);
+
+    if (mpView->IsBordSnap() != bBordSnap)
+        mpView->SetBordSnap(bBordSnap);
+
+    bool bHlplSnap = pFrameView->IsHlplSnap();
+    bHlplSnap = (bSnapModPressed != bHlplSnap);
+
+    if (mpView->IsHlplSnap() != bHlplSnap)
+        mpView->SetHlplSnap(bHlplSnap);
+
+    bool bOFrmSnap = pFrameView->IsOFrmSnap();
+    bOFrmSnap = (bSnapModPressed != bOFrmSnap);
+
+    if (mpView->IsOFrmSnap() != bOFrmSnap)
+        mpView->SetOFrmSnap(bOFrmSnap);
+
+    bool bOPntSnap = pFrameView->IsOPntSnap();
+    bOPntSnap = (bSnapModPressed != bOPntSnap);
+
+    if (mpView->IsOPntSnap() != bOPntSnap)
+        mpView->SetOPntSnap(bOPntSnap);
+
+    bool bOConSnap = pFrameView->IsOConSnap();
+    bOConSnap = (bSnapModPressed != bOConSnap);
+
+    if (mpView->IsOConSnap() != bOConSnap)
+        mpView->SetOConSnap(bOConSnap);
+
+    bool bAngleSnap = rMEvt.IsShift() == !pFrameView->IsAngleSnapEnabled();
+
+    if (mpView->IsAngleSnapEnabled() != bAngleSnap)
+        mpView->SetAngleSnapEnabled(bAngleSnap);
+
+    bool bCenter = rMEvt.IsMod2();
+
+    if ( mpView->IsCreate1stPointAsCenter() != bCenter ||
+         mpView->IsResizeAtCenter() != bCenter )
+    {
+        mpView->SetCreate1stPointAsCenter(bCenter);
+        mpView->SetResizeAtCenter(bCenter);
+    }
+}
+
+
 bool FuDraw::MouseButtonDown(const MouseEvent& rMEvt)
 {
     // remember button state for creation of own MouseEvents
@@ -140,63 +199,14 @@ bool FuDraw::MouseButtonDown(const MouseEvent& rMEvt)
         {
             bOrtho = rMEvt.IsShift() != pFrameView->IsOrtho();
         }
-
         if (!mpView->IsSnapEnabled())
             mpView->SetSnapEnabled(true);
-        bool bSnapModPressed = rMEvt.IsMod1();
-
-        bool bGridSnap = pFrameView->IsGridSnap();
-        bGridSnap = (bSnapModPressed != bGridSnap);
-
-        if (mpView->IsGridSnap() != bGridSnap)
-            mpView->SetGridSnap(bGridSnap);
-
-        bool bBordSnap = pFrameView->IsBordSnap();
-        bBordSnap = (bSnapModPressed != bBordSnap);
-
-        if (mpView->IsBordSnap() != bBordSnap)
-            mpView->SetBordSnap(bBordSnap);
-
-        bool bHlplSnap = pFrameView->IsHlplSnap();
-        bHlplSnap = (bSnapModPressed != bHlplSnap);
-
-        if (mpView->IsHlplSnap() != bHlplSnap)
-            mpView->SetHlplSnap(bHlplSnap);
-
-        bool bOFrmSnap = pFrameView->IsOFrmSnap();
-        bOFrmSnap = (bSnapModPressed != bOFrmSnap);
-
-        if (mpView->IsOFrmSnap() != bOFrmSnap)
-            mpView->SetOFrmSnap(bOFrmSnap);
-
-        bool bOPntSnap = pFrameView->IsOPntSnap();
-        bOPntSnap = (bSnapModPressed != bOPntSnap);
-
-        if (mpView->IsOPntSnap() != bOPntSnap)
-            mpView->SetOPntSnap(bOPntSnap);
-
-        bool bOConSnap = pFrameView->IsOConSnap();
-        bOConSnap = (bSnapModPressed != bOConSnap);
-
-        if (mpView->IsOConSnap() != bOConSnap)
-            mpView->SetOConSnap(bOConSnap);
-
-        bool bAngleSnap = rMEvt.IsShift() == !pFrameView->IsAngleSnapEnabled();
-
-        if (mpView->IsAngleSnapEnabled() != bAngleSnap)
-            mpView->SetAngleSnapEnabled(bAngleSnap);
 
+        bool bSnapModPressed = rMEvt.IsMod1();
         if (mpView->IsOrtho() != bOrtho)
             mpView->SetOrtho(bOrtho);
 
-        bool bCenter = rMEvt.IsMod2();
-
-        if ( mpView->IsCreate1stPointAsCenter() != bCenter ||
-             mpView->IsResizeAtCenter() != bCenter )
-        {
-            mpView->SetCreate1stPointAsCenter(bCenter);
-            mpView->SetResizeAtCenter(bCenter);
-        }
+        DoModifiers(rMEvt, bSnapModPressed);
 
         SdrPageView* pPV = 0;
         sal_uInt16 nHitLog = sal_uInt16 ( 
mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
@@ -259,58 +269,10 @@ bool FuDraw::MouseMove(const MouseEvent& rMEvt)
         bool bSnapModPressed = rMEvt.IsMod2();
         mpView->SetDragWithCopy(rMEvt.IsMod1() && 
pFrameView->IsDragWithCopy());
 
-        bool bGridSnap = pFrameView->IsGridSnap();
-        bGridSnap = (bSnapModPressed != bGridSnap);
-
-        if (mpView->IsGridSnap() != bGridSnap)
-            mpView->SetGridSnap(bGridSnap);
-
-        bool bBordSnap = pFrameView->IsBordSnap();
-        bBordSnap = (bSnapModPressed != bBordSnap);
-
-        if (mpView->IsBordSnap() != bBordSnap)
-            mpView->SetBordSnap(bBordSnap);
-
-        bool bHlplSnap = pFrameView->IsHlplSnap();
-        bHlplSnap = (bSnapModPressed != bHlplSnap);
-
-        if (mpView->IsHlplSnap() != bHlplSnap)
-            mpView->SetHlplSnap(bHlplSnap);
-
-        bool bOFrmSnap = pFrameView->IsOFrmSnap();
-        bOFrmSnap = (bSnapModPressed != bOFrmSnap);
-
-        if (mpView->IsOFrmSnap() != bOFrmSnap)
-            mpView->SetOFrmSnap(bOFrmSnap);
-
-        bool bOPntSnap = pFrameView->IsOPntSnap();
-        bOPntSnap = (bSnapModPressed != bOPntSnap);
-
-        if (mpView->IsOPntSnap() != bOPntSnap)
-            mpView->SetOPntSnap(bOPntSnap);
-
-        bool bOConSnap = pFrameView->IsOConSnap();
-        bOConSnap = (bSnapModPressed != bOConSnap);
-
-        if (mpView->IsOConSnap() != bOConSnap)
-            mpView->SetOConSnap(bOConSnap);
-
-        bool bAngleSnap = rMEvt.IsShift() == !pFrameView->IsAngleSnapEnabled();
-
-        if (mpView->IsAngleSnapEnabled() != bAngleSnap)
-            mpView->SetAngleSnapEnabled(bAngleSnap);
-
         if (mpView->IsOrtho() != bOrtho)
             mpView->SetOrtho(bOrtho);
+        DoModifiers(rMEvt, bSnapModPressed);
 
-        bool bCenter = rMEvt.IsMod2();
-
-        if ( mpView->IsCreate1stPointAsCenter() != bCenter ||
-             mpView->IsResizeAtCenter() != bCenter )
-        {
-            mpView->SetCreate1stPointAsCenter(bCenter);
-            mpView->SetResizeAtCenter(bCenter);
-        }
 
         if ( mpView->IsDragHelpLine() )
             mpView->MovDragHelpLine(aPos);
diff --git a/sd/source/ui/inc/fudraw.hxx b/sd/source/ui/inc/fudraw.hxx
index 41efba2..19a7ab6 100644
--- a/sd/source/ui/inc/fudraw.hxx
+++ b/sd/source/ui/inc/fudraw.hxx
@@ -80,6 +80,9 @@ protected:
     bool    bPermanent;
     bool bIsImageSelected;
 
+private:
+    void DoModifiers(const MouseEvent& rMEvt, bool bSnapModPressed);
+
 };
 
 } // end of namespace sd
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to