InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FileTypeRegistry.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Steve Pellegrin
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __FileTypeRegistry_h__
25 #define __FileTypeRegistry_h__
26 
27 #include "PMLocaleId.h"
28 #include "K2Vector.h"
29 #include "FileTypeInfo.h"
30 #include "OMTypes.h"
31 #include "KeyValuePair.h"
32 #include "DBUtils.h"
33 #include "IDResourceShell.h"
34 
35 //========================================================================================
36 // CLASS FileTypeRegistry
37 //========================================================================================
38 
39 
58 {
59 public:
64 
65 
66 public:
72 
77  virtual ~FileTypeRegistry();
78 
84  static bool16 FileTypeIsRegistered(FileTypeInfoID id);
85 
93  static void AddCurrentFileType(FileTypeInfoID id, const FileTypeInfo& fileInfo);
94 
100  static void RemoveCurrentFileType(FileTypeInfoID id);
101 
107  static void RemoveAllFileType(FileTypeInfoID id);
108 
115 
125  static bool16 GetAllFileTypeInfo(FileTypeInfoID id, FileTypeInfoList &list, bool16 clearList);
126 
132  static OSType GetCurrentFileType(FileTypeInfoID id);
133 
143  static bool16 GetAllFileType(FileTypeInfoID id, OSTypeList &list, bool16 clearList);
144 
150  static OSType GetCurrentFileCreator(FileTypeInfoID id);
151 
161  static bool16 GetAllFileCreator(FileTypeInfoID id, OSTypeList &list, bool16 clearList);
162 
170 
177  static bool16 GetCurrentMagicByte(FileTypeInfoID id, DBUtils::MagicBytes magic);
178 
189  static bool16 GetAllFileExtension(FileTypeInfoID id, FileExtensionList &list, bool16 clearList);
190 
198 
209  static bool16 GetAllFileMimeType(FileTypeInfoID id, FileMimeTypeList &list, bool16 clearList);
210 
219  static FileTypeInfoID GetFileTypeInfoIDForFile(const IDFile& file);
220 
221 private:
222  void LoadFileTypeRegistry();
223  bool SetupBootStrapStringStreamCallback(IDResource r);
224  bool PubFileAliasCountCallback(IDResource r, void* count);
225  void AddFileTypeTable(IPMStream* stream);
226  void AddPubFileAlias(IPMStream* stream);
227  void PrivAddCurrentFileType(FileTypeInfoID id, const FileTypeInfo& fileInfo);
228  void PrivRemoveCurrentFileType(FileTypeInfoID id);
229  void PrivRemoveAllFileType(FileTypeInfoID id);
230  bool16 PrivFileTypeIsRegistered(FileTypeInfoID id);
231  FileTypeInfo PrivGetCurrentInfo(FileTypeInfoID id);
232  OSType PrivGetCurrentFileCreator(FileTypeInfoID id);
233  bool16 PrivGetAllInfo(FileTypeInfoID id, FileTypeInfoList &list);
234  bool16 MakeInfoMRU(FileTypeInfoID id);
235  FileTypeInfoID AliasedInfoID(FileTypeInfoID id);
236 
237 private:
238  //--------------------------------------------------
239  // Class IDInfo
240  // Used to store a set of FileTypeInfo objects
241  // associated with a single file type ID.
242  //--------------------------------------------------
243  class IDInfo
244  {
245  public:
246  typedef object_type data_type;
247 
248  IDInfo()
249  {}
250  IDInfo(const FileTypeInfo &info)
251  {AddCurrentInfo(info);}
252  IDInfo(const IDInfo &other)
253  {Copy(other);}
254  ~IDInfo()
255  {}
256 
257  bool operator==(const IDInfo&) const { ASSERT_FAIL("appease K2Vector.Location"); return false; }
258 
259  void AddCurrentInfo(const FileTypeInfo &info)
260  {fInfoList.push_back(info);}
261  bool16 RemoveCurrentInfo()
262  {fInfoList.pop_back(); return !fInfoList.empty();}
263  bool16 GetAllInfo(FileTypeInfoList &list) const
264  {list = fInfoList; return !fInfoList.empty();}
265 
266  IDInfo&operator =(const IDInfo &other)
267  {Copy(other); return *this;}
268 
269  private:
270  void Copy(const IDInfo &other)
271  {fInfoList = other.fInfoList;}
272 
273  private:
274  FileTypeInfoList fInfoList;
275  };
276 
277 private:
279  typedef K2Vector<IDPair> IDVector;
280 
281 private:
282  IDVector fFileTypeTable;
283  IDVector::iterator fMRU;
284  FileTypeInfoID fPubFileAlias;
285  FileTypeInfoID fTmplFileAlias;
286  OSType fPubCurrentCreator;
287 };
288 
289 
290 #endif // __FileTypeRegistry_h__