cxfrech.h

Go to the documentation of this file.
00001 // $Id: cxfrech.h 1237 2006-06-01 17:40:10Z gerry $
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 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // Header for the record handler class of the v2 file format
00099 
00100 #ifndef INC_CXFRECH
00101 #define INC_CXFRECH
00102 
00103 #include "listitem.h"
00104 #include "doccoord.h"
00105 
00106 #if !defined(EXCLUDE_FROM_XARLIB)
00107 #include "camfiltr.h"
00108 #endif
00109 
00110 #define CXFRH_TAG_LIST_END  (0xffffffff)
00111 
00112 class CXaraFileRecord;
00113 class BaseCamelotFilter;
00114 class DocColour;
00115 class KernelBitmap;
00116 class Node;
00117 class ColourListComponent;
00118 class BitmapListComponent;
00119 class UnitListComponent;
00120 class DocInfoComponent;
00121 class PrintComponent;
00122 class FontComponent;
00123 class CXaraFile;
00124 
00125 class Document;
00126 class Chapter;
00127 class Spread;
00128 class Layer;
00129 class NodePath;
00130 
00131 class AtomicTagListItem;
00132 class EssentialTagListItem;
00133 class TagDescriptionListItem;
00134 
00135 /********************************************************************************************
00136 
00137 >   class CXaraFileRecordHandler : public ListItem
00138 
00139     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00140     Created:    29/5/96
00141     Purpose:    This is the class that encapsulates a record handler in the new v2 format.
00142 
00143 ********************************************************************************************/
00144 
00145 class CXaraFileRecordHandler : public ListItem
00146 {
00147     // Give my name in memory dumps
00148     CC_DECLARE_DYNAMIC(CXaraFileRecordHandler);
00149 
00150 public:
00151     CXaraFileRecordHandler();
00152     ~CXaraFileRecordHandler();
00153 
00154     // Pure virtual functions that must be overridden.
00155     virtual UINT32* GetTagList() = 0;
00156     virtual BOOL    HandleRecord(CXaraFileRecord* pCXaraFileRecord) = 0;
00157     virtual BOOL    HandleStreamedRecord(CXaraFile * pCXFile, UINT32 Tag,UINT32 Size,UINT32 RecordNumber);
00158 
00159     // Find out if the record is streamed or not
00160     virtual BOOL IsStreamed(UINT32 Tag) = 0;
00161 
00162     virtual void IncProgressBarCount(UINT32 n) = 0;
00163 
00164     virtual BOOL IsTagInList(UINT32 Tag);
00165 
00166 #if defined(EXCLUDE_FROM_XARLIB)
00167     virtual BOOL Init(CXaraFile* pCXFile);
00168 #else
00169     virtual BOOL Init(BaseCamelotFilter* pBaseCamelotFilter);
00170 #endif
00171     virtual BOOL BeginImport();
00172     virtual BOOL EndImport();
00173     virtual BOOL BeginSubtree(UINT32 Tag);
00174     virtual BOOL EndSubtree(UINT32 Tag);
00175 
00176 #ifdef XAR_TREE_DIALOG
00177     virtual void GetTagText(UINT32 Tag,String_256& Str);
00178     virtual void GetRecordInfo(CXaraFileRecord *pCXaraFileRecord, StringBase *pStr);
00179     virtual void GetRecordDescriptionText(CXaraFileRecord* pCXaraFileRecord,StringBase* Str);
00180     virtual void DescribePath(CXaraFileRecord* pCXaraFileRecord,StringBase* Str);
00181     virtual void DescribePathRelative(CXaraFileRecord* pCXaraFileRecord,StringBase* Str);
00182 #endif
00183 };
00184 
00185 /********************************************************************************************
00186 
00187 >   class CamelotRecordHandler : public CXaraFileRecordHandler
00188 
00189     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00190     Created:    29/5/96
00191     Purpose:    This is the class that encapsulates a camelot-specific record handler in the new v2 format.
00192 
00193                 It's main purpose is to make it easy for record handlers to access BaseCamelotFilter
00194                 functions by providing mirror functions into the filter.
00195 
00196                 It also hides the fact that there is an underlying filter.
00197 
00198 ********************************************************************************************/
00199 
00200 class CamelotRecordHandler : public CXaraFileRecordHandler
00201 {
00202     // Give my name in memory dumps
00203     CC_DECLARE_DYNAMIC(CamelotRecordHandler);
00204 
00205 public:
00206     CamelotRecordHandler();
00207     ~CamelotRecordHandler();
00208 
00209     virtual BOOL IsCamelotHandler() { return TRUE; }
00210 
00211 #if defined(EXCLUDE_FROM_XARLIB)
00212     virtual BOOL Init(CXaraFile* pCXFile);
00213 #else
00214     virtual BOOL Init(BaseCamelotFilter* pBaseCamelotFilter);
00215 
00216     // Funcs for extracting reusable data items
00217     BOOL GetDocColour(INT32 ColourRef,DocColour* pDocColour);
00218     KernelBitmap* GetReadBitmapReference(INT32 BitmapRef);
00219 
00220     // functions that map onto BaseCamelotFilter functions
00221     ColourListComponent*    GetColourDocComponent();
00222     BitmapListComponent*    GetBitmapDocComponent();
00223     UnitListComponent*      GetUnitDocComponent();
00224     DocInfoComponent*       GetDocInfoComponent();
00225     PrintComponent*         GetPrintComponent();
00226     FontComponent*          GetFontComponent();
00227 
00228     BOOL        IsImporting();
00229     BOOL        IsImportingAtPosition();
00230 
00231     BOOL        InsertNode(Node* pNode);
00232     BOOL        IncInsertLevel();
00233     BOOL        DecInsertLevel();
00234     Node*       GetInsertContextNode();
00235     void        SetInsertContextNode(Node* pNode);
00236     void        InsertNextNodeAsChild();
00237     void        InsertNextNodeAsSibling();
00238 
00239     // Saving & restoring tree-building contexts
00240     InsertTreeContext *GetInsertContext(void);
00241     void RestoreInsertContext(InsertTreeContext *pOldState);
00242 
00243 
00244     // These calls are used for building the document structure when load a file
00245     //-----------
00246     Document*   GetLastDocumentInserted();
00247     Chapter*    GetLastChapterInserted();
00248     Spread*     GetLastSpreadInserted();
00249     Layer*      GetLastLayerInserted();
00250     NodePath*   GetLastNodePathInserted();
00251 
00252     void    SetLastDocumentInserted(Document* pNode);
00253     void    SetLastChapterInserted(Chapter* pNode);
00254     void    SetLastSpreadInserted(Spread* pNode);
00255     void    SetLastLayerInserted(Layer* pNode);
00256     void    SetLastNodePathInserted(NodePath* pNodePath);
00257     
00258     Layer * GetFirstImportedLayer();
00259     void    SetFirstImportedLayer(Layer* pLayer);
00260 
00261     UINT32  GetDocumentInsertedCount();
00262     UINT32  GetChapterInsertedCount();
00263     UINT32  GetSpreadInsertedCount();
00264     UINT32  GetLayerInsertedCount();
00265     UINT32  GetSetSentinelInsertedCount();
00266 
00267     void    IncDocumentInsertedCount();
00268     void    IncChapterInsertedCount();
00269     void    IncSpreadInsertedCount();
00270     void    IncLayerInsertedCount();
00271     void    IncSetSentinelInsertedCount();
00272 
00273     BOOL AddTagDescription(TagDescriptionListItem* pItem);
00274     TagDescriptionListItem* GetTagDescription(UINT32 Tag);
00275 
00276     BOOL UnrecognisedTag(UINT32 Tag);
00277 
00278     BOOL SetDocumentNudgeSize(UINT32 newVal);
00279 #endif
00280 
00281     void AddAtomicTag(AtomicTagListItem* pItem);
00282     void AddEssentialTag(EssentialTagListItem* pItem);
00283 
00284     BOOL IsTagInAtomicList(UINT32 Tag);
00285     BOOL IsTagInEssentialList(UINT32 Tag);
00286 
00287 #if !defined(EXCLUDE_FROM_XARLIB)
00288     // Path record references
00289     void        AddPathRecordRefToList(NodePath* pNodePath, UINT32 RecordNumber);
00290     UINT32      FindPathRecordRefRecordNumber(NodePath* pNodePath);
00291     NodePath*   FindPathRecordRefPath(UINT32 RecordNumber);
00292 
00293 //-----------
00294 
00295     Document*   GetDocument();
00296     Spread*     GetSpread();
00297 
00298     void        SetCoordOrigin(const DocCoord& Origin);
00299     DocCoord    GetCoordOrigin();
00300 
00301     void    EndOfFile();
00302     void    SetTotalNumBytesToRead(UINT32 s);
00303     void    IncProgressBarCount(UINT32 n);
00304     void    SetTotalProgressBarCount(UINT32 n);
00305 
00306     BaseCamelotFilter* GetBaseCamelotFilter() { return pBaseCamelotFilter; }
00307 
00308     // Function to turn Compression on or off on the underlying CCFile
00309     virtual BOOL  SetPreCompression(UINT32 Flags);
00310     virtual UINT32 GetPreCompression();
00311 #endif
00312 
00313     virtual BOOL  SetCompression(BOOL NewState);
00314 
00315     // Find out if the record is streamed or not
00316     virtual BOOL IsStreamed(UINT32 Tag);
00317 
00318 #if !defined(EXCLUDE_FROM_XARLIB)
00319     virtual void    SetImportFileType(char* pFileType);
00320     virtual BOOL    IsOpeningMinimalWebFormat();
00321 #endif
00322 
00323 protected:
00324 #if !defined(EXCLUDE_FROM_XARLIB)
00325     BaseCamelotFilter* pBaseCamelotFilter;
00326 #else
00327     CXaraFile* m_pCXFile;
00328 #endif
00329 };
00330 
00331 /********************************************************************************************
00332 
00333 >   class StripSubTreeRecordHandler : public CamelotRecordHandler
00334 
00335     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
00336     Created:    19/8/96
00337     Purpose:    This is the class is used to strip a subtree of records from the file.
00338 
00339                 It works counting the number of TAG_DOWN & TAG_UP records it gets.
00340 
00341                 If the next record it gets is a TAG_DOWN, it increments the tree level counter.
00342                 If the next record it gets is a TAG_UP, it decrements the tree level counter.
00343                 If the next record is neither a TAG_UP or TAG_DOWN, and the level counter > 0, it is thrown away
00344                 If the next record is neither a TAG_UP or TAG_DOWN, and the level counter == 0, it is passed on to it's proper handler
00345 
00346 ********************************************************************************************/
00347 
00348 class StripSubTreeRecordHandler : public CamelotRecordHandler
00349 {
00350     // Give my name in memory dumps
00351     CC_DECLARE_DYNAMIC(StripSubTreeRecordHandler);
00352 
00353 public:
00354     StripSubTreeRecordHandler();
00355 
00356     virtual UINT32* GetTagList();
00357     virtual BOOL    HandleRecord(CXaraFileRecord* pCXaraFileRecord);
00358     virtual BOOL    IsTagInList(UINT32 Tag);
00359     virtual BOOL    BeginImport();
00360     virtual void    IncProgressBarCount(UINT32 n) {};
00361 
00362     virtual void StripSubTreeOn()   { StripSubTree = TRUE; }
00363     virtual void StripSubTreeOff()  { StripSubTree = FALSE; }
00364     virtual BOOL IsStripSubTreeOn() { return StripSubTree; }
00365 
00366 private:
00367     BOOL StripSubTree;
00368     UINT32 LevelCounter;
00369 };
00370 
00371 #endif  // INC_CXFRECH

Generated on Sat Nov 10 03:44:58 2007 for Camelot by  doxygen 1.4.4