summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2014-12-05 05:14:07 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2014-12-05 16:10:35 +0100
commit04adb4de787086c59813dce65dae8d7b94e900ca (patch)
tree633c1ddb3acb3fb0e6ce3fe1e5c79f3d5ec91f9e /sw
parentdd21dac3ea6f0d78061d602c99c7d952a29661ad (diff)
move Ring<>::MoveRingTo to RingContainer<>::merge
Change-Id: I864c9768ffd84c8cdee986cafd205ef2943c73e5
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/ring.hxx28
-rw-r--r--sw/source/core/crsr/findattr.cxx2
-rw-r--r--sw/source/core/crsr/findtxt.cxx2
-rw-r--r--sw/source/core/crsr/swcrsr.cxx6
-rw-r--r--sw/source/core/edit/acorrect.cxx4
-rw-r--r--sw/source/core/edit/autofmt.cxx2
6 files changed, 23 insertions, 21 deletions
diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index f83ce3e622a6..bd5c6348475d 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -41,7 +41,7 @@ namespace sw
public:
typedef typename std::add_const<value_type>::type const_value_type;
typedef RingContainer<value_type> ring_container;
- typedef RingContainer< const_value_type > const_ring_container;
+ typedef RingContainer<const_value_type> const_ring_container;
virtual ~Ring()
{ algo::unlink(static_cast< value_type* >(this)); };
/**
@@ -53,18 +53,6 @@ namespace sw
* @param pDestRing the container to add this item to
*/
void MoveTo( value_type* pDestRing );
- /**
- * Merges two ring containers. All item from both ring containers will
- * be in the same ring container in the end.
- * Note: value_typehe items of this ring container will be inserted just before
- * item pDestRing
- * @param pDestRing the container to merge this container with
- */
- void MoveRingTo( value_type* pDestRing )
- {
- std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext));
- std::swap(*(&pPrev), *(&pDestRing->pPrev));
- }
/** @return a stl-like container with begin()/end() for iteration */
ring_container GetRingContainer();
/** @return a stl-like container with begin()/end() for const iteration */
@@ -110,6 +98,8 @@ namespace sw
static node_ptr get_previous(const_node_ptr n) { return const_cast<node_ptr>(static_cast<const_node_ptr>(n))->GetPrevInRing(); };
static void set_previous(node_ptr n, node_ptr previous) { n->pPrev = previous; };
};
+ friend ring_container;
+ friend const_ring_container;
friend typename ring_container::iterator;
friend typename ring_container::const_iterator;
friend typename const_ring_container::iterator;
@@ -175,6 +165,18 @@ namespace sw
/** @return the number of elements in the container */
size_t size() const
{ return std::distance(begin(), end()); }
+ /**
+ * Merges two ring containers. All item from both ring containers will
+ * be in the same ring container in the end.
+ * Note: value_typehe items of this ring container will be inserted just before
+ * item pDestRing
+ * @param pDestRing the container to merge this container with
+ */
+ void merge( RingContainer< value_type > aDestRing )
+ {
+ std::swap(*(&m_pStart->pPrev->pNext), *(&aDestRing.m_pStart->pPrev->pNext));
+ std::swap(*(&m_pStart->pPrev), *(&aDestRing.m_pStart->pPrev));
+ }
};
template <typename value_type>
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index ff341f8c0d23..abf042c2dc43 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -1148,7 +1148,7 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion,
if( bRegExp )
{
pPrevRing = const_cast< SwPaM* >(pRegion)->GetPrev();
- const_cast< SwPaM* >(pRegion)->MoveRingTo( &rCursor );
+ const_cast< SwPaM* >(pRegion)->GetRingContainer().merge( rCursor.GetRingContainer() );
}
boost::scoped_ptr<OUString> pRepl( (bRegExp) ?
diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx
index 40af2a84a7a9..ea5c6ada3c05 100644
--- a/sw/source/core/crsr/findtxt.cxx
+++ b/sw/source/core/crsr/findtxt.cxx
@@ -579,7 +579,7 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove,
if( bRegExp )
{
pPrev = const_cast<SwPaM*>(pRegion)->GetPrev();
- const_cast<SwPaM*>(pRegion)->MoveRingTo( &rCursor );
+ const_cast<SwPaM*>(pRegion)->GetRingContainer().merge( rCursor.GetRingContainer() );
}
boost::scoped_ptr<OUString> pRepl( (bRegExp)
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index e726efcd58d4..347ae3637338 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -953,7 +953,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas,
*GetPoint() = *pFndRing->GetPoint();
SetMark();
*GetMark() = *pFndRing->GetMark();
- pFndRing->MoveRingTo( this );
+ pFndRing->GetRingContainer().merge( GetRingContainer() );
delete pFndRing;
}
else if( FND_IN_OTHER & eFndRngs )
@@ -1011,7 +1011,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas,
*GetPoint() = *pFndRing->GetPoint();
SetMark();
*GetMark() = *pFndRing->GetMark();
- pFndRing->MoveRingTo( this );
+ pFndRing->GetRingContainer().merge( GetRingContainer() );
}
delete pFndRing;
}
@@ -1051,7 +1051,7 @@ sal_uLong SwCursor::FindAll( SwFindParas& rParas,
*GetPoint() = *pFndRing->GetPoint();
SetMark();
*GetMark() = *pFndRing->GetMark();
- pFndRing->MoveRingTo( this );
+ pFndRing->GetRingContainer().merge( GetRingContainer() );
delete pFndRing;
}
else
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index 440510ead094..216a033799a9 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -59,8 +59,8 @@ _PaMIntoCrsrShellRing::_PaMIntoCrsrShellRing( SwCrsrShell& rCSh,
pPrevDelPam = rDelPam.GetPrev();
pPrevCrsr = rCrsr.GetPrev();
- rDelPam.MoveRingTo( pShCrsr );
- rCrsr.MoveRingTo( pShCrsr );
+ rDelPam.GetRingContainer().merge( pShCrsr->GetRingContainer() );
+ rCrsr.GetRingContainer().merge( pShCrsr->GetRingContainer() );
}
_PaMIntoCrsrShellRing::~_PaMIntoCrsrShellRing()
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 4326f7141114..905858e0f541 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -1089,7 +1089,7 @@ void SwAutoFormat::DeleteSel( SwPaM& rDelPam )
SwPaM aTmp( *m_pCurTxtNd, 0, pShCrsr );
SwPaM* pPrev = rDelPam.GetPrev();
- rDelPam.MoveRingTo( pShCrsr );
+ rDelPam.GetRingContainer().merge( pShCrsr->GetRingContainer() );
m_pEditShell->DeleteSel( rDelPam );