[Libreoffice-commits] core.git: sw/inc sw/source

Noel Grandin noel at peralex.com
Sun Oct 12 09:44:11 PDT 2014


 sw/inc/fesh.hxx                    |   15 +++++++-----
 sw/source/core/frmedt/feshview.cxx |   44 ++++++++++++++++++-------------------
 sw/source/uibase/docvw/edtwin.cxx  |    8 +++---
 3 files changed, 35 insertions(+), 32 deletions(-)

New commits:
commit c967872d46a7cfd7c52063068313d5ec0356453e
Author: Noel Grandin <noel at peralex.com>
Date:   Sun Oct 12 17:25:33 2014 +0200

    convert SW_MOVE constants to enum
    
    Change-Id: I504862618bfeeeed674c1cb816104a167cb2e27e
    Reviewed-on: https://gerrit.libreoffice.org/11935
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index 2a10307..f01e2d5 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -143,10 +143,13 @@ struct SwGetCurColNumPara
 #define SW_ENTER_GROUP  2
 #define SW_LEAVE_FRAME  4
 
-#define SW_MOVE_UP      0
-#define SW_MOVE_DOWN    1
-#define SW_MOVE_LEFT    2
-#define SW_MOVE_RIGHT   3
+enum class SwMove
+{
+    UP      = 0,
+    DOWN    = 1,
+    LEFT    = 2,
+    RIGHT   = 3
+};
 
 #define SW_TABCOL_NONE          0
 #define SW_TABCOL_HORI          1
@@ -259,7 +262,7 @@ public:
      the draw object. */
     bool ShouldObjectBeSelected(const Point& rPt);
 
-    bool MoveAnchor( sal_uInt16 nDir );
+    bool MoveAnchor( SwMove nDir );
 
     /** @return if Upper of frame at current position is section frame
      Currently only used by the rules. To be replaced by something more
@@ -453,7 +456,7 @@ public:
     const SdrObject* GetBestObject( bool bNext, sal_uInt16 eType = GOTOOBJ_DRAW_ANY, bool bFlat = true, const ::svx::ISdrObjectFilter* pFilter = NULL );
     bool GotoObj( bool bNext, sal_uInt16 /*GOTOOBJ_...*/ eType = GOTOOBJ_DRAW_ANY);
 
-    /// Set DragMode (e.g. Rotae), but do nothing when frame is selected.
+    /// Set DragMode (e.g. Rotate), but do nothing when frame is selected.
     void SetDragMode( sal_uInt16 eSdrDragMode );
 
     sal_uInt16 IsObjSelected() const;   ///< @return object count, but doesn't count the objects in groups.
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index d64644e..bf88617 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -287,7 +287,7 @@ bool SwFEShell::SelectObj( const Point& rPt, sal_uInt8 nFlag, SdrObject *pObj )
         ( aPt1.getY() == aPt2.getY() && ( aPt1.getX() < aPt2.getX() || \
         ( aPt1.getX() == aPt2.getX() && bOld ) ) ) )
 
-bool SwFEShell::MoveAnchor( sal_uInt16 nDir )
+bool SwFEShell::MoveAnchor( SwMove nDir )
 {
     const SdrMarkList* pMrkList;
     if( !Imp()->GetDrawView() ||
@@ -320,17 +320,17 @@ bool SwFEShell::MoveAnchor( sal_uInt16 nDir )
             if( pOld->IsTxtFrm() )
             {
                 switch( nDir ) {
-                    case SW_MOVE_UP: nDir = SW_MOVE_LEFT; break;
-                    case SW_MOVE_DOWN: nDir = SW_MOVE_RIGHT; break;
-                    case SW_MOVE_LEFT: nDir = SW_MOVE_DOWN; break;
-                    case SW_MOVE_RIGHT: nDir = SW_MOVE_UP; break;
+                    case SwMove::UP: nDir = SwMove::LEFT; break;
+                    case SwMove::DOWN: nDir = SwMove::RIGHT; break;
+                    case SwMove::LEFT: nDir = SwMove::DOWN; break;
+                    case SwMove::RIGHT: nDir = SwMove::UP; break;
                 }
                 if( pOld->IsRightToLeft() )
                 {
-                    if( nDir == SW_MOVE_LEFT )
-                        nDir = SW_MOVE_RIGHT;
-                    else if( nDir == SW_MOVE_RIGHT )
-                        nDir = SW_MOVE_LEFT;
+                    if( nDir == SwMove::LEFT )
+                        nDir = SwMove::RIGHT;
+                    else if( nDir == SwMove::RIGHT )
+                        nDir = SwMove::LEFT;
                 }
             }
         }
@@ -338,9 +338,9 @@ bool SwFEShell::MoveAnchor( sal_uInt16 nDir )
             case FLY_AT_PAGE:
             {
                 OSL_ENSURE( pOld->IsPageFrm(), "Wrong anchor, page expected." );
-                if( SW_MOVE_UP == nDir )
+                if( SwMove::UP == nDir )
                     pNew = pOld->GetPrev();
-                else if( SW_MOVE_DOWN == nDir )
+                else if( SwMove::DOWN == nDir )
                     pNew = pOld->GetNext();
                 if( pNew && pNew != pOld )
                 {
@@ -352,12 +352,12 @@ bool SwFEShell::MoveAnchor( sal_uInt16 nDir )
             case FLY_AT_CHAR:
             {
                 OSL_ENSURE( pOld->IsCntntFrm(), "Wrong anchor, page expected." );
-                if( SW_MOVE_LEFT == nDir || SW_MOVE_RIGHT == nDir )
+                if( SwMove::LEFT == nDir || SwMove::RIGHT == nDir )
                 {
                     SwPosition *pPos = (SwPosition*)aAnch.GetCntntAnchor();
                     SwTxtNode* pTxtNd = ((SwTxtFrm*)pOld)->GetTxtNode();
                     const sal_Int32 nAct = pPos->nContent.GetIndex();
-                    if( SW_MOVE_LEFT == nDir )
+                    if( SwMove::LEFT == nDir )
                     {
                         bRet = true;
                         if( nAct )
@@ -365,7 +365,7 @@ bool SwFEShell::MoveAnchor( sal_uInt16 nDir )
                             pPos->nContent.Assign( pTxtNd, nAct-1 );
                         }
                         else
-                            nDir = SW_MOVE_UP;
+                            nDir = SwMove::UP;
                     }
                     else
                     {
@@ -377,16 +377,16 @@ bool SwFEShell::MoveAnchor( sal_uInt16 nDir )
                             pPos->nContent.Assign( pTxtNd, nAct+1 );
                         }
                         else
-                            nDir = SW_MOVE_DOWN;
+                            nDir = SwMove::DOWN;
                     }
                 }
             } // no break!
             case FLY_AT_PARA:
             {
                 OSL_ENSURE( pOld->IsCntntFrm(), "Wrong anchor, page expected." );
-                if( SW_MOVE_UP == nDir )
+                if( SwMove::UP == nDir )
                     pNew = pOld->FindPrev();
-                else if( SW_MOVE_DOWN == nDir )
+                else if( SwMove::DOWN == nDir )
                     pNew = pOld->FindNext();
                 if( pNew && pNew != pOld && pNew->IsCntntFrm() )
                 {
@@ -403,7 +403,7 @@ bool SwFEShell::MoveAnchor( sal_uInt16 nDir )
                     pPos->nContent.Assign( pTxtNd, nTmp );
                     bRet = true;
                 }
-                else if( SW_MOVE_UP == nDir || SW_MOVE_DOWN == nDir )
+                else if( SwMove::UP == nDir || SwMove::DOWN == nDir )
                     bRet = false;
                 break;
             }
@@ -445,28 +445,28 @@ bool SwFEShell::MoveAnchor( sal_uInt16 nDir )
                                             pTmp->Frm().Height()/2 );
                                 bool bAccept = false;
                                 switch( nDir ) {
-                                    case SW_MOVE_RIGHT:
+                                    case SwMove::RIGHT:
                                     {
                                         bAccept = LESS_X( aCenter, aNew, bOld )
                                              && ( !pNewFly ||
                                              LESS_X( aNew, aBest, false ) );
                                         break;
                                     }
-                                    case SW_MOVE_LEFT:
+                                    case SwMove::LEFT:
                                     {
                                         bAccept = LESS_X( aNew, aCenter, !bOld )
                                              && ( !pNewFly ||
                                              LESS_X( aBest, aNew, true ) );
                                         break;
                                     }
-                                    case SW_MOVE_UP:
+                                    case SwMove::UP:
                                     {
                                         bAccept = LESS_Y( aNew, aCenter, !bOld )
                                              && ( !pNewFly ||
                                              LESS_Y( aBest, aNew, true ) );
                                         break;
                                     }
-                                    case SW_MOVE_DOWN:
+                                    case SwMove::DOWN:
                                     {
                                         bAccept = LESS_Y( aCenter, aNew, bOld )
                                              && ( !pNewFly ||
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index f95e7f6..95d2bf3d 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -1187,14 +1187,14 @@ void SwEditWin::ChangeDrawing( sal_uInt8 nDir )
         MOVE_UP_HUGE == nDir ||
         MOVE_RIGHT_HUGE == nDir ||
         MOVE_DOWN_HUGE == nDir);
-    sal_uInt16 nAnchorDir = SW_MOVE_UP;
+    SwMove nAnchorDir = SwMove::UP;
     switch(nDir)
     {
         case MOVE_LEFT_SMALL:
         case MOVE_LEFT_HUGE:
         case MOVE_LEFT_BIG:
             nX = -1;
-            nAnchorDir = SW_MOVE_LEFT;
+            nAnchorDir = SwMove::LEFT;
         break;
         case MOVE_UP_SMALL:
         case MOVE_UP_HUGE:
@@ -1205,13 +1205,13 @@ void SwEditWin::ChangeDrawing( sal_uInt8 nDir )
         case MOVE_RIGHT_HUGE:
         case MOVE_RIGHT_BIG:
             nX = +1;
-            nAnchorDir = SW_MOVE_RIGHT;
+            nAnchorDir = SwMove::RIGHT;
         break;
         case MOVE_DOWN_SMALL:
         case MOVE_DOWN_HUGE:
         case MOVE_DOWN_BIG:
             nY = +1;
-            nAnchorDir = SW_MOVE_DOWN;
+            nAnchorDir = SwMove::DOWN;
         break;
     }
 


More information about the Libreoffice-commits mailing list