summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-09-29 14:22:00 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-10-06 10:14:01 +0200
commit495444d09dba7af63c0bf87804be02bc3f0f8c17 (patch)
tree13285c8d50f1b1160f12e81ba76af1d1fcceb800
parentxmloff: ODF import: fix crash on fdo34997-1.odt (diff)
downloadcore-495444d09dba7af63c0bf87804be02bc3f0f8c17.tar.gz
core-495444d09dba7af63c0bf87804be02bc3f0f8c17.zip
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> (cherry picked from commit 305443d59a0fa579fe05b749d0891e63675d7050) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140613 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit a2f91c0d5315156df1d2700deec936a4ee1c61e0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140879 Tested-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sc/inc/table.hxx8
-rw-r--r--sc/source/core/data/table4.cxx8
2 files changed, 12 insertions, 4 deletions
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 35388b54ea1f..7403b36780f1 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 41250d5e2871..8ec1512136e7 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);
}