[Libreoffice-commits] core.git: sw/inc sw/source
Noel Grandin
noel.grandin at collabora.co.uk
Mon Feb 13 09:58:50 UTC 2017
sw/inc/calc.hxx | 18 ++++-------
sw/inc/shellres.hxx | 2 -
sw/source/core/bastyp/calc.cxx | 44 ++++++++++++---------------
sw/source/core/doc/DocumentFieldsManager.cxx | 4 +-
sw/source/core/fields/cellfml.cxx | 18 +++++------
sw/source/core/fields/usrfld.cxx | 2 -
sw/source/uibase/inc/utlui.hrc | 4 +-
sw/source/uibase/utlui/initui.cxx | 2 -
sw/source/uibase/utlui/initui.src | 8 ----
9 files changed, 43 insertions(+), 59 deletions(-)
New commits:
commit 651752b9294f2db3458faa429beaa45bb450a57b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Feb 13 10:24:02 2017 +0200
convert SwCalcError to scoped enum
and drop unused CALC_VARNFND and CALC_WRONGTIME enumerators
Change-Id: I415960180b074ee4c54c47e69962fe2ca1be42e0
Reviewed-on: https://gerrit.libreoffice.org/34195
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx
index 630c43c..306a2bb 100644
--- a/sw/inc/calc.hxx
+++ b/sw/inc/calc.hxx
@@ -87,16 +87,14 @@ extern const sal_Char sCalc_Round[];
extern const sal_Char sCalc_Date[];
// Calculate ErrorCodes
-enum SwCalcError
+enum class SwCalcError
{
- CALC_NOERR=0,
- CALC_SYNTAX, // syntax error
- CALC_ZERODIV, // division by zero
- CALC_BRACK, // faulty brackets
- CALC_POWERR, // overflow in power function
- CALC_VARNFND, // variable was not found
- CALC_OVERFLOW, // overflow
- CALC_WRONGTIME // wrong time format
+ NONE=0,
+ Syntax, // syntax error
+ DivByZero, // division by zero
+ FaultyBrackets, // faulty brackets
+ OverflowInPower, // overflow in power function
+ Overflow, // overflow
};
class SwSbxValue : public SbxValue
@@ -196,7 +194,7 @@ public:
void Pop();
void SetCalcError( SwCalcError eErr ) { m_eError = eErr; }
- bool IsCalcError() const { return 0 != m_eError; }
+ bool IsCalcError() const { return SwCalcError::NONE != m_eError; }
static bool Str2Double( const OUString& rStr, sal_Int32& rPos,
double& rVal );
diff --git a/sw/inc/shellres.hxx b/sw/inc/shellres.hxx
index 5f391b7..4694866 100644
--- a/sw/inc/shellres.hxx
+++ b/sw/inc/shellres.hxx
@@ -35,9 +35,7 @@ struct SW_DLLPUBLIC ShellResource
OUString aCalc_ZeroDiv;
OUString aCalc_Brack;
OUString aCalc_Pow;
- OUString aCalc_VarNFnd;
OUString aCalc_Overflow;
- OUString aCalc_WrongTime;
OUString aCalc_Default;
OUString aCalc_Error;
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index 8862dd3..cb73166 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -237,7 +237,7 @@ SwCalc::SwCalc( SwDoc& rD )
, m_nListPor( 0 )
, m_eCurrOper( CALC_NAME )
, m_eCurrListOper( CALC_NAME )
- , m_eError( CALC_NOERR )
+ , m_eError( SwCalcError::NONE )
{
m_aErrExpr.aStr = "~C_ERR~";
memset( m_aVarTable, 0, sizeof(m_aVarTable) );
@@ -374,7 +374,7 @@ SwCalc::~SwCalc()
SwSbxValue SwCalc::Calculate( const OUString& rStr )
{
- m_eError = CALC_NOERR;
+ m_eError = SwCalcError::NONE;
SwSbxValue nResult;
if( rStr.isEmpty() )
@@ -386,10 +386,10 @@ SwSbxValue SwCalc::Calculate( const OUString& rStr )
m_sCommand = rStr;
m_nCommandPos = 0;
- while( (m_eCurrOper = GetToken()) != CALC_ENDCALC && m_eError == CALC_NOERR )
+ while( (m_eCurrOper = GetToken()) != CALC_ENDCALC && m_eError == SwCalcError::NONE )
nResult = Expr();
- if( m_eError )
+ if( m_eError != SwCalcError::NONE)
nResult.PutDouble( DBL_MAX );
return nResult;
@@ -409,14 +409,12 @@ OUString SwCalc::GetStrResult( double nValue, bool )
if( nValue >= DBL_MAX )
switch( m_eError )
{
- case CALC_SYNTAX : return RESOURCE->aCalc_Syntax;
- case CALC_ZERODIV : return RESOURCE->aCalc_ZeroDiv;
- case CALC_BRACK : return RESOURCE->aCalc_Brack;
- case CALC_POWERR : return RESOURCE->aCalc_Pow;
- case CALC_VARNFND : return RESOURCE->aCalc_VarNFnd;
- case CALC_OVERFLOW : return RESOURCE->aCalc_Overflow;
- case CALC_WRONGTIME : return RESOURCE->aCalc_WrongTime;
- default : return RESOURCE->aCalc_Default;
+ case SwCalcError::Syntax : return RESOURCE->aCalc_Syntax;
+ case SwCalcError::DivByZero : return RESOURCE->aCalc_ZeroDiv;
+ case SwCalcError::FaultyBrackets : return RESOURCE->aCalc_Brack;
+ case SwCalcError::OverflowInPower : return RESOURCE->aCalc_Pow;
+ case SwCalcError::Overflow : return RESOURCE->aCalc_Overflow;
+ default : return RESOURCE->aCalc_Default;
}
const sal_Int32 nDecPlaces = 15;
@@ -839,7 +837,7 @@ SwCalcOper SwCalc::GetToken()
if( bSetError )
{
- m_eError = CALC_SYNTAX;
+ m_eError = SwCalcError::Syntax;
m_eCurrOper = CALC_PRINT;
}
m_nCommandPos = aRes.EndPos;
@@ -938,7 +936,7 @@ SwSbxValue SwCalc::Term()
sal_Int32 nDec = (sal_Int32) floor( e.GetDouble() );
if( nDec < -20 || nDec > 20 )
{
- m_eError = CALC_OVERFLOW;
+ m_eError = SwCalcError::Overflow;
left.Clear();
return left;
}
@@ -1021,7 +1019,7 @@ SwSbxValue SwCalc::Term()
left.MakeDouble();
if( SbxDIV == eSbxOper && !aRight.GetDouble() )
- m_eError = CALC_ZERODIV;
+ m_eError = SwCalcError::DivByZero;
else
left.Compute( eSbxOper, aRight );
}
@@ -1037,7 +1035,7 @@ SwSbxValue SwCalc::StdFunc(pfCalc pFnc, bool bChkTrig)
if( !bChkTrig || ( nVal > -1 && nVal < 1 ) )
nErg.PutDouble( (*pFnc)( nVal ) );
else
- m_eError = CALC_OVERFLOW;
+ m_eError = SwCalcError::Overflow;
return nErg;
}
@@ -1104,7 +1102,7 @@ SwSbxValue SwCalc::PrimFunc(bool &rChkPow)
}
else if( m_eCurrOper == CALC_NAME )
{
- m_eError = CALC_SYNTAX;
+ m_eError = SwCalcError::Syntax;
}
else
{
@@ -1131,7 +1129,7 @@ SwSbxValue SwCalc::PrimFunc(bool &rChkPow)
// Explicitly disallow unknown function names (followed by "("),
// allow unknown variable names (equal to zero)
if (nErg.IsVoidValue() && (eOper == CALC_LP))
- m_eError = CALC_SYNTAX;
+ m_eError = SwCalcError::Syntax;
else
rChkPow = true;
break;
@@ -1153,7 +1151,7 @@ SwSbxValue SwCalc::PrimFunc(bool &rChkPow)
SwSbxValue nErg = Expr();
if( m_eCurrOper != CALC_RP )
{
- m_eError = CALC_BRACK;
+ m_eError = SwCalcError::FaultyBrackets;
}
else
{
@@ -1179,7 +1177,7 @@ SwSbxValue SwCalc::PrimFunc(bool &rChkPow)
GetToken();
SwSbxValue nErg = Prim();
if( nErg.GetDouble() < 0 )
- m_eError = CALC_OVERFLOW;
+ m_eError = SwCalcError::Overflow;
else
nErg.PutDouble( sqrt( nErg.GetDouble() ));
return nErg;
@@ -1203,7 +1201,7 @@ SwSbxValue SwCalc::PrimFunc(bool &rChkPow)
break;
}
default:
- m_eError = CALC_SYNTAX;
+ m_eError = SwCalcError::Syntax;
break;
}
@@ -1226,7 +1224,7 @@ SwSbxValue SwCalc::Prim()
if( ( dleft < 0.0 && 0.0 != fraction ) ||
( 0.0 == dleft && right < 0.0 ) )
{
- m_eError = CALC_OVERFLOW;
+ m_eError = SwCalcError::Overflow;
nErg.Clear();
}
else
@@ -1234,7 +1232,7 @@ SwSbxValue SwCalc::Prim()
dleft = pow(dleft, right );
if( dleft == HUGE_VAL )
{
- m_eError = CALC_POWERR;
+ m_eError = SwCalcError::OverflowInPower;
nErg.Clear();
}
else
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
index 85e28a8..1f4b074 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -736,7 +736,7 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt )
OSL_ENSURE(bResult,
"the chained formula could no be calculated");
}
- pCalc->SetCalcError( CALC_NOERR );
+ pCalc->SetCalcError( SwCalcError::NONE );
}
pFormatField->ModifyNotification( nullptr, pHt );
}
@@ -815,7 +815,7 @@ void DocumentFieldsManager::UpdateTableFields( SfxPoolItem* pHt )
aTmp.Put( SwTableBoxNumFormat( 0 ));
pFormat->SetFormatAttr( aTmp );
- pCalc->SetCalcError( CALC_NOERR );
+ pCalc->SetCalcError( SwCalcError::NONE );
}
}
}
diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx
index 79432e2..d45c070 100644
--- a/sw/source/core/fields/cellfml.cxx
+++ b/sw/source/core/fields/cellfml.cxx
@@ -78,7 +78,7 @@ double SwTableBox::GetValue( SwTableCalcPara& rCalcPara ) const
if( rCalcPara.rCalc.IsCalcError() )
return nRet; // stop if there is already an error set
- rCalcPara.rCalc.SetCalcError( CALC_SYNTAX ); // default: error
+ rCalcPara.rCalc.SetCalcError( SwCalcError::Syntax ); // default: error
// no content box?
if( !m_pStartNode )
@@ -106,7 +106,7 @@ double SwTableBox::GetValue( SwTableCalcPara& rCalcPara ) const
if( SfxItemState::SET == GetFrameFormat()->GetItemState(
RES_BOXATR_FORMULA, false, &pItem ) )
{
- rCalcPara.rCalc.SetCalcError( CALC_NOERR ); // reset status
+ rCalcPara.rCalc.SetCalcError( SwCalcError::NONE ); // reset status
if( !static_cast<const SwTableBoxFormula*>(pItem)->IsValid() )
{
// calculate
@@ -133,7 +133,7 @@ double SwTableBox::GetValue( SwTableCalcPara& rCalcPara ) const
else if( SfxItemState::SET == pBox->GetFrameFormat()->GetItemState(
RES_BOXATR_VALUE, false, &pItem ) )
{
- rCalcPara.rCalc.SetCalcError( CALC_NOERR ); // reset status
+ rCalcPara.rCalc.SetCalcError( SwCalcError::NONE ); // reset status
nRet = static_cast<const SwTableBoxValue*>(pItem)->GetValue();
break;
}
@@ -157,7 +157,7 @@ double SwTableBox::GetValue( SwTableCalcPara& rCalcPara ) const
}
if ( pTextField != nullptr )
{
- rCalcPara.rCalc.SetCalcError( CALC_NOERR ); // reset status
+ rCalcPara.rCalc.SetCalcError( SwCalcError::NONE ); // reset status
const SwField* pField = pTextField->GetFormatField().GetField();
switch ( pField->GetTyp()->Which() )
@@ -209,7 +209,7 @@ double SwTableBox::GetValue( SwTableCalcPara& rCalcPara ) const
else if ( Char != CH_TXTATR_BREAKWORD )
{
// result is 0 but no error!
- rCalcPara.rCalc.SetCalcError( CALC_NOERR ); // reset status
+ rCalcPara.rCalc.SetCalcError( SwCalcError::NONE ); // reset status
double aNum = 0.0;
sText = bOK ? sText.copy( nSttPos ) : OUString();
@@ -243,7 +243,7 @@ double SwTableBox::GetValue( SwTableCalcPara& rCalcPara ) const
//JP 12.01.99: error detection, Bug 60794
if( DBL_MAX == nRet )
- rCalcPara.rCalc.SetCalcError( CALC_SYNTAX ); // set error
+ rCalcPara.rCalc.SetCalcError( SwCalcError::Syntax ); // set error
return nRet;
}
@@ -272,7 +272,7 @@ bool SwTableCalcPara::CalcWithStackOverflow()
do {
SwTableBox* pBox = const_cast<SwTableBox*>(pLastTableBox);
nStackCnt = 0;
- rCalc.SetCalcError( CALC_NOERR );
+ rCalc.SetCalcError( SwCalcError::NONE );
aStackOverflows.insert( aStackOverflows.begin() + nCnt++, pBox );
pBoxStack->erase( pBox );
@@ -283,7 +283,7 @@ bool SwTableCalcPara::CalcWithStackOverflow()
// if recursion was detected
nStackCnt = 0;
- rCalc.SetCalcError( CALC_NOERR );
+ rCalc.SetCalcError( SwCalcError::NONE );
pBoxStack->clear();
while( !rCalc.IsCalcError() && nCnt )
@@ -372,7 +372,7 @@ void SwTableFormula::MakeFormula_( const SwTable& rTable, OUString& rNewStr,
}
}
else
- pCalcPara->rCalc.SetCalcError( CALC_SYNTAX ); // set error
+ pCalcPara->rCalc.SetCalcError( SwCalcError::Syntax ); // set error
rNewStr += " ";
}
diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx
index 77d12f28..ec7aee3 100644
--- a/sw/source/core/fields/usrfld.cxx
+++ b/sw/source/core/fields/usrfld.cxx
@@ -219,7 +219,7 @@ double SwUserFieldType::GetValue( SwCalc& rCalc )
if(!rCalc.Push( this ))
{
- rCalc.SetCalcError( CALC_SYNTAX );
+ rCalc.SetCalcError( SwCalcError::Syntax );
return 0;
}
nValue = rCalc.Calculate( aContent ).GetDouble();
diff --git a/sw/source/uibase/inc/utlui.hrc b/sw/source/uibase/inc/utlui.hrc
index e8b9bd1..d34c035 100644
--- a/sw/source/uibase/inc/utlui.hrc
+++ b/sw/source/uibase/inc/utlui.hrc
@@ -196,9 +196,9 @@
#define STR_CALC_ZERODIV (RID_SW_SHELLRES_BEGIN + 4)
#define STR_CALC_BRACK (RID_SW_SHELLRES_BEGIN + 5)
#define STR_CALC_POW (RID_SW_SHELLRES_BEGIN + 6)
-#define STR_CALC_VARNFND (RID_SW_SHELLRES_BEGIN + 7)
+// empty
#define STR_CALC_OVERFLOW (RID_SW_SHELLRES_BEGIN + 8)
-#define STR_CALC_WRONGTIME (RID_SW_SHELLRES_BEGIN + 9)
+// empty
#define STR_CALC_DEFAULT (RID_SW_SHELLRES_BEGIN + 10)
#define STR_CALC_ERROR (RID_SW_SHELLRES_BEGIN + 11)
#define STR_GETREFFLD_UP (RID_SW_SHELLRES_BEGIN + 12)
diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx
index 519019d..73265b6 100644
--- a/sw/source/uibase/utlui/initui.cxx
+++ b/sw/source/uibase/utlui/initui.cxx
@@ -182,9 +182,7 @@ ShellResource::ShellResource()
aCalc_ZeroDiv( SW_RES( STR_CALC_ZERODIV ) ),
aCalc_Brack( SW_RES( STR_CALC_BRACK ) ),
aCalc_Pow( SW_RES( STR_CALC_POW ) ),
- aCalc_VarNFnd( SW_RES( STR_CALC_VARNFND ) ),
aCalc_Overflow( SW_RES( STR_CALC_OVERFLOW ) ),
- aCalc_WrongTime( SW_RES( STR_CALC_WRONGTIME ) ),
aCalc_Default( SW_RES( STR_CALC_DEFAULT ) ),
aCalc_Error( SW_RES( STR_CALC_ERROR ) ),
diff --git a/sw/source/uibase/utlui/initui.src b/sw/source/uibase/utlui/initui.src
index 676dc10..1b06fec 100644
--- a/sw/source/uibase/utlui/initui.src
+++ b/sw/source/uibase/utlui/initui.src
@@ -51,18 +51,10 @@ String STR_CALC_POW
{
Text [ en-US ] = "** Square function overflow **" ;
};
-String STR_CALC_VARNFND
-{
- Text [ en-US ] = "** Variable not found **" ;
-};
String STR_CALC_OVERFLOW
{
Text [ en-US ] = "** Overflow **" ;
};
-String STR_CALC_WRONGTIME
-{
- Text [ en-US ] = "** Wrong time format **" ;
-};
String STR_CALC_DEFAULT
{
Text [ en-US ] = "** Error **" ;
More information about the Libreoffice-commits
mailing list