mshtml: Added IHTMLDocument2::get_defaultCharset implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2016-01-12 14:42:46 +01:00 committed by Alexandre Julliard
parent 8a20cf4cf8
commit 5910925728
3 changed files with 46 additions and 15 deletions

View File

@ -921,8 +921,11 @@ static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BST
static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
{
HTMLDocument *This = impl_from_IHTMLDocument2(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", This, p);
*p = charset_string_from_cp(GetACP());
return *p ? S_OK : E_OUTOFMEMORY;
}
static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)

View File

@ -54,24 +54,34 @@ static HDC display_dc;
static WCHAR *status_strings[IDS_STATUS_LAST-IDS_STATUS_FIRST+1];
static IMultiLanguage2 *mlang;
static BOOL ensure_mlang(void)
{
IMultiLanguage2 *new_mlang;
HRESULT hres;
if(mlang)
return TRUE;
hres = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
&IID_IMultiLanguage2, (void**)&new_mlang);
if(FAILED(hres)) {
ERR("Could not create CMultiLanguage instance\n");
return FALSE;
}
if(InterlockedCompareExchangePointer((void**)&mlang, new_mlang, NULL))
IMultiLanguage2_Release(new_mlang);
return TRUE;
}
UINT cp_from_charset_string(BSTR charset)
{
MIMECSETINFO info;
HRESULT hres;
if(!mlang) {
IMultiLanguage2 *new_mlang;
hres = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
&IID_IMultiLanguage2, (void**)&new_mlang);
if(FAILED(hres)) {
ERR("Could not create CMultiLanguage instance\n");
return CP_UTF8;
}
if(InterlockedCompareExchangePointer((void**)&mlang, new_mlang, NULL))
IMultiLanguage2_Release(new_mlang);
}
if(!ensure_mlang())
return CP_UTF8;
hres = IMultiLanguage2_GetCharsetInfo(mlang, charset, &info);
if(FAILED(hres)) {
@ -82,6 +92,23 @@ UINT cp_from_charset_string(BSTR charset)
return info.uiInternetEncoding;
}
BSTR charset_string_from_cp(UINT cp)
{
MIMECPINFO info;
HRESULT hres;
if(!ensure_mlang())
return SysAllocString(NULL);
hres = IMultiLanguage2_GetCodePageInfo(mlang, cp, GetUserDefaultUILanguage(), &info);
if(FAILED(hres)) {
ERR("GetCodePageInfo failed: %08x\n", hres);
return SysAllocString(NULL);
}
return SysAllocString(info.wszWebCharset);
}
static void thread_detach(void)
{
thread_data_t *thread_data;

View File

@ -1271,6 +1271,7 @@ static inline void windowref_release(windowref_t *ref)
}
UINT cp_from_charset_string(BSTR) DECLSPEC_HIDDEN;
BSTR charset_string_from_cp(UINT) DECLSPEC_HIDDEN;
HDC get_display_dc(void) DECLSPEC_HIDDEN;
HINSTANCE get_shdoclc(void) DECLSPEC_HIDDEN;
void set_statustext(HTMLDocumentObj*,INT,LPCWSTR) DECLSPEC_HIDDEN;