CCamDocTemplate Class Reference

Allows the customisation of the process MFC uses to create, load, and associate its view and document classes. More...

#include <camdoctp.h>

List of all members.

Public Types

enum  Confidence {
  noAttempt, maybeAttemptForeign, maybeAttemptNative, yesAttemptForeign,
  yesAttemptNative, yesAlreadyOpen
}

Public Member Functions

 CCamDocTemplate (wxDocManager *pManager, const wxString &descr, const wxString &filter, const wxString &dir, const wxString &ext, const wxString &docTypeName, const wxString &viewTypeName, wxClassInfo *docClassInfo, wxClassInfo *viewClassInfo)
virtual Confidence MatchDocType (LPCTSTR lpszPathName, wxDocument *&rpDocMatch)
 This function has been overiden from its MFC version. It is actually identical apart from the bit that checks to see if the document is already open. The MFC version of the function goes and looks at the files involved by calling AfxComparePaths(), but we just compare the paths. This stops the floppy drive from being accessed all the time if you have a document opened from a floppy drive (it also stops network problems if the conection to an open document goes away). I am not too sure what all the params mean.


Detailed Description

Allows the customisation of the process MFC uses to create, load, and associate its view and document classes.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
sometime in '93 (sorry!)
See also:
CCamDoc; CCamMDIChild; CCamView

Definition at line 120 of file camdoctp.h.


Member Enumeration Documentation

enum CCamDocTemplate::Confidence
 

Enumerator:
noAttempt 
maybeAttemptForeign 
maybeAttemptNative 
yesAttemptForeign 
yesAttemptNative 
yesAlreadyOpen 

Definition at line 125 of file camdoctp.h.

00126     {
00127         noAttempt,
00128         maybeAttemptForeign,
00129         maybeAttemptNative,
00130         yesAttemptForeign,
00131         yesAttemptNative,
00132         yesAlreadyOpen
00133     };


Constructor & Destructor Documentation

CCamDocTemplate::CCamDocTemplate wxDocManager *  pManager,
const wxString &  descr,
const wxString &  filter,
const wxString &  dir,
const wxString &  ext,
const wxString &  docTypeName,
const wxString &  viewTypeName,
wxClassInfo *  docClassInfo,
wxClassInfo *  viewClassInfo
 

Definition at line 120 of file camdoctp.cpp.

00123  : wxDocTemplate( pManager, descr, filter, dir, ext, docTypeName, viewTypeName, docClassInfo, viewClassInfo )
00124 {
00125 #if 0
00126     if (m_hMenu != NULL)
00127     {
00128         ::DestroyMenu(m_hMenuShared);
00129         m_hMenuShared = m_hMenu;
00130     }
00131         
00132     if (m_hAccelTable != NULL)
00133         m_hAccelTable = m_hAccelTable;
00134     
00135     #ifdef _DEBUG
00136         // warnings about missing components (don't bother with accelerators)
00137         if (m_hMenuShared == NULL)
00138             TRACE1("Warning: no shared menu for document template #%d\n", nIDResource);
00139     #endif //_DEBUG
00140 
00141 #if _MFC_VER >= 0x400
00142     // Strangeness we need to do here to create the DocManager as our derived version instead
00143     // of MFC's version, so we can over-ride DoPromptFilename() - see mfccopy.cpp/h. (Tim)
00144     // This code fragment taken from mfc\src\doctempl.cpp (MFC4).
00145 
00146     // Er, Richard here... Defining _AFXDLL and using the MD version of MFC seems not to
00147     // contain this bStaticInit stuff. This needs looking into...
00148     if (CDocManager::bStaticInit)
00149     {
00150         if (CDocManager::pStaticDocManager == NULL)
00151             CDocManager::pStaticDocManager = new CamelotDocManager;
00152     }
00153 #endif // _MFC_VER >= 0x400
00154 #endif
00155 }


Member Function Documentation

CCamDocTemplate::Confidence CCamDocTemplate::MatchDocType LPCTSTR  lpszPathName,
wxDocument *&  rpDocMatch
[virtual]
 

This function has been overiden from its MFC version. It is actually identical apart from the bit that checks to see if the document is already open. The MFC version of the function goes and looks at the files involved by calling AfxComparePaths(), but we just compare the paths. This stops the floppy drive from being accessed all the time if you have a document opened from a floppy drive (it also stops network problems if the conection to an open document goes away). I am not too sure what all the params mean.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/5/95

Definition at line 176 of file camdoctp.cpp.

00181 {
00182     ASSERT(lpszPathName != NULL);
00183     rpDocMatch = NULL;
00184 
00185     // go through all documents
00186     wxList&             listDocuments = GetDocumentManager()->GetDocuments();
00187     wxNode*             pNode = listDocuments.GetFirst();
00188     while (pNode != NULL)
00189     {
00190         // Get the next document
00191         CCamDoc* pDoc = (CCamDoc*)pNode->GetData();
00192 
00193     #if (_OLE_VER >= 0x200)
00194         // Don't consider embedded or hidden docs.
00195         if (pDoc->IsEmbedded() || pDoc->GetKernelDoc()->IsAHiddenDoc()) continue;
00196     #endif
00197 
00198         // Find out the names of the old and new documents
00199         wxString OldDocName  = pDoc->GetFilename();
00200         wxString OrigDocName = wxString((LPCTSTR) pDoc->GetOriginalPath());
00201         wxString NewDocName  = wxString(lpszPathName);
00202         OldDocName.MakeLower();
00203         OrigDocName.MakeLower();
00204         NewDocName.MakeLower();
00205 
00206         // Test if the docs refer to the same existing .ART file or if the two docs are based
00207         // on the same existing non-.ART file.
00208         BOOL fSameArtFiles = (OldDocName == NewDocName);
00209         BOOL fSameNonArtFiles = (OldDocName.IsEmpty() && OrigDocName == NewDocName);
00210 
00211         // see if they are the same
00212         if (fSameArtFiles || fSameNonArtFiles)
00213         {
00214             // already open
00215             TRACEUSER("JustinF", _T("File %s is already open\n"),  (LPCTSTR) lpszPathName);
00216             rpDocMatch = pDoc;
00217             return yesAlreadyOpen;
00218         }
00219 
00220         pNode = pNode->GetNext();
00221     }
00222 
00223     // see if it matches our default suffix
00224     if( !m_defaultExt.IsEmpty() )
00225     {
00226         // see if extension matches
00227         LPCTSTR         lpszDot = camStrrchr( lpszPathName, _T('.') );
00228         if( NULL != lpszDot && 
00229             0 == camStricmp( lpszDot + 1, m_defaultExt ) )
00230             return yesAttemptNative; // extension matches, looks like ours
00231     }
00232 
00233     // otherwise we will guess it may work
00234     return yesAttemptForeign;
00235 }


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