summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-10-01 12:23:46 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-10-01 12:33:11 +0100
commita77223b281d79db60c6905e77538f077200b1af8 (patch)
tree2f8ff13b42f1b210642ff572978826b746415d2c /sw/source/core
parent9b2a24b9e32ded1b6dc111ddc06b7ed07c0b7d6d (diff)
rearrange SwCalc some more
Change-Id: Ib1ffc112ddd006102b29536f7433a3f16bf63a3f
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/bastyp/calc.cxx63
1 files changed, 44 insertions, 19 deletions
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index 2f2e42f50a82..c7bdf9fdadc9 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -1042,36 +1042,34 @@ SwSbxValue SwCalc::StdFunc(pfCalc pFnc, bool bChkTrig)
return nErg;
}
-SwSbxValue SwCalc::Prim()
+SwSbxValue SwCalc::PrimFunc(bool &rChkPow)
{
- SwSbxValue nErg;
-
- bool bChkPow = false;
+ rChkPow = false;
switch (m_eCurrOper)
{
case CALC_SIN:
- nErg = StdFunc(&sin, false);
+ return StdFunc(&sin, false);
break;
case CALC_COS:
- nErg = StdFunc(&cos, false);
+ return StdFunc(&cos, false);
break;
case CALC_TAN:
- nErg = StdFunc(&tan, false);
+ return StdFunc(&tan, false);
break;
case CALC_ATAN:
- nErg = StdFunc(&atan, false);
+ return StdFunc(&atan, false);
break;
case CALC_ASIN:
- nErg = StdFunc(&asin, true);
+ return StdFunc(&asin, true);
break;
case CALC_ACOS:
- nErg = StdFunc(&acos, true);
+ return StdFunc(&acos, true);
break;
case CALC_NOT:
{
GetToken();
- nErg = Prim();
+ SwSbxValue nErg = Prim();
if( SbxSTRING == nErg.GetType() )
{
nErg.PutBool( nErg.GetOUString().isEmpty() );
@@ -1092,10 +1090,12 @@ SwSbxValue SwCalc::Prim()
//!! computes a binary NOT
nErg.Compute( SbxNOT, nErg );
}
+ return nErg;
break;
}
case CALC_NUMBER:
{
+ SwSbxValue nErg;
if( GetToken() == CALC_PHD )
{
double aTmp = m_nNumberValue.GetDouble();
@@ -1110,12 +1110,14 @@ SwSbxValue SwCalc::Prim()
else
{
nErg = m_nNumberValue;
- bChkPow = true;
+ rChkPow = true;
}
+ return nErg;
break;
}
case CALC_NAME:
{
+ SwSbxValue nErg;
switch(SwCalcOper eOper = GetToken())
{
case CALC_ASSIGN:
@@ -1132,19 +1134,24 @@ SwSbxValue SwCalc::Prim()
if (nErg.IsVoidValue() && (eOper == CALC_LP))
m_eError = CALC_SYNTAX;
else
- bChkPow = true;
+ rChkPow = true;
break;
}
+ return nErg;
break;
}
case CALC_MINUS:
+ {
+ SwSbxValue nErg;
GetToken();
nErg.PutDouble( -(Prim().GetDouble()) );
+ return nErg;
break;
+ }
case CALC_LP:
{
GetToken();
- nErg = Expr();
+ SwSbxValue nErg = Expr();
if( m_eCurrOper != CALC_RP )
{
m_eError = CALC_BRACK;
@@ -1152,46 +1159,64 @@ SwSbxValue SwCalc::Prim()
else
{
GetToken();
- bChkPow = true; // in order for =(7)^2 to work
+ rChkPow = true; // in order for =(7)^2 to work
}
+ return nErg;
break;
}
case CALC_MEAN:
{
m_nListPor = 1;
GetToken();
- nErg = Expr();
+ SwSbxValue nErg = Expr();
double aTmp = nErg.GetDouble();
aTmp /= m_nListPor;
nErg.PutDouble( aTmp );
+ return nErg;
break;
}
case CALC_SQRT:
{
GetToken();
- nErg = Prim();
+ SwSbxValue nErg = Prim();
if( nErg.GetDouble() < 0 )
m_eError = CALC_OVERFLOW;
else
nErg.PutDouble( sqrt( nErg.GetDouble() ));
+ return nErg;
break;
}
case CALC_SUM:
case CALC_DATE:
case CALC_MIN:
case CALC_MAX:
+ {
GetToken();
- nErg = Expr();
+ SwSbxValue nErg = Expr();
+ return nErg;
break;
+ }
case CALC_ENDCALC:
+ {
+ SwSbxValue nErg;
nErg.Clear();
+ return nErg;
break;
+ }
default:
m_eError = CALC_SYNTAX;
break;
}
- if( bChkPow && m_eCurrOper == CALC_POW )
+ return SwSbxValue();
+}
+
+SwSbxValue SwCalc::Prim()
+{
+ bool bChkPow;
+ SwSbxValue nErg = PrimFunc(bChkPow);
+
+ if (bChkPow && m_eCurrOper == CALC_POW)
{
double dleft = nErg.GetDouble();
GetToken();