diff options
-rw-r--r-- | sw/inc/calc.hxx | 8 | ||||
-rw-r--r-- | sw/source/core/bastyp/calc.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 8 |
3 files changed, 21 insertions, 3 deletions
diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx index 8f54ab3bb385..4bf0ec2580cb 100644 --- a/sw/inc/calc.hxx +++ b/sw/inc/calc.hxx @@ -102,10 +102,11 @@ enum SwCalcError class SwSbxValue : public SbxValue { bool bVoid; + bool bDBvalue; public: // always default to a number. otherwise it will become a SbxEMPTY - SwSbxValue( long n = 0 ) : bVoid(false) { PutLong( n ); } - SwSbxValue( const double& rD ) : bVoid(false) { PutDouble( rD ); } + SwSbxValue( long n = 0 ) : bVoid(false), bDBvalue(false) { PutLong( n ); } + SwSbxValue( const double& rD ) : bVoid(false), bDBvalue(false) { PutDouble( rD ); } bool GetBool() const; double GetDouble() const; @@ -113,6 +114,9 @@ public: bool IsVoidValue() {return bVoid;} void SetVoidValue(bool bSet) {bVoid = bSet;} + + bool IsDBvalue() {return bDBvalue;} + void SetDBvalue(bool bSet) {bDBvalue = bSet;} }; // Calculate HashTables for VarTable und Operations diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx index 3f2d0ba89781..a8090a3423dd 100644 --- a/sw/source/core/bastyp/calc.cxx +++ b/sw/source/core/bastyp/calc.cxx @@ -499,6 +499,14 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns ) pFndExp->nValue.PutDouble( pUField->GetValue() ); } } + else if ( !pFndExp->pFieldType && pFndExp->nValue.IsDBvalue() ) + { + if ( pFndExp->nValue.IsString() ) + m_aErrExpr.nValue.PutString( pFndExp->nValue.GetOUString() ); + else if ( pFndExp->nValue.IsDouble() ) + m_aErrExpr.nValue.PutDouble( pFndExp->nValue.GetDouble() ); + pFndExp = &m_aErrExpr; + } return pFndExp; } diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 9adf98c24340..991b6127c251 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -2164,6 +2164,10 @@ bool SwDBManager::FillCalcWithMergeData( SvNumberFormatter *pDocFormatter, const OUString* pColNames = aColNames.getConstArray(); OUString aString; + // add the "record number" variable, as SwCalc::VarLook would. + rCalc.VarChange( GetAppCharClass().lowercase( + SwFieldType::GetTypeStr(TYP_DBSETNUMBERFLD) ), GetSelectedRecordId() ); + for( int nCol = 0; nCol < aColNames.getLength(); nCol++ ) { // get the column type @@ -2189,7 +2193,8 @@ bool SwDBManager::FillCalcWithMergeData( SvNumberFormatter *pDocFormatter, if( bValidValue ) { SwSbxValue aValue; - aValue.PutString( aString ); + aValue.PutDouble( aNumber ); + aValue.SetDBvalue( true ); SAL_INFO( "sw.ui", "'" << pColNames[nCol] << "': " << aNumber << " / " << aString ); rCalc.VarChange( pColNames[nCol], aValue ); } @@ -2198,6 +2203,7 @@ bool SwDBManager::FillCalcWithMergeData( SvNumberFormatter *pDocFormatter, { SwSbxValue aValue; aValue.PutString( aString ); + aValue.SetDBvalue( true ); SAL_INFO( "sw.ui", "'" << pColNames[nCol] << "': " << aString ); rCalc.VarChange( pColNames[nCol], aValue ); } |