summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-01-24 21:29:54 -0500
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-01-27 14:28:17 +0000
commitb5f9c2be36f935f0009c2d7c40f7fadebf0b7ef8 (patch)
tree2f9e4d3514bc6496ce0b4abef4c6b7ba3aacd4d7 /sc
parent1abf248b24d0804bed361acdb4052cefbd1a918f (diff)
Stop leaking all ScPostIt instances.
And re-implement correct swapping of two ScPostIt instances during sort. (cherry picked from commit ab05317c79f665bcf9d5cff7b8312ce6963ff969) Change-Id: Ifbf120aae594342ae0b7c5760f771c53092c8022 Reviewed-on: https://gerrit.libreoffice.org/7641 Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/mtvelements.hxx2
-rw-r--r--sc/source/core/data/column2.cxx19
2 files changed, 9 insertions, 12 deletions
diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx
index 0fcafdecce98..3eb5527b8eaf 100644
--- a/sc/inc/mtvelements.hxx
+++ b/sc/inc/mtvelements.hxx
@@ -65,7 +65,7 @@ const mdds::mtv::element_t element_type_empty = mdds::mtv::element_type_empty;
/// Custom element blocks.
-typedef mdds::mtv::default_element_block<element_type_cellnote, ScPostIt*> cellnote_block;
+typedef mdds::mtv::noncopyable_managed_element_block<element_type_cellnote, ScPostIt> cellnote_block;
typedef mdds::mtv::noncopyable_managed_element_block<element_type_broadcaster, SvtBroadcaster> broadcaster_block;
typedef mdds::mtv::default_element_block<element_type_celltextattr, CellTextAttr> celltextattr_block;
typedef mdds::mtv::default_element_block<element_type_string, svl::SharedString> string_block;
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index ad16dd49d225..20d3ee7edf1a 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1902,8 +1902,6 @@ void ScColumn::SwapCellNotes( SCROW nRow1, SCROW nRow2 )
if (aPos2.first == maCellNotes.end())
return;
- ScPostIt* aNote;
-
sc::CellNoteStoreType::iterator it1 = aPos1.first, it2 = aPos2.first;
if (it1->type == it2->type)
{
@@ -1917,10 +1915,10 @@ void ScColumn::SwapCellNotes( SCROW nRow1, SCROW nRow2 )
sc::cellnote_block::at(*it2->data, aPos2.second));
//update Note caption with position
- aNote = sc::cellnote_block::at(*it1->data, aPos1.second);
- aNote->UpdateCaptionPos(ScAddress(nCol,nRow2,nTab));
- aNote = sc::cellnote_block::at(*it2->data, aPos2.second);
- aNote->UpdateCaptionPos(ScAddress(nCol,nRow1,nTab));
+ ScPostIt* pNote = sc::cellnote_block::at(*it1->data, aPos1.second);
+ pNote->UpdateCaptionPos(ScAddress(nCol,nRow2,nTab));
+ pNote = sc::cellnote_block::at(*it2->data, aPos2.second);
+ pNote->UpdateCaptionPos(ScAddress(nCol,nRow1,nTab));
return;
}
@@ -1931,19 +1929,18 @@ void ScColumn::SwapCellNotes( SCROW nRow1, SCROW nRow2 )
// row 1 is empty while row 2 is non-empty.
ScPostIt* pVal2 = sc::cellnote_block::at(*it2->data, aPos2.second);
it1 = maCellNotes.set(it1, nRow1, pVal2);
- maCellNotes.set_empty(it1, nRow2, nRow2);
+ maCellNotes.release(it1, nRow2, pVal2);
pVal2->UpdateCaptionPos(ScAddress(nCol,nRow1,nTab)); //update Note caption with position
return;
}
// row 1 is non-empty while row 2 is empty.
- ScPostIt* pVal1 = sc::cellnote_block::at(*it1->data, aPos1.second);
- it1 = maCellNotes.set_empty(it1, nRow1, nRow1);
+ ScPostIt* pVal1 = NULL;
+ it1 = maCellNotes.release(it1, nRow1, pVal1);
+ assert(pVal1);
maCellNotes.set(it1, nRow2, pVal1);
pVal1->UpdateCaptionPos(ScAddress(nCol,nRow1,nTab)); //update Note caption with position
-
- CellStorageModified();
}
SvtBroadcaster* ScColumn::GetBroadcaster(SCROW nRow)