InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PMLocaleId.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Michael Burbidge
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 __PMLocaleId_h__
25 #define __PMLocaleId_h__
26 
27 #include "ICUForwardDeclare.h"
28 #include "PMTypes.h"
29 #include "IPMStream.h"
30 #include "PMLocaleIds.h"
31 
32 
33 #ifdef PUBLIC_BUILD
34 #endif
35 
42 {
43 public:
44  typedef base_type data_type;
45 
48  inline PMLocaleId();
49  inline explicit PMLocaleId(int32 combinedId);
50  inline PMLocaleId(int16 featureSetId, int16 userInterfaceId);
51 
56  inline bool16 operator==(const PMLocaleId& other) const;
57 
62  inline bool16 operator!=(const PMLocaleId& other) const;
63 
64 
70  bool16 Match(const PMLocaleId& other) const;
71 
75  inline int32 operator*() const;
76 
80  inline void ReadWrite(IPMStream* s);
81 
85  inline int16 GetFeatureSetId() const;
86 
90  inline int16 GetProductFS() const;
91 
95  inline int16 GetLanguageFS() const;
96 
100  inline int16 GetUserInterfaceId() const;
101 
105  inline int16 GetDefaultLanguageId() const;
106 
111  inline bool16 IsProductFS(const int16 productFS) const;
112 
117  inline bool16 IsLanguageFS(const int16 languageFS) const;
118 
122  int32 GetFeatureSetScript() const;
123 
127  int32 GetUIScript() const;
128 
132  ID_ICU_NAMESPACE::Locale GetUserInterfaceICULocale() const;
133 
137  bool16 IsRightToLeftUI() const;
138 
142  void SetUserInterface(ID_ICU_NAMESPACE::Locale newLocale);
143 
144  inline bool operator<(const PMLocaleId& other) const;
145 
146 private:
147  int16 fFeatureSetId;
148  int16 fUserInterfaceId;
149 };
150 
151 
152 //========================================================================================
153 // METHODS PMLocaleId
154 //========================================================================================
155 
157  fFeatureSetId(0),
158  fUserInterfaceId(0)
159 {
160 }
161 
162 inline PMLocaleId::PMLocaleId(int32 combinedId) :
163  fFeatureSetId((combinedId & 0xFFFF0000) >> 16),
164  fUserInterfaceId(combinedId & 0x0000FFFF)
165 {
166 }
167 
168 inline PMLocaleId::PMLocaleId(int16 featureSetId, int16 userInterfaceId) :
169  fFeatureSetId(featureSetId),
170  fUserInterfaceId(userInterfaceId)
171 {
172 }
173 
174 inline bool16 PMLocaleId::operator==(const PMLocaleId& other) const
175 {
176  return fFeatureSetId == other.fFeatureSetId && fUserInterfaceId == other.fUserInterfaceId;
177 }
178 
179 inline bool16 PMLocaleId::operator!=(const PMLocaleId& other) const
180 {
181  return fFeatureSetId != other.fFeatureSetId || fUserInterfaceId != other.fUserInterfaceId;
182 }
183 
184 inline int32 PMLocaleId::operator*() const
185 {
186  return (fFeatureSetId << 16) & fUserInterfaceId;
187 }
188 
189 inline bool PMLocaleId::operator< (const PMLocaleId& other) const
190 {
191  if (fFeatureSetId < other.fFeatureSetId)
192  return true;
193  else if (fFeatureSetId == other.fFeatureSetId && fUserInterfaceId < other.fUserInterfaceId)
194  return true;
195  else
196  return false;
197 }
198 
199 inline int16 PMLocaleId::GetFeatureSetId() const
200 {
201  return fFeatureSetId;
202 }
203 
204 inline int16 PMLocaleId::GetUserInterfaceId() const
205 {
206  if (fUserInterfaceId == k_enAE || fUserInterfaceId == k_enIL)
207  return k_enUS;
208  return fUserInterfaceId;
209 }
210 
212 {
213  return fUserInterfaceId;
214 }
215 
216 inline int16 PMLocaleId::GetProductFS() const
217 {
218  return (fFeatureSetId & 0xFF00);
219 }
220 
221 inline int16 PMLocaleId::GetLanguageFS() const
222 {
223  return (fFeatureSetId & 0x00FF);
224 }
225 
226 // if either is wild or they match
227 inline bool16 PMLocaleId::IsProductFS(const int16 productFS) const
228 {
229  uint16 product = static_cast<uint16>(fFeatureSetId) & 0xFF00;
230 #if 1
231  return ((product == kAllProductsFS) || (static_cast<uint16>(productFS) == kAllProductsFS) || (product == static_cast<uint16>(productFS)));
232 #else
233  //11/24/03 pboctor/mburbidge - The last part of this expression was changed to allow a ScriptInfo resource to be something like this:
234  // kInDesignRomanFS | kInDesignServerRomanFS
235  // In order for this to work: 1. The product feature set values must occupy unique bits 2. We can't have a product feature set value of 0
236  //5/13/04 jwbrown - ScriptInfo resources no longer require/permit OR'd feature sets, so I've reverted this code
237  return ((product == (int16)kAllProductsFS) || (productFS == (int16)kAllProductsFS) || ((productFS & product) != 0));
238 #endif
239 }
240 
241 // if either is wild or they match
242 inline bool16 PMLocaleId::IsLanguageFS(const int16 languageFS) const
243 {
244  int16 language = fFeatureSetId & 0x00FF;
245  return ((language == (int16)kAllLanguagesFS) || (languageFS == (int16)kAllLanguagesFS) || (language == languageFS));
246 }
247 
248 inline bool16 PMLocaleId::IsRightToLeftUI() const
249 {
250  return ((GetUserInterfaceId() == k_arAE) || (GetUserInterfaceId() == k_heIL));
251 }
252 
253 
254 
256 {
257  s->XferInt16(fFeatureSetId);
258  s->XferInt16(fUserInterfaceId);
259 }
260 
261 #endif // __PMLocaleId_h__