Kaydet (Commit) 3c2b5242 authored tarafından Oliver-Rainer Wittmann's avatar Oliver-Rainer Wittmann

124179: trigger update User Fields and related Input Fields when user directly…

124179: trigger update User Fields and related Input Fields when user directly edits a User Field Input Field

- assure that no recursive updates occur
üst 9098e3da
...@@ -327,6 +327,9 @@ class SW_DLLPUBLIC SwInputField : public SwField ...@@ -327,6 +327,9 @@ class SW_DLLPUBLIC SwInputField : public SwField
// Accessing Input Field's content // Accessing Input Field's content
const String& getContent() const; const String& getContent() const;
void LockNotifyContentChange();
void UnlockNotifyContentChange();
public: public:
// Direkte Eingabe ueber Dialog alten Wert loeschen // Direkte Eingabe ueber Dialog alten Wert loeschen
SwInputField( SwInputField(
......
...@@ -86,6 +86,8 @@ public: ...@@ -86,6 +86,8 @@ public:
virtual xub_StrLen* GetEnd(); virtual xub_StrLen* GetEnd();
void LockNotifyContentChange();
void UnlockNotifyContentChange();
virtual void NotifyContentChange( SwFmtFld& rFmtFld ); virtual void NotifyContentChange( SwFmtFld& rFmtFld );
void UpdateTextNodeContent( const String& rNewContent ); void UpdateTextNodeContent( const String& rNewContent );
...@@ -95,6 +97,8 @@ public: ...@@ -95,6 +97,8 @@ public:
private: private:
xub_StrLen m_nEnd; xub_StrLen m_nEnd;
bool m_bLockNotifyContentChange;
}; };
#endif #endif
......
...@@ -1181,6 +1181,32 @@ const String& SwInputField::getContent() const ...@@ -1181,6 +1181,32 @@ const String& SwInputField::getContent() const
return aContent; 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 ) void SwInputField::applyFieldContent( const String& rNewFieldContent )
{ {
if ( (nSubType & 0x00ff) == INP_TXT ) if ( (nSubType & 0x00ff) == INP_TXT )
...@@ -1194,6 +1220,13 @@ void SwInputField::applyFieldContent( const String& rNewFieldContent ) ...@@ -1194,6 +1220,13 @@ void SwInputField::applyFieldContent( const String& rNewFieldContent )
if( pUserTyp ) if( pUserTyp )
{ {
pUserTyp->SetContent( rNewFieldContent ); pUserTyp->SetContent( rNewFieldContent );
// trigger update of the corresponding User Fields and other related Input Fields
{
LockNotifyContentChange();
pUserTyp->UpdateFlds();
UnlockNotifyContentChange();
}
} }
} }
} }
......
...@@ -234,8 +234,14 @@ void SwUserFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) ...@@ -234,8 +234,14 @@ void SwUserFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
ChgValid( sal_False ); ChgValid( sal_False );
NotifyClients( pOld, pNew ); 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 ) double SwUserFieldType::GetValue( SwCalc& rCalc )
......
...@@ -457,6 +457,7 @@ SwTxtInputFld::SwTxtInputFld( ...@@ -457,6 +457,7 @@ SwTxtInputFld::SwTxtInputFld(
: SwTxtFld( rAttr, nStart ) : SwTxtFld( rAttr, nStart )
, m_nEnd( nEnd ) , m_nEnd( nEnd )
, m_bLockNotifyContentChange( false )
{ {
SetHasDummyChar( false ); SetHasDummyChar( false );
SetHasContent( true ); SetHasContent( true );
...@@ -477,11 +478,30 @@ xub_StrLen* SwTxtInputFld::GetEnd() ...@@ -477,11 +478,30 @@ xub_StrLen* SwTxtInputFld::GetEnd()
return &m_nEnd; return &m_nEnd;
} }
void SwTxtInputFld::LockNotifyContentChange()
{
m_bLockNotifyContentChange = true;
}
void SwTxtInputFld::UnlockNotifyContentChange()
{
m_bLockNotifyContentChange = false;
}
void SwTxtInputFld::NotifyContentChange( SwFmtFld& rFmtFld ) 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 const String SwTxtInputFld::GetFieldContent() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment