Kaydet (Commit) 50f0bb85 authored tarafından Oliver-Rainer Wittmann's avatar Oliver-Rainer Wittmann Kaydeden (comit) Caolán McNamara

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 3c2b5242)

Conflicts:
	sw/inc/txtfld.hxx
	sw/source/core/fields/expfld.cxx
	sw/source/core/fields/usrfld.cxx

Change-Id: I36af4d5e8008f16737e3ec14c1ec737a5f43d3b1
üst 2540c06a
......@@ -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(
......
......@@ -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
......
......@@ -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();
}
}
}
}
......
......@@ -202,8 +202,14 @@ void SwUserFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
ChgValid( 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 )
......
......@@ -453,6 +453,7 @@ SwTxtInputFld::SwTxtInputFld(
: SwTxtFld( rAttr, nStart, bInClipboard )
, m_nEnd( nEnd )
, m_bLockNotifyContentChange( false )
{
SetHasDummyChar( false );
SetHasContent( true );
......@@ -473,11 +474,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
......
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