summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/edimp.hxx2
-rw-r--r--sw/inc/ring.hxx94
-rw-r--r--sw/qa/core/uwriter.cxx4
-rw-r--r--sw/source/core/doc/doccorr.cxx6
-rw-r--r--sw/source/core/edit/autofmt.cxx2
5 files changed, 60 insertions, 48 deletions
diff --git a/sw/inc/edimp.hxx b/sw/inc/edimp.hxx
index f3f985aa0f6d..a62f0d2fa58e 100644
--- a/sw/inc/edimp.hxx
+++ b/sw/inc/edimp.hxx
@@ -31,7 +31,7 @@ class SwNodeIndex;
#define PCURCRSR (static_cast<SwPaM *>(&__r))
#define FOREACHPAM_START(pCURSH) \
- BOOST_FOREACH(SwPaM& __r, (pCURSH)->rangeRing()) \
+ for(SwPaM& __r : (pCURSH)->GetRingContainer()) \
{
#define FOREACHPAM_END() }
diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx
index d58733f1459f..61181ebd4c07 100644
--- a/sw/inc/ring.hxx
+++ b/sw/inc/ring.hxx
@@ -27,9 +27,7 @@
namespace sw
{
- class Ring_node_traits;
- template <class T> class RingIterator;
-
+ template <class T> class RingContainer;
/**
* An intrusive container class double linking the contained nodes
* @example sw/qa/core/uwriter.cxx
@@ -68,8 +66,8 @@ namespace sw
*/
Ring( T* pRing );
public:
- typedef RingIterator<T> iterator;
- typedef RingIterator<const T> const_iterator;
+ typedef RingContainer<T> ring_container;
+ typedef RingContainer<const T> const_ring_container;
virtual ~Ring()
{ algo::unlink(static_cast< T* >(this)); };
/**
@@ -96,36 +94,13 @@ namespace sw
/** @return the previous item in the ring container */
T* GetPrev() const
{ return pPrev; }
- /**
- * iterator access
- * @code
- * for(Ring<SwPaM>::iterator ppRing = pPaM->beginRing(); ppRing != pPaM->endRing(); ++ppRing)
- * do_stuff(*ppRing);
- * @endcode
- * @TODO: unfortunately we cant name these STL-conforming, as some derived classes
- * also derive from other STL containers. This should be fixed though.
- * That should allow this to be used directly with C++11s for( : )
- * iteration statement.
- */
- iterator beginRing();
- iterator endRing();
- const_iterator beginRing() const;
- const_iterator endRing() const;
- /**
- * simplified iteration with BOOST_FOREACH (example for Ring<SwPaM>):
- * @code
- * BOOST_FOREACH(SwPaM& rPaM, pPaM->rangeRing())
- * do_stuff(rPaM);
- * @endcode
- */
- std::pair<iterator, iterator> rangeRing()
- { return std::make_pair(beginRing(), endRing()); }
- std::pair<const_iterator, const_iterator> rangeRing() const
- { return std::make_pair(beginRing(), endRing()); }
-
/** @return the number of elements in the container */
size_t size() const
{ return algo::count(static_cast< const T* >(this)); }
+ /** @return a stl-like container with begin()/end() for iteration */
+ ring_container GetRingContainer();
+ /** @return a stl-like container with begin()/end() for const iteration */
+ const_ring_container GetRingContainer() const;
};
template <class T>
@@ -161,8 +136,37 @@ namespace sw
std::swap(*(&pPrev), *(&pDestRing->pPrev));
}
+ template <class T> class RingIterator;
template <class T>
- class RingIterator : public boost::iterator_facade<
+ class RingContainer SAL_FINAL
+ {
+ T* m_pStart;
+
+ public:
+ RingContainer( T* pRing ) : m_pStart(pRing) {};
+ typedef RingIterator<T> iterator;
+ typedef RingIterator<const T> const_iterator;
+ /**
+ * iterator access
+ * @code
+ * for(Ring<SwPaM>::iterator ppRing = pPaM->beginRing(); ppRing != pPaM->endRing(); ++ppRing)
+ * do_stuff(*ppRing);
+ * @endcode
+ * @TODO: unfortunately we cant name these STL-conforming, as some derived classes
+ * also derive from other STL containers. This should be fixed though.
+ * That should allow this to be used directly with C++11s for( : )
+ * iteration statement.
+ */
+ iterator begin();
+ iterator end();
+ const_iterator begin() const;
+ const_iterator end() const;
+ ///** @return the number of elements in the container */
+ //size_t size() const
+ // { return algo::count(static_cast< const T* >(this)); }
+ };
+ template <class T>
+ class RingIterator SAL_FINAL : public boost::iterator_facade<
RingIterator<T>
, T
, boost::forward_traversal_tag
@@ -193,20 +197,28 @@ namespace sw
};
template <class T>
- inline typename Ring<T>::iterator Ring<T>::beginRing()
- { return Ring<T>::iterator(static_cast< T* >(this)); };
+ inline typename Ring<T>::ring_container Ring<T>::GetRingContainer()
+ { return Ring<T>::ring_container(static_cast< T* >(this)); };
+
+ template <class T>
+ inline typename Ring<T>::const_ring_container Ring<T>::GetRingContainer() const
+ { return Ring<T>::const_ring_container(static_cast< const T* >(this)); };
+
+ template <class T>
+ inline typename RingContainer<T>::iterator RingContainer<T>::begin()
+ { return RingContainer<T>::iterator(m_pStart); };
template <class T>
- inline typename Ring<T>::iterator Ring<T>::endRing()
- { return Ring<T>::iterator(static_cast< T* >(this), false); };
+ inline typename RingContainer<T>::iterator RingContainer<T>::end()
+ { return RingContainer<T>::iterator(m_pStart, false); };
template <class T>
- inline typename Ring<T>::const_iterator Ring<T>::beginRing() const
- { return Ring<T>::const_iterator(static_cast< const T* >(this)); };
+ inline typename RingContainer<T>::const_iterator RingContainer<T>::begin() const
+ { return RingContainer<T>::const_iterator(m_pStart); };
template <class T>
- inline typename Ring<T>::const_iterator Ring<T>::endRing() const
- { return Ring<T>::const_iterator(static_cast< const T* >(this), false); };
+ inline typename RingContainer<T>::const_iterator RingContainer<T>::end() const
+ { return RingContainer<T>::const_iterator(m_pStart, false); };
}
#endif
diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx
index 55a93909b056..584f3987c464 100644
--- a/sw/qa/core/uwriter.cxx
+++ b/sw/qa/core/uwriter.cxx
@@ -1317,14 +1317,14 @@ void SwDocTest::testIntrusiveRing()
CPPUNIT_ASSERT_EQUAL((*ppRing)->GetNext(), *ppNext);
CPPUNIT_ASSERT_EQUAL((*ppNext)->GetPrev(), *ppRing);
}
- BOOST_FOREACH(TestRing& r, aRing1.rangeRing())
+ for(TestRing& r: aRing1.GetRingContainer())
{
TestRing* pRing = &r;
CPPUNIT_ASSERT(pRing);
//pRing->debug();
}
const TestRing* pConstRing = &aRing1;
- BOOST_FOREACH(const TestRing& r, pConstRing->rangeRing()) // this should fail without r being const
+ for(const TestRing& r: pConstRing->GetRingContainer()) // this should fail without r being const
{
const TestRing* pRing = &r;
CPPUNIT_ASSERT(pRing);
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index 5dc2ca001f05..eaf11f6691ad 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -99,7 +99,7 @@ void PaMCorrAbs( const SwPaM& rRange,
if( pShell )
{
- BOOST_FOREACH(const SwViewShell& rShell, pShell->rangeRing())
+ for(const SwViewShell& rShell : pShell->GetRingContainer())
{
if(!rShell.IsA( TYPE( SwCrsrShell )))
continue;
@@ -249,7 +249,7 @@ void PaMCorrRel( const SwNodeIndex &rOldNode,
SwCrsrShell const* pShell = pDoc->GetEditShell();
if( pShell )
{
- BOOST_FOREACH(const SwViewShell& rShell, pShell->rangeRing())
+ for(const SwViewShell& rShell : pShell->GetRingContainer())
{
if(!rShell.IsA( TYPE( SwCrsrShell )))
continue;
@@ -262,7 +262,7 @@ void PaMCorrRel( const SwNodeIndex &rOldNode,
((_pStkCrsr = static_cast<SwPaM *>(_pStkCrsr->GetNext())) != pCrsrShell->GetStkCrsr()) );
SwPaM* pStartPaM = pCrsrShell->_GetCrsr();
- BOOST_FOREACH(SwPaM& rPaM, pStartPaM->rangeRing())
+ for(SwPaM& rPaM : pStartPaM->GetRingContainer())
{
lcl_PaMCorrRel1( &rPaM, pOldNode, aNewPos, nCntIdx);
}
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 93beffdb4306..132501fd1fef 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -2538,7 +2538,7 @@ void SwEditShell::AutoFormat( const SvxSwAutoFmtFlags* pAFlags )
// There are more than one or a selection is open
if( pCrsr->GetNext() != pCrsr || pCrsr->HasMark() )
{
- BOOST_FOREACH(SwPaM& rPaM, GetCrsr()->rangeRing())
+ for(SwPaM& rPaM : GetCrsr()->GetRingContainer())
{
if( rPaM.HasMark() )
{