sw: prefix members of SwCalc

Change-Id: I8603ce669c09419919ba9fb93788666f45783caa
Reviewed-on: https://gerrit.libreoffice.org/27998
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
Miklos Vajna
2016-08-09 09:35:16 +02:00
parent 60cfbcf9e7
commit af5fe812c8
2 changed files with 180 additions and 180 deletions

View File

@@ -151,24 +151,24 @@ CalcOp* FindOperator( const OUString& rSearch );
class SwCalc class SwCalc
{ {
SwHash* VarTable[ TBLSZ ]; SwHash* m_aVarTable[ TBLSZ ];
OUString aVarName, sCurrSym; OUString m_aVarName, m_sCurrSym;
OUString sCommand; OUString m_sCommand;
std::vector<const SwUserFieldType*> aRekurStack; std::vector<const SwUserFieldType*> m_aRekurStack;
SwSbxValue nLastLeft; SwSbxValue m_nLastLeft;
SwSbxValue nNumberValue; SwSbxValue m_nNumberValue;
SwCalcExp aErrExpr; SwCalcExp m_aErrExpr;
sal_Int32 nCommandPos; sal_Int32 m_nCommandPos;
SwDoc& rDoc; SwDoc& m_rDoc;
SvtSysLocale m_aSysLocale; SvtSysLocale m_aSysLocale;
const LocaleDataWrapper* pLclData; const LocaleDataWrapper* m_pLocaleDataWrapper;
CharClass* pCharClass; CharClass* m_pCharClass;
sal_uInt16 nListPor; sal_uInt16 m_nListPor;
SwCalcOper eCurrOper; SwCalcOper m_eCurrOper;
SwCalcOper eCurrListOper; SwCalcOper m_eCurrListOper;
SwCalcError eError; SwCalcError m_eError;
SwCalcOper GetToken(); SwCalcOper GetToken();
SwSbxValue Expr(); SwSbxValue Expr();
@@ -193,13 +193,13 @@ public:
SwCalcExp* VarLook( const OUString &rStr, bool bIns = false ); SwCalcExp* VarLook( const OUString &rStr, bool bIns = false );
void VarChange( const OUString& rStr, const SwSbxValue& rValue ); void VarChange( const OUString& rStr, const SwSbxValue& rValue );
void VarChange( const OUString& rStr, double ); void VarChange( const OUString& rStr, double );
SwHash** GetVarTable() { return VarTable; } SwHash** GetVarTable() { return m_aVarTable; }
bool Push(const SwUserFieldType* pUserFieldType); bool Push(const SwUserFieldType* pUserFieldType);
void Pop(); void Pop();
void SetCalcError( SwCalcError eErr ) { eError = eErr; } void SetCalcError( SwCalcError eErr ) { m_eError = eErr; }
bool IsCalcError() const { return 0 != eError; } bool IsCalcError() const { return 0 != m_eError; }
static bool Str2Double( const OUString& rStr, sal_Int32& rPos, static bool Str2Double( const OUString& rStr, sal_Int32& rPos,
double& rVal ); double& rVal );

View File

@@ -230,30 +230,30 @@ static double lcl_ConvertToDateValue( SwDoc& rDoc, sal_Int32 nDate )
} }
SwCalc::SwCalc( SwDoc& rD ) SwCalc::SwCalc( SwDoc& rD )
: aErrExpr( OUString(), SwSbxValue(), nullptr ) : m_aErrExpr( OUString(), SwSbxValue(), nullptr )
, nCommandPos(0) , m_nCommandPos(0)
, rDoc( rD ) , m_rDoc( rD )
, pLclData( m_aSysLocale.GetLocaleDataPtr() ) , m_pLocaleDataWrapper( m_aSysLocale.GetLocaleDataPtr() )
, pCharClass( &GetAppCharClass() ) , m_pCharClass( &GetAppCharClass() )
, nListPor( 0 ) , m_nListPor( 0 )
, eCurrOper( CALC_NAME ) , m_eCurrOper( CALC_NAME )
, eCurrListOper( CALC_NAME ) , m_eCurrListOper( CALC_NAME )
, eError( CALC_NOERR ) , m_eError( CALC_NOERR )
{ {
aErrExpr.aStr = "~C_ERR~"; m_aErrExpr.aStr = "~C_ERR~";
memset( VarTable, 0, sizeof(VarTable) ); memset( m_aVarTable, 0, sizeof(m_aVarTable) );
LanguageType eLang = GetDocAppScriptLang( rDoc ); LanguageType eLang = GetDocAppScriptLang( m_rDoc );
if( eLang != pLclData->getLanguageTag().getLanguageType() || if( eLang != m_pLocaleDataWrapper->getLanguageTag().getLanguageType() ||
eLang != pCharClass->getLanguageTag().getLanguageType() ) eLang != m_pCharClass->getLanguageTag().getLanguageType() )
{ {
LanguageTag aLanguageTag( eLang ); LanguageTag aLanguageTag( eLang );
pCharClass = new CharClass( ::comphelper::getProcessComponentContext(), aLanguageTag ); m_pCharClass = new CharClass( ::comphelper::getProcessComponentContext(), aLanguageTag );
pLclData = new LocaleDataWrapper( aLanguageTag ); m_pLocaleDataWrapper = new LocaleDataWrapper( aLanguageTag );
} }
sCurrSym = comphelper::string::strip(pLclData->getCurrSymbol(), ' '); m_sCurrSym = comphelper::string::strip(m_pLocaleDataWrapper->getCurrSymbol(), ' ');
sCurrSym = pCharClass->lowercase( sCurrSym ); m_sCurrSym = m_pCharClass->lowercase( m_sCurrSym );
static sal_Char const static sal_Char const
sNType0[] = "false", sNType0[] = "false",
@@ -324,7 +324,7 @@ SwCalc::SwCalc( SwDoc& rD )
#error Did you adjust all hash values? #error Did you adjust all hash values?
#endif #endif
const SwDocStat& rDocStat = rDoc.getIDocumentStatistics().GetDocStat(); const SwDocStat& rDocStat = m_rDoc.getIDocumentStatistics().GetDocStat();
SwSbxValue nVal; SwSbxValue nVal;
OUString sTmpStr; OUString sTmpStr;
@@ -333,64 +333,64 @@ SwCalc::SwCalc( SwDoc& rD )
for( n = 0; n < 25; ++n ) for( n = 0; n < 25; ++n )
{ {
sTmpStr = OUString::createFromAscii(sNTypeTab[n]); sTmpStr = OUString::createFromAscii(sNTypeTab[n]);
VarTable[ aHashValue[ n ] ] = new SwCalcExp( sTmpStr, nVal, nullptr ); m_aVarTable[ aHashValue[ n ] ] = new SwCalcExp( sTmpStr, nVal, nullptr );
} }
static_cast<SwCalcExp*>(VarTable[ aHashValue[ 0 ] ])->nValue.PutBool( false ); static_cast<SwCalcExp*>(m_aVarTable[ aHashValue[ 0 ] ])->nValue.PutBool( false );
static_cast<SwCalcExp*>(VarTable[ aHashValue[ 1 ] ])->nValue.PutBool( true ); static_cast<SwCalcExp*>(m_aVarTable[ aHashValue[ 1 ] ])->nValue.PutBool( true );
static_cast<SwCalcExp*>(VarTable[ aHashValue[ 2 ] ])->nValue.PutDouble( F_PI ); static_cast<SwCalcExp*>(m_aVarTable[ aHashValue[ 2 ] ])->nValue.PutDouble( F_PI );
static_cast<SwCalcExp*>(VarTable[ aHashValue[ 3 ] ])->nValue.PutDouble( 2.7182818284590452354 ); static_cast<SwCalcExp*>(m_aVarTable[ aHashValue[ 3 ] ])->nValue.PutDouble( 2.7182818284590452354 );
for( n = 0; n < 3; ++n ) for( n = 0; n < 3; ++n )
static_cast<SwCalcExp*>(VarTable[ aHashValue[ n + 4 ] ])->nValue.PutLong( rDocStat.*aDocStat1[ n ] ); static_cast<SwCalcExp*>(m_aVarTable[ aHashValue[ n + 4 ] ])->nValue.PutLong( rDocStat.*aDocStat1[ n ] );
for( n = 0; n < 4; ++n ) for( n = 0; n < 4; ++n )
static_cast<SwCalcExp*>(VarTable[ aHashValue[ n + 7 ] ])->nValue.PutLong( rDocStat.*aDocStat2[ n ] ); static_cast<SwCalcExp*>(m_aVarTable[ aHashValue[ n + 7 ] ])->nValue.PutLong( rDocStat.*aDocStat2[ n ] );
SvtUserOptions& rUserOptions = SW_MOD()->GetUserOptions(); SvtUserOptions& rUserOptions = SW_MOD()->GetUserOptions();
static_cast<SwCalcExp*>(VarTable[ aHashValue[ 11 ] ])->nValue.PutString( rUserOptions.GetFirstName() ); static_cast<SwCalcExp*>(m_aVarTable[ aHashValue[ 11 ] ])->nValue.PutString( rUserOptions.GetFirstName() );
static_cast<SwCalcExp*>(VarTable[ aHashValue[ 12 ] ])->nValue.PutString( rUserOptions.GetLastName() ); static_cast<SwCalcExp*>(m_aVarTable[ aHashValue[ 12 ] ])->nValue.PutString( rUserOptions.GetLastName() );
static_cast<SwCalcExp*>(VarTable[ aHashValue[ 13 ] ])->nValue.PutString( rUserOptions.GetID() ); static_cast<SwCalcExp*>(m_aVarTable[ aHashValue[ 13 ] ])->nValue.PutString( rUserOptions.GetID() );
for( n = 0; n < 11; ++n ) for( n = 0; n < 11; ++n )
static_cast<SwCalcExp*>(VarTable[ aHashValue[ n + 14 ] ])->nValue.PutString( static_cast<SwCalcExp*>(m_aVarTable[ aHashValue[ n + 14 ] ])->nValue.PutString(
rUserOptions.GetToken( aAdrToken[ n ] )); rUserOptions.GetToken( aAdrToken[ n ] ));
nVal.PutString( rUserOptions.GetToken( aAdrToken[ 11 ] )); nVal.PutString( rUserOptions.GetToken( aAdrToken[ 11 ] ));
sTmpStr = OUString::createFromAscii(sNTypeTab[25]); sTmpStr = OUString::createFromAscii(sNTypeTab[25]);
VarTable[ aHashValue[ 25 ] ]->pNext = new SwCalcExp( sTmpStr, nVal, nullptr ); m_aVarTable[ aHashValue[ 25 ] ]->pNext = new SwCalcExp( sTmpStr, nVal, nullptr );
} // SwCalc::SwCalc } // SwCalc::SwCalc
SwCalc::~SwCalc() SwCalc::~SwCalc()
{ {
for(SwHash* p : VarTable) for(SwHash* p : m_aVarTable)
delete p; delete p;
if( pLclData != m_aSysLocale.GetLocaleDataPtr() ) if( m_pLocaleDataWrapper != m_aSysLocale.GetLocaleDataPtr() )
delete pLclData; delete m_pLocaleDataWrapper;
if( pCharClass != &GetAppCharClass() ) if( m_pCharClass != &GetAppCharClass() )
delete pCharClass; delete m_pCharClass;
} }
SwSbxValue SwCalc::Calculate( const OUString& rStr ) SwSbxValue SwCalc::Calculate( const OUString& rStr )
{ {
eError = CALC_NOERR; m_eError = CALC_NOERR;
SwSbxValue nResult; SwSbxValue nResult;
if( rStr.isEmpty() ) if( rStr.isEmpty() )
return nResult; return nResult;
nListPor = 0; m_nListPor = 0;
eCurrListOper = CALC_PLUS; // default: sum m_eCurrListOper = CALC_PLUS; // default: sum
sCommand = rStr; m_sCommand = rStr;
nCommandPos = 0; m_nCommandPos = 0;
while( (eCurrOper = GetToken()) != CALC_ENDCALC && eError == CALC_NOERR ) while( (m_eCurrOper = GetToken()) != CALC_ENDCALC && m_eError == CALC_NOERR )
nResult = Expr(); nResult = Expr();
if( eError ) if( m_eError )
nResult.PutDouble( DBL_MAX ); nResult.PutDouble( DBL_MAX );
return nResult; return nResult;
@@ -408,7 +408,7 @@ OUString SwCalc::GetStrResult( const SwSbxValue& rVal )
OUString SwCalc::GetStrResult( double nValue, bool ) OUString SwCalc::GetStrResult( double nValue, bool )
{ {
if( nValue >= DBL_MAX ) if( nValue >= DBL_MAX )
switch( eError ) switch( m_eError )
{ {
case CALC_SYNTAX : return RESOURCE->aCalc_Syntax; case CALC_SYNTAX : return RESOURCE->aCalc_Syntax;
case CALC_ZERODIV : return RESOURCE->aCalc_ZeroDiv; case CALC_ZERODIV : return RESOURCE->aCalc_ZeroDiv;
@@ -425,30 +425,30 @@ OUString SwCalc::GetStrResult( double nValue, bool )
nValue, nValue,
rtl_math_StringFormat_Automatic, rtl_math_StringFormat_Automatic,
nDecPlaces, nDecPlaces,
pLclData->getNumDecimalSep()[0], m_pLocaleDataWrapper->getNumDecimalSep()[0],
true )); true ));
return aRetStr; return aRetStr;
} }
SwCalcExp* SwCalc::VarInsert( const OUString &rStr ) SwCalcExp* SwCalc::VarInsert( const OUString &rStr )
{ {
OUString aStr = pCharClass->lowercase( rStr ); OUString aStr = m_pCharClass->lowercase( rStr );
return VarLook( aStr, true ); return VarLook( aStr, true );
} }
SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns ) SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns )
{ {
aErrExpr.nValue.SetVoidValue(false); m_aErrExpr.nValue.SetVoidValue(false);
sal_uInt16 ii = 0; sal_uInt16 ii = 0;
OUString aStr = pCharClass->lowercase( rStr ); OUString aStr = m_pCharClass->lowercase( rStr );
SwHash* pFnd = Find( aStr, VarTable, TBLSZ, &ii ); SwHash* pFnd = Find( aStr, m_aVarTable, TBLSZ, &ii );
if( !pFnd ) if( !pFnd )
{ {
// then check doc // then check doc
SwHash* const * ppDocTable = rDoc.getIDocumentFieldsAccess().GetUpdateFields().GetFieldTypeTable(); SwHash* const * ppDocTable = m_rDoc.getIDocumentFieldsAccess().GetUpdateFields().GetFieldTypeTable();
for( SwHash* pEntry = *(ppDocTable+ii); pEntry; pEntry = pEntry->pNext ) for( SwHash* pEntry = *(ppDocTable+ii); pEntry; pEntry = pEntry->pNext )
{ {
if( aStr == pEntry->aStr ) if( aStr == pEntry->aStr )
@@ -456,8 +456,8 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns )
// then insert here // then insert here
pFnd = new SwCalcExp( aStr, SwSbxValue(), pFnd = new SwCalcExp( aStr, SwSbxValue(),
static_cast<SwCalcFieldType*>(pEntry)->pFieldType ); static_cast<SwCalcFieldType*>(pEntry)->pFieldType );
pFnd->pNext = *(VarTable+ii); pFnd->pNext = *(m_aVarTable+ii);
*(VarTable+ii) = pFnd; *(m_aVarTable+ii) = pFnd;
break; break;
} }
} }
@@ -477,22 +477,22 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns )
else if( !pUField->IsValid() ) else if( !pUField->IsValid() )
{ {
// Save the current values... // Save the current values...
sal_uInt16 nOld_ListPor = nListPor; sal_uInt16 nListPor = m_nListPor;
SwSbxValue nOld_LastLeft = nLastLeft; SwSbxValue nLastLeft = m_nLastLeft;
SwSbxValue nOld_NumberValue = nNumberValue; SwSbxValue nNumberValue = m_nNumberValue;
sal_Int32 nOld_CommandPos = nCommandPos; sal_Int32 nCommandPos = m_nCommandPos;
SwCalcOper eOld_CurrOper = eCurrOper; SwCalcOper eCurrOper = m_eCurrOper;
SwCalcOper eOld_CurrListOper = eCurrListOper; SwCalcOper eCurrListOper = m_eCurrListOper;
pFndExp->nValue.PutDouble( pUField->GetValue( *this ) ); pFndExp->nValue.PutDouble( pUField->GetValue( *this ) );
// ...and write them back. // ...and write them back.
nListPor = nOld_ListPor; m_nListPor = nListPor;
nLastLeft = nOld_LastLeft; m_nLastLeft = nLastLeft;
nNumberValue = nOld_NumberValue; m_nNumberValue = nNumberValue;
nCommandPos = nOld_CommandPos; m_nCommandPos = nCommandPos;
eCurrOper = eOld_CurrOper; m_eCurrOper = eCurrOper;
eCurrListOper = eOld_CurrListOper; m_eCurrListOper = eCurrListOper;
} }
else else
{ {
@@ -508,7 +508,7 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns )
if( !bIns ) if( !bIns )
{ {
#if HAVE_FEATURE_DBCONNECTIVITY #if HAVE_FEATURE_DBCONNECTIVITY
SwDBManager *pMgr = rDoc.GetDBManager(); SwDBManager *pMgr = m_rDoc.GetDBManager();
OUString sDBName(GetDBName( sTmpName )); OUString sDBName(GetDBName( sTmpName ));
OUString sSourceName(sDBName.getToken(0, DB_DELIM)); OUString sSourceName(sDBName.getToken(0, DB_DELIM));
@@ -520,7 +520,7 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns )
OSL_ENSURE(!sColumnName.isEmpty(), "Missing DB column name"); OSL_ENSURE(!sColumnName.isEmpty(), "Missing DB column name");
OUString sDBNum( SwFieldType::GetTypeStr(TYP_DBSETNUMBERFLD) ); OUString sDBNum( SwFieldType::GetTypeStr(TYP_DBSETNUMBERFLD) );
sDBNum = pCharClass->lowercase(sDBNum); sDBNum = m_pCharClass->lowercase(sDBNum);
// Initialize again because this doesn't happen in docfld anymore for // Initialize again because this doesn't happen in docfld anymore for
// elements != RES_DBFLD. E.g. if there is an expression field before // elements != RES_DBFLD. E.g. if there is an expression field before
@@ -529,42 +529,42 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns )
if( sDBNum.equalsIgnoreAsciiCase(sColumnName) ) if( sDBNum.equalsIgnoreAsciiCase(sColumnName) )
{ {
aErrExpr.nValue.PutLong(long(pMgr->GetSelectedRecordId(sSourceName, sTableName))); m_aErrExpr.nValue.PutLong(long(pMgr->GetSelectedRecordId(sSourceName, sTableName)));
return &aErrExpr; return &m_aErrExpr;
} }
sal_uLong nTmpRec = 0; sal_uLong nTmpRec = 0;
if( nullptr != ( pFnd = Find( sDBNum, VarTable, TBLSZ ) ) ) if( nullptr != ( pFnd = Find( sDBNum, m_aVarTable, TBLSZ ) ) )
nTmpRec = static_cast<SwCalcExp*>(pFnd)->nValue.GetULong(); nTmpRec = static_cast<SwCalcExp*>(pFnd)->nValue.GetULong();
OUString sResult; OUString sResult;
double nNumber = DBL_MAX; double nNumber = DBL_MAX;
long nLang = pLclData->getLanguageTag().getLanguageType(); long nLang = m_pLocaleDataWrapper->getLanguageTag().getLanguageType();
if(pMgr->GetColumnCnt( sSourceName, sTableName, sColumnName, if(pMgr->GetColumnCnt( sSourceName, sTableName, sColumnName,
nTmpRec, nLang, sResult, &nNumber )) nTmpRec, nLang, sResult, &nNumber ))
{ {
if (nNumber != DBL_MAX) if (nNumber != DBL_MAX)
aErrExpr.nValue.PutDouble( nNumber ); m_aErrExpr.nValue.PutDouble( nNumber );
else else
aErrExpr.nValue.PutString( sResult ); m_aErrExpr.nValue.PutString( sResult );
return &aErrExpr; return &m_aErrExpr;
} }
} }
else else
#endif #endif
{ {
//data source was not available - set return to "NoValue" //data source was not available - set return to "NoValue"
aErrExpr.nValue.SetVoidValue(true); m_aErrExpr.nValue.SetVoidValue(true);
} }
// NEVER save! // NEVER save!
return &aErrExpr; return &m_aErrExpr;
} }
SwCalcExp* pNewExp = new SwCalcExp( aStr, SwSbxValue(), nullptr ); SwCalcExp* pNewExp = new SwCalcExp( aStr, SwSbxValue(), nullptr );
pNewExp->pNext = VarTable[ ii ]; pNewExp->pNext = m_aVarTable[ ii ];
VarTable[ ii ] = pNewExp; m_aVarTable[ ii ] = pNewExp;
OUString sColumnName( GetColumnName( sTmpName )); OUString sColumnName( GetColumnName( sTmpName ));
OSL_ENSURE( !sColumnName.isEmpty(), "Missing DB column name" ); OSL_ENSURE( !sColumnName.isEmpty(), "Missing DB column name" );
@@ -572,7 +572,7 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns )
SwFieldType::GetTypeStr( TYP_DBSETNUMBERFLD ) )) SwFieldType::GetTypeStr( TYP_DBSETNUMBERFLD ) ))
{ {
#if HAVE_FEATURE_DBCONNECTIVITY #if HAVE_FEATURE_DBCONNECTIVITY
SwDBManager *pMgr = rDoc.GetDBManager(); SwDBManager *pMgr = m_rDoc.GetDBManager();
OUString sDBName(GetDBName( sTmpName )); OUString sDBName(GetDBName( sTmpName ));
OUString sSourceName(sDBName.getToken(0, DB_DELIM)); OUString sSourceName(sDBName.getToken(0, DB_DELIM));
OUString sTableName(sDBName.getToken(0, ';').getToken(1, DB_DELIM)); OUString sTableName(sDBName.getToken(0, ';').getToken(1, DB_DELIM));
@@ -600,16 +600,16 @@ void SwCalc::VarChange( const OUString& rStr, double nValue )
void SwCalc::VarChange( const OUString& rStr, const SwSbxValue& rValue ) void SwCalc::VarChange( const OUString& rStr, const SwSbxValue& rValue )
{ {
OUString aStr = pCharClass->lowercase( rStr ); OUString aStr = m_pCharClass->lowercase( rStr );
sal_uInt16 nPos = 0; sal_uInt16 nPos = 0;
SwCalcExp* pFnd = static_cast<SwCalcExp*>(Find( aStr, VarTable, TBLSZ, &nPos )); SwCalcExp* pFnd = static_cast<SwCalcExp*>(Find( aStr, m_aVarTable, TBLSZ, &nPos ));
if( !pFnd ) if( !pFnd )
{ {
pFnd = new SwCalcExp( aStr, SwSbxValue( rValue ), nullptr ); pFnd = new SwCalcExp( aStr, SwSbxValue( rValue ), nullptr );
pFnd->pNext = VarTable[ nPos ]; pFnd->pNext = m_aVarTable[ nPos ];
VarTable[ nPos ] = pFnd; m_aVarTable[ nPos ] = pFnd;
} }
else else
{ {
@@ -619,18 +619,18 @@ void SwCalc::VarChange( const OUString& rStr, const SwSbxValue& rValue )
bool SwCalc::Push( const SwUserFieldType* pUserFieldType ) bool SwCalc::Push( const SwUserFieldType* pUserFieldType )
{ {
if( aRekurStack.end() != std::find(aRekurStack.begin(), aRekurStack.end(), pUserFieldType ) ) if( m_aRekurStack.end() != std::find(m_aRekurStack.begin(), m_aRekurStack.end(), pUserFieldType ) )
return false; return false;
aRekurStack.push_back( pUserFieldType ); m_aRekurStack.push_back( pUserFieldType );
return true; return true;
} }
void SwCalc::Pop() void SwCalc::Pop()
{ {
OSL_ENSURE( aRekurStack.size(), "SwCalc: Pop on an invalid pointer" ); OSL_ENSURE( m_aRekurStack.size(), "SwCalc: Pop on an invalid pointer" );
aRekurStack.pop_back(); m_aRekurStack.pop_back();
} }
SwCalcOper SwCalc::GetToken() SwCalcOper SwCalc::GetToken()
@@ -643,36 +643,36 @@ SwCalcOper SwCalc::GetToken()
{ {
#endif #endif
if( nCommandPos >= sCommand.getLength() ) if( m_nCommandPos >= m_sCommand.getLength() )
return eCurrOper = CALC_ENDCALC; return m_eCurrOper = CALC_ENDCALC;
using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::i18n;
{ {
// Parse any token. // Parse any token.
ParseResult aRes = pCharClass->parseAnyToken( sCommand, nCommandPos, ParseResult aRes = m_pCharClass->parseAnyToken( m_sCommand, m_nCommandPos,
coStartFlags, OUString(), coStartFlags, OUString(),
coContFlags, OUString()); coContFlags, OUString());
bool bSetError = true; bool bSetError = true;
sal_Int32 nRealStt = nCommandPos + aRes.LeadingWhiteSpace; sal_Int32 nRealStt = m_nCommandPos + aRes.LeadingWhiteSpace;
if( aRes.TokenType & (KParseType::ASC_NUMBER | KParseType::UNI_NUMBER) ) if( aRes.TokenType & (KParseType::ASC_NUMBER | KParseType::UNI_NUMBER) )
{ {
nNumberValue.PutDouble( aRes.Value ); m_nNumberValue.PutDouble( aRes.Value );
eCurrOper = CALC_NUMBER; m_eCurrOper = CALC_NUMBER;
bSetError = false; bSetError = false;
} }
else if( aRes.TokenType & KParseType::IDENTNAME ) else if( aRes.TokenType & KParseType::IDENTNAME )
{ {
OUString aName( sCommand.copy( nRealStt, OUString aName( m_sCommand.copy( nRealStt,
aRes.EndPos - nRealStt ) ); aRes.EndPos - nRealStt ) );
//#101436#: The variable may contain a database name. It must not be //#101436#: The variable may contain a database name. It must not be
// converted to lower case! Instead all further comparisons must be // converted to lower case! Instead all further comparisons must be
// done case-insensitive // done case-insensitive
OUString sLowerCaseName = pCharClass->lowercase( aName ); OUString sLowerCaseName = m_pCharClass->lowercase( aName );
// catch currency symbol // catch currency symbol
if( sLowerCaseName == sCurrSym ) if( sLowerCaseName == m_sCurrSym )
{ {
nCommandPos = aRes.EndPos; m_nCommandPos = aRes.EndPos;
return GetToken(); // call again return GetToken(); // call again
} }
@@ -680,40 +680,40 @@ SwCalcOper SwCalc::GetToken()
CalcOp* pFnd = ::FindOperator( sLowerCaseName ); CalcOp* pFnd = ::FindOperator( sLowerCaseName );
if( pFnd ) if( pFnd )
{ {
switch( ( eCurrOper = pFnd->eOp ) ) switch( ( m_eCurrOper = pFnd->eOp ) )
{ {
case CALC_SUM: case CALC_SUM:
case CALC_MEAN: case CALC_MEAN:
eCurrListOper = CALC_PLUS; m_eCurrListOper = CALC_PLUS;
break; break;
case CALC_MIN: case CALC_MIN:
eCurrListOper = CALC_MIN_IN; m_eCurrListOper = CALC_MIN_IN;
break; break;
case CALC_MAX: case CALC_MAX:
eCurrListOper = CALC_MAX_IN; m_eCurrListOper = CALC_MAX_IN;
break; break;
case CALC_DATE: case CALC_DATE:
eCurrListOper = CALC_MONTH; m_eCurrListOper = CALC_MONTH;
break; break;
default: default:
break; break;
} }
nCommandPos = aRes.EndPos; m_nCommandPos = aRes.EndPos;
return eCurrOper; return m_eCurrOper;
} }
aVarName = aName; m_aVarName = aName;
eCurrOper = CALC_NAME; m_eCurrOper = CALC_NAME;
bSetError = false; bSetError = false;
} }
else if ( aRes.TokenType & KParseType::DOUBLE_QUOTE_STRING ) else if ( aRes.TokenType & KParseType::DOUBLE_QUOTE_STRING )
{ {
nNumberValue.PutString( aRes.DequotedNameOrString ); m_nNumberValue.PutString( aRes.DequotedNameOrString );
eCurrOper = CALC_NUMBER; m_eCurrOper = CALC_NUMBER;
bSetError = false; bSetError = false;
} }
else if( aRes.TokenType & KParseType::ONE_SINGLE_CHAR ) else if( aRes.TokenType & KParseType::ONE_SINGLE_CHAR )
{ {
OUString aName( sCommand.copy( nRealStt, OUString aName( m_sCommand.copy( nRealStt,
aRes.EndPos - nRealStt )); aRes.EndPos - nRealStt ));
if( 1 == aName.getLength() ) if( 1 == aName.getLength() )
{ {
@@ -722,14 +722,14 @@ SwCalcOper SwCalc::GetToken()
switch( ch ) switch( ch )
{ {
case ';': case ';':
if( CALC_MONTH == eCurrListOper || CALC_DAY == eCurrListOper ) if( CALC_MONTH == m_eCurrListOper || CALC_DAY == m_eCurrListOper )
{ {
eCurrOper = eCurrListOper; m_eCurrOper = m_eCurrListOper;
break; break;
} }
SAL_FALLTHROUGH; SAL_FALLTHROUGH;
case '\n': case '\n':
eCurrOper = CALC_PRINT; m_eCurrOper = CALC_PRINT;
break; break;
case '%': case '%':
@@ -740,7 +740,7 @@ SwCalcOper SwCalc::GetToken()
case '-': case '-':
case '(': case '(':
case ')': case ')':
eCurrOper = SwCalcOper(ch); m_eCurrOper = SwCalcOper(ch);
break; break;
case '=': case '=':
@@ -749,43 +749,43 @@ SwCalcOper SwCalc::GetToken()
SwCalcOper eTmp2; SwCalcOper eTmp2;
if( '=' == ch ) if( '=' == ch )
{ {
eCurrOper = SwCalcOper('='); m_eCurrOper = SwCalcOper('=');
eTmp2 = CALC_EQ; eTmp2 = CALC_EQ;
} }
else else
{ {
eCurrOper = CALC_NOT; m_eCurrOper = CALC_NOT;
eTmp2 = CALC_NEQ; eTmp2 = CALC_NEQ;
} }
if( aRes.EndPos < sCommand.getLength() && if( aRes.EndPos < m_sCommand.getLength() &&
'=' == sCommand[aRes.EndPos] ) '=' == m_sCommand[aRes.EndPos] )
{ {
eCurrOper = eTmp2; m_eCurrOper = eTmp2;
++aRes.EndPos; ++aRes.EndPos;
} }
} }
break; break;
case cListDelim: case cListDelim:
eCurrOper = eCurrListOper; m_eCurrOper = m_eCurrListOper;
break; break;
case '[': case '[':
if( aRes.EndPos < sCommand.getLength() ) if( aRes.EndPos < m_sCommand.getLength() )
{ {
aVarName.clear(); m_aVarName.clear();
sal_Int32 nFndPos = aRes.EndPos, sal_Int32 nFndPos = aRes.EndPos,
nSttPos = nFndPos; nSttPos = nFndPos;
do { do {
if( -1 != ( nFndPos = if( -1 != ( nFndPos =
sCommand.indexOf( ']', nFndPos )) ) m_sCommand.indexOf( ']', nFndPos )) )
{ {
// ignore the ] // ignore the ]
if ('\\' == sCommand[nFndPos-1]) if ('\\' == m_sCommand[nFndPos-1])
{ {
aVarName += sCommand.copy( nSttPos, m_aVarName += m_sCommand.copy( nSttPos,
nFndPos - nSttPos - 1 ); nFndPos - nSttPos - 1 );
nSttPos = ++nFndPos; nSttPos = ++nFndPos;
} }
@@ -797,10 +797,10 @@ SwCalcOper SwCalc::GetToken()
if( nFndPos != -1 ) if( nFndPos != -1 )
{ {
if( nSttPos != nFndPos ) if( nSttPos != nFndPos )
aVarName += sCommand.copy( nSttPos, m_aVarName += m_sCommand.copy( nSttPos,
nFndPos - nSttPos ); nFndPos - nSttPos );
aRes.EndPos = nFndPos + 1; aRes.EndPos = nFndPos + 1;
eCurrOper = CALC_NAME; m_eCurrOper = CALC_NAME;
} }
else else
bSetError = true; bSetError = true;
@@ -819,7 +819,7 @@ SwCalcOper SwCalc::GetToken()
} }
else if( aRes.TokenType & KParseType::BOOLEAN ) else if( aRes.TokenType & KParseType::BOOLEAN )
{ {
OUString aName( sCommand.copy( nRealStt, OUString aName( m_sCommand.copy( nRealStt,
aRes.EndPos - nRealStt )); aRes.EndPos - nRealStt ));
if( !aName.isEmpty() ) if( !aName.isEmpty() )
{ {
@@ -831,27 +831,27 @@ SwCalcOper SwCalc::GetToken()
bSetError = false; bSetError = false;
SwCalcOper eTmp2 = ('<' == ch) ? CALC_LEQ : CALC_GEQ; SwCalcOper eTmp2 = ('<' == ch) ? CALC_LEQ : CALC_GEQ;
eCurrOper = ('<' == ch) ? CALC_LES : CALC_GRE; m_eCurrOper = ('<' == ch) ? CALC_LES : CALC_GRE;
if( 2 == aName.getLength() && '=' == aName[1] ) if( 2 == aName.getLength() && '=' == aName[1] )
eCurrOper = eTmp2; m_eCurrOper = eTmp2;
else if( 1 != aName.getLength() ) else if( 1 != aName.getLength() )
bSetError = true; bSetError = true;
} }
} }
} }
else if( nRealStt == sCommand.getLength() ) else if( nRealStt == m_sCommand.getLength() )
{ {
eCurrOper = CALC_ENDCALC; m_eCurrOper = CALC_ENDCALC;
bSetError = false; bSetError = false;
} }
if( bSetError ) if( bSetError )
{ {
eError = CALC_SYNTAX; m_eError = CALC_SYNTAX;
eCurrOper = CALC_PRINT; m_eCurrOper = CALC_PRINT;
} }
nCommandPos = aRes.EndPos; m_nCommandPos = aRes.EndPos;
}; };
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
@@ -1069,18 +1069,18 @@ SwCalcOper SwCalc::GetToken()
} }
} }
#endif #endif
return eCurrOper; return m_eCurrOper;
} }
SwSbxValue SwCalc::Term() SwSbxValue SwCalc::Term()
{ {
SwSbxValue left( Prim() ); SwSbxValue left( Prim() );
nLastLeft = left; m_nLastLeft = left;
for(;;) for(;;)
{ {
sal_uInt16 nSbxOper = USHRT_MAX; sal_uInt16 nSbxOper = USHRT_MAX;
switch( eCurrOper ) switch( m_eCurrOper )
{ {
case CALC_AND: case CALC_AND:
{ {
@@ -1138,7 +1138,7 @@ SwSbxValue SwCalc::Term()
sal_Int32 nMonth = (sal_Int32) floor( e.GetDouble() ); sal_Int32 nMonth = (sal_Int32) floor( e.GetDouble() );
nMonth = ( nMonth & 0x000000FF ) << 16; nMonth = ( nMonth & 0x000000FF ) << 16;
left.PutLong( nMonth + nYear ); left.PutLong( nMonth + nYear );
eCurrOper = CALC_DAY; m_eCurrOper = CALC_DAY;
} }
break; break;
case CALC_DAY: case CALC_DAY:
@@ -1149,7 +1149,7 @@ SwSbxValue SwCalc::Term()
nYearMonth = nYearMonth & 0x00FFFFFF; nYearMonth = nYearMonth & 0x00FFFFFF;
sal_Int32 nDay = (sal_Int32) floor( e.GetDouble() ); sal_Int32 nDay = (sal_Int32) floor( e.GetDouble() );
nDay = ( nDay & 0x000000FF ) << 24; nDay = ( nDay & 0x000000FF ) << 24;
left = lcl_ConvertToDateValue( rDoc, nDay + nYearMonth ); left = lcl_ConvertToDateValue( m_rDoc, nDay + nYearMonth );
} }
break; break;
case CALC_ROUND: case CALC_ROUND:
@@ -1162,7 +1162,7 @@ SwSbxValue SwCalc::Term()
sal_Int32 nDec = (sal_Int32) floor( e.GetDouble() ); sal_Int32 nDec = (sal_Int32) floor( e.GetDouble() );
if( nDec < -20 || nDec > 20 ) if( nDec < -20 || nDec > 20 )
{ {
eError = CALC_OVERFLOW; m_eError = CALC_OVERFLOW;
left.Clear(); left.Clear();
return left; return left;
} }
@@ -1245,7 +1245,7 @@ SwSbxValue SwCalc::Term()
left.MakeDouble(); left.MakeDouble();
if( SbxDIV == eSbxOper && !aRight.GetDouble() ) if( SbxDIV == eSbxOper && !aRight.GetDouble() )
eError = CALC_ZERODIV; m_eError = CALC_ZERODIV;
else else
left.Compute( eSbxOper, aRight ); left.Compute( eSbxOper, aRight );
} }
@@ -1263,7 +1263,7 @@ SwSbxValue SwCalc::Prim()
bool bChkTrig = false, bChkPow = false; bool bChkTrig = false, bChkPow = false;
switch( eCurrOper ) switch( m_eCurrOper )
{ {
case CALC_SIN: pFnc = &sin; break; case CALC_SIN: pFnc = &sin; break;
case CALC_COS: pFnc = &cos; break; case CALC_COS: pFnc = &cos; break;
@@ -1302,18 +1302,18 @@ SwSbxValue SwCalc::Prim()
case CALC_NUMBER: case CALC_NUMBER:
if( GetToken() == CALC_PHD ) if( GetToken() == CALC_PHD )
{ {
double aTmp = nNumberValue.GetDouble(); double aTmp = m_nNumberValue.GetDouble();
aTmp *= 0.01; aTmp *= 0.01;
nErg.PutDouble( aTmp ); nErg.PutDouble( aTmp );
GetToken(); GetToken();
} }
else if( eCurrOper == CALC_NAME ) else if( m_eCurrOper == CALC_NAME )
{ {
eError = CALC_SYNTAX; m_eError = CALC_SYNTAX;
} }
else else
{ {
nErg = nNumberValue; nErg = m_nNumberValue;
bChkPow = true; bChkPow = true;
} }
break; break;
@@ -1323,17 +1323,17 @@ SwSbxValue SwCalc::Prim()
{ {
case CALC_ASSIGN: case CALC_ASSIGN:
{ {
SwCalcExp* n = VarInsert(aVarName); SwCalcExp* n = VarInsert(m_aVarName);
GetToken(); GetToken();
nErg = n->nValue = Expr(); nErg = n->nValue = Expr();
} }
break; break;
default: default:
nErg = VarLook(aVarName)->nValue; nErg = VarLook(m_aVarName)->nValue;
// Explicitly disallow unknown function names (followed by "("), // Explicitly disallow unknown function names (followed by "("),
// allow unknown variable names (equal to zero) // allow unknown variable names (equal to zero)
if (nErg.IsVoidValue() && (eOper == CALC_LP)) if (nErg.IsVoidValue() && (eOper == CALC_LP))
eError = CALC_SYNTAX; m_eError = CALC_SYNTAX;
else else
bChkPow = true; bChkPow = true;
} }
@@ -1348,9 +1348,9 @@ SwSbxValue SwCalc::Prim()
{ {
GetToken(); GetToken();
nErg = Expr(); nErg = Expr();
if( eCurrOper != CALC_RP ) if( m_eCurrOper != CALC_RP )
{ {
eError = CALC_BRACK; m_eError = CALC_BRACK;
} }
else else
{ {
@@ -1362,11 +1362,11 @@ SwSbxValue SwCalc::Prim()
case CALC_MEAN: case CALC_MEAN:
{ {
nListPor = 1; m_nListPor = 1;
GetToken(); GetToken();
nErg = Expr(); nErg = Expr();
double aTmp = nErg.GetDouble(); double aTmp = nErg.GetDouble();
aTmp /= nListPor; aTmp /= m_nListPor;
nErg.PutDouble( aTmp ); nErg.PutDouble( aTmp );
} }
break; break;
@@ -1376,7 +1376,7 @@ SwSbxValue SwCalc::Prim()
GetToken(); GetToken();
nErg = Prim(); nErg = Prim();
if( nErg.GetDouble() < 0 ) if( nErg.GetDouble() < 0 )
eError = CALC_OVERFLOW; m_eError = CALC_OVERFLOW;
else else
nErg.PutDouble( sqrt( nErg.GetDouble() )); nErg.PutDouble( sqrt( nErg.GetDouble() ));
} }
@@ -1395,7 +1395,7 @@ SwSbxValue SwCalc::Prim()
break; break;
default: default:
eError = CALC_SYNTAX; m_eError = CALC_SYNTAX;
break; break;
} }
@@ -1406,10 +1406,10 @@ SwSbxValue SwCalc::Prim()
if( !bChkTrig || ( nVal > -1 && nVal < 1 ) ) if( !bChkTrig || ( nVal > -1 && nVal < 1 ) )
nErg.PutDouble( (*pFnc)( nVal ) ); nErg.PutDouble( (*pFnc)( nVal ) );
else else
eError = CALC_OVERFLOW; m_eError = CALC_OVERFLOW;
} }
if( bChkPow && eCurrOper == CALC_POW ) if( bChkPow && m_eCurrOper == CALC_POW )
{ {
double dleft = nErg.GetDouble(); double dleft = nErg.GetDouble();
GetToken(); GetToken();
@@ -1420,7 +1420,7 @@ SwSbxValue SwCalc::Prim()
if( ( dleft < 0.0 && 0.0 != fraction ) || if( ( dleft < 0.0 && 0.0 != fraction ) ||
( 0.0 == dleft && right < 0.0 ) ) ( 0.0 == dleft && right < 0.0 ) )
{ {
eError = CALC_OVERFLOW; m_eError = CALC_OVERFLOW;
nErg.Clear(); nErg.Clear();
} }
else else
@@ -1428,7 +1428,7 @@ SwSbxValue SwCalc::Prim()
dleft = pow(dleft, right ); dleft = pow(dleft, right );
if( dleft == HUGE_VAL ) if( dleft == HUGE_VAL )
{ {
eError = CALC_POWERR; m_eError = CALC_POWERR;
nErg.Clear(); nErg.Clear();
} }
else else
@@ -1444,17 +1444,17 @@ SwSbxValue SwCalc::Prim()
SwSbxValue SwCalc::Expr() SwSbxValue SwCalc::Expr()
{ {
SwSbxValue left = Term(), right; SwSbxValue left = Term(), right;
nLastLeft = left; m_nLastLeft = left;
for(;;) for(;;)
{ {
switch(eCurrOper) switch(m_eCurrOper)
{ {
case CALC_PLUS: case CALC_PLUS:
GetToken(); GetToken();
left.MakeDouble(); left.MakeDouble();
( right = Term() ).MakeDouble(); ( right = Term() ).MakeDouble();
left.Compute( SbxPLUS, right ); left.Compute( SbxPLUS, right );
nListPor++; m_nListPor++;
break; break;
case CALC_MINUS: case CALC_MINUS:
@@ -1493,7 +1493,7 @@ OUString SwCalc::GetDBName(const OUString& rName)
if( -1 != nPos ) if( -1 != nPos )
return rName.copy( 0, nPos ); return rName.copy( 0, nPos );
} }
SwDBData aData = rDoc.GetDBData(); SwDBData aData = m_rDoc.GetDBData();
OUString sRet = aData.sDataSource; OUString sRet = aData.sDataSource;
sRet += OUString(DB_DELIM); sRet += OUString(DB_DELIM);
sRet += aData.sCommand; sRet += aData.sCommand;