source: trunk/src/shell32/clipboard.c@ 5655

Last change on this file since 5655 was 4121, checked in by sandervl, 25 years ago

complete merge with shell32 from wine 20000801

File size: 6.1 KB
Line 
1/* $Id: clipboard.c,v 1.1 2000-08-30 13:52:50 sandervl Exp $ */
2/*
3 * clipboard helper functions
4 *
5 * Copyright 2000 Juergen Schmied <juergen.schmied@debitel.de>
6 *
7 * For copy & paste functions within contextmenus does the shell use
8 * the OLE clipboard functions in combination with dataobjects.
9 * The OLE32.DLL gets loaded with LoadLibrary
10 *
11 * - a right mousebutton-copy sets the following formats:
12 * classic:
13 * Shell IDList Array
14 * Prefered Drop Effect
15 * Shell Object Offsets
16 * HDROP
17 * FileName
18 * ole:
19 * OlePrivateData (ClipboardDataObjectInterface)
20 *
21 */
22#ifdef __WIN32OS2__
23#define ICOM_CINTERFACE 1
24#include <odin.h>
25#endif
26
27#include <string.h>
28
29#include "debugtools.h"
30
31#include "pidl.h"
32#include "wine/undocshell.h"
33#include "shell32_main.h"
34#include "shell.h" /* DROPFILESTRUCT */
35
36DEFAULT_DEBUG_CHANNEL(shell)
37
38static int refClipCount = 0;
39static HINSTANCE hShellOle32 = 0;
40
41/**************************************************************************
42 * InitShellOle
43 *
44 *
45 */
46void InitShellOle(void)
47{
48}
49
50/**************************************************************************
51 * FreeShellOle
52 *
53 * unload OLE32.DLL
54 */
55void FreeShellOle(void)
56{
57 if (!--refClipCount)
58 {
59 pOleUninitialize();
60 FreeLibrary(hShellOle32);
61 }
62}
63
64/**************************************************************************
65 * LoadShellOle
66 *
67 * make sure OLE32.DLL is loaded
68 */
69BOOL GetShellOle(void)
70{
71 if(!refClipCount)
72 {
73 hShellOle32 = LoadLibraryA("ole32.dll");
74 if(hShellOle32)
75 {
76 pOleInitialize=(void*)GetProcAddress(hShellOle32,"OleInitialize");
77 pOleUninitialize=(void*)GetProcAddress(hShellOle32,"OleUninitialize");
78 pRegisterDragDrop=(void*)GetProcAddress(hShellOle32,"RegisterDragDrop");
79 pRevokeDragDrop=(void*)GetProcAddress(hShellOle32,"RevokeDragDrop");
80 pDoDragDrop=(void*)GetProcAddress(hShellOle32,"DoDragDrop");
81 pReleaseStgMedium=(void*)GetProcAddress(hShellOle32,"ReleaseStgMedium");
82 pOleSetClipboard=(void*)GetProcAddress(hShellOle32,"OleSetClipboard");
83 pOleGetClipboard=(void*)GetProcAddress(hShellOle32,"OleGetClipboard");
84
85 pOleInitialize(NULL);
86 refClipCount++;
87 }
88 }
89 return TRUE;
90}
91
92/**************************************************************************
93 * RenderHDROP
94 *
95 * creates a CF_HDROP structure
96 */
97HGLOBAL RenderHDROP(LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
98{
99 int i;
100 int rootsize = 0,size = 0;
101 char szRootPath[MAX_PATH];
102 char szFileName[MAX_PATH];
103 HGLOBAL hGlobal;
104 LPDROPFILESTRUCT pDropFiles;
105 int offset;
106
107 TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
108
109 /* get the size needed */
110 size = sizeof(DROPFILESTRUCT);
111
112 SHGetPathFromIDListA(pidlRoot, szRootPath);
113 PathAddBackslashA(szRootPath);
114 rootsize = strlen(szRootPath);
115
116 for (i=0; i<cidl;i++)
117 {
118 _ILSimpleGetText(apidl[i], szFileName, MAX_PATH);
119 size += rootsize + strlen(szFileName) + 1;
120 }
121
122 size++;
123
124 /* Fill the structure */
125 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
126 if(!hGlobal) return hGlobal;
127
128 pDropFiles = (LPDROPFILESTRUCT)GlobalLock(hGlobal);
129 pDropFiles->lSize = sizeof(DROPFILESTRUCT);
130 pDropFiles->fWideChar = FALSE;
131
132 offset = pDropFiles->lSize;
133 strcpy(szFileName, szRootPath);
134
135 for (i=0; i<cidl;i++)
136 {
137
138 _ILSimpleGetText(apidl[i], szFileName + rootsize, MAX_PATH - rootsize);
139 size = strlen(szFileName) + 1;
140 strcpy(((char*)pDropFiles)+offset, szFileName);
141 offset += size;
142 }
143
144 ((char*)pDropFiles)[offset] = 0;
145 GlobalUnlock(hGlobal);
146
147 return hGlobal;
148}
149
150HGLOBAL RenderSHELLIDLIST (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
151{
152 int i,offset = 0, sizePidl, size;
153 HGLOBAL hGlobal;
154 LPCIDA pcida;
155
156 TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
157
158 /* get the size needed */
159 size = sizeof(CIDA) + sizeof (UINT)*(cidl); /* header */
160 size += ILGetSize (pidlRoot); /* root pidl */
161 for(i=0; i<cidl; i++)
162 {
163 size += ILGetSize(apidl[i]); /* child pidls */
164 }
165
166 /* fill the structure */
167 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
168 if(!hGlobal) return hGlobal;
169 pcida = GlobalLock (hGlobal);
170 pcida->cidl = cidl;
171
172 /* root pidl */
173 offset = sizeof(CIDA) + sizeof (UINT)*(cidl);
174 pcida->aoffset[0] = offset; /* first element */
175 sizePidl = ILGetSize (pidlRoot);
176 memcpy(((LPBYTE)pcida)+offset, pidlRoot, sizePidl);
177 offset += sizePidl;
178
179 for(i=0; i<cidl; i++) /* child pidls */
180 {
181 pcida->aoffset[i+1] = offset;
182 sizePidl = ILGetSize(apidl[i]);
183 memcpy(((LPBYTE)pcida)+offset, apidl[i], sizePidl);
184 offset += sizePidl;
185 }
186
187 GlobalUnlock(hGlobal);
188 return hGlobal;
189}
190
191HGLOBAL RenderSHELLIDLISTOFFSET (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
192{
193 FIXME("\n");
194 return 0;
195}
196
197HGLOBAL RenderFILECONTENTS (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
198{
199 FIXME("\n");
200 return 0;
201}
202
203HGLOBAL RenderFILEDESCRIPTOR (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
204{
205 FIXME("\n");
206 return 0;
207}
208
209HGLOBAL RenderFILENAME (LPITEMIDLIST pidlRoot, LPITEMIDLIST * apidl, UINT cidl)
210{
211 int len, size = 0;
212 char szTemp[MAX_PATH], *szFileName;
213 HGLOBAL hGlobal;
214
215 TRACE("(%p,%p,%u)\n", pidlRoot, apidl, cidl);
216
217 /* build name of first file */
218 SHGetPathFromIDListA(pidlRoot, szTemp);
219 PathAddBackslashA(szTemp);
220 len = strlen(szTemp);
221 _ILSimpleGetText(apidl[0], szTemp+len, MAX_PATH - len);
222 size = strlen(szTemp) + 1;
223
224 /* fill the structure */
225 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, size);
226 if(!hGlobal) return hGlobal;
227 szFileName = (char *)GlobalLock(hGlobal);
228 GlobalUnlock(hGlobal);
229 return hGlobal;
230}
231
232HGLOBAL RenderPREFEREDDROPEFFECT (DWORD dwFlags)
233{
234 DWORD * pdwFlag;
235 HGLOBAL hGlobal;
236
237 TRACE("(0x%08lx)\n", dwFlags);
238
239 hGlobal = GlobalAlloc(GHND|GMEM_SHARE, sizeof(DWORD));
240 if(!hGlobal) return hGlobal;
241 pdwFlag = (DWORD*)GlobalLock(hGlobal);
242 *pdwFlag = dwFlags;
243 GlobalUnlock(hGlobal);
244 return hGlobal;
245}
246
247/**************************************************************************
248 * IsDataInClipboard
249 *
250 * checks if there is something in the clipboard we can use
251 */
252BOOL IsDataInClipboard (HWND hwnd)
253{
254 BOOL ret = FALSE;
255
256 if (OpenClipboard(hwnd))
257 {
258 if (GetOpenClipboardWindow())
259 {
260 ret = IsClipboardFormatAvailable(CF_TEXT);
261 }
262 CloseClipboard();
263 }
264 return ret;
265}
Note: See TracBrowser for help on using the repository browser.