sc/inc/table.hxx               |    8 ++++++++
 sc/source/core/data/table4.cxx |    8 ++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

New commits:
commit c21ba00a93cd02e322fd28af50af1fb1930bac48
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Thu Sep 29 14:22:00 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Oct 3 10:55:35 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>
    (cherry picked from commit 305443d59a0fa579fe05b749d0891e63675d7050)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140613
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

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

Reply via email to