Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

365 lines
10 KiB

  1. /*++
  2. Copyright (C) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. LOCITEM.H
  5. History:
  6. --*/
  7. #ifndef LOCITEM_H
  8. #define LOCITEM_H
  9. #pragma warning(disable : 4251) // Shut up already about _declspec(import)
  10. #pragma warning(disable : 4275) // Shut up already about _declspec(export)
  11. class CLocItem;
  12. //
  13. // Class to hold an array of pointers to items.
  14. //
  15. class LTAPIENTRY CLocItemPtrArray : public CTypedPtrArray<CPtrArray, CLocItem *>
  16. {
  17. public:
  18. NOTHROW CLocItemPtrArray(BOOL fDelete=TRUE);
  19. void AssertValid(void) const;
  20. void NOTHROW ClearItemPtrArray(void);
  21. int NOTHROW Find(DBID, const CLocItem * &, BOOL bLocalizableOnly = FALSE) const;
  22. virtual ~CLocItemPtrArray();
  23. private:
  24. CLocItemPtrArray(const CLocItemPtrArray &);
  25. void operator=(const CLocItemPtrArray &);
  26. BOOL m_fDelete;
  27. };
  28. //
  29. // Class to hold an item set. This is an array of items that all have the
  30. // same identifier.
  31. //
  32. class LTAPIENTRY CLocItemSet : public CLocItemPtrArray
  33. {
  34. public:
  35. NOTHROW CLocItemSet(BOOL fDelete=TRUE);
  36. void AssertValid(void) const;
  37. NOTHROW const CLocUniqueId & GetUniqueId(void) const;
  38. NOTHROW const DBID & GetPseudoParentId(void) const;
  39. NOTHROW void ClearItemSet(void);
  40. NOTHROW void Match(const CLocItemSet &, CMap<int, int, int, int> &);
  41. NOTHROW int Find(CLocItem * pItem, int nStartAt = 0);
  42. NOTHROW ~CLocItemSet();
  43. private:
  44. static const CLocUniqueId m_luid; //This is a default last ditch
  45. DEBUGONLY(static CCounter m_UsageCounter);
  46. };
  47. //
  48. // A localizable item.
  49. // It represents either source or target data, depending on the context, but not both.
  50. //
  51. class LTAPIENTRY CLocItem : public CObject
  52. {
  53. public:
  54. NOTHROW CLocItem();
  55. void AssertValid(void) const;
  56. //
  57. // Read-only access members
  58. //
  59. NOTHROW BOOL HasLocString(void) const;
  60. NOTHROW BOOL HasBinary(void) const;
  61. NOTHROW const DBID & GetMyDatabaseId(void) const;
  62. NOTHROW const CLocUniqueId & GetUniqueId(void) const;
  63. const DBID &GetPseudoParentId(void) const;
  64. NOTHROW CLocUniqueId & GetUniqueId(void);
  65. NOTHROW CLS::LocStatus GetTranslationStatus(void) const;
  66. NOTHROW CLS::LocStatus GetBinaryStatus(void) const;
  67. NOTHROW CTO::TranslationOrigin GetTranslationOrigin(void) const;
  68. NOTHROW CAS::ApprovalState GetApprovalStatus(void) const;
  69. NOTHROW CAA::AutoApproved GetAutoApproved(void) const;
  70. NOTHROW long GetConfidenceLevel(void) const;
  71. NOTHROW long GetCustom1(void) const;
  72. NOTHROW long GetCustom2(void) const;
  73. NOTHROW long GetCustom3(void) const;
  74. NOTHROW long GetCustom4(void) const;
  75. NOTHROW long GetCustom5(void) const;
  76. NOTHROW long GetCustom6(void) const;
  77. NOTHROW const CLocString & GetLocString(void) const;
  78. NOTHROW BOOL GetBinary(const CLocBinary *&) const;
  79. NOTHROW CIT::IconType GetIconType(void) const;
  80. NOTHROW const CPascalString & GetInstructions(void) const;
  81. NOTHROW const CPascalString GetInstructions(BOOL) const;
  82. NOTHROW const CPascalString & GetTermNotes(void) const;
  83. NOTHROW UINT GetDisplayOrder(void) const;
  84. NOTHROW VisualEditor GetVisualEditor(void) const;
  85. NOTHROW BOOL GetFEqualSrcTgtString(void) const;
  86. NOTHROW void SetFEqualSrcTgtString(BOOL);
  87. NOTHROW BOOL GetFEqualSrcTgtBinary(void) const;
  88. NOTHROW void SetFEqualSrcTgtBinary(BOOL);
  89. NOTHROW BOOL GetFStringDirty(void) const;
  90. NOTHROW void SetFStringDirty(BOOL);
  91. NOTHROW BOOL GetFTargetStringDirty(void) const;
  92. NOTHROW void SetFTargetStringDirty(BOOL);
  93. NOTHROW BOOL GetFItemDirty(void) const;
  94. NOTHROW void SetFItemDirty(BOOL);
  95. NOTHROW BOOL IsAnyDirty(void);
  96. NOTHROW BOOL IsLocked(void) const;
  97. NOTHROW BOOL GetFDevLock(void) const;
  98. NOTHROW void SetFDevLock(BOOL);
  99. NOTHROW BOOL GetFTransLock(void) const;
  100. NOTHROW void SetFTransLock(BOOL);
  101. NOTHROW BOOL GetFUsrLock(void) const;
  102. NOTHROW void SetFUsrLock(BOOL);
  103. NOTHROW BOOL GetFExpandable(void) const;
  104. NOTHROW void SetFExpandable(BOOL);
  105. NOTHROW BOOL GetFDisplayable(void) const;
  106. NOTHROW void SetFDisplayable(BOOL);
  107. NOTHROW BOOL GetFNoResTable(void) const;
  108. NOTHROW void SetFNoResTable(BOOL);
  109. NOTHROW BOOL GetFValidTranslation(void) const;
  110. NOTHROW void SetFValidTranslation(BOOL);
  111. NOTHROW BOOL GetFVisEditorIgnore(void) const;
  112. NOTHROW void SetFVisEditorIgnore(BOOL);
  113. NOTHROW void SetFInstructionsDirty(BOOL);
  114. NOTHROW BOOL GetFInstructionsDirty(void) const;
  115. NOTHROW void SetFInstrAtt(BOOL);
  116. NOTHROW BOOL GetFInstrAtt(void) const;
  117. //
  118. // Assignment members. These set the appropriate dirty flags in the
  119. // item.
  120. //
  121. NOTHROW void SetMyDatabaseId(const DBID&);
  122. NOTHROW void SetUniqueId(const CLocUniqueId &);
  123. NOTHROW void SetPseudoParent(const DBID &);
  124. NOTHROW void SetLocString(const CLocString &);
  125. NOTHROW void ClearUniqueId(void);
  126. NOTHROW void SetTranslationStatus(CLS::LocStatus);
  127. NOTHROW void SetBinaryStatus(CLS::LocStatus);
  128. NOTHROW void SetTranslationOrigin(CTO::TranslationOrigin);
  129. NOTHROW void SetApprovalStatus(CAS::ApprovalState);
  130. NOTHROW void SetAutoApproved(CAA::AutoApproved);
  131. NOTHROW void SetConfidenceLevel(long);
  132. NOTHROW void SetCustom1(long);
  133. NOTHROW void SetCustom2(long);
  134. NOTHROW void SetCustom3(long);
  135. NOTHROW void SetCustom4(long);
  136. NOTHROW void SetCustom5(long);
  137. NOTHROW void SetCustom6(long);
  138. NOTHROW void SetIconType(CIT::IconType);
  139. NOTHROW void SetInstructions(const CPascalString &);
  140. NOTHROW void SetTermNotes(const CPascalString &);
  141. NOTHROW void SetDisplayOrder(UINT);
  142. NOTHROW void SetVisualEditor(VisualEditor);
  143. //
  144. // Setting the binary part will delete the
  145. // previous one!
  146. //
  147. NOTHROW void SetBinary(CLocBinary *);
  148. NOTHROW BOOL ExtractBinary(CLocBinary *&);
  149. NOTHROW void TransferBinary(CLocItem *);
  150. //
  151. // Clear ALL the dirty flags for the item.
  152. //
  153. NOTHROW void ClearDirtyFlags(void);
  154. // Kind of smart assignment
  155. BOOL UpdateFrom(CLocItem &);
  156. enum eLocContent
  157. {
  158. Source,
  159. Target
  160. };
  161. enum eDataFlow
  162. {
  163. FromFileToDb,
  164. FromDbToFile
  165. };
  166. // Kind of assignment for localizable content only.
  167. BOOL UpdateLocContentFrom(
  168. CLocItem & itemInput,
  169. eDataFlow nDataFlow,
  170. eLocContent nFrom,
  171. eLocContent nTo);
  172. //Used to know how similar is the localizable content between 2 items
  173. enum eMatchType
  174. {
  175. matchEmpty,
  176. matchBinary,
  177. matchString,
  178. matchFull
  179. };
  180. int MatchLocContent(const CLocItem &);
  181. //
  182. // Comparisons between localizable items.
  183. //
  184. NOTHROW int operator==(const CLocItem &) const;
  185. NOTHROW int operator!=(const CLocItem &) const;
  186. NOTHROW BOOL BobsConsistencyChecker(void) const;
  187. virtual ~CLocItem();
  188. protected:
  189. //
  190. // Private helper functions.
  191. //
  192. NOTHROW BOOL CompareItems(const CLocItem &);
  193. private:
  194. //
  195. // Flags that apply to the entire item. These control the display and
  196. // editablity and internal status of an item.
  197. //
  198. struct Flags
  199. {
  200. BOOL m_fDevLock :1; // Resource locked (in source file) from parser data
  201. BOOL m_fUsrLock :1; // Resource locked (by user) from parser data
  202. BOOL m_fTransLock :1; // Resource locked (for the user) from parser data
  203. BOOL m_fExpandable :1; // Expandable in project window
  204. BOOL m_fDisplayable :1; // Display in project window
  205. BOOL m_fNoResTable :1; // Don't display in res table
  206. BOOL m_fStringDirty :1; // has the source locstring changed?
  207. BOOL m_fTargetStringDirty :1; // has the target locstring changed?
  208. BOOL m_fItemDirty :1; // has any other part of the item changed?
  209. BOOL m_fEqualSrcTgtString :1; // are the src&tgt strings equal?
  210. BOOL m_fEqualSrcTgtBinary :1; // are the src&tgt binaries equal?
  211. BOOL m_fValidTranslation :1; // is the target string (the translation) good
  212. // for an autotranslate ?
  213. BOOL m_fVisEditorIgnore :1; // is the item ignored in the visual editor?
  214. // in memory state only.
  215. BOOL m_fInstructionsDirty :1;
  216. BOOL m_fInstrAtt :1; // has the instruction changed by Update command?
  217. };
  218. //
  219. // Prevents the default copy constructor from being called.
  220. //
  221. CLocItem(const CLocItem &);
  222. virtual void Serialize(CArchive &) {}
  223. const CLocItem &operator=(const CLocItem &);
  224. //
  225. // Item data.
  226. //
  227. //Language-independent members
  228. DBID m_dbid; //Id of item within the db
  229. DBID m_PseudoParent;
  230. CLocUniqueId m_uid;
  231. CLocString m_lsString;
  232. CIT::IconType m_icIconType; //UI Icon that visually indicates item type
  233. CPascalString m_pstrInstructions; //Instructions on how to localize the item
  234. CPascalString m_pstrTermNotes; // glossary notes
  235. CLS::LocStatus m_lsTranslationStatus; // Translation Loc status
  236. CLS::LocStatus m_lsBinaryStatus; // Binary Loc status
  237. CTO::TranslationOrigin m_toTranslationOrigin; // translation origin
  238. CAS::ApprovalState m_asApprovalStatus;
  239. CAA::AutoApproved m_auto_approved; // AUTO APPROVED
  240. long m_confidence_level; // confidence level
  241. long m_custom1; // CUSTOM1
  242. long m_custom2; // CUSTOM2
  243. long m_custom3; // CUSTOM3
  244. long m_custom4; // CUSTOM4
  245. long m_custom5; // CUSTOM5
  246. long m_custom6; // CUSTOM6
  247. VisualEditor m_veEditor; //Graphical editor used for the item
  248. Flags m_Flags; //Various flags
  249. //Language-dependent members
  250. UINT m_uiDisplayOrder; //Physical order of item in the file
  251. CLocBinary *m_pBinary; //Parser-specific properties
  252. DEBUGONLY(static CCounter m_UsageCounter);
  253. };
  254. //
  255. // Callback class used to provide information about
  256. // items to the item log.
  257. //
  258. class LTAPIENTRY CItemInfo
  259. {
  260. public:
  261. CItemInfo() {};
  262. virtual ~CItemInfo() {};
  263. virtual CLString GetFileName(const CLocItem *) = 0;
  264. virtual CLString GetItemName(const CLocItem *) = 0;
  265. private:
  266. CItemInfo(const CItemInfo &);
  267. const CItemInfo & operator=(const CItemInfo &);
  268. };
  269. //Classes used to retrieve mnemonics (aka hotkeys) from parsers
  270. class LTAPIENTRY CMnemonic
  271. {
  272. public:
  273. NOTHROW operator unsigned long() const;
  274. WCHAR m_cHotkeyChar;
  275. WORD m_nHotkeyScope;
  276. };
  277. class LTAPIENTRY CMnemonicsMap : public CMap<CMnemonic, CMnemonic &,
  278. CLocItemPtrArray *, CLocItemPtrArray * &>
  279. {
  280. public:
  281. CMnemonicsMap()
  282. {};
  283. ~CMnemonicsMap();
  284. private:
  285. CMnemonicsMap(const CMnemonicsMap &);
  286. void operator=(int);
  287. };
  288. #pragma warning(default : 4251)
  289. #if !defined(_DEBUG) || defined(IMPLEMENT)
  290. #include "locitem.inl"
  291. #endif
  292. #endif // LOCITEM_H