summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-04-21 15:56:31 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-04-23 21:08:22 -0400
commitbac1e2ddeb438b73556466a3014751c0f4f54960 (patch)
treec414f56f291f56f2d33df7514a1dc94386c0a5b6 /sc/source
parent607b7ddeeb6c9d380adf67edf4ae7877ff3bdb0c (diff)
Add empty block at the top to keep row and element positions in sync.
Otherwise formula cells would mis-behave during grouping. Also, the range-based release() was renamed to release_range() to avoid unwanted function overloading due to implicit type conversion. Change-Id: I3dc1421f89926f161963eede9a2c8eb477d7e5be
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/table3.cxx20
1 files changed, 15 insertions, 5 deletions
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index bc433340bcde..dfca5244d7f3 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -383,6 +383,11 @@ struct SortedColumn : boost::noncopyable
sc::CellStoreType maCells;
sc::CellTextAttrStoreType maCellTextAttrs;
sc::BroadcasterStoreType maBroadcasters;
+
+ SortedColumn( size_t nTopEmptyRows ) :
+ maCells(nTopEmptyRows),
+ maCellTextAttrs(nTopEmptyRows),
+ maBroadcasters(nTopEmptyRows) {}
};
}
@@ -446,7 +451,12 @@ void ScTable::SortReorder( ScSortInfoArray* pArray, ScProgress* pProgress )
boost::ptr_vector<SortedColumn> aSortedCols; // storage for copied cells.
aSortedCols.reserve(nColCount);
for (size_t i = 0; i < nColCount; ++i)
- aSortedCols.push_back(new SortedColumn);
+ {
+ // In the sorted column container, element positions and row
+ // positions must match, else formula cells may mis-behave during
+ // grouping.
+ aSortedCols.push_back(new SortedColumn(nRow1));
+ }
for (size_t i = 0; i < pRows->size(); ++i)
{
@@ -515,24 +525,24 @@ void ScTable::SortReorder( ScSortInfoArray* pArray, ScProgress* pProgress )
{
sc::CellStoreType& rDest = aCol[nThisCol].maCells;
sc::CellStoreType& rSrc = aSortedCols[i].maCells;
- rSrc.transfer(0, rSrc.size()-1, rDest, nRow1);
+ rSrc.transfer(nRow1, aSortParam.nRow2, rDest, nRow1);
}
{
sc::CellTextAttrStoreType& rDest = aCol[nThisCol].maCellTextAttrs;
sc::CellTextAttrStoreType& rSrc = aSortedCols[i].maCellTextAttrs;
- rSrc.transfer(0, rSrc.size()-1, rDest, nRow1);
+ rSrc.transfer(nRow1, aSortParam.nRow2, rDest, nRow1);
}
{
sc::BroadcasterStoreType& rBCDest = aCol[nThisCol].maBroadcasters;
// Release current broadcasters first, to prevent them from getting deleted.
- rBCDest.release(nRow1, aSortParam.nRow2);
+ rBCDest.release_range(nRow1, aSortParam.nRow2);
// Transfer sorted broadcaster segment to the document.
sc::BroadcasterStoreType& rBCSrc = aSortedCols[i].maBroadcasters;
- rBCSrc.transfer(0, rBCSrc.size()-1, rBCDest, nRow1);
+ rBCSrc.transfer(nRow1, aSortParam.nRow2, rBCDest, nRow1);
}
aCol[nThisCol].CellStorageModified();