sc/inc/table.hxx | 8 ++++++++ sc/source/core/data/table4.cxx | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-)
New commits: commit 1c53f5b6647dcffa57012990d342b21eaff19888 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Thu Sep 29 14:22:00 2022 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Thu Sep 29 16:19:18 2022 +0200 introduce ScTable::GetColumnData() (tdf#151182) This is intended to handle possibly unallocated columns similarly to CreateColumnIfNotExists(), but unlike that one this one does not allocate, if the column is not allocated then the default column data is returned. This is intended for reading of columns. Change-Id: Ic3b637eb3d16bac69ebc7ecd389973407db4f7fd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140737 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 4d4e7a2f7830..a9d2ad71bd39 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -294,6 +294,14 @@ public: } // out-of-line the cold part of the function void CreateColumnIfNotExistsImpl( const SCCOL nScCol ); + + ScColumnData& GetColumnData( SCCOL nCol ) + { + if( nCol >= aCol.size()) + return aDefaultColData; + return aCol[nCol]; + } + sal_uInt64 GetCellCount() const; sal_uInt64 GetWeightedCount() const; sal_uInt64 GetWeightedCount(SCROW nStartRow, SCROW nEndRow) const; diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 6cf97e5d9caf..77f17feaa8f3 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -910,9 +910,9 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, if ( bGetPattern ) { if (bVertical) // rInner&:=nRow, rOuter&:=nCol - pSrcPattern = aCol[nCol].GetPattern(static_cast<SCROW>(nAtSrc)); + pSrcPattern = GetColumnData(nCol).GetPattern(static_cast<SCROW>(nAtSrc)); else // rInner&:=nCol, rOuter&:=nRow - pSrcPattern = aCol[nAtSrc].GetPattern(static_cast<SCROW>(nRow)); + pSrcPattern = GetColumnData(nAtSrc).GetPattern(static_cast<SCROW>(nRow)); bGetPattern = false; pStyleSheet = pSrcPattern->GetStyleSheet(); // do transfer ATTR_MERGE / ATTR_MERGE_FLAG @@ -1894,7 +1894,7 @@ void ScTable::FillAutoSimple( return; } const SvNumFormatType nFormatType = rDocument.GetFormatTable()->GetType( - aCol[rCol].GetNumberFormat( rDocument.GetNonThreadedContext(), nSource)); + GetColumnData(rCol).GetNumberFormat( rDocument.GetNonThreadedContext(), nSource)); bBooleanCell = (nFormatType == SvNumFormatType::LOGICAL); bPercentCell = (nFormatType == SvNumFormatType::PERCENT); @@ -1903,7 +1903,7 @@ void ScTable::FillAutoSimple( { aSrcCell = GetCellValue(nSource, rRow); const SvNumFormatType nFormatType = rDocument.GetFormatTable()->GetType( - aCol[nSource].GetNumberFormat( rDocument.GetNonThreadedContext(), rRow)); + GetColumnData(nSource).GetNumberFormat( rDocument.GetNonThreadedContext(), rRow)); bBooleanCell = (nFormatType == SvNumFormatType::LOGICAL); bPercentCell = (nFormatType == SvNumFormatType::PERCENT); }