sw/inc/expfld.hxx | 3 +++ sw/inc/txtfld.hxx | 4 ++++ sw/source/core/fields/expfld.cxx | 32 +++++++++++++++++++++++++++++++- sw/source/core/fields/usrfld.cxx | 8 +++++++- sw/source/core/txtnode/atrfld.cxx | 24 ++++++++++++++++++++++-- 5 files changed, 67 insertions(+), 4 deletions(-)
New commits: commit 4cf1ab04f7fb0ccd546240f40e024872827c997f Author: Oliver-Rainer Wittmann <o...@apache.org> Date: Tue Feb 11 13:25:08 2014 +0000 Resolves: #i124179# trigger update User Fields... and related Input Fields when user directly edits a User Field Input Field - assure that no recursive updates occur (cherry picked from commit 3c2b5242e81575ec4b6c110afd88894670bd2283) Conflicts: sw/inc/txtfld.hxx sw/source/core/fields/expfld.cxx sw/source/core/fields/usrfld.cxx Change-Id: I36af4d5e8008f16737e3ec14c1ec737a5f43d3b1 (cherry picked from commit 50f0bb85b7e18001886fdf8bb03eb1d138838b90) diff --git a/sw/inc/expfld.hxx b/sw/inc/expfld.hxx index 2944589..076569a 100644 --- a/sw/inc/expfld.hxx +++ b/sw/inc/expfld.hxx @@ -308,6 +308,9 @@ class SW_DLLPUBLIC SwInputField : public SwField // Accessing Input Field's content const OUString& getContent() const; + void LockNotifyContentChange(); + void UnlockNotifyContentChange(); + public: /// Direct input via dialog; delete old value. SwInputField( diff --git a/sw/inc/txtfld.hxx b/sw/inc/txtfld.hxx index cfab932..b973aaa 100644 --- a/sw/inc/txtfld.hxx +++ b/sw/inc/txtfld.hxx @@ -83,6 +83,8 @@ public: virtual sal_Int32* GetEnd(); + void LockNotifyContentChange(); + void UnlockNotifyContentChange(); virtual void NotifyContentChange( SwFmtFld& rFmtFld ); void UpdateTextNodeContent( const OUString& rNewContent ); @@ -92,6 +94,8 @@ public: private: sal_Int32 m_nEnd; + + bool m_bLockNotifyContentChange; }; #endif diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index e25dd31..6cdd6e7 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -1145,12 +1145,35 @@ SwFmtFld* SwInputField::GetFmtFld() return mpFmtFld; } - const OUString& 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 OUString& rNewFieldContent ) { if ( (nSubType & 0x00ff) == INP_TXT ) @@ -1164,6 +1187,13 @@ void SwInputField::applyFieldContent( const OUString& 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 35b7261..9cd6baa 100644 --- a/sw/source/core/fields/usrfld.cxx +++ b/sw/source/core/fields/usrfld.cxx @@ -202,8 +202,14 @@ void SwUserFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) ChgValid( sal_False ); NotifyClients( pOld, pNew ); + // update input fields that might be connected to the user field - GetDoc()->GetSysFldType( RES_INPUTFLD )->UpdateFlds(); + 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 5810067..1107c1c 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -440,6 +440,7 @@ SwTxtInputFld::SwTxtInputFld( : SwTxtFld( rAttr, nStart, bInClipboard ) , m_nEnd( nEnd ) + , m_bLockNotifyContentChange( false ) { SetHasDummyChar( false ); SetHasContent( true ); @@ -460,11 +461,30 @@ sal_Int32* 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 OUString SwTxtInputFld::GetFieldContent() const _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits