diff options
author | Oliver-Rainer Wittmann <orw@apache.org> | 2014-02-11 13:25:08 +0000 |
---|---|---|
committer | Oliver-Rainer Wittmann <orw@apache.org> | 2014-02-11 13:25:08 +0000 |
commit | 3c2b5242e81575ec4b6c110afd88894670bd2283 (patch) | |
tree | adb7cc4b23d5187a494ec6d33307ee0df897b210 | |
parent | 9098e3da831f24cd384f5bc70c42310792bb3bde (diff) |
124179: trigger update User Fields and related Input Fields when user directly edits a User Field Input Field
- assure that no recursive updates occur
Notes
Notes:
merged as: 50f0bb85b7e18001886fdf8bb03eb1d138838b90
-rw-r--r-- | sw/inc/expfld.hxx | 3 | ||||
-rw-r--r-- | sw/inc/txtfld.hxx | 4 | ||||
-rw-r--r-- | sw/source/core/fields/expfld.cxx | 33 | ||||
-rw-r--r-- | sw/source/core/fields/usrfld.cxx | 10 | ||||
-rw-r--r-- | sw/source/core/txtnode/atrfld.cxx | 24 |
5 files changed, 70 insertions, 4 deletions
diff --git a/sw/inc/expfld.hxx b/sw/inc/expfld.hxx index 784f0fb15919..0b4e14bc739a 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 83ca7396ba71..f31dd0705bc0 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 6274bd8d7ced..282f92041bee 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 e6491dbb2b7f..0ea4417e1fd8 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 c93733fcc24e..90526b0a0558 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 |