sc/source/core/data/document.cxx | 18 +++++++++--------- sc/source/core/data/table3.cxx | 4 ++++ 2 files changed, 13 insertions(+), 9 deletions(-)
New commits: commit e63704897b14085d1290f5112ebd7cf7c2f0b2c6 Author: Luboš Luňák <[email protected]> AuthorDate: Tue Mar 29 20:44:10 2022 +0200 Commit: Luboš Luňák <[email protected]> CommitDate: Wed Mar 30 00:02:23 2022 +0200 allocate columns for initDataRows() Triggered by TestSort::testSortImages() with INITIALCOLCOUNT set to 1. Change-Id: Ifd3e63de6411e0a4d8776ed6cc8a7b6c7c64eec6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132283 Tested-by: Jenkins Reviewed-by: Luboš Luňák <[email protected]> diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index fa47526f3f0f..511d4a3c80ed 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -474,6 +474,7 @@ std::unique_ptr<ScSortInfoArray> ScTable::CreateSortInfoArray( const sc::Reorder pArray->SetKeepQuery(rParam.mbHiddenFiltered); pArray->SetUpdateRefs(rParam.mbUpdateRefs); + CreateColumnIfNotExists(nCol2); initDataRows( *pArray, *this, aCol, nCol1, nRow1, nCol2, nRow2, rParam.mbHiddenFiltered, rParam.maDataAreaExtras.mbCellFormats, true, true, false); } @@ -517,6 +518,7 @@ std::unique_ptr<ScSortInfoArray> ScTable::CreateSortInfoArray( } } + CreateColumnIfNotExists(rSortParam.nCol2); initDataRows( *pArray, *this, aCol, rSortParam.nCol1, nInd1, rSortParam.nCol2, nInd2, bKeepQuery, rSortParam.aDataAreaExtras.mbCellFormats, true, true, false); } @@ -904,6 +906,7 @@ void ScTable::SortReorderAreaExtrasByRow( ScSortInfoArray* pArray, for (SCCOL nCol = rDataAreaExtras.mnStartCol; nCol < nDataCol1; nCol += nChunkCols) { const SCCOL nEndCol = std::min<SCCOL>( nCol + nChunkCols - 1, nDataCol1 - 1); + CreateColumnIfNotExists(nEndCol); initDataRows( *pArray, *this, aCol, nCol, nRow1, nEndCol, nLastRow, false, rDataAreaExtras.mbCellFormats, rDataAreaExtras.mbCellNotes, rDataAreaExtras.mbCellDrawObjects, true); SortReorderByRow( pArray, nCol, nEndCol, pProgress, true); @@ -912,6 +915,7 @@ void ScTable::SortReorderAreaExtrasByRow( ScSortInfoArray* pArray, for (SCCOL nCol = nDataCol2 + 1; nCol <= rDataAreaExtras.mnEndCol; nCol += nChunkCols) { const SCCOL nEndCol = std::min<SCCOL>( nCol + nChunkCols - 1, rDataAreaExtras.mnEndCol); + CreateColumnIfNotExists(nEndCol); initDataRows( *pArray, *this, aCol, nCol, nRow1, nEndCol, nLastRow, false, rDataAreaExtras.mbCellFormats, rDataAreaExtras.mbCellNotes, rDataAreaExtras.mbCellDrawObjects, true); SortReorderByRow( pArray, nCol, nEndCol, pProgress, true); commit cf560fd387ee9f54d3edaf066c70b411d1f7b299 Author: Luboš Luňák <[email protected]> AuthorDate: Tue Mar 29 20:11:30 2022 +0200 Commit: Luboš Luňák <[email protected]> CommitDate: Wed Mar 30 00:02:10 2022 +0200 use ScTable::ColumnData() in ScDocument::ExtendOverlapped() Otherwise there's invalid array access triggered by VBAMacroTest::testVba() with INITIALCOLCOUNT set to 1. Change-Id: Iaff333788d2d29444139c99b0f6e82b69a5a2d84 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132282 Tested-by: Jenkins Reviewed-by: Luboš Luňák <[email protected]> diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 363bd168fcab..59d05432ae5c 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -5550,25 +5550,25 @@ void ScDocument::ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow, //TODO: pass on ? - ScAttrArray* pAttrArray = maTabs[nTab]->aCol[nOldCol].pAttrArray.get(); + const ScAttrArray& pAttrArray = maTabs[nTab]->ColumnData(nOldCol).AttrArray(); SCSIZE nIndex; - if ( pAttrArray->Count() ) - pAttrArray->Search( nOldRow, nIndex ); + if ( pAttrArray.Count() ) + pAttrArray.Search( nOldRow, nIndex ); else nIndex = 0; SCROW nAttrPos = nOldRow; while (nAttrPos<=nEndRow) { - OSL_ENSURE( nIndex < pAttrArray->Count(), "Wrong index in AttrArray" ); + OSL_ENSURE( nIndex < pAttrArray.Count(), "Wrong index in AttrArray" ); bool bHorOverlapped; - if ( pAttrArray->Count() ) - bHorOverlapped = pAttrArray->mvData[nIndex].pPattern->GetItem(ATTR_MERGE_FLAG).IsHorOverlapped(); + if ( pAttrArray.Count() ) + bHorOverlapped = pAttrArray.mvData[nIndex].pPattern->GetItem(ATTR_MERGE_FLAG).IsHorOverlapped(); else bHorOverlapped = GetDefPattern()->GetItem(ATTR_MERGE_FLAG).IsHorOverlapped(); if ( bHorOverlapped ) { - SCROW nEndRowSeg = (pAttrArray->Count()) ? pAttrArray->mvData[nIndex].nEndRow : MaxRow(); + SCROW nEndRowSeg = (pAttrArray.Count()) ? pAttrArray.mvData[nIndex].nEndRow : MaxRow(); SCROW nLoopEndRow = std::min( nEndRow, nEndRowSeg ); for (SCROW nAttrRow = nAttrPos; nAttrRow <= nLoopEndRow; nAttrRow++) { @@ -5580,9 +5580,9 @@ void ScDocument::ExtendOverlapped( SCCOL& rStartCol, SCROW& rStartRow, rStartCol = nTempCol; } } - if ( pAttrArray->Count() ) + if ( pAttrArray.Count() ) { - nAttrPos = pAttrArray->mvData[nIndex].nEndRow + 1; + nAttrPos = pAttrArray.mvData[nIndex].nEndRow + 1; ++nIndex; } else
