ntoskrnl.exe: Implemented a couple of time-related APIs.
[wine/dibdrv.git] / dlls / riched20 / richole.c
blob0585e43edf83230f71a656a1663d5defba907641
1 /*
2 * RichEdit GUIDs and OLE interface
4 * Copyright 2004 by Krzysztof Foltman
5 * Copyright 2004 Aric Stewart
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <stdarg.h>
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
26 #define COBJMACROS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "ole2.h"
33 #include "richole.h"
34 #include "editor.h"
35 #include "tom.h"
36 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
40 /* there is no way to be consistent across different sets of headers - mingw, Wine, Win32 SDK*/
42 /* FIXME: the next 6 lines should be in textserv.h */
43 #include "initguid.h"
44 #define TEXTSERV_GUID(name, l, w1, w2, b1, b2) \
45 DEFINE_GUID(name, l, w1, w2, b1, b2, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5)
47 TEXTSERV_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d);
48 TEXTSERV_GUID(IID_ITextHost, 0xc5bdd8d0, 0xd26e, 0x11ce, 0xa8, 0x9e);
49 TEXTSERV_GUID(IID_ITextHost2, 0xc5bdd8d0, 0xd26e, 0x11ce, 0xa8, 0x9e);
50 DEFINE_GUID(IID_ITextDocument, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
52 typedef struct IRichEditOleImpl {
53 const IRichEditOleVtbl *lpRichEditOleVtbl;
54 const ITextDocumentVtbl *lpTextDocumentVtbl;
55 LONG ref;
57 ME_TextEditor *editor;
58 } IRichEditOleImpl;
60 static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface)
62 return (IRichEditOleImpl *)((BYTE*)iface - FIELD_OFFSET(IRichEditOleImpl, lpRichEditOleVtbl));
65 static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface)
67 return (IRichEditOleImpl *)((BYTE*)iface - FIELD_OFFSET(IRichEditOleImpl, lpTextDocumentVtbl));
70 static HRESULT WINAPI
71 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
73 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
75 TRACE("%p %s\n", This, debugstr_guid(riid) );
77 *ppvObj = NULL;
78 if (IsEqualGUID(riid, &IID_IUnknown) ||
79 IsEqualGUID(riid, &IID_IRichEditOle))
80 *ppvObj = &This->lpRichEditOleVtbl;
81 else if (IsEqualGUID(riid, &IID_ITextDocument))
82 *ppvObj = &This->lpTextDocumentVtbl;
83 if (*ppvObj)
85 IRichEditOle_AddRef(me);
86 return S_OK;
88 FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid) );
90 return E_NOINTERFACE;
93 static ULONG WINAPI
94 IRichEditOle_fnAddRef(IRichEditOle *me)
96 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
97 ULONG ref = InterlockedIncrement( &This->ref );
99 TRACE("%p ref = %u\n", This, ref);
101 return ref;
104 static ULONG WINAPI
105 IRichEditOle_fnRelease(IRichEditOle *me)
107 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
108 ULONG ref = InterlockedDecrement(&This->ref);
110 TRACE ("%p ref=%u\n", This, ref);
112 if (!ref)
114 TRACE ("Destroying %p\n", This);
115 richedit_free(This);
117 return ref;
120 static HRESULT WINAPI
121 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
123 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
124 FIXME("stub %p\n",This);
125 return E_NOTIMPL;
128 static HRESULT WINAPI
129 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
131 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
132 FIXME("stub %p\n",This);
133 return E_NOTIMPL;
136 static HRESULT WINAPI
137 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
138 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
140 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
141 FIXME("stub %p\n",This);
142 return E_NOTIMPL;
145 static HRESULT WINAPI
146 IRichEditOle_fnGetClientSite(IRichEditOle *me,
147 LPOLECLIENTSITE *lplpolesite)
149 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
150 FIXME("stub %p\n",This);
151 return E_NOTIMPL;
154 static HRESULT WINAPI
155 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
156 DWORD reco, LPDATAOBJECT *lplpdataobj)
158 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
159 CHARRANGE tmpchrg;
161 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
162 if(!lplpdataobj)
163 return E_INVALIDARG;
164 if(!lpchrg) {
165 ME_GetSelection(This->editor, (int*)&tmpchrg.cpMin, (int*)&tmpchrg.cpMax);
166 lpchrg = &tmpchrg;
168 return ME_GetDataObject(This->editor, lpchrg, lplpdataobj);
171 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
173 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
174 FIXME("stub %p\n",This);
175 return E_NOTIMPL;
178 static HRESULT WINAPI
179 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
180 REOBJECT *lpreobject, DWORD dwFlags)
182 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
183 FIXME("stub %p\n",This);
184 return E_NOTIMPL;
187 static LONG WINAPI
188 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
190 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
191 FIXME("stub %p\n",This);
192 return E_NOTIMPL;
195 static HRESULT WINAPI
196 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
198 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
199 FIXME("stub %p\n",This);
200 return E_NOTIMPL;
203 static HRESULT WINAPI
204 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
205 CLIPFORMAT cf, HGLOBAL hMetaPict)
207 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
208 FIXME("stub %p\n",This);
209 return E_NOTIMPL;
212 static HRESULT WINAPI
213 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
215 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
216 FIXME("stub %p\n",This);
217 return E_NOTIMPL;
220 static HRESULT WINAPI
221 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *lpreobject)
223 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
224 FIXME("stub %p\n",This);
225 return E_NOTIMPL;
228 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
229 LPSTORAGE lpstg)
231 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
232 FIXME("stub %p\n",This);
233 return E_NOTIMPL;
236 static HRESULT WINAPI
237 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
239 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
240 FIXME("stub %p\n",This);
241 return E_NOTIMPL;
244 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
245 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
247 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
248 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
249 return E_NOTIMPL;
252 static HRESULT WINAPI
253 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
255 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
256 FIXME("stub %p\n",This);
257 return E_NOTIMPL;
260 static const IRichEditOleVtbl revt = {
261 IRichEditOle_fnQueryInterface,
262 IRichEditOle_fnAddRef,
263 IRichEditOle_fnRelease,
264 IRichEditOle_fnGetClientSite,
265 IRichEditOle_fnGetObjectCount,
266 IRichEditOle_fnGetLinkCount,
267 IRichEditOle_fnGetObject,
268 IRichEditOle_fnInsertObject,
269 IRichEditOle_fnConvertObject,
270 IRichEditOle_fnActivateAs,
271 IRichEditOle_fnSetHostNames,
272 IRichEditOle_fnSetLinkAvailable,
273 IRichEditOle_fnSetDvaspect,
274 IRichEditOle_fnHandsOffStorage,
275 IRichEditOle_fnSaveCompleted,
276 IRichEditOle_fnInPlaceDeactivate,
277 IRichEditOle_fnContextSensitiveHelp,
278 IRichEditOle_fnGetClipboardData,
279 IRichEditOle_fnImportDataObject
282 static HRESULT WINAPI
283 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
284 void** ppvObject)
286 IRichEditOleImpl *This = impl_from_ITextDocument(me);
287 return IRichEditOle_fnQueryInterface((IRichEditOle*)&This->lpRichEditOleVtbl,
288 riid, ppvObject);
291 static ULONG WINAPI
292 ITextDocument_fnAddRef(ITextDocument* me)
294 IRichEditOleImpl *This = impl_from_ITextDocument(me);
295 return IRichEditOle_fnAddRef((IRichEditOle*)&This->lpRichEditOleVtbl);
298 static ULONG WINAPI
299 ITextDocument_fnRelease(ITextDocument* me)
301 IRichEditOleImpl *This = impl_from_ITextDocument(me);
302 return IRichEditOle_fnRelease((IRichEditOle*)&This->lpRichEditOleVtbl);
305 static HRESULT WINAPI
306 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
307 UINT* pctinfo)
309 IRichEditOleImpl *This = impl_from_ITextDocument(me);
310 FIXME("stub %p\n",This);
311 return E_NOTIMPL;
314 static HRESULT WINAPI
315 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
316 ITypeInfo** ppTInfo)
318 IRichEditOleImpl *This = impl_from_ITextDocument(me);
319 FIXME("stub %p\n",This);
320 return E_NOTIMPL;
323 static HRESULT WINAPI
324 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
325 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
327 IRichEditOleImpl *This = impl_from_ITextDocument(me);
328 FIXME("stub %p\n",This);
329 return E_NOTIMPL;
332 static HRESULT WINAPI
333 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
334 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
335 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
337 IRichEditOleImpl *This = impl_from_ITextDocument(me);
338 FIXME("stub %p\n",This);
339 return E_NOTIMPL;
342 static HRESULT WINAPI
343 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
345 IRichEditOleImpl *This = impl_from_ITextDocument(me);
346 FIXME("stub %p\n",This);
347 return E_NOTIMPL;
350 static HRESULT WINAPI
351 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
353 IRichEditOleImpl *This = impl_from_ITextDocument(me);
354 FIXME("stub %p\n",This);
355 return E_NOTIMPL;
358 static HRESULT WINAPI
359 ITextDocument_fnGetStoryCount(ITextDocument* me, long* pCount)
361 IRichEditOleImpl *This = impl_from_ITextDocument(me);
362 FIXME("stub %p\n",This);
363 return E_NOTIMPL;
366 static HRESULT WINAPI
367 ITextDocument_fnGetStoryRanges(ITextDocument* me,
368 ITextStoryRanges** ppStories)
370 IRichEditOleImpl *This = impl_from_ITextDocument(me);
371 FIXME("stub %p\n",This);
372 return E_NOTIMPL;
375 static HRESULT WINAPI
376 ITextDocument_fnGetSaved(ITextDocument* me, long* pValue)
378 IRichEditOleImpl *This = impl_from_ITextDocument(me);
379 FIXME("stub %p\n",This);
380 return E_NOTIMPL;
383 static HRESULT WINAPI
384 ITextDocument_fnSetSaved(ITextDocument* me, long Value)
386 IRichEditOleImpl *This = impl_from_ITextDocument(me);
387 FIXME("stub %p\n",This);
388 return E_NOTIMPL;
391 static HRESULT WINAPI
392 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
394 IRichEditOleImpl *This = impl_from_ITextDocument(me);
395 FIXME("stub %p\n",This);
396 return E_NOTIMPL;
399 static HRESULT WINAPI
400 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
402 IRichEditOleImpl *This = impl_from_ITextDocument(me);
403 FIXME("stub %p\n",This);
404 return E_NOTIMPL;
407 static HRESULT WINAPI
408 ITextDocument_fnNew(ITextDocument* me)
410 IRichEditOleImpl *This = impl_from_ITextDocument(me);
411 FIXME("stub %p\n",This);
412 return E_NOTIMPL;
415 static HRESULT WINAPI
416 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, long Flags,
417 long CodePage)
419 IRichEditOleImpl *This = impl_from_ITextDocument(me);
420 FIXME("stub %p\n",This);
421 return E_NOTIMPL;
424 static HRESULT WINAPI
425 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, long Flags,
426 long CodePage)
428 IRichEditOleImpl *This = impl_from_ITextDocument(me);
429 FIXME("stub %p\n",This);
430 return E_NOTIMPL;
433 static HRESULT WINAPI
434 ITextDocument_fnFreeze(ITextDocument* me, long* pCount)
436 IRichEditOleImpl *This = impl_from_ITextDocument(me);
437 FIXME("stub %p\n",This);
438 return E_NOTIMPL;
441 static HRESULT WINAPI
442 ITextDocument_fnUnfreeze(ITextDocument* me, long* pCount)
444 IRichEditOleImpl *This = impl_from_ITextDocument(me);
445 FIXME("stub %p\n",This);
446 return E_NOTIMPL;
449 static HRESULT WINAPI
450 ITextDocument_fnBeginEditCollection(ITextDocument* me)
452 IRichEditOleImpl *This = impl_from_ITextDocument(me);
453 FIXME("stub %p\n",This);
454 return E_NOTIMPL;
457 static HRESULT WINAPI
458 ITextDocument_fnEndEditCollection(ITextDocument* me)
460 IRichEditOleImpl *This = impl_from_ITextDocument(me);
461 FIXME("stub %p\n",This);
462 return E_NOTIMPL;
465 static HRESULT WINAPI
466 ITextDocument_fnUndo(ITextDocument* me, long Count, long* prop)
468 IRichEditOleImpl *This = impl_from_ITextDocument(me);
469 FIXME("stub %p\n",This);
470 return E_NOTIMPL;
473 static HRESULT WINAPI
474 ITextDocument_fnRedo(ITextDocument* me, long Count, long* prop)
476 IRichEditOleImpl *This = impl_from_ITextDocument(me);
477 FIXME("stub %p\n",This);
478 return E_NOTIMPL;
481 static HRESULT WINAPI
482 ITextDocument_fnRange(ITextDocument* me, long cp1, long cp2,
483 ITextRange** ppRange)
485 IRichEditOleImpl *This = impl_from_ITextDocument(me);
486 FIXME("stub %p\n",This);
487 return E_NOTIMPL;
490 static HRESULT WINAPI
491 ITextDocument_fnRangeFromPoint(ITextDocument* me, long x, long y,
492 ITextRange** ppRange)
494 IRichEditOleImpl *This = impl_from_ITextDocument(me);
495 FIXME("stub %p\n",This);
496 return E_NOTIMPL;
499 static const ITextDocumentVtbl tdvt = {
500 ITextDocument_fnQueryInterface,
501 ITextDocument_fnAddRef,
502 ITextDocument_fnRelease,
503 ITextDocument_fnGetTypeInfoCount,
504 ITextDocument_fnGetTypeInfo,
505 ITextDocument_fnGetIDsOfNames,
506 ITextDocument_fnInvoke,
507 ITextDocument_fnGetName,
508 ITextDocument_fnGetSelection,
509 ITextDocument_fnGetStoryCount,
510 ITextDocument_fnGetStoryRanges,
511 ITextDocument_fnGetSaved,
512 ITextDocument_fnSetSaved,
513 ITextDocument_fnGetDefaultTabStop,
514 ITextDocument_fnSetDefaultTabStop,
515 ITextDocument_fnNew,
516 ITextDocument_fnOpen,
517 ITextDocument_fnSave,
518 ITextDocument_fnFreeze,
519 ITextDocument_fnUnfreeze,
520 ITextDocument_fnBeginEditCollection,
521 ITextDocument_fnEndEditCollection,
522 ITextDocument_fnUndo,
523 ITextDocument_fnRedo,
524 ITextDocument_fnRange,
525 ITextDocument_fnRangeFromPoint
528 LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj)
530 IRichEditOleImpl *reo;
532 reo = richedit_alloc(sizeof(IRichEditOleImpl));
533 if (!reo)
534 return 0;
536 reo->lpRichEditOleVtbl = &revt;
537 reo->lpTextDocumentVtbl = &tdvt;
538 reo->ref = 1;
539 reo->editor = editor;
540 TRACE("Created %p\n",reo);
541 *ppObj = (LPVOID) reo;
543 return 1;