diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-02-16 13:52:25 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-03-23 09:09:02 +0100 |
commit | 3c8162751d847009ecd657ca1382267f526ded33 (patch) | |
tree | 1bf2a702413fd90c48177e6169eabac4ba349e5b | |
parent | 6a3cac77ee59efa9e576af4c89d79e089c30be76 (diff) |
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.lunak@collabora.com>
-rw-r--r-- | sc/inc/column.hxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 9 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 9 |
3 files changed, 14 insertions, 8 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index b5c6aa1b7847..f27091ba07c3 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -465,8 +465,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 9d5643073f70..8e9ed94b9a21 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 c3f4d709661a..3cf56bbc0153 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -2187,10 +2187,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 @@ -2198,7 +2195,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 ) |