BaseDocument Class Reference

A simple base class document object. More...

#include <basedoc.h>

Inheritance diagram for BaseDocument:

ListItem CCObject SimpleCCObject Document BitmapExportDocument InternalClipboard List of all members.

Public Member Functions

 BaseDocument (BOOL fHide=TRUE)
 BaseDocument constructor.
virtual ~BaseDocument ()
 The BaseDocument destructor deletes all nodes in the document. It also deletes all the document components.
BOOL Init ()
 Creates StartDocument, NodeDocument, and EndDocument nodes. Initialises the doc components.
BOOL FixColourRefsAfterCopy (BaseDocument *SourceDocument)
void PostImport ()
 Scans the entire tree, calling all nodes PostImport function. If any of functions returns FALSE the error is reported and the scan continues.
BOOL CheckReferences ()
 Checks for references to resources outside the document that may be dangling because the resources are not present.
BOOL CheckFontSubstitution ()
 Checks for substituted fonts, and if it finds any, in warns the user.
BOOL CheckEffects ()
 Checks for missing effects, and warn the user.
ListRangeGetEffectsList (UINT32 iMaxItems)
 Updates the effects list showing referred and missing effects.
BOOL IsAHiddenDoc () const
BOOL IsNotAHiddenDoc () const
ExportHintGetExportHint (void)
NodeGetFirstNode () const
 Get the first node in the document tree - this will always be a StartDocument node.
void DeleteContents ()
TAG NewTag ()
 Returns a new unique TAG for this Document.
void IncNodeCount ()
 Adds one to the NodesInTree counter of this Document object. Called by the constructors of class Node.
void DecNodeCount ()
 Decrements the node counter in this Document. Called by the destructor of class Node.
INT32 NodesInDocument () const
 Returns the nodes in the document's tree, ho hum.
BOOL InitDocComponents (void)
 Creates and initialises all doc components.
void DestroyDocComponents (void)
 Deletes all DocComponents and related junk from this document Used by the destructor, and also by the InternalClipboard document when it wipes the clipboard.
void AddDocComponent (DocComponent *)
 Add the given document component to the document - no check is made to see if such a component is already in the document - the caller should ensure that they do not overwrite the existing component.
DocComponentGetDocComponent (CCRuntimeClass *)
 Find a document component of a specific type in this document.
DocComponentGetDocComponentKindOf (CCRuntimeClass *)
 Find a kind of document component of in this document - it must be derived from the class described by pClass.
DocComponentEnumerateDocComponents (DocComponent *)
 Allow the caller to examine/use all the document components attached to this document.. pContext should be NULL for the first call, which will return the first document component. After that, the returned pointer should be passed back in to this function, which will return the next one, and so on. For example: MonoOn DocComponent *pDocComp = NULL; do { pDocComp = pDoc->EnumerateDocComponents(pDocComp);.
ColourContextArrayGetDefaultColourContexts (void)
 Gives access to the Documents array of default colour contexts This is used internally by the DocColour system, and I shouldn't think it will be of much interest to anyone else.
ColourListGetIndexedColours (void)
 Returns a pointer to a list of the IndexedColours available to the user within this document. Scope: Private (intended only for colour manager to access).
virtual BOOL StartComponentCopy ()
 This function traverses the documents list of DocComponents and calls the virtual StartComponentCopy method on them. It calls AbortComponent copy on all DocComponents if we fail.
virtual BOOL EndComponentCopy ()
 This function traverses the documents list of DocComponents and calls the virtual EndComponentCopy method on them.
virtual void AbortComponentCopy ()
 This function traverses the documents list of DocComponents and calls the virtual AbortComponentCopy method on them.

Protected Attributes

BOOL IsHidden
ExportHintm_pExportHint
NodeTreeStart
INT32 NodesInTree
ColourContextArray DefaultColourContexts
ListDocComponents

Private Member Functions

 CC_DECLARE_DYNAMIC (BaseDocument)

Private Attributes

TAG TagCounter

Detailed Description

A simple base class document object.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/07/94
Returns:
Errors: -

Definition at line 149 of file basedoc.h.


Constructor & Destructor Documentation

BaseDocument::BaseDocument BOOL  fHide = TRUE  ) 
 

BaseDocument constructor.

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

Errors: -

See also:
-

Definition at line 153 of file basedoc.cpp.

00154   : IsHidden(fHide),
00155     m_pExportHint(NULL),
00156     TreeStart(0),
00157     DocComponents(0),
00158     TagCounter(1)
00159 {
00160     // Empty.
00161 } 

BaseDocument::~BaseDocument  )  [virtual]
 

The BaseDocument destructor deletes all nodes in the document. It also deletes all the document components.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94

Definition at line 176 of file basedoc.cpp.

00177 {
00178     // Destroy the tree if it exists.  This routine deletes all nodes to the right of
00179     // the StartDocument node.  This is done by continually deleting the node to the
00180     // right (which shuffles all the others left one) until there are no more nodes.
00181     // Then the StartDocument node itself is deleted.
00182     if (TreeStart != NULL)
00183     {
00184         for (Node* pn = TreeStart->FindNext(); pn != NULL; pn = TreeStart->FindNext())
00185         {
00186             // Delete the node's children then delete the node.  The TreeStart
00187             // variable will be updated to point to the new first node.
00188             pn->CascadeDelete();
00189             delete pn;
00190         }
00191         // Tree has only one node left - waste it.
00192         delete TreeStart;
00193         TreeStart = NULL;
00194     }
00195 
00196     // The SelRange might still contain cached indexed colours. We must delete these
00197     // before destroying the DocComponents.
00198     SelRange* Sel = GetApplication()->FindSelection();
00199     if (Sel) 
00200         Sel->AttrsHaveChanged(); 
00201 
00202     // Destroy doc components (colours, etc)
00203     // (this must be left until after all possible things in the document that could
00204     // contain references to components (such as IndexedColours) have been deleted)
00205     DestroyDocComponents();
00206 
00207     if (m_pExportHint)
00208     {
00209         delete m_pExportHint;
00210         m_pExportHint = NULL;
00211     }
00212 }


Member Function Documentation

void BaseDocument::AbortComponentCopy  )  [virtual]
 

This function traverses the documents list of DocComponents and calls the virtual AbortComponentCopy method on them.

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

Errors: -

See also:
DocComponent::AbortComponentCopy

Definition at line 670 of file basedoc.cpp.

00671 {
00672      DocComponent* Current = (DocComponent*) DocComponents->GetHead();
00673      DocComponent* Next; 
00674      while (Current != NULL)
00675      {
00676         Next = (DocComponent*) DocComponents->GetNext(Current); 
00677         Current->AbortComponentCopy(); 
00678         Current = Next; 
00679      }  
00680 
00681 }  

void BaseDocument::AddDocComponent DocComponent pComponent  ) 
 

Add the given document component to the document - no check is made to see if such a component is already in the document - the caller should ensure that they do not overwrite the existing component.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/08/94
Parameters:
pComponent - the document component to add. [INPUTS]
Returns:
Errors: ENSURE of no document component list exists in the document.
See also:
BaseDocument::GetDocComponent; BaseDocument::GetDocComponentKindOf

Definition at line 457 of file basedoc.cpp.

00458 {
00459     // Basic sanity/safety checks.
00460     ENSURE(DocComponents != NULL, "No document component list in the document!");
00461     if (DocComponents == NULL)
00462         return;
00463 
00464     // Just add the component to the document's list.
00465     DocComponents->AddTail(pComponent);
00466 }

BaseDocument::CC_DECLARE_DYNAMIC BaseDocument   )  [private]
 

BOOL BaseDocument::CheckEffects  ) 
 

Checks for missing effects, and warn the user.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/01/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for Success/Failure

Errors: -

See also:
-

Definition at line 871 of file basedoc.cpp.

00872 {
00873     ListRange* pEffectList = GetEffectsList(500000);    // Arbitrary large number
00874     BOOL bFound = TRUE;
00875 
00876     if (pEffectList)
00877     {
00878         Node* pNode = pEffectList->FindFirst();
00879         while (pNode)
00880         {
00881             if (pNode->IsBitmapEffect())
00882             {
00883                 NodeBitmapEffect* pEffect = (NodeBitmapEffect*)pNode;
00884 
00885                 if (!pEffect->IsLockedEffect())
00886                 {
00887 
00888 PORTNOTE("other","Removed XPEHost usage")
00889 #ifndef EXCLUDE_FROM_XARALX
00890                     // Live effects need to regenerate their bitmaps so we must
00891                     // test whether the handler is present and warn the user if not
00892                     String_64 strDisplayName;
00893                     bFound = XPEHost::GetEffectDetails(pEffect->GetPostProcessorID(), &strDisplayName);
00894                     if (!bFound)
00895                     {
00896                         break;
00897                     }
00898 #endif
00899                 }
00900             }
00901 
00902             pNode = pEffectList->FindNext(pNode);
00903         }
00904 
00905         delete pEffectList;
00906     }
00907 
00908     if (!bFound)
00909     {
00910         Operation::SetQuickRender(TRUE);    // Prevent cacheing while this warning is on screen
00911         InformWarning(_R(IDS_FINFO_MISSINGEFFECTS), _R(IDS_CONTINUE));
00912         Operation::SetQuickRender(FALSE);
00913     }
00914 
00915     return TRUE;
00916 }

BOOL BaseDocument::CheckFontSubstitution  ) 
 

Checks for substituted fonts, and if it finds any, in warns the user.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/7/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for Success/Failure
(This code has been separated from PostImport() so it can be called independantly)

Returns:
Errors: -
See also:
-

Definition at line 812 of file basedoc.cpp.

00813 {
00814     // check whether any fonts have been substituted
00815     BOOL  FontSubstitution = FALSE;
00816     FontList DocFonts;
00817     DocFonts.Build((Document*)this);
00818     FontListItem* FontItem = DocFonts.GetFirstItem();
00819     if (FontItem!=NULL)
00820     {
00821         // fill up the list
00822         while (FontItem)
00823         {
00824             // get the name
00825             String_64 Name = FontItem->GetFontName();
00826             FontClass Class = FontItem->GetFontClass();
00827             if (FONTMANAGER->IsFontReplaced(&Name, Class))
00828             {           
00829                 FontSubstitution=TRUE;
00830                 break;
00831             }
00832             FontItem = DocFonts.GetNextItem(FontItem);
00833         }
00834     }
00835 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00836     if (FontSubstitution)
00837     {
00838 #if (_OLE_VER >= 0x200)
00839         // Only warn about this if the document is visible to the user.
00840         CCamDoc* pOilDoc = 0;
00841         if (IS_KIND_OF(Document)) pOilDoc = ((Document*) this)->GetOilDoc();
00842         if (pOilDoc && pOilDoc->IsVisible())
00843 #endif
00844             // Inform the user that some fonts are not installed
00845             Operation::SetQuickRender(TRUE);    // Prevent cacheing while this warning is on screen
00846             InformWarning(_R(IDS_FONTSSUBSTITUTED), _R(IDS_CONTINUE));
00847             Operation::SetQuickRender(FALSE);
00848     }
00849 #endif
00850 
00851     return TRUE;
00852 }

BOOL BaseDocument::CheckReferences  ) 
 

Checks for references to resources outside the document that may be dangling because the resources are not present.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/01/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for Success/Failure

Errors: -

See also:
-

Definition at line 754 of file basedoc.cpp.

00755 {
00756     // URGH! This should be implemented in Document, not BaseDocument!
00757     CCamDoc* pOilDoc = NULL;
00758     if (IS_KIND_OF(Document))
00759         pOilDoc = ((Document*) this)->GetOilDoc();
00760     if (pOilDoc && pOilDoc->IsVisible())
00761     {
00762         // We don't want to show the user a sequence of boxes so collapse all reference
00763         // checks into a single warning...
00764         // (Argh but it's too much trouble at the mo...)
00765         PORTNOTETRACE("text","BaseDocument::CheckReferences - removed CheckFontSubstitution call");
00766 #ifndef EXCLUDE_FROM_XARALX
00767         BOOL bFontsOK   = CheckFontSubstitution();
00768 #endif
00769         BOOL bFontsOK   = true;
00770         BOOL bEffectsOK = CheckEffects();
00771 
00772 #ifndef EXCLUDE_FROM_XARALX
00773         BOOL bFontsOK   = CheckFontSubstitution(FALSE);
00774         BOOL bEffectsOK = CheckEffects(FALSE);
00775 
00776         if (!bFontsOK || !bEffectsOK)
00777         {
00778             ErrorInfo warning;
00779             String_256 strWarning;
00780             strWarning.MakeMsg(_R(IDS_MISSINGREFERENCES), strFontsWarning, strEffectsWarning);
00781             warning.ErrorMsg = strWarning;
00782             warning.Title = String(_R(IDS_MISSINGREFS_TITLE));
00783             warning.Button[0] = _R(IDB_CONTINUE);
00784             InformWarning(warning);
00785         }
00786 #endif
00787         return (bFontsOK && bEffectsOK);
00788     }
00789 
00790     return FALSE;
00791 }

void BaseDocument::DecNodeCount  ) 
 

Decrements the node counter in this Document. Called by the destructor of class Node.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/93
See also:
BaseDocument::IncNodeCount; BaseDocument::NodesInDocument

Definition at line 393 of file basedoc.cpp.

00394 {
00395     NodesInTree--;
00396 }

void BaseDocument::DeleteContents  ) 
 

Reimplemented in Document.

void BaseDocument::DestroyDocComponents void   ) 
 

Deletes all DocComponents and related junk from this document Used by the destructor, and also by the InternalClipboard document when it wipes the clipboard.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/4/95
See also:
BaseDocument::InitDocComponents

Definition at line 230 of file basedoc.cpp.

00231 {
00232     // And delete all the document components
00233     if (DocComponents != NULL)
00234     {       
00235         DocComponents->DeleteAll();
00236         delete DocComponents;
00237         DocComponents = NULL;
00238     }
00239 }

BOOL BaseDocument::EndComponentCopy  )  [virtual]
 

This function traverses the documents list of DocComponents and calls the virtual EndComponentCopy method on them.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
FALSE if a call to DocComponent::EndComponentCopy fails. In this situation Abort component copy is called.

Errors: -

See also:
DocComponent::EndComponentCopy

Definition at line 637 of file basedoc.cpp.

00638 {
00639      DocComponent* Current = (DocComponent*) DocComponents->GetHead();
00640      DocComponent* Next; 
00641      while (Current != NULL)
00642      {
00643         Next = (DocComponent*) DocComponents->GetNext(Current); 
00644         if (!Current->EndComponentCopy())
00645         {
00646             AbortComponentCopy(); 
00647             return FALSE; 
00648         } 
00649         Current = Next; 
00650      }  
00651      return TRUE; 
00652 } 

DocComponent * BaseDocument::EnumerateDocComponents DocComponent pContext  ) 
 

Allow the caller to examine/use all the document components attached to this document.. pContext should be NULL for the first call, which will return the first document component. After that, the returned pointer should be passed back in to this function, which will return the next one, and so on. For example: MonoOn DocComponent *pDocComp = NULL; do { pDocComp = pDoc->EnumerateDocComponents(pDocComp);.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/08/94
Parameters:
pContext,: NULL => Get the first document component [INPUTS] non-NULL => Get the next document component after the one pointed to by pContext.
Returns:
Pointer to the required document component.
Do something groovy with pDocComp... } while (pDocComp != NULL); MonoOff

See also:
DocComponent

Definition at line 570 of file basedoc.cpp.

00571 {
00572     if (pContext == NULL)
00573     {
00574         // Return the first item in the list...
00575         return (DocComponent *) (DocComponents->GetHead());
00576     }
00577     else
00578     {
00579         // Return the next document component...
00580         return (DocComponent *) (DocComponents->GetNext(pContext));
00581     }
00582 }

BOOL BaseDocument::FixColourRefsAfterCopy BaseDocument SourceDocument  ) 
 

ColourContextArray * BaseDocument::GetDefaultColourContexts void   ) 
 

Gives access to the Documents array of default colour contexts This is used internally by the DocColour system, and I shouldn't think it will be of much interest to anyone else.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/04/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A pointer to this documents array of default colour contexts.

Errors: -

See also:
ColourContext

Definition at line 732 of file basedoc.cpp.

00733 {
00734     return(&DefaultColourContexts);
00735 }

DocComponent * BaseDocument::GetDocComponent CCRuntimeClass pClass  ) 
 

Find a document component of a specific type in this document.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/08/94
Parameters:
pClass - the class of component to look for. [INPUTS]
Returns:
A pointer to the required component, or NULL if no match was found.
See also:
BaseDocument::GetDocComponentKindOf; DocComponent

Definition at line 484 of file basedoc.cpp.

00485 {
00486     DocComponent *pItem = (DocComponent *) DocComponents->GetHead();
00487 
00488     while (pItem != NULL)
00489     {
00490         // Is this an exact match to the given runtime class?
00491         if (pItem->GetRuntimeClass() == pClass)
00492             // Yes - return to caller.
00493             return pItem;
00494 
00495         // Try the next component
00496         pItem = (DocComponent *) DocComponents->GetNext(pItem);
00497     }
00498 
00499     // Didn't find the component - report this to caller
00500     return NULL;
00501 }

DocComponent * BaseDocument::GetDocComponentKindOf CCRuntimeClass pClass  ) 
 

Find a kind of document component of in this document - it must be derived from the class described by pClass.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/08/94
Parameters:
pClass - the base class of the component to look for. [INPUTS]
Returns:
A pointer to the required component, or NULL if no match was found.
See also:
BaseDocument::GetDocComponent; DocComponent

Definition at line 518 of file basedoc.cpp.

00519 {
00520     DocComponent *pItem = (DocComponent *) DocComponents->GetHead();
00521 
00522     while (pItem != NULL)
00523     {
00524         // Is this derived from the base class specified?
00525         if (pItem->IsKindOf(pClass))
00526             // Yes - return to caller.
00527             return pItem;
00528 
00529         // Try the next component
00530         pItem = (DocComponent *) DocComponents->GetNext(pItem);
00531     }
00532 
00533     // Didn't find the component - report this to caller
00534     return NULL;
00535 }

ListRange * BaseDocument::GetEffectsList UINT32  iMaxItems  ) 
 

Updates the effects list showing referred and missing effects.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/01/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
True if completed ok, False otherwise.

Errors: -

See also:
SetDocInfo; FontDropDown; DocumentFontDropDown;

Definition at line 936 of file basedoc.cpp.

00937 {
00938     // Make a list of all unique effects used in the doc
00939     // Add each list item to the listbox, marking it if the referred effect can not
00940     // be found in the installed effect list
00941 
00942     ListRange* pEffectList = new ListRange();
00943     Node* pNode = GetFirstNode();
00944     UINT32 i = 0;
00945     while (pNode && i<iMaxItems)
00946     {
00947         if (pNode->IsBitmapEffect())
00948         {
00949             NodeBitmapEffect* pEffect = (NodeBitmapEffect*)pNode;
00950 
00951             // Search for this type of effect in the list already
00952             Node* pListNode = pEffectList->FindFirst();
00953             while (pListNode)
00954             {
00955                 if (((NodeBitmapEffect*)pListNode)->GetPostProcessorID() == pEffect->GetPostProcessorID())
00956                     break;
00957 
00958                 pListNode = pEffectList->FindNext(pListNode);
00959             }
00960 
00961             // If this effect type is not already in the list, add it
00962             if (pListNode==NULL)
00963             {
00964                 pEffectList->AddNode(pNode);
00965                 i++;
00966             }
00967         }
00968 
00969         pNode = pNode->FindNextDepthFirst(NULL);
00970     }
00971 
00972     return pEffectList;
00973 }

ExportHint* BaseDocument::GetExportHint void   )  [inline]
 

Definition at line 188 of file basedoc.h.

00188 { return(m_pExportHint); };

Node * BaseDocument::GetFirstNode  )  const
 

Get the first node in the document tree - this will always be a StartDocument node.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/5/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
First node in the tree.
(* Moved from Document to BaseDocument by SimonM *)

Returns:
Errors: None.

Definition at line 435 of file basedoc.cpp.

00436 {
00437     return TreeStart;
00438 }

ColourList * BaseDocument::GetIndexedColours void   ) 
 

Returns a pointer to a list of the IndexedColours available to the user within this document. Scope: Private (intended only for colour manager to access).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
05/05/94 (Moved here from NodeDocument 1/8/94)
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A pointer to this documents list of IndexedColours

Errors: -

See also:
class IndexedColour; class ColourList

Definition at line 701 of file basedoc.cpp.

00702 {
00703     // Get the colour list component
00704     ColourListComponent *pComponent = 
00705         (ColourListComponent *) GetDocComponent(CC_RUNTIME_CLASS(ColourListComponent));
00706 
00707     if(pComponent == NULL)
00708         return NULL;
00709 
00710     // Extract the colour list
00711     return pComponent->GetColourList();
00712 }

void BaseDocument::IncNodeCount  ) 
 

Adds one to the NodesInTree counter of this Document object. Called by the constructors of class Node.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/02/95
See also:
BaseDocument::DecCurrentNodeCount; BaseDocument::NodesInDocument

Definition at line 374 of file basedoc.cpp.

00375 {
00376     NodesInTree++;
00377 }

BOOL BaseDocument::Init void   ) 
 

Creates StartDocument, NodeDocument, and EndDocument nodes. Initialises the doc components.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94

Reimplemented from SimpleCCObject.

Definition at line 254 of file basedoc.cpp.

00255 {  
00256     NodeDocument   *Doc;
00257     EndDocument    *End;
00258 
00259     // Get a new StartDocument node.
00260     TreeStart = new StartDocument;
00261     if (TreeStart == NULL)
00262         goto NoMemory;
00263 
00264     // Add a NodeDocument
00265     Doc = new NodeDocument(TreeStart, NEXT); 
00266     if (Doc == NULL)
00267         goto NoMemory;
00268 
00269     // Tell the NodeDocument which document it is attached to.
00270     Doc->SetParentDoc(this);
00271         
00272     // Join a new EndDocument node after it in the tree.
00273     End = new EndDocument(Doc, NEXT);
00274     if (End == NULL)
00275         goto NoMemory;
00276 
00277     if (!InitDocComponents())
00278         goto NoMemory;
00279 
00280     // We don't really mind if this fails but check it anyway
00281     m_pExportHint = new ExportHint;
00282     if (m_pExportHint == NULL)
00283         goto NoMemory;
00284 
00285     // All is well
00286     return TRUE;
00287 
00288 NoMemory:
00289 
00290     // Failed to initialise due to running out of memory.
00291     if (TreeStart != NULL)
00292     {
00293         TreeStart->CascadeDelete();
00294         delete TreeStart;
00295         TreeStart = NULL; 
00296     }
00297 
00298     return FALSE; 
00299 }

BOOL BaseDocument::InitDocComponents void   ) 
 

Creates and initialises all doc components.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/4/95
Returns:
TRUE if it succeeds
This is a subroutine called by Init(), and is also used by the InternalClipboard document when clearing the clipboard in order to wipe all contents of the document.

See also:
BaseDocument::DestroyDocComponents

Definition at line 323 of file basedoc.cpp.

00324 {
00325     // Get a new set of document components for this document...
00326     DocComponents = new List;
00327     if (DocComponents == NULL)
00328         return(FALSE);
00329 
00330     // Get each of the registered document components to add themselves to the document.
00331     if (!GetApplication()->ApplyDocComponents(this))
00332         return(FALSE);
00333 
00334     return(TRUE);
00335 }

BOOL BaseDocument::IsAHiddenDoc  )  const [inline]
 

Definition at line 181 of file basedoc.h.

00181 { return IsHidden; };

BOOL BaseDocument::IsNotAHiddenDoc  )  const [inline]
 

Definition at line 184 of file basedoc.h.

00184 { return !IsHidden; };

TAG BaseDocument::NewTag  ) 
 

Returns a new unique TAG for this Document.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/5/93

Definition at line 349 of file basedoc.cpp.

00350 {
00351     // Increment and check for loop around.
00352     if (TagCounter == TAG_LAST_VALID)
00353         TagCounter = 1; // NB 0 is not used (not sure why - Tim).
00354     else
00355         TagCounter++;
00356 
00357     // Return a unique tag      
00358     return TagCounter;
00359 }

INT32 BaseDocument::NodesInDocument  )  const
 

Returns the nodes in the document's tree, ho hum.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/93
Returns:
The number of nodes in this Document's tree.
See also:
BaseDocument::IncNodeCount; BaseDocument::DecNodeCount

Definition at line 412 of file basedoc.cpp.

00413 {
00414     return NodesInTree;
00415 }

void BaseDocument::PostImport  ) 
 

Scans the entire tree, calling all nodes PostImport function. If any of functions returns FALSE the error is reported and the scan continues.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
04/04/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for Success/Failure (you what? Surely some mistake? Sack the programmer)

Errors: -

See also:
-

Definition at line 992 of file basedoc.cpp.

00993 {
00994 #ifdef RALPH
00995     // We don't want to be rendering at the same time as doing this, because we get
00996     // blobby text problems - fun, but bad !
00997     RalphCriticalSection RalphCS;
00998 #endif
00999 
01000     BeginSlowJob();
01001 
01002     // Get a pointer to the StartDocument node
01003     Node* pStartNode = GetFirstNode();
01004     ERROR3IF(pStartNode == NULL, "(BaseDocument::PostImport) TreeStart was NULL");
01005     
01006     // Get a pointer to the NodeDocument node
01007     if (pStartNode != NULL)
01008     {
01009         pStartNode = pStartNode->FindNext();
01010         ERROR3IF(pStartNode == NULL, "(BaseDocument::PostImport) No NodeDocument after StartDocument");
01011     }
01012 
01013     // Scan through the tree, calling all PostImport functions
01014     if (pStartNode != NULL)
01015     {
01016         Node* pCurrentNode = pStartNode->FindFirstDepthFirst();
01017 
01018         while (pCurrentNode != NULL)
01019         {
01020             if (!pCurrentNode->PostImport())
01021             {
01022                 InformError();
01023             }
01024             pCurrentNode = pCurrentNode->FindNextDepthFirst(pStartNode);
01025         }
01026     }
01027     
01028     // check whether any fonts have been substituted, and warn the user if they have
01029 //  CheckFontSubstitution();
01030     CheckReferences();
01031 
01032     EndSlowJob();
01033 }

BOOL BaseDocument::StartComponentCopy  )  [virtual]
 

This function traverses the documents list of DocComponents and calls the virtual StartComponentCopy method on them. It calls AbortComponent copy on all DocComponents if we fail.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
FALSE if a call to DocComponent::StartComponentCopy fails. In this case AbortComponentCopy gets called.

Errors: -

See also:
DocComponent::StartComponentCopy

Definition at line 602 of file basedoc.cpp.

00603 {
00604      DocComponent* Current = (DocComponent*) DocComponents->GetHead();
00605      DocComponent* Next; 
00606      while (Current != NULL)
00607      {
00608         Next = (DocComponent*) DocComponents->GetNext(Current); 
00609         if (!Current->StartComponentCopy())
00610         {
00611             AbortComponentCopy(); 
00612             return FALSE; 
00613         } 
00614         Current = Next; 
00615      }
00616      return TRUE;   
00617 }


Member Data Documentation

ColourContextArray BaseDocument::DefaultColourContexts [protected]
 

Definition at line 232 of file basedoc.h.

List* BaseDocument::DocComponents [protected]
 

Definition at line 243 of file basedoc.h.

BOOL BaseDocument::IsHidden [protected]
 

Definition at line 178 of file basedoc.h.

ExportHint* BaseDocument::m_pExportHint [protected]
 

Definition at line 188 of file basedoc.h.

INT32 BaseDocument::NodesInTree [protected]
 

Definition at line 200 of file basedoc.h.

TAG BaseDocument::TagCounter [private]
 

Definition at line 246 of file basedoc.h.

Node* BaseDocument::TreeStart [protected]
 

Definition at line 199 of file basedoc.h.


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