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 #ifndef INCLUDED_SW_INC_SWNUMBERTREE_HXX
21 #define INCLUDED_SW_INC_SWNUMBERTREE_HXX
22 
23 #include <set>
24 #include <vector>
25 #include "swdllapi.h"
26 #include "SwNumberTreeTypes.hxx"
27 
28 class SwNumberTreeNode;
29 
31  const SwNumberTreeNode * pB);
32 
34 {
35  bool operator()(const SwNumberTreeNode * pA,
36  const SwNumberTreeNode * pB) const
37  { return SwNumberTreeNodeLessThan(pA, pB); }
38 };
39 
115 {
116 protected:
117  typedef std::set<SwNumberTreeNode *, compSwNumberTreeNodeLessThan>
119 
120 public:
122 
123  virtual ~SwNumberTreeNode();
124 
131  void AddChild( SwNumberTreeNode* pChild,
132  const int nDepth );
133 
139  void RemoveChild( SwNumberTreeNode* pChild );
140 
144  void RemoveMe();
145 
152  {
153  return mpParent;
154  }
155 
163  SwNumberTree::tSwNumTreeNumber GetNumber( bool bValidate = true ) const;
164 
165  bool IsContinueingPreviousSubTree() const { return mbContinueingPreviousSubTree;}
166 
172  SwNumberTree::tNumberVector GetNumberVector() const;
173 
177  virtual bool IsRestart() const = 0;
178 
184  virtual SwNumberTree::tSwNumTreeNumber GetStartValue() const = 0;
185 
192  virtual bool IsCounted() const;
193 
200  virtual bool IsContinuous() const = 0;
201 
210  bool IsFirst(const SwNumberTreeNode * pNode) const;
211 
218  bool IsFirst() const;
219 
226  bool IsPhantom() const { return mbPhantom;}
227 
232  void SetLevelInListTree( const int nLevel );
233 
242  int GetLevelInListTree() const;
243 
255  virtual bool LessThan(const SwNumberTreeNode & rTreeNode) const;
256 
265  void InvalidateTree() const;
266 
271  void NotifyInvalidChildren();
272 
278  void InvalidateMe();
279 
285  void ValidateMe();
286 
288  void NotifyInvalidSiblings();
289 
291  void NotifyNodesOnListLevel( const int nListLevel );
292 
300  {
301  if ( GetRoot() )
302  {
303  GetRoot()->InvalidateTree();
304  GetRoot()->Notify();
305  }
306  }
307 
314  SwNumberTreeNode* GetPred( bool bSibling = false ) const;
315 
323  const SwNumberTreeNode* GetPrecedingNodeOf( const SwNumberTreeNode& rNode ) const;
324 
325 #ifdef DBG_UTIL
326 
334  void IsSane(bool bRecursive) const;
335 #endif // DBG_UTIL
336 
337 protected:
340 
348  SwNumberTreeNode* GetRoot() const;
349 
356  virtual bool IsNotificationEnabled() const = 0;
357 
363  tSwNumberTreeChildren::size_type GetChildCount() const;
364 
365  // #i64010# - made pure virtual
366  virtual bool HasCountedChildren() const = 0;
367 
368  // #i64010#
369  virtual bool IsCountedForNumbering() const = 0;
370 
371  // method called before this tree node has been added to the list tree
372  virtual void PreAdd() = 0;
373  // method called after this tree node has been removed from the list tree
374  virtual void PostRemove() = 0;
375 
376 #ifdef DBG_UTIL
377 
382  void IsSane(bool bRecursive, std::vector<const SwNumberTreeNode *> rParents) const;
383 #endif // DBG_UTIL
384 
387 
390 
391  // boolean indicating, that a node of a not counted parent node is continuing
392  // the numbering of parent's previous node sub tree.
393  // Example:
394  // 1. kshdkjfs
395  // 1.1. lskjf
396  // sdfjlksaf <-- not counted parent node
397  // 1.2. lfjlaskf <-- <mbContinueingPreviousSubTree = true>
399 
404  bool mbPhantom;
405 
411  mutable tSwNumberTreeChildren::const_iterator mItLastValid;
412 
414  SwNumberTreeNode& operator=( const SwNumberTreeNode& );
415 
423  void GetNumberVector_( SwNumberTree::tNumberVector& rVector,
424  bool bValidate = true ) const;
425 
434  void Invalidate( SwNumberTreeNode const * pChild );
435 
441  {
442  SetLastValid( mChildren.end() );
443  }
444 
454  void SetLastValid(const tSwNumberTreeChildren::const_iterator& aItLastValid,
455  bool bValidating = false) const;
456 
466  virtual bool IsNotifiable() const = 0;
467 
473  virtual void NotifyNode() = 0;
474 
476  void Notify();
477 
479  void NotifyChildrenOnDepth( const int nDepth );
480 
492  bool IsValid(const SwNumberTreeNode * pChild) const;
493 
500  bool IsValid() const;
501 
509  void Validate(const SwNumberTreeNode * pNode) const;
510 
518  void ValidateHierarchical(const SwNumberTreeNode * pNode) const;
519 
527  void ValidateContinuous(const SwNumberTreeNode * pNode) const;
528 
534  virtual SwNumberTreeNode * Create() const = 0;
535 
541  SwNumberTreeNode * CreatePhantom();
542 
546  virtual bool IsCountPhantoms() const = 0;
547 
549  bool HasOnlyPhantoms() const;
550 
551  bool HasPhantomCountedParent() const;
552 
560  SwNumberTreeNode* GetFirstNonPhantomChild();
561 
568  void ClearObsoletePhantoms();
569 
570  tSwNumberTreeChildren::const_iterator GetIterator(const SwNumberTreeNode * pChild) const;
571 
577  void MoveChildren(SwNumberTreeNode * pDest);
578 
593  void MoveGreaterChildren( SwNumberTreeNode& _rCompareNode,
594  SwNumberTreeNode& _rDestNode );
595 
601  SwNumberTreeNode* GetLastDescendant() const;
602 
603 };
604 
605 #endif // INCLUDED_SW_INC_SWNUMBERTREE_HXX
606 
607 /* 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:2924
SwNumberTreeNode * GetParent() const
Returns the parent of this node.
void Create(SvxOrientationItem &rItem, SvStream &rStrm, sal_uInt16)
bool SwNumberTreeNodeLessThan(const SwNumberTreeNode *pA, const SwNumberTreeNode *pB)
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.
std::set< SwNumberTreeNode *, compSwNumberTreeNodeLessThan > tSwNumberTreeChildren
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
SwNumberTreeNode * mpParent
he parent node
tSwNumberTreeChildren::const_iterator mItLastValid
Iterator to the last valid element.
std::vector< tSwNumTreeNumber > tNumberVector
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