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.

424 lines
15 KiB

  1. /************************************************************/
  2. /* Windows Write, Copyright 1985-1992 Microsoft Corporation */
  3. /************************************************************/
  4. /* kanji.h ----- kanji primitives forward declaration. */
  5. #ifdef DBCS
  6. /***** common definition for Korea, Japan and Taiwan PRC *****/
  7. /* CHLS (c of half line spacing) used to indicate the default
  8. line spacing. Used in createww.c and initmmw.c */
  9. #define chlsSingle 2
  10. #define chlsOneHalf 3
  11. #define chlsDouble 4
  12. #define chlsDefault chlsOneHalf
  13. /* HDC KanjiGetDC(HWND); */
  14. /* void FAR PASCAL SetMapperFlags(HDC, long); */
  15. /* And the kludge value to be used. */
  16. #define NEC_HACK ((long) 0x04)
  17. /* struct DNUT is used to map a unit annotation to ut. */
  18. struct DNUT {
  19. char *szUnit;
  20. int ut;
  21. };
  22. #ifdef CASHMERE
  23. #define IDNUTMAX 19
  24. #else
  25. #define IDNUTMAX 15
  26. #endif /* CASHMERE */
  27. /* Function type declarations. */
  28. int HpsFromDya(unsigned);
  29. unsigned DyaFromHps(int);
  30. BOOL FPasteTooLarge(unsigned long);
  31. /* For copy command, we now use the "COPY" key. */
  32. #ifndef NONECKEYBOARD
  33. #define VK_COPY 0x2C
  34. #else
  35. #ifndef NOVIRTUALKEYCODES
  36. #define VK_COPY VK_F2
  37. #endif /* not NOVIRTUALKEYCODES */
  38. #endif /* if-else-def NONECKEYBOARD */
  39. #ifdef DEBUG
  40. #define STATIC
  41. #else
  42. #define STATIC static
  43. #endif /* DEBUG */
  44. /* Kanji flag ---- used in CpFirstSty() */
  45. #define fkNonKanji ((CHAR) 0)
  46. #define fkKanji1 ((CHAR) 1)
  47. #define fkKanji2 ((CHAR) 2)
  48. #define cchKanji 2
  49. #define MAKEWORD(_bHi, _bLo) ((((WORD) _bHi) << 8) | ((WORD) _bLo))
  50. #define dxp0 0
  51. /******* KOREA specific definitons *******/
  52. #ifdef KOREA
  53. /* Used in GetKanjiMeasurement */
  54. #define bKanji1Min 0xA1
  55. /* First byte of a kanji space. */
  56. #define bKanjiSpace1 0xA1
  57. /* Second byte of a kanji space. */
  58. #define bKanjiSpace2 0xA1
  59. /* 1 byte kanji period. */
  60. #define bKanjiKuten 0xA1
  61. #define FKanji1(_ch) (((int) (_ch))>=0x0081 && ((int) (_ch))<=0x00FE)
  62. #define FKanji2(_ch) (((int) (_ch))>=0x0041 && ((int) (_ch))<=0x00FE)
  63. #define FKana(_ch) (FALSE)
  64. /* Excludes any kana punctuations. */
  65. #define FKanaText(_ch) ((0xB0 <= ((int) (_ch)) && ((int) (_ch)) <= 0xC8) \
  66. || (0xCA <= ((int) (_ch)) && ((int) (_ch)) <= 0xFD))
  67. #define FKanaPunct(_ch) (0xA1 <= ((int) (_ch)) && ((int) (_ch)) <= 0xA2)
  68. #define FKanjiSpace(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  69. ((int) (_ch2)) == 0x00A1)
  70. #define FKanjiQMark(_ch1, _ch2) (((int) (_ch1)) == 0x00A3 && \
  71. ((int) (_ch2)) == 0x00AF)
  72. #define FKanjiPeriod(_ch1, _ch2) (((int) (_ch1)) == 0x00A3 && \
  73. ((int) (_ch2)) == 0x00AE)
  74. #define FKanjiBang(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  75. ((int) (_ch2)) == 0x00A1)
  76. #define FKanjiKuten(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  77. ((int) (_ch2)) == 0x00A3)
  78. /* Since the higher half of 1-byte character codes are used for
  79. kanas and the first byte of a kanji character, we will use
  80. kanji characters for our markers. */
  81. #define chEMark ((CHAR) 0xA4)
  82. #define chStatPage ((CHAR) 0xBB)
  83. #if 0
  84. #define chMark1 ((CHAR) 0xA1)
  85. #define chEMark ((CHAR) 0xDF)
  86. #define chStatPage ((CHAR) 0xB7)
  87. #define chStatRH ((CHAR) 0xB5)
  88. #endif
  89. #ifdef CODE_TABLE
  90. /* The following tables defines those characters which can be display
  91. beyond the right margin.
  92. Refer to FAdmitCh2 function in d_FORM1.c */
  93. #define MPDCHRGCHIDX_MAC 2
  94. static CHAR mpdchrgchIdx[2] = {0xA1, 0xA3};
  95. static int mpdchichMax[2] = {13, 12};
  96. static CHAR mpdchrgch[2][13] = {
  97. /* A1 */ {0xA1, 0xAF, 0xB1, 0xB3, 0xB5, 0xB7, 0xB9, 0xBB, 0xBD, 0xC6, 0xC7, 0xC8, 0xC9},
  98. /* A3 */ {0xA1, 0xA2, 0xA5, 0xA7, 0xA9, 0xAC, 0xAE, 0xBA, 0xBB, 0xBF, 0xDD, 0xFD}
  99. };
  100. /* The followin tables specify characters which can exist beyond the
  101. right margin provided there is a kanji character on its left side
  102. Refer to FOptAdmitCh2 in d_FORM1.c on how to use them */
  103. #define OPTADMIT2IDX_MAC 1
  104. static CHAR OptAdmit2Idx[1] = {0xA3};
  105. static int OptAdmit2ichMax[1] = {6};
  106. static CHAR mpdchrgchOptAdmit2[1][6] = {
  107. {0xA1, 0xAC, 0xAE, 0xBA, 0xBB, 0xBF}
  108. };
  109. #endif /* CODE_TABLE */
  110. #endif /* Korea */
  111. /******* JAPAN specific definitons *******/
  112. #ifdef JAPAN
  113. /* Used in GetKanjiMeasurement */
  114. #define bKanji1Min 0x81
  115. /* First byte of a kanji space. */
  116. #define bKanjiSpace1 0x81
  117. /* Second byte of a kanji space. */
  118. #define bKanjiSpace2 0x40
  119. /* 1 byte kanji period. */
  120. #define bKanjiKuten 0xA1
  121. #define FKanji1(_ch) ((((int) (_ch))>=0x0081 && ((int) (_ch))<=0x009f) \
  122. || (((int) (_ch))>=0x00e0 && ((int) (_ch))<=0x00fc))
  123. //T-HIROYN Win3.1
  124. #define FKanji2(_ch) ((((int) (_ch))>=0x0040 && ((int) (_ch))<=0x007e) \
  125. || (((int) (_ch))>=0x0080 && ((int) (_ch))<=0x00fc))
  126. #define FKana(_ch) (0xA0 <= ((int) (_ch)) && ((int) (_ch)) <= 0xdf)
  127. /* Excludes any kana punctuations. */
  128. #define FKanaText(_ch) (0xA6 <= ((int) (_ch)) && ((int) (_ch)) <= 0xDD)
  129. #define FKanaPunct(_ch) ((0xA0 <= ((int) (_ch)) && ((int) (_ch)) <= 0xA5) || \
  130. (0xDE <= ((int) (_ch)) && ((int) (_ch)) <= 0xDF))
  131. #define FKanjiSpace(_ch1, _ch2) (((int) (_ch1)) == 0x0081 && \
  132. ((int) (_ch2)) == 0x0040)
  133. #define FKanjiQMark(_ch1, _ch2) (((int) (_ch1)) == 0x0081 && \
  134. ((int) (_ch2)) == 0x0048)
  135. #define FKanjiPeriod(_ch1, _ch2) (((int) (_ch1)) == 0x0081 && \
  136. ((int) (_ch2)) == 0x0044)
  137. #define FKanjiBang(_ch1, _ch2) (((int) (_ch1)) == 0x0081 && \
  138. ((int) (_ch2)) == 0x0049)
  139. #define FKanjiKuten(_ch1, _ch2) (((int) (_ch1)) == 0x0081 && \
  140. ((int) (_ch2)) == 0x0042)
  141. /* Write 3.1j endmark and pagemark is 1-byte charcter
  142. * t-Yoshio May 26,92
  143. */
  144. //Win3.1 New Code
  145. #define chEMark ((CHAR) 0xA4)
  146. #define chStatPage ((CHAR) 0xBB)
  147. /* Since the higher half of 1-byte character codes are used for
  148. kanas and the first byte of a kanji character, we will use
  149. kanji characters for our markers. */
  150. //Win3.0
  151. #if 0
  152. #define chMark1 ((CHAR) 0x81)
  153. #define chEMark ((CHAR) 0x9F)
  154. #define chStatPage ((CHAR) 0x74)
  155. #define chStatRH ((CHAR) 0x72)
  156. #endif
  157. #ifdef CODE_TABLE
  158. /* The following tables defines those characters which can be display
  159. beyond the right margin.
  160. Refer to FAdmitCh2 function in d_FORM1.c */
  161. #define MPDCHRGCHIDX_MAC 4
  162. static CHAR mpdchrgchIdx[4] = {0x81, 0x82, 0x83, 0x85};
  163. static int mpdchichMax[4] = {24, 9, 12, 20};
  164. static CHAR mpdchrgch[4][24] = {
  165. /* 0x81 */ {0x40, 0x41, 0x42, 0x45, 0x4A, 0x4B, 0x5B, 0x5C,
  166. 0x5D, 0x63, 0x64, 0x66, 0x68, 0x6A, 0x6C, 0x6E,
  167. 0x70, 0x72, 0x74, 0x76, 0x78, 0x7A, 0x8C, 0x8D},
  168. /* 0x82 */ {0x9F, 0xA1, 0xA3, 0xA5, 0xA7, 0xC1, 0xE1, 0xE3,
  169. 0xE5},
  170. /* 0x83 */ {0x40, 0x42, 0x44, 0x46, 0x48, 0x62, 0x83, 0x85,
  171. 0x87, 0x8E, 0x95, 0x96},
  172. /* 0x85 */ {0x41, 0x46, 0x48, 0x7C, 0x9D, 0x9F, 0xA1, 0xA2,
  173. 0xA3, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB,
  174. 0xAC, 0xAD, 0xDC, 0xDD}
  175. };
  176. /* The followin tables specify characters which can exist beyond the
  177. right margin provided there is a kanji character on its left side
  178. Refer to FOptAdmitCh2 in d_FORM1.c on how to use them */
  179. #define OPTADMIT2IDX_MAC 2
  180. static CHAR OptAdmit2Idx[2] = {0x81, 0x85};
  181. static int OptAdmit2ichMax[2] = {6,6};
  182. static CHAR mpdchrgchOptAdmit2[2][6] = {
  183. {0x43, 0x44, 0x46, 0x47, 0x48, 0x49},
  184. {0x40, 0x49, 0x4A, 0x4B, 0x4D, 0x5E}
  185. };
  186. #endif /* CODE_TABLE */
  187. #endif /* Japan */
  188. /******* PRC specific definitons *******/
  189. #ifdef PRC
  190. /* Used in GetKanjiMeasurement */
  191. #define bKanji1Min 0x81
  192. /* First byte of a kanji space. */
  193. #define bKanjiSpace1 0xA1
  194. /* Second byte of a kanji space. */
  195. #define bKanjiSpace2 0xA1
  196. /* 1 byte kanji period. */
  197. #define bKanjiKuten 0x7F
  198. #define FKanji1(_ch) (((int) (_ch))>=0x0081 && ((int) (_ch))<=0x00FE)
  199. /* Excludes any kana punctuations. */
  200. #define FKanaText(_ch) ((0x81 <= ((int) (_ch)) && ((int) (_ch)) <= 0xA0) || \
  201. (0xAA <= ((int) (_ch)) && ((int) (_ch)) <= 0xFE))
  202. #define FKanaPunct(_ch) (0xA1 <= ((int) (_ch)) && ((int) (_ch)) <= 0xA9)
  203. #define FKanjiSpace(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  204. ((int) (_ch2)) == 0x00A1)
  205. #define FKanjiQMark(_ch1, _ch2) (((int) (_ch1)) == 0x00A3 && \
  206. ((int) (_ch2)) == 0x00BF)
  207. #define FKanjiPeriod(_ch1, _ch2) (((int) (_ch1)) == 0x00A3 && \
  208. ((int) (_ch2)) == 0x00AE)
  209. #define FKanjiBang(_ch1, _ch2) (((int) (_ch1)) == 0x00A3 && \
  210. ((int) (_ch2)) == 0x00A1)
  211. #define FKanjiKuten(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  212. ((int) (_ch2)) == 0x00A2)
  213. /* Since the higher half of 1-byte character codes are used for
  214. kanas and the first byte of a kanji character, we will use
  215. kanji characters for our markers. */
  216. #define chMark1 ((CHAR) 0xA1)
  217. #define chEMark ((CHAR) 0xF4)
  218. #define chStatPage ((CHAR) 0x6E)
  219. #define chStatRH ((CHAR) 0x72)
  220. #ifdef CODE_TABLE
  221. /* The following tables defines those characters which can be display
  222. beyond the right margin.
  223. Refer to FAdmitCh2 function in d_FORM1.c */
  224. #define MPDCHRGCHIDX_MAC 2
  225. static CHAR mpdchrgchIdx[2] = {0xA1, 0xA3};
  226. static int mpdchichMax[2] = {11,13};
  227. static CHAR mpdchrgch[2][13] = {
  228. /* 0xA1 */ {0xA2, 0xA3, 0xAF, 0xB1, 0xB3, 0xB5, 0xB7,
  229. 0xB9, 0xBB, 0xBD, 0xBF},
  230. /* 0xA3 */ {0xA1, 0xA2, 0xA7, 0xA9, 0xAC, 0xAE, 0xBA,
  231. 0xBB, 0xBF, 0xDD, 0xE0, 0xFC, 0xFD},
  232. };
  233. /* The followin tables specify characters which can exist beyond the
  234. right margin provided there is a kanji character on its left side
  235. Refer to FOptAdmitCh2 in d_FORM1.c on how to use them */
  236. #define OPTADMIT2IDX_MAC 2
  237. static CHAR OptAdmit2Idx[2] = {0xA1, 0xA3};
  238. static int OptAdmit2ichMax[2] = {1,5};
  239. static CHAR mpdchrgchOptAdmit2[2][5] = {
  240. /* 0xA1 */ { 0xA3 },
  241. /* 0xA3 */ { 0xA1, 0xAE, 0xBA, 0xBB, 0xBF }
  242. };
  243. #endif /* CODE_TABLE */
  244. #else
  245. /******* TAIWAN specific definitons *******/
  246. #ifdef TAIWAN
  247. /* Used in GetKanjiMeasurement */
  248. #define bKanji1Min 0xA1
  249. /* First byte of a kanji space. */
  250. #define bKanjiSpace1 0xA1
  251. /* Second byte of a kanji space. */
  252. #define bKanjiSpace2 0x40
  253. /* 1 byte kanji period. */
  254. #define bKanjiKuten 0x7F
  255. #define FKanji1(_ch) (((int) (_ch))>=0x0081 && ((int) (_ch))<=0x00FE)
  256. /* Excludes any kana punctuations. */
  257. #define FKanaText(_ch) (0xA4 <= ((int) (_ch)) && ((int) (_ch)) <= 0xFE)
  258. #define FKanaPunct(_ch) (0xA1 <= ((int) (_ch)) && ((int) (_ch)) <= 0xA3)
  259. #define FKanjiSpace(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  260. ((int) (_ch2)) == 0x0040)
  261. #define FKanjiQMark(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  262. ((int) (_ch2)) == 0x0048)
  263. #define FKanjiPeriod(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  264. ((int) (_ch2)) == 0x0044)
  265. #define FKanjiBang(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  266. ((int) (_ch2)) == 0x0049)
  267. #define FKanjiKuten(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  268. ((int) (_ch2)) == 0x0042)
  269. /* Since the higher half of 1-byte character codes are used for
  270. kanas and the first byte of a kanji character, we will use
  271. kanji characters for our markers. */
  272. #define chMark1 ((CHAR) 0xA1)
  273. #define chEMark ((CHAR) 0xBB)
  274. #define chStatPage ((CHAR) 0x6E)
  275. #define chStatRH ((CHAR) 0x72)
  276. #ifdef CODE_TABLE
  277. /* The following tables defines those characters which can be display
  278. beyond the right margin.
  279. Refer to FAdmitCh2 function in d_FORM1.c */
  280. #define MPDCHRGCHIDX_MAC 1
  281. static CHAR mpdchrgchIdx[1] = {0xA1};
  282. static int mpdchichMax[1] = {24};
  283. static CHAR mpdchrgch[1][24] = {
  284. {0x41, 0x42, 0x43, 0x44, 0x46, 0x47, 0x48, 0x49,
  285. 0x4A, 0x4D, 0x4E, 0x51, 0x52, 0x53, 0x54, 0x62,
  286. 0x66, 0x6A, 0x77, 0x7B, 0x7E, 0xA2, 0xA4, 0xA8}
  287. };
  288. /* The followin tables specify characters which can exist beyond the
  289. right margin provided there is a kanji character on its left side
  290. Refer to FOptAdmitCh2 in d_FORM1.c on how to use them */
  291. #define OPTADMIT2IDX_MAC 1
  292. static CHAR OptAdmit2Idx[1] = {0xA1};
  293. static int OptAdmit2ichMax[1] = {6};
  294. static CHAR mpdchrgchOptAdmit2[1][6] = {
  295. 0x43, 0x44, 0x46, 0x47, 0x48, 0x49,
  296. };
  297. #endif /* CODE_TABLE */
  298. #endif /* Taiwan */
  299. #endif /* PRC */
  300. #ifdef USA
  301. #define chMark1 ((CHAR) 0x81)
  302. #define chStatPage (CHAR)'\273'
  303. #define chStatRH '>'
  304. #define chEMark (CHAR)'\244'
  305. /* Used in GetKanjiMeasurement */
  306. #define bKanji1Min 0xA1
  307. /* First byte of a kanji space. */
  308. #define bKanjiSpace1 0xA1
  309. /* Second byte of a kanji space. */
  310. #define bKanjiSpace2 0xA1
  311. /* 1 byte kanji period. */
  312. #define bKanjiKuten 0xA1
  313. #define FKanji1(_ch) (((int) (_ch))>=0x00A1 && ((int) (_ch))<=0x00FE)
  314. /* Excludes any kana punctuations. */
  315. #define FKanaText(_ch) (0xA4 <= ((int) (_ch)) && ((int) (_ch)) <= 0xFE)
  316. #define FKanaPunct(_ch) (0xA1 <= ((int) (_ch)) && ((int) (_ch)) <= 0xA3)
  317. #define FKanjiSpace(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  318. ((int) (_ch2)) == 0x0040)
  319. #define FKanjiQMark(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  320. ((int) (_ch2)) == 0x0048)
  321. #define FKanjiPeriod(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  322. ((int) (_ch2)) == 0x0044)
  323. #define FKanjiBang(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  324. ((int) (_ch2)) == 0x0049)
  325. #define FKanjiKuten(_ch1, _ch2) (((int) (_ch1)) == 0x00A1 && \
  326. ((int) (_ch2)) == 0x0042)
  327. #ifdef CODE_TABLE
  328. /* The following tables defines those characters which can be display
  329. beyond the right margin.
  330. Refer to FAdmitCh2 function in d_FORM1.c */
  331. #define MPDCHRGCHIDX_MAC 0
  332. static CHAR mpdchrgchIdx[1] = {0};
  333. static int mpdchichMax[1] = {0};
  334. static CHAR mpdchrgch[1][1] = {0};
  335. /* The followin tables specify characters which can exist beyond the
  336. right margin provided there is a kanji character on its left side
  337. Refer to FOptAdmitCh2 in d_FORM1.c on how to use them */
  338. #define OPTADMIT2IDX_MAC 0
  339. static CHAR OptAdmit2Idx[1] = {0};
  340. static int OptAdmit2ichMax[1] = {0};
  341. static CHAR mpdchrgchOptAdmit2[1][1] = {0};
  342. #endif /* CODE_TABLE */
  343. #endif
  344. #endif /* Kanji */