2 * OleUIPasteSpecial implementation
4 * Copyright 2006 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COM_NO_WINDOWS_H
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(ole);
35 static const struct ps_flag
40 #define PS_FLAG_ENTRY(p) {p, #p}
41 PS_FLAG_ENTRY(PSF_SHOWHELP),
42 PS_FLAG_ENTRY(PSF_SELECTPASTE),
43 PS_FLAG_ENTRY(PSF_SELECTPASTELINK),
44 PS_FLAG_ENTRY(PSF_CHECKDISPLAYASICON),
45 PS_FLAG_ENTRY(PSF_DISABLEDISPLAYASICON),
46 PS_FLAG_ENTRY(PSF_HIDECHANGEICON),
47 PS_FLAG_ENTRY(PSF_STAYONCLIPBOARDCHANGE),
48 PS_FLAG_ENTRY(PSF_NOREFRESHDATAOBJECT),
53 static void dump_ps_flags(DWORD flags)
55 char flagstr[1000] = "";
57 const struct ps_flag *flag = ps_flags;
58 for( ; flag->name; flag++) {
59 if(flags & flag->flag) {
60 strcat(flagstr, flag->name);
64 TRACE("flags %08x %s\n", flags, flagstr);
67 static void dump_pastespecial(LPOLEUIPASTESPECIALW ps)
70 dump_ps_flags(ps->dwFlags);
71 TRACE("hwnd %p caption %s hook %p custdata %lx\n",
72 ps->hWndOwner, debugstr_w(ps->lpszCaption), ps->lpfnHook, ps->lCustData);
73 if(IS_INTRESOURCE(ps->lpszTemplate))
74 TRACE("hinst %p template %04x hresource %p\n", ps->hInstance, (WORD)(ULONG_PTR)ps->lpszTemplate, ps->hResource);
76 TRACE("hinst %p template %s hresource %p\n", ps->hInstance, debugstr_w(ps->lpszTemplate), ps->hResource);
77 TRACE("dataobj %p arrpasteent %p cpasteent %d arrlinktype %p clinktype %d\n",
78 ps->lpSrcDataObj, ps->arrPasteEntries, ps->cPasteEntries,
79 ps->arrLinkTypes, ps->cLinkTypes);
80 TRACE("cclsidex %d lpclsidex %p nselect %d flink %d hmetapict %p size(%d,%d)\n",
81 ps->cClsidExclude, ps->lpClsidExclude, ps->nSelectedIndex, ps->fLink,
82 ps->hMetaPict, ps->sizel.cx, ps->sizel.cy);
83 for(i = 0; i < ps->cPasteEntries; i++)
85 TRACE("arrPasteEntries[%d]: cFormat %08x pTargetDevice %p dwAspect %d lindex %d tymed %d\n",
86 i, ps->arrPasteEntries[i].fmtetc.cfFormat, ps->arrPasteEntries[i].fmtetc.ptd,
87 ps->arrPasteEntries[i].fmtetc.dwAspect, ps->arrPasteEntries[i].fmtetc.lindex,
88 ps->arrPasteEntries[i].fmtetc.tymed);
89 TRACE("\tformat name %s result text %s flags %04x\n", debugstr_w(ps->arrPasteEntries[i].lpstrFormatName),
90 debugstr_w(ps->arrPasteEntries[i].lpstrResultText), ps->arrPasteEntries[i].dwFlags);
92 for(i = 0; i < ps->cLinkTypes; i++)
93 TRACE("arrLinkTypes[%d] %08x\n", i, ps->arrLinkTypes[i]);
94 for(i = 0; i < ps->cClsidExclude; i++)
95 TRACE("lpClsidExclude[%d] %s\n", i, debugstr_guid(&ps->lpClsidExclude[i]));
99 static inline WCHAR *strdupAtoW(const char *str)
103 if(!str) return NULL;
104 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
105 ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
106 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
110 /***********************************************************************
111 * OleUIPasteSpecialA (OLEDLG.4)
113 UINT WINAPI OleUIPasteSpecialA(LPOLEUIPASTESPECIALA psA)
115 OLEUIPASTESPECIALW ps;
117 TRACE("(%p)\n", psA);
119 memcpy(&ps, psA, psA->cbStruct);
121 ps.lpszCaption = strdupAtoW(psA->lpszCaption);
122 if(!IS_INTRESOURCE(ps.lpszTemplate))
123 ps.lpszTemplate = strdupAtoW(psA->lpszTemplate);
125 if(psA->cPasteEntries > 0)
127 DWORD size = psA->cPasteEntries * sizeof(ps.arrPasteEntries[0]);
130 ps.arrPasteEntries = HeapAlloc(GetProcessHeap(), 0, size);
131 memcpy(ps.arrPasteEntries, psA->arrPasteEntries, size);
132 for(i = 0; i < psA->cPasteEntries; i++)
134 ps.arrPasteEntries[i].lpstrFormatName =
135 strdupAtoW(psA->arrPasteEntries[i].lpstrFormatName);
136 ps.arrPasteEntries[i].lpstrResultText =
137 strdupAtoW(psA->arrPasteEntries[i].lpstrResultText);
141 ret = OleUIPasteSpecialW(&ps);
143 if(psA->cPasteEntries > 0)
146 for(i = 0; i < psA->cPasteEntries; i++)
148 HeapFree(GetProcessHeap(), 0, (WCHAR*)ps.arrPasteEntries[i].lpstrFormatName);
149 HeapFree(GetProcessHeap(), 0, (WCHAR*)ps.arrPasteEntries[i].lpstrResultText);
151 HeapFree(GetProcessHeap(), 0, ps.arrPasteEntries);
153 if(!IS_INTRESOURCE(ps.lpszTemplate))
154 HeapFree(GetProcessHeap(), 0, (WCHAR*)ps.lpszTemplate);
155 HeapFree(GetProcessHeap(), 0, (WCHAR*)ps.lpszCaption);
157 /* Copy back the output fields */
158 psA->dwFlags = ps.dwFlags;
159 psA->lpSrcDataObj = ps.lpSrcDataObj;
160 psA->nSelectedIndex = ps.nSelectedIndex;
161 psA->fLink = ps.fLink;
162 psA->hMetaPict = ps.hMetaPict;
163 psA->sizel = ps.sizel;
168 /***********************************************************************
169 * OleUIPasteSpecialW (OLEDLG.22)
171 UINT WINAPI OleUIPasteSpecialW(LPOLEUIPASTESPECIALW ps)
175 if(TRACE_ON(ole)) dump_pastespecial(ps);
177 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);