diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-02-01 15:15:16 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-04-05 13:43:52 +0200 |
commit | 7282014e362a1529a36c88eb308df8ed359c2cfa (patch) | |
tree | 2776ad9601f494330076ac58c08554e719c6ab3a /sc/source/core/data/table1.cxx | |
parent | df30a4515b1303b0891baa53754fa9b3e47e0c02 (diff) |
tdf#50916 Makes numbers of columns dynamic.
With this commit we are making numbers of columns
dynamic, but the number of maximum supported
columns will be the same (1024).
Such approach will allow us to check issues
(eg. performance, LO format etc.), and improve it.
Increasing number of maximum columns, will be done
in separate commit.
Change-Id: Ibac4101e9ffc05e3548eca1c198f6319ac7ff9aa
Reviewed-on: https://gerrit.libreoffice.org/44802
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'sc/source/core/data/table1.cxx')
-rw-r--r-- | sc/source/core/data/table1.cxx | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 6fb453807604..d964642bd498 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -237,7 +237,7 @@ bool SetOptimalHeightsToRows( ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName, bool bColInfo, bool bRowInfo ) : - aCol( MAXCOLCOUNT ), + aCol( INITIALCOLCOUNT ), aName( rNewName ), aCodeName( rNewName ), nLinkRefreshDelay( 0 ), @@ -1705,7 +1705,7 @@ void ScTable::UpdateReference( mpRangeName->UpdateReference(rCxt, nTab); for ( ; i<=iMax; i++) - bUpdated |= aCol[i].UpdateReference(rCxt, pUndoDoc); + bUpdated |= CreateColumnIfNotExists(i).UpdateReference(rCxt, pUndoDoc); if ( bIncludeDraw ) UpdateDrawRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, bUpdateNoteCaptionPos ); @@ -2434,11 +2434,12 @@ void ScTable::FillMatrix( ScMatrix& rMat, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, { size_t nMatCol = 0; for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol, ++nMatCol) - aCol[nCol].FillMatrix(rMat, nMatCol, nRow1, nRow2, pPool); + CreateColumnIfNotExists(nCol).FillMatrix(rMat, nMatCol, nRow1, nRow2, pPool); } void ScTable::InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) { + nCol2 = ClampToAllocatedColumns(nCol2); for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol) aCol[nCol].InterpretDirtyCells(nRow1, nRow2); } @@ -2509,32 +2510,33 @@ const ScConditionalFormatList* ScTable::GetCondFormList() const ScColumnsRange ScTable::GetColumnsRange(SCCOL nColBegin, SCCOL nColEnd) const { - // Because the range is inclusive, some code will pass nColEnd<nColBegin to - // indicate an empty range. Ensure that we create only valid iterators for - // the range, limit columns to bounds. - SCCOL nEffBegin, nEffEnd; - if (nColBegin <= nColEnd) + ScColContainer::ScColumnVector::const_iterator beginIter; + ScColContainer::ScColumnVector::const_iterator endIter; + + // because the range is inclusive, some code will pass nColEnd<nColBegin to indicate an empty range + if (nColEnd < nColBegin) { - if (nColBegin < 0) - nEffBegin = 0; - else - nEffBegin = std::min<SCCOL>( nColBegin, aCol.size()); - if (nColEnd < 0) - nEffEnd = 0; - else - nEffEnd = std::min<SCCOL>( nColEnd + 1, aCol.size()); + beginIter = aCol.end(); + endIter = aCol.end(); + } + else if (nColBegin >= aCol.size()) + { + beginIter = aCol.end(); + endIter = aCol.end(); } else { - // Any empty will do. - nEffBegin = nEffEnd = 0; + // clamp end of range to available columns + if (nColEnd >= aCol.size()) + nColEnd = aCol.size() - 1; + beginIter = aCol.begin() + nColBegin; + endIter = aCol.begin() + nColEnd + 1; } - return ScColumnsRange( ScColumnsRange::Iterator( aCol.begin() + nEffBegin), - ScColumnsRange::Iterator( aCol.begin() + nEffEnd)); + return ScColumnsRange(ScColumnsRange::Iterator(beginIter), ScColumnsRange::Iterator(endIter)); } // out-of-line the cold part of the CreateColumnIfNotExists function -void ScTable::CreateColumnIfNotExistsImpl( const SCCOL nScCol ) +void ScTable::CreateColumnIfNotExistsImpl( const SCCOL nScCol ) const { const SCCOL aOldColSize = aCol.size(); aCol.resize( static_cast< size_t >( nScCol + 1 ) ); |