20#include <libxml/xmlwriter.h>
40#include <rtl/ustrbuf.hxx>
43#include <osl/diagnose.h>
52 void lcl_FillUsedFootnoteRefNumbers(
SwDoc &rDoc,
54 std::set<sal_uInt16> &rUsedRef,
55 std::vector<SwTextFootnote*> &rInvalid)
61 for(
size_t n = 0;
n < ftnIdxs.
size(); ++
n )
64 if ( pTextFootnote != pExclude )
68 rInvalid.push_back(pTextFootnote);
82 bool lcl_IsRefNumAvailable(std::set<sal_uInt16>
const &rUsedNums,
85 if ( USHRT_MAX == requested )
87 if ( rUsedNums.count(requested) )
96 void lcl_FillUnusedSeqRefNums(std::vector<sal_uInt16> &rLowestUnusedNums,
97 const std::set<sal_uInt16> &rUsedNums,
103 rLowestUnusedNums.reserve(numRequired);
104 sal_uInt16 newNum = 0;
106 for(
const auto& rNum : rUsedNums )
108 while ( newNum < rNum )
110 rLowestUnusedNums.push_back( newNum++ );
111 if ( --numRequired == 0)
119 rLowestUnusedNums.push_back( newNum++ );
121 while ( --numRequired > 0 );
128 ,
sw::BroadcastingModify()
129 , m_pTextAttr(nullptr)
131 , m_nNumberRLHidden(0)
132 , m_bEndNote(bEndNote)
141 assert(SfxPoolItem::operator==(rAttr));
160 if (rHint.
GetId() != SfxHintId::SwLegacyModify)
163 CallSwClientNotify(rHint);
171 &
static_cast<sw::BroadcastingModify&
>(*
this));
202 buf.append(
static_cast<SwTextNode*
>(pCNd)->GetExpandText(&rLayout));
215 return buf.makeStringAndClear();
220 SwRootFrame const*
const pLayout,
bool bInclStrings)
const
226 bool bMakeNum =
true;
274 return uno::Reference<text::XTextRange>();
285 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwFormatFootnote"));
286 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
287 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"text-attr"),
"%p",
m_pTextAttr);
288 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"endnote"),
289 BAD_CAST(OString::boolean(
m_bEndNote).getStr()));
293 (void)xmlTextWriterEndElement(pWriter);
298 , m_pTextNode( nullptr )
299 , m_nSeqNo( USHRT_MAX )
359 if( !pDoc->
IsInDtor() && n < pDoc->GetFootnoteIdxs().
size() )
369 sal_uInt16
const nNumberRLHidden,
const OUString &sNumStr)
374 if ( sNumStr.isEmpty() )
393 for( ; nSttIdx < nEndIdx; ++nSttIdx )
396 if( ( pNd = rNodes[ nSttIdx ] )->IsTextNode() )
397 static_cast<SwTextNode*
>(pNd)->TriggerNodeUpdate(aHint);
435 rDstNodes.
Delete( aStart, nDestLen );
468 if(
nullptr == pFormatColl )
479 OSL_ENSURE(
m_pTextNode,
"SwTextFootnote: where is my TextNode?" );
483 bool bFrameFnd =
false;
524 while ( pFootnote && pFootnote->
GetMaster() )
526 OSL_ENSURE( pFootnote->
GetAttr() ==
this,
"Footnote mismatch error." );
554 std::set<sal_uInt16> aUsedNums;
555 std::vector<SwTextFootnote*> badRefNums;
556 ::lcl_FillUsedFootnoteRefNumbers(rDoc,
this, aUsedNums, badRefNums);
557 if ( ::lcl_IsRefNumAvailable(aUsedNums,
m_nSeqNo) )
559 std::vector<sal_uInt16> unused;
560 ::lcl_FillUnusedSeqRefNums(unused, aUsedNums, 1);
568 std::set<sal_uInt16> aUsedNums;
569 std::vector<SwTextFootnote*> badRefNums;
570 ::lcl_FillUsedFootnoteRefNumbers(rDoc,
nullptr, aUsedNums, badRefNums);
571 std::vector<sal_uInt16> aUnused;
572 ::lcl_FillUnusedSeqRefNums(aUnused, aUsedNums, badRefNums.size());
574 for (
size_t i = 0;
i < badRefNums.size(); ++
i)
576 badRefNums[
i]->m_nSeqNo = aUnused[
i];
588 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwTextFootnote"));
593 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_oStartNode"));
594 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"index"),
595 BAD_CAST(OString::number(sal_Int32(
m_oStartNode->GetIndex())).getStr()));
596 (void)xmlTextWriterEndElement(pWriter);
600 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_pTextNode"));
601 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"index"),
603 (void)xmlTextWriterEndElement(pWriter);
605 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_nSeqNo"));
606 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"value"),
607 BAD_CAST(OString::number(
m_nSeqNo).getStr()));
608 (void)xmlTextWriterEndElement(pWriter);
610 (void)xmlTextWriterEndElement(pWriter);
virtual void DeleteSection(SwNode *pNode)=0
Delete section containing the node.
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
OUString GetNumStr(sal_Int32 nNo) const
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
const SwFootnoteInfo & GetFootnoteInfo() const
IDocumentContentOperations const & getIDocumentContentOperations() const
SwFootnoteIdxs & GetFootnoteIdxs()
const SwEndNoteInfo & GetEndNoteInfo() const
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
::sw::DocumentContentOperationsManager const & GetDocumentContentOperationsManager() const
const OUString & GetPrefix() const
const OUString & GetSuffix() const
SwTextFormatColl * GetFootnoteTextColl() const
Base class of the Writer layout elements.
bool IsFootnoteFrame() const
SwLayoutFrame * GetUpper()
SwRootFrame * getRootFrame()
SwPageFrame * FindPageFrame()
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Marks a node in the document model.
const SwNodes & GetNodes() const
SwNodeOffset GetIndex() const
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwNodeOffset GetIndex() const
SwNodes & GetNodes()
Node is in which nodes-array/doc?
const SwEndNode * EndOfSectionNode() const
void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes=SwNodeOffset(1))
SwStartNode * MakeTextSection(const SwNode &rWhere, SwStartNodeType eSttNdTyp, SwTextFormatColl *pColl)
SwContentNode * GoNext(SwNodeIndex *) const
SwNode & GetEndOfInserts() const
Section for all footnotes.
SwDoc & GetDoc()
Which Doc contains the nodes-array?
PaM is Point and Mark: a selection of the document model.
const SwPosition * GetMark() const
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
const SwPosition * End() const
const SwPosition * Start() const
A page of the document layout.
The root element of a Writer document layout.
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding).
A section node represents the start of a section on the UI, i.e.
const SwSection & GetSection() const
SwSectionFormat * GetFormat()
Starts a section of nodes in the document model.
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
const SwFormatFootnote & GetFootnote() const
sal_Int32 GetStart() const
void SetHasDummyChar(const bool bFlag)
Represents the style of a paragraph.
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...
void TriggerNodeUpdate(const sw::LegacyModifyHint &)
for hanging TextFormatCollections somewhere else (Outline-Numbering!)
const_iterator begin() const
size_type erase(const Value &x)
std::pair< const_iterator, bool > insert(Value &&x)
void CopyWithFlyInFly(const SwNodeRange &rRg, SwNode &rInsPos, const std::pair< const SwPaM &, const SwPosition & > *pCopiedPaM=nullptr, bool bMakeNewFrames=true, bool bDelRedlines=true, bool bCopyFlyAtFly=false, SwCopyFlags flags=SwCopyFlags::Default) const
note: rRg/rInsPos exclude a partially selected start text node; pCopiedPaM includes a partially selec...
struct _xmlTextWriter * xmlTextWriterPtr
@ FTNEND_ATTXTEND_OWNNUMANDFMT
-""- and with own numberformat
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(181)
constexpr TypedWhichId< SwFormatEndAtTextEnd > RES_END_AT_TXTEND(124)
constexpr TypedWhichId< SwFormatFootnoteAtTextEnd > RES_FTN_AT_TXTEND(123)
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(59)
Dialog to specify the properties of date form field.
@ RES_POOLCOLL_FOOTNOTE
Footnotes.
@ RES_POOLCOLL_ENDNOTE
Endnotes.
void AdjustContent(sal_Int32 nDelta)
Adjust content index, only valid to call this if the position points to a SwContentNode subclass.