[Libreoffice-commits] core.git: sw/source
Oliver-Rainer Wittmann
orw at apache.org
Mon Jul 14 07:57:50 PDT 2014
sw/source/core/fields/cellfml.cxx | 25 +++++++++++++++++--------
sw/source/core/txtnode/atrfld.cxx | 3 +++
2 files changed, 20 insertions(+), 8 deletions(-)
New commits:
commit e465f0f4743162918dbdf2dcd50dedff00b1941c
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date: Mon Jul 14 13:36:56 2014 +0000
Resolves: #i125228# correct consideration of InputFields...
in table cells are part of table formulas
(cherry picked from commit b384441c10475c9784eae3ea501afb22e0317468)
Conflicts:
sw/source/core/fields/cellfml.cxx
Change-Id: I4780ce0c1ac9ac911b654f61aa12938d7b225139
diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx
index 796a18e..240c60a 100644
--- a/sw/source/core/fields/cellfml.cxx
+++ b/sw/source/core/fields/cellfml.cxx
@@ -151,22 +151,21 @@ double SwTableBox::GetValue( SwTblCalcPara& rCalcPara ) const
const sal_Unicode Char = bOK ? sTxt[nSttPos] : 0;
if ( bOK && (Char==CH_TXTATR_BREAKWORD || Char==CH_TXTATR_INWORD) )
{
- 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 ); // reset status
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:
{
@@ -184,7 +183,7 @@ double SwTableBox::GetValue( SwTblCalcPara& rCalcPara ) const
break;
case RES_DATETIMEFLD:
- nRet = ((SwDateTimeField*)pFld)->GetValue();
+ nRet = ( (SwDateTimeField*) pFld )->GetValue();
break;
case RES_JUMPEDITFLD:
@@ -196,6 +195,16 @@ double SwTableBox::GetValue( SwTblCalcPara& rCalcPara ) const
nRet = rCalcPara.rCalc.Calculate( pFld->ExpandField(true) ).GetDouble();
}
}
+ else if ( nSttPos < sTxt.getLength()
+ && 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
{
// result is 0 but no error!
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index b704710..035743b 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -21,6 +21,7 @@
#include <fmtfld.hxx>
#include <txtfld.hxx>
#include <txtannotationfld.hxx>
+#include <docfld.hxx>
#include <docufld.hxx>
#include <doc.hxx>
@@ -545,6 +546,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