22 #include <libxml/xmlwriter.h>
23 #include <osl/diagnose.h>
37 #include <section.hxx>
59 : m_vIndices(nullptr), m_rMyDoc( rDocument )
121 if(
GetDoc().getIDocumentFieldsAccess().SetFieldsDirty(
true, &rDelPos.
GetNode(), nSz ) &&
127 bool bInsOutlineIdx = (
167 if (bInsOutlineIdx && rTextNd.
IsOutline())
180 static_cast<SwContentNode&>(rNd).InvalidateNumRule();
185 bool bSavePersData(
GetDoc().GetIDocumentUndoRedo().IsUndoNodes(rNds));
186 bool bRestPersData(
GetDoc().GetIDocumentUndoRedo().IsUndoNodes(*
this));
188 OSL_ENSURE(!pDestDoc,
"SwNodes::ChgNode(): "
189 "the code to handle text fields here looks broken\n"
190 "if the target is in a different document.");
191 if( !bRestPersData && !bSavePersData && pDestDoc )
192 bSavePersData = bRestPersData =
true;
219 if( pNumRule && sNumRule != pNumRule->
GetName() )
221 sNumRule = pNumRule->
GetName();
247 if (bInsOutlineIdx && pTextNd->
IsOutline())
255 if( pHts && pHts->
Count() )
257 bool const bToUndo = !pDestDoc &&
259 for(
size_t i = pHts->
Count();
i; )
262 switch ( pAttr->
Which() )
295 .InvalidateFootnote();
300 .InvalidateTOXMark();
305 .InvalidateRefMark();
312 static_txtattr_cast<SwTextMeta*>(pAttr));
332 if( pCNd->IsNoTextNode() && bRestPersData )
333 static_cast<SwNoTextNode*>(pCNd)->RestorePersistentData();
361 while( aIdx != rInsPos )
369 static_cast<SwSectionNode*>(pFrameNd)->MakeFramesForAdjacentContentNode(aIdx);
371 static_cast<SwContentNode*
>(pFrameNd)->MakeFramesForAdjacentContentNode(*pCNd);
425 if(
this == &rNodes )
437 SwStartNodePointers::size_type nLevel = 0;
443 aSttNdStack.insert( aSttNdStack.begin(), pStartNode );
449 bool bSaveNewFrames = bNewFrames;
464 ChgNode( aSwIndex, nInsPos, aIdx, bNewFrames );
482 StartOfSectionNode()->
GetIndex() >= nNd ||
488 if( &rNodes ==
this )
502 static_cast<SwTextNode*>(pTmpNd)->RemoveFromList();
515 if( bInsOutlineIdx && pCNd )
518 static_cast<SwTextNode*>(pTmpNd)->AddToList();
547 if( bInsOutlineIdx && bOutlNd )
551 pSttNode = static_cast<SwStartNode*>(pNd);
556 static_cast<SwSectionNode*>(pSttNode)->NodesArrChgd();
561 if(
auto pDDETable = dynamic_cast<SwDDETable*>(&pTableNd->
GetTable()) )
573 if (
GetDoc().GetIDocumentUndoRedo().IsUndoNodes(rNodes))
601 aSttNdStack.insert( aSttNdStack.begin() + nLevel, pTmp );
606 else if (
GetDoc().GetIDocumentUndoRedo().IsUndoNodes(
634 if( bNewFrames && pSctNd )
660 aSttNdStack.insert( aSttNdStack.begin() + nLevel, pSttNd );
665 pSctNd->NodesArrChgd();
668 if (!
GetDoc().GetIDocumentUndoRedo().IsUndoNodes(rNodes))
679 GetDoc().GetIDocumentUndoRedo().IsUndoNodes(rNodes))
687 ChgNode( aSwIndex, nInsPos, aIdx, bNewFrames );
702 if( !nInsPos && !nLevel )
714 static_cast<SwStartNode*>(pCurrentNode)->GetStartNodeType() );
732 while( aTmpSIdx < aTmpEIdx )
746 ChgNode( aSwIndex, nInsPos, aIdx, bNewFrames );
752 OSL_ENSURE( pCurrentNode == aSttNdStack[nLevel] ||
754 aSttNdStack[nLevel]->IsSectionNode()),
758 ChgNode( aSwIndex, nInsPos, aIdx, bNewFrames );
767 if( pSectNd && !--nSectNdCnt )
771 bNewFrames = bSaveNewFrames;
773 aSttNdStack.erase( aSttNdStack.begin() + nLevel );
793 static_cast<SwContentNode*>(pCurrentNode)->DelFrames(
nullptr);
803 static_cast<SwContentNode*>(pCurrentNode)->DelFrames(
nullptr);
812 if (
GetDoc().GetIDocumentUndoRedo().IsUndoNodes(*
this))
814 if( &rNodes ==
this )
829 ChgNode( aSwIndex, nInsPos, aIdx, bNewFrames );
840 assert(!
"How can this node be in the node array?");
846 assert(!
"Unknown node type");
855 ChgNode( aSwIndex, nInsPos, aIdx, bNewFrames );
868 if(
this == &rNodes &&
979 while( aTmpIdx < pRange->aEnd )
981 pCurrentNode = &aTmpIdx.GetNode();
1030 aSttNdStack.push_back( pTmp );
1042 aSttNdStack.push_back( pTmp );
1046 SwStartNode* pSttNd = aSttNdStack[ aSttNdStack.size() - 1 ];
1048 aSttNdStack.pop_back();
1049 if( !aSttNdStack.empty() )
1052 else if( aTmpIdx < aEnd )
1078 if( nCnt > nNodes ) nCnt = nNodes;
1106 bool bUpdateOutline =
false;
1130 if (pTextNode->IsOutline() &&
1135 bUpdateOutline =
true;
1137 pTextNode->InvalidateNumRule();
1146 }
while( pNd != pChkNd );
1198 bUpdateOutline =
true;
1203 static_cast<SwContentNode*>(pCurrentNode)->InvalidateNumRule();
1238 if( bUpdateOutline )
1255 if(rIdx == 0)
return 1;
1267 while( !aTmp.GetNode().IsContentNode() )
1291 while( aTmp <
Count()-1 && !( pNd = &aTmp.
GetNode())->IsContentNode() )
1294 if( aTmp ==
Count()-1 )
1308 while( aTmp.
GetIndex() && !( pNd = &aTmp.
GetNode())->IsContentNode() )
1337 SwNode** ppEndNdArr = aEndNdArr;
1338 while( *ppEndNdArr )
1341 sal_uLong nEndIdx = (*ppEndNdArr)->GetIndex();
1343 if( nSttIdx != nEndIdx )
1344 RemoveNode( nSttIdx, nEndIdx - nSttIdx,
true );
1352 for(
sal_uLong n = nSttIdx, nEnd = nSttIdx + nCnt;
n < nEnd; ++
n )
1384 sal_uInt16 nLevel, nTop;
1385 explicit HighLevel( sal_uInt16 nLv ) : nLevel( nLv ), nTop( nLv ) {}
1392 HighLevel * pHL =
static_cast<HighLevel*
>(pPara);
1397 if( pHL->nTop > pHL->nLevel )
1398 pHL->nTop = pHL->nLevel;
1428 if( !rPam.
HasMark() || *pStt >= *pEnd )
1431 if(
this == &rNodes && *pStt <= rPos && rPos < *pEnd )
1438 bool bSplitDestNd =
true;
1439 bool bCopyCollFormat = pDestNd && pDestNd->
GetText().isEmpty();
1450 bCopyCollFormat =
true;
1457 const sal_Int32 nLen =
1466 for( ; nSttNdIdx < nEndNdIdx; ++nSttNdIdx )
1468 if( (*
this)[ nSttNdIdx ]->IsContentNode() )
1477 if( !bOneNd && bSplitDestNd )
1481 bCopyCollFormat =
true;
1494 if( rPos.
nNode == aEndIdx )
1498 bSplitDestNd =
true;
1500 pDestNd = rNodes[ rPos.
nNode.
GetIndex() - 1 ]->GetTextNode();
1512 if( bCopyCollFormat )
1517 bCopyCollFormat =
false;
1545 const bool bCorrEnd = aEndIdx == rPos.
nNode;
1566 bSplitDestNd =
true;
1598 if (pDestNd && bCopyCollFormat)
1618 if( aEndIdx != aSttIdx )
1626 if( &rNodes ==
this )
1637 OSL_ENSURE( bSuccess,
"Move() - no ContentNode here" );
1652 const SwNodeIndex& rIndex,
bool bNewFrames,
bool bTableInsDummyNode )
const
1673 if (0 == nIsEndOfContent)
1699 "aRg should use this node array" );
1701 "Range across different nodes arrays? You deserve punishment!");
1712 nNodeCnt > 0; --nNodeCnt )
1726 if (nDistance < nNodeCnt)
1727 nNodeCnt -= nDistance;
1732 if( bTableInsDummyNode )
1741 if( bTableInsDummyNode )
1747 aInsPos, bNewFrames );
1750 if( bTableInsDummyNode )
1755 if( bTableInsDummyNode )
1763 MakeCopy( rDoc, aInsPos );
1765 if (nDistance < nNodeCnt)
1766 nNodeCnt -= nDistance;
1768 nNodeCnt = 1 - nIsEndOfContent;
1772 if( bNewFrames && pTableNd )
1790 MakeCopy( rDoc, aInsPos );
1793 if (nDistance < nNodeCnt)
1794 nNodeCnt -= nDistance;
1796 nNodeCnt = 1 - nIsEndOfContent;
1799 if( bNewFrames && pSectNd &&
1808 static_cast<SwStartNode*>(pCurrentNode)->GetStartNodeType() );
1821 else if( 1 == nNodeCnt && 1 == nIsEndOfContent )
1838 rDoc, aInsPos, bNewFrames);
1853 assert(!
"How can this node be in the node array?");
1908 bool bSkipHidden,
bool bSkipProtect )
const
1913 while( aTmp <
Count() - 1 )
1929 m_pStartOfSection)->GetSection();
1939 if( ( bSkipHidden || bSkipProtect ) &&
1960 bool bSkipHidden,
bool bSkipProtect )
1973 m_pStartOfSection)->GetSection();
1987 m_pStartOfSection)->GetSection();
1997 if( ( bSkipHidden || bSkipProtect ) &&
2027 const SwNode* pEnd )
const
2029 SwNode* pFrameNd =
nullptr;
2032 if(
GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell() )
2057 if( ( pFrameNd = pNd )->IsContentNode() )
2061 else if(
nullptr != ( pFrameNd =
GoPrevSection( &aIdx,
true,
false )) &&
2082 if( ( pEnd && ( pFrameNd = &aIdx.
GetNode())->IsContentNode() ) ||
2083 (
nullptr != ( pFrameNd =
GoNextSection( &aIdx,
true,
false )) &&
2102 pFrameNd = pTableNode;
2103 rFrameIdx = *pFrameNd;
2111 rFrameIdx = *pFrameNd;
2120 if( (pFrameNd = &aIdx.
GetNode())->IsTableNode() )
2130 GetSectionNode()->GetSection();
2155 if( nStart >= nEnd )
2161 sal_uInt16 nElem = sal_uInt16( nStart - p->
nStart );
2162 auto pElem = p->
mvData.begin() + nElem;
2163 nElem = p->
nElem - nElem;
2166 if( !(*fn)( static_cast<SwNode *>(*pElem++), pArgs ) || ++nStart >= nEnd )
2174 pElem = p->
mvData.begin();
2189 SwNode *
const pFirst((*
this)[nDelPos]);
2191 for (
sal_uLong nCnt = 0; nCnt < nSz; nCnt++)
2193 SwNode* pNode = (*this)[ nDelPos + nCnt ];
2207 std::vector<SwTextAttr*> flys;
2208 for (
size_t i = 0;
i < pHints->Count(); ++
i)
2213 flys.push_back(pHint);
2225 assert(pTextNd == (*
this)[nDelPos + nCnt]);
2226 assert(pFirst == (*
this)[nDelPos]);
2241 SwNode* pNew = (*this)[ nEnd ];
2246 if (nDelPos <= nIdx && nIdx < nEnd)
2250 std::vector<BigPtrEntry> aTempEntries;
2254 BigPtrEntry *pDel = (*this)[ nDelPos+nCnt-1 ], *pPrev = (*this)[ nDelPos+nCnt-2 ];
2261 aTempEntries.resize(nCnt);
2276 nDelPos = pDel->
GetPos() + 1;
2299 if (
nullptr != pNode)
2303 if (aIdx <= (*
this)[0]->EndOfSectionIndex())
2327 xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwNodes"));
2329 (*
this)[
i]->dumpAsXml(pWriter);
2330 xmlTextWriterEndElement(pWriter);
SwSectionNode * FindSectionNode()
Search section node, in which it is.
Instances of SwFields and those derived from it occur 0 to n times.
const SwEndNode * EndOfSectionNode() const
Starts a section of nodes in the document model.
SwNode & GetEndOfInserts() const
Section for all footnotes.
sal_uLong GetIndex() const
SwStartNode * m_pStartOfSection
Represents the style of a paragraph.
Marks a position in the document model.
bool IsSectionNode() const
sal_uLong StartOfSectionIndex() const
void DelFrames(SwRootFrame const *pLayout=nullptr)
Method deletes all views of document for the node.
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_METAFIELD(49)
const OUString & GetText() const
bool IsOutline() const
Returns if this text node is an outline.
SwDocShell * GetDocShell()
SwpHints * GetpSwpHints()
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_META(48)
static sal_uInt16 HighestLevel(SwNodes &rNodes, const SwNodeRange &rRange)
Calculate the highest level in a range.
SwDoc & GetDoc()
Which Doc contains the nodes-array?
static sal_uInt16 GetSectionLevel(const SwNodeIndex &rIndex)
get section level at the given position
virtual sal_Int32 Len() const override
SwNode * DocumentSectionStartNode(SwNode *pNode) const
static SwContentNode * GoPrevSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true)
SwNode * m_pEndOfInserts
These are the fixed ranges.
void CutText(SwTextNode *const pDest, const SwIndex &rStart, const sal_Int32 nLen)
SwSectionNode is derived from SwStartNode.
void DelDummyNodes(const SwNodeRange &rRg)
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(57)
static SwContentNode * GoPrevious(SwNodeIndex *)
bool(* FnForEach_SwNodes)(const SwNodePtr &, void *pArgs)
const OUString & GetName() const
SwNode * DocumentSectionEndNode(SwNode *pNode) const
sal_uInt16 nElem
number of elements
SwTextNode * SplitContentNode(const SwPosition &, std::function< void(SwTextNode *, sw::mark::RestoreMode)> const *pContentIndexRestore)
IDocumentUndoRedo & GetIDocumentUndoRedo()
void UpdateOutlineIdx(const SwNode &)
Update all OutlineNodes starting from Node.
sal_uLong m_nSize
number of elements
IDocumentContentOperations const & getIDocumentContentOperations() const
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(59)
sal_uInt16 Index2Block(sal_uLong) const
block search
SwTableFormat * GetFrameFormat()
void ChgNode(SwNodeIndex const &rDelPos, sal_uLong nSize, SwNodeIndex &rInsPos, bool bNewFrames)
const SwSection & GetSection() const
void Move(sal_uLong from, sal_uLong to)
void MakeFramesForAdjacentContentNode(SwContentNode &rNode)
Method creates all views of document for given node.
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
void Delete(const SwNodeIndex &rPos, sal_uLong nNodes=1)
delete nodes
SwTableNode * GetTableNode()
SwNodeType GetNodeType() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
virtual void InsDelFieldInFieldLst(bool bIns, const SwTextField &rField)=0
void MakeOwnFrames(SwNodeIndex *pIdxBehind, SwNodeIndex *pEnd=nullptr)
Creates the frms for the SectionNode (i.e.
void Replace(sal_uLong pos, BigPtrEntry *p)
sal_uLong GetIndex() const
virtual bool IsUndoNodes(SwNodes const &rNodes) const =0
virtual bool SetFieldsDirty(bool b, const SwNode *pChk, sal_uLong nLen)=0
static void GoEndOfSection(SwNodeIndex *)
bool CheckNodesRange(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, bool bChkSection)
Check if the given range is inside one of the defined top-level sections.
const SwTable & GetTable() const
void DelNodes(const SwNodeIndex &rStart, sal_uLong nCnt=1)
Delete a number of nodes.
bool IsProtectFlag() const
const SwFormatField & GetFormatField() const
void ChkCondColl(const SwTextFormatColl *pColl=nullptr)
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(58)
void ChgTextNode(SwTextNode *const pNode)
std::unique_ptr< SwNode > m_pEndOfContent
std::unique_ptr< SwOutlineNodes > m_pOutlineNodes
Array of all outline nodes.
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
SwStartNode * MakeTextSection(const SwNodeIndex &rWhere, SwStartNodeType eSttNdTyp, SwTextFormatColl *pColl)
static bool lcl_HighestLevel(const SwNodePtr &rpNode, void *pPara)
bool IsContentNode() const
PaM is Point and Mark: a selection of the document model.
struct _xmlTextWriter * xmlTextWriterPtr
SwNumRule * FindNumRulePtr(const OUString &rName) const
static SwNodePtr GetStartNode(SwOutlineNodes const *pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type *nOutl)
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
std::unique_ptr< BlockInfo *[]> m_ppInf
block info
void SectionDown(SwNodeRange *pRange, SwStartNodeType=SwNormalStartNode)
create a start/end section pair
void Broadcast(const SfxHint &rHint)
SwTextAttr * Get(size_t nPos) const
const SwStartNode * StartOfSectionNode() const
void ForEach(FnForEach_SwNodes fnForEach, void *pArgs=nullptr)
SwIndex & Assign(SwIndexReg *, sal_Int32)
void Insert(BigPtrEntry *p, sal_uLong pos)
static void GoStartOfSection(SwNodeIndex *)
bool IsHiddenFlag() const
SwContentNode * GetContentNode()
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
std::array< BigPtrEntry *, MAXENTRY > mvData
data block
Marks a character position inside a document model node.
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
std::vector< SwStartNode * > SwStartNodePointers
bool IsNoTextNode() const
void MakeOwnFrames(SwNodeIndex *pIdxBehind)
Creates the frms for the table node (i.e. the TabFrames).
Marks a node in the document model.
SwNodes & GetNodes()
Node is in which nodes-array/doc?
T static_txtattr_cast(S *s)
ring_container GetRingContainer()
SwNodeIndex * m_vIndices
ring of all indices on nodes.
SwStartNodeType GetStartNodeType() const
SwStartNode * GetStartNode()
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
const SwPosition * Start() const
SwFieldType * GetTyp() const
void DeleteAttribute(SwTextAttr *const pTextAttr)
delete the attribute pTextAttr
bool CalcHiddenFlag() const
SwNodes(SwNodes const &)=delete
SvtBroadcaster & GetNotifier()
SwDoc & m_rMyDoc
This Doc contains the nodes-array.
static void SectionUpDown(const SwNodeIndex &aStart, const SwNodeIndex &aEnd)
correct indices after movement
sal_uLong EndOfSectionIndex() const
BigPtrEntry * operator[](sal_uLong) const
SwTextNode is a paragraph in the document model.
void dumpAsXml(xmlTextWriterPtr pWriter) const
Dumps the entire nodes structure to the given destination (file nodes.xml in the current directory by...
bool m_bInNodesDel
In Case of recursive calling.
void SetInvalidRule(bool bFlag)
An SwTextAttr container, stores all directly formatted text portions for a text node.
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
const SwNodes & GetNodes() const
void SectionUp(SwNodeRange *)
increase level of the given range
SwEndNode * m_pEndOfSection
sal_Int32 GetIndex() const
const SwPosition * End() const
void InsertNode(const SwNodePtr pNode, const SwNodeIndex &rPos)
void DelFrames(SwRootFrame const *pLayout=nullptr, bool bForce=false)
Method deletes all views of document for the node.
SwTableNode is derived from SwStartNode.
sal_uInt16 MakeNumRule(const OUString &rName, const SwNumRule *pCpy=nullptr, bool bBroadcast=false, const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode=SvxNumberFormat::LABEL_WIDTH_AND_POSITION)
constexpr TypedWhichId< SwConditionTextFormatColl > RES_CONDTXTFMTCOLL(158)
constexpr TypedWhichId< SwTOXMark > RES_TXTATR_TOXMARK(47)
SwNode * m_pEndOfAutotext
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
const SwStartNode * FindTableBoxStartNode() const
bool InvalidateNumRule()
Invalidates NumRule at the node.
SwTableNode * FindTableNode()
Search table node, in which it is.
void Remove(sal_uLong pos, sal_uLong n=1)
void CopyCollFormat(SwTextNode &rDestNd, bool bUndoForChgFormatColl=true)
Copy collection with all auto formats to dest-node.
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
const SfxPoolItem & GetAttr() const
static SwNodePtr GetEndNode(SwOutlineNodes const *pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type *nOutl)
SwContentNode * GoNextSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true) const
Go to next content-node that is not protected or hidden (Both set FALSE ==> GoNext/GoPrevious!!!).
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
SwSectionNode * GetSectionNode()
void CopyNodes(const SwNodeRange &, const SwNodeIndex &, bool bNewFrames, bool bTableInsDummyNode=false) const
Ends a section of nodes in the document model.
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
sal_uInt16 GetSectionLevel() const
Returns the section level at the position given by aIndex.
SwNode & GetEndOfRedlines() const
Section for all Redlines.
bool m_bInDelUpdOutline
Flag for updating of Outline.
std::vector< SwNode * >::size_type size_type
This class is internal, used only during DocumentContentOperationsManager::CopyWithFlyInFly(), and for undo.
SwNode * FindPrvNxtFrameNode(SwNodeIndex &rFrameIdx, const SwNode *pEnd) const
Search previous / next content node or table node with frames.
SwContentNode * GoNext(SwNodeIndex *) const
void RemoveNode(sal_uLong nDelPos, sal_uLong nLen, bool bDel)
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwTextNode * MakeTextNode(const SwNodeIndex &rWhere, SwTextFormatColl *pColl, bool bNewFrames=true)
Implementations of "Make...Node" are in the given .cxx-files.
bool MoveNodes(const SwNodeRange &, SwNodes &rNodes, const SwNodeIndex &, bool bNewFrames=true)
move the node pointer
SwNode * m_pEndOfRedlines
static SwStartNode * MakeEmptySection(const SwNodeIndex &rIdx, SwStartNodeType=SwNormalStartNode)
Create an empty section of Start- and EndNote.
Base class of the Writer document model elements.
SwTextFormatColl * GetTextColl() const
void MoveRange(SwPaM &, SwPosition &, SwNodes &rNodes)
move a range