formula/source/core/api/token.cxx | 5 ++++- include/formula/tokenarray.hxx | 11 +++++++++++ sc/source/core/data/formulacell.cxx | 5 ++++- sc/source/core/tool/compiler.cxx | 26 ++++++++++++++++++++------ sc/source/core/tool/token.cxx | 1 + 5 files changed, 40 insertions(+), 8 deletions(-)
New commits: commit e3789123da397c82109a5fcead3d49f803ba6aad Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Mon Oct 17 23:19:23 2016 -0400 tdf#93894: Prohibit grouping when certain token types are present. For instance, column / row label tokens don't work correctly in grouped cells with the current implementation. Change-Id: Idf86312ef15fbfd4382aa90ee6d131c671a80683 (cherry picked from commit e944d9510404d8c67b3867d7cd9f313fd5091004) Reviewed-on: https://gerrit.libreoffice.org/30027 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Eike Rathke <er...@redhat.com> diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index 29ac8a1..713998c 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -712,7 +712,8 @@ FormulaTokenArray::FormulaTokenArray() : nError(0), nMode(ScRecalcMode::NORMAL), bHyperLink(false), - mbFromRangeName(false) + mbFromRangeName(false), + mbShareable(true) { } @@ -735,6 +736,7 @@ void FormulaTokenArray::Assign( const FormulaTokenArray& r ) nMode = r.nMode; bHyperLink = r.bHyperLink; mbFromRangeName = r.mbFromRangeName; + mbShareable = r.mbShareable; pCode = nullptr; pRPN = nullptr; FormulaToken** pp; @@ -846,6 +848,7 @@ void FormulaTokenArray::Clear() nError = nLen = nIndex = nRPN = 0; bHyperLink = false; mbFromRangeName = false; + mbShareable = true; ClearRecalcMode(); } diff --git a/include/formula/tokenarray.hxx b/include/formula/tokenarray.hxx index 3faadec..78bbf57 100644 --- a/include/formula/tokenarray.hxx +++ b/include/formula/tokenarray.hxx @@ -118,6 +118,7 @@ protected: ScRecalcMode nMode; // Flags to indicate when to recalc this code bool bHyperLink; // If HYPERLINK() occurs in the formula. bool mbFromRangeName; // If this array originates from a named expression + bool mbShareable; // Whether or not it can be shared with adjacent cells. protected: void Assign( const FormulaTokenArray& ); @@ -166,6 +167,16 @@ public: void SetFromRangeName( bool b ) { mbFromRangeName = b; } bool IsFromRangeName() const { return mbFromRangeName; } + void SetShareable( bool b ) { mbShareable = b; } + + /** + * Check if this token array is shareable between multiple adjacent + * formula cells. Certain tokens may not function correctly when shared. + * + * @return true if the token array is shareable, false otherwise. + */ + bool IsShareable() const { return mbShareable; } + void Clear(); void DelRPN(); FormulaToken* First() { nIndex = 0; return Next(); } diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 04870c1..64a0bb4 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -1293,7 +1293,7 @@ void ScFormulaCell::CompileXML( sc::CompileFormulaContext& rCxt, ScProgress& rPr ScAddress aPreviousCell( aPos ); aPreviousCell.IncRow( -1 ); ScFormulaCell *pPreviousCell = pDocument->GetFormulaCell( aPreviousCell ); - if( pPreviousCell ) + if (pPreviousCell && pPreviousCell->GetCode()->IsShareable()) { // Now try to convert to a string quickly ... ScCompiler aBackComp( rCxt, aPos, *(pPreviousCell->pCode) ); @@ -3767,6 +3767,9 @@ ScFormulaCell::CompareState ScFormulaCell::CompareByTokenArray( ScFormulaCell& r if ( GetHash() != rOther.GetHash() ) return NotEqual; + if (!pCode->IsShareable() || !rOther.pCode->IsShareable()) + return NotEqual; + FormulaToken **pThis = pCode->GetCode(); sal_uInt16 nThisLen = pCode->GetCodeLen(); FormulaToken **pOther = rOther.pCode->GetCode(); diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index e5659d5..264b7c3 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -4386,6 +4386,12 @@ ScTokenArray* ScCompiler::CompileString( const OUString& rFormula ) --nFunction; } break; + case ocColRowName: + case ocColRowNameAuto: + // The current implementation of column / row labels doesn't + // function correctly in grouped cells. + aArr.SetShareable(false); + break; default: break; } @@ -5273,8 +5279,10 @@ bool ScCompiler::HandleColRowName() { ScSingleRefData aRefData; aRefData.InitAddress( aRange.aStart ); - aRefData.SetColRel( true ); - aRefData.SetRowRel( true ); + if ( bColName ) + aRefData.SetColRel( true ); + else + aRefData.SetRowRel( true ); aRefData.SetAddress(aRange.aStart, aPos); pNew->AddSingleReference( aRefData ); } @@ -5282,10 +5290,16 @@ bool ScCompiler::HandleColRowName() { ScComplexRefData aRefData; aRefData.InitRange( aRange ); - aRefData.Ref1.SetColRel( true ); - aRefData.Ref2.SetColRel( true ); - aRefData.Ref1.SetRowRel( true ); - aRefData.Ref2.SetRowRel( true ); + if ( bColName ) + { + aRefData.Ref1.SetColRel( true ); + aRefData.Ref2.SetColRel( true ); + } + else + { + aRefData.Ref1.SetRowRel( true ); + aRefData.Ref2.SetRowRel( true ); + } aRefData.SetRange(aRange, aPos); if ( bInList ) pNew->AddDoubleReference( aRefData ); diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx index 581c2d7..a0eb39b 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -1787,6 +1787,7 @@ ScTokenArray* ScTokenArray::Clone() const p->mnHashValue = mnHashValue; p->meVectorState = meVectorState; p->mbFromRangeName = mbFromRangeName; + p->mbShareable = mbShareable; FormulaToken** pp; if( nLen ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits