From ff151e28334a8478fc073d292d1233f99ad45fd2 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Thu, 24 Nov 2011 00:52:10 +0100 Subject: SwIndex: style cleanup --- sw/inc/index.hxx | 121 +++++++------ sw/source/core/bastyp/index.cxx | 377 ++++++++++++++++++++-------------------- 2 files changed, 255 insertions(+), 243 deletions(-) diff --git a/sw/inc/index.hxx b/sw/inc/index.hxx index a20ad4973a27..b1f73f761578 100644 --- a/sw/inc/index.hxx +++ b/sw/inc/index.hxx @@ -25,8 +25,8 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _INDEX_HXX -#define _INDEX_HXX +#ifndef SW_INDEX_HXX +#define SW_INDEX_HXX #include @@ -36,9 +36,9 @@ #include // for xub_StrLen #include +// Maximum index in IndexArray (for testing on overflows). #define INVALID_INDEX STRING_NOTFOUND -// Maximal count of indices in IndexArray (for testing on overflows). class SwIndex; class SwIndexReg; struct SwPosition; @@ -51,11 +51,14 @@ struct SwPosition; class SW_DLLPUBLIC SwIndex { +private: friend class SwIndexReg; - xub_StrLen nIndex; - SwIndexReg* pArray; - SwIndex *pNext, *pPrev; + xub_StrLen m_nIndex; + SwIndexReg * m_pIndexReg; + // doubly linked list of Indexes registered at m_pIndexReg + SwIndex * m_pNext; + SwIndex * m_pPrev; SwIndex& ChgValue( const SwIndex& rIdx, xub_StrLen nNewValue ); void Remove(); @@ -63,46 +66,53 @@ class SW_DLLPUBLIC SwIndex public: explicit SwIndex(SwIndexReg *const pReg, xub_StrLen const nIdx = 0); SwIndex( const SwIndex & ); - SwIndex( const SwIndex &, short nDiff ); + SwIndex( const SwIndex &, xub_StrLen const nDiff ); ~SwIndex() { Remove(); } + INLINE SwIndex& operator=( xub_StrLen const ); + SwIndex& operator=( const SwIndex & ); + INLINE xub_StrLen operator++(); INLINE xub_StrLen operator--(); INLINE xub_StrLen operator++(int); INLINE xub_StrLen operator--(int); - INLINE xub_StrLen operator+=( xub_StrLen ); - INLINE xub_StrLen operator-=( xub_StrLen ); + INLINE xub_StrLen operator+=( xub_StrLen const ); + INLINE xub_StrLen operator-=( xub_StrLen const ); INLINE xub_StrLen operator+=( const SwIndex& ); INLINE xub_StrLen operator-=( const SwIndex& ); - INLINE sal_Bool operator<( const SwIndex& ) const; - INLINE sal_Bool operator<=( const SwIndex& ) const; - INLINE sal_Bool operator>( const SwIndex& ) const; - INLINE sal_Bool operator>=( const SwIndex& ) const; - sal_Bool operator==( const SwIndex& rSwIndex ) const - { return (nIndex == rSwIndex.nIndex) && (pArray == rSwIndex.pArray); } + INLINE bool operator< ( const SwIndex& ) const; + INLINE bool operator<=( const SwIndex& ) const; + INLINE bool operator> ( const SwIndex& ) const; + INLINE bool operator>=( const SwIndex& ) const; - sal_Bool operator!=( const SwIndex& rSwIndex ) const - { return (nIndex != rSwIndex.nIndex) || (pArray != rSwIndex.pArray); } + bool operator< ( xub_StrLen const nVal ) const { return m_nIndex < nVal; } + bool operator<=( xub_StrLen const nVal ) const { return m_nIndex <= nVal; } + bool operator> ( xub_StrLen const nVal ) const { return m_nIndex > nVal; } + bool operator>=( xub_StrLen const nVal ) const { return m_nIndex >= nVal; } + bool operator==( xub_StrLen const nVal ) const { return m_nIndex == nVal; } + bool operator!=( xub_StrLen const nVal ) const { return m_nIndex != nVal; } - sal_Bool operator<( xub_StrLen nWert ) const { return nIndex < nWert; } - sal_Bool operator<=( xub_StrLen nWert ) const { return nIndex <= nWert; } - sal_Bool operator>( xub_StrLen nWert ) const { return nIndex > nWert; } - sal_Bool operator>=( xub_StrLen nWert ) const { return nIndex >= nWert; } - sal_Bool operator==( xub_StrLen nWert ) const { return nIndex == nWert; } - sal_Bool operator!=( xub_StrLen nWert ) const { return nIndex != nWert; } + bool operator==( const SwIndex& rSwIndex ) const + { + return (m_nIndex == rSwIndex.m_nIndex) + && (m_pIndexReg == rSwIndex.m_pIndexReg); + } - INLINE SwIndex& operator=( xub_StrLen ); - SwIndex& operator=( const SwIndex & ); + bool operator!=( const SwIndex& rSwIndex ) const + { + return (m_nIndex != rSwIndex.m_nIndex) + || (m_pIndexReg != rSwIndex.m_pIndexReg); + } - xub_StrLen GetIndex() const { return nIndex; } + xub_StrLen GetIndex() const { return m_nIndex; } // Assignments without creating a temporary object. SwIndex &Assign(SwIndexReg *,xub_StrLen); // Returns pointer to IndexArray (for RTTI at SwIndexReg). - const SwIndexReg* GetIdxReg() const { return pArray; } + const SwIndexReg* GetIdxReg() const { return m_pIndexReg; } }; #undef INLINE @@ -112,7 +122,8 @@ class SwIndexReg friend class SwIndex; friend bool lcl_PosOk(const SwPosition & aPos); - const SwIndex *pFirst, *pLast, *pMiddle; + const SwIndex * m_pFirst; + const SwIndex * m_pLast; protected: virtual void Update( SwIndex const & rPos, const xub_StrLen nChangeLen, @@ -120,10 +131,10 @@ protected: void ChkArr(); - sal_Bool HasAnyIndex() const { return 0 != pFirst; } + bool HasAnyIndex() const { return 0 != m_pFirst; } public: - SwIndexReg(); + explicit SwIndexReg(); virtual ~SwIndexReg(); // rtti, abgeleitete moegens gleichtun oder nicht. Wenn sie es gleichtun @@ -141,62 +152,64 @@ struct EmptyIndexArray: rtl::Static< SwIndexReg, EmptyIndexArray > {}; inline xub_StrLen SwIndex::operator++() { - return ChgValue( *this, nIndex+1 ).nIndex; + return ChgValue( *this, m_nIndex+1 ).m_nIndex; } inline xub_StrLen SwIndex::operator--() { - return ChgValue( *this, nIndex-1 ).nIndex; + return ChgValue( *this, m_nIndex-1 ).m_nIndex; } inline xub_StrLen SwIndex::operator++(int) { - xub_StrLen nOldIndex = nIndex; - ChgValue( *this, nIndex+1 ); + xub_StrLen const nOldIndex = m_nIndex; + ChgValue( *this, m_nIndex+1 ); return nOldIndex; } inline xub_StrLen SwIndex::operator--(int) { - xub_StrLen nOldIndex = nIndex; - ChgValue( *this, nIndex-1 ); + xub_StrLen const nOldIndex = m_nIndex; + ChgValue( *this, m_nIndex-1 ); return nOldIndex; } -inline xub_StrLen SwIndex::operator+=( xub_StrLen nWert ) +inline xub_StrLen SwIndex::operator+=( xub_StrLen const nVal ) { - return ChgValue( *this, nIndex + nWert ).nIndex; + return ChgValue( *this, m_nIndex + nVal ).m_nIndex; } -inline xub_StrLen SwIndex::operator-=( xub_StrLen nWert ) +inline xub_StrLen SwIndex::operator-=( xub_StrLen const nVal ) { - return ChgValue( *this, nIndex - nWert ).nIndex; + return ChgValue( *this, m_nIndex - nVal ).m_nIndex; } -inline xub_StrLen SwIndex::operator+=( const SwIndex& rIndex ) +inline xub_StrLen SwIndex::operator+=( const SwIndex& rIndex ) { - return ChgValue( *this, nIndex + rIndex.nIndex ).nIndex; + return ChgValue( *this, m_nIndex + rIndex.m_nIndex ).m_nIndex; } inline xub_StrLen SwIndex::operator-=( const SwIndex& rIndex ) { - return ChgValue( *this, nIndex - rIndex.nIndex ).nIndex; + return ChgValue( *this, m_nIndex - rIndex.m_nIndex ).m_nIndex; } -inline sal_Bool SwIndex::operator<( const SwIndex& rIndex ) const +inline bool SwIndex::operator< ( const SwIndex& rIndex ) const { - return nIndex < rIndex.nIndex; + return m_nIndex < rIndex.m_nIndex; } -inline sal_Bool SwIndex::operator<=( const SwIndex& rIndex ) const +inline bool SwIndex::operator<=( const SwIndex& rIndex ) const { - return nIndex <= rIndex.nIndex; + return m_nIndex <= rIndex.m_nIndex; } -inline sal_Bool SwIndex::operator>( const SwIndex& rIndex ) const +inline bool SwIndex::operator> ( const SwIndex& rIndex ) const { - return nIndex > rIndex.nIndex; + return m_nIndex > rIndex.m_nIndex; } -inline sal_Bool SwIndex::operator>=( const SwIndex& rIndex ) const +inline bool SwIndex::operator>=( const SwIndex& rIndex ) const { - return nIndex >= rIndex.nIndex; + return m_nIndex >= rIndex.m_nIndex; } -inline SwIndex& SwIndex::operator=( xub_StrLen nWert ) +inline SwIndex& SwIndex::operator= ( xub_StrLen const nVal ) { - if( nIndex != nWert ) - ChgValue( *this, nWert ); + if (m_nIndex != nVal) + { + ChgValue( *this, nVal ); + } return *this; } diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx index 95e7df170ffc..fc795c4eb55a 100644 --- a/sw/source/core/bastyp/index.cxx +++ b/sw/source/core/bastyp/index.cxx @@ -29,7 +29,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - #include // fuer qsort #include @@ -39,254 +38,263 @@ TYPEINIT0(SwIndexReg); // rtti -SwIndex::SwIndex(SwIndexReg *const pArr, xub_StrLen const nIdx) - : nIndex( nIdx ), pArray( pArr ), pNext( 0 ), pPrev( 0 ) +SwIndex::SwIndex(SwIndexReg *const pReg, xub_StrLen const nIdx) + : m_nIndex( nIdx ) + , m_pIndexReg( pReg ) + , m_pNext( 0 ) + , m_pPrev( 0 ) { - if( !pArray ) + if (!m_pIndexReg) { - pArray = &EmptyIndexArray::get(); - nIndex = 0; // steht immer auf 0 !!! + m_pIndexReg = &EmptyIndexArray::get(); + m_nIndex = 0; // always 0 if no IndexReg } - if( !pArray->pFirst || !pArray->pLast ) // 1. Index ?? - pArray->pFirst = pArray->pLast = this; - else if( nIdx > ((pArray->pLast->nIndex - pArray->pFirst->nIndex) / 2) ) - ChgValue( *pArray->pLast, nIdx ); + if (!m_pIndexReg->m_pFirst || !m_pIndexReg->m_pLast) // first Index? + { + m_pIndexReg->m_pFirst = m_pIndexReg->m_pLast = this; + } + else if (nIdx > ((m_pIndexReg->m_pLast->m_nIndex + - m_pIndexReg->m_pFirst->m_nIndex) / 2)) + { + ChgValue( *m_pIndexReg->m_pLast, nIdx ); + } else - ChgValue( *pArray->pFirst, nIdx ); + { + ChgValue( *m_pIndexReg->m_pFirst, nIdx ); + } } - -SwIndex::SwIndex( const SwIndex& rIdx, short nIdx ) - : pArray( rIdx.pArray ), pNext( 0 ), pPrev( 0 ) +SwIndex::SwIndex( const SwIndex& rIdx, xub_StrLen const nDiff ) + : m_pIndexReg( rIdx.m_pIndexReg ) + , m_pNext( 0 ) + , m_pPrev( 0 ) { - ChgValue( rIdx, rIdx.nIndex + nIdx ); + ChgValue( rIdx, rIdx.m_nIndex + nDiff ); } - SwIndex::SwIndex( const SwIndex& rIdx ) - : nIndex( rIdx.nIndex ), pArray( rIdx.pArray ), pNext( 0 ), pPrev( 0 ) + : m_nIndex( rIdx.m_nIndex ) + , m_pIndexReg( rIdx.m_pIndexReg ) + , m_pNext( 0 ) + , m_pPrev( 0 ) { - ChgValue( rIdx, rIdx.nIndex ); + ChgValue( rIdx, rIdx.m_nIndex ); } - SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, xub_StrLen nNewValue ) { - SwIndex* pFnd = (SwIndex*)&rIdx; - if( rIdx.nIndex > nNewValue ) // nach vorne versuchen + SwIndex* pFnd = const_cast(&rIdx); + if (rIdx.m_nIndex > nNewValue) // move forwards { SwIndex* pPrv; - while( 0 != ( pPrv = pFnd->pPrev ) && pPrv->nIndex > nNewValue ) + while ((0 != (pPrv = pFnd->m_pPrev)) && (pPrv->m_nIndex > nNewValue)) pFnd = pPrv; if( pFnd != this ) { - // an alter Position ausketten - // erstmal an alter Position ausketten - if( pPrev ) - pPrev->pNext = pNext; - else if( pArray->pFirst == this ) - pArray->pFirst = pNext; - - if( pNext ) - pNext->pPrev = pPrev; - else if( pArray->pLast == this ) - pArray->pLast = pPrev; - - pNext = pFnd; - pPrev = pFnd->pPrev; - if( pPrev ) - pPrev->pNext = this; + // remove from list at old position + if (m_pPrev) + m_pPrev->m_pNext = m_pNext; + else if (m_pIndexReg->m_pFirst == this) + m_pIndexReg->m_pFirst = m_pNext; + + if (m_pNext) + m_pNext->m_pPrev = m_pPrev; + else if (m_pIndexReg->m_pLast == this) + m_pIndexReg->m_pLast = m_pPrev; + + m_pNext = pFnd; + m_pPrev = pFnd->m_pPrev; + if (m_pPrev) + m_pPrev->m_pNext = this; else - pArray->pFirst = this; - pFnd->pPrev = this; + m_pIndexReg->m_pFirst = this; + pFnd->m_pPrev = this; } } - else if( rIdx.nIndex < nNewValue ) + else if (rIdx.m_nIndex < nNewValue) { SwIndex* pNxt; - while( 0 != ( pNxt = pFnd->pNext ) && pNxt->nIndex < nNewValue ) + while ((0 != (pNxt = pFnd->m_pNext)) && (pNxt->m_nIndex < nNewValue)) pFnd = pNxt; if( pFnd != this ) { - // erstmal an alter Position ausketten - if( pPrev ) - pPrev->pNext = pNext; - else if( pArray->pFirst == this ) - pArray->pFirst = pNext; - - if( pNext ) - pNext->pPrev = pPrev; - else if( pArray->pLast == this ) - pArray->pLast = pPrev; - - pPrev = pFnd; - pNext = pFnd->pNext; - if( pNext ) - pNext->pPrev = this; + // remove from list at old position + if (m_pPrev) + m_pPrev->m_pNext = m_pNext; + else if (m_pIndexReg->m_pFirst == this) + m_pIndexReg->m_pFirst = m_pNext; + + if (m_pNext) + m_pNext->m_pPrev = m_pPrev; + else if (m_pIndexReg->m_pLast == this) + m_pIndexReg->m_pLast = m_pPrev; + + m_pPrev = pFnd; + m_pNext = pFnd->m_pNext; + if (m_pNext) + m_pNext->m_pPrev = this; else - pArray->pLast = this; - pFnd->pNext = this; + m_pIndexReg->m_pLast = this; + pFnd->m_pNext = this; } } else if( pFnd != this ) { - // erstmal an alter Position ausketten - if( pPrev ) - pPrev->pNext = pNext; - else if( pArray->pFirst == this ) - pArray->pFirst = pNext; - - if( pNext ) - pNext->pPrev = pPrev; - else if( pArray->pLast == this ) - pArray->pLast = pPrev; - - pPrev = (SwIndex*)&rIdx; - pNext = rIdx.pNext; - pPrev->pNext = this; - - if( !pNext ) // im IndexArray als letzes - pArray->pLast = this; + // remove from list at old position + if (m_pPrev) + m_pPrev->m_pNext = m_pNext; + else if (m_pIndexReg->m_pFirst == this) + m_pIndexReg->m_pFirst = m_pNext; + + if (m_pNext) + m_pNext->m_pPrev = m_pPrev; + else if (m_pIndexReg->m_pLast == this) + m_pIndexReg->m_pLast = m_pPrev; + + m_pPrev = const_cast(&rIdx); + m_pNext = rIdx.m_pNext; + m_pPrev->m_pNext = this; + + if (!m_pNext) // last in the list + m_pIndexReg->m_pLast = this; else - pNext->pPrev = this; + m_pNext->m_pPrev = this; } - pArray = rIdx.pArray; + m_pIndexReg = rIdx.m_pIndexReg; - if( pArray->pFirst == pNext ) - pArray->pFirst = this; - if( pArray->pLast == pPrev ) - pArray->pLast = this; + if (m_pIndexReg->m_pFirst == m_pNext) + m_pIndexReg->m_pFirst = this; + if (m_pIndexReg->m_pLast == m_pPrev) + m_pIndexReg->m_pLast = this; - nIndex = nNewValue; - - return *this; } + m_nIndex = nNewValue; + return *this; +} void SwIndex::Remove() { - if( !pPrev ) - pArray->pFirst = pNext; + if (!m_pPrev) + m_pIndexReg->m_pFirst = m_pNext; else - pPrev->pNext = pNext; + m_pPrev->m_pNext = m_pNext; - if( !pNext ) - pArray->pLast = pPrev; + if (!m_pNext) + m_pIndexReg->m_pLast = m_pPrev; else - pNext->pPrev = pPrev; + m_pNext->m_pPrev = m_pPrev; } /************************************************************************* |* SwIndex & SwIndex::operator=( const SwIndex & aSwIndex ) *************************************************************************/ - - SwIndex& SwIndex::operator=( const SwIndex& rIdx ) { - int bEqual; - if( rIdx.pArray != pArray ) // im alten abmelden !! + bool bEqual; + if (rIdx.m_pIndexReg != m_pIndexReg) // im alten abmelden !! { Remove(); - pArray = rIdx.pArray; - pNext = pPrev = 0; + m_pIndexReg = rIdx.m_pIndexReg; + m_pNext = m_pPrev = 0; bEqual = sal_False; } else - bEqual = rIdx.nIndex == nIndex; + bEqual = rIdx.m_nIndex == m_nIndex; if( !bEqual ) - ChgValue( rIdx, rIdx.nIndex ); + ChgValue( rIdx, rIdx.m_nIndex ); return *this; } /************************************************************************* |* SwIndex &SwIndex::Assign *************************************************************************/ - - SwIndex& SwIndex::Assign( SwIndexReg* pArr, xub_StrLen nIdx ) { if( !pArr ) { pArr = &EmptyIndexArray::get(); - nIdx = 0; // steht immer auf 0 !!! + nIdx = 0; // always 0 if no IndexReg } - if( pArr != pArray ) // im alten abmelden !! + if (pArr != m_pIndexReg) // unregister! { Remove(); - pArray = pArr; - pNext = pPrev = 0; - if( !pArr->pFirst ) // 1. Index ?? + m_pIndexReg = pArr; + m_pNext = m_pPrev = 0; + if (!pArr->m_pFirst) // first index? + { + pArr->m_pFirst = pArr->m_pLast = this; + m_nIndex = nIdx; + } + else if (pArr->m_pLast && (nIdx > ((pArr->m_pLast->m_nIndex + - pArr->m_pFirst->m_nIndex) / 2))) { - pArr->pFirst = pArr->pLast = this; - nIndex = nIdx; + ChgValue( *pArr->m_pLast, nIdx ); } - else if( pArr->pLast && (nIdx > ((pArr->pLast->nIndex - pArr->pFirst->nIndex) / 2)) ) - ChgValue( *pArr->pLast, nIdx ); else - ChgValue( *pArr->pFirst, nIdx ); + { + ChgValue( *pArr->m_pFirst, nIdx ); + } } - else if( nIndex != nIdx ) + else if (m_nIndex != nIdx) ChgValue( *this, nIdx ); return *this; } +// SwIndexReg /////////////////////////////////////////////////////// SwIndexReg::SwIndexReg() - : pFirst( 0 ), pLast( 0 ) + : m_pFirst( 0 ), m_pLast( 0 ) { } - - SwIndexReg::~SwIndexReg() { - OSL_ENSURE( !pFirst || !pLast, "There are still indices registered" ); + OSL_ENSURE( !m_pFirst || !m_pLast, "There are still indices registered" ); } - - void SwIndexReg::Update( SwIndex const & rIdx, const xub_StrLen nDiff, const bool bNeg, const bool /* argument is only used in derived class*/ ) { SwIndex* pStt = const_cast(&rIdx); - xub_StrLen nNewVal = rIdx.nIndex; + xub_StrLen nNewVal = rIdx.m_nIndex; if( bNeg ) { xub_StrLen nLast = rIdx.GetIndex() + nDiff; - while( pStt && pStt->nIndex == nNewVal ) + while (pStt && pStt->m_nIndex == nNewVal) { - pStt->nIndex = nNewVal; - pStt = pStt->pPrev; + pStt->m_nIndex = nNewVal; + pStt = pStt->m_pPrev; } - pStt = rIdx.pNext; - while( pStt && pStt->nIndex >= nNewVal && - pStt->nIndex <= nLast ) + pStt = rIdx.m_pNext; + while (pStt && pStt->m_nIndex >= nNewVal + && pStt->m_nIndex <= nLast) { - pStt->nIndex = nNewVal; - pStt = pStt->pNext; + pStt->m_nIndex = nNewVal; + pStt = pStt->m_pNext; } while( pStt ) { - pStt->nIndex = pStt->nIndex - nDiff; - pStt = pStt->pNext; + pStt->m_nIndex = pStt->m_nIndex - nDiff; + pStt = pStt->m_pNext; } } else { - while( pStt && pStt->nIndex == nNewVal ) + while (pStt && pStt->m_nIndex == nNewVal) { - pStt->nIndex = pStt->nIndex + nDiff; - pStt = pStt->pPrev; + pStt->m_nIndex = pStt->m_nIndex + nDiff; + pStt = pStt->m_pPrev; } - pStt = rIdx.pNext; + pStt = rIdx.m_pNext; while( pStt ) { - pStt->nIndex = pStt->nIndex + nDiff; - pStt = pStt->pNext; + pStt->m_nIndex = pStt->m_nIndex + nDiff; + pStt = pStt->m_pNext; } } } @@ -298,132 +306,122 @@ void SwIndexReg::Update( SwIndex const & rIdx, const xub_StrLen nDiff, *************************************************************************/ xub_StrLen SwIndex::operator++(int) { - OSL_ASSERT( nIndex < INVALID_INDEX ); + OSL_ASSERT( m_nIndex < INVALID_INDEX ); - xub_StrLen nOldIndex = nIndex; - ChgValue( *this, nIndex+1 ); + xub_StrLen nOldIndex = m_nIndex; + ChgValue( *this, m_nIndex+1 ); return nOldIndex; } - xub_StrLen SwIndex::operator++() { - OSL_ASSERT( nIndex < INVALID_INDEX ); + OSL_ASSERT( m_nIndex < INVALID_INDEX ); - ChgValue( *this, nIndex+1 ); - return nIndex; + ChgValue( *this, m_nIndex+1 ); + return m_nIndex; } /************************************************************************* |* SwIndex::operator--() *************************************************************************/ - - xub_StrLen SwIndex::operator--(int) { - OSL_ASSERT( nIndex ); + OSL_ASSERT( m_nIndex ); - xub_StrLen nOldIndex = nIndex; - ChgValue( *this, nIndex-1 ); + xub_StrLen nOldIndex = m_nIndex; + ChgValue( *this, m_nIndex-1 ); return nOldIndex; } - xub_StrLen SwIndex::operator--() { - OSL_ASSERT( nIndex ); - return ChgValue( *this, nIndex-1 ).nIndex; + OSL_ASSERT( m_nIndex ); + return ChgValue( *this, m_nIndex-1 ).m_nIndex; } /************************************************************************* |* SwIndex::operator+=( xub_StrLen ) *************************************************************************/ - -xub_StrLen SwIndex::operator+=( xub_StrLen nWert ) +xub_StrLen SwIndex::operator+=( xub_StrLen const nVal ) { - OSL_ASSERT( nIndex < INVALID_INDEX - nWert ); - return ChgValue( *this, nIndex + nWert ).nIndex; + OSL_ASSERT( m_nIndex < INVALID_INDEX - nVal ); + return ChgValue( *this, m_nIndex + nVal ).m_nIndex; } /************************************************************************* |* SwIndex::operator-=( xub_StrLen ) *************************************************************************/ - -xub_StrLen SwIndex::operator-=( xub_StrLen nWert ) +xub_StrLen SwIndex::operator-=( xub_StrLen const nVal ) { - OSL_ASSERT( nIndex >= nWert ); - return ChgValue( *this, nIndex - nWert ).nIndex; + OSL_ASSERT( m_nIndex >= nVal ); + return ChgValue( *this, m_nIndex - nVal ).m_nIndex; } /************************************************************************* |* SwIndex::operator+=( const SwIndex & ) *************************************************************************/ - xub_StrLen SwIndex::operator+=( const SwIndex & rIndex ) { - OSL_ASSERT( nIndex < INVALID_INDEX - rIndex.nIndex ); - return ChgValue( *this, nIndex + rIndex.nIndex ).nIndex; + OSL_ASSERT( m_nIndex < INVALID_INDEX - rIndex.m_nIndex ); + return ChgValue( *this, m_nIndex + rIndex.m_nIndex ).m_nIndex; } /************************************************************************* |* SwIndex::operator-=( const SwIndex & ) *************************************************************************/ - xub_StrLen SwIndex::operator-=( const SwIndex & rIndex ) { - OSL_ASSERT( nIndex >= rIndex.nIndex ); - return ChgValue( *this, nIndex - rIndex.nIndex ).nIndex; + OSL_ASSERT( m_nIndex >= rIndex.m_nIndex ); + return ChgValue( *this, m_nIndex - rIndex.m_nIndex ).m_nIndex; } /************************************************************************* |* SwIndex::operator<( const SwIndex & ) *************************************************************************/ - -sal_Bool SwIndex::operator<( const SwIndex & rIndex ) const +bool SwIndex::operator< ( const SwIndex & rIndex ) const { - OSL_ENSURE( pArray == rIndex.pArray, "Attempt to compare indices into different arrays."); - return nIndex < rIndex.nIndex; + OSL_ENSURE( m_pIndexReg == rIndex.m_pIndexReg, + "Attempt to compare indices into different arrays."); + return m_nIndex < rIndex.m_nIndex; } /************************************************************************* |* SwIndex::operator<=( const SwIndex & ) *************************************************************************/ - -sal_Bool SwIndex::operator<=( const SwIndex & rIndex ) const +bool SwIndex::operator<=( const SwIndex & rIndex ) const { - OSL_ENSURE( pArray == rIndex.pArray, "Attempt to compare indices into different arrays."); - return nIndex <= rIndex.nIndex; + OSL_ENSURE( m_pIndexReg == rIndex.m_pIndexReg, + "Attempt to compare indices into different arrays."); + return m_nIndex <= rIndex.m_nIndex; } /************************************************************************* |* SwIndex::operator>( const SwIndex & ) *************************************************************************/ - -sal_Bool SwIndex::operator>( const SwIndex & rIndex ) const +bool SwIndex::operator> ( const SwIndex & rIndex ) const { - OSL_ENSURE( pArray == rIndex.pArray, "Attempt to compare indices into different arrays."); - return nIndex > rIndex.nIndex; + OSL_ENSURE( m_pIndexReg == rIndex.m_pIndexReg, + "Attempt to compare indices into different arrays."); + return m_nIndex > rIndex.m_nIndex; } /************************************************************************* |* SwIndex::operator>=( const SwIndex & ) *************************************************************************/ - -sal_Bool SwIndex::operator>=( const SwIndex & rIndex ) const +bool SwIndex::operator>=( const SwIndex & rIndex ) const { - OSL_ENSURE( pArray == rIndex.pArray, "Attempt to compare indices into different arrays."); - return nIndex >= rIndex.nIndex; + OSL_ENSURE( m_pIndexReg == rIndex.m_pIndexReg, + "Attempt to compare indices into different arrays."); + return m_nIndex >= rIndex.m_nIndex; } /************************************************************************* |* SwIndex & SwIndex::operator=( xub_StrLen ) *************************************************************************/ - -SwIndex& SwIndex::operator=( xub_StrLen nWert ) +SwIndex& SwIndex::operator= ( xub_StrLen const nVal ) { - // Werte kopieren und im neuen Array anmelden - if( nIndex != nWert ) - ChgValue( *this, nWert ); + if (m_nIndex != nVal) + ChgValue( *this, nVal ); return *this; } @@ -432,16 +430,17 @@ SwIndex& SwIndex::operator=( xub_StrLen nWert ) void SwIndexReg::MoveTo( SwIndexReg& rArr ) { - if( this != &rArr && pFirst ) + if (this != &rArr && m_pFirst) { - SwIndex* pIdx = (SwIndex*)pFirst, *pNext; + SwIndex * pIdx = const_cast(m_pFirst); + SwIndex * pNext; while( pIdx ) { - pNext = pIdx->pNext; + pNext = pIdx->m_pNext; pIdx->Assign( &rArr, pIdx->GetIndex() ); pIdx = pNext; } - pFirst = 0, pLast = 0; + m_pFirst = 0, m_pLast = 0; } } -- cgit