ReactOS 0.4.17-dev-934-g091855f
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 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 WCHAR * strdupAtoW (const char *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.

◆ 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 184 of file pastespl.c.

185{
186 HWND hwnd = GetDlgItem(hdlg, id);
187 BOOL ret = FALSE;
188
189 /* FIXME %s handling */
190
191 /* Note that this suffers from the same bug as native, in that if a new string
192 is a substring of an already added string, then the FINDSTRING will succeed
193 this is probably not what we want */
195 {
198 ret = TRUE;
199 }
200 return ret;
201}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
return ret
Definition: mutex.c:147
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
#define LB_ADDSTRING
Definition: winuser.h:2060
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define LB_FINDSTRING
Definition: winuser.h:2063
#define LB_SETITEMDATA
Definition: winuser.h:2101
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPCWSTR lpstrFormatName
Definition: oledlg.h:364
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by init_linklist(), and init_pastelist().

◆ dump_pastespecial()

static void dump_pastespecial ( const OLEUIPASTESPECIALW *  ps)
static

Definition at line 83 of file pastespl.c.

84{
85 INT i;
86 UINT j;
87
89 TRACE("hwnd %p caption %s hook %p custdata %Ix\n",
92 TRACE("hinst %p template %04x hresource %p\n", ps->hInstance, (WORD)(ULONG_PTR)ps->lpszTemplate, ps->hResource);
93 else
94 TRACE("hinst %p template %s hresource %p\n", ps->hInstance, debugstr_w(ps->lpszTemplate), ps->hResource);
95 TRACE("dataobj %p arrpasteent %p cpasteent %d arrlinktype %p clinktype %d\n",
97 ps->arrLinkTypes, ps->cLinkTypes);
98 TRACE("cclsidex %d lpclsidex %p nselect %d flink %d hmetapict %p size(%ld,%ld)\n",
100 ps->hMetaPict, ps->sizel.cx, ps->sizel.cy);
101 for(i = 0; i < ps->cPasteEntries; i++)
102 {
103 TRACE("arrPasteEntries[%d]: cFormat %08x pTargetDevice %p dwAspect %ld lindex %ld tymed %ld\n",
104 i, ps->arrPasteEntries[i].fmtetc.cfFormat, ps->arrPasteEntries[i].fmtetc.ptd,
105 ps->arrPasteEntries[i].fmtetc.dwAspect, ps->arrPasteEntries[i].fmtetc.lindex,
106 ps->arrPasteEntries[i].fmtetc.tymed);
107 TRACE("\tformat name %s result text %s flags %04lx\n", debugstr_w(ps->arrPasteEntries[i].lpstrFormatName),
109 }
110 for(i = 0; i < ps->cLinkTypes; i++)
111 TRACE("arrLinkTypes[%d] %08x\n", i, ps->arrLinkTypes[i]);
112 for(j = 0; j < ps->cClsidExclude; j++)
113 TRACE("lpClsidExclude[%u] %s\n", j, debugstr_guid(&ps->lpClsidExclude[j]));
114
115}
#define IS_INTRESOURCE(x)
Definition: loader.c:613
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
unsigned int UINT
Definition: sysinfo.c:13
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
static void dump_ps_flags(DWORD flags)
Definition: pastespl.c:69
#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

Referenced by OleUIPasteSpecialW().

◆ dump_ps_flags()

static void dump_ps_flags ( DWORD  flags)
static

Definition at line 69 of file pastespl.c.

70{
71 char flagstr[1000] = "";
72
73 const struct ps_flag *flag = ps_flags;
74 for( ; flag->name; flag++) {
75 if(flags & flag->flag) {
76 strcat(flagstr, flag->name);
77 strcat(flagstr, "|");
78 }
79 }
80 TRACE("flags %08lx %s\n", flags, flagstr);
81}
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[]
strcat
Definition: string.h:92

Referenced by dump_pastespecial().

◆ free_structure()

static void free_structure ( ps_struct_t *  ps_struct)
static

Definition at line 489 of file pastespl.c.

490{
491 free(ps_struct->type_name);
492 free(ps_struct->source_name);
493 free(ps_struct->link_type_name);
494 free(ps_struct->link_source_name);
495 CoTaskMemFree(ps_struct->app_name);
496 free(ps_struct);
497}
#define free
Definition: debug_ros.c:5
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
WCHAR * source_name
Definition: pastespl.c:44
LPOLESTR app_name
Definition: pastespl.c:48
WCHAR * link_type_name
Definition: pastespl.c:47
WCHAR * link_source_name
Definition: pastespl.c:45
WCHAR * type_name
Definition: pastespl.c:46

Referenced by ps_dlg_proc().

◆ get_descriptors()

static void get_descriptors ( HWND  hdlg,
ps_struct_t *  ps_struct 
)
static

Definition at line 128 of file pastespl.c.

129{
130 FORMATETC fmtetc;
131 STGMEDIUM stg;
132
133 fmtetc.tymed = TYMED_HGLOBAL;
134 fmtetc.dwAspect = DVASPECT_CONTENT;
135 fmtetc.ptd = NULL;
136 fmtetc.lindex = -1;
137
138 fmtetc.cfFormat = cf_object_descriptor;
139 if(IDataObject_GetData(ps_struct->ps->lpSrcDataObj, &fmtetc, &stg) == S_OK)
140 {
141 OBJECTDESCRIPTOR *obj_desc = GlobalLock(stg.hGlobal);
142 if(obj_desc->dwSrcOfCopy)
143 ps_struct->source_name = wcsdup((WCHAR*)((char*)obj_desc + obj_desc->dwSrcOfCopy));
144 if(obj_desc->dwFullUserTypeName)
145 ps_struct->type_name = wcsdup((WCHAR*)((char*)obj_desc + obj_desc->dwFullUserTypeName));
146 OleRegGetUserType(&obj_desc->clsid, USERCLASSTYPE_APPNAME, &ps_struct->app_name);
147 /* Get the icon here. If dwDrawAspect & DVASCPECT_ICON call GetData(CF_METAFILEPICT), otherwise
148 native calls OleGetIconFromClass(obj_desc->clsid) */
149 GlobalUnlock(stg.hGlobal);
150 GlobalFree(stg.hGlobal);
151 }
152 else
153 {
154 /* Try to get some data using some of the other clipboard formats */
155 }
156
157 fmtetc.cfFormat = cf_link_src_descriptor;
158 if(IDataObject_GetData(ps_struct->ps->lpSrcDataObj, &fmtetc, &stg) == S_OK)
159 {
160 OBJECTDESCRIPTOR *obj_desc = GlobalLock(stg.hGlobal);
161 if(obj_desc->dwSrcOfCopy)
162 ps_struct->link_source_name = wcsdup((WCHAR*)((char*)obj_desc + obj_desc->dwSrcOfCopy));
163 if(obj_desc->dwFullUserTypeName)
164 ps_struct->link_type_name = wcsdup((WCHAR*)((char*)obj_desc + obj_desc->dwFullUserTypeName));
165 GlobalUnlock(stg.hGlobal);
166 GlobalFree(stg.hGlobal);
167 }
168
169 if(ps_struct->source_name == NULL && ps_struct->link_source_name == NULL)
170 {
171 WCHAR buf[200];
173 ps_struct->source_name = wcsdup(buf);
174 }
175
176 if(ps_struct->type_name == NULL && ps_struct->link_type_name == NULL)
177 {
178 WCHAR buf[200];
180 ps_struct->type_name = wcsdup(buf);
181 }
182}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define NULL
Definition: types.h:112
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
HRESULT WINAPI OleRegGetUserType(REFCLSID clsid, DWORD form, LPOLESTR *usertype)
Definition: ole2.c:668
#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
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
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
UINT cf_link_src_descriptor
Definition: oledlg_main.c:45
UINT cf_object_descriptor
Definition: oledlg_main.c:44
short WCHAR
Definition: pedump.c:58
#define LoadStringW
Definition: utils.h:64
OLEUIPASTESPECIALW * ps
Definition: pastespl.c:42

Referenced by ps_dlg_proc().

◆ init_linklist()

static DWORD init_linklist ( HWND  hdlg,
OLEUIPASTESPECIALW *  ps 
)
static

Definition at line 247 of file pastespl.c.

248{
249 HRESULT hr;
250 DWORD supported_mask = 0;
251 DWORD items_added = 0;
252 int link, req_fmt;
253 FORMATETC fmt = {0, NULL, DVASPECT_CONTENT, -1, -1};
254
255 for(link = 0; link < ps->cLinkTypes && link < PS_MAXLINKTYPES; link++)
256 {
257 fmt.cfFormat = ps->arrLinkTypes[link];
258 hr = IDataObject_QueryGetData(ps->lpSrcDataObj, &fmt);
259 if(hr == S_OK)
260 supported_mask |= 1 << link;
261 }
262 TRACE("supported_mask %02lx\n", supported_mask);
263 for(req_fmt = 0; req_fmt < ps->cPasteEntries; req_fmt++)
264 {
265 DWORD linktypes;
267 linktypes = 0xff;
268 else
269 linktypes = ps->arrPasteEntries[req_fmt].dwFlags & 0xff;
270
271 if(linktypes & supported_mask)
272 {
274 items_added++;
275 }
276 }
277
278 EnableWindow(GetDlgItem(hdlg, IDC_PS_PASTELINK), items_added != 0);
279 return items_added;
280}
const WCHAR * link
Definition: db.cpp:998
HRESULT hr
Definition: delayimp.cpp:582
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:184
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
Definition: dsound.c:943

Referenced by init_lists().

◆ init_lists()

static void init_lists ( HWND  hdlg,
ps_struct_t *  ps_struct 
)
static

Definition at line 310 of file pastespl.c.

311{
312 DWORD pastes_added = init_pastelist(hdlg, ps_struct->ps);
313 DWORD links_added = init_linklist(hdlg, ps_struct->ps);
314 UINT check_id, list_id;
315
316 if((ps_struct->flags & (PSF_SELECTPASTE | PSF_SELECTPASTELINK)) == 0)
317 ps_struct->flags |= PSF_SELECTPASTE;
318
319 if(!pastes_added && !links_added)
320 ps_struct->flags &= ~(PSF_SELECTPASTE | PSF_SELECTPASTELINK);
321 else if(!pastes_added && (ps_struct->flags & PSF_SELECTPASTE))
322 {
323 ps_struct->flags &= ~PSF_SELECTPASTE;
324 ps_struct->flags |= PSF_SELECTPASTELINK;
325 }
326 else if(!links_added && (ps_struct->flags & PSF_SELECTPASTELINK))
327 {
328 ps_struct->flags &= ~PSF_SELECTPASTELINK;
329 ps_struct->flags |= PSF_SELECTPASTE;
330 }
331
332 check_id = 0;
333 list_id = 0;
334 if(ps_struct->flags & PSF_SELECTPASTE)
335 {
336 check_id = IDC_PS_PASTE;
337 list_id = IDC_PS_PASTELIST;
338 }
339 else if(ps_struct->flags & PSF_SELECTPASTELINK)
340 {
341 check_id = IDC_PS_PASTELINK;
342 list_id = IDC_PS_PASTELINKLIST;
343 }
344
346
347 if(list_id)
348 update_display_list(hdlg, list_id);
349 else
350 EnableWindow(GetDlgItem(hdlg, IDOK), 0);
351}
#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:247
static void update_display_list(HWND hdlg, UINT src_list_id)
Definition: pastespl.c:283
static DWORD init_pastelist(HWND hdlg, OLEUIPASTESPECIALW *ps)
Definition: pastespl.c:203
#define IDOK
Definition: winuser.h:841
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
DWORD flags
Definition: pastespl.c:43

Referenced by ps_dlg_proc().

◆ init_pastelist()

static DWORD init_pastelist ( HWND  hdlg,
OLEUIPASTESPECIALW *  ps 
)
static

Definition at line 203 of file pastespl.c.

204{
205 IEnumFORMATETC *penum;
206 HRESULT hr;
207 FORMATETC fmts[20];
208 DWORD fetched, items_added = 0;
209
210 hr = IDataObject_EnumFormatEtc(ps->lpSrcDataObj, DATADIR_GET, &penum);
211 if(FAILED(hr))
212 {
213 WARN("Unable to create IEnumFORMATETC\n");
214 return 0;
215 }
216
217 /* The native version grabs only the first 20 fmts and we do the same */
218 hr = IEnumFORMATETC_Next(penum, ARRAY_SIZE(fmts), fmts, &fetched);
219 TRACE("got %ld formats hr %08lx\n", fetched, hr);
220
221 if(SUCCEEDED(hr))
222 {
223 DWORD src_fmt, req_fmt;
224 for(req_fmt = 0; req_fmt < ps->cPasteEntries; req_fmt++)
225 {
226 /* This is used by update_structure() to set nSelectedIndex on exit */
227 ps->arrPasteEntries[req_fmt].dwScratchSpace = req_fmt;
228 TRACE("req_fmt %x\n", ps->arrPasteEntries[req_fmt].fmtetc.cfFormat);
229 for(src_fmt = 0; src_fmt < fetched; src_fmt++)
230 {
231 TRACE("\tenum'ed fmt %x\n", fmts[src_fmt].cfFormat);
232 if(ps->arrPasteEntries[req_fmt].fmtetc.cfFormat == fmts[src_fmt].cfFormat)
233 {
235 items_added++;
236 break;
237 }
238 }
239 }
240 }
241
242 IEnumFORMATETC_Release(penum);
243 EnableWindow(GetDlgItem(hdlg, IDC_PS_PASTE), items_added != 0);
244 return items_added;
245}
#define WARN(fmt,...)
Definition: precomp.h:61
#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 448 of file pastespl.c.

449{
450 if(id == IDC_PS_PASTE)
451 {
452 ps_struct->flags &= ~PSF_SELECTPASTELINK;
453 ps_struct->flags |= PSF_SELECTPASTE;
454 }
455 else
456 {
457 ps_struct->flags &= ~PSF_SELECTPASTE;
458 ps_struct->flags |= PSF_SELECTPASTELINK;
459 }
460
461 update_src_text(hdlg, ps_struct);
463 selection_change(hdlg, ps_struct);
464}
static void update_src_text(HWND hdlg, const ps_struct_t *ps_struct)
Definition: pastespl.c:353
static void selection_change(HWND hdlg, ps_struct_t *ps_struct)
Definition: pastespl.c:442

Referenced by ps_dlg_proc().

◆ OleUIPasteSpecialA()

UINT WINAPI OleUIPasteSpecialA ( LPOLEUIPASTESPECIALA  psA)

Definition at line 623 of file pastespl.c.

624{
626 UINT ret;
627 TRACE("(%p)\n", psA);
628
629 memcpy(&ps, psA, psA->cbStruct);
630
634
635 if(psA->cPasteEntries > 0)
636 {
637 DWORD size = psA->cPasteEntries * sizeof(ps.arrPasteEntries[0]);
638 INT i;
639
642 for(i = 0; i < psA->cPasteEntries; i++)
643 {
648 }
649 }
650
651 ret = OleUIPasteSpecialW(&ps);
652
653 if(psA->cPasteEntries > 0)
654 {
655 INT i;
656 for(i = 0; i < psA->cPasteEntries; i++)
657 {
660 }
662 }
664 free((WCHAR*)ps.lpszTemplate);
665 free((WCHAR*)ps.lpszCaption);
666
667 /* Copy back the output fields */
668 psA->dwFlags = ps.dwFlags;
669 psA->lpSrcDataObj = ps.lpSrcDataObj;
671 psA->fLink = ps.fLink;
672 psA->hMetaPict = ps.hMetaPict;
673 psA->sizel = ps.sizel;
674
675 return ret;
676}
#define malloc
Definition: debug_ros.c:4
GLsizeiptr size
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static WCHAR * strdupAtoW(const char *str)
Definition: pastespl.c:117
UINT WINAPI OleUIPasteSpecialW(LPOLEUIPASTESPECIALW ps)
Definition: pastespl.c:681
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 681 of file pastespl.c.

682{
684 UINT ret;
685
686 TRACE("(%p)\n", ps);
687
688 if(TRACE_ON(ole)) dump_pastespecial(ps);
689
690 if(!ps->lpSrcDataObj)
692
693 if(ps->hInstance || !ps->hResource)
694 {
697 HRSRC hrsrc;
698
701 if(!hrsrc) return OLEUI_ERR_FINDTEMPLATEFAILURE;
702 dlg_templ = LoadResource(hInst, hrsrc);
703 if(!dlg_templ) return OLEUI_ERR_LOADTEMPLATEFAILURE;
704 }
705
707
708 return ret;
709}
#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:2246
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:499
static void dump_pastespecial(const OLEUIPASTESPECIALW *ps)
Definition: pastespl.c:83
#define RT_DIALOG
Definition: pedump.c:367
const DLGTEMPLATE * LPCDLGTEMPLATEW
Definition: winuser.h:3177
INT_PTR WINAPI DialogBoxIndirectParamW(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
Definition: name.c:39
uint16_t * LPWSTR
Definition: typedefs.h:56

Referenced by OleUIPasteSpecialA().

◆ post_help_msg()

static void post_help_msg ( HWND  hdlg,
ps_struct_t *  ps_struct 
)
static

Definition at line 466 of file pastespl.c.

467{
469}
UINT_PTR WPARAM
Definition: minwindef.h:174
#define IDD_PASTESPECIAL
Definition: oledlg.h:445
UINT oleui_msg_help
Definition: oledlg_main.c:50
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 499 of file pastespl.c.

500{
501 /* native uses prop name "Structure", but we're not compatible
502 with that so we'll prepend "Wine_". */
503 static const WCHAR prop_name[] = {'W','i','n','e','_','S','t','r','u','c','t','u','r','e',0};
504 ps_struct_t *ps_struct;
505
506 TRACE("(%p, %04x, %08Ix, %08Ix)\n", hdlg, msg, wp, lp);
507
508 ps_struct = GetPropW(hdlg, prop_name);
509
510 if(msg != WM_INITDIALOG)
511 {
512 if(!ps_struct)
513 return 0;
514
515 if(ps_struct->ps->lpfnHook)
516 {
517 INT_PTR ret = ps_struct->ps->lpfnHook(hdlg, msg, wp, lp);
518 if(ret) return ret;
519 }
520 }
521
522 switch(msg)
523 {
524 case WM_INITDIALOG:
525 {
526 ps_struct = malloc(sizeof(*ps_struct));
527 ps_struct->ps = (OLEUIPASTESPECIALW*)lp;
528 ps_struct->type_name = NULL;
529 ps_struct->source_name = NULL;
530 ps_struct->link_type_name = NULL;
531 ps_struct->link_source_name = NULL;
532 ps_struct->app_name = NULL;
533 ps_struct->flags = ps_struct->ps->dwFlags;
534
535 SetPropW(hdlg, prop_name, ps_struct);
536
537 if(!(ps_struct->ps->dwFlags & PSF_SHOWHELP))
538 {
541 }
542
543 if(ps_struct->ps->lpszCaption)
544 SetWindowTextW(hdlg, ps_struct->ps->lpszCaption);
545
546 get_descriptors(hdlg, ps_struct);
547
548 init_lists(hdlg, ps_struct);
549
550 update_src_text(hdlg, ps_struct);
551
552 selection_change(hdlg, ps_struct);
553
555
556 if(ps_struct->ps->lpfnHook)
557 ps_struct->ps->lpfnHook(hdlg, msg, 0, 0);
558 return FALSE; /* use new focus */
559 }
560 case WM_COMMAND:
561 switch(LOWORD(wp))
562 {
564 switch(HIWORD(wp))
565 {
566 case LBN_SELCHANGE:
567 selection_change(hdlg, ps_struct);
568 return FALSE;
569 default:
570 return FALSE;
571 }
572 case IDC_PS_PASTE:
573 case IDC_PS_PASTELINK:
574 switch(HIWORD(wp))
575 {
576 case BN_CLICKED:
577 mode_change(hdlg, ps_struct, LOWORD(wp));
578 return FALSE;
579
580 default:
581 return FALSE;
582 }
583 case IDC_OLEUIHELP:
584 switch(HIWORD(wp))
585 {
586 case BN_CLICKED:
587 post_help_msg(hdlg, ps_struct);
588 return FALSE;
589 default:
590 return FALSE;
591 }
592 case IDOK:
593 case IDCANCEL:
594 switch(HIWORD(wp))
595 {
596 case BN_CLICKED:
597 send_end_dialog_msg(hdlg, ps_struct, LOWORD(wp));
598 return FALSE;
599 default:
600 return FALSE;
601 }
602 }
603 return FALSE;
604 default:
606 {
607 if(wp == IDOK)
608 update_structure(hdlg, ps_struct);
609 EndDialog(hdlg, wp);
610 /* native does its cleanup in WM_DESTROY */
611 RemovePropW(hdlg, prop_name);
612 free_structure(ps_struct);
613 return TRUE;
614 }
615 return FALSE;
616 }
617
618}
#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:128
static void init_lists(HWND hdlg, ps_struct_t *ps_struct)
Definition: pastespl.c:310
static void update_structure(HWND hdlg, ps_struct_t *ps_struct)
Definition: pastespl.c:476
static void free_structure(ps_struct_t *ps_struct)
Definition: pastespl.c:489
static void mode_change(HWND hdlg, ps_struct_t *ps_struct, UINT id)
Definition: pastespl.c:448
static void post_help_msg(HWND hdlg, ps_struct_t *ps_struct)
Definition: pastespl.c:466
static void send_end_dialog_msg(HWND hdlg, ps_struct_t *ps_struct, UINT id)
Definition: pastespl.c:471
#define LOWORD(l)
Definition: pedump.c:82
#define SW_HIDE
Definition: winuser.h:779
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
HANDLE WINAPI RemovePropW(_In_ HWND, _In_ LPCWSTR)
#define IDCANCEL
Definition: winuser.h:842
#define WM_COMMAND
Definition: winuser.h:1768
#define WM_INITDIALOG
Definition: winuser.h:1767
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:2111
#define BN_CLICKED
Definition: winuser.h:1954
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
int32_t INT_PTR
Definition: typedefs.h:64
#define HIWORD(l)
Definition: typedefs.h:247

Referenced by OleUIPasteSpecialW().

◆ selection_change()

static void selection_change ( HWND  hdlg,
ps_struct_t *  ps_struct 
)
static

Definition at line 442 of file pastespl.c.

443{
444 update_as_icon(hdlg, ps_struct);
445 update_result_text(hdlg, ps_struct);
446}
static void update_as_icon(HWND hdlg, ps_struct_t *ps_struct)
Definition: pastespl.c:376
static void update_result_text(HWND hdlg, const ps_struct_t *ps_struct)
Definition: pastespl.c:393

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 471 of file pastespl.c.

472{
473 SendMessageW(hdlg, oleui_msg_enddialog, id, 0);
474}

Referenced by ps_dlg_proc().

◆ strdupAtoW()

static WCHAR * strdupAtoW ( const char *  str)
inlinestatic

Definition at line 117 of file pastespl.c.

118{
119 DWORD len;
120 WCHAR *ret;
121 if(!str) return NULL;
122 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
123 ret = malloc(len * sizeof(WCHAR));
125 return ret;
126}
#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().

◆ update_as_icon()

static void update_as_icon ( HWND  hdlg,
ps_struct_t *  ps_struct 
)
static

Definition at line 376 of file pastespl.c.

377{
378 HWND icon_display = GetDlgItem(hdlg, IDC_PS_ICONDISPLAY);
379 HWND display_as_icon = GetDlgItem(hdlg, IDC_PS_DISPLAYASICON);
380 HWND change_icon = GetDlgItem(hdlg, IDC_PS_CHANGEICON);
381
382 /* FIXME. No as icon handling */
383 ps_struct->flags &= ~PSF_CHECKDISPLAYASICON;
384
386 EnableWindow(display_as_icon, 0);
387 ShowWindow(icon_display, SW_HIDE);
388 EnableWindow(icon_display, 0);
389 ShowWindow(change_icon, SW_HIDE);
390 EnableWindow(change_icon, 0);
391}
#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 283 of file pastespl.c.

284{
285 LONG count, i, old_pos;
286 WCHAR txt[256];
287 LONG item_data;
288 HWND display_list = GetDlgItem(hdlg, IDC_PS_DISPLAYLIST);
289 HWND list = GetDlgItem(hdlg, src_list_id);
290
291 old_pos = SendMessageW(display_list, LB_GETCURSEL, 0, 0);
292 if(old_pos == -1) old_pos = 0;
293
294 SendMessageW(display_list, WM_SETREDRAW, 0, 0);
295 SendMessageW(display_list, LB_RESETCONTENT, 0, 0);
297 for(i = 0; i < count; i++)
298 {
300 item_data = SendMessageW(list, LB_GETITEMDATA, i, 0);
301 SendMessageW(display_list, LB_INSERTSTRING, i, (LPARAM)txt);
302 SendMessageW(display_list, LB_SETITEMDATA, i, item_data);
303 }
304 SendMessageW(display_list, LB_SETCURSEL, 0, 0);
305 SendMessageW(display_list, WM_SETREDRAW, 1, 0);
306 if(GetForegroundWindow() == hdlg)
307 SetFocus(display_list);
308}
Definition: list.h:39
GLuint GLuint GLsizei count
Definition: gl.h:1545
long LONG
Definition: pedump.c:60
#define LB_GETCOUNT
Definition: winuser.h:2067
#define LB_GETITEMDATA
Definition: winuser.h:2070
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define LB_GETTEXT
Definition: winuser.h:2085
#define LB_RESETCONTENT
Definition: winuser.h:2091
#define LB_INSERTSTRING
Definition: winuser.h:2089
#define LB_SETCURSEL
Definition: winuser.h:2099
#define LB_GETCURSEL
Definition: winuser.h:2068
#define WM_SETREDRAW
Definition: winuser.h:1644

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 393 of file pastespl.c.

394{
395 WCHAR resource_txt[200];
396 UINT res_id;
397 OLEUIPASTEENTRYW *pent;
398 LONG cur_sel;
399 static const WCHAR percent_s[] = {'%','s',0};
400 WCHAR *result_txt, *ptr;
401
403 if(cur_sel == -1) return;
405
406 if(ps_struct->flags & PSF_SELECTPASTE)
407 {
408 if(ps_struct->flags & PSF_CHECKDISPLAYASICON)
410 else
411 res_id = IDS_PS_PASTE_DATA;
412 }
413 else
414 {
415 if(ps_struct->flags & PSF_CHECKDISPLAYASICON)
417 else
418 res_id = IDS_PS_PASTE_LINK_DATA;
419 }
420
421 LoadStringW(OLEDLG_hInstance, res_id, resource_txt, ARRAY_SIZE(resource_txt));
422 if((ptr = wcsstr(resource_txt, percent_s)))
423 {
424 /* FIXME handle %s in ResultText. Sub appname if IDS_PS_PASTE_OBJECT{_AS_ICON}. Else sub appropriate type name */
425 size_t result_txt_len = lstrlenW(pent->lpstrResultText);
426 ptrdiff_t offs = (char*)ptr - (char*)resource_txt;
427 result_txt = malloc((wcslen(resource_txt) + result_txt_len - 1) * sizeof(WCHAR));
428 memcpy(result_txt, resource_txt, offs);
429 memcpy((char*)result_txt + offs, pent->lpstrResultText, result_txt_len * sizeof(WCHAR));
430 memcpy((char*)result_txt + offs + result_txt_len * sizeof(WCHAR), ptr + 2, (lstrlenW(ptr + 2) + 1) * sizeof(WCHAR));
431 }
432 else
433 result_txt = resource_txt;
434
435 SetDlgItemTextW(hdlg, IDC_PS_RESULTTEXT, result_txt);
436
437 if(result_txt != resource_txt)
438 free(result_txt);
439
440}
#define lstrlenW
Definition: compat.h:750
int ptrdiff_t
Definition: corecrt.h:194
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
_ACRTIMP wchar_t *__cdecl wcsstr(const wchar_t *, const wchar_t *)
Definition: wcs.c:2998
#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
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 353 of file pastespl.c.

354{
355 WCHAR *str;
356
357 if(ps_struct->flags & PSF_SELECTPASTE)
358 {
359 if(ps_struct->source_name)
360 str = ps_struct->source_name;
361 else
362 str = ps_struct->link_source_name;
363
364 }
365 else
366 {
367 if(ps_struct->link_source_name)
368 str = ps_struct->link_source_name;
369 else
370 str = ps_struct->source_name;
371
372 }
374}
#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 476 of file pastespl.c.

477{
479 if(cur_sel != -1)
480 {
481 OLEUIPASTEENTRYW *pent;
483 ps_struct->ps->nSelectedIndex = pent->dwScratchSpace;
484 }
485 ps_struct->ps->dwFlags = ps_struct->flags;
486 ps_struct->ps->fLink = (ps_struct->flags & PSF_SELECTPASTELINK) != 0;
487}

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().