Kaydet (Commit) c9d037e5 authored tarafından Eike Rathke's avatar Eike Rathke

resolved fdo#79957 propagate ForceArray through jump tokens

ForceArray parameters weren't propagated and enforced to array arguments
on svJump tokens (FormulaJumpToken), namely IF, CHOOSE, IFERROR and
IFNA.

Change-Id: Icf9074f11b826655a52858d778d9a0122d207aa4
üst e2ae9f3e
...@@ -287,11 +287,16 @@ bool FormulaFAPToken::operator==( const FormulaToken& r ) const ...@@ -287,11 +287,16 @@ bool FormulaFAPToken::operator==( const FormulaToken& r ) const
{ {
return FormulaByteToken::operator==( r ) && pOrigToken == r.GetFAPOrigToken(); return FormulaByteToken::operator==( r ) && pOrigToken == r.GetFAPOrigToken();
} }
short* FormulaJumpToken::GetJump() const { return pJump; } short* FormulaJumpToken::GetJump() const { return pJump; }
bool FormulaJumpToken::HasForceArray() const { return bHasForceArray; }
void FormulaJumpToken::SetForceArray( bool b ) { bHasForceArray = b; }
bool FormulaJumpToken::operator==( const FormulaToken& r ) const bool FormulaJumpToken::operator==( const FormulaToken& r ) const
{ {
return FormulaToken::operator==( r ) && pJump[0] == r.GetJump()[0] && return FormulaToken::operator==( r ) && pJump[0] == r.GetJump()[0] &&
memcmp( pJump+1, r.GetJump()+1, pJump[0] * sizeof(short) ) == 0; memcmp( pJump+1, r.GetJump()+1, pJump[0] * sizeof(short) ) == 0 &&
bHasForceArray == r.HasForceArray();
} }
FormulaJumpToken::~FormulaJumpToken() FormulaJumpToken::~FormulaJumpToken()
{ {
......
...@@ -356,9 +356,9 @@ private: ...@@ -356,9 +356,9 @@ private:
static inline void ForceArrayOperator( FormulaTokenRef& rCurr, const FormulaTokenRef& rPrev ) static inline void ForceArrayOperator( FormulaTokenRef& rCurr, const FormulaTokenRef& rPrev )
{ {
if ( rPrev && rPrev->HasForceArray() && if ( rPrev && rPrev->HasForceArray() && rCurr->GetOpCode() != ocPush &&
rCurr->GetType() == svByte && rCurr->GetOpCode() != ocPush (rCurr->GetType() == svByte || rCurr->GetType() == svJump) &&
&& !rCurr->HasForceArray() ) !rCurr->HasForceArray() )
rCurr->SetForceArray( true); rCurr->SetForceArray( true);
} }
......
...@@ -352,15 +352,18 @@ class FORMULA_DLLPUBLIC FormulaJumpToken : public FormulaToken ...@@ -352,15 +352,18 @@ class FORMULA_DLLPUBLIC FormulaJumpToken : public FormulaToken
{ {
private: private:
short* pJump; short* pJump;
bool bHasForceArray;
public: public:
FormulaJumpToken( OpCode e, short* p ) : FormulaJumpToken( OpCode e, short* p ) :
FormulaToken( formula::svJump , e) FormulaToken( formula::svJump , e),
bHasForceArray( false)
{ {
pJump = new short[ p[0] + 1 ]; pJump = new short[ p[0] + 1 ];
memcpy( pJump, p, (p[0] + 1) * sizeof(short) ); memcpy( pJump, p, (p[0] + 1) * sizeof(short) );
} }
FormulaJumpToken( const FormulaJumpToken& r ) : FormulaJumpToken( const FormulaJumpToken& r ) :
FormulaToken( r ) FormulaToken( r ),
bHasForceArray( r.bHasForceArray)
{ {
pJump = new short[ r.pJump[0] + 1 ]; pJump = new short[ r.pJump[0] + 1 ];
memcpy( pJump, r.pJump, (r.pJump[0] + 1) * sizeof(short) ); memcpy( pJump, r.pJump, (r.pJump[0] + 1) * sizeof(short) );
...@@ -369,6 +372,8 @@ public: ...@@ -369,6 +372,8 @@ public:
virtual short* GetJump() const SAL_OVERRIDE; virtual short* GetJump() const SAL_OVERRIDE;
virtual bool operator==( const formula::FormulaToken& rToken ) const SAL_OVERRIDE; virtual bool operator==( const formula::FormulaToken& rToken ) const SAL_OVERRIDE;
virtual FormulaToken* Clone() const SAL_OVERRIDE { return new FormulaJumpToken(*this); } virtual FormulaToken* Clone() const SAL_OVERRIDE { return new FormulaJumpToken(*this); }
virtual bool HasForceArray() const SAL_OVERRIDE;
virtual void SetForceArray( bool b ) SAL_OVERRIDE;
}; };
......
...@@ -888,7 +888,7 @@ public: ...@@ -888,7 +888,7 @@ public:
inline void ScInterpreter::MatrixDoubleRefToMatrix() inline void ScInterpreter::MatrixDoubleRefToMatrix()
{ {
if ( bMatrixFormula && GetStackType() == formula::svDoubleRef ) if ( (bMatrixFormula || pCur->HasForceArray()) && GetStackType() == formula::svDoubleRef )
{ {
GetTokenMatrixMap(); // make sure it exists, create if not. GetTokenMatrixMap(); // make sure it exists, create if not.
PopDoubleRefPushMatrix(); PopDoubleRefPushMatrix();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment