sc/inc/column.hxx              |    4 +++-
 sc/source/core/data/column.cxx |    9 +++++++--
 sc/source/core/data/table2.cxx |    9 ++++-----
 3 files changed, 14 insertions(+), 8 deletions(-)

New commits:
commit 91c54829e84a372e9ea7460474a84abbef3d1171
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Wed Feb 16 13:52:25 2022 +0100
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Wed Feb 16 19:51:36 2022 +0100

    do not allocate columns in ScTable::GetNumberFormat()
    
    Change-Id: I9347f1d638473f9bcca9b96640a71ae1ef09e415
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129997
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 49fd2dc9b612..2e1f0df49bdb 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -460,8 +460,10 @@ public:
     const ScPatternAttr*    GetPattern( SCROW nRow ) const;
     const ScPatternAttr*    GetMostUsedPattern( SCROW nStartRow, SCROW nEndRow 
) const;
 
-    sal_uInt32 GetNumberFormat( const ScInterpreterContext& rContext, SCROW 
nRow ) const;
+    sal_uInt32  GetNumberFormat( const ScInterpreterContext& rContext, SCROW 
nRow ) const;
     sal_uInt32  GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const;
+    // Mainly to be used by ScTable to share code.
+    static sal_uInt32 GetNumberFormat( const ScDocument& rDoc, const 
ScAttrArray* pAttrArray, SCROW nStartRow, SCROW nEndRow );
 
     void        MergeSelectionPattern( ScMergePatternState& rState, const 
ScMarkData& rMark, bool bDeep ) const;
     void        MergePatternArea( ScMergePatternState& rState, SCROW nRow1, 
SCROW nRow2, bool bDeep ) const;
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index f3f5688e85e8..80a667801aac 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -402,9 +402,9 @@ const ScPatternAttr* ScColumn::GetMostUsedPattern( SCROW 
nStartRow, SCROW nEndRo
     return pMaxPattern;
 }
 
-sal_uInt32 ScColumn::GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const
+sal_uInt32 ScColumn::GetNumberFormat( const ScDocument& rDocument, const 
ScAttrArray* pAttrArray,
+    SCROW nStartRow, SCROW nEndRow )
 {
-    ScDocument& rDocument = GetDoc();
     SCROW nPatStartRow, nPatEndRow;
     const ScPatternAttr* pPattern = pAttrArray->GetPatternRange(nPatStartRow, 
nPatEndRow, nStartRow);
     sal_uInt32 nFormat = pPattern->GetNumberFormat(rDocument.GetFormatTable());
@@ -419,6 +419,11 @@ sal_uInt32 ScColumn::GetNumberFormat( SCROW nStartRow, 
SCROW nEndRow ) const
     return nFormat;
 }
 
+sal_uInt32 ScColumn::GetNumberFormat( SCROW nStartRow, SCROW nEndRow ) const
+{
+    return GetNumberFormat( GetDoc(), pAttrArray.get(), nStartRow, nEndRow );
+}
+
 sal_uInt32 ScColumn::GetNumberFormat( const ScInterpreterContext& rContext, 
SCROW nRow ) const
 {
     return pAttrArray->GetPattern( nRow )->GetNumberFormat( 
rContext.GetFormatTable() );
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 3ba705791336..c9672fc85eb5 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2166,10 +2166,7 @@ sal_uInt32 ScTable::GetNumberFormat( const 
ScInterpreterContext& rContext, const
 
 sal_uInt32 ScTable::GetNumberFormat( SCCOL nCol, SCROW nRow ) const
 {
-    if (ValidColRow(nCol,nRow))
-        return 
CreateColumnIfNotExists(nCol).GetNumberFormat(rDocument.GetNonThreadedContext(),
 nRow);
-    else
-        return 0;
+    return GetNumberFormat(rDocument.GetNonThreadedContext(), ScAddress(nCol, 
nRow, nTab));
 }
 
 sal_uInt32 ScTable::GetNumberFormat( SCCOL nCol, SCROW nStartRow, SCROW 
nEndRow ) const
@@ -2177,7 +2174,9 @@ sal_uInt32 ScTable::GetNumberFormat( SCCOL nCol, SCROW 
nStartRow, SCROW nEndRow
     if (!ValidCol(nCol) || !ValidRow(nStartRow) || !ValidRow(nEndRow))
         return 0;
 
-    return CreateColumnIfNotExists(nCol).GetNumberFormat(nStartRow, nEndRow);
+    if (nCol < GetAllocatedColumnsCount())
+        return aCol[nCol].GetNumberFormat(nStartRow, nEndRow);
+    return ScColumn::GetNumberFormat( GetDoc(), &aDefaultColAttrArray, 
nStartRow, nEndRow);
 }
 
 void ScTable::SetNumberFormat( SCCOL nCol, SCROW nRow, sal_uInt32 
nNumberFormat )

Reply via email to