summaryrefslogtreecommitdiff
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 18:26:52 +0000
commitaa94b17208a5512a344301345f26a9418f943a00 (patch)
tree69aa449ace2d47a81a9e6fc44f7f2e064248ddaa
parentbb9acf9e8c7b90b992967a90f6eb85378dda78a9 (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> (cherry picked from commit b5f9c2be36f935f0009c2d7c40f7fadebf0b7ef8) Reviewed-on: https://gerrit.libreoffice.org/7695 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org>
-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 2adf63c83271..9004bbbfbd97 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)