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 if(!This->has_key_path) {
100 hres = IDocHostUIHandler_GetOptionKeyPath(pDocHostUIHandler, &key_path, 0);
101 if(hres == S_OK && key_path) {
103 /* FIXME: use key_path */
104 TRACE("key_path = %s\n", debugstr_w(key_path));
106 CoTaskMemFree(key_path);
109 hres = IDocHostUIHandler_QueryInterface(pDocHostUIHandler, &IID_IDocHostUIHandler2,
110 (void**)&pDocHostUIHandler2);
111 if(SUCCEEDED(hres)) {
112 hres = IDocHostUIHandler2_GetOverrideKeyPath(pDocHostUIHandler2, &override_key_path, 0);
113 if(hres == S_OK && override_key_path && override_key_path[0]) {
114 if(override_key_path[0]) {
115 /*FIXME: use override_key_path */
116 TRACE("override_key_path = %s\n", debugstr_w(override_key_path));
118 CoTaskMemFree(override_key_path);
122 This->has_key_path = TRUE;
126 /* Native calls here GetWindow. What is it for?
127 * We don't have anything to do with it here (yet). */
129 IOleWindow *pOleWindow = NULL;
132 hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleWindow, (void**)&pOleWindow);
133 if(SUCCEEDED(hres)) {
134 IOleWindow_GetWindow(pOleWindow, &hwnd);
135 IOleWindow_Release(pOleWindow);
139 IOleClientSite_AddRef(pClientSite);
140 This->client = pClientSite;
141 This->hostui = pDocHostUIHandler;
146 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite)
148 HTMLDocument *This = OLEOBJ_THIS(iface);
150 TRACE("(%p)->(%p)\n", This, ppClientSite);
156 IOleClientSite_AddRef(This->client);
157 *ppClientSite = This->client;
162 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
164 HTMLDocument *This = OLEOBJ_THIS(iface);
165 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
169 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
171 HTMLDocument *This = OLEOBJ_THIS(iface);
174 FIXME("(%p)->(%08lx)\n", This, dwSaveOption);
177 IOleContainer *container;
178 hres = IOleClientSite_GetContainer(This->client, &container);
179 if(SUCCEEDED(hres)) {
180 IOleContainer_LockContainer(container, FALSE);
181 IOleContainer_Release(container);
188 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk)
190 HTMLDocument *This = OLEOBJ_THIS(iface);
191 FIXME("(%p %ld %p)->()\n", This, dwWhichMoniker, pmk);
195 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
197 HTMLDocument *This = OLEOBJ_THIS(iface);
198 FIXME("(%p)->(%ld %ld %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
202 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, IDataObject *pDataObject, BOOL fCreation,
205 HTMLDocument *This = OLEOBJ_THIS(iface);
206 FIXME("(%p)->(%p %x %ld)\n", This, pDataObject, fCreation, dwReserved);
210 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject)
212 HTMLDocument *This = OLEOBJ_THIS(iface);
213 FIXME("(%p)->(%ld %p)\n", This, dwReserved, ppDataObject);
217 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite,
218 LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
220 HTMLDocument *This = OLEOBJ_THIS(iface);
221 IOleDocumentSite *pDocSite;
224 TRACE("(%p)->(%ld %p %p %ld %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect);
226 if(iVerb != OLEIVERB_SHOW && iVerb != OLEIVERB_UIACTIVATE) {
227 FIXME("iVerb = %ld not supported\n", iVerb);
232 pActiveSite = This->client;
234 hres = IOleClientSite_QueryInterface(pActiveSite, &IID_IOleDocumentSite, (void**)&pDocSite);
235 if(SUCCEEDED(hres)) {
236 IOleContainer *pContainer;
237 hres = IOleClientSite_GetContainer(pActiveSite, &pContainer);
238 if(SUCCEEDED(hres)) {
239 IOleContainer_LockContainer(pContainer, TRUE);
240 IOleContainer_Release(pContainer);
242 /* FIXME: Create new IOleDocumentView. See CreateView for more info. */
243 hres = IOleDocumentSite_ActivateMe(pDocSite, DOCVIEW(This));
244 IOleDocumentSite_Release(pDocSite);
246 hres = IOleDocumentView_UIActivate(DOCVIEW(This), TRUE);
247 if(SUCCEEDED(hres)) {
249 RECT rect; /* We need to pass rect as not const pointer */
250 memcpy(&rect, lprcPosRect, sizeof(RECT));
251 IOleDocumentView_SetRect(DOCVIEW(This), &rect);
253 IOleDocumentView_Show(DOCVIEW(This), TRUE);
260 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
262 HTMLDocument *This = OLEOBJ_THIS(iface);
263 FIXME("(%p)->(%p)\n", This, ppEnumOleVerb);
267 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
269 HTMLDocument *This = OLEOBJ_THIS(iface);
270 FIXME("(%p)\n", This);
274 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
276 HTMLDocument *This = OLEOBJ_THIS(iface);
277 FIXME("(%p)\n", This);
281 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID *pClsid)
283 HTMLDocument *This = OLEOBJ_THIS(iface);
285 TRACE("(%p)->(%p)\n", This, pClsid);
290 memcpy(pClsid, &CLSID_HTMLDocument, sizeof(GUID));
294 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType)
296 HTMLDocument *This = OLEOBJ_THIS(iface);
297 FIXME("(%p)->(%ld %p)\n", This, dwFormOfType, pszUserType);
301 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
303 HTMLDocument *This = OLEOBJ_THIS(iface);
304 FIXME("(%p)->(%ld %p)\n", This, dwDrawAspect, psizel);
308 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
310 HTMLDocument *This = OLEOBJ_THIS(iface);
311 FIXME("(%p)->(%ld %p)\n", This, dwDrawAspect, psizel);
315 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
317 HTMLDocument *This = OLEOBJ_THIS(iface);
318 FIXME("(%p)->(%p %p)\n", This, pAdvSink, pdwConnection);
322 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
324 HTMLDocument *This = OLEOBJ_THIS(iface);
325 FIXME("(%p)->(%ld)\n", This, dwConnection);
329 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
331 HTMLDocument *This = OLEOBJ_THIS(iface);
332 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
336 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
338 HTMLDocument *This = OLEOBJ_THIS(iface);
339 FIXME("(%p)->(%ld %p)\n", This, dwAspect, pdwStatus);
343 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE *pLogpal)
345 HTMLDocument *This = OLEOBJ_THIS(iface);
346 FIXME("(%p)->(%p)\n", This, pLogpal);
352 static const IOleObjectVtbl OleObjectVtbl = {
353 OleObject_QueryInterface,
356 OleObject_SetClientSite,
357 OleObject_GetClientSite,
358 OleObject_SetHostNames,
360 OleObject_SetMoniker,
361 OleObject_GetMoniker,
362 OleObject_InitFromData,
363 OleObject_GetClipboardData,
367 OleObject_IsUpToDate,
368 OleObject_GetUserClassID,
369 OleObject_GetUserType,
374 OleObject_EnumAdvise,
375 OleObject_GetMiscStatus,
376 OleObject_SetColorScheme
379 /**********************************************************
380 * IOleDocument implementation
383 #define OLEDOC_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocument, iface)
385 static HRESULT WINAPI OleDocument_QueryInterface(IOleDocument *iface, REFIID riid, void **ppvObject)
387 HTMLDocument *This = OLEDOC_THIS(iface);
388 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
391 static ULONG WINAPI OleDocument_AddRef(IOleDocument *iface)
393 HTMLDocument *This = OLEDOC_THIS(iface);
394 return IHTMLDocument2_AddRef(HTMLDOC(This));
397 static ULONG WINAPI OleDocument_Release(IOleDocument *iface)
399 HTMLDocument *This = OLEDOC_THIS(iface);
400 return IHTMLDocument2_Release(HTMLDOC(This));
403 static HRESULT WINAPI OleDocument_CreateView(IOleDocument *iface, IOleInPlaceSite *pIPSite, IStream *pstm,
404 DWORD dwReserved, IOleDocumentView **ppView)
406 HTMLDocument *This = OLEDOC_THIS(iface);
409 TRACE("(%p)->(%p %p %ld %p)\n", This, pIPSite, pstm, dwReserved, ppView);
415 * Windows implementation creates new IOleDocumentView when function is called for the
416 * first time and returns E_FAIL when it is called for the second time, but it doesn't matter
417 * if the application uses returned interfaces, passed to ActivateMe or returned by
418 * QueryInterface, so there is no reason to create new interface. This needs more testing.
422 hres = IOleDocumentView_SetInPlaceSite(DOCVIEW(This), pIPSite);
428 FIXME("pstm is not supported\n");
430 IOleDocumentView_AddRef(DOCVIEW(This));
431 *ppView = DOCVIEW(This);
435 static HRESULT WINAPI OleDocument_GetDocMiscStatus(IOleDocument *iface, DWORD *pdwStatus)
437 HTMLDocument *This = OLEDOC_THIS(iface);
438 FIXME("(%p)->(%p)\n", This, pdwStatus);
442 static HRESULT WINAPI OleDocument_EnumViews(IOleDocument *iface, IEnumOleDocumentViews **ppEnum,
443 IOleDocumentView **ppView)
445 HTMLDocument *This = OLEDOC_THIS(iface);
446 FIXME("(%p)->(%p %p)\n", This, ppEnum, ppView);
452 static const IOleDocumentVtbl OleDocumentVtbl = {
453 OleDocument_QueryInterface,
456 OleDocument_CreateView,
457 OleDocument_GetDocMiscStatus,
458 OleDocument_EnumViews
461 /**********************************************************
462 * IOleCommandTarget implementation
465 #define CMDTARGET_THIS(iface) DEFINE_THIS(HTMLDocument, OleCommandTarget, iface)
467 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv)
469 HTMLDocument *This = CMDTARGET_THIS(iface);
470 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
473 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
475 HTMLDocument *This = CMDTARGET_THIS(iface);
476 return IHTMLDocument2_AddRef(HTMLDOC(This));
479 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
481 HTMLDocument *This = CMDTARGET_THIS(iface);
482 return IHTMLDocument_Release(HTMLDOC(This));
485 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
486 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
488 HTMLDocument *This = CMDTARGET_THIS(iface);
489 FIXME("(%p)->(%s %ld %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
493 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
494 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
496 HTMLDocument *This = CMDTARGET_THIS(iface);
497 FIXME("(%p)->(%s %ld %ld %p %p)\n", This, debugstr_guid(pguidCmdGroup), nCmdID, nCmdexecopt,
502 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
503 OleCommandTarget_QueryInterface,
504 OleCommandTarget_AddRef,
505 OleCommandTarget_Release,
506 OleCommandTarget_QueryStatus,
507 OleCommandTarget_Exec
510 void HTMLDocument_OleObj_Init(HTMLDocument *This)
512 This->lpOleObjectVtbl = &OleObjectVtbl;
513 This->lpOleDocumentVtbl = &OleDocumentVtbl;
514 This->lpOleCommandTargetVtbl = &OleCommandTargetVtbl;
519 This->has_key_path = FALSE;