[Libreoffice-commits] core.git: Branch 'feature/cib_contract136' - sw/inc sw/source
Jan-Marek Glogowski
glogow at fbihome.de
Fri Jul 7 05:04:57 UTC 2017
sw/inc/calc.hxx | 11 ++++++++---
sw/source/core/bastyp/calc.cxx | 7 +++++++
sw/source/uibase/dbui/dbmgr.cxx | 8 +++++++-
3 files changed, 22 insertions(+), 4 deletions(-)
New commits:
commit e8c47f47fc2bd96ef90e552759f927dd88a3646f
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Tue Jul 4 17:15:14 2017 +0200
tdf#108873 fix merge data handling in fields
This is a regression from tdf#70346 /
commit 4851cde7b98226b0f82ae2b191c290173e9b06c6
It added the whole DB row as variables to the SwCalc hash set.
This works correct for conditionals when hiding sections, but not
for conditionals used in fields - actually they break.
Previously the field would do a fallback to query the DB again, if
no variable was in the dict and the only possible variables in the
dict could have been user-defined fields.
This handles the added variables correctly for fields.
Also fixes a bug to store the DB number values as number variables
and adds the record number, as SwCalc::VarLook does.
Reviewed-on: https://gerrit.libreoffice.org/39509
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Conflicts:
sw/inc/calc.hxx
Change-Id: Ib0dbeda68234e671768ede55b2012235a3680276
diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx
index 6b85dbdf0968..63d42a6ecf3d 100644
--- a/sw/inc/calc.hxx
+++ b/sw/inc/calc.hxx
@@ -103,14 +103,16 @@ 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 ); }
SwSbxValue( const SwSbxValue& rVal ) :
SvRefBase( rVal ),
SbxValue( rVal ),
- bVoid(rVal.bVoid)
+ bVoid(rVal.bVoid),
+ bDBvalue(rVal.bDBvalue)
{}
virtual ~SwSbxValue();
@@ -120,6 +122,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 272b89f9357f..64a0ba1eddae 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -499,6 +499,13 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns )
pFndExp->nValue.PutDouble( pUField->GetValue() );
}
}
+ else if ( !pFndExp->pFieldType && pFndExp->nValue.IsDBvalue() )
+ {
+ if ( pFndExp->nValue.IsString() )
+ pFndExp->nValue.PutString( pFndExp->nValue.GetOUString() );
+ else if ( pFndExp->nValue.IsDouble() )
+ pFndExp->nValue.PutDouble( pFndExp->nValue.GetDouble() );
+ }
return pFndExp;
}
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 253d4e9c036b..5c6540112fcb 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -2103,6 +2103,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
@@ -2128,7 +2132,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 );
}
@@ -2137,6 +2142,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 );
}
More information about the Libreoffice-commits
mailing list