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
35 #include "wine/debug.h"
37 #include "mshtml_private.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
41 /**********************************************************
42 * IOleObject implementation
45 #define OLEOBJ_THIS(iface) DEFINE_THIS(HTMLDocument, OleObject, iface)
47 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppvObject)
49 HTMLDocument *This = OLEOBJ_THIS(iface);
50 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
53 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
55 HTMLDocument *This = OLEOBJ_THIS(iface);
56 return IHTMLDocument2_AddRef(HTMLDOC(This));
59 static ULONG WINAPI OleObject_Release(IOleObject *iface)
61 HTMLDocument *This = OLEOBJ_THIS(iface);
62 return IHTMLDocument2_Release(HTMLDOC(This));
65 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite)
67 HTMLDocument *This = OLEOBJ_THIS(iface);
68 IDocHostUIHandler *pDocHostUIHandler = NULL;
71 TRACE("(%p)->(%p)\n", This, pClientSite);
74 IOleClientSite_Release(This->client);
77 IDocHostUIHandler_Release(This->hostui);
84 hres = IOleObject_QueryInterface(pClientSite, &IID_IDocHostUIHandler, (void**)&pDocHostUIHandler);
86 DOCHOSTUIINFO hostinfo;
87 LPOLESTR key_path = NULL, override_key_path = NULL;
88 IDocHostUIHandler2 *pDocHostUIHandler2;
90 memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO));
91 hostinfo.cbSize = sizeof(DOCHOSTUIINFO);
92 hres = IDocHostUIHandler_GetHostInfo(pDocHostUIHandler, &hostinfo);
94 /* FIXME: use hostinfo */
95 TRACE("hostinfo = {%lu %08lx %08lx %s %s}\n",
96 hostinfo.cbSize, hostinfo.dwFlags, hostinfo.dwDoubleClick,
97 debugstr_w(hostinfo.pchHostCss), debugstr_w(hostinfo.pchHostNS));
99 hres = IDocHostUIHandler_GetOptionKeyPath(pDocHostUIHandler, &key_path, 0);
100 if(hres == S_OK && key_path && key_path[0])
101 /* FIXME: use key_path */
102 TRACE("key_path = %s\n", debugstr_w(key_path));
104 hres = IDocHostUIHandler_QueryInterface(pDocHostUIHandler, &IID_IDocHostUIHandler2,
105 (void**)&pDocHostUIHandler2);
106 if(SUCCEEDED(hres)) {
107 /*FIXME: use override_key_path */
108 hres = IDocHostUIHandler2_GetOverrideKeyPath(pDocHostUIHandler2, &override_key_path, 0);
109 if(hres == S_OK && override_key_path && override_key_path[0])
110 FIXME("override_key_path = %s\n", debugstr_w(override_key_path));
114 /* Native calls here GetWindow. What is it for?
115 * We don't have anything to do with it here (yet). */
117 IOleWindow *pOleWindow = NULL;
120 hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleWindow, (void**)&pOleWindow);
121 if(SUCCEEDED(hres)) {
122 IOleWindow_GetWindow(pOleWindow, &hwnd);
123 IOleWindow_Release(pOleWindow);
127 IOleClientSite_AddRef(pClientSite);
128 This->client = pClientSite;
129 This->hostui = pDocHostUIHandler;
134 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite)
136 HTMLDocument *This = OLEOBJ_THIS(iface);
138 TRACE("(%p)->(%p)\n", This, ppClientSite);
144 IOleClientSite_AddRef(This->client);
145 *ppClientSite = This->client;
150 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
152 HTMLDocument *This = OLEOBJ_THIS(iface);
153 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
157 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
159 HTMLDocument *This = OLEOBJ_THIS(iface);
162 FIXME("(%p)->(%08lx)\n", This, dwSaveOption);
165 IOleContainer *container;
166 hres = IOleClientSite_GetContainer(This->client, &container);
167 if(SUCCEEDED(hres)) {
168 IOleContainer_LockContainer(container, FALSE);
169 IOleContainer_Release(container);
176 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk)
178 HTMLDocument *This = OLEOBJ_THIS(iface);
179 FIXME("(%p %ld %p)->()\n", This, dwWhichMoniker, pmk);
183 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
185 HTMLDocument *This = OLEOBJ_THIS(iface);
186 FIXME("(%p)->(%ld %ld %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
190 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, IDataObject *pDataObject, BOOL fCreation,
193 HTMLDocument *This = OLEOBJ_THIS(iface);
194 FIXME("(%p)->(%p %x %ld)\n", This, pDataObject, fCreation, dwReserved);
198 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject)
200 HTMLDocument *This = OLEOBJ_THIS(iface);
201 FIXME("(%p)->(%ld %p)\n", This, dwReserved, ppDataObject);
205 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite,
206 LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
208 HTMLDocument *This = OLEOBJ_THIS(iface);
209 IOleDocumentSite *pDocSite;
212 TRACE("(%p)->(%ld %p %p %ld %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect);
214 if(iVerb != OLEIVERB_SHOW && iVerb != OLEIVERB_UIACTIVATE) {
215 FIXME("iVerb = %ld not supported\n", iVerb);
220 pActiveSite = This->client;
222 hres = IOleClientSite_QueryInterface(pActiveSite, &IID_IOleDocumentSite, (void**)&pDocSite);
223 if(SUCCEEDED(hres)) {
224 IOleContainer *pContainer;
225 hres = IOleClientSite_GetContainer(pActiveSite, &pContainer);
226 if(SUCCEEDED(hres)) {
227 IOleContainer_LockContainer(pContainer, TRUE);
228 IOleContainer_Release(pContainer);
230 /* FIXME: Create new IOleDocumentView. See CreateView for more info. */
231 hres = IOleDocumentSite_ActivateMe(pDocSite, DOCVIEW(This));
232 IOleDocumentSite_Release(pDocSite);
234 hres = IOleDocumentView_UIActivate(DOCVIEW(This), TRUE);
235 if(SUCCEEDED(hres)) {
237 RECT rect; /* We need to pass rect as not const pointer */
238 memcpy(&rect, lprcPosRect, sizeof(RECT));
239 IOleDocumentView_SetRect(DOCVIEW(This), &rect);
241 IOleDocumentView_Show(DOCVIEW(This), TRUE);
248 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
250 HTMLDocument *This = OLEOBJ_THIS(iface);
251 FIXME("(%p)->(%p)\n", This, ppEnumOleVerb);
255 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
257 HTMLDocument *This = OLEOBJ_THIS(iface);
258 FIXME("(%p)\n", This);
262 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
264 HTMLDocument *This = OLEOBJ_THIS(iface);
265 FIXME("(%p)\n", This);
269 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID *pClsid)
271 HTMLDocument *This = OLEOBJ_THIS(iface);
273 TRACE("(%p)->(%p)\n", This, pClsid);
278 memcpy(pClsid, &CLSID_HTMLDocument, sizeof(GUID));
282 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType)
284 HTMLDocument *This = OLEOBJ_THIS(iface);
285 FIXME("(%p)->(%ld %p)\n", This, dwFormOfType, pszUserType);
289 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
291 HTMLDocument *This = OLEOBJ_THIS(iface);
292 FIXME("(%p)->(%ld %p)\n", This, dwDrawAspect, psizel);
296 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
298 HTMLDocument *This = OLEOBJ_THIS(iface);
299 FIXME("(%p)->(%ld %p)\n", This, dwDrawAspect, psizel);
303 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
305 HTMLDocument *This = OLEOBJ_THIS(iface);
306 FIXME("(%p)->(%p %p)\n", This, pAdvSink, pdwConnection);
310 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
312 HTMLDocument *This = OLEOBJ_THIS(iface);
313 FIXME("(%p)->(%ld)\n", This, dwConnection);
317 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
319 HTMLDocument *This = OLEOBJ_THIS(iface);
320 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
324 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
326 HTMLDocument *This = OLEOBJ_THIS(iface);
327 FIXME("(%p)->(%ld %p)\n", This, dwAspect, pdwStatus);
331 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE *pLogpal)
333 HTMLDocument *This = OLEOBJ_THIS(iface);
334 FIXME("(%p)->(%p)\n", This, pLogpal);
340 static const IOleObjectVtbl OleObjectVtbl = {
341 OleObject_QueryInterface,
344 OleObject_SetClientSite,
345 OleObject_GetClientSite,
346 OleObject_SetHostNames,
348 OleObject_SetMoniker,
349 OleObject_GetMoniker,
350 OleObject_InitFromData,
351 OleObject_GetClipboardData,
355 OleObject_IsUpToDate,
356 OleObject_GetUserClassID,
357 OleObject_GetUserType,
362 OleObject_EnumAdvise,
363 OleObject_GetMiscStatus,
364 OleObject_SetColorScheme
367 /**********************************************************
368 * IOleDocument implementation
371 #define OLEDOC_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocument, iface)
373 static HRESULT WINAPI OleDocument_QueryInterface(IOleDocument *iface, REFIID riid, void **ppvObject)
375 HTMLDocument *This = OLEDOC_THIS(iface);
376 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
379 static ULONG WINAPI OleDocument_AddRef(IOleDocument *iface)
381 HTMLDocument *This = OLEDOC_THIS(iface);
382 return IHTMLDocument2_AddRef(HTMLDOC(This));
385 static ULONG WINAPI OleDocument_Release(IOleDocument *iface)
387 HTMLDocument *This = OLEDOC_THIS(iface);
388 return IHTMLDocument2_Release(HTMLDOC(This));
391 static HRESULT WINAPI OleDocument_CreateView(IOleDocument *iface, IOleInPlaceSite *pIPSite, IStream *pstm,
392 DWORD dwReserved, IOleDocumentView **ppView)
394 HTMLDocument *This = OLEDOC_THIS(iface);
397 TRACE("(%p)->(%p %p %ld %p)\n", This, pIPSite, pstm, dwReserved, ppView);
403 * Windows implementation creates new IOleDocumentView when function is called for the
404 * first time and returns E_FAIL when it is called for the second time, but it doesn't matter
405 * if the application uses returned interfaces, passed to ActivateMe or returned by
406 * QueryInterface, so there is no reason to create new interface. This needs more testing.
410 hres = IOleDocumentView_SetInPlaceSite(DOCVIEW(This), pIPSite);
416 FIXME("pstm is not supported\n");
418 IOleDocumentView_AddRef(DOCVIEW(This));
419 *ppView = DOCVIEW(This);
423 static HRESULT WINAPI OleDocument_GetDocMiscStatus(IOleDocument *iface, DWORD *pdwStatus)
425 HTMLDocument *This = OLEDOC_THIS(iface);
426 FIXME("(%p)->(%p)\n", This, pdwStatus);
430 static HRESULT WINAPI OleDocument_EnumViews(IOleDocument *iface, IEnumOleDocumentViews **ppEnum,
431 IOleDocumentView **ppView)
433 HTMLDocument *This = OLEDOC_THIS(iface);
434 FIXME("(%p)->(%p %p)\n", This, ppEnum, ppView);
440 static const IOleDocumentVtbl OleDocumentVtbl = {
441 OleDocument_QueryInterface,
444 OleDocument_CreateView,
445 OleDocument_GetDocMiscStatus,
446 OleDocument_EnumViews
449 /**********************************************************
450 * IOleCommandTarget implementation
453 #define CMDTARGET_THIS(iface) DEFINE_THIS(HTMLDocument, OleCommandTarget, iface)
455 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv)
457 HTMLDocument *This = CMDTARGET_THIS(iface);
458 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
461 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
463 HTMLDocument *This = CMDTARGET_THIS(iface);
464 return IHTMLDocument2_AddRef(HTMLDOC(This));
467 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
469 HTMLDocument *This = CMDTARGET_THIS(iface);
470 return IHTMLDocument_Release(HTMLDOC(This));
473 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
474 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
476 HTMLDocument *This = CMDTARGET_THIS(iface);
477 FIXME("(%p)->(%s %ld %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
481 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
482 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
484 HTMLDocument *This = CMDTARGET_THIS(iface);
485 FIXME("(%p)->(%s %ld %ld %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt,
490 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
491 OleCommandTarget_QueryInterface,
492 OleCommandTarget_AddRef,
493 OleCommandTarget_Release,
494 OleCommandTarget_QueryStatus,
495 OleCommandTarget_Exec
498 void HTMLDocument_OleObj_Init(HTMLDocument *This)
500 This->lpOleObjectVtbl = &OleObjectVtbl;
501 This->lpOleDocumentVtbl = &OleDocumentVtbl;
502 This->lpOleCommandTargetVtbl = &OleCommandTargetVtbl;