xref: /trunk/main/sw/source/core/txtnode/atrfld.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "fldbas.hxx"          // fuer FieldType
28cdf0e10cSrcweir #include <fmtfld.hxx>
29cdf0e10cSrcweir #include <txtfld.hxx>
30dec99bbdSOliver-Rainer Wittmann #include <txtannotationfld.hxx>
3177f92f50SOliver-Rainer Wittmann #include <docfld.hxx>
32cdf0e10cSrcweir #include <docufld.hxx>
33cdf0e10cSrcweir #include <doc.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include "reffld.hxx"
36cdf0e10cSrcweir #include "ddefld.hxx"
37cdf0e10cSrcweir #include "usrfld.hxx"
38cdf0e10cSrcweir #include "expfld.hxx"
39cdf0e10cSrcweir #include "swfont.hxx"       // fuer GetFldsColor
40cdf0e10cSrcweir #include "ndtxt.hxx"        // SwTxtNode
41cdf0e10cSrcweir #include "calc.hxx"         // Update fuer UserFields
42cdf0e10cSrcweir #include "hints.hxx"
43cdf0e10cSrcweir #include <IDocumentFieldsAccess.hxx>
44cdf0e10cSrcweir #include <fieldhint.hxx>
45cdf0e10cSrcweir #include <svl/smplhint.hxx>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir TYPEINIT3( SwFmtFld, SfxPoolItem, SwClient,SfxBroadcaster)
48cdf0e10cSrcweir TYPEINIT1(SwFmtFldHint, SfxHint);
49cdf0e10cSrcweir 
50cdf0e10cSrcweir /****************************************************************************
51cdf0e10cSrcweir  *
52cdf0e10cSrcweir  *  class SwFmtFld
53cdf0e10cSrcweir  *
54cdf0e10cSrcweir  ****************************************************************************/
55cdf0e10cSrcweir 
5669a74367SOliver-Rainer Wittmann // constructor for default item in attribute-pool
SwFmtFld(sal_uInt16 nWhich)5769a74367SOliver-Rainer Wittmann SwFmtFld::SwFmtFld( sal_uInt16 nWhich )
5869a74367SOliver-Rainer Wittmann     : SfxPoolItem( nWhich )
5969a74367SOliver-Rainer Wittmann     , SwClient()
60c0286415SOliver-Rainer Wittmann     , SfxBroadcaster()
6169a74367SOliver-Rainer Wittmann     , mpField( NULL )
6269a74367SOliver-Rainer Wittmann     , mpTxtFld( NULL )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
SwFmtFld(const SwField & rFld)66cdf0e10cSrcweir SwFmtFld::SwFmtFld( const SwField &rFld )
67c0286415SOliver-Rainer Wittmann     : SfxPoolItem( RES_TXTATR_FIELD )
68c0286415SOliver-Rainer Wittmann     , SwClient( rFld.GetTyp() )
69c0286415SOliver-Rainer Wittmann     , SfxBroadcaster()
7069a74367SOliver-Rainer Wittmann     , mpField( rFld.CopyField() )
7169a74367SOliver-Rainer Wittmann     , mpTxtFld( NULL )
72cdf0e10cSrcweir {
7369a74367SOliver-Rainer Wittmann     if ( GetField()->GetTyp()->Which() == RES_INPUTFLD )
7469a74367SOliver-Rainer Wittmann     {
75dec99bbdSOliver-Rainer Wittmann         // input field in-place editing
7669a74367SOliver-Rainer Wittmann         SetWhich( RES_TXTATR_INPUTFIELD );
7769a74367SOliver-Rainer Wittmann         dynamic_cast<SwInputField*>(GetField())->SetFmtFld( *this );
7869a74367SOliver-Rainer Wittmann     }
79dec99bbdSOliver-Rainer Wittmann     else if ( GetField()->GetTyp()->Which() == RES_POSTITFLD )
80dec99bbdSOliver-Rainer Wittmann     {
81dec99bbdSOliver-Rainer Wittmann         // text annotation field
82dec99bbdSOliver-Rainer Wittmann         SetWhich( RES_TXTATR_ANNOTATION );
83dec99bbdSOliver-Rainer Wittmann     }
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir // #i24434#
87cdf0e10cSrcweir // Since Items are used in ItemPool and in default constructed ItemSets with
88cdf0e10cSrcweir // full pool range, all items need to be clonable. Thus, this one needed to be
89cdf0e10cSrcweir // corrected
SwFmtFld(const SwFmtFld & rAttr)90cdf0e10cSrcweir SwFmtFld::SwFmtFld( const SwFmtFld& rAttr )
91c0286415SOliver-Rainer Wittmann     : SfxPoolItem( RES_TXTATR_FIELD )
92c0286415SOliver-Rainer Wittmann     , SwClient()
93c0286415SOliver-Rainer Wittmann     , SfxBroadcaster()
9469a74367SOliver-Rainer Wittmann     , mpField( NULL )
9569a74367SOliver-Rainer Wittmann     , mpTxtFld( NULL )
96cdf0e10cSrcweir {
97c0286415SOliver-Rainer Wittmann     if ( rAttr.GetField() )
98cdf0e10cSrcweir     {
99c0286415SOliver-Rainer Wittmann         rAttr.GetField()->GetTyp()->Add(this);
10069a74367SOliver-Rainer Wittmann         mpField = rAttr.GetField()->CopyField();
10169a74367SOliver-Rainer Wittmann         if ( GetField()->GetTyp()->Which() == RES_INPUTFLD )
10269a74367SOliver-Rainer Wittmann         {
103dec99bbdSOliver-Rainer Wittmann             // input field in-place editing
10469a74367SOliver-Rainer Wittmann             SetWhich( RES_TXTATR_INPUTFIELD );
10569a74367SOliver-Rainer Wittmann             dynamic_cast<SwInputField*>(GetField())->SetFmtFld( *this );
10669a74367SOliver-Rainer Wittmann         }
107dec99bbdSOliver-Rainer Wittmann         else if ( GetField()->GetTyp()->Which() == RES_POSTITFLD )
108dec99bbdSOliver-Rainer Wittmann         {
109dec99bbdSOliver-Rainer Wittmann             // text annotation field
110dec99bbdSOliver-Rainer Wittmann             SetWhich( RES_TXTATR_ANNOTATION );
111dec99bbdSOliver-Rainer Wittmann         }
112cdf0e10cSrcweir     }
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
~SwFmtFld()115cdf0e10cSrcweir SwFmtFld::~SwFmtFld()
116cdf0e10cSrcweir {
11769a74367SOliver-Rainer Wittmann     SwFieldType* pType = mpField ? mpField->GetTyp() : 0;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     if (pType && pType->Which() == RES_DBFLD)
120cdf0e10cSrcweir         pType = 0;  // DB-Feldtypen zerstoeren sich selbst
121cdf0e10cSrcweir 
122cdf0e10cSrcweir     Broadcast( SwFmtFldHint( this, SWFMTFLD_REMOVED ) );
12369a74367SOliver-Rainer Wittmann     delete mpField;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     // bei einige FeldTypen muessen wir den FeldTypen noch loeschen
126cdf0e10cSrcweir     if( pType && pType->IsLastDepend() )
127cdf0e10cSrcweir     {
128cdf0e10cSrcweir         sal_Bool bDel = sal_False;
129cdf0e10cSrcweir         switch( pType->Which() )
130cdf0e10cSrcweir         {
131cdf0e10cSrcweir         case RES_USERFLD:
132cdf0e10cSrcweir             bDel = ((SwUserFieldType*)pType)->IsDeleted();
133cdf0e10cSrcweir             break;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir         case RES_SETEXPFLD:
136cdf0e10cSrcweir             bDel = ((SwSetExpFieldType*)pType)->IsDeleted();
137cdf0e10cSrcweir             break;
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         case RES_DDEFLD:
140cdf0e10cSrcweir             bDel = ((SwDDEFieldType*)pType)->IsDeleted();
141cdf0e10cSrcweir             break;
142cdf0e10cSrcweir         }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir         if( bDel )
145cdf0e10cSrcweir         {
146cdf0e10cSrcweir             // vorm loeschen erstmal austragen
147cdf0e10cSrcweir             pType->Remove( this );
148cdf0e10cSrcweir             delete pType;
149cdf0e10cSrcweir         }
150cdf0e10cSrcweir     }
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
RegisterToFieldType(SwFieldType & rType)153cdf0e10cSrcweir void SwFmtFld::RegisterToFieldType( SwFieldType& rType )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir     rType.Add(this);
156cdf0e10cSrcweir }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 
159cdf0e10cSrcweir // #111840#
SetField(SwField * _pField)16069a74367SOliver-Rainer Wittmann void SwFmtFld::SetField(SwField * _pField)
161cdf0e10cSrcweir {
16269a74367SOliver-Rainer Wittmann     if (NULL != mpField)
16369a74367SOliver-Rainer Wittmann         delete mpField;
164cdf0e10cSrcweir 
16569a74367SOliver-Rainer Wittmann     mpField = _pField;
16669a74367SOliver-Rainer Wittmann     if ( GetField()->GetTyp()->Which() == RES_INPUTFLD )
16769a74367SOliver-Rainer Wittmann     {
16869a74367SOliver-Rainer Wittmann         dynamic_cast<SwInputField* >(GetField())->SetFmtFld( *this );
16969a74367SOliver-Rainer Wittmann     }
170cdf0e10cSrcweir     Broadcast( SwFmtFldHint( this, SWFMTFLD_CHANGED ) );
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
SetTxtFld(SwTxtFld & rTxtFld)17369a74367SOliver-Rainer Wittmann void SwFmtFld::SetTxtFld( SwTxtFld& rTxtFld )
17469a74367SOliver-Rainer Wittmann {
17569a74367SOliver-Rainer Wittmann     mpTxtFld = &rTxtFld;
17669a74367SOliver-Rainer Wittmann }
17769a74367SOliver-Rainer Wittmann 
ClearTxtFld()17869a74367SOliver-Rainer Wittmann void SwFmtFld::ClearTxtFld()
17969a74367SOliver-Rainer Wittmann {
18069a74367SOliver-Rainer Wittmann     mpTxtFld = NULL;
18169a74367SOliver-Rainer Wittmann }
18269a74367SOliver-Rainer Wittmann 
operator ==(const SfxPoolItem & rAttr) const183cdf0e10cSrcweir int SwFmtFld::operator==( const SfxPoolItem& rAttr ) const
184cdf0e10cSrcweir {
185cdf0e10cSrcweir     ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
18669a74367SOliver-Rainer Wittmann     return ( ( mpField && ((SwFmtFld&)rAttr).GetField()
18769a74367SOliver-Rainer Wittmann                && mpField->GetTyp() == ((SwFmtFld&)rAttr).GetField()->GetTyp()
18869a74367SOliver-Rainer Wittmann                && mpField->GetFormat() == ((SwFmtFld&)rAttr).GetField()->GetFormat() ) )
18969a74367SOliver-Rainer Wittmann              || ( !mpField && !((SwFmtFld&)rAttr).GetField() );
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
Clone(SfxItemPool *) const192cdf0e10cSrcweir SfxPoolItem* SwFmtFld::Clone( SfxItemPool* ) const
193cdf0e10cSrcweir {
194cdf0e10cSrcweir     return new SwFmtFld( *this );
195cdf0e10cSrcweir }
196cdf0e10cSrcweir 
SwClientNotify(const SwModify &,const SfxHint & rHint)197cdf0e10cSrcweir void SwFmtFld::SwClientNotify( const SwModify&, const SfxHint& rHint )
198cdf0e10cSrcweir {
19969a74367SOliver-Rainer Wittmann     if( !mpTxtFld )
200cdf0e10cSrcweir         return;
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     const SwFieldHint* pHint = dynamic_cast<const SwFieldHint*>( &rHint );
203cdf0e10cSrcweir     if ( pHint )
204cdf0e10cSrcweir     {
205cdf0e10cSrcweir         // replace field content by text
206cdf0e10cSrcweir         SwPaM* pPaM = pHint->GetPaM();
207cdf0e10cSrcweir         SwDoc* pDoc = pPaM->GetDoc();
20869a74367SOliver-Rainer Wittmann         const SwTxtNode& rTxtNode = mpTxtFld->GetTxtNode();
209cdf0e10cSrcweir         pPaM->GetPoint()->nNode = rTxtNode;
21069a74367SOliver-Rainer Wittmann         pPaM->GetPoint()->nContent.Assign( (SwTxtNode*)&rTxtNode, *mpTxtFld->GetStart() );
211cdf0e10cSrcweir 
212c0286415SOliver-Rainer Wittmann         String const aEntry( GetField()->ExpandField( pDoc->IsClipBoard() ) );
213cdf0e10cSrcweir         pPaM->SetMark();
214cdf0e10cSrcweir         pPaM->Move( fnMoveForward );
215cdf0e10cSrcweir         pDoc->DeleteRange( *pPaM );
216cdf0e10cSrcweir         pDoc->InsertString( *pPaM, aEntry );
217cdf0e10cSrcweir     }
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)220cdf0e10cSrcweir void SwFmtFld::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
221cdf0e10cSrcweir {
2227887cc2eSOliver-Rainer Wittmann     if ( mpTxtFld == NULL )
223cdf0e10cSrcweir         return;
224cdf0e10cSrcweir 
2257887cc2eSOliver-Rainer Wittmann     if( pNew != NULL
2267887cc2eSOliver-Rainer Wittmann         && pNew->Which() == RES_OBJECTDYING )
2277887cc2eSOliver-Rainer Wittmann     {
228cdf0e10cSrcweir         // don't do anything, especially not expand!
229cdf0e10cSrcweir         return;
2307887cc2eSOliver-Rainer Wittmann     }
231cdf0e10cSrcweir 
23269a74367SOliver-Rainer Wittmann     SwTxtNode* pTxtNd = (SwTxtNode*) &mpTxtFld->GetTxtNode();
233cdf0e10cSrcweir     ASSERT( pTxtNd, "wo ist denn mein Node?" );
234cdf0e10cSrcweir     if ( pNew )
235cdf0e10cSrcweir     {
236cdf0e10cSrcweir         switch (pNew->Which())
237cdf0e10cSrcweir         {
238cdf0e10cSrcweir         case RES_TXTATR_FLDCHG:
239cdf0e10cSrcweir             // "Farbe hat sich geaendert !"
240cdf0e10cSrcweir             // this, this fuer "nur Painten"
241cdf0e10cSrcweir             pTxtNd->ModifyNotification( this, this );
242cdf0e10cSrcweir             return;
2437887cc2eSOliver-Rainer Wittmann 
244cdf0e10cSrcweir         case RES_REFMARKFLD_UPDATE:
245cdf0e10cSrcweir             // GetReferenz-Felder aktualisieren
246c0286415SOliver-Rainer Wittmann             if ( RES_GETREFFLD == GetField()->GetTyp()->Which() )
247cdf0e10cSrcweir             {
24869a74367SOliver-Rainer Wittmann                 dynamic_cast<SwGetRefField*>(GetField())->UpdateField( mpTxtFld );
249cdf0e10cSrcweir             }
250cdf0e10cSrcweir             break;
2517887cc2eSOliver-Rainer Wittmann 
252cdf0e10cSrcweir         case RES_DOCPOS_UPDATE:
253cdf0e10cSrcweir             // Je nach DocPos aktualisieren (SwTxtFrm::Modify())
254cdf0e10cSrcweir             pTxtNd->ModifyNotification( pNew, this );
255cdf0e10cSrcweir             return;
256cdf0e10cSrcweir 
257cdf0e10cSrcweir         case RES_ATTRSET_CHG:
258cdf0e10cSrcweir             case RES_FMT_CHG:
259cdf0e10cSrcweir             pTxtNd->ModifyNotification( pOld, pNew );
260cdf0e10cSrcweir             return;
2617887cc2eSOliver-Rainer Wittmann 
262cdf0e10cSrcweir             default:
263cdf0e10cSrcweir             break;
264cdf0e10cSrcweir         }
265cdf0e10cSrcweir     }
266cdf0e10cSrcweir 
267c0286415SOliver-Rainer Wittmann     switch (GetField()->GetTyp()->Which())
268cdf0e10cSrcweir     {
269cdf0e10cSrcweir     case RES_HIDDENPARAFLD:
270cdf0e10cSrcweir         if ( !pOld || RES_HIDDENPARA_PRINT != pOld->Which() )
271cdf0e10cSrcweir             break;
272cdf0e10cSrcweir     case RES_DBSETNUMBERFLD:
273cdf0e10cSrcweir     case RES_DBNUMSETFLD:
274cdf0e10cSrcweir     case RES_DBNEXTSETFLD:
275cdf0e10cSrcweir     case RES_DBNAMEFLD:
276cdf0e10cSrcweir         pTxtNd->ModifyNotification( 0, pNew );
277cdf0e10cSrcweir         return;
278cdf0e10cSrcweir     }
279cdf0e10cSrcweir 
280c0286415SOliver-Rainer Wittmann     if ( RES_USERFLD == GetField()->GetTyp()->Which() )
281cdf0e10cSrcweir     {
282c0286415SOliver-Rainer Wittmann         SwUserFieldType* pType = (SwUserFieldType*) GetField()->GetTyp();
283cdf0e10cSrcweir         if ( !pType->IsValid() )
284cdf0e10cSrcweir         {
285cdf0e10cSrcweir             SwCalc aCalc( *pTxtNd->GetDoc() );
286cdf0e10cSrcweir             pType->GetValue( aCalc );
287cdf0e10cSrcweir         }
288cdf0e10cSrcweir     }
2897887cc2eSOliver-Rainer Wittmann 
2907887cc2eSOliver-Rainer Wittmann     const bool bForceNotify = (pOld == NULL) && (pNew == NULL);
2917887cc2eSOliver-Rainer Wittmann     mpTxtFld->ExpandTxtFld( bForceNotify );
292cdf0e10cSrcweir }
293cdf0e10cSrcweir 
GetInfo(SfxPoolItem & rInfo) const294cdf0e10cSrcweir sal_Bool SwFmtFld::GetInfo( SfxPoolItem& rInfo ) const
295cdf0e10cSrcweir {
296cdf0e10cSrcweir     const SwTxtNode* pTxtNd;
297cdf0e10cSrcweir     if( RES_AUTOFMT_DOCNODE != rInfo.Which() ||
29869a74367SOliver-Rainer Wittmann         !mpTxtFld || 0 == ( pTxtNd = mpTxtFld->GetpTxtNode() ) ||
299cdf0e10cSrcweir         &pTxtNd->GetNodes() != ((SwAutoFmtGetDocNode&)rInfo).pNodes )
300cdf0e10cSrcweir         return sal_True;
301cdf0e10cSrcweir 
302cdf0e10cSrcweir     ((SwAutoFmtGetDocNode&)rInfo).pCntntNode = pTxtNd;
303cdf0e10cSrcweir     return sal_False;
304cdf0e10cSrcweir }
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 
IsFldInDoc() const30769a74367SOliver-Rainer Wittmann bool SwFmtFld::IsFldInDoc() const
308cdf0e10cSrcweir {
30969a74367SOliver-Rainer Wittmann     return mpTxtFld != NULL
31069a74367SOliver-Rainer Wittmann            && mpTxtFld->IsFldInDoc();
311cdf0e10cSrcweir }
312cdf0e10cSrcweir 
IsProtect() const313cdf0e10cSrcweir sal_Bool SwFmtFld::IsProtect() const
314cdf0e10cSrcweir {
31569a74367SOliver-Rainer Wittmann     return mpTxtFld != NULL
31669a74367SOliver-Rainer Wittmann            && mpTxtFld->GetpTxtNode() != NULL
31769a74367SOliver-Rainer Wittmann            && mpTxtFld->GetpTxtNode()->IsProtect();
318cdf0e10cSrcweir }
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 
32169a74367SOliver-Rainer Wittmann 
32269a74367SOliver-Rainer Wittmann 
SwTxtFld(SwFmtFld & rAttr,xub_StrLen const nStartPos,const bool bIsClipboardDoc)32369a74367SOliver-Rainer Wittmann SwTxtFld::SwTxtFld(
32469a74367SOliver-Rainer Wittmann     SwFmtFld & rAttr,
3257887cc2eSOliver-Rainer Wittmann     xub_StrLen const nStartPos,
3267887cc2eSOliver-Rainer Wittmann     const bool bIsClipboardDoc )
327cdf0e10cSrcweir     : SwTxtAttr( rAttr, nStartPos )
3287887cc2eSOliver-Rainer Wittmann     , m_aExpand( rAttr.GetField()->ExpandField( bIsClipboardDoc ) )
32969a74367SOliver-Rainer Wittmann     , m_pTxtNode( NULL )
330cdf0e10cSrcweir {
33169a74367SOliver-Rainer Wittmann     rAttr.SetTxtFld( *this );
332cdf0e10cSrcweir     SetHasDummyChar(true);
333cdf0e10cSrcweir }
334cdf0e10cSrcweir 
~SwTxtFld()335cdf0e10cSrcweir SwTxtFld::~SwTxtFld( )
336cdf0e10cSrcweir {
337cdf0e10cSrcweir     SwFmtFld & rFmtFld( static_cast<SwFmtFld &>(GetAttr()) );
33869a74367SOliver-Rainer Wittmann     if ( this == rFmtFld.GetTxtFld() )
339cdf0e10cSrcweir     {
34069a74367SOliver-Rainer Wittmann         rFmtFld.ClearTxtFld();
341cdf0e10cSrcweir     }
342cdf0e10cSrcweir }
343cdf0e10cSrcweir 
344cdf0e10cSrcweir 
IsFldInDoc() const34569a74367SOliver-Rainer Wittmann bool SwTxtFld::IsFldInDoc() const
346cdf0e10cSrcweir {
34769a74367SOliver-Rainer Wittmann     return GetpTxtNode() != NULL
34869a74367SOliver-Rainer Wittmann            && GetpTxtNode()->GetNodes().IsDocNodes();
34969a74367SOliver-Rainer Wittmann }
35069a74367SOliver-Rainer Wittmann 
ExpandTxtFld(const bool bForceNotify) const3517887cc2eSOliver-Rainer Wittmann void SwTxtFld::ExpandTxtFld( const bool bForceNotify ) const
35269a74367SOliver-Rainer Wittmann {
353cdf0e10cSrcweir     ASSERT( m_pTxtNode, "SwTxtFld: where is my TxtNode?" );
354cdf0e10cSrcweir 
355c0286415SOliver-Rainer Wittmann     const SwField* pFld = GetFmtFld().GetField();
35669a74367SOliver-Rainer Wittmann     const XubString aNewExpand( pFld->ExpandField(m_pTxtNode->GetDoc()->IsClipBoard()) );
357cdf0e10cSrcweir 
358*20379b72SOliver-Rainer Wittmann     if ( aNewExpand == m_aExpand )
359cdf0e10cSrcweir     {
360cdf0e10cSrcweir         // Bei Seitennummernfeldern
361cdf0e10cSrcweir         const sal_uInt16 nWhich = pFld->GetTyp()->Which();
36269a74367SOliver-Rainer Wittmann         if ( RES_CHAPTERFLD != nWhich
36369a74367SOliver-Rainer Wittmann              && RES_PAGENUMBERFLD != nWhich
36469a74367SOliver-Rainer Wittmann              && RES_REFPAGEGETFLD != nWhich
36569a74367SOliver-Rainer Wittmann              // Page count fields to not use aExpand during formatting,
36669a74367SOliver-Rainer Wittmann              // therefore an invalidation of the text frame has to be triggered even if aNewExpand == aExpand:
36769a74367SOliver-Rainer Wittmann              && ( RES_DOCSTATFLD != nWhich || DS_PAGE != static_cast<const SwDocStatField*>(pFld)->GetSubType() )
36869a74367SOliver-Rainer Wittmann              && ( RES_GETEXPFLD != nWhich || ((SwGetExpField*)pFld)->IsInBodyTxt() ) )
369cdf0e10cSrcweir         {
370cdf0e10cSrcweir             if( m_pTxtNode->CalcHiddenParaField() )
371cdf0e10cSrcweir             {
372cdf0e10cSrcweir                 m_pTxtNode->ModifyNotification( 0, 0 );
373cdf0e10cSrcweir             }
374*20379b72SOliver-Rainer Wittmann             if ( !bForceNotify )
375*20379b72SOliver-Rainer Wittmann             {
376*20379b72SOliver-Rainer Wittmann                 // done, if no further notification forced.
377cdf0e10cSrcweir                 return;
378cdf0e10cSrcweir             }
379cdf0e10cSrcweir         }
380*20379b72SOliver-Rainer Wittmann     }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     m_aExpand = aNewExpand;
383cdf0e10cSrcweir 
38469a74367SOliver-Rainer Wittmann     const_cast<SwTxtFld*>(this)->NotifyContentChange( const_cast<SwFmtFld&>(GetFmtFld()) );
385cdf0e10cSrcweir }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 
CopyTxtFld(SwTxtFld * pDest) const38869a74367SOliver-Rainer Wittmann void SwTxtFld::CopyTxtFld( SwTxtFld *pDest ) const
389cdf0e10cSrcweir {
390cdf0e10cSrcweir     ASSERT( m_pTxtNode, "SwTxtFld: where is my TxtNode?" );
391cdf0e10cSrcweir     ASSERT( pDest->m_pTxtNode, "SwTxtFld: where is pDest's TxtNode?" );
392cdf0e10cSrcweir 
393cdf0e10cSrcweir     IDocumentFieldsAccess* pIDFA = m_pTxtNode->getIDocumentFieldsAccess();
394cdf0e10cSrcweir     IDocumentFieldsAccess* pDestIDFA = pDest->m_pTxtNode->getIDocumentFieldsAccess();
395cdf0e10cSrcweir 
39669a74367SOliver-Rainer Wittmann     SwFmtFld& rDestFmtFld = (SwFmtFld&)pDest->GetFmtFld();
39769a74367SOliver-Rainer Wittmann     const sal_uInt16 nFldWhich = rDestFmtFld.GetField()->GetTyp()->Which();
398cdf0e10cSrcweir 
399cdf0e10cSrcweir     if( pIDFA != pDestIDFA )
400cdf0e10cSrcweir     {
401cdf0e10cSrcweir         // Die Hints stehen in unterschiedlichen Dokumenten,
402cdf0e10cSrcweir         // der Feldtyp muss im neuen Dokument angemeldet werden.
403cdf0e10cSrcweir         // Z.B: Kopieren ins ClipBoard.
404cdf0e10cSrcweir         SwFieldType* pFldType;
40569a74367SOliver-Rainer Wittmann         if( nFldWhich != RES_DBFLD
40669a74367SOliver-Rainer Wittmann             && nFldWhich != RES_USERFLD
40769a74367SOliver-Rainer Wittmann             && nFldWhich != RES_SETEXPFLD
40869a74367SOliver-Rainer Wittmann             && nFldWhich != RES_DDEFLD
40969a74367SOliver-Rainer Wittmann             && RES_AUTHORITY != nFldWhich )
41069a74367SOliver-Rainer Wittmann         {
411cdf0e10cSrcweir             pFldType = pDestIDFA->GetSysFldType( nFldWhich );
41269a74367SOliver-Rainer Wittmann         }
413cdf0e10cSrcweir         else
41469a74367SOliver-Rainer Wittmann         {
41569a74367SOliver-Rainer Wittmann             pFldType = pDestIDFA->InsertFldType( *rDestFmtFld.GetField()->GetTyp() );
41669a74367SOliver-Rainer Wittmann         }
417cdf0e10cSrcweir 
418cdf0e10cSrcweir         // Sonderbehandlung fuer DDE-Felder
419cdf0e10cSrcweir         if( RES_DDEFLD == nFldWhich )
420cdf0e10cSrcweir         {
42169a74367SOliver-Rainer Wittmann             if( rDestFmtFld.GetTxtFld() )
42269a74367SOliver-Rainer Wittmann             {
42369a74367SOliver-Rainer Wittmann                 ((SwDDEFieldType*)rDestFmtFld.GetField()->GetTyp())->DecRefCnt();
42469a74367SOliver-Rainer Wittmann             }
425cdf0e10cSrcweir             ((SwDDEFieldType*)pFldType)->IncRefCnt();
426cdf0e10cSrcweir         }
427cdf0e10cSrcweir 
428cdf0e10cSrcweir         ASSERT( pFldType, "unbekannter FieldType" );
42969a74367SOliver-Rainer Wittmann         pFldType->Add( &rDestFmtFld );          // ummelden
43069a74367SOliver-Rainer Wittmann         rDestFmtFld.GetField()->ChgTyp( pFldType );
431cdf0e10cSrcweir     }
432cdf0e10cSrcweir 
433cdf0e10cSrcweir     // Expressionfelder Updaten
43469a74367SOliver-Rainer Wittmann     if( nFldWhich == RES_SETEXPFLD
43569a74367SOliver-Rainer Wittmann         || nFldWhich == RES_GETEXPFLD
43669a74367SOliver-Rainer Wittmann         || nFldWhich == RES_HIDDENTXTFLD )
437cdf0e10cSrcweir     {
438cdf0e10cSrcweir         SwTxtFld* pFld = (SwTxtFld*)this;
439cdf0e10cSrcweir         pDestIDFA->UpdateExpFlds( pFld, true );
440cdf0e10cSrcweir     }
441cdf0e10cSrcweir     // Tabellenfelder auf externe Darstellung
44269a74367SOliver-Rainer Wittmann     else if( RES_TABLEFLD == nFldWhich
44369a74367SOliver-Rainer Wittmann              && ((SwTblField*)rDestFmtFld.GetField())->IsIntrnlName() )
444cdf0e10cSrcweir     {
445cdf0e10cSrcweir         // erzeuge aus der internen (fuer CORE) die externe (fuer UI) Formel
446cdf0e10cSrcweir         const SwTableNode* pTblNd = m_pTxtNode->FindTableNode();
447cdf0e10cSrcweir         if( pTblNd )        // steht in einer Tabelle
44869a74367SOliver-Rainer Wittmann             ((SwTblField*)rDestFmtFld.GetField())->PtrToBoxNm( &pTblNd->GetTable() );
449cdf0e10cSrcweir     }
450cdf0e10cSrcweir }
451cdf0e10cSrcweir 
452cdf0e10cSrcweir 
NotifyContentChange(SwFmtFld & rFmtFld)453cdf0e10cSrcweir void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld)
454cdf0e10cSrcweir {
455cdf0e10cSrcweir     //if not in undo section notify the change
456cdf0e10cSrcweir     if (m_pTxtNode && m_pTxtNode->GetNodes().IsDocNodes())
457cdf0e10cSrcweir     {
458cdf0e10cSrcweir         m_pTxtNode->ModifyNotification(0, &rFmtFld);
459cdf0e10cSrcweir     }
460cdf0e10cSrcweir }
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 
46336375bf3SOliver-Rainer Wittmann /*static*/
GetPamForTxtFld(const SwTxtFld & rTxtFld,boost::shared_ptr<SwPaM> & rPamForTxtFld)46436375bf3SOliver-Rainer Wittmann void SwTxtFld::GetPamForTxtFld(
46536375bf3SOliver-Rainer Wittmann     const SwTxtFld& rTxtFld,
46636375bf3SOliver-Rainer Wittmann     boost::shared_ptr< SwPaM >& rPamForTxtFld )
46736375bf3SOliver-Rainer Wittmann {
46836375bf3SOliver-Rainer Wittmann     if ( rTxtFld.GetpTxtNode() == NULL )
46936375bf3SOliver-Rainer Wittmann     {
47036375bf3SOliver-Rainer Wittmann         ASSERT( false, "<SwTxtFld::GetPamForField> - missing <SwTxtNode>" );
47136375bf3SOliver-Rainer Wittmann         return;
47236375bf3SOliver-Rainer Wittmann     }
47336375bf3SOliver-Rainer Wittmann 
47436375bf3SOliver-Rainer Wittmann     const SwTxtNode& rTxtNode = rTxtFld.GetTxtNode();
47536375bf3SOliver-Rainer Wittmann 
47636375bf3SOliver-Rainer Wittmann     rPamForTxtFld.reset( new SwPaM( rTxtNode,
47736375bf3SOliver-Rainer Wittmann                                     ( (rTxtFld.End() != NULL) ? *(rTxtFld.End()) : ( *(rTxtFld.GetStart()) + 1 ) ),
47836375bf3SOliver-Rainer Wittmann                                     rTxtNode,
47936375bf3SOliver-Rainer Wittmann                                     *(rTxtFld.GetStart()) ) );
48036375bf3SOliver-Rainer Wittmann 
48136375bf3SOliver-Rainer Wittmann }
48236375bf3SOliver-Rainer Wittmann 
48336375bf3SOliver-Rainer Wittmann 
48436375bf3SOliver-Rainer Wittmann /*static*/
DeleteTxtFld(const SwTxtFld & rTxtFld)48536375bf3SOliver-Rainer Wittmann void SwTxtFld::DeleteTxtFld( const SwTxtFld& rTxtFld )
48636375bf3SOliver-Rainer Wittmann {
48736375bf3SOliver-Rainer Wittmann     if ( rTxtFld.GetpTxtNode() != NULL )
48836375bf3SOliver-Rainer Wittmann     {
48936375bf3SOliver-Rainer Wittmann         boost::shared_ptr< SwPaM > pPamForTxtFld;
49036375bf3SOliver-Rainer Wittmann         GetPamForTxtFld( rTxtFld, pPamForTxtFld );
49136375bf3SOliver-Rainer Wittmann         if ( pPamForTxtFld.get() != NULL )
49236375bf3SOliver-Rainer Wittmann         {
49336375bf3SOliver-Rainer Wittmann             rTxtFld.GetTxtNode().GetDoc()->DeleteAndJoin( *pPamForTxtFld );
49436375bf3SOliver-Rainer Wittmann         }
49536375bf3SOliver-Rainer Wittmann     }
49636375bf3SOliver-Rainer Wittmann }
49736375bf3SOliver-Rainer Wittmann 
49836375bf3SOliver-Rainer Wittmann 
49936375bf3SOliver-Rainer Wittmann 
50069a74367SOliver-Rainer Wittmann // input field in-place editing
SwTxtInputFld(SwFmtFld & rAttr,xub_StrLen const nStart,xub_StrLen const nEnd,const bool bIsClipboardDoc)50169a74367SOliver-Rainer Wittmann SwTxtInputFld::SwTxtInputFld(
50269a74367SOliver-Rainer Wittmann     SwFmtFld & rAttr,
50369a74367SOliver-Rainer Wittmann     xub_StrLen const nStart,
5047887cc2eSOliver-Rainer Wittmann     xub_StrLen const nEnd,
5057887cc2eSOliver-Rainer Wittmann     const bool bIsClipboardDoc )
50669a74367SOliver-Rainer Wittmann 
5077887cc2eSOliver-Rainer Wittmann     : SwTxtFld( rAttr, nStart, bIsClipboardDoc )
50869a74367SOliver-Rainer Wittmann     , m_nEnd( nEnd )
5091bf9188dSOliver-Rainer Wittmann     , m_bLockNotifyContentChange( false )
51069a74367SOliver-Rainer Wittmann {
51169a74367SOliver-Rainer Wittmann     SetHasDummyChar( false );
51269a74367SOliver-Rainer Wittmann     SetHasContent( true );
51369a74367SOliver-Rainer Wittmann 
51469a74367SOliver-Rainer Wittmann     SetDontExpand( true );
51569a74367SOliver-Rainer Wittmann     SetLockExpandFlag( true );
51669a74367SOliver-Rainer Wittmann     SetDontExpandStartAttr( true );
51769a74367SOliver-Rainer Wittmann 
51869a74367SOliver-Rainer Wittmann     SetNesting( true );
51969a74367SOliver-Rainer Wittmann }
52069a74367SOliver-Rainer Wittmann 
~SwTxtInputFld()52169a74367SOliver-Rainer Wittmann SwTxtInputFld::~SwTxtInputFld()
52269a74367SOliver-Rainer Wittmann {
52369a74367SOliver-Rainer Wittmann }
52469a74367SOliver-Rainer Wittmann 
GetEnd()52569a74367SOliver-Rainer Wittmann xub_StrLen* SwTxtInputFld::GetEnd()
52669a74367SOliver-Rainer Wittmann {
52769a74367SOliver-Rainer Wittmann     return &m_nEnd;
52869a74367SOliver-Rainer Wittmann }
52969a74367SOliver-Rainer Wittmann 
5301bf9188dSOliver-Rainer Wittmann 
LockNotifyContentChange()5311bf9188dSOliver-Rainer Wittmann void SwTxtInputFld::LockNotifyContentChange()
5321bf9188dSOliver-Rainer Wittmann {
5331bf9188dSOliver-Rainer Wittmann     m_bLockNotifyContentChange = true;
5341bf9188dSOliver-Rainer Wittmann }
5351bf9188dSOliver-Rainer Wittmann 
5361bf9188dSOliver-Rainer Wittmann 
UnlockNotifyContentChange()5371bf9188dSOliver-Rainer Wittmann void SwTxtInputFld::UnlockNotifyContentChange()
5381bf9188dSOliver-Rainer Wittmann {
5391bf9188dSOliver-Rainer Wittmann     m_bLockNotifyContentChange = false;
5401bf9188dSOliver-Rainer Wittmann }
5411bf9188dSOliver-Rainer Wittmann 
5421bf9188dSOliver-Rainer Wittmann 
NotifyContentChange(SwFmtFld & rFmtFld)54369a74367SOliver-Rainer Wittmann void SwTxtInputFld::NotifyContentChange( SwFmtFld& rFmtFld )
54469a74367SOliver-Rainer Wittmann {
5451bf9188dSOliver-Rainer Wittmann     if ( !m_bLockNotifyContentChange )
5461bf9188dSOliver-Rainer Wittmann     {
5471bf9188dSOliver-Rainer Wittmann         LockNotifyContentChange();
54869a74367SOliver-Rainer Wittmann 
5491bf9188dSOliver-Rainer Wittmann         SwTxtFld::NotifyContentChange( rFmtFld );
55069a74367SOliver-Rainer Wittmann         UpdateTextNodeContent( GetFieldContent() );
5511bf9188dSOliver-Rainer Wittmann 
5521bf9188dSOliver-Rainer Wittmann         UnlockNotifyContentChange();
5531bf9188dSOliver-Rainer Wittmann     }
55469a74367SOliver-Rainer Wittmann }
55569a74367SOliver-Rainer Wittmann 
GetFieldContent() const55669a74367SOliver-Rainer Wittmann const String SwTxtInputFld::GetFieldContent() const
55769a74367SOliver-Rainer Wittmann {
55869a74367SOliver-Rainer Wittmann     return GetFmtFld().GetField()->ExpandField(false);
55969a74367SOliver-Rainer Wittmann }
56069a74367SOliver-Rainer Wittmann 
UpdateFieldContent()56169a74367SOliver-Rainer Wittmann void SwTxtInputFld::UpdateFieldContent()
56269a74367SOliver-Rainer Wittmann {
56369a74367SOliver-Rainer Wittmann     if ( IsFldInDoc()
56469a74367SOliver-Rainer Wittmann          && (*GetStart()) != (*End()) )
56569a74367SOliver-Rainer Wittmann     {
56669a74367SOliver-Rainer Wittmann         ASSERT( (*End()) - (*GetStart()) >= 2,
56769a74367SOliver-Rainer Wittmann                 "<SwTxtInputFld::UpdateFieldContent()> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
56869a74367SOliver-Rainer Wittmann         // skip CH_TXT_ATR_INPUTFIELDSTART character
56969a74367SOliver-Rainer Wittmann         const xub_StrLen nIdx = (*GetStart()) + 1;
57069a74367SOliver-Rainer Wittmann         // skip CH_TXT_ATR_INPUTFIELDEND character
57169a74367SOliver-Rainer Wittmann         const xub_StrLen nLen = static_cast<xub_StrLen>(std::max( 0, ( (*End()) - 1 - nIdx ) ));
57269a74367SOliver-Rainer Wittmann         const String aNewFieldContent = GetTxtNode().GetExpandTxt( nIdx, nLen );
57369a74367SOliver-Rainer Wittmann 
57469a74367SOliver-Rainer Wittmann         const SwInputField* pInputFld = dynamic_cast<const SwInputField*>(GetFmtFld().GetField());
57569a74367SOliver-Rainer Wittmann         ASSERT( pInputFld != NULL,
57669a74367SOliver-Rainer Wittmann                 "<SwTxtInputFld::GetContent()> - Missing <SwInputFld> instance!" );
57769a74367SOliver-Rainer Wittmann         if ( pInputFld != NULL )
57869a74367SOliver-Rainer Wittmann         {
57969a74367SOliver-Rainer Wittmann             const_cast<SwInputField*>(pInputFld)->applyFieldContent( aNewFieldContent );
58077f92f50SOliver-Rainer Wittmann             // trigger update of fields for scenarios in which the Input Field's content is part of e.g. a table formula
58177f92f50SOliver-Rainer Wittmann             GetTxtNode().GetDoc()->GetUpdtFlds().SetFieldsDirty( sal_True );
58269a74367SOliver-Rainer Wittmann         }
58369a74367SOliver-Rainer Wittmann     }
58469a74367SOliver-Rainer Wittmann }
58569a74367SOliver-Rainer Wittmann 
UpdateTextNodeContent(const String & rNewContent)58669a74367SOliver-Rainer Wittmann void SwTxtInputFld::UpdateTextNodeContent( const String& rNewContent )
58769a74367SOliver-Rainer Wittmann {
58869a74367SOliver-Rainer Wittmann     if ( !IsFldInDoc() )
58969a74367SOliver-Rainer Wittmann     {
59069a74367SOliver-Rainer Wittmann         ASSERT( false, "<SwTxtInputFld::UpdateTextNodeContent(..)> - misusage as Input Field is not in document content." );
59169a74367SOliver-Rainer Wittmann         return;
59269a74367SOliver-Rainer Wittmann     }
59369a74367SOliver-Rainer Wittmann 
59469a74367SOliver-Rainer Wittmann     ASSERT( (*End()) - (*GetStart()) >= 2,
59569a74367SOliver-Rainer Wittmann             "<SwTxtInputFld::UpdateTextNodeContent(..)> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
59669a74367SOliver-Rainer Wittmann     // skip CH_TXT_ATR_INPUTFIELDSTART character
59769a74367SOliver-Rainer Wittmann     const xub_StrLen nIdx = (*GetStart()) + 1;
59869a74367SOliver-Rainer Wittmann     // skip CH_TXT_ATR_INPUTFIELDEND character
59969a74367SOliver-Rainer Wittmann     const xub_StrLen nDelLen = static_cast<xub_StrLen>(std::max( 0, ( (*End()) - 1 - nIdx ) ));
60069a74367SOliver-Rainer Wittmann     SwIndex aIdx( &GetTxtNode(), nIdx );
60169a74367SOliver-Rainer Wittmann     GetTxtNode().ReplaceText( aIdx, nDelLen, rNewContent );
60269a74367SOliver-Rainer Wittmann }
603dec99bbdSOliver-Rainer Wittmann 
604dec99bbdSOliver-Rainer Wittmann 
605dec99bbdSOliver-Rainer Wittmann 
606dec99bbdSOliver-Rainer Wittmann 
607dec99bbdSOliver-Rainer Wittmann // text annotation field
SwTxtAnnotationFld(SwFmtFld & rAttr,xub_StrLen const nStart,const bool bIsClipboardDoc)608dec99bbdSOliver-Rainer Wittmann SwTxtAnnotationFld::SwTxtAnnotationFld(
609dec99bbdSOliver-Rainer Wittmann     SwFmtFld & rAttr,
6107887cc2eSOliver-Rainer Wittmann     xub_StrLen const nStart,
6117887cc2eSOliver-Rainer Wittmann     const bool bIsClipboardDoc )
6127887cc2eSOliver-Rainer Wittmann     : SwTxtFld( rAttr, nStart, bIsClipboardDoc )
613dec99bbdSOliver-Rainer Wittmann {
614dec99bbdSOliver-Rainer Wittmann }
615dec99bbdSOliver-Rainer Wittmann 
~SwTxtAnnotationFld()616dec99bbdSOliver-Rainer Wittmann SwTxtAnnotationFld::~SwTxtAnnotationFld()
617dec99bbdSOliver-Rainer Wittmann {
618dec99bbdSOliver-Rainer Wittmann }
619dec99bbdSOliver-Rainer Wittmann 
620dec99bbdSOliver-Rainer Wittmann 
GetAnnotationMark(SwDoc * pDoc) const621dec99bbdSOliver-Rainer Wittmann ::sw::mark::IMark* SwTxtAnnotationFld::GetAnnotationMark(
622dec99bbdSOliver-Rainer Wittmann     SwDoc* pDoc ) const
623dec99bbdSOliver-Rainer Wittmann {
624dec99bbdSOliver-Rainer Wittmann     const SwPostItField* pPostItField = dynamic_cast<const SwPostItField*>(GetFmtFld().GetField());
625dec99bbdSOliver-Rainer Wittmann     ASSERT( pPostItField != NULL, "<SwTxtAnnotationFld::GetAnnotationMark()> - field missing" );
626dec99bbdSOliver-Rainer Wittmann     if ( pPostItField == NULL )
627dec99bbdSOliver-Rainer Wittmann     {
628dec99bbdSOliver-Rainer Wittmann         return NULL;
629dec99bbdSOliver-Rainer Wittmann     }
630dec99bbdSOliver-Rainer Wittmann 
631dec99bbdSOliver-Rainer Wittmann     if ( pDoc == NULL )
632dec99bbdSOliver-Rainer Wittmann     {
633dec99bbdSOliver-Rainer Wittmann         pDoc = static_cast<const SwPostItFieldType*>(pPostItField->GetTyp())->GetDoc();
634dec99bbdSOliver-Rainer Wittmann     }
635dec99bbdSOliver-Rainer Wittmann     ASSERT( pDoc != NULL, "<SwTxtAnnotationFld::GetAnnotationMark()> - missing document" );
636dec99bbdSOliver-Rainer Wittmann     if ( pDoc == NULL )
637dec99bbdSOliver-Rainer Wittmann     {
638dec99bbdSOliver-Rainer Wittmann         return NULL;
639dec99bbdSOliver-Rainer Wittmann     }
640dec99bbdSOliver-Rainer Wittmann 
641dec99bbdSOliver-Rainer Wittmann     IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
642dec99bbdSOliver-Rainer Wittmann     IDocumentMarkAccess::const_iterator_t pMark = pMarksAccess->findAnnotationMark( pPostItField->GetName() );
643dec99bbdSOliver-Rainer Wittmann     return pMark != pMarksAccess->getAnnotationMarksEnd()
644dec99bbdSOliver-Rainer Wittmann            ? pMark->get()
645dec99bbdSOliver-Rainer Wittmann            : NULL;
646dec99bbdSOliver-Rainer Wittmann }
647