[Libreoffice-commits] core.git: Branch 'aoo/trunk' - sw/inc sw/source
Oliver-Rainer Wittmann
orw at apache.org
Tue Feb 11 06:10:00 PST 2014
sw/inc/expfld.hxx | 3 +++
sw/inc/txtfld.hxx | 4 ++++
sw/source/core/fields/expfld.cxx | 33 +++++++++++++++++++++++++++++++++
sw/source/core/fields/usrfld.cxx | 10 ++++++++--
sw/source/core/txtnode/atrfld.cxx | 24 ++++++++++++++++++++++--
5 files changed, 70 insertions(+), 4 deletions(-)
New commits:
commit 3c2b5242e81575ec4b6c110afd88894670bd2283
Author: Oliver-Rainer Wittmann <orw at apache.org>
Date: Tue Feb 11 13:25:08 2014 +0000
124179: trigger update User Fields and related Input Fields when user directly edits a User Field Input Field
- assure that no recursive updates occur
diff --git a/sw/inc/expfld.hxx b/sw/inc/expfld.hxx
index 784f0fb..0b4e14b 100644
--- a/sw/inc/expfld.hxx
+++ b/sw/inc/expfld.hxx
@@ -327,6 +327,9 @@ class SW_DLLPUBLIC SwInputField : public SwField
// Accessing Input Field's content
const String& getContent() const;
+ void LockNotifyContentChange();
+ void UnlockNotifyContentChange();
+
public:
// Direkte Eingabe ueber Dialog alten Wert loeschen
SwInputField(
diff --git a/sw/inc/txtfld.hxx b/sw/inc/txtfld.hxx
index 83ca739..f31dd07 100644
--- a/sw/inc/txtfld.hxx
+++ b/sw/inc/txtfld.hxx
@@ -86,6 +86,8 @@ public:
virtual xub_StrLen* GetEnd();
+ void LockNotifyContentChange();
+ void UnlockNotifyContentChange();
virtual void NotifyContentChange( SwFmtFld& rFmtFld );
void UpdateTextNodeContent( const String& rNewContent );
@@ -95,6 +97,8 @@ public:
private:
xub_StrLen m_nEnd;
+
+ bool m_bLockNotifyContentChange;
};
#endif
diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx
index 6274bd8d..282f920 100644
--- a/sw/source/core/fields/expfld.cxx
+++ b/sw/source/core/fields/expfld.cxx
@@ -1181,6 +1181,32 @@ const String& SwInputField::getContent() const
return aContent;
}
+
+void SwInputField::LockNotifyContentChange()
+{
+ if ( GetFmtFld() != NULL )
+ {
+ SwTxtInputFld* pTxtInputFld = dynamic_cast< SwTxtInputFld* >(GetFmtFld()->GetTxtFld());
+ if ( pTxtInputFld != NULL )
+ {
+ pTxtInputFld->LockNotifyContentChange();
+ }
+ }
+}
+
+
+void SwInputField::UnlockNotifyContentChange()
+{
+ if ( GetFmtFld() != NULL )
+ {
+ SwTxtInputFld* pTxtInputFld = dynamic_cast< SwTxtInputFld* >(GetFmtFld()->GetTxtFld());
+ if ( pTxtInputFld != NULL )
+ {
+ pTxtInputFld->UnlockNotifyContentChange();
+ }
+ }
+}
+
void SwInputField::applyFieldContent( const String& rNewFieldContent )
{
if ( (nSubType & 0x00ff) == INP_TXT )
@@ -1194,6 +1220,13 @@ void SwInputField::applyFieldContent( const String& rNewFieldContent )
if( pUserTyp )
{
pUserTyp->SetContent( rNewFieldContent );
+
+ // trigger update of the corresponding User Fields and other related Input Fields
+ {
+ LockNotifyContentChange();
+ pUserTyp->UpdateFlds();
+ UnlockNotifyContentChange();
+ }
}
}
}
diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx
index e6491db..0ea4417 100644
--- a/sw/source/core/fields/usrfld.cxx
+++ b/sw/source/core/fields/usrfld.cxx
@@ -234,8 +234,14 @@ void SwUserFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
ChgValid( sal_False );
NotifyClients( pOld, pNew );
- // und ggfs. am UserFeld haengende InputFelder updaten!
- GetDoc()->GetSysFldType( RES_INPUTFLD )->UpdateFlds();
+
+ // update Input Fields as there might be Input Fields depending on this User Field
+ if ( !IsModifyLocked() )
+ {
+ LockModify();
+ GetDoc()->GetSysFldType( RES_INPUTFLD )->UpdateFlds();
+ UnlockModify();
+ }
}
double SwUserFieldType::GetValue( SwCalc& rCalc )
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index c93733f..90526b0 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -457,6 +457,7 @@ SwTxtInputFld::SwTxtInputFld(
: SwTxtFld( rAttr, nStart )
, m_nEnd( nEnd )
+ , m_bLockNotifyContentChange( false )
{
SetHasDummyChar( false );
SetHasContent( true );
@@ -477,11 +478,30 @@ xub_StrLen* SwTxtInputFld::GetEnd()
return &m_nEnd;
}
+
+void SwTxtInputFld::LockNotifyContentChange()
+{
+ m_bLockNotifyContentChange = true;
+}
+
+
+void SwTxtInputFld::UnlockNotifyContentChange()
+{
+ m_bLockNotifyContentChange = false;
+}
+
+
void SwTxtInputFld::NotifyContentChange( SwFmtFld& rFmtFld )
{
- SwTxtFld::NotifyContentChange( rFmtFld );
+ if ( !m_bLockNotifyContentChange )
+ {
+ LockNotifyContentChange();
+
+ SwTxtFld::NotifyContentChange( rFmtFld );
+ UpdateTextNodeContent( GetFieldContent() );
- UpdateTextNodeContent( GetFieldContent() );
+ UnlockNotifyContentChange();
+ }
}
const String SwTxtInputFld::GetFieldContent() const
More information about the Libreoffice-commits
mailing list