20 #include <libxml/xmlwriter.h>
38 #include <section.hxx>
42 #include <rtl/ustrbuf.hxx>
45 #include <osl/diagnose.h>
53 void lcl_FillUsedFootnoteRefNumbers(
SwDoc &rDoc,
55 std::set<sal_uInt16> &rUsedRef,
56 std::vector<SwTextFootnote*> &rInvalid)
62 for(
size_t n = 0;
n < ftnIdxs.
size(); ++
n )
65 if ( pTextFootnote != pExclude )
69 rInvalid.push_back(pTextFootnote);
83 bool lcl_IsRefNumAvailable(std::set<sal_uInt16>
const &rUsedNums,
88 if ( rUsedNums.count(requested) )
97 void lcl_FillUnusedSeqRefNums(std::vector<sal_uInt16> &rLowestUnusedNums,
98 const std::set<sal_uInt16> &rUsedNums,
104 rLowestUnusedNums.reserve(numRequired);
105 sal_uInt16 newNum = 0;
107 for(
const auto& rNum : rUsedNums )
109 while ( newNum < rNum )
111 rLowestUnusedNums.push_back( newNum++ );
112 if ( --numRequired == 0)
120 rLowestUnusedNums.push_back( newNum++ );
122 while ( --numRequired > 0 );
129 ,
sw::BroadcastingModify()
130 , m_pTextAttr(nullptr)
132 , m_nNumberRLHidden(0)
133 , m_bEndNote(bEndNote)
139 assert(SfxPoolItem::operator==(rAttr));
142 m_aNumber == static_cast<const SwFormatFootnote&>(rAttr).m_aNumber &&
163 SetXFootnote(css::uno::Reference<css::text::XFootnote>(
nullptr));
169 &static_cast<sw::BroadcastingModify&>(*
this));
199 if( pCNd->IsTextNode() ) {
200 buf.append(static_cast<SwTextNode*>(pCNd)->GetExpandText(&rLayout));
203 while ( !aIdx.GetNode().IsEndNode() ) {
204 if ( aIdx.GetNode().IsTextNode() )
207 buf.append(aIdx.GetNode().GetTextNode()->GetExpandText(&rLayout));
213 return buf.makeStringAndClear();
218 SwRootFrame const*
const pLayout,
bool bInclStrings)
const
224 bool bMakeNum =
true;
272 return uno::Reference<text::XTextRange>();
275 ++aPam.GetMark()->nContent;
276 const uno::Reference<text::XTextRange> xRet =
283 , m_pTextNode( nullptr )
362 sal_uInt16
const nNumberRLHidden,
const OUString &sNumStr)
367 if ( sNumStr.isEmpty() )
386 for( ; nSttIdx < nEndIdx; ++nSttIdx )
389 if( ( pNd = rNodes[ nSttIdx ] )->IsTextNode() )
390 static_cast<SwTextNode*
>(pNd)->TriggerNodeUpdate(aHint);
418 SwNodeIndex aEnd( *aStart.GetNode().EndOfSectionNode() );
428 rDstNodes.
Delete( aStart, nDestLen );
461 if(
nullptr == pFormatColl )
472 OSL_ENSURE(
m_pTextNode,
"SwTextFootnote: where is my TextNode?" );
476 bool bFrameFnd =
false;
517 while ( pFootnote && pFootnote->
GetMaster() )
519 OSL_ENSURE( pFootnote->
GetAttr() ==
this,
"Footnote mismatch error." );
547 std::set<sal_uInt16> aUsedNums;
548 std::vector<SwTextFootnote*> badRefNums;
549 ::lcl_FillUsedFootnoteRefNumbers(rDoc,
this, aUsedNums, badRefNums);
550 if ( ::lcl_IsRefNumAvailable(aUsedNums,
m_nSeqNo) )
552 std::vector<sal_uInt16> unused;
553 ::lcl_FillUnusedSeqRefNums(unused, aUsedNums, 1);
561 std::set<sal_uInt16> aUsedNums;
562 std::vector<SwTextFootnote*> badRefNums;
563 ::lcl_FillUsedFootnoteRefNumbers(rDoc,
nullptr, aUsedNums, badRefNums);
564 std::vector<sal_uInt16> aUnused;
565 ::lcl_FillUnusedSeqRefNums(aUnused, aUsedNums, badRefNums.size());
567 for (
size_t i = 0;
i < badRefNums.size(); ++
i)
569 badRefNums[
i]->m_nSeqNo = aUnused[
i];
583 xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwTextFootnote"));
588 xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_pStartNode"));
589 xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"index"),
590 BAD_CAST(OString::number(
m_pStartNode->GetIndex()).getStr()));
591 xmlTextWriterEndElement(pWriter);
595 xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_pTextNode"));
596 xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"index"),
598 xmlTextWriterEndElement(pWriter);
600 xmlTextWriterStartElement(pWriter, BAD_CAST(
"m_nSeqNo"));
601 xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"value"),
602 BAD_CAST(OString::number(
m_nSeqNo).getStr()));
603 xmlTextWriterEndElement(pWriter);
605 xmlTextWriterEndElement(pWriter);
OUString GetNumStr(sal_Int32 nNo) const
Starts a section of nodes in the document model.
Base class of the Writer layout elements.
constexpr TypedWhichId< SwFormatEndAtTextEnd > RES_END_AT_TXTEND(118)
SwNode & GetEndOfInserts() const
Section for all footnotes.
sal_uLong GetIndex() const
Represents the style of a paragraph.
const OUString & GetSuffix() const
void SetHasDummyChar(const bool bFlag)
void TriggerNodeUpdate(const sw::LegacyModifyHint &)
for hanging TextFormatCollections somewhere else (Outline-Numbering!)
SwDoc & GetDoc()
Which Doc contains the nodes-array?
-""- and with own numberformat
SwSectionFormat * GetFormat()
static void DestroyFrame(SwFrame *const pFrame)
this is the only way to delete a SwFrame instance
Dialog to specify the properties of date form field.
IDocumentContentOperations const & getIDocumentContentOperations() const
The root element of a Writer document layout.
bool IsFootnoteFrame() const
SwTextFormatColl * GetFootnoteTextColl() const
const SwSection & GetSection() const
void Delete(const SwNodeIndex &rPos, sal_uLong nNodes=1)
delete nodes
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
sal_uLong GetIndex() const
sal_Int32 GetStart() const
virtual void DeleteSection(SwNode *pNode)=0
Delete section containing the node.
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(58)
SwStartNode * MakeTextSection(const SwNodeIndex &rWhere, SwStartNodeType eSttNdTyp, SwTextFormatColl *pColl)
PaM is Point and Mark: a selection of the document model.
struct _xmlTextWriter * xmlTextWriterPtr
SwPageFrame * FindPageFrame()
::sw::DocumentContentOperationsManager const & GetDocumentContentOperationsManager() const
SwLayoutFrame * GetUpper()
Marks a node in the document model.
SwNodes & GetNodes()
Node is in which nodes-array/doc?
A page of the document layout.
const SwFormatFootnote & GetFootnote() const
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(179)
const_iterator begin() const
const OUString & GetPrefix() const
SwTextNode is a paragraph in the document model.
void CopyWithFlyInFly(const SwNodeRange &rRg, const SwNodeIndex &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...
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
virtual void CallSwClientNotify(const SfxHint &rHint) const override
SwFootnoteIdxs & GetFootnoteIdxs()
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
std::pair< const_iterator, bool > insert(Value &&x)
SwContentNode * GoNext(SwNodeIndex *) const
constexpr TypedWhichId< SwFormatFootnoteAtTextEnd > RES_FTN_AT_TXTEND(117)
const SwFootnoteInfo & GetFootnoteInfo() const
SwRootFrame * getRootFrame()
const SwEndNoteInfo & GetEndNoteInfo() const
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
size_type erase(const Value &x)
Base class of the Writer document model elements.