- More implementation of view
[wine/dcerpc.git] / dlls / mshtml / oleobj.c
blobee22ffb83f36f141fadd905c763ea59e28811e59
1 /*
2 * Copyright 2005 Jacek Caban
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30 #include "docobj.h"
32 #include "mshtml.h"
34 #include "wine/debug.h"
36 #include "mshtml_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
40 /**********************************************************
41 * IOleObject implementation
44 #define OLEOBJ_THIS \
45 HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpOleObjectVtbl));
47 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppvObject)
49 OLEOBJ_THIS
50 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
53 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
55 OLEOBJ_THIS
56 return IHTMLDocument2_AddRef(HTMLDOC(This));
59 static ULONG WINAPI OleObject_Release(IOleObject *iface)
61 OLEOBJ_THIS
62 return IHTMLDocument2_Release(HTMLDOC(This));
65 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite)
67 OLEOBJ_THIS
68 TRACE("(%p)->(%p)\n", This, pClientSite);
70 if(This->client)
71 IOleClientSite_Release(This->client);
72 if(pClientSite)
73 IOleClientSite_AddRef(pClientSite);
74 This->client = pClientSite;
76 return S_OK;
79 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite)
81 OLEOBJ_THIS
82 TRACE("(%p)->(%p)\n", This, ppClientSite);
84 if(!ppClientSite)
85 return E_INVALIDARG;
87 if(This->client)
88 IOleClientSite_AddRef(This->client);
89 *ppClientSite = This->client;
91 return S_OK;
94 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
96 OLEOBJ_THIS
97 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
98 return E_NOTIMPL;
101 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
103 OLEOBJ_THIS
104 FIXME("(%p)->(%08lx)\n", This, dwSaveOption);
105 return E_NOTIMPL;
108 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk)
110 OLEOBJ_THIS
111 FIXME("(%p %ld %p)->()\n", This, dwWhichMoniker, pmk);
112 return E_NOTIMPL;
115 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
117 OLEOBJ_THIS
118 FIXME("(%p)->(%ld %ld %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
119 return E_NOTIMPL;
122 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, IDataObject *pDataObject, BOOL fCreation,
123 DWORD dwReserved)
125 OLEOBJ_THIS
126 FIXME("(%p)->(%p %x %ld)\n", This, pDataObject, fCreation, dwReserved);
127 return E_NOTIMPL;
130 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject)
132 OLEOBJ_THIS
133 FIXME("(%p)->(%ld %p)\n", This, dwReserved, ppDataObject);
134 return E_NOTIMPL;
137 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite,
138 LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
140 OLEOBJ_THIS
141 IOleDocumentSite *pDocSite;
142 HRESULT hres;
144 TRACE("(%p)->(%ld %p %p %ld %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect);
146 if(iVerb != OLEIVERB_SHOW) {
147 FIXME("iVerb = %ld not supported\n", iVerb);
148 return E_NOTIMPL;
151 if(!pActiveSite)
152 pActiveSite = This->client;
154 hres = IOleClientSite_QueryInterface(pActiveSite, &IID_IOleDocumentSite, (void**)&pDocSite);
155 if(SUCCEEDED(hres)) {
156 IOleContainer *pContainer;
157 hres = IOleClientSite_GetContainer(pActiveSite, &pContainer);
158 if(SUCCEEDED(hres)) {
159 IOleContainer_LockContainer(pContainer, TRUE);
160 /* FIXME: Create new IOleDocumentView. See CreateView for more info. */
161 hres = IOleDocumentSite_ActivateMe(pDocSite, DOCVIEW(This));
162 IOleContainer_Release(pContainer);
164 IOleDocumentSite_Release(pDocSite);
165 }else {
166 hres = IOleDocumentView_UIActivate(DOCVIEW(This), TRUE);
167 if(SUCCEEDED(hres)) {
168 if(lprcPosRect) {
169 RECT rect; /* We need to pass rect as not const pointer */
170 memcpy(&rect, lprcPosRect, sizeof(RECT));
171 IOleDocumentView_SetRect(DOCVIEW(This), &rect);
173 IOleDocumentView_Show(DOCVIEW(This), TRUE);
177 return hres;
180 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
182 OLEOBJ_THIS
183 FIXME("(%p)->(%p)\n", This, ppEnumOleVerb);
184 return E_NOTIMPL;
187 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
189 OLEOBJ_THIS
190 FIXME("(%p)\n", This);
191 return E_NOTIMPL;
194 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
196 OLEOBJ_THIS
197 FIXME("(%p)\n", This);
198 return E_NOTIMPL;
201 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID *pClsid)
203 OLEOBJ_THIS
204 TRACE("(%p)->(%p)\n", This, pClsid);
206 if(!pClsid)
207 return E_INVALIDARG;
209 memcpy(pClsid, &CLSID_HTMLDocument, sizeof(GUID));
210 return S_OK;
213 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType)
215 OLEOBJ_THIS
216 FIXME("(%p)->(%ld %p)\n", This, dwFormOfType, pszUserType);
217 return E_NOTIMPL;
220 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
222 OLEOBJ_THIS
223 FIXME("(%p)->(%ld %p)\n", This, dwDrawAspect, psizel);
224 return E_NOTIMPL;
227 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
229 OLEOBJ_THIS
230 FIXME("(%p)->(%ld %p)\n", This, dwDrawAspect, psizel);
231 return E_NOTIMPL;
234 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
236 OLEOBJ_THIS
237 FIXME("(%p)->(%p %p)\n", This, pAdvSink, pdwConnection);
238 return E_NOTIMPL;
241 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
243 OLEOBJ_THIS
244 FIXME("(%p)->(%ld)\n", This, dwConnection);
245 return E_NOTIMPL;
248 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
250 OLEOBJ_THIS
251 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
252 return E_NOTIMPL;
255 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
257 OLEOBJ_THIS
258 FIXME("(%p)->(%ld %p)\n", This, dwAspect, pdwStatus);
259 return E_NOTIMPL;
262 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE *pLogpal)
264 OLEOBJ_THIS
265 FIXME("(%p)->(%p)\n", This, pLogpal);
266 return E_NOTIMPL;
269 static IOleObjectVtbl OleObjectVtbl = {
270 OleObject_QueryInterface,
271 OleObject_AddRef,
272 OleObject_Release,
273 OleObject_SetClientSite,
274 OleObject_GetClientSite,
275 OleObject_SetHostNames,
276 OleObject_Close,
277 OleObject_SetMoniker,
278 OleObject_GetMoniker,
279 OleObject_InitFromData,
280 OleObject_GetClipboardData,
281 OleObject_DoVerb,
282 OleObject_EnumVerbs,
283 OleObject_Update,
284 OleObject_IsUpToDate,
285 OleObject_GetUserClassID,
286 OleObject_GetUserType,
287 OleObject_SetExtent,
288 OleObject_GetExtent,
289 OleObject_Advise,
290 OleObject_Unadvise,
291 OleObject_EnumAdvise,
292 OleObject_GetMiscStatus,
293 OleObject_SetColorScheme
296 /**********************************************************
297 * IOleDocument implementation
300 #define OLEDOC_THIS \
301 HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpOleDocumentVtbl));
303 static HRESULT WINAPI OleDocument_QueryInterface(IOleDocument *iface, REFIID riid, void **ppvObject)
305 OLEDOC_THIS
306 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
309 static ULONG WINAPI OleDocument_AddRef(IOleDocument *iface)
311 OLEDOC_THIS
312 return IHTMLDocument2_AddRef(HTMLDOC(This));
315 static ULONG WINAPI OleDocument_Release(IOleDocument *iface)
317 OLEDOC_THIS
318 return IHTMLDocument2_Release(HTMLDOC(This));
321 static HRESULT WINAPI OleDocument_CreateView(IOleDocument *iface, IOleInPlaceSite *pIPSite, IStream *pstm,
322 DWORD dwReserved, IOleDocumentView **ppView)
324 OLEDOC_THIS
325 HRESULT hres;
327 TRACE("(%p)->(%p %p %ld %p)\n", This, pIPSite, pstm, dwReserved, ppView);
329 if(!ppView)
330 return E_INVALIDARG;
332 /* FIXME:
333 * Windows implementation creates new IOleDocumentView when function is called for the
334 * first time and returns E_FAIL when it is called for the second time, but it doesn't matter
335 * if the application uses returned interfaces, passed to ActivateMe or returned by
336 * QueryInterface, so there is no reason to create new interface. This needs more testing.
339 if(pIPSite) {
340 hres = IOleDocumentView_SetInPlaceSite(DOCVIEW(This), pIPSite);
341 if(FAILED(hres))
342 return hres;
345 if(pstm)
346 FIXME("pstm is not supported\n");
348 IOleDocumentView_AddRef(DOCVIEW(This));
349 *ppView = DOCVIEW(This);
350 return S_OK;
353 static HRESULT WINAPI OleDocument_GetDocMiscStatus(IOleDocument *iface, DWORD *pdwStatus)
355 OLEDOC_THIS
356 FIXME("(%p)->(%p)\n", This, pdwStatus);
357 return E_NOTIMPL;
360 static HRESULT WINAPI OleDocument_EnumViews(IOleDocument *iface, IEnumOleDocumentViews **ppEnum,
361 IOleDocumentView **ppView)
363 OLEDOC_THIS
364 FIXME("(%p)->(%p %p)\n", This, ppEnum, ppView);
365 return E_NOTIMPL;
368 static IOleDocumentVtbl OleDocumentVtbl = {
369 OleDocument_QueryInterface,
370 OleDocument_AddRef,
371 OleDocument_Release,
372 OleDocument_CreateView,
373 OleDocument_GetDocMiscStatus,
374 OleDocument_EnumViews
377 /**********************************************************
378 * IOleInPlaceActiveObject implementation
381 #define ACTOBJ_THIS \
382 HTMLDocument* const This=(HTMLDocument*)((char*)(iface)-offsetof(HTMLDocument,lpOleInPlaceActiveObjectVtbl));
384 static HRESULT WINAPI OleInPlaceActiveObject_QueryInterface(IOleInPlaceActiveObject *iface, REFIID riid, void **ppvObject)
386 ACTOBJ_THIS
387 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
390 static ULONG WINAPI OleInPlaceActiveObject_AddRef(IOleInPlaceActiveObject *iface)
392 ACTOBJ_THIS
393 return IHTMLDocument2_AddRef(HTMLDOC(This));
396 static ULONG WINAPI OleInPlaceActiveObject_Release(IOleInPlaceActiveObject *iface)
398 ACTOBJ_THIS
399 return IHTMLDocument2_Release(HTMLDOC(This));
402 static HRESULT WINAPI OleInPlaceActiveObject_GetWindow(IOleInPlaceActiveObject *iface, HWND *phwnd)
404 ACTOBJ_THIS
405 TRACE("(%p)->(%p)\n", This, phwnd);
407 if(!phwnd)
408 return E_INVALIDARG;
410 *phwnd = This->hwnd;
411 return S_OK;
414 static HRESULT WINAPI OleInPlaceActiveObject_ContextSensitiveHelp(IOleInPlaceActiveObject *iface, BOOL fEnterMode)
416 ACTOBJ_THIS
417 FIXME("(%p)->(%x)\n", This, fEnterMode);
418 return E_NOTIMPL;
421 static HRESULT WINAPI OleInPlaceActiveObject_TranslateAccelerator(IOleInPlaceActiveObject *iface, LPMSG lpmsg)
423 ACTOBJ_THIS
424 FIXME("(%p)->(%p)\n", This, lpmsg);
425 return E_NOTIMPL;
428 static HRESULT WINAPI OleInPlaceActiveObject_OnFrameWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate)
430 ACTOBJ_THIS
431 FIXME("(%p)->(%x)\n", This, fActivate);
432 return E_NOTIMPL;
435 static HRESULT WINAPI OleInPlaceActiveObject_OnDocWindowActivate(IOleInPlaceActiveObject *iface, BOOL fActivate)
437 ACTOBJ_THIS
438 FIXME("(%p)->(%x)\n", This, fActivate);
439 return E_NOTIMPL;
442 static HRESULT WINAPI OleInPlaceActiveObject_ResizeBorder(IOleInPlaceActiveObject *iface, LPCRECT prcBorder,
443 IOleInPlaceUIWindow *pUIWindow, BOOL fFrameWindow)
445 ACTOBJ_THIS
446 FIXME("(%p)->(%p %p %x)\n", This, prcBorder, pUIWindow, fFrameWindow);
447 return E_NOTIMPL;
450 static HRESULT WINAPI OleInPlaceActiveObject_EnableModeless(IOleInPlaceActiveObject *iface, BOOL fEnable)
452 ACTOBJ_THIS
453 FIXME("(%p)->(%x)\n", This, fEnable);
454 return E_NOTIMPL;
457 static IOleInPlaceActiveObjectVtbl OleInPlaceActiveObjectVtbl = {
458 OleInPlaceActiveObject_QueryInterface,
459 OleInPlaceActiveObject_AddRef,
460 OleInPlaceActiveObject_Release,
461 OleInPlaceActiveObject_GetWindow,
462 OleInPlaceActiveObject_ContextSensitiveHelp,
463 OleInPlaceActiveObject_TranslateAccelerator,
464 OleInPlaceActiveObject_OnFrameWindowActivate,
465 OleInPlaceActiveObject_OnDocWindowActivate,
466 OleInPlaceActiveObject_ResizeBorder,
467 OleInPlaceActiveObject_EnableModeless
470 void HTMLDocument_OleObj_Init(HTMLDocument *This)
472 This->lpOleObjectVtbl = &OleObjectVtbl;
473 This->lpOleDocumentVtbl = &OleDocumentVtbl;
474 This->lpOleInPlaceActiveObjectVtbl = &OleInPlaceActiveObjectVtbl;
476 This->client = NULL;