summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2011-11-24 00:52:44 +0100
committerMichael Stahl <mstahl@redhat.com>2011-11-24 00:52:44 +0100
commit555ff26501d1bbd8a7872c20671c6303db1e1701 (patch)
tree33ed7fbcec881bf42c0c5457f8bfe58c51abf8fc /sw
parent9a4dc4178c86f2639a23089acb6055cc0ca0321f (diff)
SwIndex: remove global EmptyIndexArray
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/index.hxx3
-rw-r--r--sw/source/core/bastyp/index.cxx30
-rw-r--r--sw/source/core/crsr/crsrsh.cxx2
3 files changed, 17 insertions, 18 deletions
diff --git a/sw/inc/index.hxx b/sw/inc/index.hxx
index cecb7bcdb0cc..ec5a980cd8e9 100644
--- a/sw/inc/index.hxx
+++ b/sw/inc/index.hxx
@@ -145,9 +145,6 @@ public:
void MoveTo( SwIndexReg& rArr );
};
-// A global array for holding indices that need to be "swapped" temporarily or
-// do not know a valid array (SwPaM/SwPosition!):
-struct EmptyIndexArray: rtl::Static< SwIndexReg, EmptyIndexArray > {};
#ifndef DBG_UTIL
diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx
index e287c53ae92f..49356c16b744 100644
--- a/sw/source/core/bastyp/index.cxx
+++ b/sw/source/core/bastyp/index.cxx
@@ -44,12 +44,6 @@ SwIndex::SwIndex(SwIndexReg *const pReg, xub_StrLen const nIdx)
, m_pNext( 0 )
, m_pPrev( 0 )
{
- if (!m_pIndexReg)
- {
- m_pIndexReg = &EmptyIndexArray::get();
- m_nIndex = 0; // always 0 if no IndexReg
- }
-
Init(m_nIndex);
}
@@ -72,7 +66,11 @@ SwIndex::SwIndex( const SwIndex& rIdx )
void SwIndex::Init(xub_StrLen const nIdx)
{
- if (!m_pIndexReg->m_pFirst) // first Index?
+ if (!m_pIndexReg)
+ {
+ m_nIndex = 0; // always 0 if no IndexReg
+ }
+ else if (!m_pIndexReg->m_pFirst) // first Index?
{
OSL_ASSERT(!m_pIndexReg->m_pLast);
m_pIndexReg->m_pFirst = m_pIndexReg->m_pLast = this;
@@ -91,6 +89,11 @@ void SwIndex::Init(xub_StrLen const nIdx)
SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, xub_StrLen nNewValue )
{
+ OSL_ASSERT(m_pIndexReg == rIdx.m_pIndexReg);
+ if (!m_pIndexReg)
+ {
+ return *this; // no IndexReg => no list to sort into; m_nIndex is 0
+ }
SwIndex* pFnd = const_cast<SwIndex*>(&rIdx);
if (rIdx.m_nIndex > nNewValue) // move forwards
{
@@ -146,7 +149,6 @@ SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, xub_StrLen nNewValue )
else
m_pNext->m_pPrev = this;
}
- m_pIndexReg = rIdx.m_pIndexReg;
if (m_pIndexReg->m_pFirst == m_pNext)
m_pIndexReg->m_pFirst = this;
@@ -160,6 +162,12 @@ SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, xub_StrLen nNewValue )
void SwIndex::Remove()
{
+ if (!m_pIndexReg)
+ {
+ OSL_ASSERT(!m_pPrev && !m_pNext);
+ return;
+ }
+
if (m_pPrev)
{
m_pPrev->m_pNext = m_pNext;
@@ -205,12 +213,6 @@ SwIndex& SwIndex::operator=( const SwIndex& rIdx )
*************************************************************************/
SwIndex& SwIndex::Assign( SwIndexReg* pArr, xub_StrLen nIdx )
{
- if( !pArr )
- {
- pArr = &EmptyIndexArray::get();
- nIdx = 0; // always 0 if no IndexReg
- }
-
if (pArr != m_pIndexReg) // unregister!
{
Remove();
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 9600bb76c06b..0618f1c46b8f 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3156,7 +3156,7 @@ const SwStartNode* lcl_NodeContext( const SwNode& rNode )
bool lcl_PosOk(const SwPosition & aPos)
{
return NULL != aPos.nNode.GetNode().GetCntntNode() &&
- &EmptyIndexArray::get() != aPos.nContent.GetIdxReg();
+ aPos.nContent.GetIdxReg();
}
/**