#include <basedoc.h>
Inheritance diagram for BaseDocument:
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. | |
ListRange * | GetEffectsList (UINT32 iMaxItems) |
Updates the effects list showing referred and missing effects. | |
BOOL | IsAHiddenDoc () const |
BOOL | IsNotAHiddenDoc () const |
ExportHint * | GetExportHint (void) |
Node * | GetFirstNode () 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. | |
DocComponent * | GetDocComponent (CCRuntimeClass *) |
Find a document component of a specific type in this document. | |
DocComponent * | GetDocComponentKindOf (CCRuntimeClass *) |
Find a kind of document component of in this document - it must be derived from the class described by pClass. | |
DocComponent * | EnumerateDocComponents (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);. | |
ColourContextArray * | 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. | |
ColourList * | 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). | |
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 |
ExportHint * | m_pExportHint |
Node * | TreeStart |
INT32 | NodesInTree |
ColourContextArray | DefaultColourContexts |
List * | DocComponents |
Private Member Functions | |
CC_DECLARE_DYNAMIC (BaseDocument) | |
Private Attributes | |
TAG | TagCounter |
Definition at line 149 of file basedoc.h.
|
BaseDocument constructor.
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 }
|
|
The BaseDocument destructor deletes all nodes in the document. It also deletes all the document components.
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 }
|
|
This function traverses the documents list of DocComponents and calls the virtual AbortComponentCopy method on them.
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 }
|
|
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.
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 }
|
|
|
|
Checks for missing effects, and warn the user.
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 }
|
|
Checks for substituted fonts, and if it finds any, in warns the user.
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 }
|
|
Checks for references to resources outside the document that may be dangling because the resources are not present.
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 }
|
|
Decrements the node counter in this Document. Called by the destructor of class Node.
Definition at line 393 of file basedoc.cpp. 00394 { 00395 NodesInTree--; 00396 }
|
|
Reimplemented in Document. |
|
Deletes all DocComponents and related junk from this document Used by the destructor, and also by the InternalClipboard document when it wipes the clipboard.
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 }
|
|
This function traverses the documents list of DocComponents and calls the virtual EndComponentCopy method on them.
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 }
|
|
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);.
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 }
|
|
|
|
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.
Definition at line 732 of file basedoc.cpp. 00733 { 00734 return(&DefaultColourContexts); 00735 }
|
|
Find a document component of a specific type in this document.
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 }
|
|
Find a kind of document component of in this document - it must be derived from the class described by pClass.
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 }
|
|
Updates the effects list showing referred and missing effects.
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 }
|
|
Definition at line 188 of file basedoc.h. 00188 { return(m_pExportHint); };
|
|
Get the first node in the document tree - this will always be a StartDocument node.
Definition at line 435 of file basedoc.cpp. 00436 { 00437 return TreeStart; 00438 }
|
|
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).
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 }
|
|
Adds one to the NodesInTree counter of this Document object. Called by the constructors of class Node.
Definition at line 374 of file basedoc.cpp. 00375 { 00376 NodesInTree++; 00377 }
|
|
Creates StartDocument, NodeDocument, and EndDocument nodes. Initialises the doc components.
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 }
|
|
Creates and initialises all doc components.
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 }
|
|
Definition at line 181 of file basedoc.h. 00181 { return IsHidden; };
|
|
Definition at line 184 of file basedoc.h. 00184 { return !IsHidden; };
|
|
Returns a new unique TAG for this Document.
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 }
|
|
Returns the nodes in the document's tree, ho hum.
Definition at line 412 of file basedoc.cpp. 00413 { 00414 return NodesInTree; 00415 }
|
|
Scans the entire tree, calling all nodes PostImport function. If any of functions returns FALSE the error is reported and the scan continues.
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 }
|
|
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.
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 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|