summaryrefslogtreecommitdiff
path: root/sw/inc/SwNumberTree.hxx
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2008-06-13 08:25:24 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2008-06-13 08:25:24 +0000
commit9b36607a1b0679c46acf2a700333f4d593c4e7a4 (patch)
tree98ca8b0a87dd77d1a1b92850aa040a89ebeeb3d9 /sw/inc/SwNumberTree.hxx
parent3b49b14e4206885e389ae4eeaa9b2def5b719b6d (diff)
INTEGRATION: CWS swlists01 (1.6.36); FILE MERGED
2008/06/10 14:01:49 od 1.6.36.10: correction after merging conflicts 2008/06/10 07:27:00 od 1.6.36.9: RESYNC: (1.9-1.10); FILE MERGED 2008/05/08 16:17:24 od 1.6.36.8: RESYNC: (1.7-1.9); FILE MERGED 2008/05/07 07:12:40 od 1.6.36.7: #i86732# further changes/adjustments for new list handling 2008/03/20 17:12:15 od 1.6.36.6: correction of merge 2008/03/20 16:25:42 od 1.6.36.5: correction of merge conflict solution 2008/03/20 16:03:54 od 1.6.36.4: correction of merge conflict solution 2008/03/20 14:26:24 od 1.6.36.3: RESYNC: (1.6-1.7); FILE MERGED 2008/03/20 07:47:59 od 1.6.36.2: #i86732# class <SwNumberTreeNode> - adjust synopsis of method <AddChild(..)> - introduce new methods <SetLevelInListTree(..)> 2008/03/06 07:48:14 od 1.6.36.1: #i86732# class <SwNumberTreeNode> and <SwNodeNum> - refactoring of class interfaces
Diffstat (limited to 'sw/inc/SwNumberTree.hxx')
-rw-r--r--sw/inc/SwNumberTree.hxx777
1 files changed, 394 insertions, 383 deletions
diff --git a/sw/inc/SwNumberTree.hxx b/sw/inc/SwNumberTree.hxx
index 8ce7627c9d..f82763b855 100644
--- a/sw/inc/SwNumberTree.hxx
+++ b/sw/inc/SwNumberTree.hxx
@@ -1,13 +1,13 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: SwNumberTree.hxx,v $
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
* This file is part of OpenOffice.org.
*
@@ -35,6 +35,7 @@
#include <vector>
#include <tools/string.hxx>
#include <swdllapi.h>
+#include <SwNumberTreeTypes.hxx>
class SwNumberTreeNode;
@@ -124,272 +125,284 @@ struct compSwNumberTreeNodeLessThan
*/
class SW_DLLPUBLIC SwNumberTreeNode
{
- /**
- Default indent for printing a tree.
-
- If a level has level n this indent is printed n times before
- the actual node is printed.
- */
- //String sDefaultIndent;
-
-#ifndef PRODUCT
- /**
- Counter for the number of created instances.
- */
- static unsigned long nInstances;
-
- /**
- Serial number.
- */
- unsigned long mnSerial;
-#endif
-
protected:
typedef std::set<SwNumberTreeNode *, compSwNumberTreeNodeLessThan>
tSwNumberTreeChildren;
public:
- typedef long tSwNumTreeNumber;
- typedef std::vector<tSwNumTreeNumber> tNumberVector;
+ SwNumberTreeNode();
-protected:
- /**
- the parent node
- */
- SwNumberTreeNode * mpParent;
+ virtual ~SwNumberTreeNode();
/**
- the number of the node
- */
- mutable tSwNumTreeNumber mnNumber;
+ Add a child.
- /**
- true this node is a phantom
- false this node is NOT a phantom
+ @param pChild child to add
+ @param nDepth depth in which to add the child
*/
- bool mbPhantom;
+ void AddChild( SwNumberTreeNode* pChild,
+ const int nDepth = 0 );
/**
- the children
- */
- tSwNumberTreeChildren mChildren;
+ Remove a child.
+
+ OD 2008-02-19 #refactorlists# - no longer virtual
+
+ @param pChild child to be removed
+ */
+ void RemoveChild( SwNumberTreeNode* pChild );
/**
- Iterator to the last valid element. All children that are less
- than or equal to the referenced child are valid. All children
- greater than the referenced child are invalid.
+ Remove this child from the tree.
*/
- mutable tSwNumberTreeChildren::iterator mItLastValid;
+ void RemoveMe();
/**
- Validates a child.
+ Returns the parent of this node.
- @param pNode child to be validated
+ @return the parent
+ */
+ inline SwNumberTreeNode* GetParent() const
+ {
+ return mpParent;
+ }
- @attention All invalid children preceding pNode are validated, too.
- */
- void Validate(const SwNumberTreeNode * pNode) const;
+ /**
+ Returns the first child of this node.
+
+ @return the child
+ */
+ SwNumberTreeNode* GetFirstChild() const;
/**
- Validates a child using hierarchical numbering.
+ Returns number of this node.
- @param pNode child to be validated
+ @param bValidate validate the number?
- @attention All invalid children preceding pNode are validated, too.
+ @return number of this node
*/
- void ValidateHierarchical(const SwNumberTreeNode * pNode) const;
+ SwNumberTree::tSwNumTreeNumber GetNumber( bool bValidate = true ) const;
/**
- Validates a child using continuous numbering.
+ Returns level numbers of this node.
- @param pNode child to be validated
+ @return level numbers of this node
+ */
+ SwNumberTree::tNumberVector GetNumberVector() const;
- @attention All invalid children preceding pNode are validated, too.
+ /**
+ Return if numbering is restartet at this node.
*/
- void ValidateContinuous(const SwNumberTreeNode * pNode) const;
+ virtual bool IsRestart() const = 0;
/**
- HB, OD : return node, if it isn't a phantom, otherwise return first
- non-phantom descendant.
- Returns the first child of this node that is NOT a phantom.
+ Return start value.
- @return the first non phantom child
- */
- SwNumberTreeNode * GetFirstNonPhantomChild();
+ @return start value
+ */
+ virtual SwNumberTree::tSwNumTreeNumber GetStartValue() const = 0;
/**
- Returns the last descendant of a node, if it has children.
+ Return if this node is counted.
- @return last descendant of the node
- */
- SwNumberTreeNode * GetLastDescendant() const;
+ @retval true this node is counted
+ @retval false this node is NOT counted
+ */
+ virtual bool IsCounted() const;
/**
- Set the last valid child of this node.
+ Return if this node is counted continuous.
- @param aItLastValid iterator pointing to the new last valid child
- @param bValidating - true always set the last valid node to
- aItLastValid
- - false only set if aItLastValid is preceeding
- the current last valid node
+ @retval true This node is counted continuous.
+ @retval false else
*/
- void SetLastValid(tSwNumberTreeChildren::iterator aItLastValid,
- bool bValidating = false) const;
+ virtual bool IsContinuous() const = 0;
/**
- Set this node as last valid child of its parent.
+ Return if a node is first non-phantom child of this node.
- @param bValidation see aboce
+ @param pNode the node to check
+
+ @retval true pNode is first child of this node
+ @retval false else
*/
- void SetLastValid(bool bValidating) const;
+ virtual bool IsFirst(const SwNumberTreeNode * pNode) const;
/**
- Notifies the node.
+ Return if this node if the first non-phantom node in the tree.
- Called when the number of the node got invalid.
+ @retval true this node is the first non-phantom node in the tree
+ @retval false else
*/
- virtual void NotifyNode();
+ virtual bool IsFirst() const;
/**
- Notifies this node (NotifyNode) and all descendants.
+ Return if this node is a phantom.
+
+ @retval true this node is a phantom
+ @retval false this node is NOT a phantom
*/
- void Notify();
+ bool IsPhantom() const;
- /**
- Notifies all invalid siblings of this node.
+ /** set level of this node
+
+ OD 2008-03-13 #refactorlists#
+ precondition: node is already member of a list tree
+
+ @author OD
*/
- void NotifyInvalidSiblings();
+ void SetLevelInListTree( const int nLevel );
/**
- Calls _GetNumberVector on parent and adds number of this node
- at the end.
+ Return level of this node.
- @param rVector return value
- @param bValidate validate the number?
+ The level of this node is the length of the path from the root
+ to this node.
+
+ @return the level of this node
*/
- void _GetNumberVector(tNumberVector & rVector, bool bValidate = true) const;
+ int GetLevelInListTree() const;
- /** Moves all children of this node that are greater than a given node
- to the destination node.
+ /**
+ Returns if this node is less than another node.
- OD 2005-10-14 #125991#
- distinguish between node for comparing, whose children are greater,
- and the destination node.
+ @param rTreeNode node to compare with
- @param _rCompareNode
- input parameter - reference to the node, which is used to determine
- the greater children
+ @attention A phantom node is considered the least element with
+ respect to lessThan.
- @param _rDestNode
- input parameter - reference to the node, which is the destination for
- the greater children
+ @retval true this node is less than rTreeNode
+ @retval false else
*/
- void MoveGreaterChildren( SwNumberTreeNode& _rCompareNode,
- SwNumberTreeNode& _rDestNode );
+ virtual bool LessThan(const SwNumberTreeNode & rTreeNode) const;
/**
- Moves all children to a given destination node.
+ Invalidate this node and all its descendants.
- @param pDest the destination node
+ All iterators holding the last valid node in the according list
+ of childs are set to the end of this list, thereby stating all
+ children in the list are invalid.
+ OD 2007-10-26 #i83479# - made public
*/
- void MoveChildren(SwNumberTreeNode * pDest);
+ void InvalidateTree() const;
/**
- Creates a phantom.
-
- @return the created phantom
+ Notifies all invalid children of this node.
+ OD 2007-10-26 #i83479# - made public
*/
- SwNumberTreeNode * CreatePhantom();
+ void NotifyInvalidChildren();
/**
- Removes recursively phantoms that have no children.
+ Notifies the node.
- The resulting tree has no phantoms that either have no children or
- whose descendancy consist entirely of phantoms.
+ Calls Invalidate(this) on parent.
*/
- void ClearObsoletePhantoms();
+ void InvalidateMe();
/**
- Return if all descendants of this node are phantoms.
+ Validate the tree.
- @retval true all descendants are phantoms
- @retval false else
- */
- bool HasOnlyPhantoms() const;
+ Validates all nodes in this subtree.
+ */
+ void ValidateTree();
-#ifdef __SW_NUMBER_TREE_SANITY_CHECK
/**
- Sanity check with loop detection.
+ Validates this node.
- @param bRecursive descend to children
- @param rParents vector for recording path
+ Calls Validate(this) on parent.
+ */
+ void ValidateMe();
- @retval true this node is sane
- @retval false else */
- virtual bool IsSane
- (bool bRecursive, std::vector<const SwNumberTreeNode *> rParents) const;
-#endif // __SW_NUMBER_TREE_SANITY_CHECK
+ /**
+ Notifies all invalid siblings of this node.
+ */
+ void NotifyInvalidSiblings();
- tSwNumberTreeChildren::iterator
- GetIterator(const SwNumberTreeNode * pChild) const;
+ /** notification of all nodes in the list tree on certain list level
- // --> OD 2006-04-26 #i64010# - made pure virtual
- virtual bool HasCountedChildren() const = 0;
- // <--
+ OD 2008-04-17 #refactorlists#
+ */
+ void NotifyNodesOnListLevel( const int nListLevel );
- // --> OD 2005-10-27 #126009#
- bool HasPhantomCountedParent() const;
- // <--
+ /** Invalidation and notification of complete numbering tree
- // --> OD 2006-04-26 #i64010#
- virtual bool IsCountedForNumbering() const = 0;
- // <--
-public:
- SwNumberTreeNode();
- SwNumberTreeNode(const SwNumberTreeNode & rNode);
+ OD 2006-04-26 #i64010#
+ Usage: on <IsCounted()> state change its needed to invalidate the
+ complete numbering tree due to wide influence of this change.
+ */
+ inline void InvalidateAndNotifyTree()
+ {
+ if ( GetRoot() )
+ {
+ GetRoot()->InvalidateTree();
+ GetRoot()->Notify();
+ }
+ }
- virtual ~SwNumberTreeNode();
+ /**
+ Returns the greatest descendant of the root that is smaller than
+ this node, aka the predecessor of this node.
-#ifndef PRODUCT
- static unsigned long GetInstances();
- unsigned long GetSerial();
-#endif
+ @return the predecessor
+ */
+ SwNumberTreeNode* GetPred( bool bSibling = false ) const;
- /**
- Creates a new node of the same class.
+ /** determines the node, which is preceding the node
- @return the new node
+ OD 2007-09-06 #i81002#
+ The search for the preceding node is performed for the tree below the
+ <this> node. To search the complete tree, the method has been called for
+ the root of the tree.
+
+ @author OD
*/
- virtual SwNumberTreeNode * Create() const = 0;
+ const SwNumberTreeNode* GetPrecedingNodeOf( const SwNumberTreeNode& rNode ) const;
- /**
- Creates a copy of this node.
+// /**
+// Returns a string representation of this node.
- @return the copy
- */
- virtual SwNumberTreeNode * Copy() const = 0;
+// @return the string representation of this node
+// */
+// virtual String ToString() const = 0;
- /**
- Returns the parent of this node.
+// /**
+// Print this subtree.
- @return the parent
- */
- SwNumberTreeNode * GetParent() const { return mpParent; }
+// @param o output stream to direct output to
+// @param rIndent additional indent for the children of this node
+// @param rMyIndent indent to use for this node
+// @param nDepth number of levels to print (-1 means all levels)
- /**
- Returns the first child of this node.
+// @return output stream after output of this subtree
+// */
+// String print(const String & rIndent = String(" ",
+// RTL_TEXTENCODING_ASCII_US),
+// const String & rMyIndent = String(" ",
+// RTL_TEXTENCODING_ASCII_US),
+// int nDepth = -1) const;
- @return the child
- */
- SwNumberTreeNode * GetFirstChild() const;
+#ifndef PRODUCT
+ static unsigned long GetInstances();
+ unsigned long GetSerial();
+#endif
+#ifdef __SW_NUMBER_TREE_SANITY_CHECK
/**
- Returns the greatest descendant of the root that is smaller than
- this node, aka the predecessor of this node.
+ Sanity check.
- @return the predecessor
+ @param bRecursive descend to children
+
+ @retval true the structure of this node is sane
+ @retval false else
*/
- SwNumberTreeNode * GetPred( bool bSibling = false ) const;
+ bool IsSane(bool bRecursive) const;
+#endif // __SW_NUMBER_TREE_SANITY_CHECK
+
+protected:
+ /**
+ the children
+ */
+ tSwNumberTreeChildren mChildren;
/**
Returns the root node of the tree this node is part of.
@@ -398,134 +411,151 @@ public:
@return the root
*/
- SwNumberTreeNode * GetRoot() const;
+ SwNumberTreeNode* GetRoot() const;
- /**
- Add a child.
-
- OD 2007-10-25 #i83479# - made virtual
+ /**
+ Return if the notification is not disabled on global conditions
- @param pChild child to add
- @param nDepth depth in whuch to add the child
+ @retval true Notification enabled in general.
+ @retval false else
*/
- virtual void AddChild(SwNumberTreeNode * pChild, unsigned int nDepth = 0);
+ virtual bool IsNotificationEnabled() const = 0;
/**
- Remove a child.
-
- @param pChild child to be removed
- */
- virtual void RemoveChild(SwNumberTreeNode * pChild);
+ Returns how many children this node has got.
- /**
- Remove this child from the tree.
+ @return number of children
*/
- void RemoveMe();
+ tSwNumberTreeChildren::size_type GetChildCount() const;
- /**
- Returns number of this node.
+ // --> OD 2006-04-26 #i64010# - made pure virtual
+ virtual bool HasCountedChildren() const = 0;
+ // <--
- @param bValidate validate the number?
+ // --> OD 2006-04-26 #i64010#
+ virtual bool IsCountedForNumbering() const = 0;
+ // <--
- @return number of this node
- */
- tSwNumTreeNumber GetNumber(bool bValidate = true) const;
+ // --> OD 2008-02-19 #refactorlists#
+ // method called before this tree node has been added to the list tree
+ virtual void PreAdd() = 0;
+ // method called after this tree node has been removed from the list tree
+ virtual void PostRemove() = 0;
+ // <--
+#ifdef __SW_NUMBER_TREE_SANITY_CHECK
/**
- Returns level numbers of this node.
-
- @return level numbers of this node
- */
- tNumberVector GetNumberVector() const;
+ Sanity check with loop detection.
- /**
- Return start value.
+ @param bRecursive descend to children
+ @param rParents vector for recording path
- @return start value
- */
- virtual tSwNumTreeNumber GetStart() const;
+ @retval true this node is sane
+ @retval false else */
+ virtual bool IsSane
+ (bool bRecursive, std::vector<const SwNumberTreeNode *> rParents) const;
+#endif // __SW_NUMBER_TREE_SANITY_CHECK
+private:
/**
- Return if numbering is restartet at this node.
- */
- virtual bool IsRestart() const;
+ the parent node
+ */
+ SwNumberTreeNode * mpParent;
/**
- Return if phantoms are counted.
+ the number of the node
+ */
+ mutable SwNumberTree::tSwNumTreeNumber mnNumber;
- @retval true phantoms are counted
- @retval false else
+ /**
+ true this node is a phantom
+ false this node is NOT a phantom
*/
- virtual bool IsCountPhantoms() const;
+ bool mbPhantom;
/**
- Invalidate this node and all its descendants.
-
- All iterators holding the last valid node in the according list
- of childs are set to the end of this list, thereby stating all
- children in the list are invalid.
- OD 2007-10-26 #i83479# - made public
+ Iterator to the last valid element. All children that are less
+ than or equal to the referenced child are valid. All children
+ greater than the referenced child are invalid.
*/
- void InvalidateTree() const;
+ mutable tSwNumberTreeChildren::iterator mItLastValid;
+#ifndef PRODUCT
/**
- Notifies all invalid children of this node.
- OD 2007-10-26 #i83479# - made public
+ Counter for the number of created instances.
*/
- void NotifyInvalidChildren();
+ static unsigned long nInstances;
/**
- Returns if a child A this node is valid.
+ Serial number.
+ */
+ unsigned long mnSerial;
+#endif
- A is valid if aItLastValid in parent refers to a node
- greater than of equal to A.
+ SwNumberTreeNode(const SwNumberTreeNode& );
+ SwNumberTreeNode& operator=( const SwNumberTreeNode& );
- @param pChild child to be tested
+ /**
+ Calls _GetNumberVector on parent and adds number of this node
+ at the end.
- @retval true this node is valid
- @retval false this node is NOT valid
+ @param rVector return value
+ @param bValidate validate the number?
*/
- bool IsValid(const SwNumberTreeNode * pChild) const;
+ void _GetNumberVector( SwNumberTree::tNumberVector& rVector,
+ bool bValidate = true ) const;
/**
- Returns if this node is valid.
+ Invalidates a child.
- @retval true this node is valid
- @retval false else
+ Calls SetLastValid for the preceeding sibling of the child and
+ notifies all invalid children.
+
+ @param pChild the child to invalidate
*/
- bool IsValid() const;
+ void Invalidate( SwNumberTreeNode * pChild );
- /**
- Return if this node is a phantom.
+ /** Invalidation of all children
- @retval true this node is a phantom
- @retval false this node is NOT a phantom
- */
- bool IsPhantom() const;
+ OD 2005-10-19 #126009#
+ Usage: on <IsCounted()> state change the children have to be invalidated
+ */
+ inline void InvalidateChildren()
+ {
+ SetLastValid( mChildren.end() );
+ }
- /**
- Set if this node is a phantom.
+ /** Invalidation of parent node, if its not counted.
- @param bPhantom - true this node is a phantom
- - false this node is a phantom
- */
- void SetPhantom(bool bPhantom = true);
+ OD 2005-10-19 #126009#
+ Usage: on <IsCounted()> state change the parent have to be invalidated
+ */
+ inline void InvalidateNotCountedParent()
+ {
+ if ( GetParent() && !GetParent()->IsCountedForNumbering() )
+ {
+ GetParent()->InvalidateMe();
+ }
+ }
/**
- Return if this node is counted.
+ Set the last valid child of this node.
- @retval true this node is counted
- @retval false this node is NOT counted
+ @param aItLastValid iterator pointing to the new last valid child
+ @param bValidating - true always set the last valid node to
+ aItLastValid
+ - false only set if aItLastValid is preceeding
+ the current last valid node
*/
- virtual bool IsCounted() const;
+ void SetLastValid(tSwNumberTreeChildren::iterator aItLastValid,
+ bool bValidating = false) const;
/**
- Return if this node is counted continuous.
+ Set this node as last valid child of its parent.
- @retval true This node is counted continuous.
- @retval false else
+ @param bValidation see aboce
*/
- virtual bool IsContinuous() const;
+ void SetLastValid(bool bValidating) const;
/**
Return if this node is notifiable.
@@ -536,203 +566,184 @@ public:
@retval true This node is notifiable.
@retval false else
*/
- virtual bool IsNotifiable() const;
+ virtual bool IsNotifiable() const = 0;
- /**
- Return if the notification is not disabled on global conditions
+ /**
+ Notifies the node.
- @retval true Notification enabled in general.
- @retval false else
+ Called when the number of the node got invalid.
*/
- virtual bool IsNotificationEnabled() const = 0;
+ virtual void NotifyNode() = 0;
/**
- Return if a node is first non-phantom child of this node.
+ Notifies this node (NotifyNode) and all descendants.
+ */
+ void Notify();
- @param pNode the node to check
+ /** Notification of parent node siblings, if its not counted.
- @retval true pNode is first child of this node
- @retval false else
- */
- virtual bool IsFirst(const SwNumberTreeNode * pNode) const;
+ OD 2005-10-19 #126009#
+ Usage: on <IsCounted()> state change the parent node and its siblings
+ have to be notified.
+ */
+ inline void NotifyNotCountedParentSiblings()
+ {
+ if ( GetParent() && !GetParent()->IsCountedForNumbering() )
+ {
+ GetParent()->NotifyInvalidSiblings();
+ }
+ }
- /**
- Return if this node if the first non-phantom node in the tree.
+ /** notification of children nodes on certain depth
- @retval true this node is the first non-phantom node in the tree
- @retval false else
- */
- virtual bool IsFirst() const;
+ OD 2008-04-17 #refactorlists#
+
+ @author OD
+ */
+ void NotifyChildrenOnDepth( const int nDepth );
/**
- Return level of this node.
+ Returns if a child A this node is valid.
- The level of this node is the length of the path from the root
- to this node.
+ A is valid if aItLastValid in parent refers to a node
+ greater than of equal to A.
- @return the level of this node
+ @param pChild child to be tested
+
+ @retval true this node is valid
+ @retval false this node is NOT valid
*/
- int GetLevel() const;
+ bool IsValid(const SwNumberTreeNode * pChild) const;
/**
- Returns how many children this node has got.
+ Returns if this node is valid.
- @return number of children
+ @retval true this node is valid
+ @retval false else
*/
- tSwNumberTreeChildren::size_type GetChildCount() const;
+ bool IsValid() const;
/**
- Returns if this node is less than another node.
-
- @param rTreeNode node to compare with
-
- @attention A phantom node is considered the least element with
- respect to lessThan.
-
- @retval true this node is less than rTreeNode
- @retval false else
- */
- virtual bool LessThan(const SwNumberTreeNode & rTreeNode) const
- { return this < &rTreeNode; }
+ Validates a child.
- /**
- Validate the tree.
+ @param pNode child to be validated
- Validates all nodes in this subtree.
- */
- void ValidateTree();
+ @attention All invalid children preceding pNode are validated, too.
+ */
+ void Validate(const SwNumberTreeNode * pNode) const;
/**
- Invalidates a child.
+ Validates a child using hierarchical numbering.
- Calls SetLastValid for the preceeding sibling of the child and
- notifies all invalid children.
+ @param pNode child to be validated
- @param pChild the child to invalidate
+ @attention All invalid children preceding pNode are validated, too.
*/
- void Invalidate(SwNumberTreeNode * pChild);
+ void ValidateHierarchical(const SwNumberTreeNode * pNode) const;
/**
- Invalidates this node.
+ Validates a child using continuous numbering.
- Calls Invalidate(this) on parent.
+ @param pNode child to be validated
+
+ @attention All invalid children preceding pNode are validated, too.
*/
- void InvalidateMe();
+ void ValidateContinuous(const SwNumberTreeNode * pNode) const;
/**
- Validates this node.
+ Creates a new node of the same class.
- Calls Validate(this) on parent.
+ @return the new node
*/
- void ValidateMe();
+ virtual SwNumberTreeNode * Create() const = 0;
-#ifdef __SW_NUMBER_TREE_SANITY_CHECK
/**
- Sanity check.
-
- @param bRecursive descend to children
+ Creates a phantom.
- @retval true the structure of this node is sane
- @retval false else
+ @return the created phantom
*/
- bool IsSane(bool bRecursive) const;
-#endif // __SW_NUMBER_TREE_SANITY_CHECK
+ SwNumberTreeNode * CreatePhantom();
/**
- Returns a string representation of this node.
+ Set if this node is a phantom.
- @return the string representation of this node
+ @param bPhantom - true this node is a phantom
+ - false this node is a phantom
*/
- virtual String ToString() const = 0;
+ void SetPhantom(bool bPhantom = true);
/**
- Returns the number of nodes in this subtree.
+ Return if phantoms are counted.
- @param bCountPhantoms - true count phantoms
- - false else
+ OD 2008-02-19 #refactorlists# - pure virtual now
- @return number of nodes counted in this subtree
+ @retval true phantoms are counted
+ @retval false else
*/
- unsigned long GetCount(bool bCountPhantoms = false) const;
+ virtual bool IsCountPhantoms() const = 0;
- /** Invalidation of all children
+ /**
+ Return if all descendants of this node are phantoms.
- OD 2005-10-19 #126009#
- Usage: on <IsCounted()> state change the children have to be invalidated
- */
- inline void InvalidateChildren()
- {
- SetLastValid( mChildren.end() );
- }
+ @retval true all descendants are phantoms
+ @retval false else
+ */
+ bool HasOnlyPhantoms() const;
- /** Invalidation of parent node, if its not counted.
+ // --> OD 2005-10-27 #126009#
+ bool HasPhantomCountedParent() const;
+ // <--
- OD 2005-10-19 #126009#
- Usage: on <IsCounted()> state change the parent have to be invalidated
+ /**
+ HB, OD : return node, if it isn't a phantom, otherwise return first
+ non-phantom descendant.
+ Returns the first child of this node that is NOT a phantom.
+
+ @return the first non phantom child
*/
- inline void InvalidateNotCountedParent()
- {
- if ( GetParent() && !GetParent()->IsCountedForNumbering() )
- {
- GetParent()->InvalidateMe();
- }
- }
+ SwNumberTreeNode* GetFirstNonPhantomChild();
- /** Notification of parent node siblings, if its not counted.
+ /**
+ Removes recursively phantoms that have no children.
- OD 2005-10-19 #126009#
- Usage: on <IsCounted()> state change the parent node and its siblings
- have to be notified.
- */
- inline void NotifyNotCountedParentSiblings()
- {
- if ( GetParent() && !GetParent()->IsCountedForNumbering() )
- {
- GetParent()->NotifyInvalidSiblings();
- }
- }
+ The resulting tree has no phantoms that either have no children or
+ whose descendancy consist entirely of phantoms.
+ */
+ void ClearObsoletePhantoms();
- /** Invalidation and notification of complete numbering tree
+ tSwNumberTreeChildren::iterator GetIterator(const SwNumberTreeNode * pChild) const;
- OD 2006-04-26 #i64010#
- Usage: on <IsCounted()> state change its needed to invalidate the
- complete numbering tree due to wide influence of this change.
- */
- inline void InvalidateAndNotifyTree()
- {
- if ( GetRoot() )
- {
- GetRoot()->InvalidateTree();
- GetRoot()->Notify();
- }
- }
+ /**
+ Moves all children to a given destination node.
- /** determines the node, which is preceding the node
+ @param pDest the destination node
+ */
+ void MoveChildren(SwNumberTreeNode * pDest);
- OD 2007-09-06 #i81002#
- The search for the preceding node is performed for the tree below the
- <this> node. To search the complete tree, the method has been called for
- the root of the tree.
+ /** Moves all children of this node that are greater than a given node
+ to the destination node.
- @author OD
+ OD 2005-10-14 #125991#
+ distinguish between node for comparing, whose children are greater,
+ and the destination node.
+
+ @param _rCompareNode
+ input parameter - reference to the node, which is used to determine
+ the greater children
+
+ @param _rDestNode
+ input parameter - reference to the node, which is the destination for
+ the greater children
*/
- const SwNumberTreeNode* GetPrecedingNodeOf( const SwNumberTreeNode& rNode ) const;
+ void MoveGreaterChildren( SwNumberTreeNode& _rCompareNode,
+ SwNumberTreeNode& _rDestNode );
/**
- Print this subtree.
-
- @param o output stream to direct output to
- @param rIndent additional indent for the children of this node
- @param rMyIndent indent to use for this node
- @param nDepth number of levels to print (-1 means all levels)
+ Returns the last descendant of a node, if it has children.
- @return output stream after output of this subtree
- */
- String print(const String & rIndent = String(" ",
- RTL_TEXTENCODING_ASCII_US),
- const String & rMyIndent = String(" ",
- RTL_TEXTENCODING_ASCII_US),
- int nDepth = -1) const;
+ @return last descendant of the node
+ */
+ SwNumberTreeNode* GetLastDescendant() const;
};