summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-05-20 15:29:16 +0200
committerCaolán McNamara <caolanm@redhat.com>2016-05-23 08:13:10 +0000
commit4c05c610661096342c0f826936aa3307a7ca78b3 (patch)
treeb4d8ebd4cfad90f8d5a29c03036d30e678192fa1
parent6c933e37f5ad448b5a22ff43e6995d9c38e6fe0e (diff)
Resolves: tdf#93101 handle external references and propagate error
Cherry-picked 5 commits from master: tdf#93101 propagate external reference error from refcache token (cherry picked from commit 7de92ad48d8c4fe7a1f9fb24ef8afc7d8907788e) tdf#93101 correctly resolve svExternalSingleRef token in GetMatrix() ... including error propagation, and use GetNewMat() instead of a plain ScFullMatrix so the interpreter error handling is set up. (cherry picked from commit 2f94ff566f7827792175daedb92f12a7e61ad95d) tdf#93101 handle svExternalSingleRef in ISERROR() (cherry picked from commit 824cf015683383b553c744a746ac8e8ea65495cf) handle svExternalSingleRef in all IS*() functions, tdf#93101 related (cherry picked from commit f053086fbc625fca8ba7b956738d33ba78a80f9b) handle svExternalDoubleRef in all IS*() functions, tdf#93101 related (cherry picked from commit 365c4d8c60e89fd57a91f51ca51a8796fe91edd7) 862c46f9afc2afd0bb2a23aa767158e0945583a5 9e2a4aeb16d6777153d2f47a1c1af68fe2e97780 14181dd2dbb5d412e3dd165dcbf7468cb8ea8b21 48813de703ea926b8828f4e262393f7643216989 Change-Id: I90491a7b18fddaddb3bbb4d7a3f8b9555b9b1198 Reviewed-on: https://gerrit.libreoffice.org/25207 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sc/source/core/tool/interpr1.cxx87
-rw-r--r--sc/source/core/tool/interpr4.cxx8
-rw-r--r--sc/source/core/tool/interpr5.cxx33
3 files changed, 112 insertions, 16 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 2d888a35e3b3..fa9d70aeb762 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1885,9 +1885,18 @@ bool ScInterpreter::IsString()
}
}
break;
+ case svExternalSingleRef:
+ {
+ ScExternalRefCache::TokenRef pToken;
+ PopExternalSingleRef(pToken);
+ if (!nGlobalError && pToken->GetType() == svString)
+ bRes = true;
+ }
+ break;
+ case svExternalDoubleRef:
case svMatrix:
{
- ScMatrixRef pMat = PopMatrix();
+ ScMatrixRef pMat = GetMatrix();
if ( !pMat )
; // nothing
else if ( !pJumpMatrix )
@@ -2452,6 +2461,22 @@ void ScInterpreter::ScIsRef()
bRes = !x.get()->GetRefList()->empty();
}
break;
+ case svExternalSingleRef:
+ {
+ ScExternalRefCache::TokenRef pToken;
+ PopExternalSingleRef(pToken);
+ if (!nGlobalError)
+ bRes = true;
+ }
+ break;
+ case svExternalDoubleRef:
+ {
+ ScExternalRefCache::TokenArrayRef pArray;
+ PopExternalDoubleRef(pArray);
+ if (!nGlobalError)
+ bRes = true;
+ }
+ break;
default:
Pop();
}
@@ -2493,9 +2518,18 @@ void ScInterpreter::ScIsValue()
}
}
break;
+ case svExternalSingleRef:
+ {
+ ScExternalRefCache::TokenRef pToken;
+ PopExternalSingleRef(pToken);
+ if (!nGlobalError && pToken->GetType() == svDouble)
+ bRes = true;
+ }
+ break;
+ case svExternalDoubleRef:
case svMatrix:
{
- ScMatrixRef pMat = PopMatrix();
+ ScMatrixRef pMat = GetMatrix();
if ( !pMat )
; // nothing
else if ( !pJumpMatrix )
@@ -2643,9 +2677,19 @@ void ScInterpreter::ScIsNV()
}
}
break;
+ case svExternalSingleRef:
+ {
+ ScExternalRefCache::TokenRef pToken;
+ PopExternalSingleRef(pToken);
+ if (nGlobalError == NOTAVAILABLE ||
+ (pToken && pToken->GetType() == svError && pToken->GetError() == NOTAVAILABLE))
+ bRes = true;
+ }
+ break;
+ case svExternalDoubleRef:
case svMatrix:
{
- ScMatrixRef pMat = PopMatrix();
+ ScMatrixRef pMat = GetMatrix();
if ( !pMat )
; // nothing
else if ( !pJumpMatrix )
@@ -2690,9 +2734,19 @@ void ScInterpreter::ScIsErr()
}
}
break;
+ case svExternalSingleRef:
+ {
+ ScExternalRefCache::TokenRef pToken;
+ PopExternalSingleRef(pToken);
+ if ((nGlobalError && nGlobalError != NOTAVAILABLE) || !pToken ||
+ (pToken->GetType() == svError && pToken->GetError() != NOTAVAILABLE))
+ bRes = true;
+ }
+ break;
+ case svExternalDoubleRef:
case svMatrix:
{
- ScMatrixRef pMat = PopMatrix();
+ ScMatrixRef pMat = GetMatrix();
if ( nGlobalError || !pMat )
bRes = ((nGlobalError && nGlobalError != NOTAVAILABLE) || !pMat);
else if ( !pJumpMatrix )
@@ -2746,9 +2800,18 @@ void ScInterpreter::ScIsError()
}
}
break;
+ case svExternalSingleRef:
+ {
+ ScExternalRefCache::TokenRef pToken;
+ PopExternalSingleRef(pToken);
+ if (nGlobalError || !pToken || pToken->GetType() == svError)
+ bRes = true;
+ }
+ break;
+ case svExternalDoubleRef:
case svMatrix:
{
- ScMatrixRef pMat = PopMatrix();
+ ScMatrixRef pMat = GetMatrix();
if ( nGlobalError || !pMat )
bRes = true;
else if ( !pJumpMatrix )
@@ -2817,9 +2880,21 @@ bool ScInterpreter::IsEven()
bRes = true;
}
break;
+ case svExternalSingleRef:
+ {
+ ScExternalRefCache::TokenRef pToken;
+ PopExternalSingleRef(pToken);
+ if (!nGlobalError && pToken->GetType() == svDouble)
+ {
+ fVal = pToken->GetDouble();
+ bRes = true;
+ }
+ }
+ break;
+ case svExternalDoubleRef:
case svMatrix:
{
- ScMatrixRef pMat = PopMatrix();
+ ScMatrixRef pMat = GetMatrix();
if ( !pMat )
; // nothing
else if ( !pJumpMatrix )
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 92e130408848..cbdc51e50f41 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1190,6 +1190,9 @@ void ScInterpreter::PopExternalSingleRef(
return;
}
+ if (xNew->GetType() == svError)
+ SetError( xNew->GetError());
+
rToken = xNew;
if (pFmt)
*pFmt = aFmt;
@@ -1288,6 +1291,11 @@ void ScInterpreter::GetExternalDoubleRef(
}
formula::FormulaToken* pToken = pArray->First();
+ if (pToken->GetType() == svError)
+ {
+ SetError( pToken->GetError());
+ return;
+ }
if (pToken->GetType() != svMatrix)
{
SetError(errIllegalArgument);
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index a0933c0b93e9..b85a9427e224 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -455,25 +455,38 @@ ScMatrixRef ScInterpreter::GetMatrix()
{
ScExternalRefCache::TokenRef pToken;
PopExternalSingleRef(pToken);
- if (!pToken)
+ pMat = GetNewMat( 1, 1, true);
+ if (!pMat)
{
- PopError();
SetError( errIllegalArgument);
break;
}
- if (pToken->GetType() == svDouble)
+ if (!pToken)
{
- pMat = new ScFullMatrix(1, 1, 0.0);
- pMat->PutDouble(pToken->GetDouble(), 0, 0);
+ SetError( errIllegalArgument);
+ pMat->PutError( nGlobalError, 0, 0);
+ nGlobalError = 0;
+ break;
}
- else if (pToken->GetType() == svString)
+ if (nGlobalError)
{
- pMat = new ScFullMatrix(1, 1, 0.0);
- pMat->PutString(pToken->GetString(), 0, 0);
+ pMat->PutError( nGlobalError, 0, 0);
+ nGlobalError = 0;
+ break;
}
- else
+ switch (pToken->GetType())
{
- pMat = new ScFullMatrix(1, 1);
+ case svError:
+ pMat->PutError( pToken->GetError(), 0, 0);
+ break;
+ case svDouble:
+ pMat->PutDouble( pToken->GetDouble(), 0, 0);
+ break;
+ case svString:
+ pMat->PutString( pToken->GetString(), 0, 0);
+ break;
+ default:
+ ; // nothing, empty element matrix
}
}
break;