LoadDirect Class Reference

This class allows the caller to load a xara document in, process the data held inside and close the document again. You should derive your own class and override the OnLoadDocument() function. You'll be given a CCamDoc and Document* which can be used to access data within the doc. On return from OnLoadDocument, the document will be destroyed. More...

#include <lddirect.h>

Inheritance diagram for LoadDirect:

LoadBrushDirect LoadPrintMarks List of all members.

Public Member Functions

virtual ~LoadDirect ()
BOOL Execute (const TCHAR *lpszFilename)
 Execute the action of loading a named document, calling a subclass virtual function 'OnLoadDocument' and killing the loaded document. The selected document and view will be retained by this function.

Protected Member Functions

virtual BOOL OnLoadDocument (Document *pKernelDoc)
 Having successfully loaded the document, this function will be called to process the loaded data. The kernel document can be used to scan the document tree and perform any actions necessary. On return from this function the calling framework will delete the document and all its associated structures.

Private Member Functions

 CC_DECLARE_MEMDUMP (LoadDirect)
BOOL ExecuteHelper (CCamApp *pApp, const TCHAR *lpszFilename)
 Helps out by conditioning its parent. ie, by making the parent routine less complex in its condition paths.

Detailed Description

This class allows the caller to load a xara document in, process the data held inside and close the document again. You should derive your own class and override the OnLoadDocument() function. You'll be given a CCamDoc and Document* which can be used to access data within the doc. On return from OnLoadDocument, the document will be destroyed.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
06/08/96

Definition at line 120 of file lddirect.h.


Constructor & Destructor Documentation

virtual LoadDirect::~LoadDirect  )  [inline, virtual]
 

Definition at line 125 of file lddirect.h.

00125 {}


Member Function Documentation

LoadDirect::CC_DECLARE_MEMDUMP LoadDirect   )  [private]
 

BOOL LoadDirect::Execute const TCHAR lpszFilename  ) 
 

Execute the action of loading a named document, calling a subclass virtual function 'OnLoadDocument' and killing the loaded document. The selected document and view will be retained by this function.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
06/08/96
Parameters:
lpszFilename = the filename of the document to load. [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the document was loaded correctly FALSE if not either (1) theres no application present (unlikely) (2) unable to find the named file to load (3) unable to load the named file due to error (4) there was no kernel document resulting from the load (5) the users OnLoadDocument returned an error
Notes: This all works via the MFC. It is impossible to load and format a native document without such things as cam views, doc view, ruler, doc scaling objects, doc status objects etc. All format and rendering of objects requires this plethora of structures to be present. Hence we simulate an MFC OnLoadDocument without actually opening the created view in order to do this.

Definition at line 141 of file lddirect.cpp.

00142 {
00143     // find our main application object
00144     CCamApp *pApp = (CCamApp*)&AfxGetApp();
00145     if (!pApp)
00146         return FALSE;
00147 
00148     // Recode the currently selected document, view and spread
00149     Document    *OldSelDocument = Document::GetSelected();
00150     DocView     *OldSelView     = DocView::GetSelected();
00151     Spread      *OldSelSpread   = Document::GetSelectedSpread();
00152 
00153     // call the loader
00154     BOOL ok = ExecuteHelper(pApp, lpszFilename);
00155 
00156     // reset the previous selected state.
00157     if (OldSelDocument != NULL)
00158         Document::SetSelectedViewAndSpread(OldSelDocument,OldSelView,OldSelSpread);
00159 
00160     // return the user state.
00161     return ok;
00162 }

BOOL LoadDirect::ExecuteHelper CCamApp pApp,
const TCHAR lpszFilename
[private]
 

Helps out by conditioning its parent. ie, by making the parent routine less complex in its condition paths.

BOOL LoadDirect::ExecuteHelper(CCamApp* pApp, const TCHAR* lpszFilename)

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/08/96
Parameters:
lpszFilename = the filename of the document to load. [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the document was processed correctly FALSE if not

Definition at line 180 of file lddirect.cpp.

00181 {
00182     BOOL ok=TRUE;
00183 
00184     PORTNOTETRACE("other", "Disabled LoadDirect::ExecuteHelper");
00185 #ifndef EXCLUDE_FROM_XARALX
00186 
00187     // now call the supporting open document function
00188     CDocument* pLoadDirectDoc = pApp->OpenHiddenDocument(lpszFilename);
00189     if (pLoadDirectDoc==NULL)
00190         return FALSE;
00191 
00192     // assume its a cam doc we have created, and find its kernel doc
00193     CCamDoc* pCamDoc = (CCamDoc*)pLoadDirectDoc;
00194     Document* pRealDoc = pCamDoc->GetKernelDoc();
00195 
00196     // call the user function for document decoding
00197     ok = (pRealDoc!=NULL);
00198     ok = ok && (OnLoadDocument(pRealDoc));
00199 
00200     // finally toast the loaded document. 
00201     pCamDoc->SetModified(FALSE);
00202     pCamDoc->OnCloseDocument();
00203 #endif
00204 
00205     return ok;
00206 }

BOOL LoadDirect::OnLoadDocument Document pKernelDoc  )  [protected, virtual]
 

Having successfully loaded the document, this function will be called to process the loaded data. The kernel document can be used to scan the document tree and perform any actions necessary. On return from this function the calling framework will delete the document and all its associated structures.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
06/08/96
Parameters:
pKernelDoc = a pointer to the loaded kernel document [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the document was processed correctly FALSE if not

Reimplemented in LoadBrushDirect, and LoadPrintMarks.

Definition at line 230 of file lddirect.cpp.

00231 {
00232     ERROR3("The base class LoadDirect::OnLoadDocument() has been called, where's your derived class?");
00233     return FALSE;
00234 }


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