Skip to content

Commit

Permalink
Fixing IFileOperation main operations, what fix chrome downloads. Nee…
Browse files Browse the repository at this point in the history
…d implement conversion of IFileOperations flags to ShFileOperation flags, implement NewItem and *Items methods too. Start of combase restructure based in ole32_wrapper, improvements for getFontFileInfo and IfileDialog implementation.
  • Loading branch information
shorthorn-project committed Nov 4, 2023
1 parent 8e0c84e commit 550b3bb
Show file tree
Hide file tree
Showing 38 changed files with 8,359 additions and 7,017 deletions.
41 changes: 23 additions & 18 deletions wrappers/base/comdlg32_wrapper/itemdlg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand Down
125 changes: 75 additions & 50 deletions wrappers/base/gdi32_wrapper/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.@)
*/
Expand All @@ -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)
Expand Down
Loading

0 comments on commit 550b3bb

Please sign in to comment.