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
{
return FormulaByteToken::operator==( r ) && pOrigToken == r.GetFAPOrigToken();
}
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
{
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()
{
......
......@@ -356,9 +356,9 @@ private:
static inline void ForceArrayOperator( FormulaTokenRef& rCurr, const FormulaTokenRef& rPrev )
{
if ( rPrev && rPrev->HasForceArray() &&
rCurr->GetType() == svByte && rCurr->GetOpCode() != ocPush
&& !rCurr->HasForceArray() )
if ( rPrev && rPrev->HasForceArray() && rCurr->GetOpCode() != ocPush &&
(rCurr->GetType() == svByte || rCurr->GetType() == svJump) &&
!rCurr->HasForceArray() )
rCurr->SetForceArray( true);
}
......
......@@ -352,15 +352,18 @@ class FORMULA_DLLPUBLIC FormulaJumpToken : public FormulaToken
{
private:
short* pJump;
bool bHasForceArray;
public:
FormulaJumpToken( OpCode e, short* p ) :
FormulaToken( formula::svJump , e)
FormulaToken( formula::svJump , e),
bHasForceArray( false)
{
pJump = new short[ p[0] + 1 ];
memcpy( pJump, p, (p[0] + 1) * sizeof(short) );
}
FormulaJumpToken( const FormulaJumpToken& r ) :
FormulaToken( r )
FormulaToken( r ),
bHasForceArray( r.bHasForceArray)
{
pJump = new short[ r.pJump[0] + 1 ];
memcpy( pJump, r.pJump, (r.pJump[0] + 1) * sizeof(short) );
......@@ -369,6 +372,8 @@ public:
virtual short* GetJump() const SAL_OVERRIDE;
virtual bool operator==( const formula::FormulaToken& rToken ) const SAL_OVERRIDE;
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:
inline void ScInterpreter::MatrixDoubleRefToMatrix()
{
if ( bMatrixFormula && GetStackType() == formula::svDoubleRef )
if ( (bMatrixFormula || pCur->HasForceArray()) && GetStackType() == formula::svDoubleRef )
{
GetTokenMatrixMap(); // make sure it exists, create if not.
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