LibreOffice Module sw (master) 1
SwNumberTree.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#pragma once
21
22#include <set>
23#include <vector>
24#include "SwNumberTreeTypes.hxx"
25
26class SwDoc;
28
30
32{
33 bool operator()(const SwNumberTreeNode* pA, const SwNumberTreeNode* pB) const
34 {
35 return SwNumberTreeNodeLessThan(pA, pB);
36 }
37};
38
113class SAL_DLLPUBLIC_RTTI SwNumberTreeNode
114{
115protected:
116 typedef std::set<SwNumberTreeNode*, compSwNumberTreeNodeLessThan> tSwNumberTreeChildren;
117
118public:
120
121 virtual ~SwNumberTreeNode();
122
129 void AddChild(SwNumberTreeNode* pChild, const int nDepth, const SwDoc& rDoc);
130
136 void RemoveChild(SwNumberTreeNode* pChild, const SwDoc& rDoc);
137
141 void RemoveMe(const SwDoc& rDoc);
142
149
157 SwNumberTree::tSwNumTreeNumber GetNumber(bool bValidate = true) const;
158
159 bool IsContinueingPreviousSubTree() const { return mbContinueingPreviousSubTree; }
160
166 SwNumberTree::tNumberVector GetNumberVector() const;
167
171 virtual bool IsRestart() const = 0;
172
179
186 virtual bool IsCounted() const;
187
194 virtual bool IsContinuous() const = 0;
195
204 bool IsFirst(const SwNumberTreeNode* pNode) const;
205
212 bool IsFirst() const;
213
220 bool IsPhantom() const { return mbPhantom; }
221
226 void SetLevelInListTree(const int nLevel, const SwDoc& rDoc);
227
236 int GetLevelInListTree() const;
237
249 virtual bool LessThan(const SwNumberTreeNode& rTreeNode) const;
250
259 void InvalidateTree() const;
260
265 void NotifyInvalidChildren(const SwDoc& rDoc);
266
272 void InvalidateMe();
273
279 void ValidateMe();
280
282 void NotifyInvalidSiblings(const SwDoc& rDoc);
283
285 void NotifyNodesOnListLevel(const int nListLevel);
286
294 {
295 if (GetRoot())
296 {
297 GetRoot()->InvalidateTree();
298 GetRoot()->Notify(rDoc);
299 }
300 }
301
308 SwNumberTreeNode* GetPred(bool bSibling = false) const;
309
317 const SwNumberTreeNode* GetPrecedingNodeOf(const SwNumberTreeNode& rNode) const;
318
319#ifdef DBG_UTIL
328 void IsSane(bool bRecursive) const;
329#endif // DBG_UTIL
330
336 tSwNumberTreeChildren::size_type GetChildCount() const;
337
338protected:
341
349 SwNumberTreeNode* GetRoot() const;
350
357 virtual bool IsNotificationEnabled(const SwDoc& rDoc) const = 0;
358
359 // #i64010# - made pure virtual
360 virtual bool HasCountedChildren() const = 0;
361
362 // #i64010#
363 virtual bool IsCountedForNumbering() const = 0;
364
365 // method called before this tree node has been added to the list tree
366 virtual void PreAdd() = 0;
367 // method called after this tree node has been removed from the list tree
368 virtual void PostRemove() = 0;
369
370#ifdef DBG_UTIL
376 void IsSane(bool bRecursive, std::vector<const SwNumberTreeNode*> rParents) const;
377#endif // DBG_UTIL
378
381
384
385 // boolean indicating, that a node of a not counted parent node is continuing
386 // the numbering of parent's previous node sub tree.
387 // Example:
388 // 1. kshdkjfs
389 // 1.1. lskjf
390 // sdfjlksaf <-- not counted parent node
391 // 1.2. lfjlaskf <-- <mbContinueingPreviousSubTree = true>
393
399
405 mutable tSwNumberTreeChildren::const_iterator mItLastValid;
406
409
417 void GetNumberVector_(SwNumberTree::tNumberVector& rVector, bool bValidate = true) const;
418
427 void Invalidate(SwNumberTreeNode const* pChild);
428
433 void InvalidateChildren() { SetLastValid(mChildren.end()); }
434
444 void SetLastValid(const tSwNumberTreeChildren::const_iterator& aItLastValid,
445 bool bValidating = false) const;
446
456 virtual bool IsNotifiable(const SwDoc& rDoc) const = 0;
457
463 virtual void NotifyNode() = 0;
464
466 void Notify(const SwDoc& rDoc);
467
469 void NotifyChildrenOnDepth(const int nDepth);
470
482 bool IsValid(const SwNumberTreeNode* pChild) const;
483
490 bool IsValid() const;
491
499 void Validate(const SwNumberTreeNode* pNode) const;
500
508 void ValidateHierarchical(const SwNumberTreeNode* pNode) const;
509
517 void ValidateContinuous(const SwNumberTreeNode* pNode) const;
518
524 virtual SwNumberTreeNode* Create() const = 0;
525
531 SwNumberTreeNode* CreatePhantom();
532
536 virtual bool IsCountPhantoms() const = 0;
537
539 bool HasOnlyPhantoms() const;
540
541 bool HasPhantomCountedParent() const;
542
550 SwNumberTreeNode* GetFirstNonPhantomChild();
551
558 void ClearObsoletePhantoms();
559
560 tSwNumberTreeChildren::const_iterator GetIterator(const SwNumberTreeNode* pChild) const;
561
567 void MoveChildren(SwNumberTreeNode* pDest);
568
583 void MoveGreaterChildren(SwNumberTreeNode& _rCompareNode, SwNumberTreeNode& _rDestNode);
584
590 SwNumberTreeNode* GetLastDescendant() const;
591};
592
593/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool SwNumberTreeNodeLessThan(const SwNumberTreeNode *pA, const SwNumberTreeNode *pB)
Definition: doc.hxx:197
A tree of numbered nodes.
bool IsPhantom() const
Return if this node is a phantom.
virtual bool IsNotifiable(const SwDoc &rDoc) const =0
Return if this node is notifiable.
virtual bool HasCountedChildren() const =0
virtual void PostRemove()=0
SwNumberTreeNode * mpParent
he parent node
virtual bool IsContinuous() const =0
Return if this node is counted continuous.
virtual bool IsNotificationEnabled(const SwDoc &rDoc) const =0
Return if the notification is not disabled on global conditions.
SwNumberTree::tSwNumTreeNumber mnNumber
the number of the node
void InvalidateChildren()
Invalidation of all children.
bool mbContinueingPreviousSubTree
SwNumberTreeNode(const SwNumberTreeNode &)
tSwNumberTreeChildren::const_iterator mItLastValid
Iterator to the last valid element.
tSwNumberTreeChildren mChildren
the children
virtual bool IsCountedForNumbering() const =0
bool IsContinueingPreviousSubTree() const
virtual bool IsRestart() const =0
Return if numbering is restarted at this node.
void IsSane(bool bRecursive, std::vector< const SwNumberTreeNode * > rParents) const
Sanity check with loop detection.
virtual SwNumberTree::tSwNumTreeNumber GetStartValue() const =0
Return start value.
virtual bool IsCountPhantoms() const =0
Return if phantoms are counted.
std::set< SwNumberTreeNode *, compSwNumberTreeNodeLessThan > tSwNumberTreeChildren
virtual void NotifyNode()=0
Notifies the node.
bool mbPhantom
true this node is a phantom false this node is NOT a phantom
SwNumberTreeNode & operator=(const SwNumberTreeNode &)
SwNumberTreeNode * GetParent() const
Returns the parent of this node.
virtual SwNumberTreeNode * Create() const =0
Creates a new node of the same class.
virtual void PreAdd()=0
void InvalidateAndNotifyTree(const SwDoc &rDoc)
Invalidation and notification of complete numbering tree.
RegionData_Impl * mpParent
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
Notify the background based on the difference between old and new rectangle.
Definition: frmtool.cxx:3254
tools::Long tSwNumTreeNumber
std::vector< tSwNumTreeNumber > tNumberVector
bool operator()(const SwNumberTreeNode *pA, const SwNumberTreeNode *pB) const