LibreOffice Module sw (master)  1
atrfld.cxx
Go to the documentation of this file.
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 <fmtfld.hxx>
21 
22 #include <libxml/xmlwriter.h>
23 
24 #include <fldbas.hxx>
25 #include <txtfld.hxx>
26 #include <txtannotationfld.hxx>
27 #include <docfld.hxx>
28 #include <docufld.hxx>
29 #include <doc.hxx>
30 
31 #include <pam.hxx>
32 #include <reffld.hxx>
33 #include <ddefld.hxx>
34 #include <usrfld.hxx>
35 #include <expfld.hxx>
36 #include <ndtxt.hxx>
37 #include <calc.hxx>
38 #include <hints.hxx>
40 #include <IDocumentMarkAccess.hxx>
42 #include <fieldhint.hxx>
43 #include <sal/log.hxx>
44 #include <osl/diagnose.h>
45 
46 
47 // constructor for default item in attribute-pool
48 SwFormatField::SwFormatField( sal_uInt16 nWhich )
49  : SfxPoolItem( nWhich )
50  , SfxBroadcaster()
51  , mpTextField( nullptr )
52 {
53 }
54 
57  , SfxBroadcaster()
58  , mpField( rField.CopyField() )
59  , mpTextField( nullptr )
60 {
61  rField.GetTyp()->Add(this);
62  if ( mpField->GetTyp()->Which() == SwFieldIds::Input )
63  {
64  // input field in-place editing
66  static_cast<SwInputField*>(mpField.get())->SetFormatField( *this );
67  }
68  else if (mpField->GetTyp()->Which() == SwFieldIds::SetExp)
69  {
70  // see SwWrtShell::StartInputFieldDlg
71  SwSetExpField *const pSetField(static_cast<SwSetExpField *>(mpField.get()));
72  if (pSetField->GetInputFlag()
73  // only for string fields for now - inline editing of number fields
74  // tends to produce error messages...
75  && (static_cast<SwSetExpFieldType*>(pSetField->GetTyp())->GetType()
77  {
79  }
80  pSetField->SetFormatField(*this);
81  }
82  else if ( mpField->GetTyp()->Which() == SwFieldIds::Postit )
83  {
84  // text annotation field
86  }
87 }
88 
89 // #i24434#
90 // Since Items are used in ItemPool and in default constructed ItemSets with
91 // full pool range, all items need to be clonable. Thus, this one needed to be
92 // corrected
94  : SfxPoolItem( rAttr )
95  , SfxBroadcaster()
96  , mpTextField( nullptr )
97 {
98  if ( rAttr.mpField )
99  {
100  rAttr.mpField->GetTyp()->Add(this);
101  mpField = rAttr.mpField->CopyField();
102  if ( mpField->GetTyp()->Which() == SwFieldIds::Input )
103  {
104  // input field in-place editing
106  SwInputField *pField = dynamic_cast<SwInputField*>(mpField.get());
107  assert(pField);
108  if (pField)
109  pField->SetFormatField( *this );
110  }
111  else if (mpField->GetTyp()->Which() == SwFieldIds::SetExp)
112  {
113  SwSetExpField *const pSetField(static_cast<SwSetExpField *>(mpField.get()));
114  if (pSetField->GetInputFlag()
115  && (static_cast<SwSetExpFieldType*>(pSetField->GetTyp())->GetType()
117  {
119  }
120  // see SwWrtShell::StartInputFieldDlg
121  pSetField->SetFormatField(*this);
122  }
123  else if ( mpField->GetTyp()->Which() == SwFieldIds::Postit )
124  {
125  // text annotation field
127  }
128  }
129 }
130 
132 {
133  SwFieldType* pType = mpField ? mpField->GetTyp() : nullptr;
134 
135  if (pType && pType->Which() == SwFieldIds::Database)
136  pType = nullptr; // DB field types destroy themselves
137 
139  mpField.reset();
140 
141  // some fields need to delete their field type
142  if( pType && pType->HasOnlyOneListener() )
143  {
144  bool bDel = false;
145  switch( pType->Which() )
146  {
147  case SwFieldIds::User:
148  bDel = static_cast<SwUserFieldType*>(pType)->IsDeleted();
149  break;
150 
151  case SwFieldIds::SetExp:
152  bDel = static_cast<SwSetExpFieldType*>(pType)->IsDeleted();
153  break;
154 
155  case SwFieldIds::Dde:
156  bDel = static_cast<SwDDEFieldType*>(pType)->IsDeleted();
157  break;
158  default: break;
159  }
160 
161  if( bDel )
162  {
163  // unregister before deleting
164  pType->Remove( this );
165  delete pType;
166  }
167  }
168 }
169 
171 {
172  rType.Add(this);
173 }
174 
175 void SwFormatField::SetField(std::unique_ptr<SwField> _pField)
176 {
177  mpField = std::move(_pField);
178  if ( mpField->GetTyp()->Which() == SwFieldIds::Input )
179  {
180  static_cast<SwInputField* >(mpField.get())->SetFormatField( *this );
181  }
182  else if (mpField->GetTyp()->Which() == SwFieldIds::SetExp)
183  {
184  // see SwWrtShell::StartInputFieldDlg
185  static_cast<SwSetExpField *>(mpField.get())->SetFormatField(*this);
186  }
188 }
189 
191 {
192  mpTextField = &rTextField;
193 }
194 
196 {
197  mpTextField = nullptr;
198 }
199 
200 bool SwFormatField::operator==( const SfxPoolItem& rAttr ) const
201 {
202  assert(SfxPoolItem::operator==(rAttr));
203  return ( mpField
204  && static_cast<const SwFormatField&>(rAttr).mpField
205  && mpField->GetTyp() == static_cast<const SwFormatField&>(rAttr).mpField->GetTyp()
206  && mpField->GetFormat() == static_cast<const SwFormatField&>(rAttr).mpField->GetFormat() )
207  ||
208  ( !mpField && !static_cast<const SwFormatField&>(rAttr).mpField );
209 }
210 
212 {
213  return new SwFormatField( *this );
214 }
215 
217 {
219  &static_cast<SwModify&>(*this)); // cast to base class (void*)
220  NotifyClients(&item, &item);
221 }
222 
223 void SwFormatField::SwClientNotify( const SwModify& rModify, const SfxHint& rHint )
224 {
225  SwClient::SwClientNotify(rModify, rHint);
226  if (const auto pFieldHint = dynamic_cast<const SwFieldHint*>( &rHint ))
227  {
228  if( !mpTextField )
229  return;
230 
231  // replace field content by text
232  SwPaM* pPaM = pFieldHint->m_pPaM;
233  SwDoc* pDoc = pPaM->GetDoc();
234  const SwTextNode& rTextNode = mpTextField->GetTextNode();
235  pPaM->GetPoint()->nNode = rTextNode;
236  pPaM->GetPoint()->nContent.Assign( const_cast<SwTextNode*>(&rTextNode), mpTextField->GetStart() );
237 
238  OUString const aEntry(mpField->ExpandField(pDoc->IsClipBoard(), pFieldHint->m_pLayout));
239  pPaM->SetMark();
240  pPaM->Move( fnMoveForward );
242  pDoc->getIDocumentContentOperations().InsertString( *pPaM, aEntry );
243  } else if (const auto pLegacyHint = dynamic_cast<const sw::LegacyModifyHint*>( &rHint ))
244  {
245  if( !mpTextField )
246  return;
247  UpdateTextNode(pLegacyHint->m_pOld, pLegacyHint->m_pNew);
248  } else if (const auto pFindForFieldHint = dynamic_cast<const sw::FindFormatForFieldHint*>( &rHint ))
249  {
250  if(pFindForFieldHint->m_rpFormat == nullptr && pFindForFieldHint->m_pField == GetField())
251  pFindForFieldHint->m_rpFormat = this;
252  } else if (const auto pFindForPostItIdHint = dynamic_cast<const sw::FindFormatForPostItIdHint*>( &rHint ))
253  {
254  auto pPostItField = dynamic_cast<SwPostItField*>(mpField.get());
255  if(pPostItField && pFindForPostItIdHint->m_rpFormat == nullptr && pFindForPostItIdHint->m_nPostItId == pPostItField->GetPostItId())
256  pFindForPostItIdHint->m_rpFormat = this;
257  } else if (const auto pCollectPostItsHint = dynamic_cast<const sw::CollectPostItsHint*>( &rHint ))
258  {
259  if(GetTextField() && IsFieldInDoc() && (!pCollectPostItsHint->m_bHideRedlines || !sw::IsFieldDeletedInModel(pCollectPostItsHint->m_rIDRA, *GetTextField())))
260  pCollectPostItsHint->m_rvFormatFields.push_back(this);
261  } else if (const auto pHasHiddenInfoHint = dynamic_cast<const sw::HasHiddenInformationNotesHint*>( &rHint ))
262  {
263  if(!pHasHiddenInfoHint->m_rbHasHiddenInformationNotes && GetTextField() && IsFieldInDoc())
264  pHasHiddenInfoHint->m_rbHasHiddenInformationNotes = true;
265  } else if (const auto pGatherNodeIndexHint = dynamic_cast<const sw::GatherNodeIndexHint*>( &rHint ))
266  {
267  if(auto pTextField = GetTextField())
268  pGatherNodeIndexHint->m_rvNodeIndex.push_back(pTextField->GetTextNode().GetIndex());
269  } else if (const auto pGatherRefFieldsHint = dynamic_cast<const sw::GatherRefFieldsHint*>( &rHint ))
270  {
271  if(!GetTextField() || pGatherRefFieldsHint->m_nType != GetField()->GetSubType())
272  return;
274  if(pNd && pNd->GetNodes().IsDocNodes())
275  pGatherRefFieldsHint->m_rvRFields.push_back(static_cast<SwGetRefField*>(GetField()));
276  }
277 }
278 
280 {
281  if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
282  { // invalidate cached UNO object
283  m_wXTextField = nullptr;
284  // ??? why does this Modify method not already do this?
285  NotifyClients(pOld, pNew);
286  return;
287  }
288 
289  if( !mpTextField )
290  return;
291 
292  // don't do anything, especially not expand!
293  if( pNew && pNew->Which() == RES_OBJECTDYING )
294  return;
295 
296  SwTextNode* pTextNd = &mpTextField->GetTextNode();
297  OSL_ENSURE( pTextNd, "Where is my Node?" );
298 
299  bool bTriggerNode = false;
300  bool bExpand = false;
301  const SfxPoolItem* pNodeOld = nullptr;
302  const SfxPoolItem* pNodeNew = nullptr;
303  if(pNew)
304  {
305  switch(pNew->Which())
306  {
308  // update GetRef fields
309  if( SwFieldIds::GetRef == mpField->GetTyp()->Which() )
310  {
311  // #i81002#
312  static_cast<SwGetRefField*>(mpField.get())->UpdateField( mpTextField );
313  }
314  break;
315  case RES_DOCPOS_UPDATE:
316  // handled in SwTextFrame::Modify()
317  bTriggerNode = true;
318  pNodeOld = pNew;
319  pNodeNew = this;
320  break;
321  case RES_ATTRSET_CHG:
322  case RES_FMT_CHG:
323  bTriggerNode = true;
324  pNodeOld = pOld;
325  pNodeNew = pNew;
326  break;
327  default:
328  break;
329  }
330  }
331  if(!bTriggerNode)
332  {
333  switch (mpField->GetTyp()->Which())
334  {
336  if( !pOld || pOld->Which() != RES_HIDDENPARA_PRINT ) {
337  bExpand =true;
338  break;
339  }
340  [[fallthrough]];
345  bTriggerNode = true;
346  pNodeNew = pNew;
347  break;
348  case SwFieldIds::User:
349  {
350  SwUserFieldType* pType = static_cast<SwUserFieldType*>(mpField->GetTyp());
351  if(!pType->IsValid())
352  {
353  SwCalc aCalc( *pTextNd->GetDoc() );
354  pType->GetValue( aCalc );
355  }
356  bExpand = true;
357  }
358  break;
359  default:
360  bExpand = true;
361  break;
362  }
363  }
364  if(bTriggerNode)
365  {
366  pTextNd->ModifyNotification(pNodeOld, pNodeNew);
367  }
368  if(bExpand)
369  {
370  mpTextField->ExpandTextField( pOld == nullptr && pNew == nullptr );
371  }
372 }
373 
375 {
376  const SwTextNode* pTextNd;
377  return RES_AUTOFMT_DOCNODE != rInfo.Which() ||
378  !mpTextField || nullptr == ( pTextNd = mpTextField->GetpTextNode() ) ||
379  &pTextNd->GetNodes() != static_cast<SwAutoFormatGetDocNode&>(rInfo).pNodes;
380 }
381 
383 {
384  return mpTextField != nullptr
386 }
387 
389 {
390  return mpTextField != nullptr
391  && mpTextField->GetpTextNode() != nullptr
393 }
394 
396 {
397  xmlTextWriterStartElement(pWriter, BAD_CAST("SwFormatField"));
398  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
399  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("mpTextField"), "%p", mpTextField);
400 
401  SfxPoolItem::dumpAsXml(pWriter);
402  mpField->dumpAsXml(pWriter);
403 
404  xmlTextWriterEndElement(pWriter);
405 }
406 
407 // class SwTextField ////////////////////////////////////////////////////
408 
410  SwFormatField & rAttr,
411  sal_Int32 const nStartPos,
412  bool const bInClipboard)
413  : SwTextAttr( rAttr, nStartPos )
414 // fdo#39694 the ExpandField here may not give the correct result in all cases,
415 // but is better than nothing
416  , m_aExpand( rAttr.GetField()->ExpandField(bInClipboard, nullptr) )
417  , m_pTextNode( nullptr )
418 {
419  rAttr.SetTextField( *this );
420  SetHasDummyChar(true);
421 }
422 
424 {
425  SwFormatField & rFormatField( static_cast<SwFormatField &>(GetAttr()) );
426  if ( this == rFormatField.GetTextField() )
427  {
428  rFormatField.ClearTextField();
429  }
430 }
431 
433 {
434  return GetpTextNode() != nullptr
435  && GetpTextNode()->GetNodes().IsDocNodes();
436 }
437 
438 void SwTextField::ExpandTextField(const bool bForceNotify) const
439 {
440  OSL_ENSURE( m_pTextNode, "SwTextField: where is my TextNode?" );
441 
442  const SwField* pField = GetFormatField().GetField();
443  const OUString aNewExpand( pField->ExpandField(m_pTextNode->GetDoc()->IsClipBoard(),
444  // can't do any better than this here...
446 
447  const SwFieldIds nWhich = pField->GetTyp()->Which();
448  const bool bSameExpandSimpleNotification
449  = SwFieldIds::Chapter != nWhich && SwFieldIds::PageNumber != nWhich
450  && SwFieldIds::RefPageGet != nWhich
451  // Page count fields to not use aExpand during formatting,
452  // therefore an invalidation of the text frame has to be triggered even if aNewExpand == aExpand:
453  && (SwFieldIds::DocStat != nWhich
454  || DS_PAGE != static_cast<const SwDocStatField*>(pField)->GetSubType())
455  && (SwFieldIds::GetExp != nWhich
456  || static_cast<const SwGetExpField*>(pField)->IsInBodyText());
457 
458  bool bHiddenParaChanged = false;
459  if (aNewExpand != m_aExpand || bSameExpandSimpleNotification)
460  bHiddenParaChanged = m_pTextNode->CalcHiddenParaField();
461 
462  if (aNewExpand == m_aExpand)
463  {
464  if ( bSameExpandSimpleNotification )
465  {
466  if( bHiddenParaChanged )
467  {
468  m_pTextNode->ModifyNotification( nullptr, nullptr );
469  }
470  if ( !bForceNotify )
471  {
472  // done, if no further notification forced.
473  return;
474  }
475  }
476  }
477  else
478  m_aExpand = aNewExpand;
479 
480  const_cast<SwTextField*>(this)->NotifyContentChange( const_cast<SwFormatField&>(GetFormatField()) );
481 }
482 
484 {
485  OSL_ENSURE( m_pTextNode, "SwTextField: where is my TextNode?" );
486  OSL_ENSURE( pDest->m_pTextNode, "SwTextField: where is pDest's TextNode?" );
487 
490 
491  SwFormatField& rDestFormatField = const_cast<SwFormatField&>(pDest->GetFormatField());
492  const SwFieldIds nFieldWhich = rDestFormatField.GetField()->GetTyp()->Which();
493 
494  if( pIDFA != pDestIDFA )
495  {
496  // different documents, e.g. clipboard:
497  // register field type in target document
498  SwFieldType* pFieldType;
499  if( nFieldWhich != SwFieldIds::Database
500  && nFieldWhich != SwFieldIds::User
501  && nFieldWhich != SwFieldIds::SetExp
502  && nFieldWhich != SwFieldIds::Dde
503  && SwFieldIds::TableOfAuthorities != nFieldWhich )
504  {
505  pFieldType = pDestIDFA->GetSysFieldType( nFieldWhich );
506  }
507  else
508  {
509  pFieldType = pDestIDFA->InsertFieldType( *rDestFormatField.GetField()->GetTyp() );
510  }
511 
512  // DDE fields need special treatment
513  if( SwFieldIds::Dde == nFieldWhich )
514  {
515  if( rDestFormatField.GetTextField() )
516  {
517  static_cast<SwDDEFieldType*>(rDestFormatField.GetField()->GetTyp())->DecRefCnt();
518  }
519  static_cast<SwDDEFieldType*>(pFieldType)->IncRefCnt();
520  }
521 
522  OSL_ENSURE( pFieldType, "unknown FieldType" );
523  pFieldType->Add( &rDestFormatField ); // register at the field type
524  rDestFormatField.GetField()->ChgTyp( pFieldType );
525  }
526 
527  // update expression fields
528  if( nFieldWhich == SwFieldIds::SetExp
529  || nFieldWhich == SwFieldIds::GetExp
530  || nFieldWhich == SwFieldIds::HiddenText )
531  {
532  SwTextField* pField = const_cast<SwTextField*>(this);
533  pDestIDFA->UpdateExpFields( pField, true );
534  }
535  // table fields: external display
536  else if( SwFieldIds::Table == nFieldWhich
537  && static_cast<SwTableField*>(rDestFormatField.GetField())->IsIntrnlName() )
538  {
539  // convert internal (core) to external (UI) formula
540  const SwTableNode* pTableNd = m_pTextNode->FindTableNode();
541  if( pTableNd ) // in a table?
542  static_cast<SwTableField*>(rDestFormatField.GetField())->PtrToBoxNm( &pTableNd->GetTable() );
543  }
544 }
545 
547 {
548  //if not in undo section notify the change
550  {
551  m_pTextNode->ModifyNotification(nullptr, &rFormatField);
552  }
553 }
554 
555 /*static*/
557  const SwTextField& rTextField,
558  std::shared_ptr< SwPaM >& rPamForTextField )
559 {
560  if (rTextField.GetpTextNode() == nullptr)
561  {
562  SAL_WARN("sw.core", "<SwTextField::GetPamForField> - missing <SwTextNode>");
563  return;
564  }
565 
566  const SwTextNode& rTextNode = rTextField.GetTextNode();
567 
568  rPamForTextField = std::make_shared<SwPaM>( rTextNode,
569  (rTextField.End() != nullptr) ? *(rTextField.End()) : ( rTextField.GetStart() + 1 ),
570  rTextNode,
571  rTextField.GetStart() );
572 
573 }
574 
575 /*static*/
576 void SwTextField::DeleteTextField( const SwTextField& rTextField )
577 {
578  if (rTextField.GetpTextNode() != nullptr)
579  {
580  std::shared_ptr< SwPaM > pPamForTextField;
581  GetPamForTextField(rTextField, pPamForTextField);
582  if (pPamForTextField != nullptr)
583  {
584  rTextField.GetTextNode().GetDoc()->getIDocumentContentOperations().DeleteAndJoin(*pPamForTextField);
585  }
586  }
587 }
588 
589 // class SwTextInputField ///////////////////////////////////////////////
590 
591 // input field in-place editing
593  SwFormatField & rAttr,
594  sal_Int32 const nStart,
595  sal_Int32 const nEnd,
596  bool const bInClipboard )
597 
598  : SwTextAttr( rAttr, nStart )
599  , SwTextAttrNesting( rAttr, nStart, nEnd )
600  , SwTextField( rAttr, nStart, bInClipboard )
601  , m_bLockNotifyContentChange( false )
602 {
603  SetHasDummyChar( false );
604  SetHasContent( true );
605 }
606 
608 {
609 }
610 
612 {
614  {
615  return false;
616  }
618  return true;
619 }
620 
622 {
624 }
625 
627 {
629  {
631 
632  SwTextField::NotifyContentChange( rFormatField );
634 
636  }
637 }
638 
640 {
641  return GetFormatField().GetField()->ExpandField(false, nullptr/*ignored anyway*/);
642 }
643 
645 {
646  if ( IsFieldInDoc()
647  && GetStart() != (*End()) )
648  {
649  assert( (*End()) - GetStart() >= 2 &&
650  "<SwTextInputField::UpdateFieldContent()> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
651  // skip CH_TXT_ATR_INPUTFIELDSTART character
652  const sal_Int32 nIdx = GetStart() + 1;
653  // skip CH_TXT_ATR_INPUTFIELDEND character
654  const sal_Int32 nLen = static_cast<sal_Int32>(std::max<sal_Int32>( 0, ( (*End()) - 1 - nIdx ) ));
655  const OUString aNewFieldContent = GetTextNode().GetExpandText(nullptr, nIdx, nLen);
656 
657  const SwField* pField = GetFormatField().GetField();
658  const SwInputField* pInputField = dynamic_cast<const SwInputField*>(pField);
659  if (pInputField)
660  const_cast<SwInputField*>(pInputField)->applyFieldContent( aNewFieldContent );
661 
662  const SwSetExpField* pExpField = dynamic_cast<const SwSetExpField*>(pField);
663  if (pExpField)
664  {
665  assert(pExpField->GetInputFlag());
666  const_cast<SwSetExpField*>(pExpField)->SetPar2(aNewFieldContent);
667  }
668  assert(pInputField || pExpField);
669 
670  // trigger update of fields for scenarios in which the Input Field's content is part of e.g. a table formula
672  }
673 }
674 
675 void SwTextInputField::UpdateTextNodeContent( const OUString& rNewContent )
676 {
677  assert(IsFieldInDoc() &&
678  "<SwTextInputField::UpdateTextNodeContent(..)> - misusage as Input Field is not in document content.");
679 
680  assert( (*End()) - GetStart() >= 2 &&
681  "<SwTextInputField::UpdateTextNodeContent(..)> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
682  // skip CH_TXT_ATR_INPUTFIELDSTART character
683  const sal_Int32 nIdx = GetStart() + 1;
684  // skip CH_TXT_ATR_INPUTFIELDEND character
685  const sal_Int32 nDelLen = std::max<sal_Int32>( 0, ( (*End()) - 1 - nIdx ) );
686  SwIndex aIdx( &GetTextNode(), nIdx );
687  GetTextNode().ReplaceText( aIdx, nDelLen, rNewContent );
688 }
689 
690 // class SwTextAnnotationField //////////////////////////////////////////
691 
692 // text annotation field
694  SwFormatField & rAttr,
695  sal_Int32 const nStart,
696  bool const bInClipboard )
697  : SwTextAttr( rAttr, nStart )
698  , SwTextField( rAttr, nStart, bInClipboard )
699 {
700 }
701 
703 {
704 }
705 
707 {
708  auto pPostItField = dynamic_cast<const SwPostItField*>(GetFormatField().GetField());
709  assert(pPostItField);
710 
711  SwDoc* pDoc = static_cast<const SwPostItFieldType*>(pPostItField->GetTyp())->GetDoc();
712  assert(pDoc != nullptr);
713 
714  IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
715  IDocumentMarkAccess::const_iterator_t pMark = pMarksAccess->findAnnotationMark( pPostItField->GetName() );
716  return pMark != pMarksAccess->getAnnotationMarksEnd()
717  ? *pMark
718  : nullptr;
719 }
720 
721 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:240
virtual bool operator==(const SfxPoolItem &) const override
"Pure virtual methods" of SfxPoolItem.
Definition: atrfld.cxx:200
Definition: calc.hxx:184
SwTextField * mpTextField
Definition: fmtfld.hxx:85
void Add(SwClient *pDepend)
Definition: calbck.cxx:217
OUString m_aExpand
Definition: txtfld.hxx:33
The shared part of a user field.
Definition: usrfld.hxx:35
const SwField * GetField() const
Definition: fmtfld.hxx:106
void SetTextField(SwTextField &rTextField)
Definition: atrfld.cxx:190
virtual void ModifyNotification(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override
Definition: node.hxx:475
virtual const_iterator_t getAnnotationMarksEnd() const =0
#define RES_AUTOFMT_DOCNODE
Definition: hintids.hxx:390
#define RES_ATTRSET_CHG
Definition: hintids.hxx:380
virtual const SwRootFrame * GetCurrentLayout() const =0
bool IsProtect() const
Definition: atrfld.cxx:388
void SetHasDummyChar(const bool bFlag)
Definition: txatbase.hxx:72
SwNodeIndex nNode
Definition: pam.hxx:37
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
Base class of all fields.
Definition: fldbas.hxx:292
Provides access to the marks of a document.
Definition: doc.hxx:186
SwTextNode * m_pTextNode
Definition: txtfld.hxx:34
virtual void DeleteRange(SwPaM &)=0
Delete a range SwFlyFrameFormat.
SwTextNode * GetpTextNode() const
Definition: txtfld.hxx:49
virtual ~SwTextInputField() override
Definition: atrfld.cxx:607
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1681
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:108
virtual bool DeleteAndJoin(SwPaM &, const bool bForceJoinNext=false)=0
complete delete of a given PaM
SwClient * Remove(SwClient *pDepend)
Definition: calbck.cxx:259
void InvalidateField()
Definition: atrfld.cxx:216
#define RES_REMOVE_UNO_OBJECT
Definition: hintids.hxx:398
virtual bool GetInfo(SfxPoolItem &rInfo) const override
Definition: atrfld.cxx:374
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:314
#define RES_DOCPOS_UPDATE
Definition: hintids.hxx:386
For old documents the Field-Which IDs must be preserved !!!
virtual void UpdateExpFields(SwTextField *pField, bool bUpdateRefFields)=0
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:356
SwIndex nContent
Definition: pam.hxx:38
const SwTextField * GetTextField() const
Definition: fmtfld.hxx:124
bool CalcHiddenParaField()
Hidden Paragraph Field:
Definition: ndtxt.hxx:701
sal_Int32 GetStart() const
Definition: txatbase.hxx:82
virtual void NotifyContentChange(SwFormatField &rFormatField) override
Definition: atrfld.cxx:626
void SetField(std::unique_ptr< SwField > pField)
Sets current field.
Definition: atrfld.cxx:175
const SwTable & GetTable() const
Definition: node.hxx:497
void CopyTextField(SwTextField *pDest) const
Definition: atrfld.cxx:483
const SwFormatField & GetFormatField() const
Definition: txatbase.hxx:191
bool HasOnlyOneListener() const
Definition: calbck.hxx:223
virtual const_iterator_t findAnnotationMark(const OUString &rName) const =0
const IDocumentFieldsAccess & getIDocumentFieldsAccess() const
Provides access to the document fields administration interface.
Definition: node.cxx:2061
void ExpandTextField(const bool bForceNotify=false) const
Definition: atrfld.cxx:438
virtual void SwClientNotify(const SwModify &rModify, const SfxHint &rHint) override
Definition: atrfld.cxx:223
virtual ~SwTextField() override
Definition: atrfld.cxx:423
virtual SwFieldType * ChgTyp(SwFieldType *)
Set new type (used for copying among documents).
Definition: fldbas.cxx:364
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
SwTextField(SwFormatField &rAttr, sal_Int32 const nStart, bool const bInClipboard)
Definition: atrfld.cxx:409
struct _xmlTextWriter * xmlTextWriterPtr
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:496
OUString GetFieldContent() const
Definition: atrfld.cxx:639
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
::sw::mark::IMark * GetAnnotationMark() const
Definition: atrfld.cxx:706
const SwPosition * GetPoint() const
Definition: pam.hxx:207
bool IsFieldInDoc() const
Definition: atrfld.cxx:432
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:198
Document fields related interfaces.
SwFormatField(sal_uInt16 nWhich)
Definition: atrfld.cxx:48
SwFieldIds
Definition: fldbas.hxx:44
SwDoc * GetDoc()
Definition: node.hxx:702
std::unique_ptr< SwField > mpField
Definition: fmtfld.hxx:84
SwDoc * GetDoc() const
Definition: pam.hxx:243
Marks a character position inside a document model node.
Definition: index.hxx:37
double GetValue(SwCalc &rCalc)
Definition: usrfld.cxx:231
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
#define RES_HIDDENPARA_PRINT
Definition: hintids.hxx:395
bool IsProtect() const
Is node in something that is protected (range, frame, table cells ...
Definition: node.cxx:418
#define RES_FMT_CHG
Definition: hintids.hxx:379
virtual sal_uInt16 GetSubType() const
Definition: fldbas.cxx:318
void RegisterToFieldType(SwFieldType &)
Definition: atrfld.cxx:170
bool m_bLockNotifyContentChange
Definition: txtfld.hxx:101
#define RES_REFMARKFLD_UPDATE
Definition: hintids.hxx:385
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:404
void ClearTextField()
Definition: atrfld.cxx:195
void SetHasContent(const bool bFlag)
Definition: txatbase.hxx:73
SwFieldType * GetTyp() const
Definition: fldbas.hxx:395
bool GetInputFlag() const
Definition: expfld.hxx:265
void NotifyClients(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue)
Definition: calbck.cxx:167
void SetFormatField(SwFormatField &rFormatField)
Definition: expfld.cxx:833
bool IsFieldInDoc() const
Definition: atrfld.cxx:382
bool IsValid() const
Definition: usrfld.hxx:77
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void Broadcast(const SfxHint &rHint)
virtual ~SwFormatField() override
Definition: atrfld.cxx:131
OUString ExpandField(bool bCached, SwRootFrame const *pLayout) const
expand the field.
Definition: fldbas.cxx:438
#define RES_TXTATR_FIELD
Definition: hintids.hxx:244
SwTextAnnotationField(SwFormatField &rAttr, sal_Int32 const nStart, bool const bInClipboard)
Definition: atrfld.cxx:693
OUString GetExpandText(SwRootFrame const *pLayout, const sal_Int32 nIdx=0, const sal_Int32 nLen=-1, const bool bWithNum=false, const bool bAddSpaceAfterListLabelStr=false, const bool bWithSpacesForLevel=false, const ExpandMode eAdditionalMode=ExpandMode::ExpandFootnote) const
add 4th optional parameter indicating, when that a spa...
Definition: ndtxt.cxx:3374
void SetFieldsDirty(bool b)
Definition: docfld.hxx:164
bool IsFieldDeletedInModel(IDocumentRedlineAccess const &rIDRA, SwTextField const &rTextField)
void ReplaceText(const SwIndex &rStart, const sal_Int32 nDelLen, const OUString &rText)
replace nDelLen characters at rStart with rText in case the replacement does not fit, it is partially inserted up to the capacity of the node
Definition: ndtxt.cxx:3675
virtual SwFieldType * InsertFieldType(const SwFieldType &)=0
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
virtual void NotifyContentChange(SwFormatField &rFormatField)
Definition: atrfld.cxx:546
#define RES_TXTATR_ANNOTATION
Definition: hintids.hxx:247
void SetWhich(sal_uInt16 nId)
bool IsClipBoard() const
Definition: doc.hxx:962
virtual SwDocUpdateField & GetUpdateFields() const =0
css::uno::WeakReference< css::text::XTextField > m_wXTextField
Definition: fmtfld.hxx:82
bool LockNotifyContentChange()
Definition: atrfld.cxx:611
const sal_Int32 * End() const
Definition: txatbase.hxx:148
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:349
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:159
void UnlockNotifyContentChange()
Definition: atrfld.cxx:621
#define RES_OBJECTDYING
Definition: hintids.hxx:378
#define SAL_WARN(area, stream)
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
Definition: nodes.cxx:2313
const SwGetSetExpType GSE_STRING
String.
Definition: fldbas.hxx:202
virtual SwFieldType * GetSysFieldType(const SwFieldIds eWhich) const =0
void UpdateTextNode(const SfxPoolItem *pOld, const SfxPoolItem *pNew)
Definition: atrfld.cxx:279
void UpdateTextNodeContent(const OUString &rNewContent)
Definition: atrfld.cxx:675
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:470
virtual ~SwTextAnnotationField() override
Definition: atrfld.cxx:702
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
void dumpAsXml(xmlTextWriterPtr pWriter) const override
Definition: atrfld.cxx:395
SwTextInputField(SwFormatField &rAttr, sal_Int32 const nStart, sal_Int32 const nEnd, bool const bInClipboard)
Definition: atrfld.cxx:592
#define RES_TXTATR_INPUTFIELD
Definition: hintids.hxx:239
SwFieldIds Which() const
Definition: fldbas.hxx:272
static void GetPamForTextField(const SwTextField &rTextField, std::shared_ptr< SwPaM > &rPamForTextField)
Definition: atrfld.cxx:556
void SetFormatField(SwFormatField &rFormatField)
Definition: expfld.cxx:1242
sal_uInt16 Which() const
virtual SwFormatField * Clone(SfxItemPool *pPool=nullptr) const override
Definition: atrfld.cxx:211
void UpdateFieldContent()
Definition: atrfld.cxx:644
static void DeleteTextField(const SwTextField &rTextField)
Definition: atrfld.cxx:576
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const