[Libreoffice-commits] core.git: Branch 'aoo/trunk' - sw/source
Oliver-Rainer Wittmann
orw at apache.org
Mon Jul 14 07:07:34 PDT 2014
sw/source/core/fields/cellfml.cxx | 36 ++++++++++++++++++++++--------------
sw/source/core/txtnode/atrfld.cxx | 3 +++
2 files changed, 25 insertions(+), 14 deletions(-)
New commits:
commit b384441c10475c9784eae3ea501afb22e0317468
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date: Mon Jul 14 13:36:56 2014 +0000
125228: correct consideration of InputFields in table cells are part of table formulas
diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx
index 4e77fdf..23abcfe 100644
--- a/sw/source/core/fields/cellfml.cxx
+++ b/sw/source/core/fields/cellfml.cxx
@@ -156,27 +156,26 @@ double SwTableBox::GetValue( SwTblCalcPara& rCalcPara ) const
if ( nSttPos < rTxt.Len() &&
( CH_TXTATR_BREAKWORD == Char || CH_TXTATR_INWORD == Char ) )
{
- SwIndex aIdx( pTxtNd, nSttPos );
- SwTxtFld * const pTxtFld = static_cast<SwTxtFld*>(
- pTxtNd->GetTxtAttrForCharAt(aIdx.GetIndex(), RES_TXTATR_FIELD));
- if( !pTxtFld )
+ SwTxtFld * const pTxtFld =
+ static_cast<SwTxtFld*>( pTxtNd->GetTxtAttrForCharAt( nSttPos, RES_TXTATR_FIELD ) );
+ if ( pTxtFld == NULL )
break;
rCalcPara.rCalc.SetCalcError( CALC_NOERR ); // wieder zuruecksetzen
const SwField* pFld = pTxtFld->GetFmtFld().GetField();
- switch( pFld->GetTyp()->Which() )
+ switch ( pFld->GetTyp()->Which() )
{
case RES_SETEXPFLD:
- nRet = ((SwSetExpField*)pFld)->GetValue();
+ nRet = ( (SwSetExpField*) pFld )->GetValue();
break;
case RES_USERFLD:
- nRet = ((SwUserFieldType*)pFld)->GetValue();
+ nRet = ( (SwUserFieldType*) pFld )->GetValue();
break;
case RES_TABLEFLD:
{
- SwTblField* pTblFld = (SwTblField*)pFld;
- if( !pTblFld->IsValid() ) // ist der Wert gueltig ??
+ SwTblField* pTblFld = (SwTblField*) pFld;
+ if ( !pTblFld->IsValid() ) // ist der Wert gueltig ??
{
// die richtige Tabelle mitgeben!
const SwTable* pTmp = rCalcPara.pTbl;
@@ -189,20 +188,29 @@ double SwTableBox::GetValue( SwTblCalcPara& rCalcPara ) const
break;
case RES_DATETIMEFLD:
- nRet = ((SwDateTimeField*)pFld)->GetValue();
+ nRet = ( (SwDateTimeField*) pFld )->GetValue();
break;
case RES_JUMPEDITFLD:
- //JP 14.09.98: Bug 56112 - der Platzhalter kann nie einen
- // gueltigen Inhalt haben!
+ // placeholder does not have valid content
nRet = 0;
break;
default:
- String const value(pFld->ExpandField(true));
- nRet = rCalcPara.rCalc.Calculate(value).GetDouble();
+ String const value( pFld->ExpandField( true ) );
+ nRet = rCalcPara.rCalc.Calculate( value ).GetDouble();
}
}
+ else if ( nSttPos < rTxt.Len()
+ && Char == CH_TXT_ATR_INPUTFIELDSTART )
+ {
+ const SwTxtInputFld * pTxtInputFld =
+ dynamic_cast< const SwTxtInputFld* >(
+ pTxtNd->GetTxtAttrAt( nSttPos, RES_TXTATR_INPUTFIELD, SwTxtNode::DEFAULT ) );
+ if ( pTxtInputFld == NULL )
+ break;
+ nRet = rCalcPara.rCalc.Calculate( pTxtInputFld->GetFieldContent() ).GetDouble();
+ }
else
{
// Ergebnis ist 0 und kein Fehler!
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index f60d07c..a6cad4c 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -28,6 +28,7 @@
#include <fmtfld.hxx>
#include <txtfld.hxx>
#include <txtannotationfld.hxx>
+#include <docfld.hxx>
#include <docufld.hxx>
#include <doc.hxx>
@@ -573,6 +574,8 @@ void SwTxtInputFld::UpdateFieldContent()
if ( pInputFld != NULL )
{
const_cast<SwInputField*>(pInputFld)->applyFieldContent( aNewFieldContent );
+ // trigger update of fields for scenarios in which the Input Field's content is part of e.g. a table formula
+ GetTxtNode().GetDoc()->GetUpdtFlds().SetFieldsDirty( sal_True );
}
}
}
More information about the Libreoffice-commits
mailing list