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.

364 lines
10 KiB

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