b9e7699f8644d65afcb59151886548867f2318ab
[reactos.git] / reactos / dll / win32 / riched20 / richole.c
1 /*
2 * RichEdit GUIDs and OLE interface
3 *
4 * Copyright 2004 by Krzysztof Foltman
5 * Copyright 2004 Aric Stewart
6 *
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.
11 *
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.
16 *
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
20 */
21
22 #include "editor.h"
23
24 #include <tom.h>
25
26 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
27
28 /* there is no way to be consistent across different sets of headers - mingw, Wine, Win32 SDK*/
29
30 #include <initguid.h>
31 DEFINE_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5);
32 DEFINE_GUID(IID_ITextHost, 0x13e670f4,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
33 DEFINE_GUID(IID_ITextHost2, 0x13e670f5,0x1a5a,0x11cf,0xab,0xeb,0x00,0xaa,0x00,0xb6,0x5e,0xa1);
34 DEFINE_GUID(IID_ITextDocument, 0x8cc497c0, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
35 DEFINE_GUID(IID_ITextRange, 0x8cc497c2, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
36 DEFINE_GUID(IID_ITextSelection, 0x8cc497c1, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d);
37
38 typedef struct ITextSelectionImpl ITextSelectionImpl;
39 typedef struct IOleClientSiteImpl IOleClientSiteImpl;
40
41 typedef struct IRichEditOleImpl {
42 IRichEditOle IRichEditOle_iface;
43 ITextDocument ITextDocument_iface;
44 LONG ref;
45
46 ME_TextEditor *editor;
47 ITextSelectionImpl *txtSel;
48 IOleClientSiteImpl *clientSite;
49 } IRichEditOleImpl;
50
51 struct ITextSelectionImpl {
52 ITextSelection ITextSelection_iface;
53 LONG ref;
54
55 IRichEditOleImpl *reOle;
56 };
57
58 struct IOleClientSiteImpl {
59 IOleClientSite IOleClientSite_iface;
60 LONG ref;
61
62 IRichEditOleImpl *reOle;
63 };
64
65 static inline IRichEditOleImpl *impl_from_IRichEditOle(IRichEditOle *iface)
66 {
67 return CONTAINING_RECORD(iface, IRichEditOleImpl, IRichEditOle_iface);
68 }
69
70 static inline IRichEditOleImpl *impl_from_ITextDocument(ITextDocument *iface)
71 {
72 return CONTAINING_RECORD(iface, IRichEditOleImpl, ITextDocument_iface);
73 }
74
75 static HRESULT WINAPI
76 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
77 {
78 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
79
80 TRACE("%p %s\n", This, debugstr_guid(riid) );
81
82 *ppvObj = NULL;
83 if (IsEqualGUID(riid, &IID_IUnknown) ||
84 IsEqualGUID(riid, &IID_IRichEditOle))
85 *ppvObj = &This->IRichEditOle_iface;
86 else if (IsEqualGUID(riid, &IID_ITextDocument))
87 *ppvObj = &This->ITextDocument_iface;
88 if (*ppvObj)
89 {
90 IRichEditOle_AddRef(me);
91 return S_OK;
92 }
93 FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid) );
94
95 return E_NOINTERFACE;
96 }
97
98 static ULONG WINAPI
99 IRichEditOle_fnAddRef(IRichEditOle *me)
100 {
101 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
102 ULONG ref = InterlockedIncrement( &This->ref );
103
104 TRACE("%p ref = %u\n", This, ref);
105
106 return ref;
107 }
108
109 static ULONG WINAPI
110 IRichEditOle_fnRelease(IRichEditOle *me)
111 {
112 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
113 ULONG ref = InterlockedDecrement(&This->ref);
114
115 TRACE ("%p ref=%u\n", This, ref);
116
117 if (!ref)
118 {
119 TRACE ("Destroying %p\n", This);
120 This->txtSel->reOle = NULL;
121 ITextSelection_Release(&This->txtSel->ITextSelection_iface);
122 IOleClientSite_Release(&This->clientSite->IOleClientSite_iface);
123 heap_free(This);
124 }
125 return ref;
126 }
127
128 static HRESULT WINAPI
129 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
130 {
131 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
132 FIXME("stub %p\n",This);
133 return E_NOTIMPL;
134 }
135
136 static HRESULT WINAPI
137 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
138 {
139 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
140 FIXME("stub %p\n",This);
141 return E_NOTIMPL;
142 }
143
144 static HRESULT WINAPI
145 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
146 REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
147 {
148 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
149 FIXME("stub %p\n",This);
150 return E_NOTIMPL;
151 }
152
153 static inline IOleClientSiteImpl *impl_from_IOleClientSite(IOleClientSite *iface)
154 {
155 return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleClientSite_iface);
156 }
157
158 static HRESULT WINAPI
159 IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj)
160 {
161 TRACE("%p %s\n", me, debugstr_guid(riid) );
162
163 *ppvObj = NULL;
164 if (IsEqualGUID(riid, &IID_IUnknown) ||
165 IsEqualGUID(riid, &IID_IOleClientSite))
166 *ppvObj = me;
167 if (*ppvObj)
168 {
169 IOleClientSite_AddRef(me);
170 return S_OK;
171 }
172 FIXME("%p: unhandled interface %s\n", me, debugstr_guid(riid) );
173
174 return E_NOINTERFACE;
175 }
176
177 static ULONG WINAPI IOleClientSite_fnAddRef(IOleClientSite *iface)
178 {
179 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
180 return InterlockedIncrement(&This->ref);
181 }
182
183 static ULONG WINAPI IOleClientSite_fnRelease(IOleClientSite *iface)
184 {
185 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
186 ULONG ref = InterlockedDecrement(&This->ref);
187 if (ref == 0)
188 heap_free(This);
189 return ref;
190 }
191
192 static HRESULT WINAPI IOleClientSite_fnSaveObject(IOleClientSite *iface)
193 {
194 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
195 if (!This->reOle)
196 return CO_E_RELEASED;
197
198 FIXME("stub %p\n", iface);
199 return E_NOTIMPL;
200 }
201
202
203 static HRESULT WINAPI IOleClientSite_fnGetMoniker(IOleClientSite *iface, DWORD dwAssign,
204 DWORD dwWhichMoniker, IMoniker **ppmk)
205 {
206 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
207 if (!This->reOle)
208 return CO_E_RELEASED;
209
210 FIXME("stub %p\n", iface);
211 return E_NOTIMPL;
212 }
213
214 static HRESULT WINAPI IOleClientSite_fnGetContainer(IOleClientSite *iface,
215 IOleContainer **ppContainer)
216 {
217 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
218 if (!This->reOle)
219 return CO_E_RELEASED;
220
221 FIXME("stub %p\n", iface);
222 return E_NOTIMPL;
223 }
224
225 static HRESULT WINAPI IOleClientSite_fnShowObject(IOleClientSite *iface)
226 {
227 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
228 if (!This->reOle)
229 return CO_E_RELEASED;
230
231 FIXME("stub %p\n", iface);
232 return E_NOTIMPL;
233 }
234
235 static HRESULT WINAPI IOleClientSite_fnOnShowWindow(IOleClientSite *iface, BOOL fShow)
236 {
237 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
238 if (!This->reOle)
239 return CO_E_RELEASED;
240
241 FIXME("stub %p\n", iface);
242 return E_NOTIMPL;
243 }
244
245 static HRESULT WINAPI IOleClientSite_fnRequestNewObjectLayout(IOleClientSite *iface)
246 {
247 IOleClientSiteImpl *This = impl_from_IOleClientSite(iface);
248 if (!This->reOle)
249 return CO_E_RELEASED;
250
251 FIXME("stub %p\n", iface);
252 return E_NOTIMPL;
253 }
254
255 static const IOleClientSiteVtbl ocst = {
256 IOleClientSite_fnQueryInterface,
257 IOleClientSite_fnAddRef,
258 IOleClientSite_fnRelease,
259 IOleClientSite_fnSaveObject,
260 IOleClientSite_fnGetMoniker,
261 IOleClientSite_fnGetContainer,
262 IOleClientSite_fnShowObject,
263 IOleClientSite_fnOnShowWindow,
264 IOleClientSite_fnRequestNewObjectLayout
265 };
266
267 static IOleClientSiteImpl *
268 CreateOleClientSite(IRichEditOleImpl *reOle)
269 {
270 IOleClientSiteImpl *clientSite = heap_alloc(sizeof *clientSite);
271 if (!clientSite)
272 return NULL;
273
274 clientSite->IOleClientSite_iface.lpVtbl = &ocst;
275 clientSite->ref = 1;
276 clientSite->reOle = reOle;
277 return clientSite;
278 }
279
280 static HRESULT WINAPI
281 IRichEditOle_fnGetClientSite(IRichEditOle *me,
282 LPOLECLIENTSITE *lplpolesite)
283 {
284 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
285
286 TRACE("%p,%p\n",This, lplpolesite);
287
288 if(!lplpolesite)
289 return E_INVALIDARG;
290 *lplpolesite = &This->clientSite->IOleClientSite_iface;
291 IOleClientSite_AddRef(*lplpolesite);
292 return S_OK;
293 }
294
295 static HRESULT WINAPI
296 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
297 DWORD reco, LPDATAOBJECT *lplpdataobj)
298 {
299 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
300 ME_Cursor start;
301 int nChars;
302
303 TRACE("(%p,%p,%d)\n",This, lpchrg, reco);
304 if(!lplpdataobj)
305 return E_INVALIDARG;
306 if(!lpchrg) {
307 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(This->editor, &nFrom, &nTo);
308 start = This->editor->pCursors[nStartCur];
309 nChars = nTo - nFrom;
310 } else {
311 ME_CursorFromCharOfs(This->editor, lpchrg->cpMin, &start);
312 nChars = lpchrg->cpMax - lpchrg->cpMin;
313 }
314 return ME_GetDataObject(This->editor, &start, nChars, lplpdataobj);
315 }
316
317 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
318 {
319 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
320 FIXME("stub %p\n",This);
321 return E_NOTIMPL;
322 }
323
324 static HRESULT WINAPI
325 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
326 REOBJECT *lpreobject, DWORD dwFlags)
327 {
328 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
329 FIXME("stub %p\n",This);
330 return E_NOTIMPL;
331 }
332
333 static LONG WINAPI
334 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
335 {
336 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
337 FIXME("stub %p\n",This);
338 return 0;
339 }
340
341 static HRESULT WINAPI
342 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
343 {
344 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
345 FIXME("stub %p\n",This);
346 return E_NOTIMPL;
347 }
348
349 static HRESULT WINAPI
350 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
351 CLIPFORMAT cf, HGLOBAL hMetaPict)
352 {
353 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
354 FIXME("stub %p\n",This);
355 return E_NOTIMPL;
356 }
357
358 static HRESULT WINAPI
359 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
360 {
361 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
362 FIXME("stub %p\n",This);
363 return E_NOTIMPL;
364 }
365
366 static HRESULT WINAPI
367 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *reo)
368 {
369 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
370 TRACE("(%p,%p)\n", This, reo);
371
372 if (reo->cbStruct < sizeof(*reo)) return STG_E_INVALIDPARAMETER;
373
374 ME_InsertOLEFromCursor(This->editor, reo, 0);
375 ME_CommitUndo(This->editor);
376 ME_UpdateRepaint(This->editor, FALSE);
377 return S_OK;
378 }
379
380 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
381 LPSTORAGE lpstg)
382 {
383 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
384 FIXME("stub %p\n",This);
385 return E_NOTIMPL;
386 }
387
388 static HRESULT WINAPI
389 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
390 {
391 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
392 FIXME("stub %p\n",This);
393 return E_NOTIMPL;
394 }
395
396 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
397 LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
398 {
399 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
400 FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
401 return E_NOTIMPL;
402 }
403
404 static HRESULT WINAPI
405 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
406 {
407 IRichEditOleImpl *This = impl_from_IRichEditOle(me);
408 FIXME("stub %p\n",This);
409 return E_NOTIMPL;
410 }
411
412 static const IRichEditOleVtbl revt = {
413 IRichEditOle_fnQueryInterface,
414 IRichEditOle_fnAddRef,
415 IRichEditOle_fnRelease,
416 IRichEditOle_fnGetClientSite,
417 IRichEditOle_fnGetObjectCount,
418 IRichEditOle_fnGetLinkCount,
419 IRichEditOle_fnGetObject,
420 IRichEditOle_fnInsertObject,
421 IRichEditOle_fnConvertObject,
422 IRichEditOle_fnActivateAs,
423 IRichEditOle_fnSetHostNames,
424 IRichEditOle_fnSetLinkAvailable,
425 IRichEditOle_fnSetDvaspect,
426 IRichEditOle_fnHandsOffStorage,
427 IRichEditOle_fnSaveCompleted,
428 IRichEditOle_fnInPlaceDeactivate,
429 IRichEditOle_fnContextSensitiveHelp,
430 IRichEditOle_fnGetClipboardData,
431 IRichEditOle_fnImportDataObject
432 };
433
434 static HRESULT WINAPI
435 ITextDocument_fnQueryInterface(ITextDocument* me, REFIID riid,
436 void** ppvObject)
437 {
438 IRichEditOleImpl *This = impl_from_ITextDocument(me);
439 return IRichEditOle_QueryInterface(&This->IRichEditOle_iface, riid, ppvObject);
440 }
441
442 static ULONG WINAPI
443 ITextDocument_fnAddRef(ITextDocument* me)
444 {
445 IRichEditOleImpl *This = impl_from_ITextDocument(me);
446 return IRichEditOle_AddRef(&This->IRichEditOle_iface);
447 }
448
449 static ULONG WINAPI
450 ITextDocument_fnRelease(ITextDocument* me)
451 {
452 IRichEditOleImpl *This = impl_from_ITextDocument(me);
453 return IRichEditOle_Release(&This->IRichEditOle_iface);
454 }
455
456 static HRESULT WINAPI
457 ITextDocument_fnGetTypeInfoCount(ITextDocument* me,
458 UINT* pctinfo)
459 {
460 IRichEditOleImpl *This = impl_from_ITextDocument(me);
461 FIXME("stub %p\n",This);
462 return E_NOTIMPL;
463 }
464
465 static HRESULT WINAPI
466 ITextDocument_fnGetTypeInfo(ITextDocument* me, UINT iTInfo, LCID lcid,
467 ITypeInfo** ppTInfo)
468 {
469 IRichEditOleImpl *This = impl_from_ITextDocument(me);
470 FIXME("stub %p\n",This);
471 return E_NOTIMPL;
472 }
473
474 static HRESULT WINAPI
475 ITextDocument_fnGetIDsOfNames(ITextDocument* me, REFIID riid,
476 LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId)
477 {
478 IRichEditOleImpl *This = impl_from_ITextDocument(me);
479 FIXME("stub %p\n",This);
480 return E_NOTIMPL;
481 }
482
483 static HRESULT WINAPI
484 ITextDocument_fnInvoke(ITextDocument* me, DISPID dispIdMember,
485 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
486 VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
487 {
488 IRichEditOleImpl *This = impl_from_ITextDocument(me);
489 FIXME("stub %p\n",This);
490 return E_NOTIMPL;
491 }
492
493 static HRESULT WINAPI
494 ITextDocument_fnGetName(ITextDocument* me, BSTR* pName)
495 {
496 IRichEditOleImpl *This = impl_from_ITextDocument(me);
497 FIXME("stub %p\n",This);
498 return E_NOTIMPL;
499 }
500
501 static HRESULT WINAPI
502 ITextDocument_fnGetSelection(ITextDocument* me, ITextSelection** ppSel)
503 {
504 IRichEditOleImpl *This = impl_from_ITextDocument(me);
505 TRACE("(%p)\n", me);
506 *ppSel = &This->txtSel->ITextSelection_iface;
507 ITextSelection_AddRef(*ppSel);
508 return S_OK;
509 }
510
511 static HRESULT WINAPI
512 ITextDocument_fnGetStoryCount(ITextDocument* me, LONG* pCount)
513 {
514 IRichEditOleImpl *This = impl_from_ITextDocument(me);
515 FIXME("stub %p\n",This);
516 return E_NOTIMPL;
517 }
518
519 static HRESULT WINAPI
520 ITextDocument_fnGetStoryRanges(ITextDocument* me,
521 ITextStoryRanges** ppStories)
522 {
523 IRichEditOleImpl *This = impl_from_ITextDocument(me);
524 FIXME("stub %p\n",This);
525 return E_NOTIMPL;
526 }
527
528 static HRESULT WINAPI
529 ITextDocument_fnGetSaved(ITextDocument* me, LONG* pValue)
530 {
531 IRichEditOleImpl *This = impl_from_ITextDocument(me);
532 FIXME("stub %p\n",This);
533 return E_NOTIMPL;
534 }
535
536 static HRESULT WINAPI
537 ITextDocument_fnSetSaved(ITextDocument* me, LONG Value)
538 {
539 IRichEditOleImpl *This = impl_from_ITextDocument(me);
540 FIXME("stub %p\n",This);
541 return E_NOTIMPL;
542 }
543
544 static HRESULT WINAPI
545 ITextDocument_fnGetDefaultTabStop(ITextDocument* me, float* pValue)
546 {
547 IRichEditOleImpl *This = impl_from_ITextDocument(me);
548 FIXME("stub %p\n",This);
549 return E_NOTIMPL;
550 }
551
552 static HRESULT WINAPI
553 ITextDocument_fnSetDefaultTabStop(ITextDocument* me, float Value)
554 {
555 IRichEditOleImpl *This = impl_from_ITextDocument(me);
556 FIXME("stub %p\n",This);
557 return E_NOTIMPL;
558 }
559
560 static HRESULT WINAPI
561 ITextDocument_fnNew(ITextDocument* me)
562 {
563 IRichEditOleImpl *This = impl_from_ITextDocument(me);
564 FIXME("stub %p\n",This);
565 return E_NOTIMPL;
566 }
567
568 static HRESULT WINAPI
569 ITextDocument_fnOpen(ITextDocument* me, VARIANT* pVar, LONG Flags,
570 LONG CodePage)
571 {
572 IRichEditOleImpl *This = impl_from_ITextDocument(me);
573 FIXME("stub %p\n",This);
574 return E_NOTIMPL;
575 }
576
577 static HRESULT WINAPI
578 ITextDocument_fnSave(ITextDocument* me, VARIANT* pVar, LONG Flags,
579 LONG CodePage)
580 {
581 IRichEditOleImpl *This = impl_from_ITextDocument(me);
582 FIXME("stub %p\n",This);
583 return E_NOTIMPL;
584 }
585
586 static HRESULT WINAPI
587 ITextDocument_fnFreeze(ITextDocument* me, LONG* pCount)
588 {
589 IRichEditOleImpl *This = impl_from_ITextDocument(me);
590 FIXME("stub %p\n",This);
591 return E_NOTIMPL;
592 }
593
594 static HRESULT WINAPI
595 ITextDocument_fnUnfreeze(ITextDocument* me, LONG* pCount)
596 {
597 IRichEditOleImpl *This = impl_from_ITextDocument(me);
598 FIXME("stub %p\n",This);
599 return E_NOTIMPL;
600 }
601
602 static HRESULT WINAPI
603 ITextDocument_fnBeginEditCollection(ITextDocument* me)
604 {
605 IRichEditOleImpl *This = impl_from_ITextDocument(me);
606 FIXME("stub %p\n",This);
607 return E_NOTIMPL;
608 }
609
610 static HRESULT WINAPI
611 ITextDocument_fnEndEditCollection(ITextDocument* me)
612 {
613 IRichEditOleImpl *This = impl_from_ITextDocument(me);
614 FIXME("stub %p\n",This);
615 return E_NOTIMPL;
616 }
617
618 static HRESULT WINAPI
619 ITextDocument_fnUndo(ITextDocument* me, LONG Count, LONG* prop)
620 {
621 IRichEditOleImpl *This = impl_from_ITextDocument(me);
622 FIXME("stub %p\n",This);
623 return E_NOTIMPL;
624 }
625
626 static HRESULT WINAPI
627 ITextDocument_fnRedo(ITextDocument* me, LONG Count, LONG* prop)
628 {
629 IRichEditOleImpl *This = impl_from_ITextDocument(me);
630 FIXME("stub %p\n",This);
631 return E_NOTIMPL;
632 }
633
634 static HRESULT WINAPI
635 ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2,
636 ITextRange** ppRange)
637 {
638 IRichEditOleImpl *This = impl_from_ITextDocument(me);
639 FIXME("stub %p\n",This);
640 return E_NOTIMPL;
641 }
642
643 static HRESULT WINAPI
644 ITextDocument_fnRangeFromPoint(ITextDocument* me, LONG x, LONG y,
645 ITextRange** ppRange)
646 {
647 IRichEditOleImpl *This = impl_from_ITextDocument(me);
648 FIXME("stub %p\n",This);
649 return E_NOTIMPL;
650 }
651
652 static const ITextDocumentVtbl tdvt = {
653 ITextDocument_fnQueryInterface,
654 ITextDocument_fnAddRef,
655 ITextDocument_fnRelease,
656 ITextDocument_fnGetTypeInfoCount,
657 ITextDocument_fnGetTypeInfo,
658 ITextDocument_fnGetIDsOfNames,
659 ITextDocument_fnInvoke,
660 ITextDocument_fnGetName,
661 ITextDocument_fnGetSelection,
662 ITextDocument_fnGetStoryCount,
663 ITextDocument_fnGetStoryRanges,
664 ITextDocument_fnGetSaved,
665 ITextDocument_fnSetSaved,
666 ITextDocument_fnGetDefaultTabStop,
667 ITextDocument_fnSetDefaultTabStop,
668 ITextDocument_fnNew,
669 ITextDocument_fnOpen,
670 ITextDocument_fnSave,
671 ITextDocument_fnFreeze,
672 ITextDocument_fnUnfreeze,
673 ITextDocument_fnBeginEditCollection,
674 ITextDocument_fnEndEditCollection,
675 ITextDocument_fnUndo,
676 ITextDocument_fnRedo,
677 ITextDocument_fnRange,
678 ITextDocument_fnRangeFromPoint
679 };
680
681 static inline ITextSelectionImpl *impl_from_ITextSelection(ITextSelection *iface)
682 {
683 return CONTAINING_RECORD(iface, ITextSelectionImpl, ITextSelection_iface);
684 }
685
686 static HRESULT WINAPI ITextSelection_fnQueryInterface(
687 ITextSelection *me,
688 REFIID riid,
689 void **ppvObj)
690 {
691 *ppvObj = NULL;
692 if (IsEqualGUID(riid, &IID_IUnknown)
693 || IsEqualGUID(riid, &IID_IDispatch)
694 || IsEqualGUID(riid, &IID_ITextRange)
695 || IsEqualGUID(riid, &IID_ITextSelection))
696 {
697 *ppvObj = me;
698 ITextSelection_AddRef(me);
699 return S_OK;
700 }
701
702 return E_NOINTERFACE;
703 }
704
705 static ULONG WINAPI ITextSelection_fnAddRef(ITextSelection *me)
706 {
707 ITextSelectionImpl *This = impl_from_ITextSelection(me);
708 return InterlockedIncrement(&This->ref);
709 }
710
711 static ULONG WINAPI ITextSelection_fnRelease(ITextSelection *me)
712 {
713 ITextSelectionImpl *This = impl_from_ITextSelection(me);
714 ULONG ref = InterlockedDecrement(&This->ref);
715 if (ref == 0)
716 heap_free(This);
717 return ref;
718 }
719
720 static HRESULT WINAPI ITextSelection_fnGetTypeInfoCount(ITextSelection *me, UINT *pctinfo)
721 {
722 ITextSelectionImpl *This = impl_from_ITextSelection(me);
723 if (!This->reOle)
724 return CO_E_RELEASED;
725
726 FIXME("not implemented\n");
727 return E_NOTIMPL;
728 }
729
730 static HRESULT WINAPI ITextSelection_fnGetTypeInfo(ITextSelection *me, UINT iTInfo, LCID lcid,
731 ITypeInfo **ppTInfo)
732 {
733 ITextSelectionImpl *This = impl_from_ITextSelection(me);
734 if (!This->reOle)
735 return CO_E_RELEASED;
736
737 FIXME("not implemented\n");
738 return E_NOTIMPL;
739 }
740
741 static HRESULT WINAPI ITextSelection_fnGetIDsOfNames(ITextSelection *me, REFIID riid,
742 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
743 {
744 ITextSelectionImpl *This = impl_from_ITextSelection(me);
745 if (!This->reOle)
746 return CO_E_RELEASED;
747
748 FIXME("not implemented\n");
749 return E_NOTIMPL;
750 }
751
752 static HRESULT WINAPI ITextSelection_fnInvoke(
753 ITextSelection *me,
754 DISPID dispIdMember,
755 REFIID riid,
756 LCID lcid,
757 WORD wFlags,
758 DISPPARAMS *pDispParams,
759 VARIANT *pVarResult,
760 EXCEPINFO *pExcepInfo,
761 UINT *puArgErr)
762 {
763 FIXME("not implemented\n");
764 return E_NOTIMPL;
765 }
766
767 /*** ITextRange methods ***/
768 static HRESULT WINAPI ITextSelection_fnGetText(ITextSelection *me, BSTR *pbstr)
769 {
770 ITextSelectionImpl *This = impl_from_ITextSelection(me);
771 if (!This->reOle)
772 return CO_E_RELEASED;
773
774 FIXME("not implemented\n");
775 return E_NOTIMPL;
776 }
777
778 static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me, BSTR bstr)
779 {
780 ITextSelectionImpl *This = impl_from_ITextSelection(me);
781 if (!This->reOle)
782 return CO_E_RELEASED;
783
784 FIXME("not implemented\n");
785 return E_NOTIMPL;
786 }
787
788 static HRESULT WINAPI ITextSelection_fnGetChar(ITextSelection *me, LONG *pch)
789 {
790 ITextSelectionImpl *This = impl_from_ITextSelection(me);
791 if (!This->reOle)
792 return CO_E_RELEASED;
793
794 FIXME("not implemented\n");
795 return E_NOTIMPL;
796 }
797
798 static HRESULT WINAPI ITextSelection_fnSetChar(ITextSelection *me, LONG ch)
799 {
800 ITextSelectionImpl *This = impl_from_ITextSelection(me);
801 if (!This->reOle)
802 return CO_E_RELEASED;
803
804 FIXME("not implemented\n");
805 return E_NOTIMPL;
806 }
807
808 static HRESULT WINAPI ITextSelection_fnGetDuplicate(ITextSelection *me, ITextRange **ppRange)
809 {
810 ITextSelectionImpl *This = impl_from_ITextSelection(me);
811 if (!This->reOle)
812 return CO_E_RELEASED;
813
814 FIXME("not implemented\n");
815 return E_NOTIMPL;
816 }
817
818 static HRESULT WINAPI ITextSelection_fnGetFormattedText(ITextSelection *me, ITextRange **ppRange)
819 {
820 ITextSelectionImpl *This = impl_from_ITextSelection(me);
821 if (!This->reOle)
822 return CO_E_RELEASED;
823
824 FIXME("not implemented\n");
825 return E_NOTIMPL;
826 }
827
828 static HRESULT WINAPI ITextSelection_fnSetFormattedText(ITextSelection *me, ITextRange *pRange)
829 {
830 ITextSelectionImpl *This = impl_from_ITextSelection(me);
831 if (!This->reOle)
832 return CO_E_RELEASED;
833
834 FIXME("not implemented\n");
835 return E_NOTIMPL;
836 }
837
838 static HRESULT WINAPI ITextSelection_fnGetStart(ITextSelection *me, LONG *pcpFirst)
839 {
840 ITextSelectionImpl *This = impl_from_ITextSelection(me);
841 if (!This->reOle)
842 return CO_E_RELEASED;
843
844 FIXME("not implemented\n");
845 return E_NOTIMPL;
846 }
847
848 static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me, LONG cpFirst)
849 {
850 ITextSelectionImpl *This = impl_from_ITextSelection(me);
851 if (!This->reOle)
852 return CO_E_RELEASED;
853
854 FIXME("not implemented\n");
855 return E_NOTIMPL;
856 }
857
858 static HRESULT WINAPI ITextSelection_fnGetEnd(ITextSelection *me, LONG *pcpLim)
859 {
860 ITextSelectionImpl *This = impl_from_ITextSelection(me);
861 if (!This->reOle)
862 return CO_E_RELEASED;
863
864 FIXME("not implemented\n");
865 return E_NOTIMPL;
866 }
867
868 static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me, LONG cpLim)
869 {
870 ITextSelectionImpl *This = impl_from_ITextSelection(me);
871 if (!This->reOle)
872 return CO_E_RELEASED;
873
874 FIXME("not implemented\n");
875 return E_NOTIMPL;
876 }
877
878 static HRESULT WINAPI ITextSelection_fnGetFont(ITextSelection *me, ITextFont **pFont)
879 {
880 ITextSelectionImpl *This = impl_from_ITextSelection(me);
881 if (!This->reOle)
882 return CO_E_RELEASED;
883
884 FIXME("not implemented\n");
885 return E_NOTIMPL;
886 }
887
888 static HRESULT WINAPI ITextSelection_fnSetFont(ITextSelection *me, ITextFont *pFont)
889 {
890 ITextSelectionImpl *This = impl_from_ITextSelection(me);
891 if (!This->reOle)
892 return CO_E_RELEASED;
893
894 FIXME("not implemented\n");
895 return E_NOTIMPL;
896 }
897
898 static HRESULT WINAPI ITextSelection_fnGetPara(ITextSelection *me, ITextPara **ppPara)
899 {
900 ITextSelectionImpl *This = impl_from_ITextSelection(me);
901 if (!This->reOle)
902 return CO_E_RELEASED;
903
904 FIXME("not implemented\n");
905 return E_NOTIMPL;
906 }
907
908 static HRESULT WINAPI ITextSelection_fnSetPara(ITextSelection *me, ITextPara *pPara)
909 {
910 ITextSelectionImpl *This = impl_from_ITextSelection(me);
911 if (!This->reOle)
912 return CO_E_RELEASED;
913
914 FIXME("not implemented\n");
915 return E_NOTIMPL;
916 }
917
918 static HRESULT WINAPI ITextSelection_fnGetStoryLength(ITextSelection *me, LONG *pcch)
919 {
920 ITextSelectionImpl *This = impl_from_ITextSelection(me);
921 if (!This->reOle)
922 return CO_E_RELEASED;
923
924 FIXME("not implemented\n");
925 return E_NOTIMPL;
926 }
927
928 static HRESULT WINAPI ITextSelection_fnGetStoryType(ITextSelection *me, LONG *pValue)
929 {
930 ITextSelectionImpl *This = impl_from_ITextSelection(me);
931 if (!This->reOle)
932 return CO_E_RELEASED;
933
934 FIXME("not implemented\n");
935 return E_NOTIMPL;
936 }
937
938 static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me, LONG bStart)
939 {
940 ITextSelectionImpl *This = impl_from_ITextSelection(me);
941 if (!This->reOle)
942 return CO_E_RELEASED;
943
944 FIXME("not implemented\n");
945 return E_NOTIMPL;
946 }
947
948 static HRESULT WINAPI ITextSelection_fnExpand(ITextSelection *me, LONG Unit, LONG *pDelta)
949 {
950 ITextSelectionImpl *This = impl_from_ITextSelection(me);
951 if (!This->reOle)
952 return CO_E_RELEASED;
953
954 FIXME("not implemented\n");
955 return E_NOTIMPL;
956 }
957
958 static HRESULT WINAPI ITextSelection_fnGetIndex(ITextSelection *me, LONG Unit, LONG *pIndex)
959 {
960 ITextSelectionImpl *This = impl_from_ITextSelection(me);
961 if (!This->reOle)
962 return CO_E_RELEASED;
963
964 FIXME("not implemented\n");
965 return E_NOTIMPL;
966 }
967
968 static HRESULT WINAPI ITextSelection_fnSetIndex(ITextSelection *me, LONG Unit, LONG Index,
969 LONG Extend)
970 {
971 ITextSelectionImpl *This = impl_from_ITextSelection(me);
972 if (!This->reOle)
973 return CO_E_RELEASED;
974
975 FIXME("not implemented\n");
976 return E_NOTIMPL;
977 }
978
979 static HRESULT WINAPI ITextSelection_fnSetRange(ITextSelection *me, LONG cpActive, LONG cpOther)
980 {
981 ITextSelectionImpl *This = impl_from_ITextSelection(me);
982 if (!This->reOle)
983 return CO_E_RELEASED;
984
985 FIXME("not implemented\n");
986 return E_NOTIMPL;
987 }
988
989 static HRESULT WINAPI ITextSelection_fnInRange(ITextSelection *me, ITextRange *pRange, LONG *pb)
990 {
991 ITextSelectionImpl *This = impl_from_ITextSelection(me);
992 if (!This->reOle)
993 return CO_E_RELEASED;
994
995 FIXME("not implemented\n");
996 return E_NOTIMPL;
997 }
998
999 static HRESULT WINAPI ITextSelection_fnInStory(ITextSelection *me, ITextRange *pRange, LONG *pb)
1000 {
1001 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1002 if (!This->reOle)
1003 return CO_E_RELEASED;
1004
1005 FIXME("not implemented\n");
1006 return E_NOTIMPL;
1007 }
1008
1009 static HRESULT WINAPI ITextSelection_fnIsEqual(ITextSelection *me, ITextRange *pRange, LONG *pb)
1010 {
1011 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1012 if (!This->reOle)
1013 return CO_E_RELEASED;
1014
1015 FIXME("not implemented\n");
1016 return E_NOTIMPL;
1017 }
1018
1019 static HRESULT WINAPI ITextSelection_fnSelect(ITextSelection *me)
1020 {
1021 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1022 if (!This->reOle)
1023 return CO_E_RELEASED;
1024
1025 FIXME("not implemented\n");
1026 return E_NOTIMPL;
1027 }
1028
1029 static HRESULT WINAPI ITextSelection_fnStartOf(ITextSelection *me, LONG Unit, LONG Extend,
1030 LONG *pDelta)
1031 {
1032 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1033 if (!This->reOle)
1034 return CO_E_RELEASED;
1035
1036 FIXME("not implemented\n");
1037 return E_NOTIMPL;
1038 }
1039
1040 static HRESULT WINAPI ITextSelection_fnEndOf(ITextSelection *me, LONG Unit, LONG Extend,
1041 LONG *pDelta)
1042 {
1043 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1044 if (!This->reOle)
1045 return CO_E_RELEASED;
1046
1047 FIXME("not implemented\n");
1048 return E_NOTIMPL;
1049 }
1050
1051 static HRESULT WINAPI ITextSelection_fnMove(ITextSelection *me, LONG Unit, LONG Count, LONG *pDelta)
1052 {
1053 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1054 if (!This->reOle)
1055 return CO_E_RELEASED;
1056
1057 FIXME("not implemented\n");
1058 return E_NOTIMPL;
1059 }
1060
1061 static HRESULT WINAPI ITextSelection_fnMoveStart(ITextSelection *me, LONG Unit, LONG Count,
1062 LONG *pDelta)
1063 {
1064 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1065 if (!This->reOle)
1066 return CO_E_RELEASED;
1067
1068 FIXME("not implemented\n");
1069 return E_NOTIMPL;
1070 }
1071
1072 static HRESULT WINAPI ITextSelection_fnMoveEnd(ITextSelection *me, LONG Unit, LONG Count,
1073 LONG *pDelta)
1074 {
1075 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1076 if (!This->reOle)
1077 return CO_E_RELEASED;
1078
1079 FIXME("not implemented\n");
1080 return E_NOTIMPL;
1081 }
1082
1083 static HRESULT WINAPI ITextSelection_fnMoveWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1084 LONG *pDelta)
1085 {
1086 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1087 if (!This->reOle)
1088 return CO_E_RELEASED;
1089
1090 FIXME("not implemented\n");
1091 return E_NOTIMPL;
1092 }
1093
1094 static HRESULT WINAPI ITextSelection_fnMoveStartWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1095 LONG *pDelta)
1096 {
1097 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1098 if (!This->reOle)
1099 return CO_E_RELEASED;
1100
1101 FIXME("not implemented\n");
1102 return E_NOTIMPL;
1103 }
1104
1105 static HRESULT WINAPI ITextSelection_fnMoveEndWhile(ITextSelection *me, VARIANT *Cset, LONG Count,
1106 LONG *pDelta)
1107 {
1108 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1109 if (!This->reOle)
1110 return CO_E_RELEASED;
1111
1112 FIXME("not implemented\n");
1113 return E_NOTIMPL;
1114 }
1115
1116 static HRESULT WINAPI ITextSelection_fnMoveUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1117 LONG *pDelta)
1118 {
1119 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1120 if (!This->reOle)
1121 return CO_E_RELEASED;
1122
1123 FIXME("not implemented\n");
1124 return E_NOTIMPL;
1125 }
1126
1127 static HRESULT WINAPI ITextSelection_fnMoveStartUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1128 LONG *pDelta)
1129 {
1130 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1131 if (!This->reOle)
1132 return CO_E_RELEASED;
1133
1134 FIXME("not implemented\n");
1135 return E_NOTIMPL;
1136 }
1137
1138 static HRESULT WINAPI ITextSelection_fnMoveEndUntil(ITextSelection *me, VARIANT *Cset, LONG Count,
1139 LONG *pDelta)
1140 {
1141 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1142 if (!This->reOle)
1143 return CO_E_RELEASED;
1144
1145 FIXME("not implemented\n");
1146 return E_NOTIMPL;
1147 }
1148
1149 static HRESULT WINAPI ITextSelection_fnFindText(ITextSelection *me, BSTR bstr, LONG cch, LONG Flags,
1150 LONG *pLength)
1151 {
1152 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1153 if (!This->reOle)
1154 return CO_E_RELEASED;
1155
1156 FIXME("not implemented\n");
1157 return E_NOTIMPL;
1158 }
1159
1160 static HRESULT WINAPI ITextSelection_fnFindTextStart(ITextSelection *me, BSTR bstr, LONG cch,
1161 LONG Flags, LONG *pLength)
1162 {
1163 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1164 if (!This->reOle)
1165 return CO_E_RELEASED;
1166
1167 FIXME("not implemented\n");
1168 return E_NOTIMPL;
1169 }
1170
1171 static HRESULT WINAPI ITextSelection_fnFindTextEnd(ITextSelection *me, BSTR bstr, LONG cch,
1172 LONG Flags, LONG *pLength)
1173 {
1174 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1175 if (!This->reOle)
1176 return CO_E_RELEASED;
1177
1178 FIXME("not implemented\n");
1179 return E_NOTIMPL;
1180 }
1181
1182 static HRESULT WINAPI ITextSelection_fnDelete(ITextSelection *me, LONG Unit, LONG Count,
1183 LONG *pDelta)
1184 {
1185 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1186 if (!This->reOle)
1187 return CO_E_RELEASED;
1188
1189 FIXME("not implemented\n");
1190 return E_NOTIMPL;
1191 }
1192
1193 static HRESULT WINAPI ITextSelection_fnCut(ITextSelection *me, VARIANT *pVar)
1194 {
1195 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1196 if (!This->reOle)
1197 return CO_E_RELEASED;
1198
1199 FIXME("not implemented\n");
1200 return E_NOTIMPL;
1201 }
1202
1203 static HRESULT WINAPI ITextSelection_fnCopy(ITextSelection *me, VARIANT *pVar)
1204 {
1205 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1206 if (!This->reOle)
1207 return CO_E_RELEASED;
1208
1209 FIXME("not implemented\n");
1210 return E_NOTIMPL;
1211 }
1212
1213 static HRESULT WINAPI ITextSelection_fnPaste(ITextSelection *me, VARIANT *pVar, LONG Format)
1214 {
1215 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1216 if (!This->reOle)
1217 return CO_E_RELEASED;
1218
1219 FIXME("not implemented\n");
1220 return E_NOTIMPL;
1221 }
1222
1223 static HRESULT WINAPI ITextSelection_fnCanPaste(ITextSelection *me, VARIANT *pVar, LONG Format,
1224 LONG *pb)
1225 {
1226 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1227 if (!This->reOle)
1228 return CO_E_RELEASED;
1229
1230 FIXME("not implemented\n");
1231 return E_NOTIMPL;
1232 }
1233
1234 static HRESULT WINAPI ITextSelection_fnCanEdit(ITextSelection *me, LONG *pb)
1235 {
1236 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1237 if (!This->reOle)
1238 return CO_E_RELEASED;
1239
1240 FIXME("not implemented\n");
1241 return E_NOTIMPL;
1242 }
1243
1244 static HRESULT WINAPI ITextSelection_fnChangeCase(ITextSelection *me, LONG Type)
1245 {
1246 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1247 if (!This->reOle)
1248 return CO_E_RELEASED;
1249
1250 FIXME("not implemented\n");
1251 return E_NOTIMPL;
1252 }
1253
1254 static HRESULT WINAPI ITextSelection_fnGetPoint(ITextSelection *me, LONG Type, LONG *cx, LONG *cy)
1255 {
1256 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1257 if (!This->reOle)
1258 return CO_E_RELEASED;
1259
1260 FIXME("not implemented\n");
1261 return E_NOTIMPL;
1262 }
1263
1264 static HRESULT WINAPI ITextSelection_fnSetPoint(ITextSelection *me, LONG x, LONG y, LONG Type,
1265 LONG Extend)
1266 {
1267 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1268 if (!This->reOle)
1269 return CO_E_RELEASED;
1270
1271 FIXME("not implemented\n");
1272 return E_NOTIMPL;
1273 }
1274
1275 static HRESULT WINAPI ITextSelection_fnScrollIntoView(ITextSelection *me, LONG Value)
1276 {
1277 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1278 if (!This->reOle)
1279 return CO_E_RELEASED;
1280
1281 FIXME("not implemented\n");
1282 return E_NOTIMPL;
1283 }
1284
1285 static HRESULT WINAPI ITextSelection_fnGetEmbeddedObject(ITextSelection *me, IUnknown **ppv)
1286 {
1287 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1288 if (!This->reOle)
1289 return CO_E_RELEASED;
1290
1291 FIXME("not implemented\n");
1292 return E_NOTIMPL;
1293 }
1294
1295 /*** ITextSelection methods ***/
1296 static HRESULT WINAPI ITextSelection_fnGetFlags(ITextSelection *me, LONG *pFlags)
1297 {
1298 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1299 if (!This->reOle)
1300 return CO_E_RELEASED;
1301
1302 FIXME("not implemented\n");
1303 return E_NOTIMPL;
1304 }
1305
1306 static HRESULT WINAPI ITextSelection_fnSetFlags(ITextSelection *me, LONG Flags)
1307 {
1308 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1309 if (!This->reOle)
1310 return CO_E_RELEASED;
1311
1312 FIXME("not implemented\n");
1313 return E_NOTIMPL;
1314 }
1315
1316 static HRESULT WINAPI ITextSelection_fnGetType(ITextSelection *me, LONG *pType)
1317 {
1318 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1319 if (!This->reOle)
1320 return CO_E_RELEASED;
1321
1322 FIXME("not implemented\n");
1323 return E_NOTIMPL;
1324 }
1325
1326 static HRESULT WINAPI ITextSelection_fnMoveLeft(ITextSelection *me, LONG Unit, LONG Count,
1327 LONG Extend, LONG *pDelta)
1328 {
1329 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1330 if (!This->reOle)
1331 return CO_E_RELEASED;
1332
1333 FIXME("not implemented\n");
1334 return E_NOTIMPL;
1335 }
1336
1337 static HRESULT WINAPI ITextSelection_fnMoveRight(ITextSelection *me, LONG Unit, LONG Count,
1338 LONG Extend, LONG *pDelta)
1339 {
1340 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1341 if (!This->reOle)
1342 return CO_E_RELEASED;
1343
1344 FIXME("not implemented\n");
1345 return E_NOTIMPL;
1346 }
1347
1348 static HRESULT WINAPI ITextSelection_fnMoveUp(ITextSelection *me, LONG Unit, LONG Count,
1349 LONG Extend, LONG *pDelta)
1350 {
1351 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1352 if (!This->reOle)
1353 return CO_E_RELEASED;
1354
1355 FIXME("not implemented\n");
1356 return E_NOTIMPL;
1357 }
1358
1359 static HRESULT WINAPI ITextSelection_fnMoveDown(ITextSelection *me, LONG Unit, LONG Count,
1360 LONG Extend, LONG *pDelta)
1361 {
1362 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1363 if (!This->reOle)
1364 return CO_E_RELEASED;
1365
1366 FIXME("not implemented\n");
1367 return E_NOTIMPL;
1368 }
1369
1370 static HRESULT WINAPI ITextSelection_fnHomeKey(ITextSelection *me, LONG Unit, LONG Extend,
1371 LONG *pDelta)
1372 {
1373 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1374 if (!This->reOle)
1375 return CO_E_RELEASED;
1376
1377 FIXME("not implemented\n");
1378 return E_NOTIMPL;
1379 }
1380
1381 static HRESULT WINAPI ITextSelection_fnEndKey(ITextSelection *me, LONG Unit, LONG Extend,
1382 LONG *pDelta)
1383 {
1384 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1385 if (!This->reOle)
1386 return CO_E_RELEASED;
1387
1388 FIXME("not implemented\n");
1389 return E_NOTIMPL;
1390 }
1391
1392 static HRESULT WINAPI ITextSelection_fnTypeText(ITextSelection *me, BSTR bstr)
1393 {
1394 ITextSelectionImpl *This = impl_from_ITextSelection(me);
1395 if (!This->reOle)
1396 return CO_E_RELEASED;
1397
1398 FIXME("not implemented\n");
1399 return E_NOTIMPL;
1400 }
1401
1402 static const ITextSelectionVtbl tsvt = {
1403 ITextSelection_fnQueryInterface,
1404 ITextSelection_fnAddRef,
1405 ITextSelection_fnRelease,
1406 ITextSelection_fnGetTypeInfoCount,
1407 ITextSelection_fnGetTypeInfo,
1408 ITextSelection_fnGetIDsOfNames,
1409 ITextSelection_fnInvoke,
1410 ITextSelection_fnGetText,
1411 ITextSelection_fnSetText,
1412 ITextSelection_fnGetChar,
1413 ITextSelection_fnSetChar,
1414 ITextSelection_fnGetDuplicate,
1415 ITextSelection_fnGetFormattedText,
1416 ITextSelection_fnSetFormattedText,
1417 ITextSelection_fnGetStart,
1418 ITextSelection_fnSetStart,
1419 ITextSelection_fnGetEnd,
1420 ITextSelection_fnSetEnd,
1421 ITextSelection_fnGetFont,
1422 ITextSelection_fnSetFont,
1423 ITextSelection_fnGetPara,
1424 ITextSelection_fnSetPara,
1425 ITextSelection_fnGetStoryLength,
1426 ITextSelection_fnGetStoryType,
1427 ITextSelection_fnCollapse,
1428 ITextSelection_fnExpand,
1429 ITextSelection_fnGetIndex,
1430 ITextSelection_fnSetIndex,
1431 ITextSelection_fnSetRange,
1432 ITextSelection_fnInRange,
1433 ITextSelection_fnInStory,
1434 ITextSelection_fnIsEqual,
1435 ITextSelection_fnSelect,
1436 ITextSelection_fnStartOf,
1437 ITextSelection_fnEndOf,
1438 ITextSelection_fnMove,
1439 ITextSelection_fnMoveStart,
1440 ITextSelection_fnMoveEnd,
1441 ITextSelection_fnMoveWhile,
1442 ITextSelection_fnMoveStartWhile,
1443 ITextSelection_fnMoveEndWhile,
1444 ITextSelection_fnMoveUntil,
1445 ITextSelection_fnMoveStartUntil,
1446 ITextSelection_fnMoveEndUntil,
1447 ITextSelection_fnFindText,
1448 ITextSelection_fnFindTextStart,
1449 ITextSelection_fnFindTextEnd,
1450 ITextSelection_fnDelete,
1451 ITextSelection_fnCut,
1452 ITextSelection_fnCopy,
1453 ITextSelection_fnPaste,
1454 ITextSelection_fnCanPaste,
1455 ITextSelection_fnCanEdit,
1456 ITextSelection_fnChangeCase,
1457 ITextSelection_fnGetPoint,
1458 ITextSelection_fnSetPoint,
1459 ITextSelection_fnScrollIntoView,
1460 ITextSelection_fnGetEmbeddedObject,
1461 ITextSelection_fnGetFlags,
1462 ITextSelection_fnSetFlags,
1463 ITextSelection_fnGetType,
1464 ITextSelection_fnMoveLeft,
1465 ITextSelection_fnMoveRight,
1466 ITextSelection_fnMoveUp,
1467 ITextSelection_fnMoveDown,
1468 ITextSelection_fnHomeKey,
1469 ITextSelection_fnEndKey,
1470 ITextSelection_fnTypeText
1471 };
1472
1473 static ITextSelectionImpl *
1474 CreateTextSelection(IRichEditOleImpl *reOle)
1475 {
1476 ITextSelectionImpl *txtSel = heap_alloc(sizeof *txtSel);
1477 if (!txtSel)
1478 return NULL;
1479
1480 txtSel->ITextSelection_iface.lpVtbl = &tsvt;
1481 txtSel->ref = 1;
1482 txtSel->reOle = reOle;
1483 return txtSel;
1484 }
1485
1486 LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *ppObj)
1487 {
1488 IRichEditOleImpl *reo;
1489
1490 reo = heap_alloc(sizeof(IRichEditOleImpl));
1491 if (!reo)
1492 return 0;
1493
1494 reo->IRichEditOle_iface.lpVtbl = &revt;
1495 reo->ITextDocument_iface.lpVtbl = &tdvt;
1496 reo->ref = 1;
1497 reo->editor = editor;
1498 reo->txtSel = CreateTextSelection(reo);
1499 if (!reo->txtSel)
1500 {
1501 heap_free(reo);
1502 return 0;
1503 }
1504 reo->clientSite = CreateOleClientSite(reo);
1505 if (!reo->txtSel)
1506 {
1507 ITextSelection_Release(&reo->txtSel->ITextSelection_iface);
1508 heap_free(reo);
1509 return 0;
1510 }
1511 TRACE("Created %p\n",reo);
1512 *ppObj = reo;
1513
1514 return 1;
1515 }
1516
1517 static void convert_sizel(const ME_Context *c, const SIZEL* szl, SIZE* sz)
1518 {
1519 /* sizel is in .01 millimeters, sz in pixels */
1520 sz->cx = MulDiv(szl->cx, c->dpi.cx, 2540);
1521 sz->cy = MulDiv(szl->cy, c->dpi.cy, 2540);
1522 }
1523
1524 /******************************************************************************
1525 * ME_GetOLEObjectSize
1526 *
1527 * Sets run extent for OLE objects.
1528 */
1529 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
1530 {
1531 IDataObject* ido;
1532 FORMATETC fmt;
1533 STGMEDIUM stgm;
1534 DIBSECTION dibsect;
1535 ENHMETAHEADER emh;
1536
1537 assert(run->nFlags & MERF_GRAPHICS);
1538 assert(run->ole_obj);
1539
1540 if (run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0)
1541 {
1542 convert_sizel(c, &run->ole_obj->sizel, pSize);
1543 if (c->editor->nZoomNumerator != 0)
1544 {
1545 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1546 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1547 }
1548 return;
1549 }
1550
1551 IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido);
1552 fmt.cfFormat = CF_BITMAP;
1553 fmt.ptd = NULL;
1554 fmt.dwAspect = DVASPECT_CONTENT;
1555 fmt.lindex = -1;
1556 fmt.tymed = TYMED_GDI;
1557 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1558 {
1559 fmt.cfFormat = CF_ENHMETAFILE;
1560 fmt.tymed = TYMED_ENHMF;
1561 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1562 {
1563 FIXME("unsupported format\n");
1564 pSize->cx = pSize->cy = 0;
1565 IDataObject_Release(ido);
1566 return;
1567 }
1568 }
1569
1570 switch (stgm.tymed)
1571 {
1572 case TYMED_GDI:
1573 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1574 pSize->cx = dibsect.dsBm.bmWidth;
1575 pSize->cy = dibsect.dsBm.bmHeight;
1576 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1577 break;
1578 case TYMED_ENHMF:
1579 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1580 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
1581 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
1582 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1583 break;
1584 default:
1585 FIXME("Unsupported tymed %d\n", stgm.tymed);
1586 break;
1587 }
1588 IDataObject_Release(ido);
1589 if (c->editor->nZoomNumerator != 0)
1590 {
1591 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1592 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1593 }
1594 }
1595
1596 void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
1597 ME_Paragraph *para, BOOL selected)
1598 {
1599 IDataObject* ido;
1600 FORMATETC fmt;
1601 STGMEDIUM stgm;
1602 DIBSECTION dibsect;
1603 ENHMETAHEADER emh;
1604 HDC hMemDC;
1605 SIZE sz;
1606 BOOL has_size;
1607
1608 assert(run->nFlags & MERF_GRAPHICS);
1609 assert(run->ole_obj);
1610 if (IOleObject_QueryInterface(run->ole_obj->poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
1611 {
1612 FIXME("Couldn't get interface\n");
1613 return;
1614 }
1615 has_size = run->ole_obj->sizel.cx != 0 || run->ole_obj->sizel.cy != 0;
1616 fmt.cfFormat = CF_BITMAP;
1617 fmt.ptd = NULL;
1618 fmt.dwAspect = DVASPECT_CONTENT;
1619 fmt.lindex = -1;
1620 fmt.tymed = TYMED_GDI;
1621 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1622 {
1623 fmt.cfFormat = CF_ENHMETAFILE;
1624 fmt.tymed = TYMED_ENHMF;
1625 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
1626 {
1627 FIXME("Couldn't get storage medium\n");
1628 IDataObject_Release(ido);
1629 return;
1630 }
1631 }
1632 switch (stgm.tymed)
1633 {
1634 case TYMED_GDI:
1635 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
1636 hMemDC = CreateCompatibleDC(c->hDC);
1637 SelectObject(hMemDC, stgm.u.hBitmap);
1638 if (has_size)
1639 {
1640 convert_sizel(c, &run->ole_obj->sizel, &sz);
1641 } else {
1642 sz.cx = MulDiv(dibsect.dsBm.bmWidth, c->dpi.cx, 96);
1643 sz.cy = MulDiv(dibsect.dsBm.bmHeight, c->dpi.cy, 96);
1644 }
1645 if (c->editor->nZoomNumerator != 0)
1646 {
1647 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1648 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1649 }
1650 if (sz.cx == dibsect.dsBm.bmWidth && sz.cy == dibsect.dsBm.bmHeight)
1651 {
1652 BitBlt(c->hDC, x, y - sz.cy,
1653 dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
1654 hMemDC, 0, 0, SRCCOPY);
1655 } else {
1656 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
1657 hMemDC, 0, 0, dibsect.dsBm.bmWidth,
1658 dibsect.dsBm.bmHeight, SRCCOPY);
1659 }
1660 DeleteDC(hMemDC);
1661 if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
1662 break;
1663 case TYMED_ENHMF:
1664 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
1665 if (has_size)
1666 {
1667 convert_sizel(c, &run->ole_obj->sizel, &sz);
1668 } else {
1669 sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, c->dpi.cx, 96);
1670 sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, c->dpi.cy, 96);
1671 }
1672 if (c->editor->nZoomNumerator != 0)
1673 {
1674 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1675 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
1676 }
1677
1678 {
1679 RECT rc;
1680
1681 rc.left = x;
1682 rc.top = y - sz.cy;
1683 rc.right = x + sz.cx;
1684 rc.bottom = y;
1685 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
1686 }
1687 if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
1688 break;
1689 default:
1690 FIXME("Unsupported tymed %d\n", stgm.tymed);
1691 selected = FALSE;
1692 break;
1693 }
1694 if (selected && !c->editor->bHideSelection)
1695 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
1696 IDataObject_Release(ido);
1697 }
1698
1699 void ME_DeleteReObject(REOBJECT* reo)
1700 {
1701 if (reo->poleobj) IOleObject_Release(reo->poleobj);
1702 if (reo->pstg) IStorage_Release(reo->pstg);
1703 if (reo->polesite) IOleClientSite_Release(reo->polesite);
1704 FREE_OBJ(reo);
1705 }
1706
1707 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src)
1708 {
1709 *dst = *src;
1710
1711 if (dst->poleobj) IOleObject_AddRef(dst->poleobj);
1712 if (dst->pstg) IStorage_AddRef(dst->pstg);
1713 if (dst->polesite) IOleClientSite_AddRef(dst->polesite);
1714 }