LCOV - code coverage report
Current view: top level - sw/source/core/txtnode - atrfld.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 167 254 65.7 %
Date: 2014-04-11 Functions: 37 47 78.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "fldbas.hxx"
      21             : #include <fmtfld.hxx>
      22             : #include <txtfld.hxx>
      23             : #include <txtannotationfld.hxx>
      24             : #include <docufld.hxx>
      25             : #include <doc.hxx>
      26             : 
      27             : #include "pam.hxx"
      28             : #include "reffld.hxx"
      29             : #include "ddefld.hxx"
      30             : #include "usrfld.hxx"
      31             : #include "expfld.hxx"
      32             : #include "swfont.hxx"
      33             : #include "ndtxt.hxx"
      34             : #include "calc.hxx"
      35             : #include "hints.hxx"
      36             : #include <IDocumentFieldsAccess.hxx>
      37             : #include <fieldhint.hxx>
      38             : #include <svl/smplhint.hxx>
      39             : 
      40       81763 : TYPEINIT3( SwFmtFld, SfxPoolItem, SwClient,SfxBroadcaster)
      41        2010 : TYPEINIT1(SwFmtFldHint, SfxHint);
      42             : 
      43             : /****************************************************************************
      44             :  *
      45             :  *  class SwFmtFld
      46             :  *
      47             :  ****************************************************************************/
      48             : 
      49             : // constructor for default item in attribute-pool
      50         111 : SwFmtFld::SwFmtFld( sal_uInt16 nWhich )
      51             :     : SfxPoolItem( nWhich )
      52             :     , SwClient()
      53             :     , SfxBroadcaster()
      54             :     , mpField( NULL )
      55         111 :     , mpTxtFld( NULL )
      56             : {
      57         111 : }
      58             : 
      59         902 : SwFmtFld::SwFmtFld( const SwField &rFld )
      60             :     : SfxPoolItem( RES_TXTATR_FIELD )
      61         902 :     , SwClient( rFld.GetTyp() )
      62             :     , SfxBroadcaster()
      63         902 :     , mpField( rFld.CopyField() )
      64        2706 :     , mpTxtFld( NULL )
      65             : {
      66         902 :     if ( GetField()->GetTyp()->Which() == RES_INPUTFLD )
      67             :     {
      68             :         // input field in-place editing
      69           2 :         SetWhich( RES_TXTATR_INPUTFIELD );
      70           2 :         static_cast<SwInputField*>(GetField())->SetFmtFld( *this );
      71             :     }
      72         900 :     else if ( GetField()->GetTyp()->Which() == RES_POSTITFLD )
      73             :     {
      74             :         // text annotation field
      75          63 :         SetWhich( RES_TXTATR_ANNOTATION );
      76             :     }
      77         902 : }
      78             : 
      79             : // #i24434#
      80             : // Since Items are used in ItemPool and in default constructed ItemSets with
      81             : // full pool range, all items need to be clonable. Thus, this one needed to be
      82             : // corrected
      83        3189 : SwFmtFld::SwFmtFld( const SwFmtFld& rAttr )
      84             :     : SfxPoolItem( RES_TXTATR_FIELD )
      85             :     , SwClient()
      86             :     , SfxBroadcaster()
      87             :     , mpField( NULL )
      88        3189 :     , mpTxtFld( NULL )
      89             : {
      90        3189 :     if ( rAttr.GetField() )
      91             :     {
      92        3189 :         rAttr.GetField()->GetTyp()->Add(this);
      93        3189 :         mpField = rAttr.GetField()->CopyField();
      94        3189 :         if ( GetField()->GetTyp()->Which() == RES_INPUTFLD )
      95             :         {
      96             :             // input field in-place editing
      97          10 :             SetWhich( RES_TXTATR_INPUTFIELD );
      98          10 :             SwInputField *pField = dynamic_cast<SwInputField*>(GetField());
      99             :             assert(pField);
     100          10 :             if (pField)
     101          10 :                 pField->SetFmtFld( *this );
     102             :         }
     103        3179 :         else if ( GetField()->GetTyp()->Which() == RES_POSTITFLD )
     104             :         {
     105             :             // text annotation field
     106         202 :             SetWhich( RES_TXTATR_ANNOTATION );
     107             :         }
     108             :     }
     109        3189 : }
     110             : 
     111       11699 : SwFmtFld::~SwFmtFld()
     112             : {
     113        4193 :     SwFieldType* pType = mpField ? mpField->GetTyp() : 0;
     114             : 
     115        4193 :     if (pType && pType->Which() == RES_DBFLD)
     116          19 :         pType = 0;  // DB-Feldtypen zerstoeren sich selbst
     117             : 
     118        4193 :     Broadcast( SwFmtFldHint( this, SWFMTFLD_REMOVED ) );
     119        4193 :     delete mpField;
     120             : 
     121             :     // bei einige FeldTypen muessen wir den FeldTypen noch loeschen
     122        4193 :     if( pType && pType->IsLastDepend() )
     123             :     {
     124         236 :         sal_Bool bDel = sal_False;
     125         236 :         switch( pType->Which() )
     126             :         {
     127             :         case RES_USERFLD:
     128           2 :             bDel = ((SwUserFieldType*)pType)->IsDeleted();
     129           2 :             break;
     130             : 
     131             :         case RES_SETEXPFLD:
     132          22 :             bDel = ((SwSetExpFieldType*)pType)->IsDeleted();
     133          22 :             break;
     134             : 
     135             :         case RES_DDEFLD:
     136           0 :             bDel = ((SwDDEFieldType*)pType)->IsDeleted();
     137           0 :             break;
     138             :         }
     139             : 
     140         236 :         if( bDel )
     141             :         {
     142             :             // vorm loeschen erstmal austragen
     143           0 :             pType->Remove( this );
     144           0 :             delete pType;
     145             :         }
     146             :     }
     147        7506 : }
     148             : 
     149           0 : void SwFmtFld::RegisterToFieldType( SwFieldType& rType )
     150             : {
     151           0 :     rType.Add(this);
     152           0 : }
     153             : 
     154             : // #111840#
     155           0 : void SwFmtFld::SetField(SwField * _pField)
     156             : {
     157           0 :     delete mpField;
     158             : 
     159           0 :     mpField = _pField;
     160           0 :     if ( GetField()->GetTyp()->Which() == RES_INPUTFLD )
     161             :     {
     162           0 :         static_cast<SwInputField* >(GetField())->SetFmtFld( *this );
     163             :     }
     164           0 :     Broadcast( SwFmtFldHint( this, SWFMTFLD_CHANGED ) );
     165           0 : }
     166             : 
     167        1224 : void SwFmtFld::SetTxtFld( SwTxtFld& rTxtFld )
     168             : {
     169        1224 :     mpTxtFld = &rTxtFld;
     170        1224 : }
     171             : 
     172        1215 : void SwFmtFld::ClearTxtFld()
     173             : {
     174        1215 :     mpTxtFld = NULL;
     175        1215 : }
     176             : 
     177           0 : bool SwFmtFld::operator==( const SfxPoolItem& rAttr ) const
     178             : {
     179             :     OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
     180           0 :     return ( ( mpField && ((SwFmtFld&)rAttr).GetField()
     181           0 :                && mpField->GetTyp() == ((SwFmtFld&)rAttr).GetField()->GetTyp()
     182           0 :                && mpField->GetFormat() == ((SwFmtFld&)rAttr).GetField()->GetFormat() ) )
     183           0 :              || ( !mpField && !((SwFmtFld&)rAttr).GetField() );
     184             : }
     185             : 
     186        3189 : SfxPoolItem* SwFmtFld::Clone( SfxItemPool* ) const
     187             : {
     188        3189 :     return new SwFmtFld( *this );
     189             : }
     190             : 
     191           0 : void SwFmtFld::SwClientNotify( const SwModify&, const SfxHint& rHint )
     192             : {
     193           0 :     if( !mpTxtFld )
     194           0 :         return;
     195             : 
     196           0 :     const SwFieldHint* pHint = dynamic_cast<const SwFieldHint*>( &rHint );
     197           0 :     if ( pHint )
     198             :     {
     199             :         // replace field content by text
     200           0 :         SwPaM* pPaM = pHint->GetPaM();
     201           0 :         SwDoc* pDoc = pPaM->GetDoc();
     202           0 :         const SwTxtNode& rTxtNode = mpTxtFld->GetTxtNode();
     203           0 :         pPaM->GetPoint()->nNode = rTxtNode;
     204           0 :         pPaM->GetPoint()->nContent.Assign( (SwTxtNode*)&rTxtNode, *mpTxtFld->GetStart() );
     205             : 
     206           0 :         OUString const aEntry( GetField()->ExpandField( pDoc->IsClipBoard() ) );
     207           0 :         pPaM->SetMark();
     208           0 :         pPaM->Move( fnMoveForward );
     209           0 :         pDoc->DeleteRange( *pPaM );
     210           0 :         pDoc->InsertString( *pPaM, aEntry );
     211             :     }
     212             : }
     213             : 
     214         974 : void SwFmtFld::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
     215             : {
     216         974 :     if( !mpTxtFld )
     217          32 :         return;
     218             : 
     219             :     // don't do anything, especially not expand!
     220         942 :     if( pNew && pNew->Which() == RES_OBJECTDYING )
     221           0 :         return;
     222             : 
     223         942 :     SwTxtNode* pTxtNd = (SwTxtNode*)&mpTxtFld->GetTxtNode();
     224             :     OSL_ENSURE( pTxtNd, "wo ist denn mein Node?" );
     225         942 :     if( pNew )
     226             :     {
     227         340 :         switch( pNew->Which() )
     228             :         {
     229             :         case RES_TXTATR_FLDCHG:
     230             :                 // "Farbe hat sich geaendert !"
     231             :                 // this, this fuer "nur Painten"
     232           0 :                 pTxtNd->ModifyNotification( this, this );
     233           0 :                 return;
     234             :         case RES_REFMARKFLD_UPDATE:
     235             :                 // GetReferenz-Felder aktualisieren
     236           0 :                 if( RES_GETREFFLD == GetField()->GetTyp()->Which() )
     237             :                 {
     238             :                     // #i81002#
     239           0 :                     static_cast<SwGetRefField*>(GetField())->UpdateField( mpTxtFld );
     240             :                 }
     241           0 :                 break;
     242             :         case RES_DOCPOS_UPDATE:
     243             :                 // Je nach DocPos aktualisieren (SwTxtFrm::Modify())
     244         339 :                 pTxtNd->ModifyNotification( pNew, this );
     245         339 :                 return;
     246             : 
     247             :         case RES_ATTRSET_CHG:
     248             :         case RES_FMT_CHG:
     249           1 :                 pTxtNd->ModifyNotification( pOld, pNew );
     250           1 :                 return;
     251             :         default:
     252           0 :                 break;
     253             :         }
     254             :     }
     255             : 
     256         602 :     switch (GetField()->GetTyp()->Which())
     257             :     {
     258             :         case RES_HIDDENPARAFLD:
     259           0 :             if( !pOld || RES_HIDDENPARA_PRINT != pOld->Which() )
     260           0 :                 break;
     261             :         case RES_DBSETNUMBERFLD:
     262             :         case RES_DBNUMSETFLD:
     263             :         case RES_DBNEXTSETFLD:
     264             :         case RES_DBNAMEFLD:
     265           0 :             pTxtNd->ModifyNotification( 0, pNew);
     266           0 :             return;
     267             :     }
     268             : 
     269         602 :     if( RES_USERFLD == GetField()->GetTyp()->Which() )
     270             :     {
     271           0 :         SwUserFieldType* pType = (SwUserFieldType*)GetField()->GetTyp();
     272           0 :         if(!pType->IsValid())
     273             :         {
     274           0 :             SwCalc aCalc( *pTxtNd->GetDoc() );
     275           0 :             pType->GetValue( aCalc );
     276             :         }
     277             :     }
     278         602 :     mpTxtFld->ExpandTxtFld();
     279             : }
     280             : 
     281           9 : bool SwFmtFld::GetInfo( SfxPoolItem& rInfo ) const
     282             : {
     283             :     const SwTxtNode* pTxtNd;
     284          27 :     if( RES_AUTOFMT_DOCNODE != rInfo.Which() ||
     285          27 :         !mpTxtFld || 0 == ( pTxtNd = mpTxtFld->GetpTxtNode() ) ||
     286           9 :         &pTxtNd->GetNodes() != ((SwAutoFmtGetDocNode&)rInfo).pNodes )
     287           0 :         return true;
     288             : 
     289           9 :     ((SwAutoFmtGetDocNode&)rInfo).pCntntNode = pTxtNd;
     290           9 :     return false;
     291             : }
     292             : 
     293         468 : bool SwFmtFld::IsFldInDoc() const
     294             : {
     295         468 :     return mpTxtFld != NULL
     296         468 :            && mpTxtFld->IsFldInDoc();
     297             : }
     298             : 
     299           0 : sal_Bool SwFmtFld::IsProtect() const
     300             : {
     301           0 :     return mpTxtFld != NULL
     302           0 :            && mpTxtFld->GetpTxtNode() != NULL
     303           0 :            && mpTxtFld->GetpTxtNode()->IsProtect();
     304             : }
     305             : 
     306        1224 : SwTxtFld::SwTxtFld(
     307             :     SwFmtFld & rAttr,
     308             :     sal_Int32 const nStartPos,
     309             :     bool const bInClipboard)
     310             :     : SwTxtAttr( rAttr, nStartPos )
     311             : // fdo#39694 the ExpandField here may not give the correct result in all cases,
     312             : // but is better than nothing
     313             :     , m_aExpand( rAttr.GetField()->ExpandField(bInClipboard) )
     314        1224 :     , m_pTxtNode( NULL )
     315             : {
     316        1224 :     rAttr.SetTxtFld( *this );
     317        1224 :     SetHasDummyChar(true);
     318        1224 : }
     319             : 
     320        3580 : SwTxtFld::~SwTxtFld( )
     321             : {
     322        1215 :     SwFmtFld & rFmtFld( static_cast<SwFmtFld &>(GetAttr()) );
     323        1215 :     if ( this == rFmtFld.GetTxtFld() )
     324             :     {
     325        1215 :         rFmtFld.ClearTxtFld();
     326             :     }
     327        2365 : }
     328             : 
     329         470 : bool SwTxtFld::IsFldInDoc() const
     330             : {
     331         470 :     return GetpTxtNode() != NULL
     332         470 :            && GetpTxtNode()->GetNodes().IsDocNodes();
     333             : }
     334             : 
     335         685 : void SwTxtFld::ExpandTxtFld() const
     336             : {
     337             :     OSL_ENSURE( m_pTxtNode, "SwTxtFld: where is my TxtNode?" );
     338             : 
     339         685 :     const SwField* pFld = GetFmtFld().GetField();
     340         685 :     const OUString aNewExpand( pFld->ExpandField(m_pTxtNode->GetDoc()->IsClipBoard()) );
     341             : 
     342         685 :     if( aNewExpand == m_aExpand )
     343             :     {
     344             :         // Bei Seitennummernfeldern
     345         603 :         const sal_uInt16 nWhich = pFld->GetTyp()->Which();
     346         603 :         if ( RES_CHAPTERFLD != nWhich
     347         603 :              && RES_PAGENUMBERFLD != nWhich
     348         603 :              && RES_REFPAGEGETFLD != nWhich
     349             :              // Page count fields to not use aExpand during formatting,
     350             :              // therefore an invalidation of the text frame has to be triggered even if aNewExpand == aExpand:
     351         603 :              && ( RES_DOCSTATFLD != nWhich || DS_PAGE != static_cast<const SwDocStatField*>(pFld)->GetSubType() )
     352        1174 :              && ( RES_GETEXPFLD != nWhich || ((SwGetExpField*)pFld)->IsInBodyTxt() ) )
     353             :         {
     354         571 :             if( m_pTxtNode->CalcHiddenParaField() )
     355             :             {
     356           0 :                 m_pTxtNode->ModifyNotification( 0, 0 );
     357             :             }
     358        1256 :             return;
     359             :         }
     360             :     }
     361             : 
     362         114 :     m_aExpand = aNewExpand;
     363             : 
     364         114 :     const_cast<SwTxtFld*>(this)->NotifyContentChange( const_cast<SwFmtFld&>(GetFmtFld()) );
     365             : }
     366             : 
     367           0 : void SwTxtFld::CopyTxtFld( SwTxtFld *pDest ) const
     368             : {
     369             :     OSL_ENSURE( m_pTxtNode, "SwTxtFld: where is my TxtNode?" );
     370             :     OSL_ENSURE( pDest->m_pTxtNode, "SwTxtFld: where is pDest's TxtNode?" );
     371             : 
     372           0 :     IDocumentFieldsAccess* pIDFA = m_pTxtNode->getIDocumentFieldsAccess();
     373           0 :     IDocumentFieldsAccess* pDestIDFA = pDest->m_pTxtNode->getIDocumentFieldsAccess();
     374             : 
     375           0 :     SwFmtFld& rDestFmtFld = (SwFmtFld&)pDest->GetFmtFld();
     376           0 :     const sal_uInt16 nFldWhich = rDestFmtFld.GetField()->GetTyp()->Which();
     377             : 
     378           0 :     if( pIDFA != pDestIDFA )
     379             :     {
     380             :         // Die Hints stehen in unterschiedlichen Dokumenten,
     381             :         // der Feldtyp muss im neuen Dokument angemeldet werden.
     382             :         // Z.B: Kopieren ins ClipBoard.
     383             :         SwFieldType* pFldType;
     384           0 :         if( nFldWhich != RES_DBFLD
     385           0 :             && nFldWhich != RES_USERFLD
     386           0 :             && nFldWhich != RES_SETEXPFLD
     387           0 :             && nFldWhich != RES_DDEFLD
     388           0 :             && RES_AUTHORITY != nFldWhich )
     389             :         {
     390           0 :             pFldType = pDestIDFA->GetSysFldType( nFldWhich );
     391             :         }
     392             :         else
     393             :         {
     394           0 :             pFldType = pDestIDFA->InsertFldType( *rDestFmtFld.GetField()->GetTyp() );
     395             :         }
     396             : 
     397             :         // Sonderbehandlung fuer DDE-Felder
     398           0 :         if( RES_DDEFLD == nFldWhich )
     399             :         {
     400           0 :             if( rDestFmtFld.GetTxtFld() )
     401             :             {
     402           0 :                 ((SwDDEFieldType*)rDestFmtFld.GetField()->GetTyp())->DecRefCnt();
     403             :             }
     404           0 :             ((SwDDEFieldType*)pFldType)->IncRefCnt();
     405             :         }
     406             : 
     407             :         OSL_ENSURE( pFldType, "unbekannter FieldType" );
     408           0 :         pFldType->Add( &rDestFmtFld );          // ummelden
     409           0 :         rDestFmtFld.GetField()->ChgTyp( pFldType );
     410             :     }
     411             : 
     412             :     // Expressionfelder Updaten
     413           0 :     if( nFldWhich == RES_SETEXPFLD
     414           0 :         || nFldWhich == RES_GETEXPFLD
     415           0 :         || nFldWhich == RES_HIDDENTXTFLD )
     416             :     {
     417           0 :         SwTxtFld* pFld = (SwTxtFld*)this;
     418           0 :         pDestIDFA->UpdateExpFlds( pFld, true );
     419             :     }
     420             :     // Tabellenfelder auf externe Darstellung
     421           0 :     else if( RES_TABLEFLD == nFldWhich
     422           0 :              && ((SwTblField*)rDestFmtFld.GetField())->IsIntrnlName() )
     423             :     {
     424             :         // erzeuge aus der internen (fuer CORE) die externe (fuer UI) Formel
     425           0 :         const SwTableNode* pTblNd = m_pTxtNode->FindTableNode();
     426           0 :         if( pTblNd )        // steht in einer Tabelle
     427           0 :             ((SwTblField*)rDestFmtFld.GetField())->PtrToBoxNm( &pTblNd->GetTable() );
     428             :     }
     429           0 : }
     430             : 
     431         116 : void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld)
     432             : {
     433             :     //if not in undo section notify the change
     434         116 :     if (m_pTxtNode && m_pTxtNode->GetNodes().IsDocNodes())
     435             :     {
     436         116 :         m_pTxtNode->ModifyNotification(0, &rFmtFld);
     437             :     }
     438         116 : }
     439             : 
     440             : // input field in-place editing
     441           2 : SwTxtInputFld::SwTxtInputFld(
     442             :     SwFmtFld & rAttr,
     443             :     sal_Int32 const nStart,
     444             :     sal_Int32 const nEnd,
     445             :     bool const bInClipboard )
     446             : 
     447             :     : SwTxtFld( rAttr, nStart, bInClipboard )
     448             :     , m_nEnd( nEnd )
     449           2 :     , m_bLockNotifyContentChange( false )
     450             : {
     451           2 :     SetHasDummyChar( false );
     452           2 :     SetHasContent( true );
     453             : 
     454           2 :     SetDontExpand( true );
     455           2 :     SetLockExpandFlag( true );
     456           2 :     SetDontExpandStartAttr( true );
     457             : 
     458           2 :     SetNesting( true );
     459           2 : }
     460             : 
     461           4 : SwTxtInputFld::~SwTxtInputFld()
     462             : {
     463           4 : }
     464             : 
     465          71 : sal_Int32* SwTxtInputFld::GetEnd()
     466             : {
     467          71 :     return &m_nEnd;
     468             : }
     469             : 
     470           1 : void SwTxtInputFld::LockNotifyContentChange()
     471             : {
     472           1 :     m_bLockNotifyContentChange = true;
     473           1 : }
     474             : 
     475           1 : void SwTxtInputFld::UnlockNotifyContentChange()
     476             : {
     477           1 :     m_bLockNotifyContentChange = false;
     478           1 : }
     479             : 
     480           1 : void SwTxtInputFld::NotifyContentChange( SwFmtFld& rFmtFld )
     481             : {
     482           1 :     if ( !m_bLockNotifyContentChange )
     483             :     {
     484           1 :         LockNotifyContentChange();
     485             : 
     486           1 :         SwTxtFld::NotifyContentChange( rFmtFld );
     487           1 :         UpdateTextNodeContent( GetFieldContent() );
     488             : 
     489           1 :         UnlockNotifyContentChange();
     490             :     }
     491           1 : }
     492             : 
     493           3 : const OUString SwTxtInputFld::GetFieldContent() const
     494             : {
     495           3 :     return GetFmtFld().GetField()->ExpandField(false);
     496             : }
     497             : 
     498           2 : void SwTxtInputFld::UpdateFieldContent()
     499             : {
     500           4 :     if ( IsFldInDoc()
     501           2 :          && (*GetStart()) != (*End()) )
     502             :     {
     503             :         OSL_ENSURE( (*End()) - (*GetStart()) >= 2,
     504             :                 "<SwTxtInputFld::UpdateFieldContent()> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
     505             :         // skip CH_TXT_ATR_INPUTFIELDSTART character
     506           2 :         const sal_Int32 nIdx = (*GetStart()) + 1;
     507             :         // skip CH_TXT_ATR_INPUTFIELDEND character
     508           2 :         const sal_Int32 nLen = static_cast<sal_Int32>(std::max<sal_Int32>( 0, ( (*End()) - 1 - nIdx ) ));
     509           2 :         const OUString aNewFieldContent = GetTxtNode().GetExpandTxt( nIdx, nLen );
     510             : 
     511           2 :         const SwInputField* pInputFld = dynamic_cast<const SwInputField*>(GetFmtFld().GetField());
     512             :         OSL_ENSURE( pInputFld != NULL,
     513             :                 "<SwTxtInputFld::GetContent()> - Missing <SwInputFld> instance!" );
     514           2 :         if ( pInputFld != NULL )
     515             :         {
     516           2 :             const_cast<SwInputField*>(pInputFld)->applyFieldContent( aNewFieldContent );
     517           2 :         }
     518             :     }
     519           2 : }
     520             : 
     521           1 : void SwTxtInputFld::UpdateTextNodeContent( const OUString& rNewContent )
     522             : {
     523           1 :     if ( !IsFldInDoc() )
     524             :     {
     525             :         OSL_ENSURE( false, "<SwTxtInputFld::UpdateTextNodeContent(..)> - misusage as Input Field is not in document content." );
     526           1 :         return;
     527             :     }
     528             : 
     529             :     OSL_ENSURE( (*End()) - (*GetStart()) >= 2,
     530             :             "<SwTxtInputFld::UpdateTextNodeContent(..)> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
     531             :     // skip CH_TXT_ATR_INPUTFIELDSTART character
     532           1 :     const sal_Int32 nIdx = (*GetStart()) + 1;
     533             :     // skip CH_TXT_ATR_INPUTFIELDEND character
     534           1 :     const sal_Int32 nDelLen = std::max<sal_Int32>( 0, ( (*End()) - 1 - nIdx ) );
     535           1 :     SwIndex aIdx( &GetTxtNode(), nIdx );
     536           1 :     GetTxtNode().ReplaceText( aIdx, nDelLen, rNewContent );
     537             : }
     538             : 
     539             : // text annotation field
     540          63 : SwTxtAnnotationFld::SwTxtAnnotationFld(
     541             :     SwFmtFld & rAttr,
     542             :     sal_Int32 const nStart,
     543             :     bool const bInClipboard )
     544          63 :     : SwTxtFld( rAttr, nStart, bInClipboard )
     545             : {
     546          63 : }
     547             : 
     548         126 : SwTxtAnnotationFld::~SwTxtAnnotationFld()
     549             : {
     550         126 : }
     551             : 
     552         386 : ::sw::mark::IMark* SwTxtAnnotationFld::GetAnnotationMark(
     553             :     SwDoc* pDoc ) const
     554             : {
     555         386 :     const SwPostItField* pPostItField = dynamic_cast<const SwPostItField*>(GetFmtFld().GetField());
     556             :     OSL_ENSURE( pPostItField != NULL, "<SwTxtAnnotationFld::GetAnnotationMark()> - field missing" );
     557         386 :     if ( pPostItField == NULL )
     558             :     {
     559           0 :         return NULL;
     560             :     }
     561             : 
     562         386 :     if ( pDoc == NULL )
     563             :     {
     564         386 :         pDoc = static_cast<const SwPostItFieldType*>(pPostItField->GetTyp())->GetDoc();
     565             :     }
     566             :     OSL_ENSURE( pDoc != NULL, "<SwTxtAnnotationFld::GetAnnotationMark()> - missing document" );
     567         386 :     if ( pDoc == NULL )
     568             :     {
     569           0 :         return NULL;
     570             :     }
     571             : 
     572         386 :     IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
     573         386 :     IDocumentMarkAccess::const_iterator_t pMark = pMarksAccess->findAnnotationMark( pPostItField->GetName() );
     574         772 :     return pMark != pMarksAccess->getAnnotationMarksEnd()
     575         319 :            ? pMark->get()
     576         705 :            : NULL;
     577             : }
     578             : 
     579             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10