InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ICMSManager.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: fhaberma
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 __ICMSMANAGER__
25 #define __ICMSMANAGER__
26 
27 #if PRAGMA_ONCE
28 #endif
29 
30 #include "IPMUnknown.h"
31 #include "ICMSProfile.h"
32 
33 #include "ColorMgmtID.h"
34 #include "BravoForwardDecl.h"
35 
36 class PMString;
37 class IDocument;
39 
40 const int32 kCMSMgrHonorProfileSpace = (1L<<0);
41 const int32 kCMSMgrHonorProfileClass = (1L<<1);
42 const int32 kCMSMgrHonorProfileCategory = (1L<<2);
43 
44 const int32 kCMSMgrIncludeStandard = (1L << 0L);
45 const int32 kCMSMgrIncludeOther = (1L << 1L);
46 const int32 kCMSMgrIncludeInternal = (1L << 2L);
47 const int32 kCMSMgrIncludeAll = (kCMSMgrIncludeStandard | kCMSMgrIncludeOther | kCMSMgrIncludeInternal);
48 
50 public:
51  // Note: this may expand in the future to allow additional criteria.
52  // Do NOT store this class in a persistent manner!
53 
55  fHonorFlags(0),
56  fIncludeFlags(kCMSMgrIncludeAll),
57  fProfileSpace(ICMSProfile::kSpaceUnknown),
58  fProfileClass(ICMSProfile::kClassUnknown),
59  fProfileCategory(ICMSProfile::kOther) {};
60 
61  CMSMgrProfileFilter(ICMSProfile::profileSpace theSpace):
62  fHonorFlags(kCMSMgrHonorProfileSpace),
63  fIncludeFlags(kCMSMgrIncludeAll),
64  fProfileSpace(theSpace),
65  fProfileClass(ICMSProfile::kClassUnknown),
66  fProfileCategory(ICMSProfile::kOther) {};
67 
68  CMSMgrProfileFilter(ICMSProfile::profileClass theClass):
69  fHonorFlags(kCMSMgrHonorProfileClass),
70  fIncludeFlags(kCMSMgrIncludeAll),
71  fProfileSpace(ICMSProfile::kSpaceUnknown),
72  fProfileClass(theClass),
73  fProfileCategory(ICMSProfile::kOther) {};
74 
75  CMSMgrProfileFilter(ICMSProfile::profileSpace theSpace, ICMSProfile::profileClass theClass):
76  fHonorFlags(kCMSMgrHonorProfileSpace | kCMSMgrHonorProfileClass),
77  fIncludeFlags(kCMSMgrIncludeAll),
78  fProfileSpace(theSpace),
79  fProfileClass(theClass),
80  fProfileCategory(ICMSProfile::kOther) {};
81 
82  CMSMgrProfileFilter(ICMSProfile::profileCategory theCategory):
83  fHonorFlags(kCMSMgrHonorProfileCategory),
84  fIncludeFlags(kCMSMgrIncludeAll),
85  fProfileSpace(ICMSProfile::kSpaceUnknown),
86  fProfileClass(ICMSProfile::kClassUnknown),
87  fProfileCategory(theCategory) {};
88 
89  int operator== (const CMSMgrProfileFilter& x) {
90  return (fHonorFlags == x.fHonorFlags
91  && (!(fHonorFlags & kCMSMgrHonorProfileSpace) || fProfileSpace == x.fProfileSpace)
92  && (!(fHonorFlags & kCMSMgrHonorProfileClass) || fProfileClass == x.fProfileClass)
93  && (!(fHonorFlags & kCMSMgrHonorProfileCategory) || fProfileCategory == x.fProfileCategory)
94  && fIncludeFlags == x.fIncludeFlags
95  );
96  };
97  int operator!= (const CMSMgrProfileFilter& x) { return !operator==(x); };
98 
99  int32 fHonorFlags; // Collection of CMSMgrHonor* flags. Be explicit; don't use 0xFFFFFFFF, for example.
100  int32 fIncludeFlags;// Collection of CMSMgrInclude* glags. Be explicit; don't use 0xFFFFFFFF, for example.
101  ICMSProfile::profileSpace fProfileSpace;
102  ICMSProfile::profileClass fProfileClass;
103  ICMSProfile::profileCategory fProfileCategory;
104 };
105 
106 //========================================================================================
107 // Description:
108 // ICMSManager is meant to provide a generic wrapper around a CMS system. Access to the CMS is typically done
109 // by coordinating between this interface and a specific data interface for the specific CMS implementation. For
110 // example, Rainbow Bridge is a CMS, and implements ICMSManager with RBCMSManager, and coordinates with
111 // an IRBSpecificData interface on the same CMS boss.
112 //
113 // The following routines are broken up into four categories:
114 // Â¥ CMS Manager startup/shutdown methods
115 // Â¥ CMM manipulation
116 // Â¥ Available profile methods.
117 // Available profiles are ones that are available from the system or a CMM.
118 // Â¥ Used profile methods
119 // Used profiles are meant to connote profiles that are used in a document by some object.
120 //
121 // Coordinating with CMS data interface
122 // Some routines below need coordinating with a data interface as mentioned above. For example, the routine
123 // GenerateAvailableProfiles() needs to be called before getting or querying for the Nth profile or profile name.
124 // Similarly, the concept of a "used" profile needs to be tracked by the CMS manager. This means that querying
125 // and releasing needs to be done through this interface. When an object is assigned a profile, you should call
126 // "UseProfile()" so that the CMS manager can clean up properly.
127 //
128 // Simple example
129 // Here are some basic steps that most apps will want to do:
130 // - See if CMS is installed in the OS by calling IsAvailable()
131 // - Call Startup to get the machine going
132 // - Make a popup of available CMMs with consecutive calls to GetNthCMMName() and turn on the user choice
133 // with UseNthCMM().
134 // - Create popups for profile choices:
135 // o Call GenerateAvailableProfiles() to generate a list of those types of profiles available
136 // o Fill a popup of available profiles with consecutive calls to GetNthAvailableProfileName()
137 // - When the user chooses from the popup, call UseProfile with the name of the profile. The CMS manager will create this profile (if
138 // it doesn't already exist) and assign it to the element. You can also categorize it as one of the 5 std profiles (rgb source, cmyk source, etc)
139 // - If the user stops using the profile (e.g. deletes the last item using it, never used it, or changes to a different selection),
140 // just release it, and the CMS Manager will remove it from the document.
141 // - Call Shutdown() when all is said and done
142 //
143 // Other notes
144 // - The profileCategory is a helper enum which allows you to find the K2 standard profiles by id (see ICMSProfile.h)
145 // - Use the GetNthAvailableProfileName() and GetNthAvailableProfileFile() routines for filling in popups, as
146 // they don't actually create any objects (in the default implementation).
147 // - You should use the CMSUtils class instead of calls to this (for things like UseProfile), as they go through commands.
148 // - If you need to connect to AGM, the GetAGMProfileMethods will return you the correct structure to set up CMS.
149 //========================================================================================
150 class ICMSManager : public IPMUnknown
151 {
152 public:
153  enum { kDefaultIID = IID_ICMSMANAGER };
154 
155  enum CMSStatus {
156  // Anything in this range means it is shut down.
157  kCMSStatusShutDown = 0,
158 
159  // Anything in this range means it couldn't start up.
160  kCMSStatusInitializationErrorBase = 100,
161  kCMSStatusFailedToInitializeEngine,
162  kCMSStatusFailedToInitializeCMMs,
163  kCMSStatusFailedToInitializeProfiles,
164 
165  // Anything in this range means it's starting up.
166  kCMSStatusInitializingBase = 200,
167  kCMSStatusInitializedEngine,
168  kCMSStatusInitializedCMMs,
169  kCMSStatusInitializedProfiles,
170 
171  // Anything >= this value means it's running. Might
172  // later add status for ongoing operations.
173  kCMSStatusRunning = 300
174  };
175 
176  enum CMSPolicy
177  {
178  kCMSPolicyOff = 'off ',
179  kCMSPolicyPreserve = 'pres',
180  kCMSPolicyConvert = 'conv',
181  kCMSPolicyPDIL = 'pdil', // Note: this is manufactured by a combination of preserve and safe-cmyk
182  // (it does not occur as such in a CSF; it's inferred)
183  kCMSPolicyUndefined = 'undf', // This indicates a legacy document with no policy set up.
184  // It doesn't occur in CSFs but occurs in legacy documents
185  kCMSPolicyMaxEnum = 0xFFFFFFFFL // Force enum to be 32-bits wide.
186  };
187 
188  // Basic status calls
189  // ----------------------------------------------
190  // Start/stop the cms manager. Should be done only
191  // at app init/deinit.
192  virtual void Startup() = 0;
193  virtual void Shutdown() = 0;
194 
195  // called when the application resumes
196  virtual void AppResume() = 0;
197 
198  // Indicates how operational the CMS manager currently is.
199  virtual CMSStatus GetStatus() = 0;
200  // Returns true if shut down or errored at startup.
201  virtual bool32 IsShutDown() = 0;
202  // Returns true if currently starting up.
203  virtual bool32 IsInitializing() = 0;
204  // Returns true if started up successfully.
205  virtual bool32 IsRunning() = 0;
206 
207  // CMM calls
208  // ----------------------------------------------
209  // Get the number of CMMs available
210  virtual uint32 GetNumOfCMMs() = 0;
211  // Get the name of an available CMM
212  virtual bool32 GetNthCMMName(int32 index, PMString& theName) = 0;
213  // Select a particular CMM
214  virtual bool32 UseNthCMM(int32 index) = 0;
215  // Get which one's selected; returns -1 if none is selected yet.
216  virtual int32 GetActiveCMMIndex() = 0;
217 
218  virtual bool16 GetEngineInfo(uint32 engineIndex, PMString *engineName = nil, uint32 *engineCMS = nil, uint32 *engineCMM = nil) = 0;
219  virtual bool16 GetEngineInfo(const PMString &engineName, uint32 *engineIndex = nil, uint32 *engineCMS = nil, uint32 *engineCMM = nil) = 0;
220  virtual bool16 GetEngineInfo(uint32 engineCMS, uint32 engineCMM, uint32 *engineIndex = nil, PMString *engineName = nil) = 0;
221 
222  // Available Profile list methods
223  // ----------------------------------------------
224  // These create CMSAvailableProfileList objects, which can be further
225  // queried (e.g., count, profile names, etc). Caller is responsible
226  // for delete-ing the resulting list.
227  // Caller may specify which CMM to use, or -1 to use the current CMM.
228  // However, if the CMM is not the current one, only names may be obtained
229  // from the resulting list; calls to the getfilename and getspace members
230  // will not work.
231  // ResetProfileListCache can be used to guarantee that the next call to
232  // GenerateAllAvailableProfiles() will take a fresh look at the profiles out
233  // on disk. Otherwise it may used a cached version, which will not take any
234  // changes to the external profiles into account.
235  virtual void ResetProfileListCache(int32 whichCMM = -1) = 0;
236  virtual CMSAvailableProfileList *GenerateAllAvailableProfiles(int32 whichCMM = -1) = 0;
237  virtual CMSAvailableProfileList *GenerateAvailableProfiles(CMSMgrProfileFilter& filter, int32 whichCMM = -1) = 0; // Generate a list of compatible profiles
238 
239  // System profiles
240  // ----------------------------------------------
241  virtual bool32 GetSystemProfileName(PMString& theName) = 0;
242 
243  virtual bool16 GetDefaultProfileName(ICMSProfile::profileCategory category, PMString &name) = 0;
244 
245  // Methods for Using/Querying used Profiles
246  // ----------------------------------------------
247  // Item profiles. These methods are used to assign profiles to items.
248 
249  // This method selects an external profile (by name) as the profile for the
250  // specified item. If the named profile is in the used profile list, its
251  // refcount is simply increased by one. If not, a new profile is created
252  // using data from the available profile list (if the profile isn't in that
253  // list, the call fails). In any case the UIDRef of the profile in the
254  // used list is returned; its database is always the same as owningItem.
255  // By passing a non-nil data and size, a profile will be created in the
256  // document (i.e., kProfileSourceEmbeddedInDocument) and will be used as
257  // the reference instead of failing when the name isn't found.
258  virtual UIDRef ItemUseExternalProfile(
259  const UIDRef& owningItem,
260  const PMString& profileName,
261  const void *pProfileData = nil,
262  const int32 profileDataSize = 0) = 0;
263 
264  // Use the image's own embedded profile. This call will fail on any item
265  // that doesn't have embedded data. The profile data is optional; if you
266  // already have it then it will be used; otherwise it will be pulled from
267  // the image when it's needed. However, if the image hasn't ever been set
268  // up with a profile name (as might happen during the import process),
269  // you must either provide profile data, or the name of the profile.
270  // The UIDRef of the new profile is returned, which is always from the
271  // same database as owningItem.
272  virtual UIDRef ItemUseEmbeddedProfile(
273  const UIDRef& owningItem,
274  void *pProfileData = nil,
275  int32 dataSize = 0,
276  PMString *pEmbeddedName = nil) = 0;
277 
278  // Have the item use the document default profile for its colorspace.
279  // This is the default state for items without embedded profiles.
280  // No return value because the default profile is looked up as needed.
281  virtual bool32 ItemUseDocDefaultProfile(const UIDRef& owningItem) = 0;
282 
283  // Document profiles can only be external and are stored by their
284  // category. Returns the UIDRef of the selected profile.
285  // By passing a non-nil data and size, a profile will be created in the
286  // document (i.e., kProfileSourceEmbeddedInDocument) and will be used as
287  // the reference instead of failing when the name isn't found.
288  virtual UIDRef DocUseProfile(
289  IDocument *doc,
290  ICMSProfile::profileCategory which,
291  const PMString& profileName,
292  const void *pProfileData = nil,
293  const int32 profileDataSize = 0) = 0;
294  virtual UIDRef DocUseProfile(
295  UIDRef docUIDRef,
296  ICMSProfile::profileCategory which,
297  const PMString& profileName,
298  const void *pProfileData = nil,
299  const int32 profileDataSize = 0) = 0;
300 
301  // Get used profile methods.
302  virtual ICMSProfile *QueryUsedProfile(ICMSProfile::profileCategory which, IDocument *doc, bool32 forceSystemDefaultIfNone = kTrue) = 0;
303  virtual ICMSProfile *QueryUsedProfile(int32 index, IDocument *doc) = 0;
304  virtual ICMSProfile *QueryUsedProfile(const PMString &name, IDocument *doc) = 0;
305  virtual ICMSProfile *QueryUsedProfile(uint32 pmCsType, IPMUnknown* obj) = 0;
306  virtual int32 FindUsedProfile(const PMString &name, IDocument *doc) = 0;
307  virtual int32 NumUsedProfiles(IDocument *doc) = 0;
308 
309  // Install the default profile for a category into a document. 'which' can be one of:
310  // ICMSProfile::kRGBSource; ICMSProfile::kCMYKSource; and ICMSProfile::kLABSource
311  // when 'doc' is non-nil and: ICMSProfile::kMonitorDestination;
312  // ICMSProfile::kCompositeDestination; and ICMSProfile::kSeparationDestination when
313  // 'doc' is nil.
314  virtual bool16 InstallDefaultProfile(ICMSProfile::profileCategory which, IDocument *doc) = 0;
315 
316  virtual bool16 ProfilesEqual(ICMSProfile *iCMSProfileA, ICMSProfile *iCMSProfileB) const = 0;
317  virtual bool16 ProfilesMatch(ICMSProfile *iCMSProfileA, ICMSProfile *iCMSProfileB) const = 0;
318 
319  // Create a virtual (memory-only, no DB) profile by asking ACE for the profile by its name.
320  // Note that the profile by that name needs to be on the system, not embedded in a doc.
321  virtual ICMSProfile *CreateVirtualProfileFromName(const PMString &name) = 0;
322 
323  // return true iff all the directories (profiles, csf, etc) required by color management
324  // are present.
325  virtual bool16 VerifyDirectories() = 0;
326 
327  // Methods for handling CMS during AGM-direct drawing (EPS, PDF)
328  // ---------------------------------------------------------------
329  // When libraries are drawing directly to AGM, you don't have the opportunity
330  // to set up color spaces for that library. So, during an EPS drawing, for example,
331  // we want to assign profiles to the uncalibrated spaces so they draw on screen
332  // properly. These methods allow the ColorMgmt plug-in to properly handle this
333  // sort of thing: bracket the AGM calls with this begin/end pair and ColorMgmt
334  // will automatically do the right thing based on whether CMS is on for the
335  // specified document.
336  // If pDestinationProfile is nil, CMS will use the current monitor profile as
337  // the destination device.
338  virtual bool32 BeginLibraryDraw(const UIDRef &pageItem, AGMColorProfile *pDestinationProfile = nil) = 0;
339  virtual bool32 EndLibraryDraw() = 0;
340 
341  // Global parameters
342  // -----------------
343  // These affect global color behavior and are nonpersistent.
344  typedef enum
345  {
346  kInvalidSelector = 0,
347 
348  kCMSOffMode, // redbook = 1, stock profiles = 2
349  kAllowV4Export // default is false (0)
350  } CMSSelector;
351 
352  // returns true if the selector is recognized and set; otherwise false
353  virtual bool32 SetGlobalParameter(CMSSelector selector, int32 value) = 0;
354  // note: always returns zero for unrecognized selectors
355  virtual int32 GetGlobalParameter(CMSSelector selector) = 0;
356 
357 
358  #ifdef DEBUG
359  virtual void DumpToDebugWindow(IDocument* document) = 0;
360  #endif
361 };
362 
363 #endif // __ICMSMANAGER__
364 
365 // End, ICMSManager.h.