camdoctp.cpp

Go to the documentation of this file.
00001 // $Id: wxOil/camdoctp.cpp, 1, 01-Jan-2006, Anonymous $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 This license does not apply to the clipart within the directory
00067 filters/clipart/OpenClipart. These have kindly been put into the
00068 public domain by their authors. See http://www.openclipart.org/
00069 
00070 
00071 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00072 ----------------------------------------------
00073 
00074 Subject to the terms of the GNU Public License (see above), you are
00075 free to do whatever you like with your modifications. However, you may
00076 (at your option) wish contribute them to Xara's source tree. You can
00077 find details of how to do this at:
00078   http://www.xaraxtreme.org/developers/
00079 
00080 Prior to contributing your modifications, you will need to complete our
00081 contributor agreement. This can be found at:
00082   http://www.xaraxtreme.org/developers/contribute/
00083 
00084 Please note that Xara will not accept modifications which modify any of
00085 the text between the start and end of this header (marked
00086 XARAHEADERSTART and XARAHEADEREND).
00087 
00088 
00089 MARKS
00090 -----
00091 
00092 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00093 designs are registered or unregistered trademarks, design-marks, and/or
00094 service marks of Xara Group Ltd. All rights in these marks are reserved.
00095 
00096 
00097       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00098                         http://www.xara.com/
00099 
00100 =================================XARAHEADEREND============================
00101  */
00102 
00103 
00104 #include "camtypes.h"
00105 #include "camdoctp.h"           // document template
00106 #include "camdoc.h"             // document
00107 //#include "ccmdikid.h"         // view frame
00108 //#include "scrcamvw.h"             // screen view
00109 #include "appstate.h"
00110 #include "errors.h"
00111 //#include "mfccopy.h"
00112 #include "camelot.h"
00113 #include "clipint.h"
00114 
00115 IMPLEMENT_CLASS(CCamDocTemplate, wxDocTemplate);
00116 DECLARE_SOURCE("$Revision: 25 $");
00117 
00118 
00119 
00120 CCamDocTemplate::CCamDocTemplate( wxDocManager* pManager, const wxString& descr, const wxString& filter, 
00121         const wxString& dir, const wxString& ext, const wxString& docTypeName, const wxString& viewTypeName, 
00122         wxClassInfo* docClassInfo, wxClassInfo* viewClassInfo )
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 }
00156 
00157 
00158 
00159 /********************************************************************************************
00160 
00161 >   CDocTemplate::Confidence CCamDocTemplate::MatchDocType(LPCTSTR lpszPathName, CDocument*& rpDocMatch)
00162 
00163     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00164     Created:    9/5/95
00165     Purpose:    This function has been overiden from its MFC version. It is actually
00166                 identical apart from the bit that checks to see if the document is already
00167                 open. The MFC version of the function goes and looks at the files involved
00168                 by calling AfxComparePaths(), but we just compare the paths. This stops the
00169                 floppy drive from being accessed all the time if you have a document opened
00170                 from a floppy drive (it also stops network problems if the conection to
00171                 an open document goes away). I am not too sure what all the params mean.
00172 
00173 ********************************************************************************************/
00174 
00175 #ifndef _MAC
00176 CCamDocTemplate::Confidence CCamDocTemplate::MatchDocType(LPCTSTR lpszPathName, wxDocument*& rpDocMatch)
00177 #else
00178 CCamDocTemplate::Confidence CCamDocTemplate::MatchDocType(LPCTSTR lpszPathName, DWORD dwFileType,
00179                                                        wxDocument*& rpDocMatch)
00180 #endif
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 }

Generated on Sat Nov 10 03:48:08 2007 for Camelot by  doxygen 1.4.4