Kaydet (Commit) dc35a397 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Fixed incorrect insertion.

üst 42d04ed4
...@@ -106,7 +106,7 @@ private: ...@@ -106,7 +106,7 @@ private:
bool DecDepth(); bool DecDepth();
void FindEntry( void FindEntry(
SCCOLROW nSearchPos, size_t& rFindLevel, ScOutlineCollection::iterator& rFindPos, SCCOLROW nSearchPos, size_t& rFindLevel, size_t& rFindIndex,
size_t nMaxLevel = SC_OL_MAXDEPTH); size_t nMaxLevel = SC_OL_MAXDEPTH);
void RemoveSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nLevel); void RemoveSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nLevel);
......
...@@ -203,10 +203,10 @@ ScOutlineArray::ScOutlineArray( const ScOutlineArray& rArray ) : ...@@ -203,10 +203,10 @@ ScOutlineArray::ScOutlineArray( const ScOutlineArray& rArray ) :
} }
void ScOutlineArray::FindEntry( void ScOutlineArray::FindEntry(
SCCOLROW nSearchPos, size_t& rFindLevel, ScOutlineCollection::iterator& rFindPos, SCCOLROW nSearchPos, size_t& rFindLevel, size_t& rFindIndex,
size_t nMaxLevel ) size_t nMaxLevel )
{ {
rFindLevel = 0; rFindLevel = rFindIndex = 0;
if (nMaxLevel > nDepth) if (nMaxLevel > nDepth)
nMaxLevel = nDepth; nMaxLevel = nDepth;
...@@ -215,14 +215,13 @@ void ScOutlineArray::FindEntry( ...@@ -215,14 +215,13 @@ void ScOutlineArray::FindEntry(
{ {
ScOutlineCollection* pCollect = &aCollections[nLevel]; ScOutlineCollection* pCollect = &aCollections[nLevel];
ScOutlineCollection::iterator it = pCollect->begin(), itEnd = pCollect->end(); ScOutlineCollection::iterator it = pCollect->begin(), itEnd = pCollect->end();
rFindPos = itEnd;
for (; it != itEnd; ++it) for (; it != itEnd; ++it)
{ {
ScOutlineEntry* pEntry = it->second; ScOutlineEntry* pEntry = it->second;
if (pEntry->GetStart() <= nSearchPos && pEntry->GetEnd() >= nSearchPos) if (pEntry->GetStart() <= nSearchPos && pEntry->GetEnd() >= nSearchPos)
{ {
rFindLevel = nLevel + 1; // naechster Level (zum Einfuegen) rFindLevel = nLevel + 1; // naechster Level (zum Einfuegen)
rFindPos = it; rFindIndex = std::distance(pCollect->begin(), it);
} }
} }
} }
...@@ -233,20 +232,19 @@ bool ScOutlineArray::Insert( ...@@ -233,20 +232,19 @@ bool ScOutlineArray::Insert(
{ {
rSizeChanged = false; rSizeChanged = false;
size_t nStartLevel, nEndLevel; size_t nStartLevel, nEndLevel, nStartIndex, nEndIndex;
ScOutlineCollection::iterator itStartPos, itEndPos;
bool bFound = false; bool bFound = false;
bool bCont; bool bCont;
sal_uInt16 nFindMax; sal_uInt16 nFindMax;
FindEntry( nStartCol, nStartLevel, itStartPos ); // nLevel = neuer Level (alter+1) !!! FindEntry( nStartCol, nStartLevel, nStartIndex ); // nLevel = neuer Level (alter+1) !!!
FindEntry( nEndCol, nEndLevel, itEndPos ); FindEntry( nEndCol, nEndLevel, nEndIndex );
nFindMax = Max(nStartLevel,nEndLevel); nFindMax = Max(nStartLevel,nEndLevel);
do do
{ {
bCont = false; bCont = false;
if (nStartLevel == nEndLevel && itStartPos == itEndPos && nStartLevel < SC_OL_MAXDEPTH) if (nStartLevel == nEndLevel && nStartIndex == nEndIndex && nStartLevel < SC_OL_MAXDEPTH)
bFound = true; bFound = true;
if (!bFound) if (!bFound)
...@@ -256,14 +254,18 @@ bool ScOutlineArray::Insert( ...@@ -256,14 +254,18 @@ bool ScOutlineArray::Insert(
--nFindMax; --nFindMax;
if (nStartLevel) if (nStartLevel)
{ {
if (itStartPos->second->GetStart() == nStartCol) ScOutlineCollection::const_iterator it = aCollections[nStartLevel-1].begin();
FindEntry(nStartCol, nStartLevel, itStartPos, nFindMax); std::advance(it, nStartIndex);
if (it->second->GetStart() == nStartCol)
FindEntry(nStartCol, nStartLevel, nStartIndex, nFindMax);
} }
if (nEndLevel) if (nEndLevel)
{ {
if (itEndPos->second->GetEnd() == nEndCol) ScOutlineCollection::const_iterator it = aCollections[nEndLevel-1].begin();
FindEntry(nEndCol, nEndLevel, itEndPos, nFindMax); std::advance(it, nEndIndex);
if (it->second->GetEnd() == nEndCol)
FindEntry(nEndCol, nEndLevel, nEndIndex, nFindMax);
} }
bCont = true; bCont = true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment