22#include <libxml/xmlwriter.h>
30#include <unofield.hxx>
44#include <osl/diagnose.h>
51 , mpTextField( nullptr )
58 , mpField( rField.CopyField() )
59 , mpTextField( nullptr )
61 rField.
GetTyp()->Add(
this);
96 , mpTextField( nullptr )
101 rAttr.
mpField->GetTyp()->Add(
this);
142 if( !(pType && pType->HasOnlyOneListener()) )
146 switch( pType->
Which() )
165 pType->Remove(
this );
202 assert(SfxPoolItem::operator==(rAttr));
225 if (rHint.
GetId() == SfxHintId::SwField)
227 const auto pFieldHint =
static_cast<const SwFieldHint*
>( &rHint );
229 SwPaM* pPaM = pFieldHint->m_pPaM;
239 OUString
const aEntry(
mpField->ExpandField(rDoc.
IsClipBoard(), pFieldHint->m_pLayout));
245 else if (rHint.
GetId() == SfxHintId::SwLegacyModify)
251 else if (rHint.
GetId() == SfxHintId::SwFindFormatForField)
254 if(pFindForFieldHint->m_rpFormat ==
nullptr && pFindForFieldHint->m_pField ==
GetField())
257 else if (rHint.
GetId() == SfxHintId::SwFindFormatForPostItId)
261 if(pPostItField && pFindForPostItIdHint->m_rpFormat ==
nullptr && pFindForPostItIdHint->m_nPostItId == pPostItField->GetPostItId())
262 pFindForPostItIdHint->m_rpFormat =
this;
264 else if (rHint.
GetId() == SfxHintId::SwCollectPostIts)
270 else if (rHint.
GetId() == SfxHintId::SwHasHiddenInformationNotes)
276 else if (rHint.
GetId() == SfxHintId::SwGatherNodeIndex)
280 pGatherNodeIndexHint->
m_rvNodeIndex.push_back(pTextField->GetTextNode().GetIndex());
282 else if (rHint.
GetId() == SfxHintId::SwGatherRefFields)
291 else if (rHint.
GetId() == SfxHintId::SwGatherFields)
294 if(pGatherFieldsHint->m_bCollectOnlyInDocNodes)
302 pGatherFieldsHint->m_rvFields.push_back(
this);
304 else if (rHint.
GetId() == SfxHintId::SwDocPosUpdate)
312 bool lcl_ExpandField(
const SwFieldIds eId,
const bool bHiddenParaPrint)
317 return !bHiddenParaPrint;
348 bool lcl_NeedsForcedUpdate(
const SwField& rField)
353 sal_uInt16 nSubType = pDocInfoField->
GetSubType();
375 OSL_ENSURE(pTextNd,
"Where is my Node?");
377 auto pType =
mpField->GetTyp();
378 lcl_EnsureUserFieldValid(*pType);
379 if(lcl_TriggerNode(pType->Which()))
381 if(!lcl_ExpandField(pType->Which(),
false))
399 if(SfxHintId::SwLegacyModify != rHint.
GetId())
402 auto pOld = pLegacy->
m_pOld;
403 auto pNew = pLegacy->m_pNew;
404 if (pOld ==
nullptr && pNew ==
nullptr)
425 OSL_ENSURE(pTextNd,
"Where is my Node?");
427 bool bTriggerNode = pNew !=
nullptr;
428 bool bExpand =
false;
431 switch(pNew->Which())
438 auto pType =
mpField->GetTyp();
439 lcl_EnsureUserFieldValid(*pType);
440 bTriggerNode = lcl_TriggerNode(pType->Which());
457 return nullptr == pTextNd ||
476 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwFormatField"));
477 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
478 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"mpTextField"),
"%p",
mpTextField);
486 (void)xmlTextWriterEndElement(pWriter);
493 sal_Int32
const nStartPos,
494 bool const bInClipboard)
498 , m_aExpand( rAttr.GetField()->ExpandField(bInClipboard, nullptr) )
499 , m_pTextNode( nullptr )
522 OSL_ENSURE(
m_pTextNode,
"SwTextField: where is my TextNode?" );
530 const bool bSameExpandSimpleNotification
540 bool bHiddenParaChanged =
false;
541 if (aNewExpand !=
m_aExpand || bSameExpandSimpleNotification)
546 if ( bSameExpandSimpleNotification )
548 if( bHiddenParaChanged )
565 OSL_ENSURE(
m_pTextNode,
"SwTextField: where is my TextNode?" );
566 OSL_ENSURE( pDest->
m_pTextNode,
"SwTextField: where is pDest's TextNode?" );
574 if( pIDFA != pDestIDFA )
602 OSL_ENSURE( pFieldType,
"unknown FieldType" );
603 pFieldType->Add( &rDestFormatField );
636 std::shared_ptr< SwPaM >& rPamForTextField )
640 SAL_WARN(
"sw.core",
"<SwTextField::GetPamForField> - missing <SwTextNode>");
646 rPamForTextField = std::make_shared<SwPaM>( rTextNode,
647 (rTextField.
End() !=
nullptr) ? *(rTextField.
End()) : ( rTextField.
GetStart() + 1 ),
658 std::shared_ptr< SwPaM > pPamForTextField;
660 if (pPamForTextField !=
nullptr)
672 sal_Int32
const nStart,
673 sal_Int32
const nEnd,
674 bool const bInClipboard )
679 , m_bLockNotifyContentChange( false )
729 "<SwTextInputField::UpdateFieldContent()> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
731 const sal_Int32 nIdx =
GetStart() + 1;
733 const sal_Int32 nLen =
static_cast<sal_Int32
>(std::max<sal_Int32>( 0, ( (*
End()) - 1 - nIdx ) ));
739 const_cast<SwInputField*
>(pInputField)->applyFieldContent( aNewFieldContent );
745 const_cast<SwSetExpField*
>(pExpField)->SetPar2(aNewFieldContent);
747 assert(pInputField || pExpField);
756 "<SwTextInputField::UpdateTextNodeContent(..)> - misusage as Input Field is not in document content.");
759 "<SwTextInputField::UpdateTextNodeContent(..)> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
761 const sal_Int32 nIdx =
GetStart() + 1;
763 const sal_Int32 nDelLen = std::max<sal_Int32>( 0, ( (*
End()) - 1 - nIdx ) );
773 sal_Int32
const nStart,
774 bool const bInClipboard )
787 assert(pPostItField);
virtual bool DeleteAndJoin(SwPaM &, SwDeleteFlags flags=SwDeleteFlags::Default)=0
complete delete of a given PaM
virtual void DeleteRange(SwPaM &)=0
Delete a range SwFlyFrameFormat.
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
Document fields related interfaces.
virtual SwFieldType * GetSysFieldType(const SwFieldIds eWhich) const =0
virtual SwFieldType * InsertFieldType(const SwFieldType &)=0
virtual SwDocUpdateField & GetUpdateFields() const =0
virtual void UpdateExpFields(SwTextField *pField, bool bUpdateRefFields)=0
virtual const SwRootFrame * GetCurrentLayout() const =0
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
Provides access to the marks of a document.
virtual const_iterator_t getAnnotationMarksEnd() const =0
virtual const_iterator_t findAnnotationMark(const OUString &rName) const =0
void Broadcast(const SfxHint &rHint)
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
void SetWhich(sal_uInt16 nId)
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Marks a character position inside a document model content node (SwContentNode)
virtual sal_uInt16 GetSubType() const override
void SetFieldsDirty(bool b)
IDocumentContentOperations const & getIDocumentContentOperations() const
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
IDocumentMarkAccess * getIDocumentMarkAccess()
Instances of SwFields and those derived from it occur 0 to n times.
Base class of all fields.
virtual sal_uInt16 GetSubType() const
OUString ExpandField(bool bCached, SwRootFrame const *pLayout) const
expand the field.
virtual SwFieldType * ChgTyp(SwFieldType *)
Set new type (used for copying among documents).
SwFieldType * GetTyp() const
bool IsInBodyText() const
Called by formatting.
bool IsProtect() const
Is node in something that is protected (range, frame, table cells ... including anchor in case of fra...
SwNodes & GetNodes()
Node is in which nodes-array/doc?
SwTableNode * FindTableNode()
Search table node, in which it is.
const IDocumentFieldsAccess & getIDocumentFieldsAccess() const
Provides access to the document fields administration interface.
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
PaM is Point and Mark: a selection of the document model.
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
const SwPosition * GetPoint() const
sal_uInt16 GetType() const
void SetFormatField(SwFormatField &rFormatField)
bool GetInputFlag() const
const SwTable & GetTable() const
::sw::mark::IMark * GetAnnotationMark() const
virtual ~SwTextAnnotationField() override
SwTextAnnotationField(SwFormatField &rAttr, sal_Int32 const nStart, bool const bInClipboard)
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
const SfxPoolItem & GetAttr() const
const sal_Int32 * End() const
sal_Int32 GetStart() const
void SetHasContent(const bool bFlag)
void SetHasDummyChar(const bool bFlag)
const SwFormatField & GetFormatField() const
void CopyTextField(SwTextField *pDest) const
SwTextNode & GetTextNode() const
void ExpandTextField(const bool bForceNotify=false) const
virtual ~SwTextField() override
bool IsFieldInDoc() const
virtual void NotifyContentChange(SwFormatField &rFormatField)
SwTextNode * GetpTextNode() const
static void DeleteTextField(const SwTextField &rTextField)
SwTextField(SwFormatField &rAttr, sal_Int32 const nStart, bool const bInClipboard)
static void GetPamForTextField(const SwTextField &rTextField, std::shared_ptr< SwPaM > &rPamForTextField)
bool m_bLockNotifyContentChange
void UpdateTextNodeContent(const OUString &rNewContent)
OUString GetFieldContent() const
void UnlockNotifyContentChange()
SwTextInputField(SwFormatField &rAttr, sal_Int32 const nStart, sal_Int32 const nEnd, bool const bInClipboard)
void UpdateFieldContent()
virtual ~SwTextInputField() override
virtual void NotifyContentChange(SwFormatField &rFormatField) override
bool LockNotifyContentChange()
SwTextNode is a paragraph in the document model.
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|ExpandMode::HideFieldmarkCommands) const
add 4th optional parameter <bAddSpaceAfterListLabelStr> indicating, when <bWithNum = true> that a spa...
bool CalcHiddenParaField()
Hidden Paragraph Field:
void UpdateDocPos(const SwTwips nDocPos, const sal_uInt32 nIndex)
void ReplaceText(const SwContentIndex &rStart, const sal_Int32 nDelLen, const OUString &rText)
replace nDelLen characters at rStart with rText in case the replacement does not fit,...
void TriggerNodeUpdate(const sw::LegacyModifyHint &)
for hanging TextFormatCollections somewhere else (Outline-Numbering!)
The shared part of a user field.
DocPosUpdate is sent to signal that only the frames from or to a specified document-global position h...
struct _xmlTextWriter * xmlTextWriterPtr
@ Database
For old documents the Field-Which IDs must be preserved !!!
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(181)
constexpr TypedWhichId< SwMsgPoolItem > RES_HIDDENPARA_PRINT(178)
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(169)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(60)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
constexpr TypedWhichId< SwAutoFormatGetDocNode > RES_AUTOFMT_DOCNODE(176)
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_OBJECTDYING(RES_FORMAT_MSG_BEGIN)
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(168)
#define SAL_WARN(area, stream)
const SwDocInfoSubType DI_CUSTOM
const SwDocInfoSubType DI_CHANGE
const SwDocInfoSubType DI_SUBJECT
const SwDocInfoSubType DI_TITLE
const SwGetSetExpType GSE_STRING
String.
bool IsFieldDeletedInModel(IDocumentRedlineAccess const &rIDRA, SwTextField const &rTextField)
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
std::vector< SwFormatField * > & m_rvFormatFields
std::vector< SwNodeOffset > & m_rvNodeIndex
const SfxPoolItem * m_pOld