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.

578 lines
19 KiB

  1. #include "private.h"
  2. const MIMERFC1766 MimeRfc1766[] =
  3. {
  4. { 0x0436, L"af", IDS_RFC1766_LCID0436 },
  5. { 0x041C, L"sq", IDS_RFC1766_LCID041C },
  6. { 0x0001, L"ar", IDS_RFC1766_LCID0001 },
  7. { 0x0401, L"ar-sa", IDS_RFC1766_LCID0401 },
  8. { 0x0801, L"ar-iq", IDS_RFC1766_LCID0801 },
  9. { 0x0C01, L"ar-eg", IDS_RFC1766_LCID0C01 },
  10. { 0x1001, L"ar-ly", IDS_RFC1766_LCID1001 },
  11. { 0x1401, L"ar-dz", IDS_RFC1766_LCID1401 },
  12. { 0x1801, L"ar-ma", IDS_RFC1766_LCID1801 },
  13. { 0x1C01, L"ar-tn", IDS_RFC1766_LCID1C01 },
  14. { 0x2001, L"ar-om", IDS_RFC1766_LCID2001 },
  15. { 0x2401, L"ar-ye", IDS_RFC1766_LCID2401 },
  16. { 0x2801, L"ar-sy", IDS_RFC1766_LCID2801 },
  17. { 0x2C01, L"ar-jo", IDS_RFC1766_LCID2C01 },
  18. { 0x3001, L"ar-lb", IDS_RFC1766_LCID3001 },
  19. { 0x3401, L"ar-kw", IDS_RFC1766_LCID3401 },
  20. { 0x3801, L"ar-ae", IDS_RFC1766_LCID3801 },
  21. { 0x3C01, L"ar-bh", IDS_RFC1766_LCID3C01 },
  22. { 0x4001, L"ar-qa", IDS_RFC1766_LCID4001 },
  23. { 0x042D, L"eu", IDS_RFC1766_LCID042D },
  24. { 0x0402, L"bg", IDS_RFC1766_LCID0402 },
  25. { 0x0423, L"be", IDS_RFC1766_LCID0423 },
  26. { 0x0403, L"ca", IDS_RFC1766_LCID0403 },
  27. { 0x0004, L"zh", IDS_RFC1766_LCID0004 },
  28. { 0x1404, L"zh-mo", IDS_RFC1766_LCID1404 },
  29. { 0x0404, L"zh-tw", IDS_RFC1766_LCID0404 },
  30. { 0x0804, L"zh-cn", IDS_RFC1766_LCID0804 },
  31. { 0x0C04, L"zh-hk", IDS_RFC1766_LCID0C04 },
  32. { 0x1004, L"zh-sg", IDS_RFC1766_LCID1004 },
  33. { 0x041A, L"hr", IDS_RFC1766_LCID041A },
  34. { 0x0405, L"cs", IDS_RFC1766_LCID0405 },
  35. { 0x0406, L"da", IDS_RFC1766_LCID0406 },
  36. { 0x0413, L"nl", IDS_RFC1766_LCID0413 },
  37. { 0x0813, L"nl-be", IDS_RFC1766_LCID0813 },
  38. { 0x0009, L"en", IDS_RFC1766_LCID0009 },
  39. { 0x2409, L"en", IDS_RFC1766_LCID2409 },
  40. { 0x0409, L"en-us", IDS_RFC1766_LCID0409 },
  41. { 0x0809, L"en-gb", IDS_RFC1766_LCID0809 },
  42. { 0x0C09, L"en-au", IDS_RFC1766_LCID0C09 },
  43. { 0x1009, L"en-ca", IDS_RFC1766_LCID1009 },
  44. { 0x1409, L"en-nz", IDS_RFC1766_LCID1409 },
  45. { 0x1809, L"en-ie", IDS_RFC1766_LCID1809 },
  46. { 0x1C09, L"en-za", IDS_RFC1766_LCID1C09 },
  47. { 0x3009, L"en-zw", IDS_RFC1766_LCID3009 },
  48. { 0x2009, L"en-jm", IDS_RFC1766_LCID2009 },
  49. { 0x2809, L"en-bz", IDS_RFC1766_LCID2809 },
  50. { 0x2C09, L"en-tt", IDS_RFC1766_LCID2C09 },
  51. { 0x3409, L"en-ph", IDS_RFC1766_LCID3409 },
  52. { 0x0425, L"et", IDS_RFC1766_LCID0425 },
  53. { 0x0438, L"fo", IDS_RFC1766_LCID0438 },
  54. { 0x0429, L"fa", IDS_RFC1766_LCID0429 },
  55. { 0x040B, L"fi", IDS_RFC1766_LCID040B },
  56. { 0x040C, L"fr", IDS_RFC1766_LCID040C },
  57. { 0x080C, L"fr-be", IDS_RFC1766_LCID080C },
  58. { 0x0C0C, L"fr-ca", IDS_RFC1766_LCID0C0C },
  59. { 0x100C, L"fr-ch", IDS_RFC1766_LCID100C },
  60. { 0x140C, L"fr-lu", IDS_RFC1766_LCID140C },
  61. { 0x180C, L"fr-mc", IDS_RFC1766_LCID180C },
  62. { 0x043C, L"gd", IDS_RFC1766_LCID043C },
  63. { 0x0407, L"de", IDS_RFC1766_LCID0407 },
  64. { 0x0807, L"de-ch", IDS_RFC1766_LCID0807 },
  65. { 0x0C07, L"de-at", IDS_RFC1766_LCID0C07 },
  66. { 0x1007, L"de-lu", IDS_RFC1766_LCID1007 },
  67. { 0x1407, L"de-li", IDS_RFC1766_LCID1407 },
  68. { 0x0408, L"el", IDS_RFC1766_LCID0408 },
  69. { 0x040D, L"he", IDS_RFC1766_LCID040D },
  70. { 0x0439, L"hi", IDS_RFC1766_LCID0439 },
  71. { 0x040E, L"hu", IDS_RFC1766_LCID040E },
  72. { 0x040F, L"is", IDS_RFC1766_LCID040F },
  73. { 0x0421, L"id", IDS_RFC1766_LCID0421 },
  74. { 0x0410, L"it", IDS_RFC1766_LCID0410 },
  75. { 0x0810, L"it-ch", IDS_RFC1766_LCID0810 },
  76. { 0x0411, L"ja", IDS_RFC1766_LCID0411 },
  77. { 0x0412, L"ko", IDS_RFC1766_LCID0412 },
  78. { 0x0426, L"lv", IDS_RFC1766_LCID0426 },
  79. { 0x0427, L"lt", IDS_RFC1766_LCID0427 },
  80. { 0x042F, L"mk", IDS_RFC1766_LCID042F },
  81. { 0x043E, L"ms", IDS_RFC1766_LCID043E },
  82. { 0x043A, L"mt", IDS_RFC1766_LCID043A },
  83. { 0x0415, L"pl", IDS_RFC1766_LCID0415 },
  84. { 0x0416, L"pt-br", IDS_RFC1766_LCID0416 },
  85. { 0x0816, L"pt", IDS_RFC1766_LCID0816 },
  86. { 0x0417, L"rm", IDS_RFC1766_LCID0417 },
  87. { 0x0418, L"ro", IDS_RFC1766_LCID0418 },
  88. { 0x0818, L"ro-md", IDS_RFC1766_LCID0818 },
  89. { 0x0419, L"ru", IDS_RFC1766_LCID0419 },
  90. { 0x0819, L"ru-md", IDS_RFC1766_LCID0819 },
  91. { 0x0C1A, L"sr", IDS_RFC1766_LCID0C1A },
  92. { 0x081A, L"sr", IDS_RFC1766_LCID081A },
  93. { 0x041B, L"sk", IDS_RFC1766_LCID041B },
  94. { 0x0424, L"sl", IDS_RFC1766_LCID0424 },
  95. { 0x042E, L"sb", IDS_RFC1766_LCID042E },
  96. { 0x040A, L"es", IDS_RFC1766_LCID040A },
  97. { 0x080A, L"es-mx", IDS_RFC1766_LCID080A },
  98. { 0x0C0A, L"es", IDS_RFC1766_LCID0C0A },
  99. { 0x100A, L"es-gt", IDS_RFC1766_LCID100A },
  100. { 0x140A, L"es-cr", IDS_RFC1766_LCID140A },
  101. { 0x180A, L"es-pa", IDS_RFC1766_LCID180A },
  102. { 0x1C0A, L"es-do", IDS_RFC1766_LCID1C0A },
  103. { 0x200A, L"es-ve", IDS_RFC1766_LCID200A },
  104. { 0x240A, L"es-co", IDS_RFC1766_LCID240A },
  105. { 0x280A, L"es-pe", IDS_RFC1766_LCID280A },
  106. { 0x2C0A, L"es-ar", IDS_RFC1766_LCID2C0A },
  107. { 0x300A, L"es-ec", IDS_RFC1766_LCID300A },
  108. { 0x340A, L"es-cl", IDS_RFC1766_LCID340A },
  109. { 0x380A, L"es-uy", IDS_RFC1766_LCID380A },
  110. { 0x3C0A, L"es-py", IDS_RFC1766_LCID3C0A },
  111. { 0x400A, L"es-bo", IDS_RFC1766_LCID400A },
  112. { 0x440A, L"es-sv", IDS_RFC1766_LCID440A },
  113. { 0x480A, L"es-hn", IDS_RFC1766_LCID480A },
  114. { 0x4C0A, L"es-ni", IDS_RFC1766_LCID4C0A },
  115. { 0x500A, L"es-pr", IDS_RFC1766_LCID500A },
  116. { 0x0430, L"sx", IDS_RFC1766_LCID0430 },
  117. { 0x041D, L"sv", IDS_RFC1766_LCID041D },
  118. { 0x081D, L"sv-fi", IDS_RFC1766_LCID081D },
  119. { 0x041E, L"th", IDS_RFC1766_LCID041E },
  120. { 0x0431, L"ts", IDS_RFC1766_LCID0431 },
  121. { 0x0432, L"tn", IDS_RFC1766_LCID0432 },
  122. { 0x041F, L"tr", IDS_RFC1766_LCID041F },
  123. { 0x0422, L"uk", IDS_RFC1766_LCID0422 },
  124. { 0x0420, L"ur", IDS_RFC1766_LCID0420 },
  125. { 0x0443, L"uz", IDS_RFC1766_LCID0443 },
  126. { 0x0843, L"uz", IDS_RFC1766_LCID0843 },
  127. { 0x042A, L"vi", IDS_RFC1766_LCID042A },
  128. { 0x0434, L"xh", IDS_RFC1766_LCID0434 },
  129. { 0x043D, L"yi", IDS_RFC1766_LCID043D },
  130. { 0x0435, L"zu", IDS_RFC1766_LCID0435 },
  131. { 0x042B, L"hy", IDS_RFC1766_LCID042B },
  132. { 0x0437, L"ka", IDS_RFC1766_LCID0437 },
  133. { 0x043F, L"kk", IDS_RFC1766_LCID043F },
  134. { 0x0441, L"sw", IDS_RFC1766_LCID0441 },
  135. { 0x0444, L"tt", IDS_RFC1766_LCID0444 },
  136. { 0x0445, L"bn", IDS_RFC1766_LCID0445 },
  137. { 0x0446, L"pa", IDS_RFC1766_LCID0446 },
  138. { 0x0447, L"gu", IDS_RFC1766_LCID0447 },
  139. { 0x0448, L"or", IDS_RFC1766_LCID0448 },
  140. { 0x0449, L"ta", IDS_RFC1766_LCID0449 },
  141. { 0x044A, L"te", IDS_RFC1766_LCID044A },
  142. { 0x044B, L"kn", IDS_RFC1766_LCID044B },
  143. { 0x044C, L"ml", IDS_RFC1766_LCID044C },
  144. { 0x044D, L"as", IDS_RFC1766_LCID044D },
  145. { 0x044E, L"mr", IDS_RFC1766_LCID044E },
  146. { 0x083E, L"ms", IDS_RFC1766_LCID083E },
  147. { 0x0861, L"ne", IDS_RFC1766_LCID0861 },
  148. { 0x044F, L"sa", IDS_RFC1766_LCID044F },
  149. // Sync W2K NLS, remove 0x0827 RFC1766 entry
  150. // { 0x0827, L"lt", IDS_RFC1766_LCID0827 },
  151. { 0x0457, L"kok", IDS_RFC1766_LCID0457 },
  152. // Following rfc1766 names are over already published MAX_RFC1766_NAME
  153. // We have to modify them for IE5 release, will do better later
  154. // { 0x082C, L"x-az-cyrillic", IDS_RFC1766_LCID082C },
  155. // { 0x042C, L"x-az-latin", IDS_RFC1766_LCID042C },
  156. { 0x0414, L"no", IDS_RFC1766_LCID0414 },
  157. { 0x0414, L"nb-no", IDS_RFC1766_LCID0414 },
  158. { 0x0814, L"nn-no", IDS_RFC1766_LCID0814 },
  159. { 0x082C, L"az", IDS_RFC1766_LCID082C },
  160. { 0x042C, L"az", IDS_RFC1766_LCID042C },
  161. // More stuffs from Whistler NLS
  162. { 0x0440, L"kz", IDS_RFC1766_LCID0440 },
  163. { 0x0450, L"mn", IDS_RFC1766_LCID0450 },
  164. { 0x0456, L"gl", IDS_RFC1766_LCID0456 },
  165. { 0x045A, L"syr", IDS_RFC1766_LCID045A },
  166. { 0x0465, L"div", IDS_RFC1766_LCID0465 },
  167. // Whistler bug#350772, for Hispanic US
  168. { 0x540A, L"es-us", IDS_RFC1766_LCID540A },
  169. };
  170. UINT g_cRfc1766 = ARRAYSIZE(MimeRfc1766);
  171. //
  172. // CEnumCodePage implementation
  173. //
  174. CEnumCodePage::CEnumCodePage(DWORD grfFlags, LANGID LangId, MIMECONTF dwSource) : _dwLevel( grfFlags ), _LangId( LangId), dwMimeSource(dwSource)
  175. {
  176. DebugMsg(DM_TRACE, TEXT("constructor of CEnumCodePage 0x%08x"), this);
  177. DllAddRef();
  178. _cRef = 1;
  179. _iCur = 0;
  180. }
  181. CEnumCodePage::~CEnumCodePage()
  182. {
  183. DebugMsg(DM_TRACE, TEXT("destructor of CEnumCodePage 0x%08x"), this);
  184. DllRelease();
  185. }
  186. STDAPI CEnumCodePage::QueryInterface(REFIID riid, void **ppvObj)
  187. {
  188. DebugMsg(DM_TRACE, TEXT("CEnumCodePage::QueryInterface called."));
  189. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IEnumCodePage))
  190. {
  191. *ppvObj = SAFECAST(this, IEnumCodePage*);
  192. AddRef();
  193. return NOERROR;
  194. }
  195. *ppvObj = NULL;
  196. return E_NOINTERFACE;
  197. }
  198. STDAPI_(ULONG) CEnumCodePage::AddRef()
  199. {
  200. _cRef++;
  201. DebugMsg(DM_TRACE, TEXT("CEnumCodePage::AddRef called. _cRef=%d"), _cRef);
  202. return _cRef;
  203. }
  204. STDAPI_(ULONG) CEnumCodePage::Release()
  205. {
  206. _cRef--;
  207. DebugMsg(DM_TRACE, TEXT("CEnumCodePage::Release called. _cRef=%d"), _cRef);
  208. if (0 < _cRef)
  209. return _cRef;
  210. delete this;
  211. return 0;
  212. }
  213. STDAPI CEnumCodePage::Clone(IEnumCodePage **ppEnumCodePage)
  214. {
  215. DebugMsg(DM_TRACE, TEXT("CEnumCodePage::Clone called."));
  216. return E_NOTIMPL;
  217. }
  218. STDAPI CEnumCodePage::Next(ULONG celt, PMIMECPINFO rgcpInfo, ULONG *pceltFetched)
  219. {
  220. DebugMsg(DM_TRACE, TEXT("CEnumCodePage::Next called."));
  221. UINT cNum = 0;
  222. MIMECPINFO cpInfo;
  223. if (dwMimeSource & MIMECONTF_MIME_REGISTRY)
  224. {
  225. if (NULL != g_pMimeDatabaseReg && NULL != rgcpInfo)
  226. {
  227. if (0 == _iCur)
  228. if (S_OK != g_pMimeDatabaseReg->EnumCodePageInfo())
  229. return E_FAIL;
  230. while (cNum < celt)
  231. {
  232. HRESULT hr = g_pMimeDatabaseReg->GetCodePageInfoWithIndex(_iCur++, &cpInfo);
  233. if (SUCCEEDED(hr))
  234. {
  235. if (_dwLevel == (cpInfo.dwFlags & _dwLevel))
  236. {
  237. *(rgcpInfo + cNum) = cpInfo;
  238. cNum++;
  239. }
  240. }
  241. else
  242. break;
  243. }
  244. if (NULL != pceltFetched)
  245. *pceltFetched = cNum;
  246. return (0 < cNum)? S_OK: S_FALSE;
  247. }
  248. else
  249. return E_FAIL;
  250. }
  251. while (cNum < celt)
  252. {
  253. if (SUCCEEDED(g_pMimeDatabase->GetCodePageInfoWithIndex(_iCur++, _LangId, &cpInfo)))
  254. {
  255. if (_dwLevel == (cpInfo.dwFlags & _dwLevel) &&
  256. (cpInfo.dwFlags & dwMimeSource))
  257. {
  258. *(rgcpInfo + cNum) = cpInfo;
  259. cNum++;
  260. }
  261. }
  262. else
  263. break;
  264. }
  265. if (NULL != pceltFetched)
  266. *pceltFetched = cNum;
  267. return (0 < cNum)? S_OK: S_FALSE;
  268. }
  269. STDAPI CEnumCodePage::Reset()
  270. {
  271. DebugMsg(DM_TRACE, TEXT("CEnumCodePage::Reset called."));
  272. _iCur = 0;
  273. return NOERROR;
  274. }
  275. STDAPI CEnumCodePage::Skip(ULONG celt)
  276. {
  277. DebugMsg(DM_TRACE, TEXT("CEnumCodePage::Skip called."));
  278. _iCur += celt;
  279. return NOERROR;
  280. }
  281. //
  282. // CEnumRfc1766 implementation
  283. //
  284. CEnumRfc1766::CEnumRfc1766(MIMECONTF dwSource, LANGID LangId) : _LangID(LangId)
  285. {
  286. DebugMsg(DM_TRACE, TEXT("constructor of CEnumRfc1766 0x%08x"), this);
  287. dwMimeSource = dwSource;
  288. DllAddRef();
  289. _cRef = 1;
  290. _uCur = 0;
  291. }
  292. CEnumRfc1766::~CEnumRfc1766()
  293. {
  294. DebugMsg(DM_TRACE, TEXT("destructor of CEnumRfc1766 0x%08x"), this);
  295. DllRelease();
  296. }
  297. STDAPI CEnumRfc1766::QueryInterface(REFIID riid, void **ppvObj)
  298. {
  299. DebugMsg(DM_TRACE, TEXT("CEnumRfc1766::QueryInterface called."));
  300. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IEnumRfc1766))
  301. {
  302. *ppvObj = SAFECAST(this, IEnumRfc1766*);
  303. AddRef();
  304. return NOERROR;
  305. }
  306. *ppvObj = NULL;
  307. return E_NOINTERFACE;
  308. }
  309. STDAPI_(ULONG) CEnumRfc1766::AddRef()
  310. {
  311. _cRef++;
  312. DebugMsg(DM_TRACE, TEXT("CEnumRfc1766::AddRef called. _cRef=%d"), _cRef);
  313. return _cRef;
  314. }
  315. STDAPI_(ULONG) CEnumRfc1766::Release()
  316. {
  317. _cRef--;
  318. DebugMsg(DM_TRACE, TEXT("CEnumRfc1766::Release called. _cRef=%d"), _cRef);
  319. if (0 < _cRef)
  320. return _cRef;
  321. delete this;
  322. return 0;
  323. }
  324. STDAPI CEnumRfc1766::Clone(IEnumRfc1766 **ppEnumRfc1766)
  325. {
  326. DebugMsg(DM_TRACE, TEXT("CEnumRfc1766::Clone called."));
  327. return E_NOTIMPL;
  328. }
  329. STDAPI CEnumRfc1766::Next(ULONG celt, PRFC1766INFO rgRfc1766Info, ULONG *pceltFetched)
  330. {
  331. DebugMsg(DM_TRACE, TEXT("CEnumRfc1766::Next called."));
  332. if (g_pMimeDatabaseReg && (dwMimeSource & MIMECONTF_MIME_REGISTRY))
  333. {
  334. g_pMimeDatabaseReg->EnsureRfc1766Table();
  335. if (NULL != g_pRfc1766Reg && NULL != rgRfc1766Info)
  336. {
  337. UINT cNum = 0;
  338. while (cNum < celt)
  339. {
  340. if (_uCur < g_cRfc1766)
  341. {
  342. (rgRfc1766Info + cNum)->lcid = g_pRfc1766Reg[_uCur].lcid;
  343. MultiByteToWideChar(CP_ACP, 0, g_pRfc1766Reg[_uCur].szRfc1766, -1, (rgRfc1766Info + cNum)->wszRfc1766, MAX_RFC1766_NAME);
  344. (rgRfc1766Info + cNum)->wszRfc1766[MAX_RFC1766_NAME-1] = 0;
  345. MultiByteToWideChar(CP_ACP, 0, g_pRfc1766Reg[_uCur].szLocaleName, -1, (rgRfc1766Info + cNum)->wszLocaleName, MAX_LOCALE_NAME);
  346. (rgRfc1766Info + cNum)->wszLocaleName[MAX_LOCALE_NAME-1] = 0;
  347. cNum++;
  348. _uCur++;
  349. }
  350. else
  351. break;
  352. }
  353. if (NULL != pceltFetched)
  354. *pceltFetched = cNum;
  355. return (0 < cNum)? S_OK: S_FALSE;
  356. }
  357. else
  358. return E_FAIL;
  359. }
  360. if (NULL != rgRfc1766Info)
  361. {
  362. UINT cNum = 0;
  363. while (cNum < celt)
  364. {
  365. if (_uCur < g_cRfc1766)
  366. {
  367. (rgRfc1766Info + cNum)->lcid = MimeRfc1766[_uCur].LcId;
  368. MLStrCpyNW((rgRfc1766Info + cNum)->wszRfc1766, MimeRfc1766[_uCur].szRfc1766, MAX_RFC1766_NAME);
  369. (rgRfc1766Info + cNum)->wszRfc1766[MAX_RFC1766_NAME-1] = 0;
  370. if (!_LoadStringExW(g_hInst, MimeRfc1766[_uCur].uidLCID, (rgRfc1766Info + cNum)->wszLocaleName,
  371. MAX_LOCALE_NAME, _LangID))
  372. {
  373. // Last try, switch to English, US
  374. if (!_LoadStringExW(g_hInst, MimeRfc1766[_uCur].uidLCID, (rgRfc1766Info + cNum)->wszLocaleName,
  375. MAX_LOCALE_NAME, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)))
  376. (rgRfc1766Info + cNum)->wszLocaleName[0] = 0x0000;
  377. }
  378. (rgRfc1766Info + cNum)->wszLocaleName[MAX_LOCALE_NAME-1] = 0;
  379. cNum++;
  380. _uCur++;
  381. }
  382. else
  383. break;
  384. }
  385. if (NULL != pceltFetched)
  386. *pceltFetched = cNum;
  387. return (0 < cNum)? S_OK: S_FALSE;
  388. }
  389. else
  390. return E_FAIL;
  391. }
  392. STDAPI CEnumRfc1766::Reset()
  393. {
  394. DebugMsg(DM_TRACE, TEXT("CEnumRfc1766::Reset called."));
  395. _uCur = 0;
  396. return NOERROR;
  397. }
  398. STDAPI CEnumRfc1766::Skip(ULONG celt)
  399. {
  400. DebugMsg(DM_TRACE, TEXT("CEnumRfc1766::Skip called."));
  401. _uCur += celt;
  402. return NOERROR;
  403. }
  404. //
  405. // CEnumScript implementation
  406. //
  407. CEnumScript::CEnumScript(DWORD grfFlags, LANGID LangId, MIMECONTF dwSource) : _dwLevel(grfFlags), _LangId( LangId)
  408. {
  409. DebugMsg(DM_TRACE, TEXT("constructor of CEnumScript 0x%08x"), this);
  410. DllAddRef();
  411. _cRef = 1;
  412. _uCur = 0;
  413. }
  414. CEnumScript::~CEnumScript()
  415. {
  416. DebugMsg(DM_TRACE, TEXT("destructor of CEnumScript 0x%08x"), this);
  417. DllRelease();
  418. }
  419. STDAPI CEnumScript::QueryInterface(REFIID riid, void **ppvObj)
  420. {
  421. DebugMsg(DM_TRACE, TEXT("CEnumScript::QueryInterface called."));
  422. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IEnumScript))
  423. {
  424. *ppvObj = SAFECAST(this, IEnumScript*);
  425. AddRef();
  426. return NOERROR;
  427. }
  428. *ppvObj = NULL;
  429. return E_NOINTERFACE;
  430. }
  431. STDAPI_(ULONG) CEnumScript::AddRef()
  432. {
  433. _cRef++;
  434. DebugMsg(DM_TRACE, TEXT("CEnumScript::AddRef called. _cRef=%d"), _cRef);
  435. return _cRef;
  436. }
  437. STDAPI_(ULONG) CEnumScript::Release()
  438. {
  439. _cRef--;
  440. DebugMsg(DM_TRACE, TEXT("CEnumScript::Release called. _cRef=%d"), _cRef);
  441. if (0 < _cRef)
  442. return _cRef;
  443. delete this;
  444. return 0;
  445. }
  446. STDAPI CEnumScript::Clone(IEnumScript **ppEnumScript)
  447. {
  448. DebugMsg(DM_TRACE, TEXT("CEnumScript::Clone called."));
  449. return E_NOTIMPL;
  450. }
  451. STDAPI CEnumScript::Next(ULONG celt, PSCRIPTINFO rgScriptInfo, ULONG *pceltFetched)
  452. {
  453. DebugMsg(DM_TRACE, TEXT("CEnumScript::Next called."));
  454. if (!_dwLevel)
  455. _dwLevel = ~0;
  456. if (NULL != rgScriptInfo)
  457. {
  458. UINT cNum = 0;
  459. LANGID LangId = _LangId;
  460. while (cNum < celt)
  461. {
  462. if (_uCur < g_cScript)
  463. {
  464. if (!(ScriptTable[_uCur].dwFlags & _dwLevel))
  465. {
  466. _uCur++;
  467. continue;
  468. }
  469. (rgScriptInfo + cNum)->ScriptId = ScriptTable[_uCur].sid;
  470. (rgScriptInfo + cNum)->uiCodePage = ScriptTable[_uCur].uiCodePage;
  471. (rgScriptInfo + cNum)->wszDescription[0] = 0x0000;
  472. if (!_LoadStringExW(g_hInst, ScriptTable[_uCur].uidDescription, (rgScriptInfo + cNum)->wszDescription,
  473. MAX_SCRIPT_NAME, LangId))
  474. {
  475. // Last try, switch to English, US
  476. LangId = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
  477. _LoadStringExW(g_hInst, ScriptTable[_uCur].uidDescription, (rgScriptInfo + cNum)->wszDescription,
  478. MAX_SCRIPT_NAME, LangId);
  479. }
  480. (rgScriptInfo + cNum)->wszFixedWidthFont[0] = 0x0000;
  481. if (ScriptTable[_uCur].uidFixedWidthFont)
  482. {
  483. _LoadStringExW(g_hInst, ScriptTable[_uCur].uidFixedWidthFont, (rgScriptInfo + cNum)->wszFixedWidthFont,
  484. MAX_MIMEFACE_NAME, LangId);
  485. }
  486. (rgScriptInfo + cNum)->wszProportionalFont[0] = 0x0000;
  487. if (ScriptTable[_uCur].uidProportionalFont)
  488. {
  489. _LoadStringExW(g_hInst, ScriptTable[_uCur].uidProportionalFont, (rgScriptInfo + cNum)->wszProportionalFont,
  490. MAX_MIMEFACE_NAME, LangId);
  491. }
  492. cNum++;
  493. _uCur++;
  494. }
  495. else
  496. break;
  497. }
  498. if (NULL != pceltFetched)
  499. *pceltFetched = cNum;
  500. return (0 < cNum)? S_OK: S_FALSE;
  501. }
  502. else
  503. return E_FAIL;
  504. }
  505. STDAPI CEnumScript::Reset()
  506. {
  507. DebugMsg(DM_TRACE, TEXT("CEnumScript::Reset called."));
  508. _uCur = 0;
  509. return NOERROR;
  510. }
  511. STDAPI CEnumScript::Skip(ULONG celt)
  512. {
  513. DebugMsg(DM_TRACE, TEXT("CEnumScript::Skip called."));
  514. _uCur += celt;
  515. return NOERROR;
  516. }