summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver-Rainer Wittmann <orw@apache.org>2014-02-11 13:25:08 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-02-12 11:46:50 +0000
commit4cf1ab04f7fb0ccd546240f40e024872827c997f (patch)
treebafc5a56c829ef443231fd16aa75f77ea2253c55
parente46392bbe25028528086a43a4c414dcb0acde401 (diff)
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)
-rw-r--r--sw/inc/expfld.hxx3
-rw-r--r--sw/inc/txtfld.hxx4
-rw-r--r--sw/source/core/fields/expfld.cxx32
-rw-r--r--sw/source/core/fields/usrfld.cxx8
-rw-r--r--sw/source/core/txtnode/atrfld.cxx24
5 files changed, 67 insertions, 4 deletions
diff --git a/sw/inc/expfld.hxx b/sw/inc/expfld.hxx
index 2944589c42e4..076569a669ca 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 cfab932a8660..b973aaadd469 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 e25dd31f13eb..6cdd6e7228d0 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 35b726178f9d..9cd6baa7fb3b 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 581006712c1d..1107c1c37789 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