From a94bc4c0b6031d2a1c94fa7716c7ec6cfea351a9 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Wed, 18 Oct 2006 17:07:47 +0100 Subject: [PATCH] oledlg: Forward OleUIPasteSpecialA -> OleUIPasteSpecialW. --- dlls/oledlg/pastespl.c | 68 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/dlls/oledlg/pastespl.c b/dlls/oledlg/pastespl.c index 94547ddae0b..f255486cd51 100644 --- a/dlls/oledlg/pastespl.c +++ b/dlls/oledlg/pastespl.c @@ -26,6 +26,7 @@ #include "winerror.h" #include "wingdi.h" #include "winuser.h" +#include "winnls.h" #include "oledlg.h" #include "wine/debug.h" @@ -95,14 +96,73 @@ static void dump_pastespecial(LPOLEUIPASTESPECIALW ps) } +static inline WCHAR *strdupAtoW(const char *str) +{ + DWORD len; + WCHAR *ret; + if(!str) return NULL; + len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); + return ret; +} + /*********************************************************************** * OleUIPasteSpecialA (OLEDLG.4) */ -UINT WINAPI OleUIPasteSpecialA(LPOLEUIPASTESPECIALA lpOleUIPasteSpecial) +UINT WINAPI OleUIPasteSpecialA(LPOLEUIPASTESPECIALA psA) { - FIXME("(%p): stub\n", lpOleUIPasteSpecial); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return OLEUI_FALSE; + OLEUIPASTESPECIALW ps; + UINT ret; + TRACE("(%p)\n", psA); + + memcpy(&ps, psA, psA->cbStruct); + + ps.lpszCaption = strdupAtoW(psA->lpszCaption); + if(!IS_INTRESOURCE(ps.lpszTemplate)) + ps.lpszTemplate = strdupAtoW(psA->lpszTemplate); + + if(psA->cPasteEntries > 0) + { + DWORD size = psA->cPasteEntries * sizeof(ps.arrPasteEntries[0]); + UINT i; + + ps.arrPasteEntries = HeapAlloc(GetProcessHeap(), 0, size); + memcpy(ps.arrPasteEntries, psA->arrPasteEntries, size); + for(i = 0; i < psA->cPasteEntries; i++) + { + ps.arrPasteEntries[i].lpstrFormatName = + strdupAtoW(psA->arrPasteEntries[i].lpstrFormatName); + ps.arrPasteEntries[i].lpstrResultText = + strdupAtoW(psA->arrPasteEntries[i].lpstrResultText); + } + } + + ret = OleUIPasteSpecialW(&ps); + + if(psA->cPasteEntries > 0) + { + UINT i; + for(i = 0; i < psA->cPasteEntries; i++) + { + HeapFree(GetProcessHeap(), 0, (WCHAR*)ps.arrPasteEntries[i].lpstrFormatName); + HeapFree(GetProcessHeap(), 0, (WCHAR*)ps.arrPasteEntries[i].lpstrResultText); + } + HeapFree(GetProcessHeap(), 0, ps.arrPasteEntries); + } + if(!IS_INTRESOURCE(ps.lpszTemplate)) + HeapFree(GetProcessHeap(), 0, (WCHAR*)ps.lpszTemplate); + HeapFree(GetProcessHeap(), 0, (WCHAR*)ps.lpszCaption); + + /* Copy back the output fields */ + psA->dwFlags = ps.dwFlags; + psA->lpSrcDataObj = ps.lpSrcDataObj; + psA->nSelectedIndex = ps.nSelectedIndex; + psA->fLink = ps.fLink; + psA->hMetaPict = ps.hMetaPict; + psA->sizel = ps.sizel; + + return ret; } /***********************************************************************