summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-03-02 01:59:01 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-03-02 02:00:28 +0100
commit921fb226d2836673c1d3ef0f254708a5c5c0b313 (patch)
tree066414fdb4b1a83a4231bc19889d00a32daf3206
parent1d1141cd06fcdbadd008744a28674d4b50457923 (diff)
fix crashs in undo/redo realted to note captions
-rw-r--r--sc/inc/postit.hxx4
-rw-r--r--sc/source/core/data/postit.cxx11
-rw-r--r--sc/source/core/data/table2.cxx4
3 files changed, 11 insertions, 8 deletions
diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index 16746d6b2838..1b370ceacb32 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -297,7 +297,7 @@ public:
bool insert( SCCOL nCol, SCROW nRow, ScPostIt* );
bool insert( const ScAddress& rPos, ScPostIt* );
- void erase(SCCOL, SCROW);
+ void erase(SCCOL, SCROW, bool bForgetCaption = false);
void erase(const ScAddress& rPos);
/** Returns and forgets the cell note object at the passed cell address. */
@@ -311,7 +311,7 @@ public:
ScNotes* clone(ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bCloneNoteCaption, SCTAB nTab);
void CopyFromClip(const ScNotes& maNotes, ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCsCOL nDx, SCsROW nDy, SCTAB nTab, bool bCloneCaption);
- void erase(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2);
+ void erase(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bForgetCaption = false);
};
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 8ecacfad145e..8a0677fcdae9 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -1009,11 +1009,14 @@ bool ScNotes::insert(const ScAddress& rPos, ScPostIt* pPostIt)
return insert(rPos.Col(), rPos.Row(), pPostIt);
}
-void ScNotes::erase(SCCOL nCol, SCROW nRow)
+void ScNotes::erase(SCCOL nCol, SCROW nRow, bool bForgetCaption)
{
iterator itr = maNoteMap.find(std::pair<SCCOL, SCROW>(nCol, nRow));
if (itr != maNoteMap.end())
{
+ if (bForgetCaption)
+ itr->second->ForgetCaption();
+
delete itr->second;
maNoteMap.erase(itr);
}
@@ -1088,12 +1091,12 @@ void ScNotes::CopyFromClip(const ScNotes& rNotes, ScDocument* pDoc, SCCOL nCol1,
if (nCol+nDx >= nCol1 && nCol+nDx <= nCol2 && nRow+nDy >= nRow1 && nRow+nDy <= nRow2)
{
erase(nCol+nDx, nRow+nDy);
- insert(nCol+nDx, nRow+nDy, itr->second->Clone( ScAddress(nCol, nRow, nTab), *pDoc, ScAddress(nCol, nRow, nTab), bCloneCaption ));
+ insert(nCol+nDx, nRow+nDy, itr->second->Clone( ScAddress(nCol, nRow, nTab), *pDoc, ScAddress(nCol+nDx, nRow+nDy, nTab), bCloneCaption ));
}
}
}
-void ScNotes::erase(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
+void ScNotes::erase(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bForgetCaption)
{
ScNotes::iterator itr = maNoteMap.begin();
while(itr != maNoteMap.end())
@@ -1103,7 +1106,7 @@ void ScNotes::erase(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
++itr;
if (nCol >= nCol1 && nCol <= nCol2 && nRow >= nRow1 && nRow <= nRow2)
{
- erase(nCol, nRow);
+ erase(nCol, nRow, bForgetCaption);
}
}
}
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 4cc42f626800..19fa5477885f 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -537,7 +537,7 @@ void ScTable::DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sal
}
if (nDelFlag & IDF_NOTE)
- maNotes.erase( nCol1, nRow1, nCol2, nRow2);
+ maNotes.erase( nCol1, nRow1, nCol2, nRow2, true );
if (IsStreamValid())
// TODO: In the future we may want to check if the table has been
@@ -561,7 +561,7 @@ void ScTable::DeleteSelection( sal_uInt16 nDelFlag, const ScMarkData& rMark )
{
ScRange* pRange = aRangeList[i];
if (nDelFlag & IDF_NOTE && pRange)
- maNotes.erase(pRange->aStart.Col(), pRange->aStart.Row(), pRange->aEnd.Col(), pRange->aEnd.Row());
+ maNotes.erase(pRange->aStart.Col(), pRange->aStart.Row(), pRange->aEnd.Col(), pRange->aEnd.Row(), true);
}
//