4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2003,2004 Mike McCormack
6 * Copyright 2004 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(mlang);
46 #define CP_UNICODE 1200
48 #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
50 static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj);
53 * Under what circumstances HKEY_CLASSES_ROOT\MIME\Database\Codepage and
54 * HKEY_CLASSES_ROOT\MIME\Database\Charset are used?
61 const char *web_charset;
62 const char *header_charset;
63 const char *body_charset;
66 /* These data are based on the codepage info in libs/unicode/cpmap.pl */
67 /* FIXME: Add 28604 (Celtic), 28606 (Balkan) */
69 static const MIME_CP_INFO arabic_cp[] =
71 { 864, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
72 MIMECONTF_MIME_LATEST,
73 "ibm864", "ibm864", "ibm864" },
74 { 1006, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
75 MIMECONTF_MIME_LATEST,
76 "ibm1006", "ibm1006", "ibm1006" },
77 { 1256, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
78 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
79 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
80 "windows-1256", "windows-1256", "windows-1256" },
81 { 28596, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
82 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
83 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
84 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
85 "iso-8859-6", "iso-8859-6", "iso-8859-6" }
87 static const MIME_CP_INFO baltic_cp[] =
89 { 775, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
90 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
91 "ibm775", "ibm775", "ibm775" },
92 { 1257, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
93 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
94 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
95 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
96 "windows-1257", "windows-1257", "windows-1257" },
97 { 28594, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
98 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
99 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
100 MIMECONTF_MIME_LATEST,
101 "iso-8859-4", "iso-8859-4", "iso-8859-4" },
102 { 28603, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
103 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
104 "iso-8859-13", "iso-8859-13", "iso-8859-13" }
106 static const MIME_CP_INFO chinese_simplified_cp[] =
108 { 936, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
109 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
110 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
111 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
112 "gb2312", "gb2312", "gb2312" }
114 static const MIME_CP_INFO chinese_traditional_cp[] =
116 { 950, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
117 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
118 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
119 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
120 "big5", "big5", "big5" }
122 static const MIME_CP_INFO central_european_cp[] =
124 { 852, MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER |
125 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
126 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
127 "ibm852", "ibm852", "ibm852" },
128 { 1250, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
129 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
130 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
131 MIMECONTF_MIME_LATEST,
132 "windows-1250", "windows-1250", "windows-1250" },
133 { 10029, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
134 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
135 "x-mac-ce", "x-mac-ce", "x-mac-ce" },
136 { 28592, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
137 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
138 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
139 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
140 "iso-8859-2", "iso-8859-2", "iso-8859-2" }
142 static const MIME_CP_INFO cyrillic_cp[] =
144 { 855, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
145 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
146 "ibm855", "ibm855", "ibm855" },
147 { 866, MIMECONTF_BROWSER | MIMECONTF_IMPORT | MIMECONTF_SAVABLE_BROWSER |
148 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
149 MIMECONTF_MIME_LATEST,
150 "cp866", "cp866", "cp866" },
151 #if 0 /* Windows has 20866 as an official code page for KOI8-R */
152 { 878, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
153 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
154 "koi8-r", "koi8-r", "koi8-r" },
156 { 1251, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
157 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
158 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
159 "windows-1251", "windows-1251", "windows-1251" },
160 { 10007, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
161 MIMECONTF_MIME_LATEST,
162 "x-mac-cyrillic", "x-mac-cyrillic", "x-mac-cyrillic" },
163 { 20866, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
164 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
165 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
166 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
167 "koi8-r", "koi8-r", "koi8-r" },
168 { 28595, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
169 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
170 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
171 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
172 "iso-8859-5", "iso-8859-5", "iso-8859-5" }
174 static const MIME_CP_INFO greek_cp[] =
176 { 737, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
177 MIMECONTF_MIME_LATEST,
178 "ibm737", "ibm737", "ibm737" },
179 { 869, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
180 MIMECONTF_MIME_LATEST,
181 "ibm869", "ibm869", "ibm869" },
182 { 875, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
183 MIMECONTF_MIME_LATEST,
184 "cp875", "cp875", "cp875" },
185 { 1253, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
186 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
187 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
188 "windows-1253", "windows-1253", "windows-1253" },
189 { 10006, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
190 MIMECONTF_MIME_LATEST,
191 "x-mac-greek", "x-mac-greek", "x-mac-greek" },
192 { 28597, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
193 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
194 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
195 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
196 "iso-8859-7", "iso-8859-7", "iso-8859-7" }
198 static const MIME_CP_INFO hebrew_cp[] =
200 { 424, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
201 MIMECONTF_MIME_LATEST,
202 "ibm424", "ibm424", "ibm424" },
203 { 856, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
204 MIMECONTF_MIME_LATEST,
205 "cp856", "cp856", "cp856" },
206 { 862, MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
207 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
208 MIMECONTF_MIME_LATEST,
209 "dos-862", "dos-862", "dos-862" },
210 { 1255, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
211 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
212 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
213 "windows-1255", "windows-1255", "windows-1255" },
214 { 28598, MIMECONTF_BROWSER | MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
215 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
216 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
217 "iso-8859-8", "iso-8859-8", "iso-8859-8" }
219 static const MIME_CP_INFO japanese_cp[] =
221 { 932, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
222 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
223 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
224 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
225 "shift_jis", "iso-2022-jp", "iso-2022-jp" },
226 { 20932, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
227 MIMECONTF_MIME_LATEST,
228 "euc-jp", "euc-jp", "euc-jp" }
230 static const MIME_CP_INFO korean_cp[] =
232 { 949, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
233 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
234 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID_NLS |
235 MIMECONTF_MIME_LATEST,
236 "ks_c_5601-1987", "ks_c_5601-1987", "ks_c_5601-1987" }
238 static const MIME_CP_INFO thai_cp[] =
240 { 874, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_MIME_LATEST,
241 "ibm-thai", "ibm-thai", "ibm-thai" }
243 static const MIME_CP_INFO turkish_cp[] =
245 { 857, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
246 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
247 "ibm857", "ibm857", "ibm857" },
248 { 1026, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
249 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
250 "ibm1026", "ibm1026", "ibm1026" },
251 { 1254, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
252 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
253 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
254 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
255 "windows-1254", "windows-1254", "windows-1254" },
256 { 10081, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
257 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
258 "x-mac-turkish", "x-mac-turkish", "x-mac-turkish" },
259 { 28593, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
260 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_VALID |
261 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
262 "iso-8859-3", "iso-8859-3", "iso-8859-3" },
263 { 28599, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
264 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
265 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
266 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
267 "iso-8859-9", "iso-8859-9", "iso-8859-9" }
269 static const MIME_CP_INFO vietnamese_cp[] =
271 { 1258, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
272 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
273 MIMECONTF_EXPORT | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
274 MIMECONTF_MIME_LATEST,
275 "windows-1258", "windows-1258", "windows-1258" }
277 static const MIME_CP_INFO western_cp[] =
279 { 37, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
280 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
281 "ibm037", "ibm037", "ibm037" },
282 { 437, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
283 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
284 "ibm437", "ibm437", "ibm437" },
285 { 500, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
286 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
287 "ibm500", "ibm500", "ibm500" },
288 { 850, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
289 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
290 "ibm850", "ibm850", "ibm850" },
291 { 860, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
292 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
293 "ibm860", "ibm860", "ibm860" },
294 { 861, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
295 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
296 "ibm861", "ibm861", "ibm861" },
297 { 863, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
298 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
299 "ibm863", "ibm863", "ibm863" },
300 { 865, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
301 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
302 "ibm865", "ibm865", "ibm865" },
303 { 1252, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_MINIMAL |
304 MIMECONTF_IMPORT | MIMECONTF_SAVABLE_MAILNEWS |
305 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT | MIMECONTF_VALID |
306 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
307 "windows-1252", "windows-1252", "iso-8859-1" },
308 { 10000, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
309 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
310 "macintosh", "macintosh", "macintosh" },
311 { 10079, MIMECONTF_IMPORT | MIMECONTF_EXPORT | MIMECONTF_VALID |
312 MIMECONTF_VALID_NLS | MIMECONTF_MIME_LATEST,
313 "x-mac-icelandic", "x-mac-icelandic", "x-mac-icelandic" },
314 { 28591, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
315 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
316 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
317 MIMECONTF_MIME_LATEST,
318 "iso-8859-1", "iso-8859-1", "iso-8859-1" },
319 { 28605, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
320 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
321 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
322 MIMECONTF_MIME_LATEST,
323 "iso-8859-15", "iso-8859-15", "iso-8859-15" }
325 static const MIME_CP_INFO unicode_cp[] =
327 { CP_UNICODE, MIMECONTF_MINIMAL | MIMECONTF_IMPORT |
328 MIMECONTF_SAVABLE_BROWSER | MIMECONTF_EXPORT |
329 MIMECONTF_VALID | MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 |
330 MIMECONTF_MIME_LATEST,
331 "unicode", "unicode", "unicode" },
332 { CP_UTF7, MIMECONTF_MAILNEWS | MIMECONTF_IMPORT |
333 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_EXPORT | MIMECONTF_VALID |
334 MIMECONTF_VALID_NLS | MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
335 "utf-7", "utf-7", "utf-7" },
336 { CP_UTF8, MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_IMPORT |
337 MIMECONTF_SAVABLE_MAILNEWS | MIMECONTF_SAVABLE_BROWSER |
338 MIMECONTF_EXPORT | MIMECONTF_VALID | MIMECONTF_VALID_NLS |
339 MIMECONTF_MIME_IE4 | MIMECONTF_MIME_LATEST,
340 "utf-8", "utf-8", "utf-8" }
343 static const struct mlang_data
345 const char *description;
346 UINT family_codepage;
348 const MIME_CP_INFO *mime_cp_info;
349 const char *fixed_font;
350 const char *proportional_font;
353 { "Arabic",1256,sizeof(arabic_cp)/sizeof(arabic_cp[0]),arabic_cp,
354 "Courier","Arial" }, /* FIXME */
355 { "Baltic",1257,sizeof(baltic_cp)/sizeof(baltic_cp[0]),baltic_cp,
356 "Courier","Arial" }, /* FIXME */
357 { "Chinese Simplified",936,sizeof(chinese_simplified_cp)/sizeof(chinese_simplified_cp[0]),chinese_simplified_cp,
358 "Courier","Arial" }, /* FIXME */
359 { "Chinese Traditional",950,sizeof(chinese_traditional_cp)/sizeof(chinese_traditional_cp[0]),chinese_traditional_cp,
360 "Courier","Arial" }, /* FIXME */
361 { "Central European",1250,sizeof(central_european_cp)/sizeof(central_european_cp[0]),central_european_cp,
362 "Courier","Arial" }, /* FIXME */
363 { "Cyrillic",1251,sizeof(cyrillic_cp)/sizeof(cyrillic_cp[0]),cyrillic_cp,
364 "Courier","Arial" }, /* FIXME */
365 { "Greek",1253,sizeof(greek_cp)/sizeof(greek_cp[0]),greek_cp,
366 "Courier","Arial" }, /* FIXME */
367 { "Hebrew",1255,sizeof(hebrew_cp)/sizeof(hebrew_cp[0]),hebrew_cp,
368 "Courier","Arial" }, /* FIXME */
369 { "Japanese",932,sizeof(japanese_cp)/sizeof(japanese_cp[0]),japanese_cp,
370 "Courier","Arial" }, /* FIXME */
371 { "Korean",949,sizeof(korean_cp)/sizeof(korean_cp[0]),korean_cp,
372 "Courier","Arial" }, /* FIXME */
373 { "Thai",874,sizeof(thai_cp)/sizeof(thai_cp[0]),thai_cp,
374 "Courier","Arial" }, /* FIXME */
375 { "Turkish",1254,sizeof(turkish_cp)/sizeof(turkish_cp[0]),turkish_cp,
376 "Courier","Arial" }, /* FIXME */
377 { "Vietnamese",1258,sizeof(vietnamese_cp)/sizeof(vietnamese_cp[0]),vietnamese_cp,
378 "Courier","Arial" }, /* FIXME */
379 { "Western European",1252,sizeof(western_cp)/sizeof(western_cp[0]),western_cp,
380 "Courier","Arial" }, /* FIXME */
381 { "Unicode",CP_UNICODE,sizeof(unicode_cp)/sizeof(unicode_cp[0]),unicode_cp,
382 "Courier","Arial" } /* FIXME */
385 static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info);
387 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
390 case DLL_PROCESS_ATTACH:
391 DisableThreadLibraryCalls(hInstDLL);
393 case DLL_PROCESS_DETACH:
399 HRESULT WINAPI ConvertINetMultiByteToUnicode(
409 TRACE("%p %ld %s %p %p %p\n", pdwMode, dwEncoding,
410 debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
416 pcSrcSize = &src_len;
427 if (*pcSrcSize == -1)
428 *pcSrcSize = lstrlenW((LPCWSTR)pSrcStr);
429 *pcDstSize = min(*pcSrcSize, *pcDstSize);
430 *pcSrcSize *= sizeof(WCHAR);
432 memmove(pDstStr, pSrcStr, *pcDstSize * sizeof(WCHAR));
436 if (*pcSrcSize == -1)
437 *pcSrcSize = lstrlenA(pSrcStr);
440 *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize);
442 *pcDstSize = MultiByteToWideChar(dwEncoding, 0, pSrcStr, *pcSrcSize, NULL, 0);
452 HRESULT WINAPI ConvertINetUnicodeToMultiByte(
463 TRACE("%p %ld %s %p %p %p\n", pdwMode, dwEncoding,
464 debugstr_w(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
470 pcSrcSize = &src_len;
481 if (*pcSrcSize == -1)
482 *pcSrcSize = lstrlenW(pSrcStr);
483 *pcDstSize = min(*pcSrcSize * sizeof(WCHAR), *pcDstSize);
485 memmove(pDstStr, pSrcStr, *pcDstSize);
489 if (*pcSrcSize == -1)
490 *pcSrcSize = lstrlenW(pSrcStr);
493 *pcDstSize = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize, pDstStr, *pcDstSize, NULL, NULL);
495 *pcDstSize = WideCharToMultiByte(dwEncoding, 0, pSrcStr, *pcSrcSize, NULL, 0, NULL, NULL);
506 HRESULT WINAPI ConvertINetString(
516 FIXME("%p %ld %ld %s %p %p %p: stub!\n", pdwMode, dwSrcEncoding, dwDstEncoding,
517 debugstr_a(pSrcStr), pcSrcSize, pDstStr, pcDstSize);
521 static HRESULT GetFamilyCodePage(
523 UINT* puiFamilyCodePage)
527 TRACE("%u %p\n", uiCodePage, puiFamilyCodePage);
529 if (!puiFamilyCodePage) return S_FALSE;
531 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
533 for (n = 0; n < mlang_data[i].number_of_cp; n++)
535 if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
537 *puiFamilyCodePage = mlang_data[i].family_codepage;
546 HRESULT WINAPI IsConvertINetStringAvailable(
550 UINT src_family, dst_family;
552 TRACE("%ld %ld\n", dwSrcEncoding, dwDstEncoding);
554 if (GetFamilyCodePage(dwSrcEncoding, &src_family) != S_OK ||
555 GetFamilyCodePage(dwDstEncoding, &dst_family) != S_OK)
558 if (src_family == dst_family) return S_OK;
560 /* we can convert any codepage to/from unicode */
561 if (src_family == CP_UNICODE || dst_family == CP_UNICODE) return S_OK;
566 HRESULT WINAPI LcidToRfc1766A(
571 FIXME("%ld %s %u\n", Locale, pszRfc1766, nChar);
575 HRESULT WINAPI LcidToRfc1766W(
580 FIXME("%ld %p %u\n", Locale, pszRfc1766, nChar);
584 /******************************************************************************
588 IClassFactory ITF_IClassFactory;
591 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
594 struct object_creation_info
598 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
601 static const struct object_creation_info object_creation[] =
603 { &CLSID_CMultiLanguage, "CLSID_CMultiLanguage", MultiLanguage_create },
606 static HRESULT WINAPI
607 MLANGCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
609 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
611 TRACE("%s\n", debugstr_guid(riid) );
613 if (IsEqualGUID(riid, &IID_IUnknown)
614 || IsEqualGUID(riid, &IID_IClassFactory))
616 IClassFactory_AddRef(iface);
621 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
622 return E_NOINTERFACE;
625 static ULONG WINAPI MLANGCF_AddRef(LPCLASSFACTORY iface) {
626 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
627 return InterlockedIncrement(&This->ref);
630 static ULONG WINAPI MLANGCF_Release(LPCLASSFACTORY iface) {
631 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
633 ULONG ref = InterlockedDecrement(&This->ref);
637 TRACE("Destroying %p\n", This);
638 HeapFree(GetProcessHeap(), 0, This);
644 static HRESULT WINAPI MLANGCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
645 REFIID riid, LPVOID *ppobj) {
646 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
650 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
652 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
657 hres = IUnknown_QueryInterface(punk, riid, ppobj);
662 IUnknown_Release(punk);
663 TRACE("returning (%p) -> %lx\n", *ppobj, hres);
667 static HRESULT WINAPI MLANGCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
668 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
669 FIXME("(%p)->(%d),stub!\n",This,dolock);
673 static IClassFactoryVtbl MLANGCF_Vtbl =
675 MLANGCF_QueryInterface,
678 MLANGCF_CreateInstance,
682 HRESULT WINAPI MLANG_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
685 IClassFactoryImpl *factory;
687 TRACE("%s %s %p\n",debugstr_guid(rclsid), debugstr_guid(iid), ppv);
689 if ( !IsEqualGUID( &IID_IClassFactory, iid )
690 && ! IsEqualGUID( &IID_IUnknown, iid) )
691 return E_NOINTERFACE;
693 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
695 if (IsEqualGUID(object_creation[i].clsid, rclsid))
699 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
701 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
702 return CLASS_E_CLASSNOTAVAILABLE;
705 TRACE("Creating a class factory for %s\n",object_creation[i].szClassName);
707 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
708 if (factory == NULL) return E_OUTOFMEMORY;
710 factory->ITF_IClassFactory.lpVtbl = &MLANGCF_Vtbl;
713 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
715 *ppv = &(factory->ITF_IClassFactory);
717 TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
723 /******************************************************************************/
725 typedef struct tagMLang_impl
727 IMLangFontLinkVtbl *vtbl_IMLangFontLink;
728 IMultiLanguageVtbl *vtbl_IMultiLanguage;
729 IMultiLanguage2Vtbl *vtbl_IMultiLanguage2;
731 DWORD total_cp, total_scripts;
734 static ULONG WINAPI MLang_AddRef( MLang_impl* This)
736 return InterlockedIncrement(&This->ref);
739 static ULONG WINAPI MLang_Release( MLang_impl* This )
741 ULONG ref = InterlockedDecrement(&This->ref);
743 TRACE("%p ref = %ld\n", This, ref);
746 TRACE("Destroying %p\n", This);
747 HeapFree(GetProcessHeap(), 0, This);
753 static HRESULT WINAPI MLang_QueryInterface(
758 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
760 if (IsEqualGUID(riid, &IID_IUnknown)
761 || IsEqualGUID(riid, &IID_IMLangCodePages)
762 || IsEqualGUID(riid, &IID_IMLangFontLink))
765 TRACE("Returning IID_IMLangFontLink %p ref = %ld\n", This, This->ref);
766 *ppvObject = &(This->vtbl_IMLangFontLink);
770 if (IsEqualGUID(riid, &IID_IMultiLanguage) )
773 TRACE("Returning IID_IMultiLanguage %p ref = %ld\n", This, This->ref);
774 *ppvObject = &(This->vtbl_IMultiLanguage);
778 if (IsEqualGUID(riid, &IID_IMultiLanguage2) )
781 *ppvObject = &(This->vtbl_IMultiLanguage2);
782 TRACE("Returning IID_IMultiLanguage2 %p ref = %ld\n", This, This->ref);
786 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
787 return E_NOINTERFACE;
790 /******************************************************************************/
792 typedef struct tagEnumCodePage_impl
794 IEnumCodePageVtbl *vtbl_IEnumCodePage;
800 static HRESULT WINAPI fnIEnumCodePage_QueryInterface(
801 IEnumCodePage* iface,
805 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
807 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
809 if (IsEqualGUID(riid, &IID_IUnknown)
810 || IsEqualGUID(riid, &IID_IEnumCodePage))
812 IEnumCodePage_AddRef(iface);
813 TRACE("Returning IID_IEnumCodePage %p ref = %ld\n", This, This->ref);
814 *ppvObject = &(This->vtbl_IEnumCodePage);
818 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
819 return E_NOINTERFACE;
822 static ULONG WINAPI fnIEnumCodePage_AddRef(
823 IEnumCodePage* iface)
825 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
826 return InterlockedIncrement(&This->ref);
829 static ULONG WINAPI fnIEnumCodePage_Release(
830 IEnumCodePage* iface)
832 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
833 ULONG ref = InterlockedDecrement(&This->ref);
835 TRACE("%p ref = %ld\n", This, ref);
838 TRACE("Destroying %p\n", This);
839 HeapFree(GetProcessHeap(), 0, This->cpinfo);
840 HeapFree(GetProcessHeap(), 0, This);
846 static HRESULT WINAPI fnIEnumCodePage_Clone(
847 IEnumCodePage* iface,
848 IEnumCodePage** ppEnum)
850 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
851 FIXME("%p %p\n", This, ppEnum);
855 static HRESULT WINAPI fnIEnumCodePage_Next(
856 IEnumCodePage* iface,
863 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
864 TRACE("%p %lu %p %p\n", This, celt, rgelt, pceltFetched);
866 if (!pceltFetched) return S_FALSE;
869 if (!rgelt) return S_FALSE;
871 if (This->pos + celt > This->total)
872 celt = This->total - This->pos;
874 if (!celt) return S_FALSE;
876 memcpy(rgelt, This->cpinfo + This->pos, celt * sizeof(MIMECPINFO));
877 *pceltFetched = celt;
880 for (i = 0; i < celt; i++)
882 TRACE("#%lu: %08lx %u %u %s %s %s %s %s %s %d\n",
883 i, rgelt[i].dwFlags, rgelt[i].uiCodePage,
884 rgelt[i].uiFamilyCodePage,
885 wine_dbgstr_w(rgelt[i].wszDescription),
886 wine_dbgstr_w(rgelt[i].wszWebCharset),
887 wine_dbgstr_w(rgelt[i].wszHeaderCharset),
888 wine_dbgstr_w(rgelt[i].wszBodyCharset),
889 wine_dbgstr_w(rgelt[i].wszFixedWidthFont),
890 wine_dbgstr_w(rgelt[i].wszProportionalFont),
891 rgelt[i].bGDICharset);
896 static HRESULT WINAPI fnIEnumCodePage_Reset(
897 IEnumCodePage* iface)
899 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
906 static HRESULT WINAPI fnIEnumCodePage_Skip(
907 IEnumCodePage* iface,
910 ICOM_THIS_MULTI(EnumCodePage_impl, vtbl_IEnumCodePage, iface);
911 TRACE("%p %lu\n", This, celt);
913 if (celt >= This->total) return S_FALSE;
915 This->pos = celt; /* FIXME: should be += ?? */
919 static IEnumCodePageVtbl IEnumCodePage_vtbl =
921 fnIEnumCodePage_QueryInterface,
922 fnIEnumCodePage_AddRef,
923 fnIEnumCodePage_Release,
924 fnIEnumCodePage_Clone,
925 fnIEnumCodePage_Next,
926 fnIEnumCodePage_Reset,
930 static HRESULT EnumCodePage_create( MLang_impl* mlang, DWORD grfFlags,
931 LANGID LangId, IEnumCodePage** ppEnumCodePage )
933 EnumCodePage_impl *ecp;
937 TRACE("%p, %08lx, %04x, %p\n", mlang, grfFlags, LangId, ppEnumCodePage);
939 if (!grfFlags) /* enumerate internal data base of encodings */
940 grfFlags = MIMECONTF_MIME_LATEST;
942 ecp = HeapAlloc( GetProcessHeap(), 0, sizeof (EnumCodePage_impl) );
943 ecp->vtbl_IEnumCodePage = &IEnumCodePage_vtbl;
947 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
949 for (n = 0; n < mlang_data[i].number_of_cp; n++)
951 if (mlang_data[i].mime_cp_info[n].flags & grfFlags)
956 ecp->cpinfo = HeapAlloc(GetProcessHeap(), 0,
957 sizeof(MIMECPINFO) * ecp->total);
958 cpinfo = ecp->cpinfo;
960 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
962 for (n = 0; n < mlang_data[i].number_of_cp; n++)
964 if (mlang_data[i].mime_cp_info[n].flags & grfFlags)
965 fill_cp_info(&mlang_data[i], n, cpinfo++);
969 TRACE("enumerated %ld codepages with flags %08lx\n", ecp->total, grfFlags);
971 *ppEnumCodePage = (IEnumCodePage*) ecp;
976 /******************************************************************************/
978 typedef struct tagEnumScript_impl
980 IEnumScriptVtbl *vtbl_IEnumScript;
982 SCRIPTINFO *script_info;
986 static HRESULT WINAPI fnIEnumScript_QueryInterface(
991 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
993 TRACE("%p -> %s\n", This, debugstr_guid(riid) );
995 if (IsEqualGUID(riid, &IID_IUnknown)
996 || IsEqualGUID(riid, &IID_IEnumScript))
998 IEnumScript_AddRef(iface);
999 TRACE("Returning IID_IEnumScript %p ref = %ld\n", This, This->ref);
1000 *ppvObject = &(This->vtbl_IEnumScript);
1004 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
1005 return E_NOINTERFACE;
1008 static ULONG WINAPI fnIEnumScript_AddRef(
1011 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1012 return InterlockedIncrement(&This->ref);
1015 static ULONG WINAPI fnIEnumScript_Release(
1018 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1019 ULONG ref = InterlockedDecrement(&This->ref);
1021 TRACE("%p ref = %ld\n", This, ref);
1024 TRACE("Destroying %p\n", This);
1025 HeapFree(GetProcessHeap(), 0, This);
1031 static HRESULT WINAPI fnIEnumScript_Clone(
1033 IEnumScript** ppEnum)
1035 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1036 FIXME("%p %p: stub!\n", This, ppEnum);
1040 static HRESULT WINAPI fnIEnumScript_Next(
1044 ULONG* pceltFetched)
1046 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1047 TRACE("%p %lu %p %p\n", This, celt, rgelt, pceltFetched);
1049 if (!pceltFetched || !rgelt) return E_FAIL;
1053 if (This->pos + celt > This->total)
1054 celt = This->total - This->pos;
1056 if (!celt) return S_FALSE;
1058 memcpy(rgelt, This->script_info + This->pos, celt * sizeof(SCRIPTINFO));
1059 *pceltFetched = celt;
1065 static HRESULT WINAPI fnIEnumScript_Reset(
1068 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1069 TRACE("%p\n", This);
1075 static HRESULT WINAPI fnIEnumScript_Skip(
1079 ICOM_THIS_MULTI(EnumScript_impl, vtbl_IEnumScript, iface);
1080 TRACE("%p %lu\n", This, celt);
1082 if (celt >= This->total) return S_FALSE;
1084 This->pos = celt; /* FIXME: should be += ?? */
1088 static IEnumScriptVtbl IEnumScript_vtbl =
1090 fnIEnumScript_QueryInterface,
1091 fnIEnumScript_AddRef,
1092 fnIEnumScript_Release,
1093 fnIEnumScript_Clone,
1095 fnIEnumScript_Reset,
1099 static HRESULT EnumScript_create( MLang_impl* mlang, DWORD dwFlags,
1100 LANGID LangId, IEnumScript** ppEnumScript )
1102 EnumScript_impl *es;
1105 TRACE("%p, %08lx, %04x, %p: stub!\n", mlang, dwFlags, LangId, ppEnumScript);
1107 if (!dwFlags) /* enumerate all available scripts */
1108 dwFlags = SCRIPTCONTF_SCRIPT_USER | SCRIPTCONTF_SCRIPT_HIDE | SCRIPTCONTF_SCRIPT_SYSTEM;
1110 es = HeapAlloc( GetProcessHeap(), 0, sizeof (EnumScript_impl) );
1111 es->vtbl_IEnumScript = &IEnumScript_vtbl;
1114 /* do not enumerate unicode flavours */
1115 es->total = sizeof(mlang_data)/sizeof(mlang_data[0]) - 1;
1116 es->script_info = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPTINFO) * es->total);
1118 for (i = 0; i < es->total; i++)
1120 es->script_info[i].ScriptId = i;
1121 es->script_info[i].uiCodePage = mlang_data[i].family_codepage;
1122 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].description, -1,
1123 es->script_info[i].wszDescription, MAX_SCRIPT_NAME);
1124 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].fixed_font, -1,
1125 es->script_info[i].wszFixedWidthFont, MAX_MIMEFACE_NAME);
1126 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].proportional_font, -1,
1127 es->script_info[i].wszProportionalFont, MAX_MIMEFACE_NAME);
1130 TRACE("enumerated %ld scripts with flags %08lx\n", es->total, dwFlags);
1132 *ppEnumScript = (IEnumScript *)es;
1137 /******************************************************************************/
1139 static HRESULT WINAPI fnIMLangFontLink_QueryInterface(
1140 IMLangFontLink* iface,
1144 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1145 return MLang_QueryInterface( This, riid, ppvObject );
1148 static ULONG WINAPI fnIMLangFontLink_AddRef(
1149 IMLangFontLink* iface)
1151 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1152 return MLang_AddRef( This );
1155 static ULONG WINAPI fnIMLangFontLink_Release(
1156 IMLangFontLink* iface)
1158 ICOM_THIS_MULTI(MLang_impl, vtbl_IMLangFontLink, iface);
1159 return MLang_Release( This );
1162 static HRESULT WINAPI fnIMLangFontLink_GetCharCodePages(
1163 IMLangFontLink* iface,
1165 DWORD* pdwCodePages)
1171 static HRESULT WINAPI fnIMLangFontLink_GetStrCodePages(
1172 IMLangFontLink* iface,
1173 const WCHAR* pszSrc,
1175 DWORD dwPriorityCodePages,
1176 DWORD* pdwCodePages,
1177 long* pcchCodePages)
1183 static HRESULT WINAPI fnIMLangFontLink_CodePageToCodePages(
1184 IMLangFontLink* iface,
1186 DWORD* pdwCodePages)
1192 static HRESULT WINAPI fnIMLangFontLink_CodePagesToCodePage(
1193 IMLangFontLink* iface,
1195 UINT uDefaultCodePage,
1202 static HRESULT WINAPI fnIMLangFontLink_GetFontCodePages(
1203 IMLangFontLink* iface,
1206 DWORD* pdwCodePages)
1212 static HRESULT WINAPI fnIMLangFontLink_MapFont(
1213 IMLangFontLink* iface,
1223 static HRESULT WINAPI fnIMLangFontLink_ReleaseFont(
1224 IMLangFontLink* iface,
1231 static HRESULT WINAPI fnIMLangFontLink_ResetFontMapping(
1232 IMLangFontLink* iface)
1239 static IMLangFontLinkVtbl IMLangFontLink_vtbl =
1241 fnIMLangFontLink_QueryInterface,
1242 fnIMLangFontLink_AddRef,
1243 fnIMLangFontLink_Release,
1244 fnIMLangFontLink_GetCharCodePages,
1245 fnIMLangFontLink_GetStrCodePages,
1246 fnIMLangFontLink_CodePageToCodePages,
1247 fnIMLangFontLink_CodePagesToCodePage,
1248 fnIMLangFontLink_GetFontCodePages,
1249 fnIMLangFontLink_MapFont,
1250 fnIMLangFontLink_ReleaseFont,
1251 fnIMLangFontLink_ResetFontMapping,
1254 /******************************************************************************/
1256 static HRESULT WINAPI fnIMultiLanguage_QueryInterface(
1257 IMultiLanguage* iface,
1261 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1262 return MLang_QueryInterface( This, riid, ppvObject );
1265 static ULONG WINAPI fnIMultiLanguage_AddRef( IMultiLanguage* iface )
1267 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1268 return IMLangFontLink_AddRef( ((IMLangFontLink*)This) );
1271 static ULONG WINAPI fnIMultiLanguage_Release( IMultiLanguage* iface )
1273 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1274 return IMLangFontLink_Release( ((IMLangFontLink*)This) );
1277 static HRESULT WINAPI fnIMultiLanguage_GetNumberOfCodePageInfo(
1278 IMultiLanguage* iface,
1285 static HRESULT WINAPI fnIMultiLanguage_GetCodePageInfo(
1286 IMultiLanguage* iface,
1288 PMIMECPINFO pCodePageInfo)
1294 static HRESULT WINAPI fnIMultiLanguage_GetFamilyCodePage(
1295 IMultiLanguage* iface,
1297 UINT* puiFamilyCodePage)
1299 return GetFamilyCodePage(uiCodePage, puiFamilyCodePage);
1302 static HRESULT WINAPI fnIMultiLanguage_EnumCodePages(
1303 IMultiLanguage* iface,
1305 IEnumCodePage** ppEnumCodePage)
1307 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage, iface);
1308 TRACE("%p %08lx %p\n", This, grfFlags, ppEnumCodePage);
1310 return EnumCodePage_create( This, grfFlags, 0, ppEnumCodePage );
1313 static HRESULT WINAPI fnIMultiLanguage_GetCharsetInfo(
1314 IMultiLanguage* iface,
1316 PMIMECSETINFO pCharsetInfo)
1322 static HRESULT WINAPI fnIMultiLanguage_IsConvertible(
1323 IMultiLanguage* iface,
1324 DWORD dwSrcEncoding,
1325 DWORD dwDstEncoding)
1327 return IsConvertINetStringAvailable(dwSrcEncoding, dwDstEncoding);
1330 static HRESULT WINAPI fnIMultiLanguage_ConvertString(
1331 IMultiLanguage* iface,
1333 DWORD dwSrcEncoding,
1334 DWORD dwDstEncoding,
1340 return ConvertINetString(pdwMode, dwSrcEncoding, dwDstEncoding,
1341 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1344 static HRESULT WINAPI fnIMultiLanguage_ConvertStringToUnicode(
1345 IMultiLanguage* iface,
1353 return ConvertINetMultiByteToUnicode(pdwMode, dwEncoding,
1354 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1357 static HRESULT WINAPI fnIMultiLanguage_ConvertStringFromUnicode(
1358 IMultiLanguage* iface,
1366 return ConvertINetUnicodeToMultiByte(pdwMode, dwEncoding,
1367 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1370 static HRESULT WINAPI fnIMultiLanguage_ConvertStringReset(
1371 IMultiLanguage* iface)
1377 static HRESULT WINAPI fnIMultiLanguage_GetRfc1766FromLcid(
1378 IMultiLanguage* iface,
1386 static HRESULT WINAPI fnIMultiLanguage_GetLcidFromRfc1766(
1387 IMultiLanguage* iface,
1395 static HRESULT WINAPI fnIMultiLanguage_EnumRfc1766(
1396 IMultiLanguage* iface,
1397 IEnumRfc1766** ppEnumRfc1766)
1403 static HRESULT WINAPI fnIMultiLanguage_GetRfc1766Info(
1404 IMultiLanguage* iface,
1406 PRFC1766INFO pRfc1766Info)
1412 static HRESULT WINAPI fnIMultiLanguage_CreateConvertCharset(
1413 IMultiLanguage* iface,
1417 IMLangConvertCharset** ppMLangConvertCharset)
1423 static IMultiLanguageVtbl IMultiLanguage_vtbl =
1425 fnIMultiLanguage_QueryInterface,
1426 fnIMultiLanguage_AddRef,
1427 fnIMultiLanguage_Release,
1428 fnIMultiLanguage_GetNumberOfCodePageInfo,
1429 fnIMultiLanguage_GetCodePageInfo,
1430 fnIMultiLanguage_GetFamilyCodePage,
1431 fnIMultiLanguage_EnumCodePages,
1432 fnIMultiLanguage_GetCharsetInfo,
1433 fnIMultiLanguage_IsConvertible,
1434 fnIMultiLanguage_ConvertString,
1435 fnIMultiLanguage_ConvertStringToUnicode,
1436 fnIMultiLanguage_ConvertStringFromUnicode,
1437 fnIMultiLanguage_ConvertStringReset,
1438 fnIMultiLanguage_GetRfc1766FromLcid,
1439 fnIMultiLanguage_GetLcidFromRfc1766,
1440 fnIMultiLanguage_EnumRfc1766,
1441 fnIMultiLanguage_GetRfc1766Info,
1442 fnIMultiLanguage_CreateConvertCharset,
1446 /******************************************************************************/
1448 static HRESULT WINAPI fnIMultiLanguage2_QueryInterface(
1449 IMultiLanguage2* iface,
1453 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1454 return MLang_QueryInterface( This, riid, ppvObject );
1457 static ULONG WINAPI fnIMultiLanguage2_AddRef( IMultiLanguage2* iface )
1459 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1460 return MLang_AddRef( This );
1463 static ULONG WINAPI fnIMultiLanguage2_Release( IMultiLanguage2* iface )
1465 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1466 return MLang_Release( This );
1469 static HRESULT WINAPI fnIMultiLanguage2_GetNumberOfCodePageInfo(
1470 IMultiLanguage2* iface,
1473 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1474 TRACE("%p, %p\n", This, pcCodePage);
1476 if (!pcCodePage) return S_FALSE;
1478 *pcCodePage = This->total_cp;
1482 static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINFO *mime_cp_info)
1487 if (TranslateCharsetInfo((DWORD *)ml_data->family_codepage, &csi, TCI_SRCCODEPAGE))
1488 mime_cp_info->bGDICharset = csi.ciCharset;
1490 mime_cp_info->bGDICharset = DEFAULT_CHARSET;
1492 if (!GetCPInfoExW(ml_data->mime_cp_info[index].cp, 0, &cpinfo))
1494 /* fall back to family codepage in the case of alias */
1495 if (!GetCPInfoExW(ml_data->family_codepage, 0, &cpinfo))
1496 cpinfo.CodePageName[0] = 0;
1499 mime_cp_info->dwFlags = ml_data->mime_cp_info[index].flags;
1500 mime_cp_info->uiCodePage = ml_data->mime_cp_info[index].cp;
1501 mime_cp_info->uiFamilyCodePage = ml_data->family_codepage;
1502 strcpyW(mime_cp_info->wszDescription, cpinfo.CodePageName);
1503 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].web_charset, -1,
1504 mime_cp_info->wszWebCharset, sizeof(mime_cp_info->wszWebCharset)/sizeof(WCHAR));
1505 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].header_charset, -1,
1506 mime_cp_info->wszHeaderCharset, sizeof(mime_cp_info->wszHeaderCharset)/sizeof(WCHAR));
1507 MultiByteToWideChar(CP_ACP, 0, ml_data->mime_cp_info[index].body_charset, -1,
1508 mime_cp_info->wszBodyCharset, sizeof(mime_cp_info->wszBodyCharset)/sizeof(WCHAR));
1511 MultiByteToWideChar(CP_ACP, 0, ml_data->fixed_font, -1,
1512 mime_cp_info->wszFixedWidthFont, sizeof(mime_cp_info->wszFixedWidthFont)/sizeof(WCHAR));
1513 MultiByteToWideChar(CP_ACP, 0, ml_data->proportional_font, -1,
1514 mime_cp_info->wszProportionalFont, sizeof(mime_cp_info->wszProportionalFont)/sizeof(WCHAR));
1516 TRACE("%08lx %u %u %s %s %s %s %s %s %d\n",
1517 mime_cp_info->dwFlags, mime_cp_info->uiCodePage,
1518 mime_cp_info->uiFamilyCodePage,
1519 wine_dbgstr_w(mime_cp_info->wszDescription),
1520 wine_dbgstr_w(mime_cp_info->wszWebCharset),
1521 wine_dbgstr_w(mime_cp_info->wszHeaderCharset),
1522 wine_dbgstr_w(mime_cp_info->wszBodyCharset),
1523 wine_dbgstr_w(mime_cp_info->wszFixedWidthFont),
1524 wine_dbgstr_w(mime_cp_info->wszProportionalFont),
1525 mime_cp_info->bGDICharset);
1528 static HRESULT WINAPI fnIMultiLanguage2_GetCodePageInfo(
1529 IMultiLanguage2* iface,
1532 PMIMECPINFO pCodePageInfo)
1536 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1537 TRACE("%p, %u, %04x, %p\n", This, uiCodePage, LangId, pCodePageInfo);
1539 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1541 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1543 if (mlang_data[i].mime_cp_info[n].cp == uiCodePage)
1545 fill_cp_info(&mlang_data[i], n, pCodePageInfo);
1554 static HRESULT WINAPI fnIMultiLanguage2_GetFamilyCodePage(
1555 IMultiLanguage2* iface,
1557 UINT* puiFamilyCodePage)
1559 return GetFamilyCodePage(uiCodePage, puiFamilyCodePage);
1562 static HRESULT WINAPI fnIMultiLanguage2_EnumCodePages(
1563 IMultiLanguage2* iface,
1566 IEnumCodePage** ppEnumCodePage)
1568 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1569 TRACE("%p %08lx %04x %p\n", This, grfFlags, LangId, ppEnumCodePage);
1571 return EnumCodePage_create( This, grfFlags, LangId, ppEnumCodePage );
1574 static HRESULT WINAPI fnIMultiLanguage2_GetCharsetInfo(
1575 IMultiLanguage2* iface,
1577 PMIMECSETINFO pCharsetInfo)
1581 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1582 TRACE("%p %s %p\n", This, debugstr_w(Charset), pCharsetInfo);
1584 if (!pCharsetInfo) return E_FAIL;
1586 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1588 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1590 WCHAR csetW[MAX_MIMECSET_NAME];
1592 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].mime_cp_info[n].web_charset, -1, csetW, MAX_MIMECSET_NAME);
1593 if (!lstrcmpiW(Charset, csetW))
1595 pCharsetInfo->uiCodePage = mlang_data[i].family_codepage;
1596 pCharsetInfo->uiInternetEncoding = mlang_data[i].mime_cp_info[n].cp;
1597 strcpyW(pCharsetInfo->wszCharset, csetW);
1604 * Since we do not support charsets like iso-2022-jp and do not have
1605 * them in our database as a primary (web_charset) encoding this loop
1606 * does an attempt to 'approximate' charset name by header_charset.
1608 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1610 for (n = 0; n < mlang_data[i].number_of_cp; n++)
1612 WCHAR csetW[MAX_MIMECSET_NAME];
1614 MultiByteToWideChar(CP_ACP, 0, mlang_data[i].mime_cp_info[n].header_charset, -1, csetW, MAX_MIMECSET_NAME);
1615 if (!lstrcmpiW(Charset, csetW))
1617 pCharsetInfo->uiCodePage = mlang_data[i].family_codepage;
1618 pCharsetInfo->uiInternetEncoding = mlang_data[i].mime_cp_info[n].cp;
1619 strcpyW(pCharsetInfo->wszCharset, csetW);
1628 static HRESULT WINAPI fnIMultiLanguage2_IsConvertible(
1629 IMultiLanguage2* iface,
1630 DWORD dwSrcEncoding,
1631 DWORD dwDstEncoding)
1633 return IsConvertINetStringAvailable(dwSrcEncoding, dwDstEncoding);
1636 static HRESULT WINAPI fnIMultiLanguage2_ConvertString(
1637 IMultiLanguage2* iface,
1639 DWORD dwSrcEncoding,
1640 DWORD dwDstEncoding,
1646 return ConvertINetString(pdwMode, dwSrcEncoding, dwDstEncoding,
1647 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1650 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringToUnicode(
1651 IMultiLanguage2* iface,
1659 return ConvertINetMultiByteToUnicode(pdwMode, dwEncoding,
1660 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1663 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringFromUnicode(
1664 IMultiLanguage2* iface,
1672 return ConvertINetUnicodeToMultiByte(pdwMode, dwEncoding,
1673 pSrcStr, pcSrcSize, pDstStr, pcDstSize);
1676 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringReset(
1677 IMultiLanguage2* iface)
1683 static HRESULT WINAPI fnIMultiLanguage2_GetRfc1766FromLcid(
1684 IMultiLanguage2* iface,
1692 static HRESULT WINAPI fnIMultiLanguage2_GetLcidFromRfc1766(
1693 IMultiLanguage2* iface,
1701 static HRESULT WINAPI fnIMultiLanguage2_EnumRfc1766(
1702 IMultiLanguage2* iface,
1704 IEnumRfc1766** ppEnumRfc1766)
1710 static HRESULT WINAPI fnIMultiLanguage2_GetRfc1766Info(
1711 IMultiLanguage2* iface,
1714 PRFC1766INFO pRfc1766Info)
1720 static HRESULT WINAPI fnIMultiLanguage2_CreateConvertCharset(
1721 IMultiLanguage2* iface,
1725 IMLangConvertCharset** ppMLangConvertCharset)
1731 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringInIStream(
1732 IMultiLanguage2* iface,
1736 DWORD dwSrcEncoding,
1737 DWORD dwDstEncoding,
1745 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringToUnicodeEx(
1746 IMultiLanguage2* iface,
1760 static HRESULT WINAPI fnIMultiLanguage2_ConvertStringFromUnicodeEx(
1761 IMultiLanguage2* This,
1775 static HRESULT WINAPI fnIMultiLanguage2_DetectCodepageInIStream(
1776 IMultiLanguage2* iface,
1778 DWORD dwPrefWinCodePage,
1780 DetectEncodingInfo* lpEncoding,
1787 static HRESULT WINAPI fnIMultiLanguage2_DetectInputCodepage(
1788 IMultiLanguage2* iface,
1790 DWORD dwPrefWinCodePage,
1793 DetectEncodingInfo* lpEncoding,
1800 static HRESULT WINAPI fnIMultiLanguage2_ValidateCodePage(
1801 IMultiLanguage2* iface,
1809 static HRESULT WINAPI fnIMultiLanguage2_GetCodePageDescription(
1810 IMultiLanguage2* iface,
1813 LPWSTR lpWideCharStr,
1820 static HRESULT WINAPI fnIMultiLanguage2_IsCodePageInstallable(
1821 IMultiLanguage2* iface,
1828 static HRESULT WINAPI fnIMultiLanguage2_SetMimeDBSource(
1829 IMultiLanguage2* iface,
1836 static HRESULT WINAPI fnIMultiLanguage2_GetNumberOfScripts(
1837 IMultiLanguage2* iface,
1840 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1841 TRACE("%p %p\n", This, pnScripts);
1843 if (!pnScripts) return S_FALSE;
1845 *pnScripts = This->total_scripts;
1849 static HRESULT WINAPI fnIMultiLanguage2_EnumScripts(
1850 IMultiLanguage2* iface,
1853 IEnumScript** ppEnumScript)
1855 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1856 TRACE("%p %08lx %04x %p\n", This, dwFlags, LangId, ppEnumScript);
1858 return EnumScript_create( This, dwFlags, LangId, ppEnumScript );
1861 static HRESULT WINAPI fnIMultiLanguage2_ValidateCodePageEx(
1862 IMultiLanguage2* iface,
1865 DWORD dwfIODControl)
1867 ICOM_THIS_MULTI(MLang_impl, vtbl_IMultiLanguage2, iface);
1868 FIXME("%p %u %p %08lx: stub!\n", This, uiCodePage, hwnd, dwfIODControl);
1873 static IMultiLanguage2Vtbl IMultiLanguage2_vtbl =
1875 fnIMultiLanguage2_QueryInterface,
1876 fnIMultiLanguage2_AddRef,
1877 fnIMultiLanguage2_Release,
1878 fnIMultiLanguage2_GetNumberOfCodePageInfo,
1879 fnIMultiLanguage2_GetCodePageInfo,
1880 fnIMultiLanguage2_GetFamilyCodePage,
1881 fnIMultiLanguage2_EnumCodePages,
1882 fnIMultiLanguage2_GetCharsetInfo,
1883 fnIMultiLanguage2_IsConvertible,
1884 fnIMultiLanguage2_ConvertString,
1885 fnIMultiLanguage2_ConvertStringToUnicode,
1886 fnIMultiLanguage2_ConvertStringFromUnicode,
1887 fnIMultiLanguage2_ConvertStringReset,
1888 fnIMultiLanguage2_GetRfc1766FromLcid,
1889 fnIMultiLanguage2_GetLcidFromRfc1766,
1890 fnIMultiLanguage2_EnumRfc1766,
1891 fnIMultiLanguage2_GetRfc1766Info,
1892 fnIMultiLanguage2_CreateConvertCharset,
1893 fnIMultiLanguage2_ConvertStringInIStream,
1894 fnIMultiLanguage2_ConvertStringToUnicodeEx,
1895 fnIMultiLanguage2_ConvertStringFromUnicodeEx,
1896 fnIMultiLanguage2_DetectCodepageInIStream,
1897 fnIMultiLanguage2_DetectInputCodepage,
1898 fnIMultiLanguage2_ValidateCodePage,
1899 fnIMultiLanguage2_GetCodePageDescription,
1900 fnIMultiLanguage2_IsCodePageInstallable,
1901 fnIMultiLanguage2_SetMimeDBSource,
1902 fnIMultiLanguage2_GetNumberOfScripts,
1903 fnIMultiLanguage2_EnumScripts,
1904 fnIMultiLanguage2_ValidateCodePageEx,
1907 static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj)
1912 TRACE("Creating MultiLanguage object\n");
1915 return CLASS_E_NOAGGREGATION;
1917 mlang = HeapAlloc( GetProcessHeap(), 0, sizeof (MLang_impl) );
1918 mlang->vtbl_IMLangFontLink = &IMLangFontLink_vtbl;
1919 mlang->vtbl_IMultiLanguage = &IMultiLanguage_vtbl;
1920 mlang->vtbl_IMultiLanguage2 = &IMultiLanguage2_vtbl;
1922 mlang->total_cp = 0;
1923 for (i = 0; i < sizeof(mlang_data)/sizeof(mlang_data[0]); i++)
1924 mlang->total_cp += mlang_data[i].number_of_cp;
1926 /* do not enumerate unicode flavours */
1927 mlang->total_scripts = sizeof(mlang_data)/sizeof(mlang_data[0]) - 1;
1930 *ppObj = (LPVOID) mlang;
1931 TRACE("returning %p\n", mlang);
1935 /******************************************************************************/
1937 HRESULT WINAPI MLANG_DllCanUnloadNow(void)