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.

249 lines
9.0 KiB

  1. #ifndef CITN_H
  2. #define CITN_H
  3. #include "sphelper.h"
  4. // Flags for number display
  5. typedef enum DISPLAYFLAGS
  6. {
  7. DF_UNFORMATTED = (1L << 0),// No formatting
  8. DF_ORDINAL = (1L << 1),// Ordinal number
  9. DF_WHOLENUMBER = (1L << 2),// Should be displayed without decimal
  10. DF_FIXEDWIDTH = (1L << 3),// Requiring a certain width
  11. DF_LEADINGZERO = (1L << 4),// Presence of leading 0 of the number is between 0 and 1
  12. DF_NOTHOUSANDSGROUP = (1L << 5),// Do not do any thousands grouping (commas)
  13. DF_MILLIONBILLION = (1L << 6) // If the number is a flat "millions" or "billions"
  14. // then display as "3 million"
  15. } DISPLAYFLAGS;
  16. class CSimpleITN
  17. {
  18. public:
  19. CSimpleITN(LANGID langid)
  20. {
  21. m_langid = langid;
  22. m_pwszNeg = NULL;
  23. }
  24. ~CSimpleITN()
  25. {
  26. if (m_pwszNeg)
  27. delete m_pwszNeg;
  28. if ( m_nmfmtDefault.lpDecimalSep )
  29. delete[] m_nmfmtDefault.lpDecimalSep;
  30. if ( m_nmfmtDefault.lpThousandSep )
  31. delete[] m_nmfmtDefault.lpThousandSep;
  32. }
  33. HRESULT _EnsureNumberFormatDefaults(void);
  34. HRESULT MakeNumberNegative( WCHAR *pwszNumber, UINT cSize );
  35. HRESULT MakeDisplayNumber( DOUBLE dblNum, DWORD dwDisplayFlags,
  36. UINT uiFixedWidth, UINT uiDecimalPlaces,
  37. WCHAR *pwszNum, UINT cSize );
  38. HRESULT InterpretNumberSimple(const SPPHRASEPROPERTY *pProperties,
  39. DOUBLE *pdblVal,
  40. WCHAR *pszVal,
  41. UINT cSize)
  42. {
  43. HRESULT hr = _EnsureNumberFormatDefaults();
  44. if (S_OK != hr)
  45. return hr;
  46. hr = E_NOTIMPL;
  47. switch(PRIMARYLANGID(m_langid))
  48. {
  49. case LANG_ENGLISH:
  50. hr = InterpretNumberEn(pProperties,
  51. TRUE,
  52. pdblVal,
  53. pszVal,
  54. cSize,
  55. TRUE);
  56. break;
  57. case LANG_JAPANESE:
  58. hr = InterpretNumberJp(pProperties,
  59. TRUE,
  60. pdblVal,
  61. pszVal,
  62. cSize,
  63. TRUE);
  64. break;
  65. case LANG_CHINESE:
  66. hr = InterpretNumberCh(pProperties,
  67. TRUE,
  68. pdblVal,
  69. pszVal,
  70. cSize,
  71. TRUE);
  72. break;
  73. default:
  74. break;
  75. }
  76. return hr;
  77. }
  78. HRESULT InterpretNumberEn(const SPPHRASEPROPERTY *pProperties,
  79. const bool fCardinal,
  80. DOUBLE *pdblVal,
  81. WCHAR *pszVal,
  82. UINT cSize,
  83. const bool fFinalDisplayFmt);
  84. HRESULT InterpretIntegerEn(const SPPHRASEPROPERTY *pProperties,
  85. const bool fCardinal,
  86. DOUBLE *pdblVal,
  87. WCHAR *pszVal,
  88. UINT cSize,
  89. const bool fFinalDisplayFmt,
  90. BOOL fNegative);
  91. HRESULT InterpretDecimalEn(const SPPHRASEPROPERTY *pProperties,
  92. const bool fCardinal,
  93. DOUBLE *pdblVal,
  94. WCHAR *pszVal,
  95. UINT cSize,
  96. const bool fFinalDisplayFmt,
  97. BOOL fNegative);
  98. ULONG ComputeNum999En(const SPPHRASEPROPERTY *pProperties );
  99. HRESULT InterpretNumberJp(const SPPHRASEPROPERTY *pProperties,
  100. const bool fCardinal,
  101. DOUBLE *pdblVal,
  102. WCHAR *pszVal,
  103. UINT cSize,
  104. const bool fFinalDisplayFmt);
  105. HRESULT InterpretIntegerJp(const SPPHRASEPROPERTY *pProperties,
  106. const bool fCardinal,
  107. DOUBLE *pdblVal,
  108. WCHAR *pszVal,
  109. UINT cSize,
  110. const bool fFinalDisplayFmt,
  111. BOOL fNegative);
  112. HRESULT InterpretDecimalJp(const SPPHRASEPROPERTY *pProperties,
  113. const bool fCardinal,
  114. DOUBLE *pdblVal,
  115. WCHAR *pszVal,
  116. UINT cSize,
  117. const bool fFinalDisplayFmt,
  118. BOOL fNegative);
  119. ULONG ComputeNum9999Jp(const SPPHRASEPROPERTY *pProperties );
  120. HRESULT InterpretNumberCh(const SPPHRASEPROPERTY *pProperties,
  121. const bool fCardinal,
  122. DOUBLE *pdblVal,
  123. WCHAR *pszVal,
  124. UINT cSize,
  125. const bool fFinalDisplayFmt);
  126. HRESULT InterpretIntegerCh(const SPPHRASEPROPERTY *pProperties,
  127. const bool fCardinal,
  128. DOUBLE *pdblVal,
  129. WCHAR *pszVal,
  130. UINT cSize,
  131. const bool fFinalDisplayFmt,
  132. BOOL fNegative);
  133. HRESULT InterpretDecimalCh(const SPPHRASEPROPERTY *pProperties,
  134. const bool fCardinal,
  135. DOUBLE *pdblVal,
  136. WCHAR *pszVal,
  137. UINT cSize,
  138. const bool fFinalDisplayFmt,
  139. BOOL fNegative);
  140. ULONG ComputeNum9999Ch(const SPPHRASEPROPERTY *pProperties);
  141. ULONG ComputeNum10000Ch(const SPPHRASEPROPERTY *pProperties);
  142. private:
  143. WCHAR *m_pwszNeg;
  144. LANGID m_langid;
  145. NUMBERFMTW m_nmfmtDefault;
  146. };
  147. #define BILLIONS 1
  148. #define MILLIONS 2
  149. #define THOUSANDS 3
  150. #define HUNDREDS 4
  151. #define TENS 5
  152. #define ONES 6
  153. #define TEENS 200
  154. #define NEGATIVE 7
  155. #define MILLBILL 8
  156. #define DIGIT 9
  157. #define TWODIGIT 10
  158. #define FP_PART 11
  159. #define ZERO 12
  160. #define POINT_ZERO 13
  161. #define NUMERATOR 14
  162. #define DENOMINATOR 15
  163. #define WHOLE 16
  164. #define ONEDIGIT 17
  165. #define GRID_INTEGER_99 101
  166. #define GRID_INTEGER_999 102
  167. #define GRID_INTEGER_MILLBILL 103
  168. #define GRID_INTEGER_STANDALONE 104
  169. #define GRID_INTEGER 105
  170. #define GRID_INTEGER_NONNEG 106
  171. #define GRID_DIGIT_NUMBER 107
  172. #define GRID_FP_NUMBER 108
  173. #define GRID_FP_NUMBER_NONNEG 109
  174. // Definition for Chinese Grammar.
  175. #define CHS_HUNDREDMILLIONS 1
  176. #define CHS_TENTHOUSANDS 2
  177. #define CHS_TENTHOUSANDS_ 3
  178. #define CHS_THOUSANDS 4
  179. #define CHS_HUNDREDS 5
  180. #define CHS_HUNDREDS_ 6
  181. #define CHS_ONES 7
  182. #define CHS_INTEGER 8
  183. #define CHS_DECIMAL 9
  184. #define CHS_NEGATIVE 10
  185. #define CHS_PERIOD 23
  186. #define CHS_DIGITS 24
  187. #define CHS_POS_OF_MINUS 27
  188. #define CHS_ONES_THOUSANDS 28
  189. #define CHS_GRID_NUMBER 1001
  190. #define CHS_GRID_NUMBER_MINUS 1002
  191. #define CHS_GRID_DECIMAL 1003
  192. #define CHS_GRID_NUMBER_ALL 1004
  193. // Definition for Japanese Grammar
  194. #define JPN_YENs 1
  195. #define JPN_CHOOs 2
  196. #define JPN_OKUs 3
  197. #define JPN_MANNs 4
  198. #define JPN_SENNs 5
  199. #define JPN_HYAKUs 6
  200. #define JPN_JUUs 7
  201. #define JPN_ICHIs 8
  202. #define JPN_NEGATIVE 9
  203. #define JPN_DIGIT 10
  204. #define JPN_FP_PART 12
  205. #define JPN_FP_PART_D 95
  206. #define JPN_ZERO 13
  207. #define JPN_NUMERATOR 14
  208. #define JPN_DENOMINATOR 15
  209. #define JPN_WHOLE 16
  210. #define JPN_GRID_INTEGER_9999 1001
  211. #define JPN_GRID_INTEGER_STANDALONE 1002
  212. #define JPN_GRID_INTEGER 1003
  213. #define JPN_GRID_INTEGER_NONNEG 1004
  214. #define JPN_GRID_DIGIT_NUMBER 1005
  215. #define JPN_GRID_FP_NUMBER 1006
  216. #define JPN_GRID_NUMBER_ALL 1007
  217. #endif // CITN_H