summaryrefslogtreecommitdiff
path: root/sw/inc/node.hxx
blob: 75096dd2aa280f21f9bc3d8ebdaf9263ba943432 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef INCLUDED_SW_INC_NODE_HXX
#define INCLUDED_SW_INC_NODE_HXX

#include <sal/types.h>

#include "swdllapi.h"
#include "BorderCacheOwner.hxx"
#include "ndarr.hxx"
#include "ndtyp.hxx"
#include "contentindex.hxx"
#include "fmtcol.hxx"
#include "nodeoffset.hxx"

#include <memory>
#include <vector>

class SwContentFrame;
class SwContentNode;
class SwDoc;
class SwEndNode;
class SwFrame;
class SwFrameFormat;
class SwGrfNode;
class SwNoTextNode;
class SwNodeIndex;
class SwOLENode;
class SwRect;
class SwSection;
class SwSectionFormat;
class SwTOXBase;
class SwSectionNode;
class SwStartNode;
class SwTabFrame;
class SwRootFrame;
class SwTable;
class SwTableNode;
class SwTableBox;
class SwTextNode;
class SwPageDesc;
class SwViewShell;
struct SwPosition;
class IStyleAccess;
class IDocumentSettingAccess;
class IDocumentDeviceAccess;
class IDocumentMarkAccess;
class IDocumentRedlineAccess;
class IDocumentStylePoolAccess;
class IDocumentLinksAdministration;
class IDocumentFieldsAccess;
class IDocumentContentOperations;
class IDocumentListItems;
class Point;
enum class SvxFrameDirection;
typedef std::vector<SwOLENode*> SwOLENodes; // docary.hxx
enum class SwCursorSkipMode;

namespace drawinglayer::attribute {
    class SdrAllFillAttributesHelper;
    typedef std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr;
}

/// Base class of the Writer document model elements.
class SW_DLLPUBLIC SwNode
    : public sw::BorderCacheOwner, private BigPtrEntry
{
    friend class SwNodes;

    SwNodeType m_nNodeType;

    /// For text nodes: level of auto format. Was put here because we had still free bits.
    sal_uInt8 m_nAFormatNumLvl : 3;
    bool m_bIgnoreDontExpand : 1;     ///< for Text Attributes - ignore the flag

public:
    /// sw_redlinehide: redline node merge state
    enum class Merge { None, First, NonFirst, Hidden };
    bool IsCreateFrameWhenHidingRedlines() const {
        return m_eMerge == Merge::None || m_eMerge == Merge::First;
    }
    void SetRedlineMergeFlag(Merge const eMerge) { m_eMerge = eMerge; }
    Merge GetRedlineMergeFlag() const { return m_eMerge; }
private:
    Merge m_eMerge;

#ifdef DBG_UTIL
    static tools::Long s_nSerial;
    tools::Long m_nSerial;
#endif

    /// all SwFrameFormat that are anchored at the node
    /// invariant: SwFrameFormat is in the list iff
    /// SwFrameFormat::GetAnchor().GetContentAnchor() points to this node
    std::vector<SwFrameFormat*> m_aAnchoredFlys;

protected:
    SwStartNode* m_pStartOfSection;

    /// only used by SwContentNodeTmp in SwTextNode::Update
    SwNode();

    SwNode( const SwNode& rWhere, const SwNodeType nNodeId );

    /// for the initial StartNode
    SwNode( SwNodes& rNodes, SwNodeOffset nPos, const SwNodeType nNodeId );

public:
    /** the = 0 forces the class to be an abstract base class, but the dtor can be still called
       from subclasses */
    virtual ~SwNode() override = 0;

#ifdef DBG_UTIL
    tools::Long GetSerial() const { return m_nSerial; }
#endif

    sal_uInt16 GetSectionLevel() const;

    inline SwNodeOffset StartOfSectionIndex() const;
    const SwStartNode* StartOfSectionNode() const { return m_pStartOfSection; }
    SwStartNode* StartOfSectionNode() { return m_pStartOfSection; }

    inline SwNodeOffset EndOfSectionIndex() const;
    inline const SwEndNode* EndOfSectionNode() const;
    inline         SwEndNode* EndOfSectionNode();

    sal_uInt8 GetAutoFormatLvl() const     { return m_nAFormatNumLvl; }
    void SetAutoFormatLvl( sal_uInt8 nVal )      { m_nAFormatNumLvl = nVal; }

    bool IsIgnoreDontExpand() const  { return m_bIgnoreDontExpand; }
    void SetIgnoreDontExpand( bool bNew )  { m_bIgnoreDontExpand = bNew; }

    SwNodeType   GetNodeType() const { return m_nNodeType; }

    inline       SwStartNode *GetStartNode();
    inline const SwStartNode *GetStartNode() const;
    inline       SwContentNode *GetContentNode();
    inline const SwContentNode *GetContentNode() const;
    inline       SwEndNode   *GetEndNode();
    inline const SwEndNode   *GetEndNode() const;
    inline       SwTextNode   *GetTextNode();
    inline const SwTextNode   *GetTextNode() const;
    inline       SwOLENode   *GetOLENode();
    inline const SwOLENode   *GetOLENode() const;
    inline       SwNoTextNode *GetNoTextNode();
    inline const SwNoTextNode *GetNoTextNode() const;
    inline       SwGrfNode   *GetGrfNode();
    inline const SwGrfNode   *GetGrfNode() const;
    inline       SwTableNode *GetTableNode();
    inline const SwTableNode *GetTableNode() const;
    inline       SwSectionNode *GetSectionNode();
    inline const SwSectionNode *GetSectionNode() const;

    inline bool IsStartNode() const;
    inline bool IsContentNode() const;
    inline bool IsEndNode() const;
    inline bool IsTextNode() const;
    inline bool IsTableNode() const;
    inline bool IsSectionNode() const;
    inline bool IsOLENode() const;
    inline bool IsNoTextNode() const;
    inline bool IsGrfNode() const;

    /**
       Checks if this node is in redlines.

       @retval true       this node is in redlines
       @retval false      else
     */
    bool IsInRedlines() const;

    /** Search table node, in which it is. If it is in no table
       @return 0. */
                    SwTableNode *FindTableNode();
    inline const  SwTableNode *FindTableNode() const;

    /** Search section node, in which it is. If it is in no section
       @return 0. */
                    SwSectionNode *FindSectionNode();
    inline    const   SwSectionNode *FindSectionNode() const;

    SwStartNode* FindSttNodeByType( SwStartNodeType eTyp );
    inline const SwStartNode* FindSttNodeByType( SwStartNodeType eTyp ) const;

    const SwStartNode* FindTableBoxStartNode() const
                        { return FindSttNodeByType( SwTableBoxStartNode ); }
    const SwStartNode* FindFlyStartNode() const
                        { return FindSttNodeByType( SwFlyStartNode ); }
    const SwStartNode* FindFootnoteStartNode() const
                        { return FindSttNodeByType( SwFootnoteStartNode ); }
    const SwStartNode* FindHeaderStartNode() const
                        { return FindSttNodeByType( SwHeaderStartNode ); }
    const SwStartNode* FindFooterStartNode() const
                        { return FindSttNodeByType( SwFooterStartNode ); }

    /// Node is in which nodes-array/doc?
    inline          SwNodes& GetNodes();
    inline const  SwNodes& GetNodes() const;

    SwDoc& GetDoc()
    {
        return GetNodes().GetDoc();
    }

    const SwDoc& GetDoc() const
    {
        return GetNodes().GetDoc();
    }

    /** Provides access to the document setting interface
     */
    const IDocumentSettingAccess* getIDocumentSettingAccess() const;

    /** Provides access to the document device interface
     */
    const IDocumentDeviceAccess& getIDocumentDeviceAccess() const;

    /** Provides access to the document bookmark interface
     */
    const IDocumentMarkAccess* getIDocumentMarkAccess() const;

    /** Provides access to the document redline interface
     */
    const IDocumentRedlineAccess& getIDocumentRedlineAccess() const;

    /** Provides access to the document style pool interface
     */
    const IDocumentStylePoolAccess& getIDocumentStylePoolAccess() const;

    /** Provides access to the document draw model interface
     */
    const IDocumentDrawModelAccess& getIDocumentDrawModelAccess() const;

    /** Provides access to the document layout interface
     */
    const IDocumentLayoutAccess& getIDocumentLayoutAccess() const;
          IDocumentLayoutAccess& getIDocumentLayoutAccess();

    /** Provides access to the document links administration interface
     */
    const IDocumentLinksAdministration& getIDocumentLinksAdministration() const;
          IDocumentLinksAdministration& getIDocumentLinksAdministration();

    /** Provides access to the document fields administration interface
     */
    const IDocumentFieldsAccess& getIDocumentFieldsAccess() const;
          IDocumentFieldsAccess& getIDocumentFieldsAccess();

    /** Provides access to the document content operations interface
     */
          IDocumentContentOperations& getIDocumentContentOperations();

    /** Provides access to the document automatic styles interface
     */
          IStyleAccess& getIDocumentStyleAccess();

    /** Provides access to the document's numbered items interface */
    IDocumentListItems& getIDocumentListItems();

    /// Is node in the visible area of the Shell?
    bool IsInVisibleArea( SwViewShell const * pSh ) const;
    /// Is node in a protected area?
    bool IsInProtectSect() const;
    /**  Is node in something that is protected (range, frame,
        table cells ... including anchor in case of frames or footnotes)? */
    bool IsProtect() const;

    /** Search PageDesc with which this node is formatted. If layout is existent
       search over layout, else only the hard way is left: search over the nodes
       to the front!! */
    const SwPageDesc* FindPageDesc( SwNodeOffset* pPgDescNdIdx = nullptr ) const;

    /// If node is in a fly return the respective format.
    SwFrameFormat* GetFlyFormat() const;

    /// If node is in a table return the respective table box.
    SwTableBox* GetTableBox() const;

    SwNodeOffset GetIndex() const { return SwNodeOffset(GetPos()); }

    const SwTextNode* FindOutlineNodeOfLevel(sal_uInt8 nLvl, SwRootFrame const* pLayout = nullptr) const;

    sal_uInt8 HasPrevNextLayNode() const;

    std::vector<SwFrameFormat *> const & GetAnchoredFlys() const { return m_aAnchoredFlys; }
    void AddAnchoredFly(SwFrameFormat *);
    void RemoveAnchoredFly(SwFrameFormat *);

    /**
     * Dumps the node structure to the given destination (file nodes.xml in the current directory by default)
     */
    virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;

    bool operator==(const SwNode& rOther) const { return this == &rOther; }
    bool operator!=(const SwNode& rOther) const { return this != &rOther; }
    bool operator<(const SwNode& rOther) const { assert(&GetNodes() == &rOther.GetNodes()); return GetIndex() < rOther.GetIndex(); }
    bool operator<=(const SwNode& rOther) const { assert(&GetNodes() == &rOther.GetNodes()); return GetIndex() <= rOther.GetIndex(); }
    bool operator>(const SwNode& rOther) const { assert(&GetNodes() == &rOther.GetNodes()); return GetIndex() > rOther.GetIndex(); }
    bool operator>=(const SwNode& rOther) const { assert(&GetNodes() == &rOther.GetNodes()); return GetIndex() >= rOther.GetIndex(); }

private:
    SwNode( const SwNode & rNodes ) = delete;
    SwNode & operator= ( const SwNode & rNodes ) = delete;
};

/// Starts a section of nodes in the document model.
class SAL_DLLPUBLIC_RTTI SwStartNode: public SwNode
{
    friend class SwNode;
    friend class SwNodes;
    friend class SwEndNode;     ///< to set the theEndOfSection !!

    SwEndNode* m_pEndOfSection;
    SwStartNodeType m_eStartNodeType;

    /// for the initial StartNode
    SwStartNode( SwNodes& rNodes, SwNodeOffset nPos );

protected:
    SwStartNode( const SwNode& rWhere,
                 const SwNodeType nNodeType = SwNodeType::Start,
                 SwStartNodeType = SwNormalStartNode );
public:
    SwStartNodeType GetStartNodeType() const        { return m_eStartNodeType; }

    /// Call ChkCondcoll to all ContentNodes of section.
    void CheckSectionCondColl() const;

    virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override;

private:
    SwStartNode( const SwStartNode & rNode ) = delete;
    SwStartNode & operator= ( const SwStartNode & rNode ) = delete;
};

/// Ends a section of nodes in the document model.
class SwEndNode final : public SwNode
{
    friend class SwNodes;
    friend class SwTableNode;       ///< To enable creation of its EndNote.
    friend class SwSectionNode;     ///< To enable creation of its EndNote.

    /// for the initial StartNode
    SwEndNode( SwNodes& rNodes, SwNodeOffset nPos, SwStartNode& rSttNd );

    SwEndNode( const SwNode& rWhere, SwStartNode& rSttNd );

    SwEndNode( const SwEndNode & rNode ) = delete;
    SwEndNode & operator= ( const SwEndNode & rNode ) = delete;
};

// SwContentNode

class SW_DLLPUBLIC SwContentNode: public sw::BroadcastingModify, public SwNode, public SwContentIndexReg
{

    sw::WriterMultiListener m_aCondCollListener;
    SwFormatColl* m_pCondColl;
    mutable bool mbSetModifyAtAttr;

protected:
    /// only used by SwContentNodeTmp in SwTextNode::Update
    SwContentNode();

    SwContentNode( const SwNode& rWhere, const SwNodeType nNodeType,
                SwFormatColl *pFormatColl );
    /** the = 0 forces the class to be an abstract base class, but the dtor can be still called
       from subclasses */
    virtual ~SwContentNode() override = 0;

    /**  Attribute-set for all auto attributes of a ContentNode.
      (e.g. TextNode or NoTextNode). */
    std::shared_ptr<const SfxItemSet> mpAttrSet;

    /// Make respective nodes create the specific AttrSets.
    virtual void NewAttrSet( SwAttrPool& ) = 0;

    /** There some functions that like to remove items from the internal
       SwAttrSet (handle): */
    sal_uInt16 ClearItemsFromAttrSet( const std::vector<sal_uInt16>& rWhichIds );

    virtual void SwClientNotify( const SwModify&, const SfxHint& rHint) override;

public:

    /** MakeFrame will be called for a certain layout
       pSib is another SwFrame of the same layout (e.g. the SwRootFrame itself, a sibling, the parent) */
    virtual SwContentFrame *MakeFrame( SwFrame* pSib ) = 0;

    virtual SwContentNode *JoinNext();
    /** Is it possible to join two nodes?
       In pIdx the second position can be returned. */
    bool CanJoinNext( SwNodeIndex* pIdx = nullptr ) const;
    bool CanJoinNext( SwPosition* pIdx ) const;
    bool CanJoinPrev( SwNodeIndex* pIdx =nullptr ) const;

    bool GoNext(SwContentIndex *, SwCursorSkipMode nMode ) const;
    bool GoNext(SwPosition*, SwCursorSkipMode nMode ) const;
    bool GoPrevious(SwContentIndex *, SwCursorSkipMode nMode ) const;

    /// @see GetFrameOfModify
    SwContentFrame *getLayoutFrame( const SwRootFrame*,
            const SwPosition *pPos = nullptr,
            std::pair<Point, bool> const* pViewPosAndCalcFrame = nullptr) const;
    /** @return the real size of the frame or an empty rectangle if
       no layout exists. Needed for export filters. */
    SwRect FindLayoutRect( const bool bPrtArea = false,
                            const Point* pPoint = nullptr  ) const;
    SwRect FindPageFrameRect() const;

    /** Method creates all views of document for given node. The content
       frames that are created are put in the respective layout. */
    void MakeFramesForAdjacentContentNode(SwContentNode& rNode);

    /** Method deletes all views of document for the node. The content-
        frames are removed from the respective layout.
    */
    void DelFrames(SwRootFrame const* pLayout);

    /** @return count of elements of node content. Default is 1.
       There are differences between text node and formula node. */
    virtual sal_Int32 Len() const;

    virtual SwContentNode* MakeCopy(SwDoc&, SwNode& rWhere, bool bNewFrames) const = 0;

    /// Get information from Client.
    virtual bool GetInfo( SfxPoolItem& ) const override;

    /// SS for PoolItems: hard attributation.

    /// If bInParent is FALSE search for attribute only in this node.
    const SfxPoolItem& GetAttr( sal_uInt16 nWhich, bool bInParent=true ) const;
    template<class T>
    const T& GetAttr( TypedWhichId<T> nWhich, bool bInParent=true ) const
    { return static_cast<const T&>(GetAttr(sal_uInt16(nWhich), bInParent)); }
    bool GetAttr( SfxItemSet& rSet ) const;
    /// made virtual
    virtual bool SetAttr( const SfxPoolItem& );
    virtual bool SetAttr( const SfxItemSet& rSet );
    virtual bool ResetAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 = 0 );
    virtual bool ResetAttr( const std::vector<sal_uInt16>& rWhichArr );
    virtual sal_uInt16 ResetAllAttr();

    /// Obtains attribute that is not delivered via conditional style!
    const SfxPoolItem* GetNoCondAttr( sal_uInt16 nWhich, bool bInParents ) const;
    template<class T>
    const T* GetNoCondAttr( TypedWhichId<T> nWhich, bool bInParents ) const
    { return static_cast<const T*>(GetNoCondAttr(sal_uInt16(nWhich), bInParents)); }

    /** Does node has already its own auto-attributes?
     Access to SwAttrSet. */
    inline const SwAttrSet &GetSwAttrSet() const;
    const SwAttrSet *GetpSwAttrSet() const { return static_cast<const SwAttrSet*>(mpAttrSet.get()); }
    bool  HasSwAttrSet() const { return mpAttrSet != nullptr; }

    virtual SwFormatColl* ChgFormatColl( SwFormatColl* );
    SwFormatColl* GetFormatColl() const { return const_cast<SwFormatColl*>(static_cast<const SwFormatColl*>(GetRegisteredIn())); }

    inline SwFormatColl& GetAnyFormatColl() const;
    void SetCondFormatColl( SwFormatColl* );
    inline SwFormatColl* GetCondFormatColl() const;

    bool IsAnyCondition( SwCollCondition& rTmp ) const;
    void ChkCondColl(const SwTextFormatColl* pColl = nullptr);

    /** Invalidates NumRule at the node. NumRule is updated
       on EndAction of a Shell at the latest. */
    bool InvalidateNumRule();

    /** determines the text direction for a certain
       position. @return -1, if text direction could *not* be determined. */
    SvxFrameDirection GetTextDirection( const SwPosition& rPos,
                            const Point* pPt ) const;

    void SetModifyAtAttr( bool bSetModifyAtAttr ) const { mbSetModifyAtAttr = bSetModifyAtAttr; }
    bool GetModifyAtAttr() const { return mbSetModifyAtAttr; }

    static std::unique_ptr<SwOLENodes> CreateOLENodesArray( const SwFormatColl& rColl, bool bOnlyWithInvalidSize );

    // Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
    virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const;

    void UpdateAttr(const SwUpdateAttr&);

private:
    SwContentNode( const SwContentNode & rNode ) = delete;
    SwContentNode & operator= ( const SwContentNode & rNode ) = delete;
};

// SwTableNode

class SW_DLLPUBLIC SwTableNode final : public SwStartNode, public sw::BroadcastingModify
{
    friend class SwNodes;
    std::unique_ptr<SwTable> m_pTable;

    virtual ~SwTableNode() override;

public:
    SwTableNode( const SwNode& );

    const SwTable& GetTable() const { return *m_pTable; }
    SwTable& GetTable() { return *m_pTable; }
    SwTabFrame *MakeFrame( SwFrame* );

    /// Creates the frms for the table node (i.e. the TabFrames).
    /// pIdxBehind is optional parameter.
    void MakeOwnFrames(SwPosition* pIdxBehind = nullptr);

    /** Method deletes all views of document for the node.
       The content frames are removed from the respective layout. */
    void DelFrames(SwRootFrame const* pLayout = nullptr);

    /** Method creates all views of the document for the previous node.
       The content frames that are created are put into the respective layout. */
    void MakeFramesForAdjacentContentNode(const SwNodeIndex & rIdx);

    SwTableNode* MakeCopy( SwDoc&, const SwNodeIndex& ) const;
    void SetNewTable( std::unique_ptr<SwTable> , bool bNewFrames=true );

    // Removes redline objects that relate to this table from the 'Extra Redlines' table
    void RemoveRedlines();

    void dumpAsXml(xmlTextWriterPtr pWriter) const override;

private:
    SwTableNode( const SwTableNode & rNode ) = delete;
    SwTableNode & operator= ( const SwTableNode & rNode ) = delete;
};

class SAL_DLLPUBLIC_RTTI SwSectionNode final
    : public SwStartNode
{
    friend class SwNodes;

private:
    SwSectionNode(const SwSectionNode&) = delete;
    SwSectionNode& operator=(const SwSectionNode&) = delete;

    std::unique_ptr<SwSection> const m_pSection;

    virtual ~SwSectionNode() override;

public:
    SwSectionNode(const SwNode& rWhere,
        SwSectionFormat & rFormat, SwTOXBase const*const pTOXBase);

    const SwSection& GetSection() const { return *m_pSection; }
          SwSection& GetSection()       { return *m_pSection; }

    SwFrame *MakeFrame( SwFrame* );

    /** Creates the frms for the SectionNode (i.e. the SectionFrames).
       On default the frames are created until the end of the range.
       When another NodeIndex pEnd is passed a MakeFrames is called up to it.
       Used by TableToText. */
    void MakeOwnFrames(SwNodeIndex* pIdxBehind, SwNodeIndex* pEnd = nullptr);

    /** Method deletes all views of document for the node. The
     content frames are removed from the respective layout. */
    void DelFrames(SwRootFrame const* pLayout = nullptr, bool bForce = false);

    /** Method creates all views of document for the previous node.
       The content frames created are put into the respective layout. */
    void MakeFramesForAdjacentContentNode(const SwNodeIndex & rIdx);

    SwSectionNode* MakeCopy( SwDoc&, const SwNodeIndex& ) const;

    /// Set pointer in format of section on itself.
    void NodesArrChgd();

    /** Check for not hidden areas whether there is content that is not in
       a hidden sub-area. */
    bool IsContentHidden() const;

    void dumpAsXml(xmlTextWriterPtr pWriter) const override;

};

/** This class is internal, used only during DocumentContentOperationsManager::CopyWithFlyInFly(), and for undo.

Some of the nodes are then replaced with SwPlaceholderNode, and at the end of the operation, removed again.
FIXME find out if this is really necessary, and if we can avoid creation of the SwPlaceholderNodes in the first place.
*/
class SwPlaceholderNode final : private SwNode
{
private:
    friend class SwNodes;
    SwPlaceholderNode(const SwNode& rWhere);
};

inline       SwEndNode   *SwNode::GetEndNode()
{
     return SwNodeType::End == m_nNodeType ? static_cast<SwEndNode*>(this) : nullptr;
}
inline const SwEndNode   *SwNode::GetEndNode() const
{
     return SwNodeType::End == m_nNodeType ? static_cast<const SwEndNode*>(this) : nullptr;
}
inline       SwStartNode *SwNode::GetStartNode()
{
     return SwNodeType::Start & m_nNodeType ? static_cast<SwStartNode*>(this) : nullptr;
}
inline const SwStartNode *SwNode::GetStartNode() const
{
     return SwNodeType::Start & m_nNodeType ? static_cast<const SwStartNode*>(this) : nullptr;
}
inline       SwTableNode *SwNode::GetTableNode()
{
     return SwNodeType::Table == m_nNodeType ? static_cast<SwTableNode*>(this) : nullptr;
}
inline const SwTableNode *SwNode::GetTableNode() const
{
     return SwNodeType::Table == m_nNodeType ? static_cast<const SwTableNode*>(this) : nullptr;
}
inline       SwSectionNode *SwNode::GetSectionNode()
{
     return SwNodeType::Section == m_nNodeType ? static_cast<SwSectionNode*>(this) : nullptr;
}
inline const SwSectionNode *SwNode::GetSectionNode() const
{
     return SwNodeType::Section == m_nNodeType ? static_cast<const SwSectionNode*>(this) : nullptr;
}
inline       SwContentNode *SwNode::GetContentNode()
{
     return SwNodeType::ContentMask & m_nNodeType ? static_cast<SwContentNode*>(this) : nullptr;
}
inline const SwContentNode *SwNode::GetContentNode() const
{
     return SwNodeType::ContentMask & m_nNodeType ? static_cast<const SwContentNode*>(this) : nullptr;
}

inline bool SwNode::IsStartNode() const
{
    return bool(SwNodeType::Start & m_nNodeType);
}
inline bool SwNode::IsContentNode() const
{
    return bool(SwNodeType::ContentMask & m_nNodeType);
}
inline bool SwNode::IsEndNode() const
{
    return SwNodeType::End == m_nNodeType;
}
inline bool SwNode::IsTextNode() const
{
    return SwNodeType::Text == m_nNodeType;
}
inline bool SwNode::IsTableNode() const
{
    return SwNodeType::Table == m_nNodeType;
}
inline bool SwNode::IsSectionNode() const
{
    return SwNodeType::Section == m_nNodeType;
}
inline bool SwNode::IsNoTextNode() const
{
    return bool(SwNodeType::NoTextMask & m_nNodeType);
}
inline bool SwNode::IsOLENode() const
{
    return SwNodeType::Ole == m_nNodeType;
}
inline bool SwNode::IsGrfNode() const
{
    return SwNodeType::Grf == m_nNodeType;
}

inline const SwStartNode* SwNode::FindSttNodeByType( SwStartNodeType eTyp ) const
{
    return const_cast<SwNode*>(this)->FindSttNodeByType( eTyp );
}
inline const SwTableNode* SwNode::FindTableNode() const
{
    return const_cast<SwNode*>(this)->FindTableNode();
}
inline const SwSectionNode* SwNode::FindSectionNode() const
{
    return const_cast<SwNode*>(this)->FindSectionNode();
}
inline SwNodeOffset SwNode::StartOfSectionIndex() const
{
    return m_pStartOfSection->GetIndex();
}
inline SwNodeOffset SwNode::EndOfSectionIndex() const
{
    const SwStartNode* pStNd = IsStartNode() ? static_cast<const SwStartNode*>(this) : m_pStartOfSection;
    return pStNd->m_pEndOfSection->GetIndex();
}
inline const SwEndNode* SwNode::EndOfSectionNode() const
{
    const SwStartNode* pStNd = IsStartNode() ? static_cast<const SwStartNode*>(this) : m_pStartOfSection;
    return pStNd->m_pEndOfSection;
}
inline SwEndNode* SwNode::EndOfSectionNode()
{
    const SwStartNode* pStNd = IsStartNode() ? static_cast<const SwStartNode*>(this) : m_pStartOfSection;
    return pStNd->m_pEndOfSection;
}

inline SwNodes& SwNode::GetNodes()
{
    return static_cast<SwNodes&>(GetArray());
}
inline const SwNodes& SwNode::GetNodes() const
{
    return static_cast<SwNodes&>(GetArray());
}

inline SwFormatColl* SwContentNode::GetCondFormatColl() const
{
    return m_pCondColl;
}

inline SwFormatColl& SwContentNode::GetAnyFormatColl() const
{
    return m_pCondColl
            ? *m_pCondColl
            : *const_cast<SwFormatColl*>(static_cast<const SwFormatColl*>(GetRegisteredIn()));
}

inline const SwAttrSet& SwContentNode::GetSwAttrSet() const
{
    return mpAttrSet ? *GetpSwAttrSet() : GetAnyFormatColl().GetAttrSet();
}

//FEATURE::CONDCOLL

inline const SfxPoolItem& SwContentNode::GetAttr( sal_uInt16 nWhich,
                                                bool bInParents ) const
{
    return GetSwAttrSet().Get( nWhich, bInParents );
}

inline SwPlaceholderNode::SwPlaceholderNode(const SwNode& rWhere)
    : SwNode(rWhere, SwNodeType::PlaceHolder)
{
}

inline SwNode* SwNodes::operator[]( SwNodeOffset n ) const
{
    return static_cast<SwNode*>(BigPtrArray::operator[] ( sal_Int32(n) ));
}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */