22 #include <libxml/xmlwriter.h>
44 #include <osl/diagnose.h>
51 , mpTextField( nullptr )
58 , mpField( rField.CopyField() )
59 , mpTextField( nullptr )
96 , mpTextField( nullptr )
101 rAttr.
mpField->GetTyp()->Add(
this);
146 switch( pType->
Which() )
202 assert(SfxPoolItem::operator==(rAttr));
204 && static_cast<const SwFormatField&>(rAttr).
mpField
208 ( !
mpField && !static_cast<const SwFormatField&>(rAttr).mpField );
225 if (
const auto pFieldHint = dynamic_cast<const SwFieldHint*>( &rHint ))
228 SwPaM* pPaM = pFieldHint->m_pPaM;
239 OUString
const aEntry(
mpField->ExpandField(rDoc.
IsClipBoard(), pFieldHint->m_pLayout));
244 }
else if (rHint.
GetId() == SfxHintId::SwLegacyModify)
250 }
else if (
const auto pFindForFieldHint = dynamic_cast<const sw::FindFormatForFieldHint*>( &rHint ))
252 if(pFindForFieldHint->m_rpFormat ==
nullptr && pFindForFieldHint->m_pField ==
GetField())
253 pFindForFieldHint->m_rpFormat =
this;
254 }
else if (
const auto pFindForPostItIdHint = dynamic_cast<const sw::FindFormatForPostItIdHint*>( &rHint ))
257 if(pPostItField && pFindForPostItIdHint->m_rpFormat ==
nullptr && pFindForPostItIdHint->m_nPostItId == pPostItField->GetPostItId())
258 pFindForPostItIdHint->m_rpFormat =
this;
259 }
else if (
const auto pCollectPostItsHint = dynamic_cast<const sw::CollectPostItsHint*>( &rHint ))
262 pCollectPostItsHint->m_rvFormatFields.push_back(
this);
263 }
else if (
const auto pHasHiddenInfoHint = dynamic_cast<const sw::HasHiddenInformationNotesHint*>( &rHint ))
266 pHasHiddenInfoHint->m_rbHasHiddenInformationNotes =
true;
267 }
else if (
const auto pGatherNodeIndexHint = dynamic_cast<const sw::GatherNodeIndexHint*>( &rHint ))
270 pGatherNodeIndexHint->m_rvNodeIndex.push_back(pTextField->GetTextNode().GetIndex());
271 }
else if (
const auto pGatherRefFieldsHint = dynamic_cast<const sw::GatherRefFieldsHint*>( &rHint ))
277 pGatherRefFieldsHint->m_rvRFields.push_back(static_cast<SwGetRefField*>(
GetField()));
278 }
else if (
const auto pGatherFieldsHint = dynamic_cast<const sw::GatherFieldsHint*>( &rHint ))
280 if(pGatherFieldsHint->m_bCollectOnlyInDocNodes)
288 pGatherFieldsHint->m_rvFields.push_back(
this);
310 OSL_ENSURE( pTextNd,
"Where is my Node?" );
312 bool bTriggerNode =
false;
313 bool bExpand =
false;
318 switch(pNew->
Which())
346 switch (
mpField->GetTyp()->Which())
382 bool bForceNotify = pOld ==
nullptr && pNew ==
nullptr;
392 sal_uInt16 nSubType = pDocInfoField->
GetSubType();
401 bForceNotify =
false;
415 return nullptr == pTextNd ||
434 (
void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwFormatField"));
435 (
void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
436 (
void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"mpTextField"),
"%p",
mpTextField);
444 (
void)xmlTextWriterEndElement(pWriter);
451 sal_Int32
const nStartPos,
452 bool const bInClipboard)
456 , m_aExpand( rAttr.GetField()->ExpandField(bInClipboard, nullptr) )
457 , m_pTextNode( nullptr )
480 OSL_ENSURE(
m_pTextNode,
"SwTextField: where is my TextNode?" );
488 const bool bSameExpandSimpleNotification
496 || static_cast<const SwGetExpField*>(pField)->IsInBodyText());
498 bool bHiddenParaChanged =
false;
499 if (aNewExpand !=
m_aExpand || bSameExpandSimpleNotification)
504 if ( bSameExpandSimpleNotification )
506 if( bHiddenParaChanged )
523 OSL_ENSURE(
m_pTextNode,
"SwTextField: where is my TextNode?" );
524 OSL_ENSURE( pDest->
m_pTextNode,
"SwTextField: where is pDest's TextNode?" );
532 if( pIDFA != pDestIDFA )
560 OSL_ENSURE( pFieldType,
"unknown FieldType" );
561 pFieldType->
Add( &rDestFormatField );
575 && static_cast<SwTableField*>(rDestFormatField.
GetField())->IsIntrnlName() )
594 std::shared_ptr< SwPaM >& rPamForTextField )
598 SAL_WARN(
"sw.core",
"<SwTextField::GetPamForField> - missing <SwTextNode>");
604 rPamForTextField = std::make_shared<SwPaM>( rTextNode,
605 (rTextField.
End() !=
nullptr) ? *(rTextField.
End()) : ( rTextField.
GetStart() + 1 ),
616 std::shared_ptr< SwPaM > pPamForTextField;
618 if (pPamForTextField !=
nullptr)
630 sal_Int32
const nStart,
631 sal_Int32
const nEnd,
632 bool const bInClipboard )
637 , m_bLockNotifyContentChange(
false )
687 "<SwTextInputField::UpdateFieldContent()> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
689 const sal_Int32 nIdx =
GetStart() + 1;
691 const sal_Int32 nLen =
static_cast<sal_Int32
>(std::max<sal_Int32>( 0, ( (*
End()) - 1 - nIdx ) ));
697 const_cast<SwInputField*
>(pInputField)->applyFieldContent( aNewFieldContent );
703 const_cast<SwSetExpField*
>(pExpField)->SetPar2(aNewFieldContent);
705 assert(pInputField || pExpField);
714 "<SwTextInputField::UpdateTextNodeContent(..)> - misusage as Input Field is not in document content.");
717 "<SwTextInputField::UpdateTextNodeContent(..)> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
719 const sal_Int32 nIdx =
GetStart() + 1;
721 const sal_Int32 nDelLen = std::max<sal_Int32>( 0, ( (*
End()) - 1 - nIdx ) );
731 sal_Int32
const nStart,
732 bool const bInClipboard )
745 assert(pPostItField);
Instances of SwFields and those derived from it occur 0 to n times.
void Add(SwClient *pDepend)
The shared part of a user field.
virtual const_iterator_t getAnnotationMarksEnd() const =0
virtual const SwRootFrame * GetCurrentLayout() const =0
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(162)
void SetHasDummyChar(const bool bFlag)
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(181)
void TriggerNodeUpdate(const sw::LegacyModifyHint &)
for hanging TextFormatCollections somewhere else (Outline-Numbering!)
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
Base class of all fields.
Provides access to the marks of a document.
virtual void DeleteRange(SwPaM &)=0
Delete a range SwFlyFrameFormat.
SwTextNode * GetpTextNode() const
virtual ~SwTextInputField() override
IDocumentMarkAccess * getIDocumentMarkAccess()
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
SwClient * Remove(SwClient *pDepend)
IDocumentContentOperations const & getIDocumentContentOperations() const
For old documents the Field-Which IDs must be preserved !!!
virtual void UpdateExpFields(SwTextField *pField, bool bUpdateRefFields)=0
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
constexpr TypedWhichId< SwDocPosUpdate > RES_DOCPOS_UPDATE(169)
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
virtual sal_uInt16 GetSubType() const override
const SwDocInfoSubType DI_SUBJECT
bool CalcHiddenParaField()
Hidden Paragraph Field:
sal_Int32 GetStart() const
virtual void NotifyContentChange(SwFormatField &rFormatField) override
const SwTable & GetTable() const
void CopyTextField(SwTextField *pDest) const
const SwFormatField & GetFormatField() const
bool HasOnlyOneListener() const
virtual const_iterator_t findAnnotationMark(const OUString &rName) const =0
const IDocumentFieldsAccess & getIDocumentFieldsAccess() const
Provides access to the document fields administration interface.
void ExpandTextField(const bool bForceNotify=false) const
const SwDocInfoSubType DI_CUSTOM
virtual ~SwTextField() override
virtual SwFieldType * ChgTyp(SwFieldType *)
Set new type (used for copying among documents).
PaM is Point and Mark: a selection of the document model.
SwTextField(SwFormatField &rAttr, sal_Int32 const nStart, bool const bInClipboard)
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
OUString GetFieldContent() const
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
::sw::mark::IMark * GetAnnotationMark() const
const SwPosition * GetPoint() const
bool IsFieldInDoc() const
SwIndex & Assign(SwIndexReg *, sal_Int32)
Document fields related interfaces.
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
Marks a character position inside a document model node.
constexpr TypedWhichId< SwAutoFormatGetDocNode > RES_AUTOFMT_DOCNODE(173)
double GetValue(SwCalc &rCalc)
SwNodes & GetNodes()
Node is in which nodes-array/doc?
bool IsProtect() const
Is node in something that is protected (range, frame, table cells ...
constexpr TypedWhichId< SwRefMarkFieldUpdate > RES_REFMARKFLD_UPDATE(168)
virtual sal_uInt16 GetSubType() const
bool m_bLockNotifyContentChange
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
void SetHasContent(const bool bFlag)
SwFieldType * GetTyp() const
bool GetInputFlag() const
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(60)
void SetFormatField(SwFormatField &rFormatField)
SwTextNode is a paragraph in the document model.
void Broadcast(const SfxHint &rHint)
OUString ExpandField(bool bCached, SwRootFrame const *pLayout) const
expand the field.
SwTextAnnotationField(SwFormatField &rAttr, sal_Int32 const nStart, bool const bInClipboard)
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...
void SetFieldsDirty(bool b)
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
virtual SwFieldType * InsertFieldType(const SwFieldType &)=0
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
virtual void NotifyContentChange(SwFormatField &rFormatField)
void SetWhich(sal_uInt16 nId)
virtual SwDocUpdateField & GetUpdateFields() const =0
bool LockNotifyContentChange()
const sal_Int32 * End() const
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
virtual void CallSwClientNotify(const SfxHint &rHint) const override
SwTableNode * FindTableNode()
Search table node, in which it is.
const SfxPoolItem & GetAttr() const
void UnlockNotifyContentChange()
#define SAL_WARN(area, stream)
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
struct _xmlTextWriter * xmlTextWriterPtr
const SwGetSetExpType GSE_STRING
String.
virtual SwFieldType * GetSysFieldType(const SwFieldIds eWhich) const =0
constexpr TypedWhichId< SwMsgPoolItem > RES_HIDDENPARA_PRINT(178)
const SwDocInfoSubType DI_CHANGE
void UpdateTextNodeContent(const OUString &rNewContent)
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
virtual ~SwTextAnnotationField() override
SwTextNode & GetTextNode() const
const SwDocInfoSubType DI_TITLE
virtual bool DeleteAndJoin(SwPaM &)=0
complete delete of a given PaM
SwTextInputField(SwFormatField &rAttr, sal_Int32 const nStart, sal_Int32 const nEnd, bool const bInClipboard)
static void GetPamForTextField(const SwTextField &rTextField, std::shared_ptr< SwPaM > &rPamForTextField)
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_OBJECTDYING(RES_MSG_BEGIN)
void UpdateFieldContent()
static void DeleteTextField(const SwTextField &rTextField)
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
bool m_bDetectedRangeSegmentation false