22#include <libxml/xmlwriter.h>
30#include <unofield.hxx>
45#include <osl/diagnose.h>
52 , mpTextField( nullptr )
59 , mpField( rField.CopyField() )
60 , mpTextField( nullptr )
62 rField.
GetTyp()->Add(
this);
97 , mpTextField( nullptr )
102 rAttr.
mpField->GetTyp()->Add(
this);
143 if( !(pType && pType->HasOnlyOneListener()) )
147 switch( pType->
Which() )
166 pType->Remove(
this );
203 assert(SfxPoolItem::operator==(rAttr));
226 if (rHint.
GetId() == SfxHintId::SwField)
228 const auto pFieldHint =
static_cast<const SwFieldHint*
>( &rHint );
230 SwPaM* pPaM = pFieldHint->m_pPaM;
240 OUString
const aEntry(
mpField->ExpandField(rDoc.
IsClipBoard(), pFieldHint->m_pLayout));
246 else if (rHint.
GetId() == SfxHintId::SwLegacyModify)
253 else if (rHint.
GetId() == SfxHintId::SwFindFormatForField)
256 if(pFindForFieldHint->m_rpFormat ==
nullptr && pFindForFieldHint->m_pField ==
GetField())
259 else if (rHint.
GetId() == SfxHintId::SwFindFormatForPostItId)
263 if(pPostItField && pFindForPostItIdHint->m_rpFormat ==
nullptr && pFindForPostItIdHint->m_nPostItId == pPostItField->GetPostItId())
264 pFindForPostItIdHint->m_rpFormat =
this;
266 else if (rHint.
GetId() == SfxHintId::SwCollectPostIts)
272 else if (rHint.
GetId() == SfxHintId::SwHasHiddenInformationNotes)
278 else if (rHint.
GetId() == SfxHintId::SwGatherNodeIndex)
282 pGatherNodeIndexHint->
m_rvNodeIndex.push_back(pTextField->GetTextNode().GetIndex());
284 else if (rHint.
GetId() == SfxHintId::SwGatherRefFields)
293 else if (rHint.
GetId() == SfxHintId::SwGatherFields)
296 if(pGatherFieldsHint->m_bCollectOnlyInDocNodes)
304 pGatherFieldsHint->m_rvFields.push_back(
this);
326 OSL_ENSURE( pTextNd,
"Where is my Node?" );
328 bool bTriggerNode =
false;
329 bool bExpand =
false;
334 switch(pNew->
Which())
362 switch (
mpField->GetTyp()->Which())
398 bool bForceNotify = pOld ==
nullptr && pNew ==
nullptr;
408 sal_uInt16 nSubType = pDocInfoField->
GetSubType();
417 bForceNotify =
false;
431 return nullptr == pTextNd ||
450 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwFormatField"));
451 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
452 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"mpTextField"),
"%p",
mpTextField);
460 (void)xmlTextWriterEndElement(pWriter);
467 sal_Int32
const nStartPos,
468 bool const bInClipboard)
472 , m_aExpand( rAttr.GetField()->ExpandField(bInClipboard, nullptr) )
473 , m_pTextNode( nullptr )
496 OSL_ENSURE(
m_pTextNode,
"SwTextField: where is my TextNode?" );
504 const bool bSameExpandSimpleNotification
514 bool bHiddenParaChanged =
false;
515 if (aNewExpand !=
m_aExpand || bSameExpandSimpleNotification)
520 if ( bSameExpandSimpleNotification )
522 if( bHiddenParaChanged )
539 OSL_ENSURE(
m_pTextNode,
"SwTextField: where is my TextNode?" );
540 OSL_ENSURE( pDest->
m_pTextNode,
"SwTextField: where is pDest's TextNode?" );
548 if( pIDFA != pDestIDFA )
576 OSL_ENSURE( pFieldType,
"unknown FieldType" );
577 pFieldType->Add( &rDestFormatField );
610 std::shared_ptr< SwPaM >& rPamForTextField )
614 SAL_WARN(
"sw.core",
"<SwTextField::GetPamForField> - missing <SwTextNode>");
620 rPamForTextField = std::make_shared<SwPaM>( rTextNode,
621 (rTextField.
End() !=
nullptr) ? *(rTextField.
End()) : ( rTextField.
GetStart() + 1 ),
632 std::shared_ptr< SwPaM > pPamForTextField;
634 if (pPamForTextField !=
nullptr)
646 sal_Int32
const nStart,
647 sal_Int32
const nEnd,
648 bool const bInClipboard )
653 , m_bLockNotifyContentChange( false )
703 "<SwTextInputField::UpdateFieldContent()> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
705 const sal_Int32 nIdx =
GetStart() + 1;
707 const sal_Int32 nLen =
static_cast<sal_Int32
>(std::max<sal_Int32>( 0, ( (*
End()) - 1 - nIdx ) ));
713 const_cast<SwInputField*
>(pInputField)->applyFieldContent( aNewFieldContent );
719 const_cast<SwSetExpField*
>(pExpField)->SetPar2(aNewFieldContent);
721 assert(pInputField || pExpField);
730 "<SwTextInputField::UpdateTextNodeContent(..)> - misusage as Input Field is not in document content.");
733 "<SwTextInputField::UpdateTextNodeContent(..)> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
735 const sal_Int32 nIdx =
GetStart() + 1;
737 const sal_Int32 nDelLen = std::max<sal_Int32>( 0, ( (*
End()) - 1 - nIdx ) );
747 sal_Int32
const nStart,
748 bool const bInClipboard )
761 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 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.
double GetValue(SwCalc &rCalc)
struct _xmlTextWriter * xmlTextWriterPtr
@ Database
For old documents the Field-Which IDs must be preserved !!!
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(181)
constexpr TypedWhichId< SwRefMarkFieldUpdate > RES_REFMARKFLD_UPDATE(168)
constexpr TypedWhichId< SwMsgPoolItem > RES_HIDDENPARA_PRINT(178)
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_OBJECTDYING(RES_MSG_BEGIN)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(60)
constexpr TypedWhichId< SwDocPosUpdate > RES_DOCPOS_UPDATE(169)
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(162)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
constexpr TypedWhichId< SwAutoFormatGetDocNode > RES_AUTOFMT_DOCNODE(173)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
#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