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  const SwNumberTreeNode * pB);
31 
33 {
34  bool operator()(const SwNumberTreeNode * pA,
35  const SwNumberTreeNode * pB) const
36  { return SwNumberTreeNodeLessThan(pA, pB); }
37 };
38 
113 class SAL_DLLPUBLIC_RTTI SwNumberTreeNode
114 {
115 protected:
116  typedef std::set<SwNumberTreeNode *, compSwNumberTreeNodeLessThan>
118 
119 public:
121 
122  virtual ~SwNumberTreeNode();
123 
130  void AddChild( SwNumberTreeNode* pChild,
131  const int nDepth );
132 
138  void RemoveChild( SwNumberTreeNode* pChild );
139 
143  void RemoveMe();
144 
151  {
152  return mpParent;
153  }
154 
162  SwNumberTree::tSwNumTreeNumber GetNumber( bool bValidate = true ) const;
163 
164  bool IsContinueingPreviousSubTree() const { return mbContinueingPreviousSubTree;}
165 
171  SwNumberTree::tNumberVector GetNumberVector() const;
172 
176  virtual bool IsRestart() const = 0;
177 
183  virtual SwNumberTree::tSwNumTreeNumber GetStartValue() const = 0;
184 
191  virtual bool IsCounted() const;
192 
199  virtual bool IsContinuous() const = 0;
200 
209  bool IsFirst(const SwNumberTreeNode * pNode) const;
210 
217  bool IsFirst() const;
218 
225  bool IsPhantom() const { return mbPhantom;}
226 
231  void SetLevelInListTree( const int nLevel );
232 
241  int GetLevelInListTree() const;
242 
254  virtual bool LessThan(const SwNumberTreeNode & rTreeNode) const;
255 
264  void InvalidateTree() const;
265 
270  void NotifyInvalidChildren();
271 
277  void InvalidateMe();
278 
284  void ValidateMe();
285 
287  void NotifyInvalidSiblings();
288 
290  void NotifyNodesOnListLevel( const int nListLevel );
291 
299  {
300  if ( GetRoot() )
301  {
302  GetRoot()->InvalidateTree();
303  GetRoot()->Notify();
304  }
305  }
306 
313  SwNumberTreeNode* GetPred( bool bSibling = false ) const;
314 
322  const SwNumberTreeNode* GetPrecedingNodeOf( const SwNumberTreeNode& rNode ) const;
323 
324 #ifdef DBG_UTIL
325 
333  void IsSane(bool bRecursive) const;
334 #endif // DBG_UTIL
335 
336 protected:
339 
347  SwNumberTreeNode* GetRoot() const;
348 
355  virtual bool IsNotificationEnabled() const = 0;
356 
362  tSwNumberTreeChildren::size_type GetChildCount() const;
363 
364  // #i64010# - made pure virtual
365  virtual bool HasCountedChildren() const = 0;
366 
367  // #i64010#
368  virtual bool IsCountedForNumbering() const = 0;
369 
370  // method called before this tree node has been added to the list tree
371  virtual void PreAdd() = 0;
372  // method called after this tree node has been removed from the list tree
373  virtual void PostRemove() = 0;
374 
375 #ifdef DBG_UTIL
376 
381  void IsSane(bool bRecursive, std::vector<const SwNumberTreeNode *> rParents) const;
382 #endif // DBG_UTIL
383 
386 
389 
390  // boolean indicating, that a node of a not counted parent node is continuing
391  // the numbering of parent's previous node sub tree.
392  // Example:
393  // 1. kshdkjfs
394  // 1.1. lskjf
395  // sdfjlksaf <-- not counted parent node
396  // 1.2. lfjlaskf <-- <mbContinueingPreviousSubTree = true>
398 
403  bool mbPhantom;
404 
410  mutable tSwNumberTreeChildren::const_iterator mItLastValid;
411 
413  SwNumberTreeNode& operator=( const SwNumberTreeNode& );
414 
422  void GetNumberVector_( SwNumberTree::tNumberVector& rVector,
423  bool bValidate = true ) const;
424 
433  void Invalidate( SwNumberTreeNode const * pChild );
434 
440  {
441  SetLastValid( mChildren.end() );
442  }
443 
453  void SetLastValid(const tSwNumberTreeChildren::const_iterator& aItLastValid,
454  bool bValidating = false) const;
455 
465  virtual bool IsNotifiable() const = 0;
466 
472  virtual void NotifyNode() = 0;
473 
475  void Notify();
476 
478  void NotifyChildrenOnDepth( const int nDepth );
479 
491  bool IsValid(const SwNumberTreeNode * pChild) const;
492 
499  bool IsValid() const;
500 
508  void Validate(const SwNumberTreeNode * pNode) const;
509 
517  void ValidateHierarchical(const SwNumberTreeNode * pNode) const;
518 
526  void ValidateContinuous(const SwNumberTreeNode * pNode) const;
527 
533  virtual SwNumberTreeNode * Create() const = 0;
534 
540  SwNumberTreeNode * CreatePhantom();
541 
545  virtual bool IsCountPhantoms() const = 0;
546 
548  bool HasOnlyPhantoms() const;
549 
550  bool HasPhantomCountedParent() const;
551 
559  SwNumberTreeNode* GetFirstNonPhantomChild();
560 
567  void ClearObsoletePhantoms();
568 
569  tSwNumberTreeChildren::const_iterator GetIterator(const SwNumberTreeNode * pChild) const;
570 
576  void MoveChildren(SwNumberTreeNode * pDest);
577 
592  void MoveGreaterChildren( SwNumberTreeNode& _rCompareNode,
593  SwNumberTreeNode& _rDestNode );
594 
600  SwNumberTreeNode* GetLastDescendant() const;
601 
602 };
603 
604 /* 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:3052
SwNumberTreeNode * GetParent() const
Returns the parent of this node.
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.
void Create(SvxOrientationItem &rItem, SvStream &rStrm, sal_uInt16)
std::set< SwNumberTreeNode *, compSwNumberTreeNodeLessThan > tSwNumberTreeChildren
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