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 SwOLENode *MakeOLENode( SwNode& rWhere,
228 SwGrfFormatColl *pColl );
229 SwOLENode *MakeOLENode( SwNode& rWhere,
230 const OUString &rName,
231 sal_Int64 nAspect,
232 SwGrfFormatColl *pColl,
233 SwAttrSet const * pAutoAttr );
234
236 const SwOutlineNodes& GetOutLineNds() const { return m_aOutlineNodes;}
237
239 void UpdateOutlineNode(SwNode & rNd);
240
249 static SwTableNode* InsertTable( SwNode& rNd,
250 sal_uInt16 nBoxes, SwTextFormatColl* pContentTextColl,
251 sal_uInt16 nLines, sal_uInt16 nRepeat,
252 SwTextFormatColl* pHeadlineTextColl,
253 const SwAttrSet * pAttrSet);
254
256 SwTableNode* TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
257 SwTableFormat* pTableFormat,
258 SwTableLineFormat* pLineFormat,
259 SwTableBoxFormat* pBoxFormat,
260 SwTextFormatColl* pTextColl,
261 SwUndoTextToTable* pUndo );
262
263 void ExpandRangeForTableBox(const SwNodeRange & rRange,
264 std::optional<SwNodeRange>& rExpandedRange);
265
267 SwTableNode* TextToTable( const TableRanges_t& rTableNodes,
268 SwTableFormat* pTableFormat,
269 SwTableLineFormat* pLineFormat,
270 SwTableBoxFormat* pBoxFormat );
271
273 bool TableToText( const SwNodeRange& rRange, sal_Unicode cCh,
276 SwTableNode* UndoTableToText( SwNodeOffset nStt, SwNodeOffset nEnd,
277 const SwTableToTextSaves& rSavedData );
278
282 bool InsBoxen( SwTableNode*, SwTableLine*, SwTableBoxFormat*,
284 SwTextFormatColl*, const SfxItemSet* pAutoAttr,
285 sal_uInt16 nInsPos, sal_uInt16 nCnt = 1 );
292 SwTableNode* SplitTable( SwNode& rPos, bool bAfter = true,
293 bool bCalcNewSize = false );
295 bool MergeTable( SwNode& rPos, bool bWithPrev = true );
296
298 SwSectionNode* InsertTextSection(SwNode& rNd,
299 SwSectionFormat& rSectionFormat,
300 SwSectionData const&,
301 SwTOXBase const*const pTOXBase,
302 SwNode const * pEndNd,
303 bool const bInsAtStart = true,
304 bool const bCreateFrames = true);
305
307 SwDoc& GetDoc() { return m_rMyDoc; }
308 const SwDoc& GetDoc() const { return m_rMyDoc; }
309
314 SwNode* FindPrvNxtFrameNode( const SwNode& rFrameNd,
315 const SwNode* pEnd,
316 SwRootFrame const* pLayout = nullptr) const;
317
318 SwNode * DocumentSectionStartNode(SwNode * pNode) const;
319 SwNode * DocumentSectionEndNode(SwNode * pNode) const;
320
324 void dumpAsXml( xmlTextWriterPtr pWriter ) const;
325};
326
327
328#endif
329
330/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 Count() const
Definition: bparr.hxx:87
BigPtrEntry * operator[](sal_Int32) const
Definition: bparr.cxx:82
Definition: doc.hxx:197
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:280
void ForEach(FnForEach_SwNodes fnForEach, void *pArgs=nullptr)
Definition: ndarr.hxx:143
const SwOutlineNodes & GetOutLineNds() const
Array of all OutlineNodes.
Definition: ndarr.hxx:236
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:308
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:307
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:188
The root element of a Writer document layout.
Definition: rootfrm.hxx:85
A section node represents the start of a section on the UI, i.e.
Definition: node.hxx:575
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:1003
SwTableLine is one table row in the document model.
Definition: swtable.hxx:376
Represents the style of a paragraph.
Definition: fmtcol.hxx:61
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
struct _xmlTextWriter * xmlTextWriterPtr
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:1175
bool GoNext(SwNode *pNd, SwContentIndex *pIdx, SwCursorSkipMode nMode)
Definition: pam.cxx:381
void GoStartOfSection(SwPosition *pPos)
Definition: pam.cxx:1153
bool GoPrevious(SwNode *pNd, SwContentIndex *pIdx, SwCursorSkipMode nMode)
Definition: pam.cxx:388
bool operator()(SwNode *const &lhs, SwNode *const &rhs) const
Definition: ndnum.cxx:27
Marks a position in the document model.
Definition: pam.hxx:38
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
sal_uInt16 sal_Unicode