[Libreoffice-commits] .: 2 commits - sw/inc sw/source

Takeshi Abe tabe at kemper.freedesktop.org
Mon Sep 19 18:08:49 PDT 2011


 sw/inc/pam.hxx                  |   47 +++++++++++++++++++--
 sw/source/core/crsr/pam.cxx     |   88 ----------------------------------------
 sw/source/core/undo/unredln.cxx |    2 
 3 files changed, 43 insertions(+), 94 deletions(-)

New commits:
commit 0aa547c18dee940d7e9726c85880790710d3ec76
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Tue Sep 20 03:17:10 2011 +0900

    reduce duplicate code to one template

diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 9d83947..5be01df 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -94,14 +94,51 @@ enum SwComparePosition {
     POS_COLLIDE_START,      // Pos1 start touches at Pos2 end.
     POS_COLLIDE_END         // Pos1 end touches at Pos2 start.
 };
-SwComparePosition ComparePosition(
-            const SwPosition& rStt1, const SwPosition& rEnd1,
-            const SwPosition& rStt2, const SwPosition& rEnd2 );
 
+template<typename T>
 SwComparePosition ComparePosition(
-            const unsigned long nStt1, const unsigned long nEnd1,
-            const unsigned long nStt2, const unsigned long nEnd2 );
+            const T& rStt1, const T& rEnd1,
+            const T& rStt2, const T& rEnd2 )
+{
+    SwComparePosition nRet;
+    if( rStt1 < rStt2 )
+    {
+        if( rEnd1 > rStt2 )
+        {
+            if( rEnd1 >= rEnd2 )
+                nRet = POS_OUTSIDE;
+            else
+                nRet = POS_OVERLAP_BEFORE;
 
+        }
+        else if( rEnd1 == rStt2 )
+            nRet = POS_COLLIDE_END;
+        else
+            nRet = POS_BEFORE;
+    }
+    else if( rEnd2 > rStt1 )
+    {
+        if( rEnd2 >= rEnd1 )
+        {
+            if( rEnd2 == rEnd1 && rStt2 == rStt1 )
+                nRet = POS_EQUAL;
+            else
+                nRet = POS_INSIDE;
+        }
+        else
+        {
+            if (rStt1 == rStt2)
+                nRet = POS_OUTSIDE;
+            else
+                nRet = POS_OVERLAP_BEHIND;
+        }
+    }
+    else if( rEnd2 == rStt1 )
+        nRet = POS_COLLIDE_START;
+    else
+        nRet = POS_BEHIND;
+    return nRet;
+}
 
 // SwPointAndMark / SwPaM
 struct SwMoveFnCollection;
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index 5d5f39d..a229fc5 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -165,94 +165,6 @@ SwDoc * SwPosition::GetDoc() const
     return nNode.GetNode().GetDoc();
 }
 
-SwComparePosition ComparePosition(
-            const SwPosition& rStt1, const SwPosition& rEnd1,
-            const SwPosition& rStt2, const SwPosition& rEnd2 )
-{
-    SwComparePosition nRet;
-    if( rStt1 < rStt2 )
-    {
-        if( rEnd1 > rStt2 )
-        {
-            if( rEnd1 >= rEnd2 )
-                nRet = POS_OUTSIDE;
-            else
-                nRet = POS_OVERLAP_BEFORE;
-
-        }
-        else if( rEnd1 == rStt2 )
-            nRet = POS_COLLIDE_END;
-        else
-            nRet = POS_BEFORE;
-    }
-    else if( rEnd2 > rStt1 )
-    {
-        if( rEnd2 >= rEnd1 )
-        {
-            if( rEnd2 == rEnd1 && rStt2 == rStt1 )
-                nRet = POS_EQUAL;
-            else
-                nRet = POS_INSIDE;
-        }
-        else
-        {
-            if (rStt1 == rStt2)
-                nRet = POS_OUTSIDE;
-            else
-                nRet = POS_OVERLAP_BEHIND;
-        }
-    }
-    else if( rEnd2 == rStt1 )
-        nRet = POS_COLLIDE_START;
-    else
-        nRet = POS_BEHIND;
-    return nRet;
-}
-
-SwComparePosition ComparePosition(
-            const unsigned long nStt1, const unsigned long nEnd1,
-            const unsigned long nStt2, const unsigned long nEnd2 )
-{
-    SwComparePosition nRet;
-    if( nStt1 < nStt2 )
-    {
-        if( nEnd1 > nStt2 )
-        {
-            if( nEnd1 >= nEnd2 )
-                nRet = POS_OUTSIDE;
-            else
-                nRet = POS_OVERLAP_BEFORE;
-
-        }
-        else if( nEnd1 == nStt2 )
-            nRet = POS_COLLIDE_END;
-        else
-            nRet = POS_BEFORE;
-    }
-    else if( nEnd2 > nStt1 )
-    {
-        if( nEnd2 >= nEnd1 )
-        {
-            if( nEnd2 == nEnd1 && nStt2 == nStt1 )
-                nRet = POS_EQUAL;
-            else
-                nRet = POS_INSIDE;
-        }
-        else
-        {
-            if (nStt1 == nStt2)
-                nRet = POS_OUTSIDE;
-            else
-                nRet = POS_OVERLAP_BEHIND;
-        }
-    }
-    else if( nEnd2 == nStt1 )
-        nRet = POS_COLLIDE_START;
-    else
-        nRet = POS_BEHIND;
-    return nRet;
-}
-
 
 enum CHKSECTION { Chk_Both, Chk_One, Chk_None };
 
commit 2defcfa33e86150ac936cc8a9a8edb1dcb242b5b
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Mon Sep 19 11:34:37 2011 +0900

    removed an assignment in no use

diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx
index c0879af..bbb75dd 100644
--- a/sw/source/core/undo/unredln.cxx
+++ b/sw/source/core/undo/unredln.cxx
@@ -162,7 +162,7 @@ void SwUndoRedline::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
 // SwUndoRedlineDelete ///////////////////////////////////////////////////
 
 SwUndoRedlineDelete::SwUndoRedlineDelete( const SwPaM& rRange, SwUndoId nUsrId )
-    : SwUndoRedline( nUsrId = (nUsrId ? nUsrId : UNDO_DELETE), rRange ),
+    : SwUndoRedline( nUsrId ? nUsrId : UNDO_DELETE, rRange ),
     bCanGroup( sal_False ), bIsDelim( sal_False ), bIsBackspace( sal_False )
 {
     const SwTxtNode* pTNd;


More information about the Libreoffice-commits mailing list