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.

290 lines
6.9 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: _locstr.inl
  4. // Copyright (C) 1994-1997 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. //
  8. //
  9. //-----------------------------------------------------------------------------
  10. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  11. //
  12. // Swaps two elements of the translation array.
  13. //
  14. //-----------------------------------------------------------------------------
  15. inline
  16. void
  17. CLocTranslationArray::SwapElements(
  18. UINT iOne, // First index to swap
  19. UINT iTwo) // Second index to swap
  20. {
  21. CLocTranslation Temp;
  22. LTASSERT(iOne <= (UINT)GetSize());
  23. LTASSERT(iTwo <= (UINT)GetSize());
  24. Temp = (*this)[iOne];
  25. (*this)[iOne] = (*this)[iTwo];
  26. (*this)[iTwo] = Temp;
  27. }
  28. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  29. //
  30. // Assignment operator for cracked strings.
  31. //
  32. //-----------------------------------------------------------------------------
  33. inline
  34. const CLocCrackedString &
  35. CLocCrackedString::operator=(
  36. const CLocCrackedString &csSource)
  37. {
  38. m_pstrBaseString = csSource.m_pstrBaseString;
  39. m_pstrExtension = csSource.m_pstrExtension;
  40. m_pstrControl = csSource.m_pstrControl;
  41. m_cControlLeader = csSource.m_cControlLeader;
  42. m_cHotKeyChar = csSource.m_cHotKeyChar;
  43. m_uiHotKeyPos = csSource.m_uiHotKeyPos;
  44. return *this;
  45. }
  46. //-----------------------------------------------------------------------------
  47. //
  48. // Implementation for comparing two cracked strings. Language ID and
  49. // string type are NOT significant!
  50. //
  51. //-----------------------------------------------------------------------------
  52. inline
  53. BOOL
  54. CLocCrackedString::Compare(
  55. const CLocCrackedString &csOther)
  56. const
  57. {
  58. return ((m_uiHotKeyPos == csOther.m_uiHotKeyPos) &&
  59. (m_cHotKeyChar == csOther.m_cHotKeyChar) &&
  60. (m_pstrControl == csOther.m_pstrControl) &&
  61. (m_cControlLeader == csOther.m_cControlLeader) &&
  62. (m_pstrExtension == csOther.m_pstrExtension) &&
  63. (m_pstrBaseString == csOther.m_pstrBaseString));
  64. }
  65. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  66. //
  67. // Comparision operator.
  68. //
  69. //-----------------------------------------------------------------------------
  70. inline
  71. int
  72. CLocCrackedString::operator==(
  73. const CLocCrackedString &csOther)
  74. const
  75. {
  76. return Compare(csOther);
  77. }
  78. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  79. //
  80. // Comparision operator.
  81. //
  82. //-----------------------------------------------------------------------------
  83. inline
  84. int
  85. CLocCrackedString::operator!=(
  86. const CLocCrackedString &csOther)
  87. const
  88. {
  89. return !Compare(csOther);
  90. }
  91. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  92. //
  93. // Tests to see if the Cracked string has an 'extension'. The extension
  94. // is a sequence of characters ("...", ">>", stc) that indicates that this
  95. // item leads to another UI element.
  96. //
  97. //-----------------------------------------------------------------------------
  98. inline
  99. BOOL // TRUE if the extension is non-null.
  100. CLocCrackedString::HasExtension(void)
  101. const
  102. {
  103. return m_pstrExtension.GetStringLength() != 0;
  104. }
  105. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  106. //
  107. // Tests to see if the cracked string has a 'control' sequence. This is
  108. // usually text describing a shortcut key that invokes the same action as this
  109. // item, for example "Ctrl + F".
  110. //
  111. //-----------------------------------------------------------------------------
  112. inline
  113. BOOL // TRUE if the control seq. is non-null
  114. CLocCrackedString::HasControl(void)
  115. const
  116. {
  117. return m_pstrControl.GetStringLength() != 0;
  118. }
  119. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  120. //
  121. // Check to see if the cracked string has a hot-key. This come directly out
  122. // of the CLocString that was parsed into the Cracked String.
  123. //
  124. //-----------------------------------------------------------------------------
  125. inline
  126. BOOL // TRUE if the string has a hot-key.
  127. CLocCrackedString::HasHotKey(void)
  128. const
  129. {
  130. return (m_cHotKeyChar != 0);
  131. }
  132. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  133. //
  134. // Returns the 'base string'. This is the original string stripped of
  135. // extension and control sequences, and of the hot-key.
  136. //
  137. //-----------------------------------------------------------------------------
  138. inline
  139. const CPascalString & // Base string.
  140. CLocCrackedString::GetBaseString(void)
  141. const
  142. {
  143. return m_pstrBaseString;
  144. }
  145. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  146. //
  147. // Returns the extension component of the string.
  148. //
  149. //-----------------------------------------------------------------------------
  150. inline
  151. const CPascalString &
  152. CLocCrackedString::GetExtension(void)
  153. const
  154. {
  155. return m_pstrExtension;
  156. }
  157. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  158. //
  159. // Returns the constol sequence of the string.
  160. //
  161. //-----------------------------------------------------------------------------
  162. inline
  163. const CPascalString &
  164. CLocCrackedString::GetControl(void)
  165. const
  166. {
  167. return m_pstrControl;
  168. }
  169. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  170. //
  171. // Returns the hot-key character for the string.
  172. //
  173. //-----------------------------------------------------------------------------
  174. inline
  175. WCHAR
  176. CLocCrackedString::GetHotKeyChar(void)
  177. const
  178. {
  179. LTASSERT(HasHotKey());
  180. return m_cHotKeyChar;
  181. }
  182. inline
  183. UINT
  184. CLocCrackedString::GetHotKeyPos(void)
  185. const
  186. {
  187. LTASSERT(HasHotKey());
  188. return m_uiHotKeyPos;
  189. }
  190. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  191. //
  192. // Returns the string type for the string.
  193. //
  194. //-----------------------------------------------------------------------------
  195. inline
  196. CST::StringType
  197. CLocCrackedString::GetStringType(void)
  198. const
  199. {
  200. return m_stStringType;
  201. }
  202. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  203. //
  204. // Cleans out all the components of the cracked string.
  205. //
  206. //-----------------------------------------------------------------------------
  207. inline
  208. void
  209. CLocCrackedString::ClearCrackedString(void)
  210. {
  211. m_pstrBaseString.ClearString();
  212. m_pstrExtension.ClearString();
  213. m_pstrControl.ClearString();
  214. m_cControlLeader = L'\0';
  215. m_cHotKeyChar = L'\0';
  216. m_uiHotKeyPos = 0;
  217. m_stStringType = CST::None;
  218. }
  219. inline
  220. void
  221. CLocCrackedString::SetBaseString(
  222. const CPascalString &pasBase)
  223. {
  224. m_pstrBaseString = pasBase;
  225. }
  226. inline
  227. void
  228. CLocCrackedString::SetHotKey(
  229. WCHAR cHotKeyChar,
  230. UINT uiHotKeyPos)
  231. {
  232. m_cHotKeyChar = cHotKeyChar;
  233. m_uiHotKeyPos = uiHotKeyPos;
  234. }