diff --git a/wrappers/base/comdlg32_wrapper/itemdlg.c b/wrappers/base/comdlg32_wrapper/itemdlg.c index 941b0ddf91..2f2c808b74 100644 --- a/wrappers/base/comdlg32_wrapper/itemdlg.c +++ b/wrappers/base/comdlg32_wrapper/itemdlg.c @@ -119,6 +119,7 @@ typedef struct FileDialogImpl { IShellItemArray *psia_selection; IShellItemArray *psia_results; + IShellItem *psia_result; IShellItem *psi_defaultfolder; IShellItem *psi_setfolder; IShellItem *psi_folder; @@ -2459,8 +2460,8 @@ static HRESULT create_dialog(FileDialogImpl *This, HWND parent) ERR("Failed to show dialog (LastError: %ld)\n", GetLastError()); return E_FAIL; }else{ - // IShellItem shellItem; - // SHCreateItemFromParsingName(ofn.lpstrFile,NULL,&IID_IShellItem, (void**)&shellItem); + //IShellItem *shellItem; + SHCreateItemFromParsingName(ofn.lpstrFile,NULL,&IID_IShellItem, &This->psia_result); // SHCreateShellItemArrayFromShellItem(&shellItem,&IID_IShellItemArray, (void**)&This->psia_results); } @@ -2877,27 +2878,31 @@ static HRESULT WINAPI IFileDialog2_fnSetFileNameLabel(IFileDialog2 *iface, LPCWS static HRESULT WINAPI IFileDialog2_fnGetResult(IFileDialog2 *iface, IShellItem **ppsi) { FileDialogImpl *This = impl_from_IFileDialog2(iface); - HRESULT hr; + //HRESULT hr; TRACE("%p (%p)\n", This, ppsi); if(!ppsi) return E_INVALIDARG; - if(This->psia_results) - { - DWORD item_count; - hr = IShellItemArray_GetCount(This->psia_results, &item_count); - if(SUCCEEDED(hr)) - { - if(item_count != 1) - return E_FAIL; - - /* Adds a reference. */ - hr = IShellItemArray_GetItemAt(This->psia_results, 0, ppsi); - } - - return hr; - } + if(This->psia_result){ + *ppsi = This->psia_result; + return S_OK; + } + // if(This->psia_results) + // { + // DWORD item_count; + // hr = IShellItemArray_GetCount(This->psia_results, &item_count); + // if(SUCCEEDED(hr)) + // { + // if(item_count != 1) + // return E_FAIL; + + // /* Adds a reference. */ + // hr = IShellItemArray_GetItemAt(This->psia_results, 0, ppsi); + // } + + // return hr; + // } return E_UNEXPECTED; } diff --git a/wrappers/base/gdi32_wrapper/font.c b/wrappers/base/gdi32_wrapper/font.c index c28b45fe3d..f9394ca8d3 100644 --- a/wrappers/base/gdi32_wrapper/font.c +++ b/wrappers/base/gdi32_wrapper/font.c @@ -131,44 +131,76 @@ static inline struct font_handle_entry *handle_entry( DWORD handle ) return NULL; } -/************************************************************************* - * GetFontFileInfo (GDI32.@) - */ -BOOL WINAPI GetFontFileInfo( DWORD instance_id, DWORD unknown, struct font_fileinfo *info, DWORD size, DWORD *needed ) -{ - // LOGFONTW logfont; - // HFONT hfont; - // HRESULT hr; - - // // *fontface = NULL; - - // hfont = GetCurrentObject(currentHdcFont, OBJ_FONT); - // if (!hfont) - // return E_INVALIDARG; - // GetObjectW(hfont, sizeof(logfont), &logfont); - - struct font_handle_entry *entry = handle_entry( instance_id ); - const GdiFont *font; - - if (!entry) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - font = entry->obj; - *needed = sizeof(*info) + strlenW(font->fileinfo->path) * sizeof(WCHAR); +LPCWSTR fontPath = L"C:\\Windows\\Fonts\\Tahoma.ttf"; + +BOOL WINAPI GetFontFileInfo( DWORD instance_id, DWORD file_index, struct font_fileinfo *info, DWORD size, DWORD *needed ) { + struct font_fileinfo fileinfo = {0}; + DWORD neededLength; + + ZeroMemory(&fileinfo, sizeof(fileinfo)); + + neededLength = sizeof(info) + (strlenW(fontPath) + 1) * sizeof(WCHAR); + + //font = entry->obj; + *needed = neededLength; if (*needed > size) { SetLastError(ERROR_INSUFFICIENT_BUFFER); return FALSE; } - - /* path is included too */ - memcpy(info, font->fileinfo, *needed); + info->writetime.dwLowDateTime = 0; + info->writetime.dwHighDateTime = 0; + info->size.LowPart = 1000000; // replace with actual font size + info->size.HighPart = 1000000; // replace with actual font size + memcpy(&(info->path), fontPath, (strlenW(fontPath) + 1) * sizeof(WCHAR)); return TRUE; } +// /************************************************************************* + // * GetFontFileInfo (GDI32.@) + // */ +// BOOL WINAPI GetFontFileInfo( DWORD instance_id, DWORD unknown, struct font_fileinfo *info, DWORD size, DWORD *needed ) +// { + // // LOGFONTW logfont; + // // HFONT hfont; + // // HRESULT hr; + + // // // *fontface = NULL; + + // // hfont = GetCurrentObject(currentHdcFont, OBJ_FONT); + // // if (!hfont) + // // return E_INVALIDARG; + // // GetObjectW(hfont, sizeof(logfont), &logfont); + + // //struct font_handle_entry *entry = handle_entry( instance_id ); + // //const GdiFont *font; + + // // if (!entry) + // // { + // // SetLastError(ERROR_INVALID_PARAMETER); + // // return FALSE; + // // } + + // struct font_fileinfo fileinfo = {0}; + + // ZeroMemory(&fileinfo, sizeof(fileinfo)); + + // fileinfo.path = L"C:\\Windows\\Fonts\\Tahoma.ttf"; + // fileinfo.size = sizeof(*info) + strlenW(fileinfo.path) * sizeof(WCHAR); + + // //font = entry->obj; + // *needed = fileinfo.size; + // if (*needed > size) + // { + // SetLastError(ERROR_INSUFFICIENT_BUFFER); + // return FALSE; + // } + + // /* path is included too */ + // memcpy(info, fileinfo, *needed); + // return TRUE; +// } + /************************************************************* * GetFontRealizationInfo (GDI32.@) */ @@ -183,29 +215,22 @@ GetFontRealizationInfo(HDC hdc, struct font_realization_info *info) } //Just return GetRealizationInfo, because call internally same syscall, NtGdiGetRealizationInfo if(GdiRealizationInfo(hdc, &reinfo)){ - info->file_count = 1; - switch(reinfo.iTechnology) - { - case 1: - info->flags = 1; - break; - case 2: - info->flags |= 2; - break; - default: - break; - } - info->instance_id = reinfo.iUniq; - info->face_index = reinfo.iFontFileId; - info->simulations = 0; + info->flags = reinfo.iTechnology; + info->cache_num = 0; + info->instance_id = reinfo.iUniq; + if (info->size >= 20) + info->file_count = 1; + if (info->size >= 22) + info->face_index = reinfo.iFontFileId; + if (info->size >= 24) + info->simulations = 0; + // info->instance_id = reinfo.iUniq; + // info->face_index = reinfo.iFontFileId; + // info->simulations = 0; return TRUE; } - return FALSE; - - // if (physdev->font->fake_bold) info->simulations |= 0x1; - // if (physdev->font->fake_italic) info->simulations |= 0x2; - + return FALSE; } static DWORD get_font_data( GdiFont *font, DWORD table, DWORD offset, LPVOID buf, DWORD cbData) diff --git a/wrappers/base/kernelbase_wrapper/locale.c b/wrappers/base/kernelbase_wrapper/locale.c index 93d4bea4da..8b0302359a 100644 --- a/wrappers/base/kernelbase_wrapper/locale.c +++ b/wrappers/base/kernelbase_wrapper/locale.c @@ -75,6 +75,145 @@ static const NLS_LOCALE_HEADER *locale_table; #define LOCALE_SSHORTESTDAYNAME6 0x0065 #define LOCALE_SSHORTESTDAYNAME7 0x0066 +NeutralToSpecific NeutralToSpecificMap[] = +{ + { L"af", L"af-ZA" }, + { L"am", L"am-ET" }, + { L"ar", L"ar-SA" }, + { L"arn", L"arn-CL" }, + { L"as", L"as-IN" }, + { L"az", L"az-Latn-AZ" }, + { L"az-Cyrl", L"az-Cyrl-AZ" }, + { L"az-Latn", L"az-Latn-AZ" }, + { L"ba", L"ba-RU" }, + { L"be", L"be-BY" }, + { L"bg", L"bg-BG" }, + { L"bn", L"bn-IN" }, + { L"bo", L"bo-CN" }, + { L"br", L"br-FR" }, + { L"bs-Cyrl", L"bs-Cyrl-BA" }, + { L"bs-Latn", L"bs-Latn-BA" }, + { L"ca", L"ca-ES" }, + { L"co", L"co-FR" }, + { L"cs", L"cs-CZ" }, + { L"cy", L"cy-GB" }, + { L"da", L"da-DK" }, + { L"de", L"de-DE" }, + { L"dsb", L"dsb-DE" }, + { L"dv", L"dv-MV" }, + { L"el", L"el-GR" }, + { L"en", L"en-US" }, + { L"es", L"es-ES" }, + { L"et", L"et-EE" }, + { L"eu", L"eu-ES" }, + { L"fa", L"fa-IR" }, + { L"fi", L"fi-FI" }, + { L"fil", L"fil-PH" }, + { L"fo", L"fo-FO" }, + { L"fr", L"fr-FR" }, + { L"fy", L"fy-NL" }, + { L"ga", L"ga-IE" }, + { L"gd", L"gd-GB" }, + { L"gl", L"gl-ES" }, + { L"gsw", L"gsw-FR" }, + { L"gu", L"gu-IN" }, + { L"ha-Latn", L"ha-Latn-NG" }, + { L"he", L"he-IL" }, + { L"hi", L"hi-IN" }, + { L"hr", L"hr-HR" }, + { L"hsb", L"hsb-DE" }, + { L"hu", L"hu-HU" }, + { L"hy", L"hy-AM" }, + { L"id", L"id-ID" }, + { L"ig", L"ig-NG" }, + { L"ii", L"ii-CN" }, + { L"is", L"is-IS" }, + { L"it", L"it-IT" }, + { L"iu-Cans", L"iu-Cans-CA" }, + { L"iu-Latn", L"iu-Latn-CA" }, + { L"ja", L"ja-JP" }, + { L"ka", L"ka-GE" }, + { L"kk", L"kk-KZ" }, + { L"kl", L"kl-GL" }, + { L"km", L"km-KH" }, + { L"kn", L"kn-IN" }, + { L"ko", L"ko-KR" }, + { L"kok", L"kok-IN" }, + { L"ky", L"ky-KG" }, + { L"lb", L"lb-LU" }, + { L"lo", L"lo-LA" }, + { L"lt", L"lt-LT" }, + { L"lv", L"lv-LV" }, + { L"mi", L"mi-NZ" }, + { L"mk", L"mk-MK" }, + { L"ml", L"ml-IN" }, + { L"mn", L"mn-MN" }, + { L"mn-Cyrl", L"mn-MN" }, + { L"mn-Mong", L"mn-Mong-CN" }, + { L"moh", L"moh-CA" }, + { L"mr", L"mr-IN" }, + { L"ms", L"ms-MY" }, + { L"mt", L"mt-MT" }, + { L"nb", L"nb-NO" }, + { L"ne", L"ne-NP" }, + { L"nl", L"nl-NL" }, + { L"nn", L"nn-NO" }, + { L"no", L"nb-NO" }, + { L"nso", L"nso-ZA" }, + { L"oc", L"oc-FR" }, + { L"or", L"or-IN" }, + { L"pa", L"pa-IN" }, + { L"pl", L"pl-PL" }, + { L"prs", L"prs-AF" }, + { L"ps", L"ps-AF" }, + { L"pt", L"pt-BR" }, + { L"qut", L"qut-GT" }, + { L"quz", L"quz-BO" }, + { L"rm", L"rm-CH" }, + { L"ro", L"ro-RO" }, + { L"ru", L"ru-RU" }, + { L"rw", L"rw-RW" }, + { L"sa", L"sa-IN" }, + { L"sah", L"sah-RU" }, + { L"se", L"se-NO" }, + { L"si", L"si-LK" }, + { L"sk", L"sk-SK" }, + { L"sl", L"sl-SI" }, + { L"sma", L"sma-SE" }, + { L"smj", L"smj-SE" }, + { L"smn", L"smn-FI" }, + { L"sms", L"sms-FI" }, + { L"sq", L"sq-AL" }, + { L"sr", L"sr-Latn-RS" }, + { L"sr-Cyrl", L"sr-Cyrl-RS" }, + { L"sr-Latn", L"sr-Latn-RS" }, + { L"sv", L"sv-SE" }, + { L"sw", L"sw-KE" }, + { L"syr", L"syr-SY" }, + { L"ta", L"ta-IN" }, + { L"te", L"te-IN" }, + { L"tg-Cyrl", L"tg-Cyrl-TJ" }, + { L"th", L"th-TH" }, + { L"tk", L"tk-TM" }, + { L"tn", L"tn-ZA" }, + { L"tr", L"tr-TR" }, + { L"tt", L"tt-RU" }, + { L"tzm-Latn", L"tzm-Latn-DZ" }, + { L"ug", L"ug-CN" }, + { L"uk", L"uk-UA" }, + { L"ur", L"ur-PK" }, + { L"uz", L"uz-Latn-UZ" }, + { L"uz-Cyrl", L"uz-Cyrl-UZ" }, + { L"uz-Latn", L"uz-Latn-UZ" }, + { L"vi", L"vi-VN" }, + { L"wo", L"wo-SN" }, + { L"xh", L"xh-ZA" }, + { L"yo", L"yo-NG" }, + { L"zh-Hans", L"zh-CN" }, + { L"zh-Hant", L"zh-HK" }, + { L"zu", L"zu-ZA" }, +}; + WINE_DEFAULT_DEBUG_CHANNEL(locale); struct sortguid @@ -841,31 +980,99 @@ LocaleNameToLCID( return GetSystemDefaultLCID(); } +// Implements wcsncpmp for ASCII chars only. +// NOTE: We can't use wcsncmp in this context because we may end up trying to modify +// locale data structs or even calling the same function in NLS code. +static int _fastcall __wcsnicmp_ascii(const wchar_t* string1, const wchar_t* string2, size_t count) +{ + wchar_t f, l; + int result = 0; + + if (count) + { + /* validation section */ + do { + f = towlower(*string1); + l = towlower(*string2); + string1++; + string2++; + } while ((--count) && f && (f == l)); + + result = (int)(f - l); + } + + return result; +} + +//尝试将一个中性语言匹配到实际区域 +static LPCWSTR __fastcall DownlevelNeutralToSpecificLocaleName(LPCWSTR szLocaleName) +{ + int bottom = 0; + int top = _countof(NeutralToSpecificMap) - 1; + int middle; + int testIndex; + + while (bottom <= top) + { + middle = (bottom + top) / 2; + testIndex = __wcsnicmp_ascii(szLocaleName, NeutralToSpecificMap[middle].szNeutralLocale, LOCALE_NAME_MAX_LENGTH); + + if (testIndex == 0) + return NeutralToSpecificMap[middle].szSpecificLocale; + + if (testIndex < 0) + top = middle - 1; + else + bottom = middle + 1; + } + + //找不到就直接返回本身 + return szLocaleName; +} + /*********************************************************************** * LCIDToLocaleName (KERNEL32.@) */ INT WINAPI LCIDToLocaleName( - LCID lcid, + LCID Locale, LPWSTR lpName, - INT count, - DWORD flags + INT cchName, + DWORD dwFlags ) { int i; - int length = 0; + int count = 0; + LPCWSTR szLocaleName; + + szLocaleName = (LPWSTR)HeapAlloc(GetProcessHeap(), 8, MAX_PATH * 2); + + if (Locale == 0 || (lpName == NULL && cchName > 0) || cchName < 0) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } for(i=0;i