1 // $Id: camdoc.h 1009 2006-05-11 15:52:04Z phil $
2 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
3 ================================XARAHEADERSTART===========================
5 Xara LX, a vector drawing and manipulation program.
6 Copyright (C) 1993-2006 Xara Group Ltd.
7 Copyright on certain contributions may be held in joint with their
8 respective authors. See AUTHORS file for details.
10 LICENSE TO USE AND MODIFY SOFTWARE
11 ----------------------------------
13 This file is part of Xara LX.
15 Xara LX is free software; you can redistribute it and/or modify it
16 under the terms of the GNU General Public License version 2 as published
17 by the Free Software Foundation.
19 Xara LX and its component source files are distributed in the hope
20 that it will be useful, but WITHOUT ANY WARRANTY; without even the
21 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 See the GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License along
25 with Xara LX (see the file GPL in the root directory of the
26 distribution); if not, write to the Free Software Foundation, Inc., 51
27 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 Conditional upon your continuing compliance with the GNU General Public
34 License described above, Xara Group Ltd grants to you certain additional
37 The additional rights are to use, modify, and distribute the software
38 together with the wxWidgets library, the wxXtra library, and the "CDraw"
39 library and any other such library that any version of Xara LX relased
40 by Xara Group Ltd requires in order to compile and execute, including
41 the static linking of that library to XaraLX. In the case of the
42 "CDraw" library, you may satisfy obligation under the GNU General Public
43 License to provide source code by providing a binary copy of the library
44 concerned and a copy of the license accompanying it.
46 Nothing in this section restricts any of the rights you have under
47 the GNU General Public License.
53 This license applies to this program (XaraLX) and its constituent source
54 files only, and does not necessarily apply to other Xara products which may
55 in part share the same code base, and are subject to their own licensing
58 This license does not apply to files in the wxXtra directory, which
59 are built into a separate library, and are subject to the wxWindows
60 license contained within that directory in the file "WXXTRA-LICENSE".
62 This license does not apply to the binary libraries (if any) within
63 the "libs" directory, which are subject to a separate license contained
64 within that directory in the file "LIBS-LICENSE".
67 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
68 ----------------------------------------------
70 Subject to the terms of the GNU Public License (see above), you are
71 free to do whatever you like with your modifications. However, you may
72 (at your option) wish contribute them to Xara's source tree. You can
73 find details of how to do this at:
74 http://www.xaraxtreme.org/developers/
76 Prior to contributing your modifications, you will need to complete our
77 contributor agreement. This can be found at:
78 http://www.xaraxtreme.org/developers/contribute/
80 Please note that Xara will not accept modifications which modify any of
81 the text between the start and end of this header (marked
82 XARAHEADERSTART and XARAHEADEREND).
88 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
89 designs are registered or unregistered trademarks, design-marks, and/or
90 service marks of Xara Group Ltd. All rights in these marks are reserved.
93 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
96 =================================XARAHEADEREND============================
100 camdoc.h : interface of the CCamDoc class
106 // Forward references.
113 /**********************************************************************************
114 > class CCamDoc : public COleServerDoc (MFC 2.5)
116 Author: Luke_Hart (Xara Group Ltd) <camelotdev@xara.com> (originally from samples\docvwmdi) with mods.
119 Purpose: This is the wxWidgets class for a document type object in the OIL (it was
120 originally part of wxWidgets example app. docvwmdi). It is very simple -
121 its main use is getting hold of the relevant Document object from the kernel
122 layer. wxWidgets calls various member functions when processing commands
123 from the File menu. This class calls down into the kernel to do
127 ***********************************************************************************/
133 CCamDoc( Document
*pKernelDoc
= NULL
);
136 // Returns a pointer to the kernel document associated with this.
137 Document
*GetKernelDoc() const;
139 // Serialization support
140 virtual bool OnNewDocument();
141 virtual bool OnSaveDocument(const wxString
& filename
);
142 virtual bool OnOpenDocument(const wxString
& filename
);
144 // override wxDocument::SaveAs
145 virtual bool SaveAs();
147 // Some CDocument emulation stuff
148 void SetModifiedFlag( BOOL fMod
= TRUE
) { Modify( FALSE
!= fMod
); }
150 // Framwwork titles, paths, & filenames.
151 virtual void SetTitle(LPCTSTR lpszTitle
);
152 virtual void SetPathName(LPCTSTR lpszPathName
, BOOL bAddToMRU
= TRUE
);
153 void SetPathNameEmpty();
154 void SetDocName(LPCTSTR lpszTitle
);
156 // Kernel titles, paths, and filenames.
157 String_256
GetKernelTitle();
158 String_256
GetKernelPathName(UINT32 MaxSize
= 0);
159 String_256
GetKernelDocName(BOOL IncludeFileType
= TRUE
);
160 String_256
GetKernelLocation(UINT32 MaxSize
= 0);
162 // The original file that this Camelot doc was based on, if they still correspond.
163 String_256
GetOriginalPath() const;
164 void SetOriginalPath(const String_256
& strPath
);
166 // Sets or clears the document's flags.
167 void SetModified(bool fState
);
168 void SetReadOnly(bool fState
);
169 void SetCopy(bool fState
);
171 // Test the above flags (note that MFC defines the IsModified() function).
172 bool IsReadOnly() const;
173 bool IsACopy() const;
174 bool IsUntouched() const;
175 bool IsModifiable() const;
177 // Call this to set the document flags MFC uses to decide if a save is Save, Save As,
179 void SetSaveFlags(BOOL fSameAsLoad
, BOOL fRememberName
)
181 #if (_OLE_VER >= 0x200)
182 m_bSameAsLoad
= fSameAsLoad
; m_bRemember
= fRememberName
;
186 // This returns the file-name of the template document for this kind of
187 // document (normally 'template.xar', for embedded documents it's 'embedded.xar'
188 //virtual void GetTemplateFilename(String_256* pstr) const;
190 //Graham 21/10/97: New template stuff
192 PathName
GetTemplate() const;
193 void SetTemplate( const PathName
&pathToSet
= PathName() );
195 static PathName
GetNextTemplateToUse();
196 static void SetNextTemplateToUse(const PathName
& pathToSet
=PathName());
199 PathName m_pathTemplate
;
200 static PathName ms_pathNextTemplateToUse
;
203 // This creates a CCOleStream or a CCDiskFile for OnOpenDocument and
204 // OnSaveDocument, according to their role (server doc or normal doc).
205 virtual CCLexFile
* CreateCCFile(LPCTSTR lpcszPath
, INT32 nOpenMode
);
207 // Useful helper functions.
208 // Functions to help with the opening of documents
209 virtual bool DefaultDocumentRequired(CCLexFile
* pFile
, UINT32 nPrefFilter
);
210 virtual bool LoadDefaultDocument();
211 virtual bool GeneralOpenDocument(CCLexFile
* pFile
, UINT32 nPrefFilter
);
212 virtual bool OnSaveModified();
213 virtual bool DoSave(LPCTSTR lpszPathName
, BOOL bReplace
= TRUE
);
214 virtual bool DeleteContents();
216 BOOL
RemoveExistingDocs();
218 // These perform the actual loading and saving of the document, without
219 // touching the doc's flags etc.
220 virtual bool DoNewDocument();
221 virtual bool DoOpenDocument( const wxString
&strFilename
);
222 virtual bool DoSaveDocument( const wxString
&strFilename
);
224 ////////////////////////////////////////////////////////////////////////////////
229 // Public so that Document can get at it (?)
230 static BOOL s_RemoveExistingOnNewDoc
;
232 // Don't want or need a stinking wxCommandProcessor, we do our own undo\redo handling
233 virtual wxCommandProcessor
*OnCreateCommandProcessor() { return NULL
; }
235 static BOOL
EnableRemoveUntouchedDocs();
236 // static BOOL RemoveUntouchedDocs();
237 // static BOOL IdleDocumentProcess();
238 // static BOOL MarkAllDocsUntouched(CWinApp* pApp);
243 // BOOL AnotherIsMaximised(); // TRUE is a view onto another doc is maximised.
246 Document
*m_pKernelDoc
; // points to this object's alter-ego
247 bool m_fIsReadOnly
; // "is modified" flag and functions.
249 bool m_fIsUntouched
; // ...by human hand.
250 String_256 m_TitlePrefix
; // essentially the document name
251 String_256 m_strOriginalPath
; // the file that this doc was loaded from if
252 // it wasn't from a .ART file or the default document,
253 // empty if this doc is new or no longer corresponds
254 bool m_bIsModifiable
; // Is this doc modifiable?
255 LPTSTR m_lpszInitialZoomOp
; // the initial zoom Op to perform, if any
256 bool m_fDoneNewDoc
; // bodge-flag to stop OLE calling OnNewDoc twice (??)
258 // static BOOL s_fRunIdleProcessing; // Do some Document work on next idle event
259 static Document
*s_pForceDocument
;
262 // Originaly OLE related, hardcoded to true now
263 bool IsVisible() const { return true; }
266 DECLARE_DYNAMIC_CLASS(CCamDoc
)