Author: orw
Date: Tue Feb 11 13:25:08 2014
New Revision: 1567110

URL: http://svn.apache.org/r1567110
Log:
124179: trigger update User Fields and related Input Fields when user directly 
edits a User Field Input Field
        - assure that no recursive updates occur


Modified:
    openoffice/trunk/main/sw/inc/expfld.hxx
    openoffice/trunk/main/sw/inc/txtfld.hxx
    openoffice/trunk/main/sw/source/core/fields/expfld.cxx
    openoffice/trunk/main/sw/source/core/fields/usrfld.cxx
    openoffice/trunk/main/sw/source/core/txtnode/atrfld.cxx

Modified: openoffice/trunk/main/sw/inc/expfld.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/expfld.hxx?rev=1567110&r1=1567109&r2=1567110&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/expfld.hxx (original)
+++ openoffice/trunk/main/sw/inc/expfld.hxx Tue Feb 11 13:25:08 2014
@@ -327,6 +327,9 @@ class SW_DLLPUBLIC SwInputField : public
     // Accessing Input Field's content
     const String& getContent() const;
 
+    void LockNotifyContentChange();
+    void UnlockNotifyContentChange();
+
 public:
     // Direkte Eingabe ueber Dialog alten Wert loeschen
     SwInputField(

Modified: openoffice/trunk/main/sw/inc/txtfld.hxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/inc/txtfld.hxx?rev=1567110&r1=1567109&r2=1567110&view=diff
==============================================================================
--- openoffice/trunk/main/sw/inc/txtfld.hxx (original)
+++ openoffice/trunk/main/sw/inc/txtfld.hxx Tue Feb 11 13:25:08 2014
@@ -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

Modified: openoffice/trunk/main/sw/source/core/fields/expfld.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/fields/expfld.cxx?rev=1567110&r1=1567109&r2=1567110&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/fields/expfld.cxx (original)
+++ openoffice/trunk/main/sw/source/core/fields/expfld.cxx Tue Feb 11 13:25:08 
2014
@@ -1181,6 +1181,32 @@ const String& SwInputField::getContent()
     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( co
         if( pUserTyp )
         {
             pUserTyp->SetContent( rNewFieldContent );
+
+            // trigger update of the corresponding User Fields and other 
related Input Fields
+            {
+                LockNotifyContentChange();
+                pUserTyp->UpdateFlds();
+                UnlockNotifyContentChange();
+            }
         }
     }
 }

Modified: openoffice/trunk/main/sw/source/core/fields/usrfld.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/fields/usrfld.cxx?rev=1567110&r1=1567109&r2=1567110&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/fields/usrfld.cxx (original)
+++ openoffice/trunk/main/sw/source/core/fields/usrfld.cxx Tue Feb 11 13:25:08 
2014
@@ -230,12 +230,18 @@ const String& SwUserFieldType::GetName()
 
 void SwUserFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew 
)
 {
-       if( !pOld && !pNew )
-               ChgValid( sal_False );
+    if( !pOld && !pNew )
+        ChgValid( sal_False );
 
-       NotifyClients( pOld, pNew );
-       // und ggfs. am UserFeld haengende InputFelder updaten!
-       GetDoc()->GetSysFldType( RES_INPUTFLD )->UpdateFlds();
+    NotifyClients( pOld, pNew );
+
+    // 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 )

Modified: openoffice/trunk/main/sw/source/core/txtnode/atrfld.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/txtnode/atrfld.cxx?rev=1567110&r1=1567109&r2=1567110&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/txtnode/atrfld.cxx (original)
+++ openoffice/trunk/main/sw/source/core/txtnode/atrfld.cxx Tue Feb 11 13:25:08 
2014
@@ -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


Reply via email to