00001 // $Id: metafilt.h 1282 2006-06-09 09:46:49Z alex $ 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 00099 // Filters that are a bit on the OILy side e.g. Metafile, Aldus 00100 00101 #ifndef INC_METAFILT 00102 #define INC_METAFILT 00103 00104 //#include "oilfltrs.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00105 #include "clipmap.h" 00106 //#include "doccolor.h" - in camtypes.h [AUTOMATICALLY REMOVED] 00107 00108 class WinBitmap; 00109 class NodeBitmap; 00110 class MetafileView; 00111 00112 00113 00114 // This is to get access to the 16 bit windows types 00115 typedef short INT16; 00116 00117 #ifdef _MSC_VER 00118 // Make sure structures correspond to Win16 equivalents. 00119 // (pack to 1 byte boundaries) 00120 #pragma pack(push, 1) 00121 00122 typedef struct 00123 { 00124 INT16 lfHeight; 00125 INT16 lfWidth; 00126 INT16 lfEscapement; 00127 INT16 lfOrientation; 00128 INT16 lfWeight; 00129 BYTE lfItalic; 00130 BYTE lfUnderline; 00131 BYTE lfStrikeOut; 00132 BYTE lfCharSet; 00133 BYTE lfOutPrecision; 00134 BYTE lfClipPrecision; 00135 BYTE lfQuality; 00136 BYTE lfPitchAndFamily; 00137 CHAR lfFaceName[LF_FACESIZE]; 00138 } LOGFONT_16; 00139 00140 #pragma pack(pop) 00141 #else 00142 #error Don't know how to pack structures with this compiler! 00143 #endif // _MSC_VER 00144 00145 /******************************************************************************************** 00146 00147 > class MetaFileClipMap : public ClipboardMapping 00148 00149 Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com> 00150 Created: 20/4/95 00151 00152 Purpose: A class which describes and implements an available mapping between internal 00153 and external data formats. 00154 00155 This class implements clipboard import/export functionality for Windows 00156 MetaFiles, using the MetaFile Filter. 00157 00158 SeeAlso: ExternalClipboard; Filter; MetaFileFilter 00159 00160 *********************************************************************************************/ 00161 00162 class MetaFileClipMap : public ClipboardMapping 00163 { 00164 CC_DECLARE_DYNCREATE(MetaFileClipMap) 00165 00166 friend class ExternalClipboard; 00167 friend class OpClipboardExport; 00168 friend class OpClipboardImport; 00169 00170 protected: 00171 MetaFileClipMap() {} 00172 MetaFileClipMap(ClipboardMappingType TheType, Filter *TheFilter, 00173 InternalClipboardFormat &InternalDataType, UINT32 ExternalDataType, 00174 UINT32 Priority); 00175 00176 public: // Public method for constructing a mapping object 00177 static void CreateAndRegister(ClipboardMappingType TheType, Filter *TheFilter, 00178 InternalClipboardFormat &InternalDataType, UINT32 ExternalDataType, 00179 UINT32 Priority); 00180 00181 00182 protected: // Entry points for external clipboard manager 00183 virtual BOOL HandleImport(SelOperation *Caller, HANDLE ClipboardData, InternalClipboard *Dest); 00184 // Works out how to call the parent filter to import the given clipboard data 00185 00186 virtual HANDLE HandleExport(Operation *Caller, InternalClipboard *Source); 00187 // Works out how to call the parent filter to export the given clipboard document 00188 }; 00189 00190 00191 00192 00193 00194 // Forward reference for MetaFileFilter (see oilfltrs.cpp for declaration). 00195 class HandleTable; 00196 class CCLexFile; 00197 00198 /******************************************************************************************** 00199 00200 < METAHEADER 00201 00202 Comment: This structure is used when loading a MetaFile. 00203 00204 MonoOn 00205 typedef struct 00206 { 00207 BOOL Placeable; 00208 METAFILEHEADER Header; 00209 } METADATA; 00210 MonoOff 00211 00212 SeeAlso: MetaFileFilter; MetaFileFilter::GetMetaFileHandle 00213 00214 ********************************************************************************************/ 00215 00216 typedef struct 00217 { 00218 BOOL Placeable; 00219 METAFILEHEADER Header; 00220 } METADATA; 00221 00222 00223 /******************************************************************************************** 00224 00225 > class MetaFileFilter : public VectorFilter 00226 00227 Author: Tim_Browse (Xara Group Ltd) <camelotdev@xara.com> 00228 Created: 08/03/94 00229 Purpose: Encapsulates a filter for importing Windows MetaFiles (16-bit only at the 00230 moment) 00231 SeeAlso: Filter 00232 00233 ********************************************************************************************/ 00234 00235 class MetaFileFilter : public VectorFilter 00236 { 00237 friend class MetaFileClipMap; // Allow access to GetMetaFileHandle() 00238 00239 CC_DECLARE_MEMDUMP(MetaFileFilter); 00240 00241 public: 00242 MetaFileFilter(); 00243 ~MetaFileFilter(); 00244 00245 BOOL Init(); 00246 00247 // Works out if opening a file of this type requires a default document to be loaded 00248 // or does the file format supply the document. 00249 virtual BOOL IsDefaultDocRequired(const TCHAR* pcszPathName); 00250 00251 INT32 HowCompatible( PathName& Filename, ADDR HeaderStart, UINT32 HeaderSize, 00252 UINT32 FileSize ); 00253 00254 BOOL DoImport(SelOperation *Op, CCLexFile*, Document *DestDoc, 00255 BOOL AutoChosen, ImportPosition *Pos = NULL, 00256 KernelBitmap** ppImportedBitmap = NULL, 00257 DocCoord* pPosTranslate = NULL, String_256* URL=NULL); 00258 00259 // Exporting functions 00260 BOOL DoExport(Operation*, CCLexFile*, PathName*, Document*, BOOL); 00261 BOOL DoExport(Operation*, CCLexFile* pFile, Document* pDoc, METAFILEPICT* pMetaInfo); 00262 00263 // Set the font ready for use 00264 void SetLogicalFont(LOGFONT_16* pNewFont); 00265 00266 protected: 00267 BOOL PrepareToImport(); 00268 void CleanUpAfterImport(); 00269 00270 // The file we are reading, and the DC for it. 00271 HMETAFILE MetaFile; 00272 HDC MetaFileDC; 00273 00274 BOOL MetaFileHeaderIsOk(METAHEADER *pHeader); 00275 00276 // this is virtual so that inherited classes can override it 00277 virtual BOOL OpenAndIterateMetafile( CCLexFile *pDiskFile ); 00278 00279 // Given a metafile filename, return a metafile handle to it. 00280 HMETAFILE GetMetaFileHandle(LPSTR Filename, METADATA *); 00281 00282 INT32 DecodeMetafileRecord( METARECORD *pMetaRec ); 00283 // This must be static as it needs to be registered as a Windows callback. 00284 static INT32 CALLBACK DecodeMetaFile(HDC hdc, HANDLETABLE FAR* pHandleTable, 00285 METARECORD FAR* pMetaRec, INT32 cObj, LPARAM lParam); 00286 00287 00288 // Functions for decoding MetaFile records. 00289 BOOL DecodePolygon(METARECORD* pRec, BOOL FillPolygon); 00290 BOOL DecodePolyPolygon(METARECORD *); 00291 BOOL DecodeLineTo(METARECORD* pMetaRec); 00292 BOOL DecodeRectangle(METARECORD* pMetaRec); 00293 BOOL DecodeEllipse(METARECORD* pMetaRec); 00294 BOOL DecodeTextStory(METARECORD* pMetaRec); 00295 BOOL DecodeExtTextStory(METARECORD* pMetaRec); 00296 00297 // All the bitmap decoding functions 00298 BOOL DecodeStretchDIB(METARECORD*); 00299 BOOL DecodeDIBStretchBlt(METARECORD* pMetaRec); 00300 BOOL DecodeBitBlt(METARECORD* pMetaRec); 00301 BOOL DecodeStretchBlt(METARECORD* pMetaRec); 00302 BOOL DecodeDIBToDevice(METARECORD* pMetaRec); 00303 BOOL DecodeDIBBitBlt(METARECORD* pMetaRec); 00304 00305 // common code for the bitmap decoding 00306 KernelBitmap* CreateBitmap(BITMAPINFO* pBitmapStart); 00307 NodeBitmap* BuildNodeBitmap(KernelBitmap* pBitmap, const DocRect& Position); 00308 00309 // The Selected Font 00310 LOGFONT SelectedFont; 00311 00312 // TransformCoord() - converts a metafile coord to a DocCoord, taking into account the origin. 00313 void TransformCoord(DocCoord* C); 00314 00315 // ScaleCoord() - converts a metafile coord to a DocCoord. 00316 void ScaleCoord(DocCoord* C); 00317 00318 // Scale factors for coordinates 00319 INT32 CurrentMappingMode; 00320 DocCoord MetaFileOrigin; 00321 BOOL FlipYCoords; 00322 BOOL IsYExtentNegative; 00323 INT32 YShift; 00324 00325 // The layer that objects are placed on 00326 Layer *pLayer; 00327 00328 // The Node to which new objects are attached (may be a Layer or a Group node) 00329 Node *pNode; 00330 00331 struct CImportInfo 00332 { 00333 // The operation that caused the import 00334 SelOperation *pOp; 00335 00336 // Where the file was dropped for drag'n'drop, or NULL if drag'n'drop was not used. 00337 ImportPosition Pos; 00338 }; 00339 00340 CImportInfo ImportInfo; 00341 00342 // Attribute stuff 00343 BOOL AddAttributes(Node* pNewNode); 00344 DocColour TextColour; 00345 00346 // Array of GDI object handles 00347 HandleTable *Handles; 00348 00349 // Allow HandleTable objects to set our LineColour/FillColour variables. 00350 friend HandleTable; 00351 00352 // For progress cursor 00353 INT32 FileSize; 00354 INT32 BytesRead, 00355 LastProgressUpdate; 00356 00357 // TRUE if we're loading a placeable metafile. 00358 BOOL Placeable; 00359 00360 // How many units to the inch for a placeable metafile 00361 MILLIPOINT ScaleFactor; 00362 INT32 Dpi; 00363 00364 // Remembers the current point for operations such as moveto, lineto etc. 00365 DocCoord CurrentPoint; 00366 00367 // Need to know if we found anything in this file that we did not understand 00368 BOOL AllUnderstood; 00369 00370 // 00371 // Export related functions 00372 // 00373 virtual BOOL PrepareToExport(CCLexFile*, Spread *pSpread); 00374 virtual void CleanUpAfterExport(); 00375 virtual BOOL WriteToFile(HMETAFILE, METAFILEHEADER*); 00376 00377 CCLexFile* OutputFile; // where the metafile is going to (was CCLexFile*) 00378 CDC ReferenceDC; // reference DC for the metafile 00379 CMetaFileDC MetafileDC; // the CDC that actually gets rendered to 00380 RenderRegion *ExportRegion; // where rendering goes 00381 DocRect ExportClipRect; // The Clip rect of the export region 00382 MetafileView* pMetaView; // The metafile view to help with the rendering 00383 00384 private: 00385 Node *pLastInsertedNode; // where we put the last node in the tree so we can 00386 // insert new nodes as NEXT using this pointer 00387 00388 inline void AddNodeToMetaFileGroup(NodeRenderableBounded *pNode); 00389 // Add a node into the group we are importing the 00390 // metafile into 00391 00392 HFILE InFile; 00393 }; 00394 00395 /******************************************************************************************** 00396 00397 > class AldusFormatFilter : public MetaFileFilter 00398 00399 Author: Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com> 00400 Created: 10/3/95 00401 Purpose: Base class for various Aldus-format filters. 00402 SeeAlso: MetaFileFilter 00403 00404 ********************************************************************************************/ 00405 /* 00406 class AldusFormatFilter : public MetaFileFilter 00407 { 00408 CC_DECLARE_MEMDUMP(AldusFormatFilter); 00409 00410 public: 00411 static BOOL InitAll(List&); 00412 00413 AldusFormatFilter(); 00414 ~AldusFormatFilter(); 00415 BOOL Init(LPTCHAR, LPTCHAR, LPTCHAR); 00416 BOOL Init(); 00417 00418 INT32 HowCompatible( PathName& Filename, ADDR HeaderStart, UINT32 HeaderSize, 00419 UINT32 FileSize ); 00420 00421 protected: 00422 00423 BOOL OpenAndIterateMetafile( CCLexFile *pDiskFile ); 00424 00425 void UnloadDLL(); 00426 00427 LPTCHAR DLLPath; // complete path to filter DLL 00428 HMODULE DLLHandle; // handle of above DLL, NULL=not loaded 00429 HANDLE DLLPrefHandle; // for filters preference info 00430 00431 static UINT32 AutomaticID; // dynamic filter ID 00432 static BOOL DeclareFilter( List&, LPTCHAR , LPTCHAR , LPTCHAR ); 00433 00434 }; 00435 */ 00436 #endif