winex11.drv: Map coordinates before calling send_mouse_input.
[wine/zf.git] / dlls / ole2.dll16 / ole2.c
blob04b40b086354d2e52ffbc0f36af2f0ec343202b4
2 /*
3 * OLE2 library - 16 bit only interfaces
5 * Copyright 1995 Martin von Loewis
6 * Copyright 1999 Francis Beaudet
7 * Copyright 1999 Noel Borthwick
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include <assert.h>
25 #include <stdlib.h>
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <string.h>
30 #include "windef.h"
31 #include "winbase.h"
32 #include "wingdi.h"
33 #include "winuser.h"
34 #include "wownt32.h"
35 #include "ole2.h"
36 #include "winerror.h"
38 #include "wine/winbase16.h"
39 #include "wine/wingdi16.h"
40 #include "wine/winuser16.h"
41 #include "ifs.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(ole);
47 #define E_INVALIDARG16 MAKE_SCODE(SEVERITY_ERROR, FACILITY_NULL, 3)
49 static HICON convert_icon_to_32( HICON16 icon16 )
51 CURSORICONINFO *info = GlobalLock16( icon16 );
52 void *and_bits = info + 1;
53 void *xor_bits = (BYTE *)and_bits + info->nHeight * 2 * ((info->nWidth + 15) / 16);
54 HICON ret = CreateIcon( 0, info->nWidth, info->nHeight, info->bPlanes, info->bBitsPerPixel,
55 and_bits, xor_bits );
56 GlobalUnlock16( icon16 );
57 return ret;
60 /******************************************************************************
61 * OleBuildVersion (OLE2.1)
63 DWORD WINAPI OleBuildVersion16(void)
65 return OleBuildVersion();
68 /***********************************************************************
69 * OleInitialize (OLE2.2)
71 HRESULT WINAPI OleInitialize16(LPVOID reserved)
73 return OleInitialize( reserved );
76 /******************************************************************************
77 * OleUninitialize (OLE2.3)
79 void WINAPI OleUninitialize16(void)
81 OleUninitialize();
84 /***********************************************************************
85 * DllGetClassObject (OLE2.4)
87 HRESULT WINAPI DllGetClassObject16(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
89 FIXME("(%s, %s, %p): stub\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
90 return E_NOTIMPL;
93 /******************************************************************************
94 * GetRunningObjectTable (OLE2.30)
96 HRESULT WINAPI GetRunningObjectTable16(DWORD reserved, LPRUNNINGOBJECTTABLE *pprot)
98 FIXME("(%d,%p),stub!\n",reserved,pprot);
99 return E_NOTIMPL;
102 /***********************************************************************
103 * RegisterDragDrop (OLE2.35)
105 HRESULT WINAPI RegisterDragDrop16(
106 HWND16 hwnd,
107 LPDROPTARGET pDropTarget
109 FIXME("(0x%04x,%p),stub!\n",hwnd,pDropTarget);
110 return S_OK;
113 /***********************************************************************
114 * RevokeDragDrop (OLE2.36)
116 HRESULT WINAPI RevokeDragDrop16(
117 HWND16 hwnd
119 FIXME("(0x%04x),stub!\n",hwnd);
120 return S_OK;
123 /******************************************************************************
124 * OleMetaFilePictFromIconAndLabel (OLE2.56)
126 * Returns a global memory handle to a metafile which contains the icon and
127 * label given.
128 * I guess the result of that should look somehow like desktop icons.
129 * If no hIcon is given, we load the icon via lpszSourceFile and iIconIndex.
130 * This code might be wrong at some places.
132 HGLOBAL16 WINAPI OleMetafilePictFromIconAndLabel16(
133 HICON16 icon16,
134 LPCOLESTR16 lpszLabel,
135 LPCOLESTR16 lpszSourceFile,
136 UINT16 iIconIndex
138 METAFILEPICT *pict;
139 HGLOBAL hmf;
140 HGLOBAL16 hmf16;
141 LPWSTR label = NULL, source = NULL;
142 DWORD len;
143 HICON icon = convert_icon_to_32( icon16 );
145 if (lpszLabel)
147 len = MultiByteToWideChar( CP_ACP, 0, lpszLabel, -1, NULL, 0 );
148 label = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
149 MultiByteToWideChar( CP_ACP, 0, lpszLabel, -1, label, len );
151 if (lpszSourceFile)
153 len = MultiByteToWideChar( CP_ACP, 0, lpszSourceFile, -1, NULL, 0 );
154 source = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
155 MultiByteToWideChar( CP_ACP, 0, lpszSourceFile, -1, source, len );
157 hmf = OleMetafilePictFromIconAndLabel( icon, label, source, iIconIndex );
158 HeapFree( GetProcessHeap(), 0, label );
159 HeapFree( GetProcessHeap(), 0, source );
160 DestroyIcon( icon );
162 if (!hmf) return 0;
163 pict = GlobalLock( hmf );
165 hmf16 = GlobalAlloc16(0, sizeof(METAFILEPICT16));
166 if (hmf16)
168 METAFILEPICT16 *pict16 = GlobalLock16( hmf16 );
169 pict16->mm = pict->mm;
170 pict16->xExt = pict->xExt;
171 pict16->yExt = pict->yExt;
172 len = GetMetaFileBitsEx( pict->hMF, 0, 0 );
173 pict16->hMF = GlobalAlloc16( GMEM_MOVEABLE, len );
174 GetMetaFileBitsEx( pict->hMF, len, GlobalLock16( pict16->hMF) );
175 GlobalUnlock16( pict16->hMF );
176 GlobalUnlock16( hmf16 );
178 DeleteMetaFile( pict->hMF );
179 GlobalUnlock( hmf );
180 GlobalFree( hmf );
181 return hmf16;
185 /******************************************************************************
186 * CreateItemMoniker (OLE2.27)
188 HRESULT WINAPI CreateItemMoniker16(LPCOLESTR16 lpszDelim,LPCOLESTR16 lpszItem,LPMONIKER* ppmk)
190 FIXME("(%s,%p),stub!\n",lpszDelim,ppmk);
191 *ppmk = NULL;
192 return E_NOTIMPL;
196 /******************************************************************************
197 * CreateFileMoniker (OLE2.28)
199 HRESULT WINAPI CreateFileMoniker16(LPCOLESTR16 lpszPathName,LPMONIKER* ppmk)
201 FIXME("(%s,%p),stub!\n",lpszPathName,ppmk);
202 return E_NOTIMPL;
205 /******************************************************************************
206 * OleSetMenuDescriptor (OLE2.41)
208 * PARAMS
209 * hOleMenu FIXME: Should probably be an HOLEMENU16.
211 HRESULT WINAPI OleSetMenuDescriptor16(
212 HOLEMENU hOleMenu,
213 HWND16 hwndFrame,
214 HWND16 hwndActiveObject,
215 LPOLEINPLACEFRAME lpFrame,
216 LPOLEINPLACEACTIVEOBJECT lpActiveObject)
218 FIXME("(%p, %x, %x, %p, %p), stub!\n", hOleMenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObject);
219 return E_NOTIMPL;
222 /******************************************************************************
223 * OleLoad [OLE2.12]
225 * PARAMS
226 * pStg Segmented LPSTORAGE pointer.
227 * pClientSite Segmented LPOLECLIENTSITE pointer.
229 HRESULT WINAPI OleLoad16(
230 SEGPTR pStg,
231 REFIID riid,
232 SEGPTR pClientSite,
233 LPVOID* ppvObj)
235 FIXME("(%x,%s,%x,%p), stub!\n", pStg, debugstr_guid(riid), pClientSite, ppvObj);
236 return E_NOTIMPL;
239 /******************************************************************************
240 * OleDoAutoConvert [OLE2.79]
242 HRESULT WINAPI OleDoAutoConvert16(LPSTORAGE pStg, LPCLSID pClsidNew)
244 FIXME("(%p,%p) : stub\n",pStg,pClsidNew);
245 return E_NOTIMPL;
248 /***********************************************************************
249 * OleSetClipboard [OLE2.49]
251 HRESULT WINAPI OleSetClipboard16(IDataObject* pDataObj)
253 FIXME("(%p): stub\n", pDataObj);
254 return S_OK;
257 /***********************************************************************
258 * OleGetClipboard [OLE2.50]
260 HRESULT WINAPI OleGetClipboard16(IDataObject** ppDataObj)
262 FIXME("(%p): stub\n", ppDataObj);
263 return E_NOTIMPL;
266 /***********************************************************************
267 * OleFlushClipboard [OLE2.76]
270 HRESULT WINAPI OleFlushClipboard16(void)
272 return OleFlushClipboard();
275 /***********************************************************************
276 * OleIsCurrentClipboard [OLE2.77]
278 HRESULT WINAPI OleIsCurrentClipboard16(IDataObject* pDataObj)
280 FIXME("(%p): stub\n", pDataObj);
281 return S_OK;
284 #define GET_SEGPTR_METHOD_ADDR(ifacename,segptr,methodname) \
285 ((SEGPTR)((const ifacename##Vtbl*)MapSL((SEGPTR)((ifacename*)MapSL(segptr))->lpVtbl))->methodname)
287 /***********************************************************************
288 * ReadClassStg (OLE2.18)
290 * This method reads the CLSID previously written to a storage object with
291 * the WriteClassStg.
293 * PARAMS
294 * pstg [I] Segmented LPSTORAGE pointer.
295 * pclsid [O] Pointer to where the CLSID is written
297 * RETURNS
298 * Success: S_OK.
299 * Failure: HRESULT code.
301 HRESULT WINAPI ReadClassStg16(SEGPTR pstg, CLSID *pclsid)
303 STATSTG16 statstg;
304 HANDLE16 hstatstg;
305 HRESULT hres;
306 DWORD args[3];
308 TRACE("(%x, %p)\n", pstg, pclsid);
310 if (!pclsid)
311 return E_INVALIDARG16;
313 memset(pclsid, 0, sizeof(*pclsid));
315 if (!pstg)
316 return E_INVALIDARG16;
319 * read a STATSTG structure (contains the clsid) from the storage
321 args[0] = pstg; /* iface */
322 args[1] = WOWGlobalAllocLock16( 0, sizeof(STATSTG16), &hstatstg );
323 args[2] = STATFLAG_DEFAULT;
325 if (!WOWCallback16Ex(
326 GET_SEGPTR_METHOD_ADDR(IStorage16, pstg, Stat),
327 WCB16_PASCAL,
328 3*sizeof(DWORD),
329 args,
330 (LPDWORD)&hres
331 )) {
332 WOWGlobalUnlockFree16(args[1]);
333 ERR("CallTo16 IStorage16::Stat() failed, hres %x\n",hres);
334 return hres;
336 memcpy(&statstg, MapSL(args[1]), sizeof(STATSTG16));
337 WOWGlobalUnlockFree16(args[1]);
339 if(SUCCEEDED(hres)) {
340 *pclsid=statstg.clsid;
341 TRACE("clsid is %s\n", debugstr_guid(&statstg.clsid));
343 return hres;
346 /***********************************************************************
347 * ReadClassStm (OLE2.20)
349 HRESULT WINAPI ReadClassStm16(SEGPTR stream, CLSID *clsid)
351 HANDLE16 hclsid, hread;
352 HRESULT hres;
353 DWORD args[4];
355 TRACE("(0x%x, %p)\n", stream, clsid);
357 if (!clsid)
358 return E_INVALIDARG16;
360 memset(clsid, 0, sizeof(*clsid));
362 if (!stream)
363 return E_INVALIDARG16;
365 args[0] = stream; /* iface */
366 args[1] = WOWGlobalAllocLock16( 0, sizeof(CLSID), &hclsid );
367 args[2] = sizeof(CLSID);
368 args[3] = WOWGlobalAllocLock16( 0, sizeof(ULONG), &hread );
370 if (WOWCallback16Ex(
371 GET_SEGPTR_METHOD_ADDR(IStream16, stream, Read),
372 WCB16_PASCAL,
373 4*sizeof(DWORD),
374 args,
375 (DWORD*)&hres))
377 ULONG readlen;
379 memcpy(&readlen, MapSL(args[3]), sizeof(readlen));
380 if (readlen == sizeof(CLSID))
381 memcpy(clsid, MapSL(args[1]), sizeof(CLSID));
382 else
383 hres = STG_E_READFAULT;
385 TRACE("clsid is %s\n", debugstr_guid(clsid));
387 else
389 ERR("CallTo16 IStream16::Read() failed, hres %x\n", hres);
390 hres = E_FAIL;
392 WOWGlobalUnlockFree16(args[1]);
393 WOWGlobalUnlockFree16(args[3]);
395 return hres;
398 /***********************************************************************
399 * GetConvertStg (OLE2.82)
401 HRESULT WINAPI GetConvertStg16(LPSTORAGE stg)
403 FIXME("unimplemented stub!\n");
404 return E_FAIL;
407 /***********************************************************************
408 * ReleaseStgMedium (OLE2.32)
410 VOID WINAPI ReleaseStgMedium16(LPSTGMEDIUM medium)
412 FIXME("%p: unimplemented stub!\n", medium);
415 /***********************************************************************
416 * WriteClassStg16 (OLE2.19)
418 HRESULT WINAPI WriteClassStg16(IStorage *stg, REFCLSID clsid)
420 FIXME("stub:%p %s\n", stg, debugstr_guid(clsid));
421 return STG_E_MEDIUMFULL;