Commit 4911d0bf authored by Sander van Leeuwen's avatar Sander van Leeuwen Committed by Alexandre Julliard

- Save and restore current directory in GetFileDialog95W if

OFN_NOCHANGEDIR flag set. - GetFileDialog95W: only convert ofn->lpTemplateName if it's a string resource id (fixes OpenOffice 1.0 file open dialog crash). - Ignore OFN_FILEMUSTEXIST flag for save file dialog (fixes save dialog in ElstarFormular). - Rewrote casts that some compilers don't accept.
parent 54c8f7b9
...@@ -330,6 +330,7 @@ BOOL WINAPI GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType) ...@@ -330,6 +330,7 @@ BOOL WINAPI GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType)
break; break;
case SAVE_DIALOG : case SAVE_DIALOG :
fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG; fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
ofn->Flags &= ~OFN_FILEMUSTEXIST;
ret = GetFileName95(fodInfos); ret = GetFileName95(fodInfos);
break; break;
default : default :
...@@ -403,6 +404,7 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType) ...@@ -403,6 +404,7 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
BOOL ret; BOOL ret;
FileOpenDlgInfos *fodInfos; FileOpenDlgInfos *fodInfos;
HINSTANCE hInstance; HINSTANCE hInstance;
LPSTR lpstrSavDir = NULL;
/* out arguments */ /* out arguments */
LPWSTR lpstrFile = NULL; LPWSTR lpstrFile = NULL;
...@@ -444,7 +446,7 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType) ...@@ -444,7 +446,7 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
len = WideCharToMultiByte( CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0, NULL, NULL ); len = WideCharToMultiByte( CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0, NULL, NULL );
y = (LPSTR)MemAlloc(len); y = (LPSTR)MemAlloc(len);
WideCharToMultiByte( CP_ACP, 0, ofn->lpstrFilter, n, y, len, NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, ofn->lpstrFilter, n, y, len, NULL, NULL );
(LPSTR)ofn->lpstrFilter = y; ofn->lpstrFilter = (LPWSTR)y;
} }
/* convert lpstrCustomFilter */ /* convert lpstrCustomFilter */
...@@ -463,7 +465,7 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType) ...@@ -463,7 +465,7 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
len = WideCharToMultiByte( CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0, NULL, NULL ); len = WideCharToMultiByte( CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0, NULL, NULL );
y = (LPSTR)MemAlloc(len); y = (LPSTR)MemAlloc(len);
WideCharToMultiByte( CP_ACP, 0, ofn->lpstrCustomFilter, n, y, len, NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, ofn->lpstrCustomFilter, n, y, len, NULL, NULL );
(LPSTR)ofn->lpstrCustomFilter = y; ofn->lpstrCustomFilter = (LPWSTR)y;
} }
/* convert string arguments, save others */ /* convert string arguments, save others */
...@@ -472,10 +474,21 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType) ...@@ -472,10 +474,21 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
AllocInArgWtoA(ofn->lpstrInitialDir, lpstrInitialDir); AllocInArgWtoA(ofn->lpstrInitialDir, lpstrInitialDir);
AllocInArgWtoA(ofn->lpstrTitle, lpstrTitle); AllocInArgWtoA(ofn->lpstrTitle, lpstrTitle);
AllocInArgWtoA(ofn->lpstrDefExt, lpstrDefExt); AllocInArgWtoA(ofn->lpstrDefExt, lpstrDefExt);
AllocInArgWtoA(ofn->lpTemplateName, lpTemplateName); if(HIWORD(ofn->lpTemplateName)) {
AllocInArgWtoA(ofn->lpTemplateName, lpTemplateName);
}
else lpTemplateName = ofn->lpTemplateName;
dwFlags = ofn->Flags; dwFlags = ofn->Flags;
hInstance = ofn->hInstance; hInstance = ofn->hInstance;
/* save current directory */
if (ofn->Flags & OFN_NOCHANGEDIR)
{
lpstrSavDir = MemAlloc(MAX_PATH);
GetCurrentDirectoryA(MAX_PATH, lpstrSavDir);
}
ofn->Flags = ofn->Flags|OFN_WINE|OFN_UNICODE; ofn->Flags = ofn->Flags|OFN_WINE|OFN_UNICODE;
ofn->hInstance = MapHModuleLS(ofn->hInstance); ofn->hInstance = MapHModuleLS(ofn->hInstance);
...@@ -486,12 +499,19 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType) ...@@ -486,12 +499,19 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
break; break;
case SAVE_DIALOG : case SAVE_DIALOG :
fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG; fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
ofn->Flags &= ~OFN_FILEMUSTEXIST;
ret = GetFileName95(fodInfos); ret = GetFileName95(fodInfos);
break; break;
default : default :
ret = 0; ret = 0;
} }
if (lpstrSavDir)
{
SetCurrentDirectoryA(lpstrSavDir);
MemFree(lpstrSavDir);
}
/* restore saved IN arguments and convert OUT arguments back */ /* restore saved IN arguments and convert OUT arguments back */
ofn->Flags = dwFlags; ofn->Flags = dwFlags;
ofn->hInstance = hInstance; ofn->hInstance = hInstance;
...@@ -502,8 +522,10 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType) ...@@ -502,8 +522,10 @@ BOOL WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
FreeInArg(ofn->lpstrInitialDir, lpstrInitialDir); FreeInArg(ofn->lpstrInitialDir, lpstrInitialDir);
FreeInArg(ofn->lpstrTitle, lpstrTitle); FreeInArg(ofn->lpstrTitle, lpstrTitle);
FreeInArg(ofn->lpstrDefExt, lpstrDefExt); FreeInArg(ofn->lpstrDefExt, lpstrDefExt);
FreeInArg(ofn->lpTemplateName, lpTemplateName); if(HIWORD(lpTemplateName)) {
FreeInArg(ofn->lpTemplateName, lpTemplateName);
}
else ofn->lpTemplateName = lpTemplateName;
MemFree((LPVOID)(fodInfos)); MemFree((LPVOID)(fodInfos));
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment