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.lunak@collabora.com>
This commit is contained in:
Luboš Luňák 2022-09-29 14:22:00 +02:00
parent 436c37e699
commit 1c53f5b664
2 changed files with 12 additions and 4 deletions

View file

@ -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;

View file

@ -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);
}