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

125044: - use field's content cache on <SwTxtFld> construction only for clipboard documents

- assure invalidation and updates on code to update fields
üst f5d07409
......@@ -33,7 +33,8 @@ class SwTxtAnnotationFld : public SwTxtFld
public:
SwTxtAnnotationFld(
SwFmtFld & rAttr,
xub_StrLen const nStart );
xub_StrLen const nStart,
const bool bIsClipboardDoc );
virtual ~SwTxtAnnotationFld();
......
......@@ -39,18 +39,14 @@ class SwTxtFld : public SwTxtAttr
public:
SwTxtFld(
SwFmtFld & rAttr,
xub_StrLen const nStart );
xub_StrLen const nStart,
const bool bIsClipboardDoc );
virtual ~SwTxtFld();
void CopyTxtFld( SwTxtFld *pDest ) const;
void ExpandTxtFld() const;
inline void ExpandAlways()
{
m_aExpand += ' '; // changing current value to assure that <ExpandTxtFld()> changes the value.
ExpandTxtFld();
}
void ExpandTxtFld( const bool bForceNotify = false ) const;
// get and set TxtNode pointer
inline SwTxtNode* GetpTxtNode() const
......@@ -80,7 +76,8 @@ public:
SwTxtInputFld(
SwFmtFld & rAttr,
xub_StrLen const nStart,
xub_StrLen const nEnd );
xub_StrLen const nEnd,
const bool bIsClipboardDoc );
virtual ~SwTxtInputFld();
......
......@@ -722,7 +722,7 @@ sal_Bool SwCrsrShell::MoveFldType(
SwFmtFld* pFmtFld = new SwFmtFld( SwDateTimeField(
(SwDateTimeFieldType*)pDoc->GetSysFldType( RES_DATETIMEFLD ) ) );
pTxtFld = new SwTxtFld( *pFmtFld, rPos.nContent.GetIndex() );
pTxtFld = new SwTxtFld( *pFmtFld, rPos.nContent.GetIndex(), pDoc->IsClipBoard() );
pTxtFld->ChgTxtNode( pTNd );
}
......
......@@ -2006,7 +2006,7 @@ void SwDoc::ChangeDBFields( const SvStringsDtor& rOldNames,
}
if (bExpand)
pTxtFld->ExpandAlways();
pTxtFld->ExpandTxtFld( true );
}
SetModified();
}
......
......@@ -218,71 +218,76 @@ void SwFmtFld::SwClientNotify( const SwModify&, const SfxHint& rHint )
void SwFmtFld::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
{
if( !mpTxtFld )
if ( mpTxtFld == NULL )
return;
// don't do anything, especially not expand!
if( pNew && pNew->Which() == RES_OBJECTDYING )
if( pNew != NULL
&& pNew->Which() == RES_OBJECTDYING )
{
// don't do anything, especially not expand!
return;
}
SwTxtNode* pTxtNd = (SwTxtNode*)&mpTxtFld->GetTxtNode();
SwTxtNode* pTxtNd = (SwTxtNode*) &mpTxtFld->GetTxtNode();
ASSERT( pTxtNd, "wo ist denn mein Node?" );
if( pNew )
if ( pNew )
{
switch( pNew->Which() )
switch (pNew->Which())
{
case RES_TXTATR_FLDCHG:
// "Farbe hat sich geaendert !"
// this, this fuer "nur Painten"
pTxtNd->ModifyNotification( this, this );
return;
// "Farbe hat sich geaendert !"
// this, this fuer "nur Painten"
pTxtNd->ModifyNotification( this, this );
return;
case RES_REFMARKFLD_UPDATE:
// GetReferenz-Felder aktualisieren
if( RES_GETREFFLD == GetField()->GetTyp()->Which() )
{
// --> OD 2007-09-06 #i81002#
// ((SwGetRefField*)GetFld())->UpdateField();
dynamic_cast<SwGetRefField*>(GetField())->UpdateField( mpTxtFld );
// <--
}
break;
// GetReferenz-Felder aktualisieren
if ( RES_GETREFFLD == GetField()->GetTyp()->Which() )
{
dynamic_cast<SwGetRefField*>(GetField())->UpdateField( mpTxtFld );
}
break;
case RES_DOCPOS_UPDATE:
// Je nach DocPos aktualisieren (SwTxtFrm::Modify())
pTxtNd->ModifyNotification( pNew, this );
return;
// Je nach DocPos aktualisieren (SwTxtFrm::Modify())
pTxtNd->ModifyNotification( pNew, this );
return;
case RES_ATTRSET_CHG:
case RES_FMT_CHG:
pTxtNd->ModifyNotification( pOld, pNew );
return;
default:
break;
case RES_FMT_CHG:
pTxtNd->ModifyNotification( pOld, pNew );
return;
default:
break;
}
}
switch (GetField()->GetTyp()->Which())
{
case RES_HIDDENPARAFLD:
if( !pOld || RES_HIDDENPARA_PRINT != pOld->Which() )
break;
case RES_DBSETNUMBERFLD:
case RES_DBNUMSETFLD:
case RES_DBNEXTSETFLD:
case RES_DBNAMEFLD:
pTxtNd->ModifyNotification( 0, pNew);
return;
case RES_HIDDENPARAFLD:
if ( !pOld || RES_HIDDENPARA_PRINT != pOld->Which() )
break;
case RES_DBSETNUMBERFLD:
case RES_DBNUMSETFLD:
case RES_DBNEXTSETFLD:
case RES_DBNAMEFLD:
pTxtNd->ModifyNotification( 0, pNew );
return;
}
if( RES_USERFLD == GetField()->GetTyp()->Which() )
if ( RES_USERFLD == GetField()->GetTyp()->Which() )
{
SwUserFieldType* pType = (SwUserFieldType*)GetField()->GetTyp();
if(!pType->IsValid())
SwUserFieldType* pType = (SwUserFieldType*) GetField()->GetTyp();
if ( !pType->IsValid() )
{
SwCalc aCalc( *pTxtNd->GetDoc() );
pType->GetValue( aCalc );
}
}
mpTxtFld->ExpandTxtFld();
const bool bForceNotify = (pOld == NULL) && (pNew == NULL);
mpTxtFld->ExpandTxtFld( bForceNotify );
}
sal_Bool SwFmtFld::GetInfo( SfxPoolItem& rInfo ) const
......@@ -316,9 +321,10 @@ sal_Bool SwFmtFld::IsProtect() const
SwTxtFld::SwTxtFld(
SwFmtFld & rAttr,
xub_StrLen const nStartPos )
xub_StrLen const nStartPos,
const bool bIsClipboardDoc )
: SwTxtAttr( rAttr, nStartPos )
, m_aExpand( rAttr.GetField()->ExpandField(true) )
, m_aExpand( rAttr.GetField()->ExpandField( bIsClipboardDoc ) )
, m_pTxtNode( NULL )
{
rAttr.SetTxtFld( *this );
......@@ -341,14 +347,15 @@ bool SwTxtFld::IsFldInDoc() const
&& GetpTxtNode()->GetNodes().IsDocNodes();
}
void SwTxtFld::ExpandTxtFld() const
void SwTxtFld::ExpandTxtFld( const bool bForceNotify ) const
{
ASSERT( m_pTxtNode, "SwTxtFld: where is my TxtNode?" );
const SwField* pFld = GetFmtFld().GetField();
const XubString aNewExpand( pFld->ExpandField(m_pTxtNode->GetDoc()->IsClipBoard()) );
if( aNewExpand == m_aExpand )
if ( !bForceNotify &&
aNewExpand == m_aExpand )
{
// Bei Seitennummernfeldern
const sal_uInt16 nWhich = pFld->GetTyp()->Which();
......@@ -453,9 +460,10 @@ void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld)
SwTxtInputFld::SwTxtInputFld(
SwFmtFld & rAttr,
xub_StrLen const nStart,
xub_StrLen const nEnd )
xub_StrLen const nEnd,
const bool bIsClipboardDoc )
: SwTxtFld( rAttr, nStart )
: SwTxtFld( rAttr, nStart, bIsClipboardDoc )
, m_nEnd( nEnd )
, m_bLockNotifyContentChange( false )
{
......@@ -556,8 +564,9 @@ void SwTxtInputFld::UpdateTextNodeContent( const String& rNewContent )
// text annotation field
SwTxtAnnotationFld::SwTxtAnnotationFld(
SwFmtFld & rAttr,
xub_StrLen const nStart )
: SwTxtFld( rAttr, nStart )
xub_StrLen const nStart,
const bool bIsClipboardDoc )
: SwTxtFld( rAttr, nStart, bIsClipboardDoc )
{
}
......
......@@ -1049,12 +1049,14 @@ SwTxtAttr* MakeTxtAttr(
break;
case RES_TXTATR_FIELD:
pNew = new SwTxtFld( static_cast<SwFmtFld &>(rNew), nStt );
pNew =
new SwTxtFld( static_cast<SwFmtFld &>(rNew), nStt, rDoc.IsClipBoard() );
break;
case RES_TXTATR_ANNOTATION:
{
pNew = new SwTxtAnnotationFld( static_cast<SwFmtFld &>(rNew), nStt );
pNew =
new SwTxtAnnotationFld( static_cast<SwFmtFld &>(rNew), nStt, rDoc.IsClipBoard() );
if ( bIsCopy == COPY )
{
// On copy of the annotation field do not keep the annotated text range by removing
......@@ -1067,7 +1069,8 @@ SwTxtAttr* MakeTxtAttr(
break;
case RES_TXTATR_INPUTFIELD:
pNew = new SwTxtInputFld( static_cast<SwFmtFld &>(rNew), nStt, nEnd );
pNew =
new SwTxtInputFld( static_cast<SwFmtFld &>(rNew), nStt, nEnd, rDoc.IsClipBoard() );
break;
case RES_TXTATR_FLYCNT:
......
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