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 "swdllapi.h"
25 #include "SwNumberTreeTypes.hxx"
26 
27 class SwNumberTreeNode;
28 
30 
32 {
33  bool operator()(const SwNumberTreeNode* pA, const SwNumberTreeNode* pB) const
34  {
35  return SwNumberTreeNodeLessThan(pA, pB);
36  }
37 };
38 
113 class SAL_DLLPUBLIC_RTTI SwNumberTreeNode
114 {
115 protected:
116  typedef std::set<SwNumberTreeNode*, compSwNumberTreeNodeLessThan> tSwNumberTreeChildren;
117 
118 public:
120 
121  virtual ~SwNumberTreeNode();
122 
129  void AddChild(SwNumberTreeNode* pChild, const int nDepth);
130 
136  void RemoveChild(SwNumberTreeNode* pChild);
137 
141  void RemoveMe();
142 
148  SwNumberTreeNode* GetParent() const { return mpParent; }
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 
178  virtual SwNumberTree::tSwNumTreeNumber GetStartValue() const = 0;
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);
227 
236  int GetLevelInListTree() const;
237 
249  virtual bool LessThan(const SwNumberTreeNode& rTreeNode) const;
250 
259  void InvalidateTree() const;
260 
265  void NotifyInvalidChildren();
266 
272  void InvalidateMe();
273 
279  void ValidateMe();
280 
282  void NotifyInvalidSiblings();
283 
285  void NotifyNodesOnListLevel(const int nListLevel);
286 
294  {
295  if (GetRoot())
296  {
297  GetRoot()->InvalidateTree();
298  GetRoot()->Notify();
299  }
300  }
301 
308  SwNumberTreeNode* GetPred(bool bSibling = false) const;
309 
317  const SwNumberTreeNode* GetPrecedingNodeOf(const SwNumberTreeNode& rNode) const;
318 
319 #ifdef DBG_UTIL
320 
328  void IsSane(bool bRecursive) const;
329 #endif // DBG_UTIL
330 
331 protected:
333  tSwNumberTreeChildren mChildren;
334 
342  SwNumberTreeNode* GetRoot() const;
343 
350  virtual bool IsNotificationEnabled() const = 0;
351 
357  tSwNumberTreeChildren::size_type GetChildCount() const;
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
371 
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 
398  bool mbPhantom;
399 
405  mutable tSwNumberTreeChildren::const_iterator mItLastValid;
406 
408  SwNumberTreeNode& operator=(const SwNumberTreeNode&);
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 = 0;
457 
463  virtual void NotifyNode() = 0;
464 
466  void Notify();
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: */
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:3121
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