- RTF reader doesn't use RichEdit messages anymore (which saves on
[wine] / dlls / 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <stdarg.h>
23
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
26 #define COBJMACROS
27
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 "wine/debug.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(richedit);
37
38 typedef struct IRichEditOleImpl {
39     IRichEditOleVtbl *lpVtbl;
40     DWORD ref;
41 } IRichEditOleImpl;
42
43 /* there is no way to be consistent across different sets of headers - mingw, Wine, Win32 SDK*/
44
45 /* FIXME: the next 6 lines should be in textserv.h */
46 #define TEXTSERV_GUID(name, l, w1, w2, b1, b2) \
47   GUID name = { l, w1, w2, {b1, b2, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5}}
48
49 TEXTSERV_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d);
50 TEXTSERV_GUID(IID_ITextHost, 0xc5bdd8d0, 0xd26e, 0x11ce, 0xa8, 0x9e);
51 TEXTSERV_GUID(IID_ITextHost2, 0xc5bdd8d0, 0xd26e, 0x11ce, 0xa8, 0x9e);
52
53 static HRESULT WINAPI
54 IRichEditOle_fnQueryInterface(IRichEditOle *me, REFIID riid, LPVOID *ppvObj)
55 {
56     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
57
58     TRACE("%p %s\n", This, debugstr_guid(riid) );
59
60     if (IsEqualGUID(riid, &IID_IUnknown) ||
61         IsEqualGUID(riid, &IID_IRichEditOle))
62     {
63         IRichEditOle_AddRef(me);
64         *ppvObj = (LPVOID) This;
65         return S_OK;
66     }
67     FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid) );
68  
69     return E_NOINTERFACE;   
70 }
71
72 static ULONG WINAPI
73 IRichEditOle_fnAddRef(IRichEditOle *me)
74 {
75     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
76     ULONG ref = InterlockedIncrement( &This->ref );
77
78     TRACE("%p ref = %lu\n", This, ref);
79
80     return ref;
81 }
82
83 static ULONG WINAPI
84 IRichEditOle_fnRelease(IRichEditOle *me)
85 {
86     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
87     ULONG ref = InterlockedDecrement(&This->ref);
88
89     TRACE ("%p ref=%lu\n", This, ref);
90
91     if (!ref)
92     {
93         TRACE ("Destroying %p\n", This);
94         HeapFree(GetProcessHeap(),0,This);
95     }
96     return ref;
97 }
98
99 static HRESULT WINAPI
100 IRichEditOle_fnActivateAs(IRichEditOle *me, REFCLSID rclsid, REFCLSID rclsidAs)
101 {
102     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
103     FIXME("stub %p\n",This);
104     return E_NOTIMPL;
105 }
106
107 static HRESULT WINAPI
108 IRichEditOle_fnContextSensitiveHelp(IRichEditOle *me, BOOL fEnterMode)
109 {
110     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
111     FIXME("stub %p\n",This);
112     return E_NOTIMPL;
113 }
114
115 static HRESULT WINAPI
116 IRichEditOle_fnConvertObject(IRichEditOle *me, LONG iob,
117                REFCLSID rclsidNew, LPCSTR lpstrUserTypeNew)
118 {
119     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
120     FIXME("stub %p\n",This);
121     return E_NOTIMPL;
122 }
123
124 static HRESULT WINAPI
125 IRichEditOle_fnGetClientSite(IRichEditOle *me,
126                LPOLECLIENTSITE *lplpolesite)
127 {
128     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
129     FIXME("stub %p\n",This);
130     return E_NOTIMPL;
131 }
132
133 static HRESULT WINAPI
134 IRichEditOle_fnGetClipboardData(IRichEditOle *me, CHARRANGE *lpchrg,
135                DWORD reco, LPDATAOBJECT *lplpdataobj)
136 {
137     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
138     FIXME("stub %p\n",This);
139     return E_NOTIMPL;
140 }
141
142 static LONG WINAPI IRichEditOle_fnGetLinkCount(IRichEditOle *me)
143 {
144     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
145     FIXME("stub %p\n",This);
146     return E_NOTIMPL;
147 }
148
149 static HRESULT WINAPI
150 IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
151                REOBJECT *lpreobject, DWORD dwFlags)
152 {
153     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
154     FIXME("stub %p\n",This);
155     return E_NOTIMPL;
156 }
157
158 static LONG WINAPI
159 IRichEditOle_fnGetObjectCount(IRichEditOle *me)
160 {
161     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
162     FIXME("stub %p\n",This);
163     return E_NOTIMPL;
164 }
165
166 static HRESULT WINAPI
167 IRichEditOle_fnHandsOffStorage(IRichEditOle *me, LONG iob)
168 {
169     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
170     FIXME("stub %p\n",This);
171     return E_NOTIMPL;
172 }
173
174 static HRESULT WINAPI
175 IRichEditOle_fnImportDataObject(IRichEditOle *me, LPDATAOBJECT lpdataobj,
176                CLIPFORMAT cf, HGLOBAL hMetaPict)
177 {
178     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
179     FIXME("stub %p\n",This);
180     return E_NOTIMPL;
181 }
182
183 static HRESULT WINAPI
184 IRichEditOle_fnInPlaceDeactivate(IRichEditOle *me)
185 {
186     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
187     FIXME("stub %p\n",This);
188     return E_NOTIMPL;
189 }
190
191 static HRESULT WINAPI
192 IRichEditOle_fnInsertObject(IRichEditOle *me, REOBJECT *lpreobject)
193 {
194     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
195     FIXME("stub %p\n",This);
196     return E_NOTIMPL;
197 }
198
199 static HRESULT WINAPI IRichEditOle_fnSaveCompleted(IRichEditOle *me, LONG iob,
200                LPSTORAGE lpstg)
201 {
202     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
203     FIXME("stub %p\n",This);
204     return E_NOTIMPL;
205 }
206
207 static HRESULT WINAPI
208 IRichEditOle_fnSetDvaspect(IRichEditOle *me, LONG iob, DWORD dvaspect)
209 {
210     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
211     FIXME("stub %p\n",This);
212     return E_NOTIMPL;
213 }
214
215 static HRESULT WINAPI IRichEditOle_fnSetHostNames(IRichEditOle *me,
216                LPCSTR lpstrContainerApp, LPCSTR lpstrContainerObj)
217 {
218     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
219     FIXME("stub %p %s %s\n",This, lpstrContainerApp, lpstrContainerObj);
220     return E_NOTIMPL;
221 }
222
223 static HRESULT WINAPI
224 IRichEditOle_fnSetLinkAvailable(IRichEditOle *me, LONG iob, BOOL fAvailable)
225 {
226     IRichEditOleImpl *This = (IRichEditOleImpl *)me;
227     FIXME("stub %p\n",This);
228     return E_NOTIMPL;
229 }
230
231 static IRichEditOleVtbl revt = {
232     IRichEditOle_fnQueryInterface,
233     IRichEditOle_fnAddRef,
234     IRichEditOle_fnRelease,
235     IRichEditOle_fnGetClientSite,
236     IRichEditOle_fnGetObjectCount,
237     IRichEditOle_fnGetLinkCount,
238     IRichEditOle_fnGetObject,
239     IRichEditOle_fnInsertObject,
240     IRichEditOle_fnConvertObject,
241     IRichEditOle_fnActivateAs,
242     IRichEditOle_fnSetHostNames,
243     IRichEditOle_fnSetLinkAvailable,
244     IRichEditOle_fnSetDvaspect,
245     IRichEditOle_fnHandsOffStorage,
246     IRichEditOle_fnSaveCompleted,
247     IRichEditOle_fnInPlaceDeactivate,
248     IRichEditOle_fnContextSensitiveHelp,
249     IRichEditOle_fnGetClipboardData,
250     IRichEditOle_fnImportDataObject
251 };
252
253 LRESULT CreateIRichEditOle(LPVOID *ppObj)
254 {
255     IRichEditOleImpl *reo;
256
257     reo = HeapAlloc(GetProcessHeap(), 0, sizeof(IRichEditOleImpl));
258     if (!reo)
259         return 0;
260
261     reo->lpVtbl = &revt;
262     reo->ref = 1;
263     TRACE("Created %p\n",reo);
264     *ppObj = (LPVOID) reo;
265
266     return 1;
267 }