sw/inc/txtannotationfld.hxx | 3 - sw/inc/txtfld.hxx | 13 +--- sw/source/core/crsr/crstrvl.cxx | 2 sw/source/core/doc/docfld.cxx | 2 sw/source/core/txtnode/atrfld.cxx | 105 ++++++++++++++++++++------------------ sw/source/core/txtnode/thints.cxx | 9 ++- 6 files changed, 72 insertions(+), 62 deletions(-)
New commits: commit 3d4d98d4d98bc62474ec295cdc4d070a01dcac13 Author: Oliver-Rainer Wittmann <o...@apache.org> Date: Fri Jun 13 14:08:22 2014 +0000 125044: - use field's content cache on <SwTxtFld> construction only for clipboard documents - assure invalidation and updates on code to update fields diff --git a/sw/inc/txtannotationfld.hxx b/sw/inc/txtannotationfld.hxx index f7cd9b8..2a8d9db 100755 --- a/sw/inc/txtannotationfld.hxx +++ b/sw/inc/txtannotationfld.hxx @@ -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(); diff --git a/sw/inc/txtfld.hxx b/sw/inc/txtfld.hxx index f31dd07..d86a447 100644 --- a/sw/inc/txtfld.hxx +++ b/sw/inc/txtfld.hxx @@ -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(); diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index fbbde30..479a755 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -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 ); } diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 384bfa2..bb93c8c 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -2006,7 +2006,7 @@ void SwDoc::ChangeDBFields( const SvStringsDtor& rOldNames, } if (bExpand) - pTxtFld->ExpandAlways(); + pTxtFld->ExpandTxtFld( true ); } SetModified(); } diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 90526b0..d111950 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -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 ) { } diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 6a7bdfc..66781e0 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -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: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits