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
29#include "bparr.hxx"
30#include "ndtyp.hxx"
31#include <rtl/ustring.hxx>
33#include "nodeoffset.hxx"
34
35class Graphic;
36class GraphicObject;
37class SwAttrSet;
38class SfxItemSet;
39class SwContentNode;
40class SwDoc;
41class SwGrfFormatColl;
42class SwGrfNode;
43class SwNode;
44class SwNodeIndex;
45class SwNodeRange;
46class SwOLENode;
47class SwPaM;
48class SwRootFrame;
49class SwSectionData;
50class SwSectionFormat;
51class SwTOXBase;
52class SwSectionNode;
53class SwStartNode;
55class SwTableFormat;
56class SwTableLine;
58class SwTableNode;
60class SwTextNode;
63struct SwPosition;
64
65namespace sw { class DocumentContentOperationsManager; }
66namespace svt { class EmbeddedObjectRef; }
67
68
69typedef bool (*FnForEach_SwNodes)( SwNode*, void* pArgs );
70typedef struct _xmlTextWriter *xmlTextWriterPtr;
71
73{
74 bool operator()( SwNode* const& lhs, SwNode* const& rhs) const;
75};
76
77class SwOutlineNodes : public o3tl::sorted_vector<SwNode*, CompareSwOutlineNodes>
78{
79public:
80 static constexpr auto npos = std::numeric_limits<size_type>::max();
81
82 bool Seek_Entry(SwNode* rP, size_type* pnPos) const;
83};
84
86using SwTableToTextSaves = std::vector<std::unique_ptr<SwTableToTextSave>>;
87
89 : private BigPtrArray
90{
91 friend class SwDoc;
92 friend class SwNode;
93 friend class SwNodeIndex;
94 friend class SwStartNode;
95 friend class ::sw::DocumentContentOperationsManager;
96
98 void RemoveNode( SwNodeOffset nDelPos, SwNodeOffset nLen, bool bDel );
99
100 void InsertNode( SwNode* pNode, const SwNodeIndex& rPos );
101 void InsertNode( SwNode* pNode, SwNodeOffset nPos );
102
104
105 SwNode *m_pEndOfPostIts, *m_pEndOfInserts,
106 *m_pEndOfAutotext, *m_pEndOfRedlines;
107 std::unique_ptr<SwNode> m_pEndOfContent;
108
109 mutable std::unique_ptr<SwOutlineNodes> m_pOutlineNodes;
110
111 bool m_bInNodesDel : 1;
114
115 // Actions on the nodes.
116 static void SectionUpDown( const SwNodeIndex & aStart, const SwNodeIndex & aEnd );
117 void DelNodes( const SwNodeIndex& rStart, SwNodeOffset nCnt = SwNodeOffset(1) );
118
119 void ChgNode( SwNodeIndex const & rDelPos, SwNodeOffset nSize,
120 SwNodeIndex& rInsPos, bool bNewFrames );
121
122 void UpdateOutlineIdx( const SwNode& );
123
124 void CopyNodes( const SwNodeRange&, const SwNodeIndex&,
125 bool bNewFrames, bool bTableInsDummyNode = false ) const;
126 void DelDummyNodes( const SwNodeRange& rRg );
127
128 SwNodes(SwNodes const&) = delete;
129 SwNodes& operator=(SwNodes const&) = delete;
130
131 SwNodes(SwDoc& rDoc);
132
133public:
134 ~SwNodes();
135
136 typedef std::vector<SwNodeRange> NodeRanges_t;
137 typedef std::vector<NodeRanges_t> TableRanges_t;
138
139 SwNode* operator[]( SwNodeOffset n ) const; // defined in node.hxx
140
142 void ForEach( FnForEach_SwNodes fnForEach, void* pArgs = nullptr )
143 {
144 ForEach( SwNodeOffset(0), Count(), fnForEach, pArgs );
145 }
146 void ForEach( SwNodeOffset nStt, SwNodeOffset nEnd, FnForEach_SwNodes fnForEach, void* pArgs );
147 void ForEach( const SwNodeIndex& rStart, const SwNodeIndex& rEnd,
148 FnForEach_SwNodes fnForEach, void* pArgs );
149
151 SwNode& GetEndOfPostIts() const { return *m_pEndOfPostIts; }
153 SwNode& GetEndOfInserts() const { return *m_pEndOfInserts; }
155 SwNode& GetEndOfAutotext() const { return *m_pEndOfAutotext; }
157 SwNode& GetEndOfRedlines() const { return *m_pEndOfRedlines; }
160 SwNode& GetEndOfExtras() const { return *m_pEndOfRedlines; }
162 SwNode& GetEndOfContent() const { return *m_pEndOfContent; }
163
166 bool IsDocNodes() const;
167
168 static sal_uInt16 GetSectionLevel(const SwNodeIndex &rIndex);
169 void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes = SwNodeOffset(1));
170
171 bool MoveNodes( const SwNodeRange&, SwNodes& rNodes, const SwNodeIndex&,
172 bool bNewFrames = true );
173 void MoveRange( SwPaM&, SwPosition&, SwNodes& rNodes );
174
175 void Copy_( const SwNodeRange& rRg, const SwNodeIndex& rInsPos,
176 bool bNewFrames = true ) const
177 { CopyNodes( rRg, rInsPos, bNewFrames ); }
178
179 void SectionUp( SwNodeRange *);
180 void SectionDown( SwNodeRange *pRange, SwStartNodeType = SwNormalStartNode );
181
182 static void GoStartOfSection(SwNodeIndex *);
183 static void GoEndOfSection(SwNodeIndex *);
184
187
190 SwContentNode* GoNextSection( SwNodeIndex *, bool bSkipHidden = true,
191 bool bSkipProtect = true ) const;
192 static SwContentNode* GoPrevSection( SwNodeIndex *, bool bSkipHidden = true,
193 bool bSkipProtect = true );
194
198 static SwStartNode* MakeEmptySection( const SwNodeIndex& rIdx,
200
202 SwTextNode *MakeTextNode( const SwNodeIndex & rWhere,
203 SwTextFormatColl *pColl,
204 bool bNewFrames = true);
205 SwStartNode* MakeTextSection( const SwNodeIndex & rWhere,
206 SwStartNodeType eSttNdTyp,
207 SwTextFormatColl *pColl );
208
209 static SwGrfNode *MakeGrfNode( const SwNodeIndex & rWhere,
210 const OUString& rGrfName,
211 const OUString& rFltName,
212 const Graphic* pGraphic,
213 SwGrfFormatColl *pColl,
214 SwAttrSet const * pAutoAttr = nullptr );
215
216 static SwGrfNode *MakeGrfNode( const SwNodeIndex & rWhere,
217 const GraphicObject& rGrfObj,
218 SwGrfFormatColl *pColl );
219
220 SwOLENode *MakeOLENode( const SwNodeIndex & rWhere,
222 SwGrfFormatColl *pColl );
223 SwOLENode *MakeOLENode( const SwNodeIndex & rWhere,
224 const OUString &rName,
225 sal_Int64 nAspect,
226 SwGrfFormatColl *pColl,
227 SwAttrSet const * pAutoAttr );
228
230 const SwOutlineNodes& GetOutLineNds() const { return *m_pOutlineNodes;}
231
233 void UpdateOutlineNode(SwNode & rNd);
234
243 static SwTableNode* InsertTable( const SwNodeIndex& rNdIdx,
244 sal_uInt16 nBoxes, SwTextFormatColl* pContentTextColl,
245 sal_uInt16 nLines, sal_uInt16 nRepeat,
246 SwTextFormatColl* pHeadlineTextColl,
247 const SwAttrSet * pAttrSet);
248
250 SwTableNode* TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
251 SwTableFormat* pTableFormat,
252 SwTableLineFormat* pLineFormat,
253 SwTableBoxFormat* pBoxFormat,
254 SwTextFormatColl* pTextColl,
255 SwUndoTextToTable* pUndo );
256
257 std::unique_ptr<SwNodeRange> ExpandRangeForTableBox(const SwNodeRange & rRange);
258
260 SwTableNode* TextToTable( const TableRanges_t& rTableNodes,
261 SwTableFormat* pTableFormat,
262 SwTableLineFormat* pLineFormat,
263 SwTableBoxFormat* pBoxFormat );
264
266 bool TableToText( const SwNodeRange& rRange, sal_Unicode cCh,
269 SwTableNode* UndoTableToText( SwNodeOffset nStt, SwNodeOffset nEnd,
270 const SwTableToTextSaves& rSavedData );
271
275 bool InsBoxen( SwTableNode*, SwTableLine*, SwTableBoxFormat*,
277 SwTextFormatColl*, const SfxItemSet* pAutoAttr,
278 sal_uInt16 nInsPos, sal_uInt16 nCnt = 1 );
285 SwTableNode* SplitTable( const SwNodeIndex& rPos, bool bAfter = true,
286 bool bCalcNewSize = false );
288 bool MergeTable( const SwNodeIndex& rPos, bool bWithPrev = true,
289 sal_uInt16 nMode = 0 );
290
292 SwSectionNode* InsertTextSection(SwNodeIndex const& rNdIdx,
293 SwSectionFormat& rSectionFormat,
294 SwSectionData const&,
295 SwTOXBase const*const pTOXBase,
296 SwNodeIndex const*const pEnd,
297 bool const bInsAtStart = true,
298 bool const bCreateFrames = true);
299
301 SwDoc& GetDoc() { return m_rMyDoc; }
302 const SwDoc& GetDoc() const { return m_rMyDoc; }
303
308 SwNode* FindPrvNxtFrameNode( SwNodeIndex& rFrameIdx,
309 const SwNode* pEnd,
310 SwRootFrame const* pLayout = nullptr) const;
311
312 SwNode * DocumentSectionStartNode(SwNode * pNode) const;
313 SwNode * DocumentSectionEndNode(SwNode * pNode) const;
314
318 void dumpAsXml( xmlTextWriterPtr pWriter ) const;
319};
320
321
322#endif
323
324/* 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:188
Marks a node in the document model.
Definition: ndindex.hxx:31
Base class of the Writer document model elements.
Definition: node.hxx:83
sal_uInt16 GetSectionLevel() const
Returns the section level at the position given by aIndex.
Definition: node.cxx:271
void ForEach(FnForEach_SwNodes fnForEach, void *pArgs=nullptr)
Definition: ndarr.hxx:142
const SwOutlineNodes & GetOutLineNds() const
Array of all OutlineNodes.
Definition: ndarr.hxx:230
bool m_bInNodesDel
In Case of recursive calling.
Definition: ndarr.hxx:111
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:160
std::unique_ptr< SwOutlineNodes > m_pOutlineNodes
Array of all outline nodes.
Definition: ndarr.hxx:109
bool m_bInDelUpdOutline
Flag for updating of Outline.
Definition: ndarr.hxx:113
SwNode * m_pEndOfAutotext
Definition: ndarr.hxx:106
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
Definition: ndarr.hxx:155
SwNodes & operator=(SwNodes const &)=delete
void Copy_(const SwNodeRange &rRg, const SwNodeIndex &rInsPos, bool bNewFrames=true) const
Definition: ndarr.hxx:175
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:162
std::unique_ptr< SwNode > m_pEndOfContent
Definition: ndarr.hxx:107
SwNode * m_pEndOfInserts
These are the fixed ranges.
Definition: ndarr.hxx:105
std::vector< NodeRanges_t > TableRanges_t
Definition: ndarr.hxx:137
const SwDoc & GetDoc() const
Definition: ndarr.hxx:302
SwNode & GetEndOfRedlines() const
Section for all Redlines.
Definition: ndarr.hxx:157
SwNodes(SwNodes const &)=delete
SwNode & GetEndOfInserts() const
Section for all footnotes.
Definition: ndarr.hxx:153
std::vector< SwNodeRange > NodeRanges_t
Definition: ndarr.hxx:136
SwNode & GetEndOfPostIts() const
A still empty section.
Definition: ndarr.hxx:151
SwDoc & GetDoc()
Which Doc contains the nodes-array?
Definition: ndarr.hxx:301
SwDoc & m_rMyDoc
This Doc contains the nodes-array.
Definition: ndarr.hxx:103
SwNodeIndex * m_vIndices
ring of all indices on nodes.
Definition: ndarr.hxx:97
SwNodeOffset Count() const
Definition: ndarr.hxx:141
bool Seek_Entry(SwNode *rP, size_type *pnPos) const
Definition: ndnum.cxx:32
static constexpr auto npos
Definition: ndarr.hxx:80
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:138
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
Starts a section of nodes in the document model.
Definition: node.hxx:314
friend class SwNodes
Definition: node.hxx:316
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:987
SwTableLine is one table row in the document model.
Definition: swtable.hxx:358
Represents the style of a paragraph.
Definition: fmtcol.hxx:59
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:84
Dialog to specify the properties of date form field.
std::vector< std::unique_ptr< SwTableToTextSave > > SwTableToTextSaves
Definition: ndarr.hxx:86
bool(* FnForEach_SwNodes)(SwNode *, void *pArgs)
Definition: ndarr.hxx:69
struct _xmlTextWriter * xmlTextWriterPtr
Definition: ndarr.hxx:70
SwStartNodeType
Definition: ndtyp.hxx:51
@ SwNormalStartNode
Definition: ndtyp.hxx:52
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
bool GoPrevious(SwNode *pNd, SwIndex *pIdx, sal_uInt16 nMode)
Definition: pam.cxx:297
bool GoNext(SwNode *pNd, SwIndex *pIdx, sal_uInt16 nMode)
Definition: pam.cxx:290
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