sc/source/core/data/document10.cxx |    7 ++++---
 sc/source/core/data/table2.cxx     |    7 ++-----
 2 files changed, 6 insertions(+), 8 deletions(-)

New commits:
commit 823eb92025853d120c17790d1c8efde59f033c69
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Wed Feb 16 13:19:29 2022 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Wed Feb 16 21:37:36 2022 +0100

    do not allocate columns in ScTable::GetPattern()
    
    Otherwise e.g. going to the last column allocates all columns.
    
    Change-Id: I9cbdb18545bb200379616484c46c85ca31833563
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129995
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/source/core/data/document10.cxx 
b/sc/source/core/data/document10.cxx
index e2293c585e7c..5d5728844e56 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -125,10 +125,11 @@ bool ScDocument::CopyOneCellFromClip(
         if ((rCxt.getInsertFlag() & (InsertDeleteFlags::NOTE | 
InsertDeleteFlags::ADDNOTES)) != InsertDeleteFlags::NONE)
             rCxt.setSingleCellNote(nColOffset, pClipDoc->GetNote(aSrcPos));
 
-        ScColumn& rSrcCol = pSrcTab->aCol[aSrcPos.Col()];
+        ScColumn* pSrcCol = pSrcTab->FetchColumn(aSrcPos.Col());
+        assert(pSrcCol);
         // Determine the script type of the copied single cell.
-        rSrcCol.UpdateScriptTypes(aSrcPos.Row(), aSrcPos.Row());
-        rCxt.setSingleCell(aSrcPos, rSrcCol);
+        pSrcCol->UpdateScriptTypes(aSrcPos.Row(), aSrcPos.Row());
+        rCxt.setSingleCell(aSrcPos, *pSrcCol);
     }
 
     // All good. Proceed with the pasting.
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 864876f04ad7..02c237e3af31 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2189,13 +2189,10 @@ void ScTable::SetNumberFormat( SCCOL nCol, SCROW nRow, 
sal_uInt32 nNumberFormat
 
 const ScPatternAttr* ScTable::GetPattern( SCCOL nCol, SCROW nRow ) const
 {
-    if (ValidColRow(nCol,nRow))
+    if (ValidColRow(nCol,nRow) && nCol < GetAllocatedColumnsCount())
         return CreateColumnIfNotExists(nCol).GetPattern( nRow );
     else
-    {
-        OSL_FAIL("wrong column or row");
-        return rDocument.GetDefPattern();      // for safety
-    }
+        return aDefaultColAttrArray.GetPattern( nRow );
 }
 
 const ScPatternAttr* ScTable::GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, 
SCROW nEndRow ) const

Reply via email to