NodeDocument Class Reference

This class represents the root of a document tree. It contains the extents of the entire document as two DocCoords (LowExtent, HighExtent). LowExtent is the Coordinate position of the low corner of its first chapter whilst High Extent is the coordinate position of the high corner of its final chapter. More...

#include <nodedoc.h>

Inheritance diagram for NodeDocument:

NodeRenderablePaper NodeRenderableBounded NodeRenderable Node CCObject SimpleCCObject List of all members.

Public Member Functions

 NodeDocument ()
 This constructor creates a NodeDocument linked to no other nodes, with all status flags false, and NULL bounding and pasteboard rectangles.
 NodeDocument (Node *ContextNode, AttachNodeDirection Direction, BOOL Locked=FALSE, BOOL Mangled=FALSE, BOOL Marked=FALSE, BOOL Selected=FALSE)
 This constructor initialises the node and links it to ContextNode in the direction specified by Direction. All neccesary tree links are updated.
 ~NodeDocument ()
 NodeDocument destructor.
void SetParentDoc (BaseDocument *pNewDoc)
 Specify which Document object a NodeDocument object is attached to. This cannot be done again, unless this function is first called with NULL as the document to attachto.
BaseDocumentGetParentDoc ()
virtual BOOL IsNodeDocument () const
 Find out which Document object a NodeDocument object is attached to. Tell the caller that this is a NodeDocument.
DocCoord LoExtent () const
 For finding the low extent of the document.
DocCoord HiExtent () const
 For finding the high extent of the document.
void DescribeExtents (DocCoord *LoExtent, DocCoord *HiExtent) const
 For finding the extents of the document.
void SetExtents ()
 For setting the document's extents in the NodeDocument, and then updating the extents in the current document. The NodeDocument finds its extents by looking at its first and last chapter's pasteboard rectangles.
virtual UINT32 GetNodeSize () const
 For finding the size of the node.
virtual void GetDebugDetails (StringBase *Str)
 For obtaining debug information about the Node.
virtual void PolyCopyNodeContents (NodeRenderable *pNodeCopy)
 Polymorphically copies the contents of this node to another.

Protected Member Functions

virtual NodeSimpleCopy ()
 This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes.
void CopyNodeContents (NodeDocument *NodeCopy)
 This method copies the node's contents to the node pointed to by NodeCopy.

Protected Attributes

DocCoord LowExtent
DocCoord HighExtent
BaseDocumentpParentDoc

Detailed Description

This class represents the root of a document tree. It contains the extents of the entire document as two DocCoords (LowExtent, HighExtent). LowExtent is the Coordinate position of the low corner of its first chapter whilst High Extent is the coordinate position of the high corner of its final chapter.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/4/93
See also:
NodeRenderablePaper

Definition at line 123 of file nodedoc.h.


Constructor & Destructor Documentation

NodeDocument::NodeDocument  ) 
 

This constructor creates a NodeDocument linked to no other nodes, with all status flags false, and NULL bounding and pasteboard rectangles.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/5/93
Parameters:
- [INPUTS]
[OUTPUTS] 
Returns:
-

Errors:

Definition at line 133 of file nodedoc.cpp.

00133                           : NodeRenderablePaper()
00134 {   
00135     pParentDoc = NULL;
00136 }                    

NodeDocument::NodeDocument Node ContextNode,
AttachNodeDirection  Direction,
BOOL  Locked = FALSE,
BOOL  Mangled = FALSE,
BOOL  Marked = FALSE,
BOOL  Selected = FALSE
 

This constructor initialises the node and links it to ContextNode in the direction specified by Direction. All neccesary tree links are updated.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/4/93
Parameters:
ContextNode,: Pointer to a node which this node is to be attached to. [INPUTS]
Direction:

Specifies the direction in which this node is to be attached to the ContextNode. The values this variable can take are as follows:

PREV : Attach node as a previous sibling of the context node NEXT : Attach node as a next sibling of the context node FIRSTCHILD: Attach node as the first child of the context node LASTCHILD : Attach node as a last child of the context node

The remaining inputs specify the status of the node:

Locked: Is node locked ? Mangled: Is node mangled ? Marked: Is node marked ? Selected: Is node selected ?

Parameters:
- [OUTPUTS]
Returns:
-

Errors: An assertion error will occur if ContextNode is NULL

Definition at line 184 of file nodedoc.cpp.

00189                                          :NodeRenderablePaper(ContextNode, Direction, Locked, 
00190                                                                 Mangled,Marked, Selected)
00191 {
00192     pParentDoc = NULL;
00193 }

NodeDocument::~NodeDocument  ) 
 

NodeDocument destructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/5/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: Notes: OK, so this does nothing. But it used to. I've just ripped out all the code again 3 months later...

Definition at line 214 of file nodedoc.cpp.

00215 {
00216 }


Member Function Documentation

void NodeDocument::CopyNodeContents NodeDocument NodeCopy  )  [protected]
 

This method copies the node's contents to the node pointed to by NodeCopy.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/6/93
Parameters:
[INPUTS] 
A copy of this node [OUTPUTS]
Returns:
-

Errors: An assertion failure will occur if NodeCopy is NULL

scope: protected

Definition at line 326 of file nodedoc.cpp.

00327 {                         
00328     ENSURE(NodeCopy != NULL, "Trying to copy a node's contents to a NULL node");  
00329     NodeRenderablePaper::CopyNodeContents(NodeCopy); 
00330     NodeCopy->LowExtent = LowExtent; 
00331     NodeCopy->HighExtent = HighExtent;         
00332 }

void NodeDocument::DescribeExtents DocCoord LoExtent,
DocCoord HiExtent
const
 

For finding the extents of the document.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/06/93
Parameters:
LoExtent,: The documents low extent i.e. the low corner of the final chapters [OUTPUTS] pasteboard rectangle. HiExtent: The documents high extent i.e. the high corner of the first chapters pasteboard rectangle.
Returns:
-

Errors: -

See also:
-

Definition at line 419 of file nodedoc.cpp.

00420 {
00421     *LoExtent = LowExtent; 
00422     *HiExtent = HighExtent;     
00423 }

void NodeDocument::GetDebugDetails StringBase Str  )  [virtual]
 

For obtaining debug information about the Node.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/9/93
Parameters:
- [INPUTS]
Str,: String giving debug info about the node [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from NodeRenderablePaper.

Definition at line 514 of file nodedoc.cpp.

00515 {          
00516 #ifdef _DEBUG
00517     NodeRenderablePaper::GetDebugDetails(Str); 
00518     String_256 TempStr; 
00519     TempStr._MakeMsg(TEXT("\r\nLowExtent = (#1%ld, #2%ld)\r\nHighExtent = (#3%ld, #4%ld)\r\n"), 
00520                      LowExtent.x, LowExtent.y, HighExtent.x, HighExtent.y); 
00521     (*Str)+=TempStr;
00522 #endif
00523 }   

UINT32 NodeDocument::GetNodeSize  )  const [virtual]
 

For finding the size of the node.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The size of the node in bytes
See also:
Node::GetSubtreeSize

Reimplemented from Node.

Definition at line 540 of file nodedoc.cpp.

00541 {     
00542     return (sizeof(NodeDocument)); 
00543 }  

BaseDocument* NodeDocument::GetParentDoc  )  [inline]
 

Definition at line 141 of file nodedoc.h.

00141 { return pParentDoc; };

DocCoord NodeDocument::HiExtent  )  const
 

For finding the high extent of the document.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The documents high extent, i.e. the high corner of the first chapters pasteboard rectangle.

Errors: -

See also:
-

Definition at line 397 of file nodedoc.cpp.

00398 { 
00399     return (HighExtent); 
00400 }                                   

BOOL NodeDocument::IsNodeDocument  )  const [virtual]
 

Find out which Document object a NodeDocument object is attached to. Tell the caller that this is a NodeDocument.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/02/95
Returns:
TRUE - this is a NodeDocument.

Reimplemented from Node.

Definition at line 271 of file nodedoc.cpp.

00272 {
00273     // Yes, it's a NodeDocument
00274     return TRUE;
00275 }

DocCoord NodeDocument::LoExtent  )  const
 

For finding the low extent of the document.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The documents low extent i.e. the low corner of the final chapters pasteboard rectangle.

Errors: -

See also:
-

Definition at line 375 of file nodedoc.cpp.

00376 {
00377     return (LowExtent); 
00378 }

void NodeDocument::PolyCopyNodeContents NodeRenderable pNodeCopy  )  [virtual]
 

Polymorphically copies the contents of this node to another.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/12/2003
Parameters:
- [OUTPUTS]
Returns:
Errors: An assertion failure will occur if NodeCopy is NULL Scope: protected

Reimplemented from NodeRenderablePaper.

Definition at line 347 of file nodedoc.cpp.

00348 {
00349     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
00350     ENSURE(IS_A(pNodeCopy, NodeDocument), "PolyCopyNodeContents given wrong dest node type");
00351 
00352     if (IS_A(pNodeCopy, NodeDocument))
00353         CopyNodeContents((NodeDocument*)pNodeCopy);
00354 }

void NodeDocument::SetExtents  ) 
 

For setting the document's extents in the NodeDocument, and then updating the extents in the current document. The NodeDocument finds its extents by looking at its first and last chapter's pasteboard rectangles.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/4/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
This method relies on the current document having been set.

Returns:
Errors: An assertion failure will occur if the document has no chapters

Definition at line 450 of file nodedoc.cpp.

00451 {   
00452     BOOL FoundChapter = FALSE; // Flag indicating if we have found a chapter beneath the doc
00453 
00454     Node* CurrentNode = FindFirstChild();   
00455 
00456     // Find the first chapter of a document
00457     while ((CurrentNode != NULL) && (!FoundChapter)) 
00458     { 
00459         if (CurrentNode->IsKindOf(CC_RUNTIME_CLASS(Chapter)))
00460         {
00461             FoundChapter = TRUE; 
00462             HighExtent = ((NodeRenderablePaper*)CurrentNode)->GetPasteboardRect(FALSE).HighCorner(); 
00463             // Low extent will change if we find another chapter 
00464             LowExtent =  ((NodeRenderablePaper*)CurrentNode)->GetPasteboardRect(FALSE).LowCorner(); 
00465         }     
00466         CurrentNode = CurrentNode->FindNext(); 
00467     }
00468     
00469     // A document should have at least one chapter when setting the extents
00470     ENSURE(FoundChapter,"Trying to set the extents of a document with no chapters"); 
00471     
00472     // Find the last chapter which may be the first
00473     while(CurrentNode != NULL)
00474     {
00475         if (CurrentNode->IsKindOf(CC_RUNTIME_CLASS(Chapter)))
00476         {
00477             LowExtent = ((NodeRenderablePaper*)CurrentNode)->GetPasteboardRect().LowCorner();  
00478         }     
00479         CurrentNode = CurrentNode->FindNext(); 
00480     }        
00481      
00482     // Inform the document that its extents have changed (only do it for 'real' documents,
00483     // and not e.g. the clipboard.
00484     if (IS_A(pParentDoc, Document))
00485         ((Document *) pParentDoc)->UpdateExtents(LowExtent, HighExtent); 
00486 }

void NodeDocument::SetParentDoc BaseDocument pNewDoc  ) 
 

Specify which Document object a NodeDocument object is attached to. This cannot be done again, unless this function is first called with NULL as the document to attachto.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/02/95
Parameters:
pNewDoc - the Document to attach to, or NULL if detaching. [INPUTS]
Returns:
Errors: Already attached to a document => ERROR2
See also:
NodeDocument::GetParentDoc

Definition at line 234 of file nodedoc.cpp.

00235 {
00236     if (pParentDoc != NULL)
00237     {
00238         // Error
00239         ERROR2RAW("NodeDocument is already attached to a Document!");
00240     }
00241     else
00242     {
00243         // Attach document.
00244         pParentDoc = pNewDoc;
00245     }
00246 }

Node * NodeDocument::SimpleCopy void   )  [protected, virtual]
 

This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/5/93
Parameters:
- [INPUTS]
[OUTPUTS] 
Returns:
A copy of the node, or NULL if memory runs out

Errors: If memory runs out when trying to copy, then ERROR is called with an out of memory error and the function returns NULL.

Scope: protected

Reimplemented from NodeRenderablePaper.

Definition at line 297 of file nodedoc.cpp.

00298 {
00299     NodeDocument* NodeCopy; 
00300     NodeCopy = new NodeDocument(); 
00301     ERRORIF(NodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL); 
00302     CopyNodeContents(NodeCopy);   
00303     return (NodeCopy);
00304 } 


Member Data Documentation

DocCoord NodeDocument::HighExtent [protected]
 

Definition at line 166 of file nodedoc.h.

DocCoord NodeDocument::LowExtent [protected]
 

Definition at line 164 of file nodedoc.h.

BaseDocument* NodeDocument::pParentDoc [protected]
 

Definition at line 168 of file nodedoc.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:56:50 2007 for Camelot by  doxygen 1.4.4