diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2011-09-20 03:17:10 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2011-09-20 09:55:21 +0900 |
commit | 0aa547c18dee940d7e9726c85880790710d3ec76 (patch) | |
tree | d332fa0ad452142e8435df84fffb1c6841efa349 /sw/inc | |
parent | 2defcfa33e86150ac936cc8a9a8edb1dcb242b5b (diff) |
reduce duplicate code to one template
Diffstat (limited to 'sw/inc')
-rw-r--r-- | sw/inc/pam.hxx | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx index 9d839475dbd5..5be01df54692 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; |