diff options
-rw-r--r-- | sc/source/core/data/table3.cxx | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 07c4030382c2..05b71c35daa2 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -253,7 +253,7 @@ public: explicit Row( size_t nColSize ) : maCells(nColSize, Cell()), mbHidden(false), mbFiltered(false) {} }; - typedef std::vector<Row*> RowsType; + typedef std::vector<Row> RowsType; private: std::unique_ptr<RowsType> mpRows; /// row-wise data table for sort by row operation. @@ -290,12 +290,6 @@ public: maOrderIndices.push_back(i+nStart); } - ~ScSortInfoArray() - { - if (mpRows) - std::for_each(mpRows->begin(), mpRows->end(), std::default_delete<Row>()); - } - void SetKeepQuery( bool b ) { mbKeepQuery = b; } bool IsKeepQuery() const { return mbKeepQuery; } @@ -325,6 +319,8 @@ public: */ void Swap( SCCOLROW nInd1, SCCOLROW nInd2 ) { + if (nInd1 == nInd2) // avoid self-move-assign + return; SCSIZE n1 = static_cast<SCSIZE>(nInd1 - nStart); SCSIZE n2 = static_cast<SCSIZE>(nInd2 - nStart); for ( sal_uInt16 nSort = 0; nSort < static_cast<sal_uInt16>(mvppInfo.size()); nSort++ ) @@ -387,10 +383,7 @@ public: RowsType& InitDataRows( size_t nRowSize, size_t nColSize ) { mpRows.reset(new RowsType); - mpRows->reserve(nRowSize); - for (size_t i = 0; i < nRowSize; ++i) - mpRows->push_back(new Row(nColSize)); - + mpRows->resize(nRowSize, Row(nColSize)); return *mpRows; } @@ -426,7 +419,7 @@ void initDataRows( for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow) { - ScSortInfoArray::Row& rRow = *rRows[nRow-nRow1]; + ScSortInfoArray::Row& rRow = rRows[nRow-nRow1]; ScSortInfoArray::Cell& rCell = rRow.maCells[nCol-nCol1]; rCell.maCell = rCol.GetCellValue(aBlockPos, nRow); rCell.mpAttr = rCol.GetCellTextAttr(aBlockPos, nRow); @@ -443,7 +436,7 @@ void initDataRows( { for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow) { - ScSortInfoArray::Row& rRow = *rRows[nRow-nRow1]; + ScSortInfoArray::Row& rRow = rRows[nRow-nRow1]; rRow.mbHidden = rTab.RowHidden(nRow); rRow.mbFiltered = rTab.RowFiltered(nRow); } @@ -700,12 +693,12 @@ void fillSortedColumnArray( for (size_t i = 0; i < pRows->size(); ++i) { - ScSortInfoArray::Row* pRow = (*pRows)[i]; - for (size_t j = 0; j < pRow->maCells.size(); ++j) + ScSortInfoArray::Row& rRow = (*pRows)[i]; + for (size_t j = 0; j < rRow.maCells.size(); ++j) { ScAddress aCellPos(nCol1 + j, nRow1 + i, nTab); - ScSortInfoArray::Cell& rCell = pRow->maCells[j]; + ScSortInfoArray::Cell& rCell = rRow.maCells[j]; sc::CellStoreType& rCellStore = aSortedCols.at(j).get()->maCells; switch (rCell.maCell.meType) @@ -799,8 +792,8 @@ void fillSortedColumnArray( { // Hidden and filtered flags are first converted to segments. SCROW nRow = nRow1 + i; - aRowFlags.setRowHidden(nRow, pRow->mbHidden); - aRowFlags.setRowFiltered(nRow, pRow->mbFiltered); + aRowFlags.setRowHidden(nRow, rRow.mbHidden); + aRowFlags.setRowFiltered(nRow, rRow.mbFiltered); } if (pProgress) |