From 65167a9265acfea04733b5ff6ee3220a9da624f4 Mon Sep 17 00:00:00 2001 From: Dennis Francis Date: Wed, 6 Jan 2021 17:44:00 +0530 Subject: tdf#133858 reduce the double-ref range to data content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in certain matrix formulas like SUM(IF(A1=G:G, H:H)*B1/B2) where whole columns are used for comparison in the condition of IF ultimately followed by a reducer like SUM. In such cases we can safely reduce the double-refs involved in the comparison to the sheet area where there is data before converting the data to ScMatrix. This is a more restricted version of Noel's fix in 37ffe509ef011357123642577c04ff296d59ce68 Change-Id: I1c2e8985adedb3f4c4648f541fb0e8e7d0fae033 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109050 Reviewed-by: Luboš Luňák Tested-by: Jenkins CollaboraOffice --- sc/inc/compiler.hxx | 2 ++ sc/inc/refdata.hxx | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'sc/inc') diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx index 5de80a6b9fb3..264c23883f74 100644 --- a/sc/inc/compiler.hxx +++ b/sc/inc/compiler.hxx @@ -514,10 +514,12 @@ private: bool HandleIIOpCodeInternal(formula::FormulaToken* token, formula::FormulaToken*** pppToken, sal_uInt8 nNumParams); bool SkipImplicitIntersectionOptimization(const formula::FormulaToken* token) const; virtual void PostProcessCode() override; + virtual void AnnotateOperands() override; static bool ParameterMayBeImplicitIntersection(const formula::FormulaToken* token, int parameter); void ReplaceDoubleRefII(formula::FormulaToken** ppDoubleRefTok); bool AdjustSumRangeShape(const ScComplexRefData& rBaseRange, ScComplexRefData& rSumRange); void CorrectSumRange(const ScComplexRefData& rBaseRange, ScComplexRefData& rSumRange, formula::FormulaToken** ppSumRangeToken); + void AnnotateTrimOnDoubleRefs(); }; #endif diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx index f46e13e60821..6edd7160cc04 100644 --- a/sc/inc/refdata.hxx +++ b/sc/inc/refdata.hxx @@ -121,6 +121,11 @@ struct ScComplexRefData { ScSingleRefData Ref1; ScSingleRefData Ref2; + bool bTrimToData; + + ScComplexRefData() : + bTrimToData(false) + {} void InitFlags() { Ref1.InitFlags(); Ref2.InitFlags(); } @@ -194,6 +199,9 @@ struct ScComplexRefData bool IsDeleted() const; + bool IsTrimToData() const { return bTrimToData; } + void SetTrimToData(bool bSet) { bTrimToData = bSet; } + #if DEBUG_FORMULA_COMPILER void Dump( int nIndent = 0 ) const; #endif -- cgit