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));
214 return buf.makeStringAndClear();
219 SwRootFrame const*
const pLayout,
bool bInclStrings)
const
225 bool bMakeNum =
true;
273 return uno::Reference<text::XTextRange>();
284 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwFormatFootnote"));
285 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"ptr"),
"%p",
this);
286 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST(
"text-attr"),
"%p",
m_pTextAttr);
287 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"endnote"),
288 BAD_CAST(OString::boolean(
m_bEndNote).getStr()));
292 (void)xmlTextWriterEndElement(pWriter);
297 , m_pTextNode( nullptr )
298 , m_nSeqNo( USHRT_MAX )
358 if( !pDoc->
IsInDtor() && n < pDoc->GetFootnoteIdxs().
size() )
368 sal_uInt16
const nNumberRLHidden,
const OUString &sNumStr)
373 if ( sNumStr.isEmpty() )
392 for( ; nSttIdx < nEndIdx; ++nSttIdx )
395 if( ( pNd = rNodes[ nSttIdx ] )->IsTextNode() )
396 static_cast<SwTextNode*
>(pNd)->TriggerNodeUpdate(aHint);
434 rDstNodes.
Delete( aStart, nDestLen );
467 if(
nullptr == pFormatColl )
478 OSL_ENSURE(
m_pTextNode,
"SwTextFootnote: where is my TextNode?" );
482 bool bFrameFnd =
false;
523 while ( pFootnote && pFootnote->
GetMaster() )
525 OSL_ENSURE( pFootnote->
GetAttr() ==
this,
"Footnote mismatch error." );
553 std::set<sal_uInt16> aUsedNums;
554 std::vector<SwTextFootnote*> badRefNums;
555 ::lcl_FillUsedFootnoteRefNumbers(rDoc,
this, aUsedNums, badRefNums);
556 if ( ::lcl_IsRefNumAvailable(aUsedNums,
m_nSeqNo) )
558 std::vector<sal_uInt16> unused;
559 ::lcl_FillUnusedSeqRefNums(unused, aUsedNums, 1);
567 std::set<sal_uInt16> aUsedNums;
568 std::vector<SwTextFootnote*> badRefNums;
569 ::lcl_FillUsedFootnoteRefNumbers(rDoc,
nullptr, aUsedNums, badRefNums);
570 std::vector<sal_uInt16> aUnused;
571 ::lcl_FillUnusedSeqRefNums(aUnused, aUsedNums, badRefNums.size());
573 for (
size_t i = 0;
i < badRefNums.size(); ++
i)
575 badRefNums[
i]->m_nSeqNo = aUnused[
i];
587 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwTextFootnote"));
592 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_oStartNode"));
593 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"index"),
594 BAD_CAST(OString::number(sal_Int32(
m_oStartNode->GetIndex())).getStr()));
595 (void)xmlTextWriterEndElement(pWriter);
599 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_pTextNode"));
600 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"index"),
602 (void)xmlTextWriterEndElement(pWriter);
604 (void)xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_nSeqNo"));
605 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"value"),
606 BAD_CAST(OString::number(
m_nSeqNo).getStr()));
607 (void)xmlTextWriterEndElement(pWriter);
609 (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.