winecfg: Update German resource.
[wine/hacks.git] / dlls / mshtml / oleobj.c
blob3c186822201307127b6a73c4e7b713714aad3922
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 "shlguid.h"
31 #include "mshtmdid.h"
32 #include "idispids.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(iface) DEFINE_THIS(HTMLDocument, OleObject, iface)
46 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppvObject)
48 HTMLDocument *This = OLEOBJ_THIS(iface);
49 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
52 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
54 HTMLDocument *This = OLEOBJ_THIS(iface);
55 return IHTMLDocument2_AddRef(HTMLDOC(This));
58 static ULONG WINAPI OleObject_Release(IOleObject *iface)
60 HTMLDocument *This = OLEOBJ_THIS(iface);
61 return IHTMLDocument2_Release(HTMLDOC(This));
64 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite)
66 HTMLDocument *This = OLEOBJ_THIS(iface);
67 IDocHostUIHandler *pDocHostUIHandler = NULL;
68 IOleCommandTarget *cmdtrg = NULL;
69 HRESULT hres;
71 TRACE("(%p)->(%p)\n", This, pClientSite);
73 if(pClientSite == This->client)
74 return S_OK;
76 if(This->client)
77 IOleClientSite_Release(This->client);
79 if(This->hostui)
80 IDocHostUIHandler_Release(This->hostui);
82 if(!pClientSite) {
83 This->client = NULL;
84 return S_OK;
87 hres = IOleObject_QueryInterface(pClientSite, &IID_IDocHostUIHandler, (void**)&pDocHostUIHandler);
88 if(SUCCEEDED(hres)) {
89 DOCHOSTUIINFO hostinfo;
90 LPOLESTR key_path = NULL, override_key_path = NULL;
91 IDocHostUIHandler2 *pDocHostUIHandler2;
93 memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO));
94 hostinfo.cbSize = sizeof(DOCHOSTUIINFO);
95 hres = IDocHostUIHandler_GetHostInfo(pDocHostUIHandler, &hostinfo);
96 if(SUCCEEDED(hres))
97 /* FIXME: use hostinfo */
98 TRACE("hostinfo = {%lu %08lx %08lx %s %s}\n",
99 hostinfo.cbSize, hostinfo.dwFlags, hostinfo.dwDoubleClick,
100 debugstr_w(hostinfo.pchHostCss), debugstr_w(hostinfo.pchHostNS));
102 if(!This->has_key_path) {
103 hres = IDocHostUIHandler_GetOptionKeyPath(pDocHostUIHandler, &key_path, 0);
104 if(hres == S_OK && key_path) {
105 if(key_path[0]) {
106 /* FIXME: use key_path */
107 TRACE("key_path = %s\n", debugstr_w(key_path));
109 CoTaskMemFree(key_path);
112 hres = IDocHostUIHandler_QueryInterface(pDocHostUIHandler, &IID_IDocHostUIHandler2,
113 (void**)&pDocHostUIHandler2);
114 if(SUCCEEDED(hres)) {
115 hres = IDocHostUIHandler2_GetOverrideKeyPath(pDocHostUIHandler2, &override_key_path, 0);
116 if(hres == S_OK && override_key_path && override_key_path[0]) {
117 if(override_key_path[0]) {
118 /*FIXME: use override_key_path */
119 TRACE("override_key_path = %s\n", debugstr_w(override_key_path));
121 CoTaskMemFree(override_key_path);
125 This->has_key_path = TRUE;
129 /* Native calls here GetWindow. What is it for?
130 * We don't have anything to do with it here (yet). */
131 if(pClientSite) {
132 IOleWindow *pOleWindow = NULL;
133 HWND hwnd;
135 hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleWindow, (void**)&pOleWindow);
136 if(SUCCEEDED(hres)) {
137 IOleWindow_GetWindow(pOleWindow, &hwnd);
138 IOleWindow_Release(pOleWindow);
142 hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleCommandTarget, (void**)&cmdtrg);
143 if(SUCCEEDED(hres)) {
144 VARIANT var;
145 OLECMD cmd = {OLECMDID_SETPROGRESSTEXT, 0};
147 IOleCommandTarget_QueryStatus(cmdtrg, NULL, 1, &cmd, NULL);
149 V_VT(&var) = VT_I4;
150 V_I4(&var) = 0;
151 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSMAX, 0, &var, NULL);
152 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSPOS, 0, &var, NULL);
154 IOleCommandTarget_Release(cmdtrg);
157 IOleClientSite_AddRef(pClientSite);
158 This->client = pClientSite;
159 This->hostui = pDocHostUIHandler;
161 IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_USERMODE);
162 IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
163 IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_SILENT);
164 IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_USERAGENT);
165 IOleControl_OnAmbientPropertyChange(CONTROL(This), DISPID_AMBIENT_PALETTE);
167 return S_OK;
170 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite)
172 HTMLDocument *This = OLEOBJ_THIS(iface);
174 TRACE("(%p)->(%p)\n", This, ppClientSite);
176 if(!ppClientSite)
177 return E_INVALIDARG;
179 if(This->client)
180 IOleClientSite_AddRef(This->client);
181 *ppClientSite = This->client;
183 return S_OK;
186 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
188 HTMLDocument *This = OLEOBJ_THIS(iface);
189 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
190 return E_NOTIMPL;
193 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
195 HTMLDocument *This = OLEOBJ_THIS(iface);
197 TRACE("(%p)->(%08lx)\n", This, dwSaveOption);
199 if(dwSaveOption == OLECLOSE_PROMPTSAVE)
200 FIXME("OLECLOSE_PROMPTSAVE not implemented\n");
202 if(This->in_place_active)
203 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
205 HTMLDocument_LockContainer(This, FALSE);
207 return S_OK;
210 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk)
212 HTMLDocument *This = OLEOBJ_THIS(iface);
213 FIXME("(%p %ld %p)->()\n", This, dwWhichMoniker, pmk);
214 return E_NOTIMPL;
217 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
219 HTMLDocument *This = OLEOBJ_THIS(iface);
220 FIXME("(%p)->(%ld %ld %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
221 return E_NOTIMPL;
224 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, IDataObject *pDataObject, BOOL fCreation,
225 DWORD dwReserved)
227 HTMLDocument *This = OLEOBJ_THIS(iface);
228 FIXME("(%p)->(%p %x %ld)\n", This, pDataObject, fCreation, dwReserved);
229 return E_NOTIMPL;
232 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject)
234 HTMLDocument *This = OLEOBJ_THIS(iface);
235 FIXME("(%p)->(%ld %p)\n", This, dwReserved, ppDataObject);
236 return E_NOTIMPL;
239 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite,
240 LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
242 HTMLDocument *This = OLEOBJ_THIS(iface);
243 IOleDocumentSite *pDocSite;
244 HRESULT hres;
246 TRACE("(%p)->(%ld %p %p %ld %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect);
248 if(iVerb != OLEIVERB_SHOW && iVerb != OLEIVERB_UIACTIVATE && iVerb != OLEIVERB_INPLACEACTIVATE) {
249 FIXME("iVerb = %ld not supported\n", iVerb);
250 return E_NOTIMPL;
253 if(!pActiveSite)
254 pActiveSite = This->client;
256 hres = IOleClientSite_QueryInterface(pActiveSite, &IID_IOleDocumentSite, (void**)&pDocSite);
257 if(SUCCEEDED(hres)) {
258 HTMLDocument_LockContainer(This, TRUE);
260 /* FIXME: Create new IOleDocumentView. See CreateView for more info. */
261 hres = IOleDocumentSite_ActivateMe(pDocSite, DOCVIEW(This));
262 IOleDocumentSite_Release(pDocSite);
263 }else {
264 hres = IOleDocumentView_UIActivate(DOCVIEW(This), TRUE);
265 if(SUCCEEDED(hres)) {
266 if(lprcPosRect) {
267 RECT rect; /* We need to pass rect as not const pointer */
268 memcpy(&rect, lprcPosRect, sizeof(RECT));
269 IOleDocumentView_SetRect(DOCVIEW(This), &rect);
271 IOleDocumentView_Show(DOCVIEW(This), TRUE);
275 return hres;
278 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
280 HTMLDocument *This = OLEOBJ_THIS(iface);
281 FIXME("(%p)->(%p)\n", This, ppEnumOleVerb);
282 return E_NOTIMPL;
285 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
287 HTMLDocument *This = OLEOBJ_THIS(iface);
288 FIXME("(%p)\n", This);
289 return E_NOTIMPL;
292 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
294 HTMLDocument *This = OLEOBJ_THIS(iface);
295 FIXME("(%p)\n", This);
296 return E_NOTIMPL;
299 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID *pClsid)
301 HTMLDocument *This = OLEOBJ_THIS(iface);
303 TRACE("(%p)->(%p)\n", This, pClsid);
305 if(!pClsid)
306 return E_INVALIDARG;
308 memcpy(pClsid, &CLSID_HTMLDocument, sizeof(GUID));
309 return S_OK;
312 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType)
314 HTMLDocument *This = OLEOBJ_THIS(iface);
315 FIXME("(%p)->(%ld %p)\n", This, dwFormOfType, pszUserType);
316 return E_NOTIMPL;
319 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
321 HTMLDocument *This = OLEOBJ_THIS(iface);
322 FIXME("(%p)->(%ld %p)\n", This, dwDrawAspect, psizel);
323 return E_NOTIMPL;
326 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
328 HTMLDocument *This = OLEOBJ_THIS(iface);
329 FIXME("(%p)->(%ld %p)\n", This, dwDrawAspect, psizel);
330 return E_NOTIMPL;
333 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
335 HTMLDocument *This = OLEOBJ_THIS(iface);
336 FIXME("(%p)->(%p %p)\n", This, pAdvSink, pdwConnection);
337 return E_NOTIMPL;
340 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
342 HTMLDocument *This = OLEOBJ_THIS(iface);
343 FIXME("(%p)->(%ld)\n", This, dwConnection);
344 return E_NOTIMPL;
347 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
349 HTMLDocument *This = OLEOBJ_THIS(iface);
350 FIXME("(%p)->(%p)\n", This, ppenumAdvise);
351 return E_NOTIMPL;
354 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
356 HTMLDocument *This = OLEOBJ_THIS(iface);
357 FIXME("(%p)->(%ld %p)\n", This, dwAspect, pdwStatus);
358 return E_NOTIMPL;
361 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE *pLogpal)
363 HTMLDocument *This = OLEOBJ_THIS(iface);
364 FIXME("(%p)->(%p)\n", This, pLogpal);
365 return E_NOTIMPL;
368 #undef OLEPBJ_THIS
370 static const IOleObjectVtbl OleObjectVtbl = {
371 OleObject_QueryInterface,
372 OleObject_AddRef,
373 OleObject_Release,
374 OleObject_SetClientSite,
375 OleObject_GetClientSite,
376 OleObject_SetHostNames,
377 OleObject_Close,
378 OleObject_SetMoniker,
379 OleObject_GetMoniker,
380 OleObject_InitFromData,
381 OleObject_GetClipboardData,
382 OleObject_DoVerb,
383 OleObject_EnumVerbs,
384 OleObject_Update,
385 OleObject_IsUpToDate,
386 OleObject_GetUserClassID,
387 OleObject_GetUserType,
388 OleObject_SetExtent,
389 OleObject_GetExtent,
390 OleObject_Advise,
391 OleObject_Unadvise,
392 OleObject_EnumAdvise,
393 OleObject_GetMiscStatus,
394 OleObject_SetColorScheme
397 /**********************************************************
398 * IOleDocument implementation
401 #define OLEDOC_THIS(iface) DEFINE_THIS(HTMLDocument, OleDocument, iface)
403 static HRESULT WINAPI OleDocument_QueryInterface(IOleDocument *iface, REFIID riid, void **ppvObject)
405 HTMLDocument *This = OLEDOC_THIS(iface);
406 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppvObject);
409 static ULONG WINAPI OleDocument_AddRef(IOleDocument *iface)
411 HTMLDocument *This = OLEDOC_THIS(iface);
412 return IHTMLDocument2_AddRef(HTMLDOC(This));
415 static ULONG WINAPI OleDocument_Release(IOleDocument *iface)
417 HTMLDocument *This = OLEDOC_THIS(iface);
418 return IHTMLDocument2_Release(HTMLDOC(This));
421 static HRESULT WINAPI OleDocument_CreateView(IOleDocument *iface, IOleInPlaceSite *pIPSite, IStream *pstm,
422 DWORD dwReserved, IOleDocumentView **ppView)
424 HTMLDocument *This = OLEDOC_THIS(iface);
425 HRESULT hres;
427 TRACE("(%p)->(%p %p %ld %p)\n", This, pIPSite, pstm, dwReserved, ppView);
429 if(!ppView)
430 return E_INVALIDARG;
432 /* FIXME:
433 * Windows implementation creates new IOleDocumentView when function is called for the
434 * first time and returns E_FAIL when it is called for the second time, but it doesn't matter
435 * if the application uses returned interfaces, passed to ActivateMe or returned by
436 * QueryInterface, so there is no reason to create new interface. This needs more testing.
439 if(pIPSite) {
440 hres = IOleDocumentView_SetInPlaceSite(DOCVIEW(This), pIPSite);
441 if(FAILED(hres))
442 return hres;
445 if(pstm)
446 FIXME("pstm is not supported\n");
448 IOleDocumentView_AddRef(DOCVIEW(This));
449 *ppView = DOCVIEW(This);
450 return S_OK;
453 static HRESULT WINAPI OleDocument_GetDocMiscStatus(IOleDocument *iface, DWORD *pdwStatus)
455 HTMLDocument *This = OLEDOC_THIS(iface);
456 FIXME("(%p)->(%p)\n", This, pdwStatus);
457 return E_NOTIMPL;
460 static HRESULT WINAPI OleDocument_EnumViews(IOleDocument *iface, IEnumOleDocumentViews **ppEnum,
461 IOleDocumentView **ppView)
463 HTMLDocument *This = OLEDOC_THIS(iface);
464 FIXME("(%p)->(%p %p)\n", This, ppEnum, ppView);
465 return E_NOTIMPL;
468 #undef OLEDOC_THIS
470 static const IOleDocumentVtbl OleDocumentVtbl = {
471 OleDocument_QueryInterface,
472 OleDocument_AddRef,
473 OleDocument_Release,
474 OleDocument_CreateView,
475 OleDocument_GetDocMiscStatus,
476 OleDocument_EnumViews
479 /**********************************************************
480 * IOleCommandTarget implementation
483 #define CMDTARGET_THIS(iface) DEFINE_THIS(HTMLDocument, OleCommandTarget, iface)
485 static HRESULT exec_open(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
487 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
488 return E_NOTIMPL;
491 static HRESULT exec_new(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
493 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
494 return E_NOTIMPL;
497 static HRESULT exec_save(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
499 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
500 return E_NOTIMPL;
503 static HRESULT exec_save_as(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
505 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
506 return E_NOTIMPL;
509 static HRESULT exec_save_copy_as(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
511 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
512 return E_NOTIMPL;
515 static HRESULT exec_print(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
517 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
518 return E_NOTIMPL;
521 static HRESULT exec_print_preview(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
523 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
524 return E_NOTIMPL;
527 static HRESULT exec_page_setup(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
529 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
530 return E_NOTIMPL;
533 static HRESULT exec_spell(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
535 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
536 return E_NOTIMPL;
539 static HRESULT exec_properties(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
541 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
542 return E_NOTIMPL;
545 static HRESULT exec_cut(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
547 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
548 return E_NOTIMPL;
551 static HRESULT exec_copy(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
553 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
554 return E_NOTIMPL;
557 static HRESULT exec_paste(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
559 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
560 return E_NOTIMPL;
563 static HRESULT exec_paste_special(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
565 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
566 return E_NOTIMPL;
569 static HRESULT exec_undo(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
571 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
572 return E_NOTIMPL;
575 static HRESULT exec_rendo(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
577 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
578 return E_NOTIMPL;
581 static HRESULT exec_select_all(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
583 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
584 return E_NOTIMPL;
587 static HRESULT exec_clear_selection(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
589 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
590 return E_NOTIMPL;
593 static HRESULT exec_zoom(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
595 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
596 return E_NOTIMPL;
599 static HRESULT exec_get_zoom_range(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
601 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
602 return E_NOTIMPL;
605 static HRESULT exec_refresh(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
607 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
608 return E_NOTIMPL;
611 static HRESULT exec_stop(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
613 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
614 return E_NOTIMPL;
617 static HRESULT exec_stop_download(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
619 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
620 return E_NOTIMPL;
623 static HRESULT exec_delete(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
625 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
626 return E_NOTIMPL;
629 static HRESULT exec_enable_interaction(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
631 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
632 return E_NOTIMPL;
635 static HRESULT exec_on_unload(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
637 TRACE("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
639 /* Tests show that we have nothing more to do here */
641 if(pvaOut) {
642 V_VT(pvaOut) = VT_BOOL;
643 V_BOOL(pvaOut) = VARIANT_TRUE;
646 return S_OK;
649 static HRESULT exec_show_page_setup(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
651 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
652 return E_NOTIMPL;
655 static HRESULT exec_show_print(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
657 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
658 return E_NOTIMPL;
661 static HRESULT exec_close(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
663 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
664 return E_NOTIMPL;
667 static HRESULT exec_set_print_template(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
669 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
670 return E_NOTIMPL;
673 static HRESULT exec_get_print_template(HTMLDocument *This, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
675 FIXME("(%p)->(%ld %p %p)\n", This, nCmdexecopt, pvaIn, pvaOut);
676 return E_NOTIMPL;
679 static const struct {
680 OLECMDF cmdf;
681 HRESULT (*func)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
682 } exec_table[OLECMDID_GETPRINTTEMPLATE+1] = {
683 {0},
684 { OLECMDF_SUPPORTED, exec_open }, /* OLECMDID_OPEN */
685 { OLECMDF_SUPPORTED, exec_new }, /* OLECMDID_NEW */
686 { OLECMDF_SUPPORTED, exec_save }, /* OLECMDID_SAVE */
687 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_save_as }, /* OLECMDID_SAVEAS */
688 { OLECMDF_SUPPORTED, exec_save_copy_as }, /* OLECMDID_SAVECOPYAS */
689 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_print }, /* OLECMDID_PRINT */
690 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_print_preview }, /* OLECMDID_PRINTPREVIEW */
691 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_page_setup }, /* OLECMDID_PAGESETUP */
692 { OLECMDF_SUPPORTED, exec_spell }, /* OLECMDID_SPELL */
693 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_properties }, /* OLECMDID_PROPERTIES */
694 { OLECMDF_SUPPORTED, exec_cut }, /* OLECMDID_CUT */
695 { OLECMDF_SUPPORTED, exec_copy }, /* OLECMDID_COPY */
696 { OLECMDF_SUPPORTED, exec_paste }, /* OLECMDID_PASTE */
697 { OLECMDF_SUPPORTED, exec_paste_special }, /* OLECMDID_PASTESPECIAL */
698 { OLECMDF_SUPPORTED, exec_undo }, /* OLECMDID_UNDO */
699 { OLECMDF_SUPPORTED, exec_rendo }, /* OLECMDID_REDO */
700 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_select_all }, /* OLECMDID_SELECTALL */
701 { OLECMDF_SUPPORTED, exec_clear_selection }, /* OLECMDID_CLEARSELECTION */
702 { OLECMDF_SUPPORTED, exec_zoom }, /* OLECMDID_ZOOM */
703 { OLECMDF_SUPPORTED, exec_get_zoom_range }, /* OLECMDID_GETZOOMRANGE */
704 {0},
705 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_refresh }, /* OLECMDID_REFRESH */
706 { OLECMDF_SUPPORTED|OLECMDF_ENABLED, exec_stop }, /* OLECMDID_STOP */
707 {0},{0},{0},{0},{0},{0},
708 { OLECMDF_SUPPORTED, exec_stop_download }, /* OLECMDID_STOPDOWNLOAD */
709 {0},{0},
710 { OLECMDF_SUPPORTED, exec_delete }, /* OLECMDID_DELETE */
711 {0},{0},
712 { OLECMDF_SUPPORTED, exec_enable_interaction }, /* OLECMDID_ENABLE_INTERACTION */
713 { OLECMDF_SUPPORTED, exec_on_unload }, /* OLECMDID_ONUNLOAD */
714 {0},{0},{0},{0},{0},
715 { OLECMDF_SUPPORTED, exec_show_page_setup }, /* OLECMDID_SHOWPAGESETUP */
716 { OLECMDF_SUPPORTED, exec_show_print }, /* OLECMDID_SHOWPRINT */
717 {0},{0},
718 { OLECMDF_SUPPORTED, exec_close }, /* OLECMDID_CLOSE */
719 {0},{0},{0},
720 { OLECMDF_SUPPORTED, exec_set_print_template }, /* OLECMDID_SETPRINTTEMPLATE */
721 { OLECMDF_SUPPORTED, exec_get_print_template } /* OLECMDID_GETPRINTTEMPLATE */
724 static HRESULT WINAPI OleCommandTarget_QueryInterface(IOleCommandTarget *iface, REFIID riid, void **ppv)
726 HTMLDocument *This = CMDTARGET_THIS(iface);
727 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
730 static ULONG WINAPI OleCommandTarget_AddRef(IOleCommandTarget *iface)
732 HTMLDocument *This = CMDTARGET_THIS(iface);
733 return IHTMLDocument2_AddRef(HTMLDOC(This));
736 static ULONG WINAPI OleCommandTarget_Release(IOleCommandTarget *iface)
738 HTMLDocument *This = CMDTARGET_THIS(iface);
739 return IHTMLDocument_Release(HTMLDOC(This));
742 static HRESULT WINAPI OleCommandTarget_QueryStatus(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
743 ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT *pCmdText)
745 HTMLDocument *This = CMDTARGET_THIS(iface);
746 HRESULT hres = S_OK, hr;
748 TRACE("(%p)->(%s %ld %p %p)\n", This, debugstr_guid(pguidCmdGroup), cCmds, prgCmds, pCmdText);
750 if(!pguidCmdGroup) {
751 ULONG i;
753 for(i=0; i<cCmds; i++) {
754 if(prgCmds[i].cmdID<OLECMDID_OPEN || prgCmds[i].cmdID>OLECMDID_GETPRINTTEMPLATE) {
755 WARN("Unsupported cmdID = %ld\n", prgCmds[i].cmdID);
756 prgCmds[i].cmdf = 0;
757 hres = OLECMDERR_E_NOTSUPPORTED;
758 }else {
759 if(prgCmds[i].cmdID == OLECMDID_OPEN || prgCmds[i].cmdID == OLECMDID_NEW) {
760 IOleCommandTarget *cmdtrg = NULL;
761 OLECMD olecmd;
763 prgCmds[i].cmdf = OLECMDF_SUPPORTED;
764 if(This->client) {
765 hr = IOleClientSite_QueryInterface(This->client, &IID_IOleCommandTarget,
766 (void**)&cmdtrg);
767 if(SUCCEEDED(hr)) {
768 olecmd.cmdID = prgCmds[i].cmdID;
769 olecmd.cmdf = 0;
771 hr = IOleCommandTarget_QueryStatus(cmdtrg, NULL, 1, &olecmd, NULL);
772 if(SUCCEEDED(hr) && olecmd.cmdf)
773 prgCmds[i].cmdf = olecmd.cmdf;
775 }else {
776 ERR("This->client == NULL, native would crash\n");
778 }else {
779 prgCmds[i].cmdf = exec_table[prgCmds[i].cmdID].cmdf;
780 TRACE("cmdID = %ld returning %lx\n", prgCmds[i].cmdID, prgCmds[i].cmdf);
782 hres = S_OK;
786 if(pCmdText)
787 FIXME("Set pCmdText\n");
788 }else {
789 FIXME("Unsupported pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
790 hres = OLECMDERR_E_UNKNOWNGROUP;
793 return hres;
796 static HRESULT WINAPI OleCommandTarget_Exec(IOleCommandTarget *iface, const GUID *pguidCmdGroup,
797 DWORD nCmdID, DWORD nCmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
799 HTMLDocument *This = CMDTARGET_THIS(iface);
801 if(!pguidCmdGroup) {
802 if(nCmdID<OLECMDID_OPEN || nCmdID>OLECMDID_GETPRINTTEMPLATE || !exec_table[nCmdID].func) {
803 WARN("Unsupported cmdID = %ld\n", nCmdID);
804 return OLECMDERR_E_NOTSUPPORTED;
807 return exec_table[nCmdID].func(This, nCmdexecopt, pvaIn, pvaOut);
808 }else if(IsEqualGUID(&CGID_Explorer, pguidCmdGroup)) {
809 FIXME("unsupported nCmdID %ld of CGID_Explorer group\n", nCmdID);
810 TRACE("%p %p\n", pvaIn, pvaOut);
811 return OLECMDERR_E_NOTSUPPORTED;
812 }else if(IsEqualGUID(&CGID_ShellDocView, pguidCmdGroup)) {
813 FIXME("unsupported nCmdID %ld of CGID_ShellDocView group\n", nCmdID);
814 return OLECMDERR_E_NOTSUPPORTED;
817 FIXME("Unsupported pguidCmdGroup %s\n", debugstr_guid(pguidCmdGroup));
818 return OLECMDERR_E_UNKNOWNGROUP;
821 #undef CMDTARGET_THIS
823 static const IOleCommandTargetVtbl OleCommandTargetVtbl = {
824 OleCommandTarget_QueryInterface,
825 OleCommandTarget_AddRef,
826 OleCommandTarget_Release,
827 OleCommandTarget_QueryStatus,
828 OleCommandTarget_Exec
831 /**********************************************************
832 * IOleControl implementation
835 #define CONTROL_THIS(iface) DEFINE_THIS(HTMLDocument, OleControl, iface)
837 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface, REFIID riid, void **ppv)
839 HTMLDocument *This = CONTROL_THIS(iface);
840 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
843 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
845 HTMLDocument *This = CONTROL_THIS(iface);
846 return IHTMLDocument2_AddRef(HTMLDOC(This));
849 static ULONG WINAPI OleControl_Release(IOleControl *iface)
851 HTMLDocument *This = CONTROL_THIS(iface);
852 return IHTMLDocument_Release(HTMLDOC(This));
855 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, CONTROLINFO *pCI)
857 HTMLDocument *This = CONTROL_THIS(iface);
858 FIXME("(%p)->(%p)\n", This, pCI);
859 return E_NOTIMPL;
862 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, MSG *pMsg)
864 HTMLDocument *This = CONTROL_THIS(iface);
865 FIXME("(%p)->(%p)\n", This, pMsg);
866 return E_NOTIMPL;
869 static HRESULT get_property(IOleClientSite *client, DISPID dispid, VARIANT *res)
871 IDispatch *disp = NULL;
872 DISPPARAMS dispparams = {NULL, 0};
873 UINT err;
874 HRESULT hres;
876 hres = IOleClientSite_QueryInterface(client, &IID_IDispatch, (void**)&disp);
877 if(FAILED(hres)) {
878 TRACE("Could not get IDispatch\n");
879 return hres;
882 VariantInit(res);
884 hres = IDispatch_Invoke(disp, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
885 DISPATCH_PROPERTYGET, &dispparams, res, NULL, &err);
887 IDispatch_Release(disp);
889 return hres;
892 static HRESULT on_change_dlcontrol(HTMLDocument *This)
894 VARIANT res;
895 HRESULT hres;
897 hres = get_property(This->client, DISPID_AMBIENT_DLCONTROL, &res);
898 if(SUCCEEDED(hres))
899 FIXME("unsupported dlcontrol %08lx\n", V_I4(&res));
901 return S_OK;
904 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
906 HTMLDocument *This = CONTROL_THIS(iface);
907 VARIANT res;
908 HRESULT hres;
910 if(!This->client) {
911 TRACE("This->client = NULL\n");
912 return S_OK;
915 switch(dispID) {
916 case DISPID_AMBIENT_USERMODE:
917 TRACE("(%p)->(DISPID_AMBIENT_USERMODE)\n", This);
918 hres = get_property(This->client, DISPID_AMBIENT_USERMODE, &res);
919 if(FAILED(hres))
920 return S_OK;
922 if(V_VT(&res) == VT_BOOL) {
923 if(!V_BOOL(&res)) {
924 FIXME("edit mode is not supported\n");
925 hres = E_FAIL;
927 }else {
928 FIXME("V_VT(res)=%d\n", V_VT(&res));
930 return S_OK;
931 case DISPID_AMBIENT_DLCONTROL:
932 TRACE("(%p)->(DISPID_AMBIENT_DLCONTROL)\n", This);
933 return on_change_dlcontrol(This);
934 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
935 TRACE("(%p)->(DISPID_AMBIENT_OFFLINEIFNOTCONNECTED)\n", This);
936 on_change_dlcontrol(This);
937 hres = get_property(This->client, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &res);
938 if(FAILED(hres))
939 return S_OK;
941 if(V_VT(&res) == VT_BOOL) {
942 if(V_BOOL(&res)) {
943 FIXME("offline connection is not supported\n");
944 hres = E_FAIL;
946 }else {
947 FIXME("V_VT(res)=%d\n", V_VT(&res));
949 return S_OK;
950 case DISPID_AMBIENT_SILENT:
951 TRACE("(%p)->(DISPID_AMBIENT_SILENT)\n", This);
952 on_change_dlcontrol(This);
953 hres = get_property(This->client, DISPID_AMBIENT_SILENT, &res);
954 if(FAILED(hres))
955 return S_OK;
957 if(V_VT(&res) == VT_BOOL) {
958 if(V_BOOL(&res)) {
959 FIXME("silent mode is not supported\n");
960 hres = E_FAIL;
962 }else {
963 FIXME("V_VT(res)=%d\n", V_VT(&res));
965 return S_OK;
966 case DISPID_AMBIENT_USERAGENT:
967 TRACE("(%p)->(DISPID_AMBIENT_USERAGENT)\n", This);
968 hres = get_property(This->client, DISPID_AMBIENT_USERAGENT, &res);
969 if(FAILED(hres))
970 return S_OK;
972 FIXME("not supported AMBIENT_USERAGENT\n");
973 hres = E_FAIL;
974 return S_OK;
975 case DISPID_AMBIENT_PALETTE:
976 TRACE("(%p)->(DISPID_AMBIENT_PALETTE)\n", This);
977 hres = get_property(This->client, DISPID_AMBIENT_PALETTE, &res);
978 if(FAILED(hres))
979 return S_OK;
981 FIXME("not supported AMBIENT_PALETTE\n");
982 hres = E_FAIL;
983 return S_OK;
986 FIXME("(%p) unsupported dispID=%ld\n", This, dispID);
987 return E_FAIL;
990 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
992 HTMLDocument *This = CONTROL_THIS(iface);
993 FIXME("(%p)->(%x)\n", This, bFreeze);
994 return E_NOTIMPL;
997 #undef CONTROL_THIS
999 static const IOleControlVtbl OleControlVtbl = {
1000 OleControl_QueryInterface,
1001 OleControl_AddRef,
1002 OleControl_Release,
1003 OleControl_GetControlInfo,
1004 OleControl_OnMnemonic,
1005 OleControl_OnAmbientPropertyChange,
1006 OleControl_FreezeEvents
1009 void HTMLDocument_LockContainer(HTMLDocument *This, BOOL fLock)
1011 IOleContainer *container;
1012 HRESULT hres;
1014 if(!This->client || This->container_locked == fLock)
1015 return;
1017 hres = IOleClientSite_GetContainer(This->client, &container);
1018 if(SUCCEEDED(hres)) {
1019 IOleContainer_LockContainer(container, fLock);
1020 This->container_locked = fLock;
1021 IOleContainer_Release(container);
1025 void HTMLDocument_OleObj_Init(HTMLDocument *This)
1027 This->lpOleObjectVtbl = &OleObjectVtbl;
1028 This->lpOleDocumentVtbl = &OleDocumentVtbl;
1029 This->lpOleCommandTargetVtbl = &OleCommandTargetVtbl;
1030 This->lpOleControlVtbl = &OleControlVtbl;
1032 This->client = NULL;
1033 This->hostui = NULL;
1035 This->has_key_path = FALSE;
1036 This->container_locked = FALSE;