diff options
-rw-r--r-- | sc/inc/formulacell.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 12 |
2 files changed, 11 insertions, 2 deletions
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index cdb67a3e27fc..867bb89692d2 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -65,6 +65,7 @@ public: ScTokenArray* mpCode; ScFormulaCell *mpTopCell; SCROW mnLength; // How many of these do we have ? + sal_Int32 mnWeight; short mnFormatType; bool mbInvariant:1; bool mbSubTotal:1; diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 0d89476ec0a2..071ec5b41923 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -523,6 +523,7 @@ ScFormulaCellGroup::ScFormulaCellGroup() : mpCode(nullptr), mpTopCell(nullptr), mnLength(0), + mnWeight(0), mnFormatType(css::util::NumberFormat::NUMBER), mbInvariant(false), mbSubTotal(false), @@ -3875,6 +3876,7 @@ void ScFormulaCell::SetCellGroup( const ScFormulaCellGroupRef &xRef ) mxGroup = xRef; pCode = mxGroup->mpCode; + mxGroup->mnWeight = 0; // invalidate } ScFormulaCell::CompareState ScFormulaCell::CompareByTokenArray( const ScFormulaCell& rOther ) const @@ -4919,12 +4921,18 @@ sal_Int32 ScFormulaCell::GetWeight() const { if (!mxGroup) return 1; + + if (mxGroup->mnWeight > 0) + return mxGroup->mnWeight; + double nSharedCodeWeight = GetSharedCode()->GetWeight(); double nResult = nSharedCodeWeight * GetSharedLength(); if (nResult < SAL_MAX_INT32) - return nResult; + mxGroup->mnWeight = nResult; else - return SAL_MAX_INT32; + mxGroup->mnWeight = SAL_MAX_INT32; + + return mxGroup->mnWeight; } ScTokenArray* ScFormulaCell::GetSharedCode() |