summaryrefslogtreecommitdiff
path: root/sc/source/core/data
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-02-05 22:59:04 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-02-05 23:06:27 -0500
commitbc504b5adfaeeac0b910b89b0c98ae564f1ff5b8 (patch)
tree8259b0795bd42d3a81f6c656372f34638c62fbd7 /sc/source/core/data
parentfe5d604ecf6de4935c622e0e95efc085c4a3cbfd (diff)
fdo#74556: Correctly handle note captions life cycles.
When copying notes to clipboard, we don't clone captions but leave them pointing to the original captions objects. Also, during undo and redo, we need to clear all caption pointers to prevent them from being deleted when the ScPostIt objects get deleted. The undo and redo of caption objects are handled in the drawing layer afterwards. Change-Id: I2b9cf0858dba5b3cac26db3ef501ea09779a795a
Diffstat (limited to 'sc/source/core/data')
-rw-r--r--sc/source/core/data/column.cxx2
-rw-r--r--sc/source/core/data/column2.cxx18
-rw-r--r--sc/source/core/data/document.cxx18
-rw-r--r--sc/source/core/data/table2.cxx9
4 files changed, 46 insertions, 1 deletions
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index ff8ed6bb1549..52eb27eb9a7e 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1278,7 +1278,7 @@ class CopyToClipHandler
void duplicateNotes(SCROW nStartRow, size_t nDataSize )
{
- mrSrcCol.DuplicateNotes(nStartRow, nDataSize, mrDestCol, maDestPos);
+ mrSrcCol.DuplicateNotes(nStartRow, nDataSize, mrDestCol, maDestPos, false);
}
public:
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index f6c7cd9fd8fb..af06f1bb5182 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1252,6 +1252,14 @@ public:
}
};
+struct NoteCaptionCleaner
+{
+ void operator() ( size_t /*nRow*/, ScPostIt* p )
+ {
+ p->ForgetCaption();
+ }
+};
+
}
void ScColumn::CreateAllNoteCaptions()
@@ -1260,6 +1268,16 @@ void ScColumn::CreateAllNoteCaptions()
sc::ProcessNote(maCellNotes, aFunc);
}
+void ScColumn::ForgetNoteCaptions( SCROW nRow1, SCROW nRow2 )
+{
+ if (!ValidRow(nRow1) || !ValidRow(nRow2))
+ return;
+
+ NoteCaptionCleaner aFunc;
+ sc::CellNoteStoreType::iterator it = maCellNotes.begin();
+ sc::ProcessNote(it, maCellNotes, nRow1, nRow2, aFunc);
+}
+
SCROW ScColumn::GetNotePosition( size_t nIndex ) const
{
// Return the row position of the nth note in the column.
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 3194f78bf5c1..3f08fd621cec 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -6245,6 +6245,24 @@ void ScDocument::CreateAllNoteCaptions()
}
}
+void ScDocument::ForgetNoteCaptions( const ScRangeList& rRanges )
+{
+ for (size_t i = 0, n = rRanges.size(); i < n; ++i)
+ {
+ const ScRange* p = rRanges[i];
+ const ScAddress& s = p->aStart;
+ const ScAddress& e = p->aEnd;
+ for (SCTAB nTab = s.Tab(); nTab <= s.Tab(); ++nTab)
+ {
+ ScTable* pTab = FetchTable(nTab);
+ if (!pTab)
+ continue;
+
+ pTab->ForgetNoteCaptions(s.Col(), s.Row(), e.Col(), e.Row());
+ }
+ }
+}
+
ScAddress ScDocument::GetNotePosition( size_t nIndex ) const
{
for (size_t nTab = 0; nTab < maTabs.size(); ++nTab)
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 41f5e0d18287..88ffc1fcd333 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1551,6 +1551,15 @@ void ScTable::CreateAllNoteCaptions()
aCol[i].CreateAllNoteCaptions();
}
+void ScTable::ForgetNoteCaptions( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
+{
+ if (!ValidCol(nCol1) || !ValidCol(nCol2))
+ return;
+
+ for (SCCOL i = nCol1; i <= nCol2; ++i)
+ aCol[i].ForgetNoteCaptions(nRow1, nRow2);
+}
+
void ScTable::GetAllNoteEntries( std::vector<sc::NoteEntry>& rNotes ) const
{
for (SCCOL nCol = 0; nCol < MAXCOLCOUNT; ++nCol)