summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2011-11-24 00:52:11 +0100
committerMichael Stahl <mstahl@redhat.com>2011-11-24 00:52:11 +0100
commitd43417b5474eab1a10c9529e3b02e930a53d4171 (patch)
treeaf591c7878e6ffc9453e9bd9e7dfb44f87cd5acf /sw
parentff151e28334a8478fc073d292d1233f99ad45fd2 (diff)
SwIndex: clean up Remove duplication
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/bastyp/index.cxx54
1 files changed, 19 insertions, 35 deletions
diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx
index fc795c4eb55a..9461c4ee2f7d 100644
--- a/sw/source/core/bastyp/index.cxx
+++ b/sw/source/core/bastyp/index.cxx
@@ -94,15 +94,7 @@ SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, xub_StrLen nNewValue )
if( pFnd != 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;
+ Remove();
m_pNext = pFnd;
m_pPrev = pFnd->m_pPrev;
@@ -122,15 +114,7 @@ SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, xub_StrLen nNewValue )
if( pFnd != 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;
+ Remove();
m_pPrev = pFnd;
m_pNext = pFnd->m_pNext;
@@ -144,17 +128,9 @@ SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, xub_StrLen nNewValue )
else if( pFnd != 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;
+ Remove();
- m_pPrev = const_cast<SwIndex*>(&rIdx);
+ m_pPrev = pFnd; // == &rIdx here
m_pNext = rIdx.m_pNext;
m_pPrev->m_pNext = this;
@@ -177,15 +153,23 @@ SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, xub_StrLen nNewValue )
void SwIndex::Remove()
{
- if (!m_pPrev)
- m_pIndexReg->m_pFirst = m_pNext;
- else
+ 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_pIndexReg->m_pLast = m_pPrev;
- else
+ if (m_pNext)
+ {
m_pNext->m_pPrev = m_pPrev;
+ }
+ else if (m_pIndexReg->m_pLast == this)
+ {
+ m_pIndexReg->m_pLast = m_pPrev;
+ }
}
/*************************************************************************
@@ -199,7 +183,7 @@ SwIndex& SwIndex::operator=( const SwIndex& rIdx )
Remove();
m_pIndexReg = rIdx.m_pIndexReg;
m_pNext = m_pPrev = 0;
- bEqual = sal_False;
+ bEqual = false;
}
else
bEqual = rIdx.m_nIndex == m_nIndex;