ReactOS 0.4.15-dev-7693-gd0e2924
pastespl.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
#include "oledlg.h"
#include "oledlg_private.h"
#include "resource.h"
#include "wine/debug.h"
Include dependency graph for pastespl.c:

Go to the source code of this file.

Classes

struct  ps_struct_t
 
struct  ps_flag
 

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 
#define PS_FLAG_ENTRY(p)   {p, #p}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ole)
 
static void dump_ps_flags (DWORD flags)
 
static void dump_pastespecial (const OLEUIPASTESPECIALW *ps)
 
static WCHARstrdupAtoW (const char *str)
 
static WCHARstrdupW (const WCHAR *str)
 
static void get_descriptors (HWND hdlg, ps_struct_t *ps_struct)
 
static BOOL add_entry_to_lb (HWND hdlg, UINT id, OLEUIPASTEENTRYW *pe)
 
static DWORD init_pastelist (HWND hdlg, OLEUIPASTESPECIALW *ps)
 
static DWORD init_linklist (HWND hdlg, OLEUIPASTESPECIALW *ps)
 
static void update_display_list (HWND hdlg, UINT src_list_id)
 
static void init_lists (HWND hdlg, ps_struct_t *ps_struct)
 
static void update_src_text (HWND hdlg, const ps_struct_t *ps_struct)
 
static void update_as_icon (HWND hdlg, ps_struct_t *ps_struct)
 
static void update_result_text (HWND hdlg, const ps_struct_t *ps_struct)
 
static void selection_change (HWND hdlg, ps_struct_t *ps_struct)
 
static void mode_change (HWND hdlg, ps_struct_t *ps_struct, UINT id)
 
static void post_help_msg (HWND hdlg, ps_struct_t *ps_struct)
 
static void send_end_dialog_msg (HWND hdlg, ps_struct_t *ps_struct, UINT id)
 
static void update_structure (HWND hdlg, ps_struct_t *ps_struct)
 
static void free_structure (ps_struct_t *ps_struct)
 
static INT_PTR CALLBACK ps_dlg_proc (HWND hdlg, UINT msg, WPARAM wp, LPARAM lp)
 
UINT WINAPI OleUIPasteSpecialA (LPOLEUIPASTESPECIALA psA)
 
UINT WINAPI OleUIPasteSpecialW (LPOLEUIPASTESPECIALW ps)
 

Variables

static const struct ps_flag ps_flags []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file pastespl.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 22 of file pastespl.c.

◆ PS_FLAG_ENTRY

#define PS_FLAG_ENTRY (   p)    {p, #p}

Function Documentation

◆ add_entry_to_lb()

static BOOL add_entry_to_lb ( HWND  hdlg,
UINT  id,
OLEUIPASTEENTRYW pe 
)
static

Definition at line 196 of file pastespl.c.

197{
198 HWND hwnd = GetDlgItem(hdlg, id);
199 BOOL ret = FALSE;
200
201 /* FIXME %s handling */
202
203 /* Note that this suffers from the same bug as native, in that if a new string
204 is a substring of an already added string, then the FINDSTRING will succeed
205 this is probably not what we want */
207 {
210 ret = TRUE;
211 }
212 return ret;
213}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
LPCWSTR lpstrFormatName
Definition: oledlg.h:364
int ret
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
#define LB_ADDSTRING
Definition: winuser.h:2030
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define LB_FINDSTRING
Definition: winuser.h:2033
#define LB_SETITEMDATA
Definition: winuser.h:2064
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by init_linklist(), and init_pastelist().

◆ dump_pastespecial()

static void dump_pastespecial ( const OLEUIPASTESPECIALW ps)
static

Definition at line 84 of file pastespl.c.

85{
86 INT i;
87 UINT j;
88
90 TRACE("hwnd %p caption %s hook %p custdata %lx\n",
93 TRACE("hinst %p template %04x hresource %p\n", ps->hInstance, (WORD)(ULONG_PTR)ps->lpszTemplate, ps->hResource);
94 else
95 TRACE("hinst %p template %s hresource %p\n", ps->hInstance, debugstr_w(ps->lpszTemplate), ps->hResource);
96 TRACE("dataobj %p arrpasteent %p cpasteent %d arrlinktype %p clinktype %d\n",
98 ps->arrLinkTypes, ps->cLinkTypes);
99 TRACE("cclsidex %d lpclsidex %p nselect %d flink %d hmetapict %p size(%d,%d)\n",
101 ps->hMetaPict, ps->sizel.cx, ps->sizel.cy);
102 for(i = 0; i < ps->cPasteEntries; i++)
103 {
104 TRACE("arrPasteEntries[%d]: cFormat %08x pTargetDevice %p dwAspect %d lindex %d tymed %d\n",
105 i, ps->arrPasteEntries[i].fmtetc.cfFormat, ps->arrPasteEntries[i].fmtetc.ptd,
106 ps->arrPasteEntries[i].fmtetc.dwAspect, ps->arrPasteEntries[i].fmtetc.lindex,
107 ps->arrPasteEntries[i].fmtetc.tymed);
108 TRACE("\tformat name %s result text %s flags %04x\n", debugstr_w(ps->arrPasteEntries[i].lpstrFormatName),
110 }
111 for(i = 0; i < ps->cLinkTypes; i++)
112 TRACE("arrLinkTypes[%d] %08x\n", i, ps->arrLinkTypes[i]);
113 for(j = 0; j < ps->cClsidExclude; j++)
114 TRACE("lpClsidExclude[%u] %s\n", j, debugstr_guid(&ps->lpClsidExclude[j]));
115
116}
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
unsigned int UINT
Definition: ndis.h:50
static void dump_ps_flags(DWORD flags)
Definition: pastespl.c:70
#define TRACE(s)
Definition: solgame.cpp:4
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
FORMATETC fmtetc
Definition: oledlg.h:363
LPCWSTR lpstrResultText
Definition: oledlg.h:365
LPDATAOBJECT lpSrcDataObj
Definition: oledlg.h:409
HINSTANCE hInstance
Definition: oledlg.h:406
LPCWSTR lpszCaption
Definition: oledlg.h:403
LPCWSTR lpszTemplate
Definition: oledlg.h:407
LPCLSID lpClsidExclude
Definition: oledlg.h:415
LPFNOLEUIHOOK lpfnHook
Definition: oledlg.h:404
LPOLEUIPASTEENTRYW arrPasteEntries
Definition: oledlg.h:410
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IS_INTRESOURCE(i)
Definition: winuser.h:580

Referenced by OleUIPasteSpecialW().

◆ dump_ps_flags()

static void dump_ps_flags ( DWORD  flags)
static

Definition at line 70 of file pastespl.c.

71{
72 char flagstr[1000] = "";
73
74 const struct ps_flag *flag = ps_flags;
75 for( ; flag->name; flag++) {
76 if(flags & flag->flag) {
77 strcat(flagstr, flag->name);
78 strcat(flagstr, "|");
79 }
80 }
81 TRACE("flags %08x %s\n", flags, flagstr);
82}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
GLbitfield flags
Definition: glext.h:7161
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52
static const struct ps_flag ps_flags[]

Referenced by dump_pastespecial().

◆ free_structure()

static void free_structure ( ps_struct_t ps_struct)
static

Definition at line 501 of file pastespl.c.

502{
503 HeapFree(GetProcessHeap(), 0, ps_struct->type_name);
504 HeapFree(GetProcessHeap(), 0, ps_struct->source_name);
505 HeapFree(GetProcessHeap(), 0, ps_struct->link_type_name);
506 HeapFree(GetProcessHeap(), 0, ps_struct->link_source_name);
507 CoTaskMemFree(ps_struct->app_name);
508 HeapFree(GetProcessHeap(), 0, ps_struct);
509}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
WCHAR * source_name
Definition: pastespl.c:45
LPOLESTR app_name
Definition: pastespl.c:49
WCHAR * link_type_name
Definition: pastespl.c:48
WCHAR * link_source_name
Definition: pastespl.c:46
WCHAR * type_name
Definition: pastespl.c:47

Referenced by ps_dlg_proc().

◆ get_descriptors()

static void get_descriptors ( HWND  hdlg,
ps_struct_t ps_struct 
)
static

Definition at line 140 of file pastespl.c.

141{
142 FORMATETC fmtetc;
143 STGMEDIUM stg;
144
145 fmtetc.tymed = TYMED_HGLOBAL;
146 fmtetc.dwAspect = DVASPECT_CONTENT;
147 fmtetc.ptd = NULL;
148 fmtetc.lindex = -1;
149
150 fmtetc.cfFormat = cf_object_descriptor;
151 if(IDataObject_GetData(ps_struct->ps->lpSrcDataObj, &fmtetc, &stg) == S_OK)
152 {
153 OBJECTDESCRIPTOR *obj_desc = GlobalLock(stg.u.hGlobal);
154 if(obj_desc->dwSrcOfCopy)
155 ps_struct->source_name = strdupW((WCHAR*)((char*)obj_desc + obj_desc->dwSrcOfCopy));
156 if(obj_desc->dwFullUserTypeName)
157 ps_struct->type_name = strdupW((WCHAR*)((char*)obj_desc + obj_desc->dwFullUserTypeName));
158 OleRegGetUserType(&obj_desc->clsid, USERCLASSTYPE_APPNAME, &ps_struct->app_name);
159 /* Get the icon here. If dwDrawAspect & DVASCPECT_ICON call GetData(CF_METAFILEPICT), otherwise
160 native calls OleGetIconFromClass(obj_desc->clsid) */
161 GlobalUnlock(stg.u.hGlobal);
162 GlobalFree(stg.u.hGlobal);
163 }
164 else
165 {
166 /* Try to get some data using some of the other clipboard formats */
167 }
168
169 fmtetc.cfFormat = cf_link_src_descriptor;
170 if(IDataObject_GetData(ps_struct->ps->lpSrcDataObj, &fmtetc, &stg) == S_OK)
171 {
172 OBJECTDESCRIPTOR *obj_desc = GlobalLock(stg.u.hGlobal);
173 if(obj_desc->dwSrcOfCopy)
174 ps_struct->link_source_name = strdupW((WCHAR*)((char*)obj_desc + obj_desc->dwSrcOfCopy));
175 if(obj_desc->dwFullUserTypeName)
176 ps_struct->link_type_name = strdupW((WCHAR*)((char*)obj_desc + obj_desc->dwFullUserTypeName));
177 GlobalUnlock(stg.u.hGlobal);
178 GlobalFree(stg.u.hGlobal);
179 }
180
181 if(ps_struct->source_name == NULL && ps_struct->link_source_name == NULL)
182 {
183 WCHAR buf[200];
185 ps_struct->source_name = strdupW(buf);
186 }
187
188 if(ps_struct->type_name == NULL && ps_struct->link_type_name == NULL)
189 {
190 WCHAR buf[200];
192 ps_struct->type_name = strdupW(buf);
193 }
194}
#define ARRAY_SIZE(A)
Definition: main.h:33
#define NULL
Definition: types.h:112
HRESULT WINAPI OleRegGetUserType(REFCLSID clsid, DWORD form, LPOLESTR *usertype)
Definition: ole2.c:678
#define IDS_PS_UNKNOWN_SRC
Definition: resource.h:61
#define IDS_PS_UNKNOWN_TYPE
Definition: resource.h:60
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HINSTANCE OLEDLG_hInstance
Definition: oledlg_main.c:39
#define S_OK
Definition: intsafe.h:52
UINT cf_link_src_descriptor
Definition: oledlg_main.c:45
UINT cf_object_descriptor
Definition: oledlg_main.c:44
static WCHAR * strdupW(const WCHAR *str)
Definition: pastespl.c:129
OLEUIPASTESPECIALW * ps
Definition: pastespl.c:43
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ps_dlg_proc().

◆ init_linklist()

static DWORD init_linklist ( HWND  hdlg,
OLEUIPASTESPECIALW ps 
)
static

Definition at line 259 of file pastespl.c.

260{
261 HRESULT hr;
262 DWORD supported_mask = 0;
263 DWORD items_added = 0;
264 int link, req_fmt;
265 FORMATETC fmt = {0, NULL, DVASPECT_CONTENT, -1, -1};
266
267 for(link = 0; link < ps->cLinkTypes && link < PS_MAXLINKTYPES; link++)
268 {
269 fmt.cfFormat = ps->arrLinkTypes[link];
270 hr = IDataObject_QueryGetData(ps->lpSrcDataObj, &fmt);
271 if(hr == S_OK)
272 supported_mask |= 1 << link;
273 }
274 TRACE("supported_mask %02x\n", supported_mask);
275 for(req_fmt = 0; req_fmt < ps->cPasteEntries; req_fmt++)
276 {
277 DWORD linktypes;
279 linktypes = 0xff;
280 else
281 linktypes = ps->arrPasteEntries[req_fmt].dwFlags & 0xff;
282
283 if(linktypes & supported_mask)
284 {
286 items_added++;
287 }
288 }
289
290 EnableWindow(GetDlgItem(hdlg, IDC_PS_PASTELINK), items_added != 0);
291 return items_added;
292}
const WCHAR * link
Definition: db.cpp:997
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDC_PS_PASTELINKLIST
Definition: oledlg.h:453
@ OLEUIPASTE_LINKANYTYPE
Definition: oledlg.h:341
#define IDC_PS_PASTELINK
Definition: oledlg.h:450
#define PS_MAXLINKTYPES
Definition: oledlg.h:426
static BOOL add_entry_to_lb(HWND hdlg, UINT id, OLEUIPASTEENTRYW *pe)
Definition: pastespl.c:196
HRESULT hr
Definition: shlfolder.c:183
Definition: dsound.c:943
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by init_lists().

◆ init_lists()

static void init_lists ( HWND  hdlg,
ps_struct_t ps_struct 
)
static

Definition at line 322 of file pastespl.c.

323{
324 DWORD pastes_added = init_pastelist(hdlg, ps_struct->ps);
325 DWORD links_added = init_linklist(hdlg, ps_struct->ps);
326 UINT check_id, list_id;
327
328 if((ps_struct->flags & (PSF_SELECTPASTE | PSF_SELECTPASTELINK)) == 0)
329 ps_struct->flags |= PSF_SELECTPASTE;
330
331 if(!pastes_added && !links_added)
332 ps_struct->flags &= ~(PSF_SELECTPASTE | PSF_SELECTPASTELINK);
333 else if(!pastes_added && (ps_struct->flags & PSF_SELECTPASTE))
334 {
335 ps_struct->flags &= ~PSF_SELECTPASTE;
336 ps_struct->flags |= PSF_SELECTPASTELINK;
337 }
338 else if(!links_added && (ps_struct->flags & PSF_SELECTPASTELINK))
339 {
340 ps_struct->flags &= ~PSF_SELECTPASTELINK;
341 ps_struct->flags |= PSF_SELECTPASTE;
342 }
343
344 check_id = 0;
345 list_id = 0;
346 if(ps_struct->flags & PSF_SELECTPASTE)
347 {
348 check_id = IDC_PS_PASTE;
349 list_id = IDC_PS_PASTELIST;
350 }
351 else if(ps_struct->flags & PSF_SELECTPASTELINK)
352 {
353 check_id = IDC_PS_PASTELINK;
354 list_id = IDC_PS_PASTELINKLIST;
355 }
356
358
359 if(list_id)
360 update_display_list(hdlg, list_id);
361 else
362 EnableWindow(GetDlgItem(hdlg, IDOK), 0);
363}
#define IDC_PS_PASTELIST
Definition: oledlg.h:452
#define PSF_SELECTPASTE
Definition: oledlg.h:429
#define IDC_PS_PASTE
Definition: oledlg.h:449
#define PSF_SELECTPASTELINK
Definition: oledlg.h:430
static DWORD init_linklist(HWND hdlg, OLEUIPASTESPECIALW *ps)
Definition: pastespl.c:259
static void update_display_list(HWND hdlg, UINT src_list_id)
Definition: pastespl.c:295
static DWORD init_pastelist(HWND hdlg, OLEUIPASTESPECIALW *ps)
Definition: pastespl.c:215
DWORD flags
Definition: pastespl.c:44
#define IDOK
Definition: winuser.h:829
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)

Referenced by ps_dlg_proc().

◆ init_pastelist()

static DWORD init_pastelist ( HWND  hdlg,
OLEUIPASTESPECIALW ps 
)
static

Definition at line 215 of file pastespl.c.

216{
217 IEnumFORMATETC *penum;
218 HRESULT hr;
219 FORMATETC fmts[20];
220 DWORD fetched, items_added = 0;
221
222 hr = IDataObject_EnumFormatEtc(ps->lpSrcDataObj, DATADIR_GET, &penum);
223 if(FAILED(hr))
224 {
225 WARN("Unable to create IEnumFORMATETC\n");
226 return 0;
227 }
228
229 /* The native version grabs only the first 20 fmts and we do the same */
230 hr = IEnumFORMATETC_Next(penum, ARRAY_SIZE(fmts), fmts, &fetched);
231 TRACE("got %d formats hr %08x\n", fetched, hr);
232
233 if(SUCCEEDED(hr))
234 {
235 DWORD src_fmt, req_fmt;
236 for(req_fmt = 0; req_fmt < ps->cPasteEntries; req_fmt++)
237 {
238 /* This is used by update_structure() to set nSelectedIndex on exit */
239 ps->arrPasteEntries[req_fmt].dwScratchSpace = req_fmt;
240 TRACE("req_fmt %x\n", ps->arrPasteEntries[req_fmt].fmtetc.cfFormat);
241 for(src_fmt = 0; src_fmt < fetched; src_fmt++)
242 {
243 TRACE("\tenum'ed fmt %x\n", fmts[src_fmt].cfFormat);
244 if(ps->arrPasteEntries[req_fmt].fmtetc.cfFormat == fmts[src_fmt].cfFormat)
245 {
247 items_added++;
248 break;
249 }
250 }
251 }
252 }
253
254 IEnumFORMATETC_Release(penum);
255 EnableWindow(GetDlgItem(hdlg, IDC_PS_PASTE), items_added != 0);
256 return items_added;
257}
#define WARN(fmt,...)
Definition: debug.h:112
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
static struct fmt fmts[]
DWORD dwScratchSpace
Definition: oledlg.h:367

Referenced by init_lists().

◆ mode_change()

static void mode_change ( HWND  hdlg,
ps_struct_t ps_struct,
UINT  id 
)
static

Definition at line 460 of file pastespl.c.

461{
462 if(id == IDC_PS_PASTE)
463 {
464 ps_struct->flags &= ~PSF_SELECTPASTELINK;
465 ps_struct->flags |= PSF_SELECTPASTE;
466 }
467 else
468 {
469 ps_struct->flags &= ~PSF_SELECTPASTE;
470 ps_struct->flags |= PSF_SELECTPASTELINK;
471 }
472
473 update_src_text(hdlg, ps_struct);
475 selection_change(hdlg, ps_struct);
476}
static void update_src_text(HWND hdlg, const ps_struct_t *ps_struct)
Definition: pastespl.c:365
static void selection_change(HWND hdlg, ps_struct_t *ps_struct)
Definition: pastespl.c:454

Referenced by ps_dlg_proc().

◆ OleUIPasteSpecialA()

UINT WINAPI OleUIPasteSpecialA ( LPOLEUIPASTESPECIALA  psA)

Definition at line 635 of file pastespl.c.

636{
638 UINT ret;
639 TRACE("(%p)\n", psA);
640
641 memcpy(&ps, psA, psA->cbStruct);
642
646
647 if(psA->cPasteEntries > 0)
648 {
649 DWORD size = psA->cPasteEntries * sizeof(ps.arrPasteEntries[0]);
650 INT i;
651
654 for(i = 0; i < psA->cPasteEntries; i++)
655 {
660 }
661 }
662
663 ret = OleUIPasteSpecialW(&ps);
664
665 if(psA->cPasteEntries > 0)
666 {
667 INT i;
668 for(i = 0; i < psA->cPasteEntries; i++)
669 {
672 }
674 }
678
679 /* Copy back the output fields */
680 psA->dwFlags = ps.dwFlags;
681 psA->lpSrcDataObj = ps.lpSrcDataObj;
683 psA->fLink = ps.fLink;
684 psA->hMetaPict = ps.hMetaPict;
685 psA->sizel = ps.sizel;
686
687 return ret;
688}
#define HeapAlloc
Definition: compat.h:733
GLsizeiptr size
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static WCHAR * strdupAtoW(const char *str)
Definition: pastespl.c:118
UINT WINAPI OleUIPasteSpecialW(LPOLEUIPASTESPECIALW ps)
Definition: pastespl.c:693
LPCSTR lpstrResultText
Definition: oledlg.h:356
LPCSTR lpstrFormatName
Definition: oledlg.h:355
LPOLEUIPASTEENTRYA arrPasteEntries
Definition: oledlg.h:386
LPDATAOBJECT lpSrcDataObj
Definition: oledlg.h:385

◆ OleUIPasteSpecialW()

UINT WINAPI OleUIPasteSpecialW ( LPOLEUIPASTESPECIALW  ps)

Definition at line 693 of file pastespl.c.

694{
696 UINT ret;
697
698 TRACE("(%p)\n", ps);
699
700 if(TRACE_ON(ole)) dump_pastespecial(ps);
701
702 if(!ps->lpSrcDataObj)
704
705 if(ps->hInstance || !ps->hResource)
706 {
709 HRSRC hrsrc;
710
713 if(!hrsrc) return OLEUI_ERR_FINDTEMPLATEFAILURE;
714 dlg_templ = LoadResource(hInst, hrsrc);
715 if(!dlg_templ) return OLEUI_ERR_LOADTEMPLATEFAILURE;
716 }
717
719
720 return ret;
721}
#define TRACE_ON(x)
Definition: compat.h:75
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
HRESULT WINAPI OleGetClipboard(IDataObject **obj)
Definition: clipboard.c:2249
HINSTANCE hInst
Definition: dxdiag.c:13
#define OLEUI_ERR_FINDTEMPLATEFAILURE
Definition: oledlg.h:77
#define OLEUI_ERR_LPSZTEMPLATEINVALID
Definition: oledlg.h:75
#define OLEUI_ERR_LOADTEMPLATEFAILURE
Definition: oledlg.h:78
#define IDD_PASTESPECIAL4
Definition: oledlg.h:446
static INT_PTR CALLBACK ps_dlg_proc(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp)
Definition: pastespl.c:511
static void dump_pastespecial(const OLEUIPASTESPECIALW *ps)
Definition: pastespl.c:84
#define RT_DIALOG
Definition: pedump.c:367
Definition: name.c:39
const DLGTEMPLATE * LPCDLGTEMPLATEW
Definition: winuser.h:3068
INT_PTR WINAPI DialogBoxIndirectParamW(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by OleUIPasteSpecialA().

◆ post_help_msg()

static void post_help_msg ( HWND  hdlg,
ps_struct_t ps_struct 
)
static

Definition at line 478 of file pastespl.c.

479{
481}
#define IDD_PASTESPECIAL
Definition: oledlg.h:445
UINT oleui_msg_help
Definition: oledlg_main.c:50
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by ps_dlg_proc().

◆ ps_dlg_proc()

static INT_PTR CALLBACK ps_dlg_proc ( HWND  hdlg,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 511 of file pastespl.c.

512{
513 /* native uses prop name "Structure", but we're not compatible
514 with that so we'll prepend "Wine_". */
515 static const WCHAR prop_name[] = {'W','i','n','e','_','S','t','r','u','c','t','u','r','e',0};
516 ps_struct_t *ps_struct;
517
518 TRACE("(%p, %04x, %08lx, %08lx)\n", hdlg, msg, wp, lp);
519
520 ps_struct = GetPropW(hdlg, prop_name);
521
522 if(msg != WM_INITDIALOG)
523 {
524 if(!ps_struct)
525 return 0;
526
527 if(ps_struct->ps->lpfnHook)
528 {
529 INT_PTR ret = ps_struct->ps->lpfnHook(hdlg, msg, wp, lp);
530 if(ret) return ret;
531 }
532 }
533
534 switch(msg)
535 {
536 case WM_INITDIALOG:
537 {
538 ps_struct = HeapAlloc(GetProcessHeap(), 0, sizeof(*ps_struct));
539 ps_struct->ps = (OLEUIPASTESPECIALW*)lp;
540 ps_struct->type_name = NULL;
541 ps_struct->source_name = NULL;
542 ps_struct->link_type_name = NULL;
543 ps_struct->link_source_name = NULL;
544 ps_struct->app_name = NULL;
545 ps_struct->flags = ps_struct->ps->dwFlags;
546
547 SetPropW(hdlg, prop_name, ps_struct);
548
549 if(!(ps_struct->ps->dwFlags & PSF_SHOWHELP))
550 {
553 }
554
555 if(ps_struct->ps->lpszCaption)
556 SetWindowTextW(hdlg, ps_struct->ps->lpszCaption);
557
558 get_descriptors(hdlg, ps_struct);
559
560 init_lists(hdlg, ps_struct);
561
562 update_src_text(hdlg, ps_struct);
563
564 selection_change(hdlg, ps_struct);
565
567
568 if(ps_struct->ps->lpfnHook)
569 ps_struct->ps->lpfnHook(hdlg, msg, 0, 0);
570 return FALSE; /* use new focus */
571 }
572 case WM_COMMAND:
573 switch(LOWORD(wp))
574 {
576 switch(HIWORD(wp))
577 {
578 case LBN_SELCHANGE:
579 selection_change(hdlg, ps_struct);
580 return FALSE;
581 default:
582 return FALSE;
583 }
584 case IDC_PS_PASTE:
585 case IDC_PS_PASTELINK:
586 switch(HIWORD(wp))
587 {
588 case BN_CLICKED:
589 mode_change(hdlg, ps_struct, LOWORD(wp));
590 return FALSE;
591
592 default:
593 return FALSE;
594 }
595 case IDC_OLEUIHELP:
596 switch(HIWORD(wp))
597 {
598 case BN_CLICKED:
599 post_help_msg(hdlg, ps_struct);
600 return FALSE;
601 default:
602 return FALSE;
603 }
604 case IDOK:
605 case IDCANCEL:
606 switch(HIWORD(wp))
607 {
608 case BN_CLICKED:
609 send_end_dialog_msg(hdlg, ps_struct, LOWORD(wp));
610 return FALSE;
611 default:
612 return FALSE;
613 }
614 }
615 return FALSE;
616 default:
618 {
619 if(wp == IDOK)
620 update_structure(hdlg, ps_struct);
621 EndDialog(hdlg, wp);
622 /* native does its cleanup in WM_DESTROY */
623 RemovePropW(hdlg, prop_name);
624 free_structure(ps_struct);
625 return TRUE;
626 }
627 return FALSE;
628 }
629
630}
#define msg(x)
Definition: auth_time.c:54
#define PSF_SHOWHELP
Definition: oledlg.h:428
#define IDC_PS_DISPLAYLIST
Definition: oledlg.h:454
#define IDC_OLEUIHELP
Definition: oledlg.h:51
UINT oleui_msg_enddialog
Definition: oledlg_main.c:51
static void get_descriptors(HWND hdlg, ps_struct_t *ps_struct)
Definition: pastespl.c:140
static void init_lists(HWND hdlg, ps_struct_t *ps_struct)
Definition: pastespl.c:322
static void update_structure(HWND hdlg, ps_struct_t *ps_struct)
Definition: pastespl.c:488
static void free_structure(ps_struct_t *ps_struct)
Definition: pastespl.c:501
static void mode_change(HWND hdlg, ps_struct_t *ps_struct, UINT id)
Definition: pastespl.c:460
static void post_help_msg(HWND hdlg, ps_struct_t *ps_struct)
Definition: pastespl.c:478
static void send_end_dialog_msg(HWND hdlg, ps_struct_t *ps_struct, UINT id)
Definition: pastespl.c:483
#define LOWORD(l)
Definition: pedump.c:82
int32_t INT_PTR
Definition: typedefs.h:64
#define HIWORD(l)
Definition: typedefs.h:247
#define SW_HIDE
Definition: winuser.h:767
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HANDLE WINAPI RemovePropW(_In_ HWND, _In_ LPCWSTR)
#define IDCANCEL
Definition: winuser.h:830
#define WM_COMMAND
Definition: winuser.h:1739
#define WM_INITDIALOG
Definition: winuser.h:1738
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
#define LBN_SELCHANGE
Definition: winuser.h:2074
#define BN_CLICKED
Definition: winuser.h:1924
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by OleUIPasteSpecialW().

◆ selection_change()

static void selection_change ( HWND  hdlg,
ps_struct_t ps_struct 
)
static

Definition at line 454 of file pastespl.c.

455{
456 update_as_icon(hdlg, ps_struct);
457 update_result_text(hdlg, ps_struct);
458}
static void update_as_icon(HWND hdlg, ps_struct_t *ps_struct)
Definition: pastespl.c:388
static void update_result_text(HWND hdlg, const ps_struct_t *ps_struct)
Definition: pastespl.c:405

Referenced by mode_change(), and ps_dlg_proc().

◆ send_end_dialog_msg()

static void send_end_dialog_msg ( HWND  hdlg,
ps_struct_t ps_struct,
UINT  id 
)
static

Definition at line 483 of file pastespl.c.

484{
485 SendMessageW(hdlg, oleui_msg_enddialog, id, 0);
486}

Referenced by ps_dlg_proc().

◆ strdupAtoW()

static WCHAR * strdupAtoW ( const char str)
inlinestatic

Definition at line 118 of file pastespl.c.

119{
120 DWORD len;
121 WCHAR *ret;
122 if(!str) return NULL;
123 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
124 ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
126 return ret;
127}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
GLenum GLsizei len
Definition: glext.h:6722
const WCHAR * str

Referenced by OleUIPasteSpecialA().

◆ strdupW()

static WCHAR * strdupW ( const WCHAR str)
inlinestatic

Definition at line 129 of file pastespl.c.

130{
131 DWORD len;
132 WCHAR *ret;
133 if(!str) return NULL;
134 len = lstrlenW(str) + 1;
135 ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
136 memcpy(ret, str, len * sizeof(WCHAR));
137 return ret;
138}
#define lstrlenW
Definition: compat.h:750

Referenced by get_descriptors().

◆ update_as_icon()

static void update_as_icon ( HWND  hdlg,
ps_struct_t ps_struct 
)
static

Definition at line 388 of file pastespl.c.

389{
390 HWND icon_display = GetDlgItem(hdlg, IDC_PS_ICONDISPLAY);
391 HWND display_as_icon = GetDlgItem(hdlg, IDC_PS_DISPLAYASICON);
392 HWND change_icon = GetDlgItem(hdlg, IDC_PS_CHANGEICON);
393
394 /* FIXME. No as icon handling */
395 ps_struct->flags &= ~PSF_CHECKDISPLAYASICON;
396
398 EnableWindow(display_as_icon, 0);
399 ShowWindow(icon_display, SW_HIDE);
400 EnableWindow(icon_display, 0);
401 ShowWindow(change_icon, SW_HIDE);
402 EnableWindow(change_icon, 0);
403}
#define IDC_PS_ICONDISPLAY
Definition: oledlg.h:456
#define PSF_CHECKDISPLAYASICON
Definition: oledlg.h:432
#define IDC_PS_DISPLAYASICON
Definition: oledlg.h:455
#define IDC_PS_CHANGEICON
Definition: oledlg.h:457
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)

Referenced by selection_change().

◆ update_display_list()

static void update_display_list ( HWND  hdlg,
UINT  src_list_id 
)
static

Definition at line 295 of file pastespl.c.

296{
297 LONG count, i, old_pos;
298 WCHAR txt[256];
299 LONG item_data;
300 HWND display_list = GetDlgItem(hdlg, IDC_PS_DISPLAYLIST);
301 HWND list = GetDlgItem(hdlg, src_list_id);
302
303 old_pos = SendMessageW(display_list, LB_GETCURSEL, 0, 0);
304 if(old_pos == -1) old_pos = 0;
305
306 SendMessageW(display_list, WM_SETREDRAW, 0, 0);
307 SendMessageW(display_list, LB_RESETCONTENT, 0, 0);
309 for(i = 0; i < count; i++)
310 {
312 item_data = SendMessageW(list, LB_GETITEMDATA, i, 0);
313 SendMessageW(display_list, LB_INSERTSTRING, i, (LPARAM)txt);
314 SendMessageW(display_list, LB_SETITEMDATA, i, item_data);
315 }
316 SendMessageW(display_list, LB_SETCURSEL, 0, 0);
317 SendMessageW(display_list, WM_SETREDRAW, 1, 0);
318 if(GetForegroundWindow() == hdlg)
319 SetFocus(display_list);
320}
Definition: list.h:37
GLuint GLuint GLsizei count
Definition: gl.h:1545
long LONG
Definition: pedump.c:60
#define LB_GETCOUNT
Definition: winuser.h:2037
#define LB_GETITEMDATA
Definition: winuser.h:2040
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define LB_GETTEXT
Definition: winuser.h:2048
#define LB_RESETCONTENT
Definition: winuser.h:2054
#define LB_INSERTSTRING
Definition: winuser.h:2052
#define LB_SETCURSEL
Definition: winuser.h:2062
#define LB_GETCURSEL
Definition: winuser.h:2038
#define WM_SETREDRAW
Definition: winuser.h:1615

Referenced by init_lists(), and mode_change().

◆ update_result_text()

static void update_result_text ( HWND  hdlg,
const ps_struct_t ps_struct 
)
static

Definition at line 405 of file pastespl.c.

406{
407 WCHAR resource_txt[200];
408 UINT res_id;
409 OLEUIPASTEENTRYW *pent;
410 LONG cur_sel;
411 static const WCHAR percent_s[] = {'%','s',0};
412 WCHAR *result_txt, *ptr;
413
415 if(cur_sel == -1) return;
417
418 if(ps_struct->flags & PSF_SELECTPASTE)
419 {
420 if(ps_struct->flags & PSF_CHECKDISPLAYASICON)
422 else
423 res_id = IDS_PS_PASTE_DATA;
424 }
425 else
426 {
427 if(ps_struct->flags & PSF_CHECKDISPLAYASICON)
429 else
430 res_id = IDS_PS_PASTE_LINK_DATA;
431 }
432
433 LoadStringW(OLEDLG_hInstance, res_id, resource_txt, ARRAY_SIZE(resource_txt));
434 if((ptr = wcsstr(resource_txt, percent_s)))
435 {
436 /* FIXME handle %s in ResultText. Sub appname if IDS_PS_PASTE_OBJECT{_AS_ICON}. Else sub appropriate type name */
437 size_t result_txt_len = lstrlenW(pent->lpstrResultText);
438 ptrdiff_t offs = (char*)ptr - (char*)resource_txt;
439 result_txt = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(resource_txt) + result_txt_len - 1) * sizeof(WCHAR));
440 memcpy(result_txt, resource_txt, offs);
441 memcpy((char*)result_txt + offs, pent->lpstrResultText, result_txt_len * sizeof(WCHAR));
442 memcpy((char*)result_txt + offs + result_txt_len * sizeof(WCHAR), ptr + 2, (lstrlenW(ptr + 2) + 1) * sizeof(WCHAR));
443 }
444 else
445 result_txt = resource_txt;
446
447 SetDlgItemTextW(hdlg, IDC_PS_RESULTTEXT, result_txt);
448
449 if(result_txt != resource_txt)
450 HeapFree(GetProcessHeap(), 0, result_txt);
451
452}
#define IDS_PS_PASTE_DATA
Definition: resource.h:53
#define IDS_PS_PASTE_OBJECT_AS_ICON
Definition: resource.h:55
#define IDS_PS_PASTE_LINK_DATA
Definition: resource.h:56
#define IDS_PS_PASTE_LINK_OBJECT_AS_ICON
Definition: resource.h:58
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
static PVOID ptr
Definition: dispmode.c:27
#define IDC_PS_RESULTTEXT
Definition: oledlg.h:459
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)

Referenced by selection_change().

◆ update_src_text()

static void update_src_text ( HWND  hdlg,
const ps_struct_t ps_struct 
)
static

Definition at line 365 of file pastespl.c.

366{
367 WCHAR *str;
368
369 if(ps_struct->flags & PSF_SELECTPASTE)
370 {
371 if(ps_struct->source_name)
372 str = ps_struct->source_name;
373 else
374 str = ps_struct->link_source_name;
375
376 }
377 else
378 {
379 if(ps_struct->link_source_name)
380 str = ps_struct->link_source_name;
381 else
382 str = ps_struct->source_name;
383
384 }
386}
#define IDC_PS_SOURCETEXT
Definition: oledlg.h:451

Referenced by mode_change(), and ps_dlg_proc().

◆ update_structure()

static void update_structure ( HWND  hdlg,
ps_struct_t ps_struct 
)
static

Definition at line 488 of file pastespl.c.

489{
491 if(cur_sel != -1)
492 {
493 OLEUIPASTEENTRYW *pent;
495 ps_struct->ps->nSelectedIndex = pent->dwScratchSpace;
496 }
497 ps_struct->ps->dwFlags = ps_struct->flags;
498 ps_struct->ps->fLink = (ps_struct->flags & PSF_SELECTPASTELINK) != 0;
499}

Referenced by ps_dlg_proc().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ole  )

Variable Documentation

◆ ps_flags

const struct ps_flag ps_flags[]
static
Initial value:

Referenced by dump_ps_flags().