LibreOffice Module sw (master) 1
ndarr.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_SW_INC_NDARR_HXX
21#define INCLUDED_SW_INC_NDARR_HXX
22
23#include <sal/config.h>
24
25#include <limits>
26#include <vector>
27#include <memory>
28#include <optional>
29
30#include "bparr.hxx"
31#include "ndtyp.hxx"
32#include <rtl/ustring.hxx>
34#include "nodeoffset.hxx"
35
36class Graphic;
37class GraphicObject;
38class SwAttrSet;
39class SfxItemSet;
40class SwContentNode;
41class SwDoc;
42class SwGrfFormatColl;
43class SwGrfNode;
44class SwNode;
45class SwNodeIndex;
46class SwNodeRange;
47class SwOLENode;
48class SwPaM;
49class SwRootFrame;
50class SwSectionData;
51class SwSectionFormat;
52class SwTOXBase;
53class SwSectionNode;
54class SwStartNode;
56class SwTableFormat;
57class SwTableLine;
59class SwTableNode;
61class SwTextNode;
64struct SwPosition;
65
66namespace sw { class DocumentContentOperationsManager; }
67namespace svt { class EmbeddedObjectRef; }
68
69
70typedef bool (*FnForEach_SwNodes)( SwNode*, void* pArgs );
71typedef struct _xmlTextWriter *xmlTextWriterPtr;
72
74{
75 bool operator()( SwNode* const& lhs, SwNode* const& rhs) const;
76};
77
78class SwOutlineNodes : public o3tl::sorted_vector<SwNode*, CompareSwOutlineNodes>
79{
80public:
81 static constexpr auto npos = std::numeric_limits<size_type>::max();
82
83 bool Seek_Entry(SwNode* rP, size_type* pnPos) const;
84};
85
87using SwTableToTextSaves = std::vector<std::unique_ptr<SwTableToTextSave>>;
88
90 : private BigPtrArray
91{
92 friend class SwDoc;
93 friend class SwNode;
94 friend class SwNodeIndex;
95 friend class SwStartNode;
96 friend class ::sw::DocumentContentOperationsManager;
97
99 void RemoveNode( SwNodeOffset nDelPos, SwNodeOffset nLen, bool bDel );
100
101 void InsertNode( SwNode* pNode, const SwNodeIndex& rPos );
102 void InsertNode( SwNode* pNode, SwNodeOffset nPos );
103
105
106 SwNode *m_pEndOfPostIts, *m_pEndOfInserts,
107 *m_pEndOfAutotext, *m_pEndOfRedlines;
108 std::unique_ptr<SwNode> m_pEndOfContent;
109
111
112 bool m_bInNodesDel : 1;
115
116 // Actions on the nodes.
117 static void SectionUpDown( const SwNodeIndex & aStart, const SwNodeIndex & aEnd );
118 void DelNodes( const SwNodeIndex& rStart, SwNodeOffset nCnt = SwNodeOffset(1) );
119
120 void ChgNode( SwNodeIndex const & rDelPos, SwNodeOffset nSize,
121 SwNodeIndex& rInsPos, bool bNewFrames );
122
123 void UpdateOutlineIdx( const SwNode& );
124
125 void CopyNodes( const SwNodeRange&, SwNode& rPos,
126 bool bNewFrames, bool bTableInsDummyNode = false ) const;
127 void DelDummyNodes( const SwNodeRange& rRg );
128
129 SwNodes(SwNodes const&) = delete;
130 SwNodes& operator=(SwNodes const&) = delete;
131
132 SwNodes(SwDoc& rDoc);
133
134public:
135 ~SwNodes();
136
137 typedef std::vector<SwNodeRange> NodeRanges_t;
138 typedef std::vector<NodeRanges_t> TableRanges_t;
139
140 SwNode* operator[]( SwNodeOffset n ) const; // defined in node.hxx
141
143 void ForEach( FnForEach_SwNodes fnForEach, void* pArgs = nullptr )
144 {
145 ForEach( SwNodeOffset(0), Count(), fnForEach, pArgs );
146 }
147 void ForEach( SwNodeOffset nStt, SwNodeOffset nEnd, FnForEach_SwNodes fnForEach, void* pArgs );
148 void ForEach( SwNode& rStart, SwNode& rEnd,
149 FnForEach_SwNodes fnForEach, void* pArgs );
150 void ForEach( const SwNodeIndex& rStart, const SwNodeIndex& rEnd,
151 FnForEach_SwNodes fnForEach, void* pArgs );
152
154 SwNode& GetEndOfPostIts() const { return *m_pEndOfPostIts; }
156 SwNode& GetEndOfInserts() const { return *m_pEndOfInserts; }
158 SwNode& GetEndOfAutotext() const { return *m_pEndOfAutotext; }
160 SwNode& GetEndOfRedlines() const { return *m_pEndOfRedlines; }
163 SwNode& GetEndOfExtras() const { return *m_pEndOfRedlines; }
165 SwNode& GetEndOfContent() const { return *m_pEndOfContent; }
166
169 bool IsDocNodes() const;
170
171 static sal_uInt16 GetSectionLevel(const SwNode &rIndex);
172 void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes = SwNodeOffset(1));
173 void Delete(const SwNode& rPos, SwNodeOffset nNodes = SwNodeOffset(1));
174
175 bool MoveNodes( const SwNodeRange&, SwNodes& rNodes, SwNode& rPos,
176 bool bNewFrames = true );
177 void MoveRange( SwPaM&, SwPosition&, SwNodes& rNodes );
178
179 void Copy_( const SwNodeRange& rRg, SwNode& rInsPos,
180 bool bNewFrames = true ) const
181 { CopyNodes( rRg, rInsPos, bNewFrames ); }
182
183 void SectionUp( SwNodeRange *);
184 void SectionDown( SwNodeRange *pRange, SwStartNodeType = SwNormalStartNode );
185
186 static void GoStartOfSection(SwNodeIndex *);
187 static void GoEndOfSection(SwNodeIndex *);
188
193
196 SwContentNode* GoNextSection( SwNodeIndex *, bool bSkipHidden = true,
197 bool bSkipProtect = true ) const;
198 SwContentNode* GoNextSection( SwPosition *, bool bSkipHidden = true,
199 bool bSkipProtect = true ) const;
200 static SwContentNode* GoPrevSection( SwNodeIndex *, bool bSkipHidden = true,
201 bool bSkipProtect = true );
202 static SwContentNode* GoPrevSection( SwPosition *, bool bSkipHidden = true,
203 bool bSkipProtect = true );
204
208 static SwStartNode* MakeEmptySection( SwNode& rWhere,
210
212 SwTextNode *MakeTextNode( SwNode& rWhere,
213 SwTextFormatColl *pColl,
214 bool bNewFrames = true);
215 SwStartNode* MakeTextSection( const SwNode & rWhere,
216 SwStartNodeType eSttNdTyp,
217 SwTextFormatColl *pColl );
218
219 static SwGrfNode *MakeGrfNode( SwNode& rWhere,
220 const OUString& rGrfName,
221 const OUString& rFltName,
222 const Graphic* pGraphic,
223 SwGrfFormatColl *pColl,
224 SwAttrSet const * pAutoAttr = nullptr );
225
226 static SwGrfNode *MakeGrfNode( SwNode & rWhere,
227 const GraphicObject& rGrfObj,
228 SwGrfFormatColl *pColl );
229
230 SwOLENode *MakeOLENode( SwNode& rWhere,
232 SwGrfFormatColl *pColl );
233 SwOLENode *MakeOLENode( SwNode& rWhere,
234 const OUString &rName,
235 sal_Int64 nAspect,
236 SwGrfFormatColl *pColl,
237 SwAttrSet const * pAutoAttr );
238
240 const SwOutlineNodes& GetOutLineNds() const { return m_aOutlineNodes;}
241
243 void UpdateOutlineNode(SwNode & rNd);
244
253 static SwTableNode* InsertTable( SwNode& rNd,
254 sal_uInt16 nBoxes, SwTextFormatColl* pContentTextColl,
255 sal_uInt16 nLines, sal_uInt16 nRepeat,
256 SwTextFormatColl* pHeadlineTextColl,
257 const SwAttrSet * pAttrSet);
258
260 SwTableNode* TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
261 SwTableFormat* pTableFormat,
262 SwTableLineFormat* pLineFormat,
263 SwTableBoxFormat* pBoxFormat,
264 SwTextFormatColl* pTextColl,
265 SwUndoTextToTable* pUndo );
266
267 void ExpandRangeForTableBox(const SwNodeRange & rRange,
268 std::optional<SwNodeRange>& rExpandedRange);
269
271 SwTableNode* TextToTable( const TableRanges_t& rTableNodes,
272 SwTableFormat* pTableFormat,
273 SwTableLineFormat* pLineFormat,
274 SwTableBoxFormat* pBoxFormat );
275
277 bool TableToText( const SwNodeRange& rRange, sal_Unicode cCh,
280 SwTableNode* UndoTableToText( SwNodeOffset nStt, SwNodeOffset nEnd,
281 const SwTableToTextSaves& rSavedData );
282
286 bool InsBoxen( SwTableNode*, SwTableLine*, SwTableBoxFormat*,
288 SwTextFormatColl*, const SfxItemSet* pAutoAttr,
289 sal_uInt16 nInsPos, sal_uInt16 nCnt = 1 );
296 SwTableNode* SplitTable( SwNode& rPos, bool bAfter = true,
297 bool bCalcNewSize = false );
299 bool MergeTable( SwNode& rPos, bool bWithPrev = true );
300
302 SwSectionNode* InsertTextSection(SwNode& rNd,
303 SwSectionFormat& rSectionFormat,
304 SwSectionData const&,
305 SwTOXBase const*const pTOXBase,
306 SwNode const * pEndNd,
307 bool const bInsAtStart = true,
308 bool const bCreateFrames = true);
309
311 SwDoc& GetDoc() { return m_rMyDoc; }
312 const SwDoc& GetDoc() const { return m_rMyDoc; }
313
318 SwNode* FindPrvNxtFrameNode( const SwNode& rFrameNd,
319 const SwNode* pEnd,
320 SwRootFrame const* pLayout = nullptr) const;
321
322 SwNode * DocumentSectionStartNode(SwNode * pNode) const;
323 SwNode * DocumentSectionEndNode(SwNode * pNode) const;
324
328 void dumpAsXml( xmlTextWriterPtr pWriter ) const;
329};
330
331
332#endif
333
334/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
sal_Int32 Count() const
Definition: bparr.hxx:88
BigPtrEntry * operator[](sal_Int32) const
Definition: bparr.cxx:82
Definition: doc.hxx:194
Marks a node in the document model.
Definition: ndindex.hxx:31
Base class of the Writer document model elements.
Definition: node.hxx:98
sal_uInt16 GetSectionLevel() const
Returns the section level at the position given by aIndex.
Definition: node.cxx:281
void ForEach(FnForEach_SwNodes fnForEach, void *pArgs=nullptr)
Definition: ndarr.hxx:143
const SwOutlineNodes & GetOutLineNds() const
Array of all OutlineNodes.
Definition: ndarr.hxx:240
SwOutlineNodes m_aOutlineNodes
Array of all outline nodes.
Definition: ndarr.hxx:110
bool m_bInNodesDel
In Case of recursive calling.
Definition: ndarr.hxx:112
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:163
bool m_bInDelUpdOutline
Flag for updating of Outline.
Definition: ndarr.hxx:114
SwNode * m_pEndOfAutotext
Definition: ndarr.hxx:107
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
Definition: ndarr.hxx:158
SwNodes & operator=(SwNodes const &)=delete
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:165
std::unique_ptr< SwNode > m_pEndOfContent
Definition: ndarr.hxx:108
SwNode * m_pEndOfInserts
These are the fixed ranges.
Definition: ndarr.hxx:106
std::vector< NodeRanges_t > TableRanges_t
Definition: ndarr.hxx:138
const SwDoc & GetDoc() const
Definition: ndarr.hxx:312
SwNode & GetEndOfRedlines() const
Section for all Redlines.
Definition: ndarr.hxx:160
void Copy_(const SwNodeRange &rRg, SwNode &rInsPos, bool bNewFrames=true) const
Definition: ndarr.hxx:179
SwNodes(SwNodes const &)=delete
SwNode & GetEndOfInserts() const
Section for all footnotes.
Definition: ndarr.hxx:156
std::vector< SwNodeRange > NodeRanges_t
Definition: ndarr.hxx:137
SwNode & GetEndOfPostIts() const
A still empty section.
Definition: ndarr.hxx:154
SwDoc & GetDoc()
Which Doc contains the nodes-array?
Definition: ndarr.hxx:311
SwDoc & m_rMyDoc
This Doc contains the nodes-array.
Definition: ndarr.hxx:104
SwNodeIndex * m_vIndices
ring of all indices on nodes.
Definition: ndarr.hxx:98
SwNodeOffset Count() const
Definition: ndarr.hxx:142
bool Seek_Entry(SwNode *rP, size_type *pnPos) const
Definition: ndnum.cxx:32
static constexpr auto npos
Definition: ndarr.hxx:81
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
Starts a section of nodes in the document model.
Definition: node.hxx:348
friend class SwNodes
Definition: node.hxx:350
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override
Dumps the node structure to the given destination (file nodes.xml in the current directory by default...
Definition: node.cxx:1010
SwTableLine is one table row in the document model.
Definition: swtable.hxx:364
Represents the style of a paragraph.
Definition: fmtcol.hxx:59
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
Dialog to specify the properties of date form field.
std::vector< std::unique_ptr< SwTableToTextSave > > SwTableToTextSaves
Definition: ndarr.hxx:87
bool(* FnForEach_SwNodes)(SwNode *, void *pArgs)
Definition: ndarr.hxx:70
struct _xmlTextWriter * xmlTextWriterPtr
Definition: ndarr.hxx:71
SwStartNodeType
Definition: ndtyp.hxx:51
@ SwNormalStartNode
Definition: ndtyp.hxx:52
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
void GoEndOfSection(SwPosition *pPos)
Definition: pam.cxx:1151
bool GoNext(SwNode *pNd, SwContentIndex *pIdx, SwCursorSkipMode nMode)
Definition: pam.cxx:380
void GoStartOfSection(SwPosition *pPos)
Definition: pam.cxx:1129
bool GoPrevious(SwNode *pNd, SwContentIndex *pIdx, SwCursorSkipMode nMode)
Definition: pam.cxx:387
bool operator()(SwNode *const &lhs, SwNode *const &rhs) const
Definition: ndnum.cxx:27
Marks a position in the document model.
Definition: pam.hxx:37
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
sal_uInt16 sal_Unicode