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 
26 class SwNumberTreeNode;
27 
29 
31 {
32  bool operator()(const SwNumberTreeNode* pA, const SwNumberTreeNode* pB) const
33  {
34  return SwNumberTreeNodeLessThan(pA, pB);
35  }
36 };
37 
112 class SAL_DLLPUBLIC_RTTI SwNumberTreeNode
113 {
114 protected:
115  typedef std::set<SwNumberTreeNode*, compSwNumberTreeNodeLessThan> tSwNumberTreeChildren;
116 
117 public:
119 
120  virtual ~SwNumberTreeNode();
121 
128  void AddChild(SwNumberTreeNode* pChild, const int nDepth);
129 
135  void RemoveChild(SwNumberTreeNode* pChild);
136 
140  void RemoveMe();
141 
147  SwNumberTreeNode* GetParent() const { return mpParent; }
148 
156  SwNumberTree::tSwNumTreeNumber GetNumber(bool bValidate = true) const;
157 
158  bool IsContinueingPreviousSubTree() const { return mbContinueingPreviousSubTree; }
159 
165  SwNumberTree::tNumberVector GetNumberVector() const;
166 
170  virtual bool IsRestart() const = 0;
171 
177  virtual SwNumberTree::tSwNumTreeNumber GetStartValue() const = 0;
178 
185  virtual bool IsCounted() const;
186 
193  virtual bool IsContinuous() const = 0;
194 
203  bool IsFirst(const SwNumberTreeNode* pNode) const;
204 
211  bool IsFirst() const;
212 
219  bool IsPhantom() const { return mbPhantom; }
220 
225  void SetLevelInListTree(const int nLevel);
226 
235  int GetLevelInListTree() const;
236 
248  virtual bool LessThan(const SwNumberTreeNode& rTreeNode) const;
249 
258  void InvalidateTree() const;
259 
264  void NotifyInvalidChildren();
265 
271  void InvalidateMe();
272 
278  void ValidateMe();
279 
281  void NotifyInvalidSiblings();
282 
284  void NotifyNodesOnListLevel(const int nListLevel);
285 
293  {
294  if (GetRoot())
295  {
296  GetRoot()->InvalidateTree();
297  GetRoot()->Notify();
298  }
299  }
300 
307  SwNumberTreeNode* GetPred(bool bSibling = false) const;
308 
316  const SwNumberTreeNode* GetPrecedingNodeOf(const SwNumberTreeNode& rNode) const;
317 
318 #ifdef DBG_UTIL
319 
327  void IsSane(bool bRecursive) const;
328 #endif // DBG_UTIL
329 
335  tSwNumberTreeChildren::size_type GetChildCount() const;
336 
337 protected:
339  tSwNumberTreeChildren mChildren;
340 
348  SwNumberTreeNode* GetRoot() const;
349 
356  virtual bool IsNotificationEnabled() const = 0;
357 
358  // #i64010# - made pure virtual
359  virtual bool HasCountedChildren() const = 0;
360 
361  // #i64010#
362  virtual bool IsCountedForNumbering() const = 0;
363 
364  // method called before this tree node has been added to the list tree
365  virtual void PreAdd() = 0;
366  // method called after this tree node has been removed from the list tree
367  virtual void PostRemove() = 0;
368 
369 #ifdef DBG_UTIL
370 
375  void IsSane(bool bRecursive, std::vector<const SwNumberTreeNode*> rParents) const;
376 #endif // DBG_UTIL
377 
380 
383 
384  // boolean indicating, that a node of a not counted parent node is continuing
385  // the numbering of parent's previous node sub tree.
386  // Example:
387  // 1. kshdkjfs
388  // 1.1. lskjf
389  // sdfjlksaf <-- not counted parent node
390  // 1.2. lfjlaskf <-- <mbContinueingPreviousSubTree = true>
392 
397  bool mbPhantom;
398 
404  mutable tSwNumberTreeChildren::const_iterator mItLastValid;
405 
407  SwNumberTreeNode& operator=(const SwNumberTreeNode&);
408 
416  void GetNumberVector_(SwNumberTree::tNumberVector& rVector, bool bValidate = true) const;
417 
426  void Invalidate(SwNumberTreeNode const* pChild);
427 
432  void InvalidateChildren() { SetLastValid(mChildren.end()); }
433 
443  void SetLastValid(const tSwNumberTreeChildren::const_iterator& aItLastValid,
444  bool bValidating = false) const;
445 
455  virtual bool IsNotifiable() const = 0;
456 
462  virtual void NotifyNode() = 0;
463 
465  void Notify();
466 
468  void NotifyChildrenOnDepth(const int nDepth);
469 
481  bool IsValid(const SwNumberTreeNode* pChild) const;
482 
489  bool IsValid() const;
490 
498  void Validate(const SwNumberTreeNode* pNode) const;
499 
507  void ValidateHierarchical(const SwNumberTreeNode* pNode) const;
508 
516  void ValidateContinuous(const SwNumberTreeNode* pNode) const;
517 
523  virtual SwNumberTreeNode* Create() const = 0;
524 
530  SwNumberTreeNode* CreatePhantom();
531 
535  virtual bool IsCountPhantoms() const = 0;
536 
538  bool HasOnlyPhantoms() const;
539 
540  bool HasPhantomCountedParent() const;
541 
549  SwNumberTreeNode* GetFirstNonPhantomChild();
550 
557  void ClearObsoletePhantoms();
558 
559  tSwNumberTreeChildren::const_iterator GetIterator(const SwNumberTreeNode* pChild) const;
560 
566  void MoveChildren(SwNumberTreeNode* pDest);
567 
582  void MoveGreaterChildren(SwNumberTreeNode& _rCompareNode, SwNumberTreeNode& _rDestNode);
583 
589  SwNumberTreeNode* GetLastDescendant() const;
590 };
591 
592 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
A tree of numbered nodes.
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:3170
SwNumberTreeNode * GetParent() const
Returns the parent of this node.
bool SwNumberTreeNodeLessThan(const SwNumberTreeNode *pA, const SwNumberTreeNode *pB)
std::set< SwNumberTreeNode *, compSwNumberTreeNodeLessThan > tSwNumberTreeChildren
tSwNumberTreeChildren mChildren
the children
bool mbPhantom
true this node is a phantom false this node is NOT a phantom
bool IsPhantom() const
Return if this node is a phantom.
tools::Long tSwNumTreeNumber
void Create(SvxOrientationItem &rItem, SvStream &rStrm, sal_uInt16)
SwNumberTreeNode * mpParent
he parent node
tSwNumberTreeChildren::const_iterator mItLastValid
Iterator to the last valid element.
std::vector< tSwNumTreeNumber > tNumberVector
RegionData_Impl * mpParent
void InvalidateChildren()
Invalidation of all children.
bool operator()(const SwNumberTreeNode *pA, const SwNumberTreeNode *pB) const
bool IsContinueingPreviousSubTree() const
SwNumberTree::tSwNumTreeNumber mnNumber
the number of the node
void InvalidateAndNotifyTree()
Invalidation and notification of complete numbering tree.
bool mbContinueingPreviousSubTree