Kaydet (Commit) bac1e2dd authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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
üst 607b7dde
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment