summaryrefslogtreecommitdiff
path: root/sw/source/core/txtnode/atrfld.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/core/txtnode/atrfld.cxx')
-rw-r--r--sw/source/core/txtnode/atrfld.cxx142
1 files changed, 94 insertions, 48 deletions
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index 2c35683be3b8..75d2a3e837f0 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -215,71 +215,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
@@ -313,9 +318,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 );
@@ -338,14 +344,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();
@@ -446,13 +453,51 @@ void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld)
}
+/*static*/
+void SwTxtFld::GetPamForTxtFld(
+ const SwTxtFld& rTxtFld,
+ boost::shared_ptr< SwPaM >& rPamForTxtFld )
+{
+ if ( rTxtFld.GetpTxtNode() == NULL )
+ {
+ ASSERT( false, "<SwTxtFld::GetPamForField> - missing <SwTxtNode>" );
+ return;
+ }
+
+ const SwTxtNode& rTxtNode = rTxtFld.GetTxtNode();
+
+ rPamForTxtFld.reset( new SwPaM( rTxtNode,
+ ( (rTxtFld.End() != NULL) ? *(rTxtFld.End()) : ( *(rTxtFld.GetStart()) + 1 ) ),
+ rTxtNode,
+ *(rTxtFld.GetStart()) ) );
+
+}
+
+
+/*static*/
+void SwTxtFld::DeleteTxtFld( const SwTxtFld& rTxtFld )
+{
+ if ( rTxtFld.GetpTxtNode() != NULL )
+ {
+ boost::shared_ptr< SwPaM > pPamForTxtFld;
+ GetPamForTxtFld( rTxtFld, pPamForTxtFld );
+ if ( pPamForTxtFld.get() != NULL )
+ {
+ rTxtFld.GetTxtNode().GetDoc()->DeleteAndJoin( *pPamForTxtFld );
+ }
+ }
+}
+
+
+
// input field in-place editing
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 )
{
@@ -553,8 +598,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 )
{
}