Revert tree-restructure attempt: r66583, r66582, r66581, r66578, sauf ntdll changes...
[reactos.git] / reactos / dll / win32 / mshtml / oleobj.c
1 /*
2 * Copyright 2005 Jacek Caban
3 *
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.
8 *
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.
13 *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #include "mshtml_private.h"
20
21 #define DOCHOST_DOCCANNAVIGATE 0
22
23 typedef struct {
24 IEnumUnknown IEnumUnknown_iface;
25 LONG ref;
26 } EnumUnknown;
27
28 static inline EnumUnknown *impl_from_IEnumUnknown(IEnumUnknown *iface)
29 {
30 return CONTAINING_RECORD(iface, EnumUnknown, IEnumUnknown_iface);
31 }
32
33 static HRESULT WINAPI EnumUnknown_QueryInterface(IEnumUnknown *iface, REFIID riid, void **ppv)
34 {
35 EnumUnknown *This = impl_from_IEnumUnknown(iface);
36
37 if(IsEqualGUID(&IID_IUnknown, riid)) {
38 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
39 *ppv = &This->IEnumUnknown_iface;
40 }else if(IsEqualGUID(&IID_IEnumUnknown, riid)) {
41 TRACE("(%p)->(IID_IEnumUnknown %p)\n", This, ppv);
42 *ppv = &This->IEnumUnknown_iface;
43 }else {
44 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
45 *ppv = NULL;
46 return E_NOINTERFACE;
47 }
48
49 IUnknown_AddRef((IUnknown*)*ppv);
50 return S_OK;
51 }
52
53 static ULONG WINAPI EnumUnknown_AddRef(IEnumUnknown *iface)
54 {
55 EnumUnknown *This = impl_from_IEnumUnknown(iface);
56 LONG ref = InterlockedIncrement(&This->ref);
57
58 TRACE("(%p) ref=%d\n", This, ref);
59
60 return ref;
61 }
62
63 static ULONG WINAPI EnumUnknown_Release(IEnumUnknown *iface)
64 {
65 EnumUnknown *This = impl_from_IEnumUnknown(iface);
66 LONG ref = InterlockedDecrement(&This->ref);
67
68 TRACE("(%p) ref=%d\n", This, ref);
69
70 if(!ref)
71 heap_free(This);
72
73 return ref;
74 }
75
76 static HRESULT WINAPI EnumUnknown_Next(IEnumUnknown *iface, ULONG celt, IUnknown **rgelt, ULONG *pceltFetched)
77 {
78 EnumUnknown *This = impl_from_IEnumUnknown(iface);
79
80 TRACE("(%p)->(%u %p %p)\n", This, celt, rgelt, pceltFetched);
81
82 /* FIXME: It's not clear if we should ever return something here */
83 if(pceltFetched)
84 *pceltFetched = 0;
85 return S_FALSE;
86 }
87
88 static HRESULT WINAPI EnumUnknown_Skip(IEnumUnknown *iface, ULONG celt)
89 {
90 EnumUnknown *This = impl_from_IEnumUnknown(iface);
91 FIXME("(%p)->(%u)\n", This, celt);
92 return E_NOTIMPL;
93 }
94
95 static HRESULT WINAPI EnumUnknown_Reset(IEnumUnknown *iface)
96 {
97 EnumUnknown *This = impl_from_IEnumUnknown(iface);
98 FIXME("(%p)\n", This);
99 return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI EnumUnknown_Clone(IEnumUnknown *iface, IEnumUnknown **ppenum)
103 {
104 EnumUnknown *This = impl_from_IEnumUnknown(iface);
105 FIXME("(%p)->(%p)\n", This, ppenum);
106 return E_NOTIMPL;
107 }
108
109 static const IEnumUnknownVtbl EnumUnknownVtbl = {
110 EnumUnknown_QueryInterface,
111 EnumUnknown_AddRef,
112 EnumUnknown_Release,
113 EnumUnknown_Next,
114 EnumUnknown_Skip,
115 EnumUnknown_Reset,
116 EnumUnknown_Clone
117 };
118
119 /**********************************************************
120 * IOleObject implementation
121 */
122
123 static inline HTMLDocument *impl_from_IOleObject(IOleObject *iface)
124 {
125 return CONTAINING_RECORD(iface, HTMLDocument, IOleObject_iface);
126 }
127
128 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **ppv)
129 {
130 HTMLDocument *This = impl_from_IOleObject(iface);
131 return htmldoc_query_interface(This, riid, ppv);
132 }
133
134 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
135 {
136 HTMLDocument *This = impl_from_IOleObject(iface);
137 return htmldoc_addref(This);
138 }
139
140 static ULONG WINAPI OleObject_Release(IOleObject *iface)
141 {
142 HTMLDocument *This = impl_from_IOleObject(iface);
143 return htmldoc_release(This);
144 }
145
146 static void update_hostinfo(HTMLDocumentObj *This, DOCHOSTUIINFO *hostinfo)
147 {
148 nsIScrollable *scrollable;
149 nsresult nsres;
150
151 if(!This->nscontainer)
152 return;
153
154 nsres = nsIWebBrowser_QueryInterface(This->nscontainer->webbrowser, &IID_nsIScrollable, (void**)&scrollable);
155 if(NS_SUCCEEDED(nsres)) {
156 nsres = nsIScrollable_SetDefaultScrollbarPreferences(scrollable, ScrollOrientation_Y,
157 (hostinfo->dwFlags & DOCHOSTUIFLAG_SCROLL_NO) ? Scrollbar_Never : Scrollbar_Always);
158 if(NS_FAILED(nsres))
159 ERR("Could not set default Y scrollbar prefs: %08x\n", nsres);
160
161 nsres = nsIScrollable_SetDefaultScrollbarPreferences(scrollable, ScrollOrientation_X,
162 hostinfo->dwFlags & DOCHOSTUIFLAG_SCROLL_NO ? Scrollbar_Never : Scrollbar_Auto);
163 if(NS_FAILED(nsres))
164 ERR("Could not set default X scrollbar prefs: %08x\n", nsres);
165
166 nsIScrollable_Release(scrollable);
167 }else {
168 ERR("Could not get nsIScrollable: %08x\n", nsres);
169 }
170 }
171
172 /* Calls undocumented 84 cmd of CGID_ShellDocView */
173 void call_docview_84(HTMLDocumentObj *doc)
174 {
175 IOleCommandTarget *olecmd;
176 VARIANT var;
177 HRESULT hres;
178
179 if(!doc->client)
180 return;
181
182 hres = IOleClientSite_QueryInterface(doc->client, &IID_IOleCommandTarget, (void**)&olecmd);
183 if(FAILED(hres))
184 return;
185
186 VariantInit(&var);
187 hres = IOleCommandTarget_Exec(olecmd, &CGID_ShellDocView, 84, 0, NULL, &var);
188 IOleCommandTarget_Release(olecmd);
189 if(SUCCEEDED(hres) && V_VT(&var) != VT_NULL)
190 FIXME("handle result\n");
191 }
192
193 void set_document_navigation(HTMLDocumentObj *doc, BOOL doc_can_navigate)
194 {
195 VARIANT var;
196
197 if(!doc->client_cmdtrg)
198 return;
199
200 if(doc_can_navigate) {
201 V_VT(&var) = VT_UNKNOWN;
202 V_UNKNOWN(&var) = (IUnknown*)&doc->basedoc.window->base.IHTMLWindow2_iface;
203 }
204
205 IOleCommandTarget_Exec(doc->client_cmdtrg, &CGID_DocHostCmdPriv, DOCHOST_DOCCANNAVIGATE, 0,
206 doc_can_navigate ? &var : NULL, NULL);
207 }
208
209 static void load_settings(HTMLDocumentObj *doc)
210 {
211 nsIMarkupDocumentViewer *markup_document_viewer;
212 nsIContentViewer *content_viewer;
213 nsIDocShell *doc_shell;
214 HKEY settings_key;
215 DWORD val, size;
216 LONG res;
217 nsresult nsres;
218
219 static const WCHAR ie_keyW[] = {
220 'S','O','F','T','W','A','R','E','\\',
221 'M','i','c','r','o','s','o','f','t','\\',
222 'I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r',0};
223 static const WCHAR zoomW[] = {'Z','o','o','m',0};
224 static const WCHAR zoom_factorW[] = {'Z','o','o','m','F','a','c','t','o','r',0};
225
226 res = RegOpenKeyW(HKEY_CURRENT_USER, ie_keyW, &settings_key);
227 if(res != ERROR_SUCCESS)
228 return;
229
230 size = sizeof(val);
231 res = RegGetValueW(settings_key, zoomW, zoom_factorW, RRF_RT_REG_DWORD, NULL, &val, &size);
232 RegCloseKey(settings_key);
233 if(res != ERROR_SUCCESS)
234 return;
235
236 TRACE("Setting ZoomFactor to %u\n", val);
237
238 nsres = get_nsinterface((nsISupports*)doc->nscontainer->navigation, &IID_nsIDocShell, (void**)&doc_shell);
239 assert(nsres == NS_OK);
240
241 nsres = nsIDocShell_GetContentViewer(doc_shell, &content_viewer);
242 assert(nsres == NS_OK && content_viewer);
243
244 nsres = nsISupports_QueryInterface(content_viewer, &IID_nsIMarkupDocumentViewer, (void**)&markup_document_viewer);
245 nsISupports_Release(content_viewer);
246 assert(nsres == NS_OK);
247
248 nsres = nsIMarkupDocumentViewer_SetFullZoom(markup_document_viewer, (float)val/100000);
249 if(NS_FAILED(nsres))
250 ERR("SetFullZoom failed: %08x\n", nsres);
251
252 nsIDocShell_Release(doc_shell);
253 }
254
255 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *pClientSite)
256 {
257 HTMLDocument *This = impl_from_IOleObject(iface);
258 IOleCommandTarget *cmdtrg = NULL;
259 IOleWindow *ole_window;
260 IBrowserService *browser_service;
261 BOOL hostui_setup;
262 VARIANT silent;
263 HWND hwnd;
264 HRESULT hres;
265
266 TRACE("(%p)->(%p)\n", This, pClientSite);
267
268 if(pClientSite == This->doc_obj->client)
269 return S_OK;
270
271 if(This->doc_obj->client) {
272 IOleClientSite_Release(This->doc_obj->client);
273 This->doc_obj->client = NULL;
274 This->doc_obj->usermode = UNKNOWN_USERMODE;
275 }
276
277 if(This->doc_obj->client_cmdtrg) {
278 IOleCommandTarget_Release(This->doc_obj->client_cmdtrg);
279 This->doc_obj->client_cmdtrg = NULL;
280 }
281
282 if(This->doc_obj->hostui && !This->doc_obj->custom_hostui) {
283 IDocHostUIHandler_Release(This->doc_obj->hostui);
284 This->doc_obj->hostui = NULL;
285 }
286
287 if(This->doc_obj->doc_object_service) {
288 IDocObjectService_Release(This->doc_obj->doc_object_service);
289 This->doc_obj->doc_object_service = NULL;
290 }
291
292 if(This->doc_obj->webbrowser) {
293 IUnknown_Release(This->doc_obj->webbrowser);
294 This->doc_obj->webbrowser = NULL;
295 }
296
297 if(This->doc_obj->browser_service) {
298 IUnknown_Release(This->doc_obj->browser_service);
299 This->doc_obj->browser_service = NULL;
300 }
301
302 if(This->doc_obj->travel_log) {
303 ITravelLog_Release(This->doc_obj->travel_log);
304 This->doc_obj->travel_log = NULL;
305 }
306
307 memset(&This->doc_obj->hostinfo, 0, sizeof(DOCHOSTUIINFO));
308
309 if(!pClientSite)
310 return S_OK;
311
312 IOleClientSite_AddRef(pClientSite);
313 This->doc_obj->client = pClientSite;
314
315 hostui_setup = This->doc_obj->hostui_setup;
316
317 if(!This->doc_obj->hostui) {
318 IDocHostUIHandler *uihandler;
319
320 This->doc_obj->custom_hostui = FALSE;
321
322 hres = IOleClientSite_QueryInterface(pClientSite, &IID_IDocHostUIHandler, (void**)&uihandler);
323 if(SUCCEEDED(hres))
324 This->doc_obj->hostui = uihandler;
325 }
326
327 if(This->doc_obj->hostui) {
328 DOCHOSTUIINFO hostinfo;
329 LPOLESTR key_path = NULL, override_key_path = NULL;
330 IDocHostUIHandler2 *uihandler2;
331
332 memset(&hostinfo, 0, sizeof(DOCHOSTUIINFO));
333 hostinfo.cbSize = sizeof(DOCHOSTUIINFO);
334 hres = IDocHostUIHandler_GetHostInfo(This->doc_obj->hostui, &hostinfo);
335 if(SUCCEEDED(hres)) {
336 TRACE("hostinfo = {%u %08x %08x %s %s}\n",
337 hostinfo.cbSize, hostinfo.dwFlags, hostinfo.dwDoubleClick,
338 debugstr_w(hostinfo.pchHostCss), debugstr_w(hostinfo.pchHostNS));
339 update_hostinfo(This->doc_obj, &hostinfo);
340 This->doc_obj->hostinfo = hostinfo;
341 }
342
343 if(!hostui_setup) {
344 hres = IDocHostUIHandler_GetOptionKeyPath(This->doc_obj->hostui, &key_path, 0);
345 if(hres == S_OK && key_path) {
346 if(key_path[0]) {
347 /* FIXME: use key_path */
348 FIXME("key_path = %s\n", debugstr_w(key_path));
349 }
350 CoTaskMemFree(key_path);
351 }
352
353 hres = IDocHostUIHandler_QueryInterface(This->doc_obj->hostui, &IID_IDocHostUIHandler2,
354 (void**)&uihandler2);
355 if(SUCCEEDED(hres)) {
356 hres = IDocHostUIHandler2_GetOverrideKeyPath(uihandler2, &override_key_path, 0);
357 if(hres == S_OK && override_key_path) {
358 if(override_key_path[0]) {
359 /*FIXME: use override_key_path */
360 FIXME("override_key_path = %s\n", debugstr_w(override_key_path));
361 }
362 CoTaskMemFree(override_key_path);
363 }
364 IDocHostUIHandler2_Release(uihandler2);
365 }
366
367 This->doc_obj->hostui_setup = TRUE;
368 }
369 }
370
371 load_settings(This->doc_obj);
372
373 /* Native calls here GetWindow. What is it for?
374 * We don't have anything to do with it here (yet). */
375 hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleWindow, (void**)&ole_window);
376 if(SUCCEEDED(hres)) {
377 IOleWindow_GetWindow(ole_window, &hwnd);
378 IOleWindow_Release(ole_window);
379 }
380
381 hres = do_query_service((IUnknown*)pClientSite, &IID_IShellBrowser,
382 &IID_IBrowserService, (void**)&browser_service);
383 if(SUCCEEDED(hres)) {
384 ITravelLog *travel_log;
385
386 This->doc_obj->browser_service = (IUnknown*)browser_service;
387
388 hres = IBrowserService_GetTravelLog(browser_service, &travel_log);
389 if(SUCCEEDED(hres))
390 This->doc_obj->travel_log = travel_log;
391 }else {
392 browser_service = NULL;
393 }
394
395 hres = IOleClientSite_QueryInterface(pClientSite, &IID_IOleCommandTarget, (void**)&cmdtrg);
396 if(SUCCEEDED(hres)) {
397 VARIANT var;
398 OLECMD cmd = {OLECMDID_SETPROGRESSTEXT, 0};
399
400 This->doc_obj->client_cmdtrg = cmdtrg;
401
402 if(!hostui_setup) {
403 IDocObjectService *doc_object_service;
404 IWebBrowser2 *wb;
405
406 set_document_navigation(This->doc_obj, TRUE);
407
408 if(browser_service) {
409 hres = IBrowserService_QueryInterface(browser_service,
410 &IID_IDocObjectService, (void**)&doc_object_service);
411 if(SUCCEEDED(hres)) {
412 This->doc_obj->doc_object_service = doc_object_service;
413
414 /*
415 * Some embedding routines, esp. in regards to use of IDocObjectService, differ if
416 * embedder supports IWebBrowserApp.
417 */
418 hres = do_query_service((IUnknown*)pClientSite, &IID_IWebBrowserApp, &IID_IWebBrowser2, (void**)&wb);
419 if(SUCCEEDED(hres))
420 This->doc_obj->webbrowser = (IUnknown*)wb;
421 }
422 }
423 }
424
425 call_docview_84(This->doc_obj);
426
427 IOleCommandTarget_QueryStatus(cmdtrg, NULL, 1, &cmd, NULL);
428
429 V_VT(&var) = VT_I4;
430 V_I4(&var) = 0;
431 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSMAX,
432 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
433 IOleCommandTarget_Exec(cmdtrg, NULL, OLECMDID_SETPROGRESSPOS,
434 OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
435 }
436
437 if(This->doc_obj->usermode == UNKNOWN_USERMODE)
438 IOleControl_OnAmbientPropertyChange(&This->IOleControl_iface, DISPID_AMBIENT_USERMODE);
439
440 IOleControl_OnAmbientPropertyChange(&This->IOleControl_iface,
441 DISPID_AMBIENT_OFFLINEIFNOTCONNECTED);
442
443 hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_SILENT, &silent);
444 if(SUCCEEDED(hres)) {
445 if(V_VT(&silent) != VT_BOOL)
446 WARN("silent = %s\n", debugstr_variant(&silent));
447 else if(V_BOOL(&silent))
448 FIXME("silent == true\n");
449 }
450
451 IOleControl_OnAmbientPropertyChange(&This->IOleControl_iface, DISPID_AMBIENT_USERAGENT);
452 IOleControl_OnAmbientPropertyChange(&This->IOleControl_iface, DISPID_AMBIENT_PALETTE);
453
454 return S_OK;
455 }
456
457 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **ppClientSite)
458 {
459 HTMLDocument *This = impl_from_IOleObject(iface);
460
461 TRACE("(%p)->(%p)\n", This, ppClientSite);
462
463 if(!ppClientSite)
464 return E_INVALIDARG;
465
466 if(This->doc_obj->client)
467 IOleClientSite_AddRef(This->doc_obj->client);
468 *ppClientSite = This->doc_obj->client;
469
470 return S_OK;
471 }
472
473 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)
474 {
475 HTMLDocument *This = impl_from_IOleObject(iface);
476 FIXME("(%p)->(%s %s)\n", This, debugstr_w(szContainerApp), debugstr_w(szContainerObj));
477 return E_NOTIMPL;
478 }
479
480 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption)
481 {
482 HTMLDocument *This = impl_from_IOleObject(iface);
483
484 TRACE("(%p)->(%08x)\n", This, dwSaveOption);
485
486 if(dwSaveOption == OLECLOSE_PROMPTSAVE)
487 FIXME("OLECLOSE_PROMPTSAVE not implemented\n");
488
489 if(This->doc_obj->in_place_active)
490 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This->IOleInPlaceObjectWindowless_iface);
491
492 HTMLDocument_LockContainer(This->doc_obj, FALSE);
493
494 if(This->advise_holder)
495 IOleAdviseHolder_SendOnClose(This->advise_holder);
496
497 return S_OK;
498 }
499
500 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD dwWhichMoniker, IMoniker *pmk)
501 {
502 HTMLDocument *This = impl_from_IOleObject(iface);
503 FIXME("(%p %d %p)->()\n", This, dwWhichMoniker, pmk);
504 return E_NOTIMPL;
505 }
506
507 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk)
508 {
509 HTMLDocument *This = impl_from_IOleObject(iface);
510 FIXME("(%p)->(%d %d %p)\n", This, dwAssign, dwWhichMoniker, ppmk);
511 return E_NOTIMPL;
512 }
513
514 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, IDataObject *pDataObject, BOOL fCreation,
515 DWORD dwReserved)
516 {
517 HTMLDocument *This = impl_from_IOleObject(iface);
518 FIXME("(%p)->(%p %x %d)\n", This, pDataObject, fCreation, dwReserved);
519 return E_NOTIMPL;
520 }
521
522 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD dwReserved, IDataObject **ppDataObject)
523 {
524 HTMLDocument *This = impl_from_IOleObject(iface);
525 FIXME("(%p)->(%d %p)\n", This, dwReserved, ppDataObject);
526 return E_NOTIMPL;
527 }
528
529 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite,
530 LONG lindex, HWND hwndParent, LPCRECT lprcPosRect)
531 {
532 HTMLDocument *This = impl_from_IOleObject(iface);
533 IOleDocumentSite *pDocSite;
534 HRESULT hres;
535
536 TRACE("(%p)->(%d %p %p %d %p %p)\n", This, iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect);
537
538 if(iVerb != OLEIVERB_SHOW && iVerb != OLEIVERB_UIACTIVATE && iVerb != OLEIVERB_INPLACEACTIVATE) {
539 FIXME("iVerb = %d not supported\n", iVerb);
540 return E_NOTIMPL;
541 }
542
543 if(!pActiveSite)
544 pActiveSite = This->doc_obj->client;
545
546 hres = IOleClientSite_QueryInterface(pActiveSite, &IID_IOleDocumentSite, (void**)&pDocSite);
547 if(SUCCEEDED(hres)) {
548 HTMLDocument_LockContainer(This->doc_obj, TRUE);
549
550 /* FIXME: Create new IOleDocumentView. See CreateView for more info. */
551 hres = IOleDocumentSite_ActivateMe(pDocSite, &This->IOleDocumentView_iface);
552 IOleDocumentSite_Release(pDocSite);
553 }else {
554 hres = IOleDocumentView_UIActivate(&This->IOleDocumentView_iface, TRUE);
555 if(SUCCEEDED(hres)) {
556 if(lprcPosRect) {
557 RECT rect; /* We need to pass rect as not const pointer */
558 rect = *lprcPosRect;
559 IOleDocumentView_SetRect(&This->IOleDocumentView_iface, &rect);
560 }
561 IOleDocumentView_Show(&This->IOleDocumentView_iface, TRUE);
562 }
563 }
564
565 return hres;
566 }
567
568 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **ppEnumOleVerb)
569 {
570 HTMLDocument *This = impl_from_IOleObject(iface);
571 FIXME("(%p)->(%p)\n", This, ppEnumOleVerb);
572 return E_NOTIMPL;
573 }
574
575 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
576 {
577 HTMLDocument *This = impl_from_IOleObject(iface);
578 FIXME("(%p)\n", This);
579 return E_NOTIMPL;
580 }
581
582 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
583 {
584 HTMLDocument *This = impl_from_IOleObject(iface);
585 FIXME("(%p)\n", This);
586 return E_NOTIMPL;
587 }
588
589 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID *pClsid)
590 {
591 HTMLDocument *This = impl_from_IOleObject(iface);
592
593 TRACE("(%p)->(%p)\n", This, pClsid);
594
595 if(!pClsid)
596 return E_INVALIDARG;
597
598 *pClsid = CLSID_HTMLDocument;
599 return S_OK;
600 }
601
602 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD dwFormOfType, LPOLESTR *pszUserType)
603 {
604 HTMLDocument *This = impl_from_IOleObject(iface);
605 FIXME("(%p)->(%d %p)\n", This, dwFormOfType, pszUserType);
606 return E_NOTIMPL;
607 }
608
609 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
610 {
611 HTMLDocument *This = impl_from_IOleObject(iface);
612 FIXME("(%p)->(%d %p)\n", This, dwDrawAspect, psizel);
613 return E_NOTIMPL;
614 }
615
616 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD dwDrawAspect, SIZEL *psizel)
617 {
618 HTMLDocument *This = impl_from_IOleObject(iface);
619 FIXME("(%p)->(%d %p)\n", This, dwDrawAspect, psizel);
620 return E_NOTIMPL;
621 }
622
623 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *pAdvSink, DWORD *pdwConnection)
624 {
625 HTMLDocument *This = impl_from_IOleObject(iface);
626 TRACE("(%p)->(%p %p)\n", This, pAdvSink, pdwConnection);
627
628 if(!pdwConnection)
629 return E_INVALIDARG;
630
631 if(!pAdvSink) {
632 *pdwConnection = 0;
633 return E_INVALIDARG;
634 }
635
636 if(!This->advise_holder) {
637 CreateOleAdviseHolder(&This->advise_holder);
638 if(!This->advise_holder)
639 return E_OUTOFMEMORY;
640 }
641
642 return IOleAdviseHolder_Advise(This->advise_holder, pAdvSink, pdwConnection);
643 }
644
645 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD dwConnection)
646 {
647 HTMLDocument *This = impl_from_IOleObject(iface);
648 TRACE("(%p)->(%d)\n", This, dwConnection);
649
650 if(!This->advise_holder)
651 return OLE_E_NOCONNECTION;
652
653 return IOleAdviseHolder_Unadvise(This->advise_holder, dwConnection);
654 }
655
656 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **ppenumAdvise)
657 {
658 HTMLDocument *This = impl_from_IOleObject(iface);
659
660 if(!This->advise_holder) {
661 *ppenumAdvise = NULL;
662 return S_OK;
663 }
664
665 return IOleAdviseHolder_EnumAdvise(This->advise_holder, ppenumAdvise);
666 }
667
668 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD dwAspect, DWORD *pdwStatus)
669 {
670 HTMLDocument *This = impl_from_IOleObject(iface);
671 FIXME("(%p)->(%d %p)\n", This, dwAspect, pdwStatus);
672 return E_NOTIMPL;
673 }
674
675 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE *pLogpal)
676 {
677 HTMLDocument *This = impl_from_IOleObject(iface);
678 FIXME("(%p)->(%p)\n", This, pLogpal);
679 return E_NOTIMPL;
680 }
681
682 static const IOleObjectVtbl OleObjectVtbl = {
683 OleObject_QueryInterface,
684 OleObject_AddRef,
685 OleObject_Release,
686 OleObject_SetClientSite,
687 OleObject_GetClientSite,
688 OleObject_SetHostNames,
689 OleObject_Close,
690 OleObject_SetMoniker,
691 OleObject_GetMoniker,
692 OleObject_InitFromData,
693 OleObject_GetClipboardData,
694 OleObject_DoVerb,
695 OleObject_EnumVerbs,
696 OleObject_Update,
697 OleObject_IsUpToDate,
698 OleObject_GetUserClassID,
699 OleObject_GetUserType,
700 OleObject_SetExtent,
701 OleObject_GetExtent,
702 OleObject_Advise,
703 OleObject_Unadvise,
704 OleObject_EnumAdvise,
705 OleObject_GetMiscStatus,
706 OleObject_SetColorScheme
707 };
708
709 /**********************************************************
710 * IOleDocument implementation
711 */
712
713 static inline HTMLDocument *impl_from_IOleDocument(IOleDocument *iface)
714 {
715 return CONTAINING_RECORD(iface, HTMLDocument, IOleDocument_iface);
716 }
717
718 static HRESULT WINAPI OleDocument_QueryInterface(IOleDocument *iface, REFIID riid, void **ppv)
719 {
720 HTMLDocument *This = impl_from_IOleDocument(iface);
721 return htmldoc_query_interface(This, riid, ppv);
722 }
723
724 static ULONG WINAPI OleDocument_AddRef(IOleDocument *iface)
725 {
726 HTMLDocument *This = impl_from_IOleDocument(iface);
727 return htmldoc_addref(This);
728 }
729
730 static ULONG WINAPI OleDocument_Release(IOleDocument *iface)
731 {
732 HTMLDocument *This = impl_from_IOleDocument(iface);
733 return htmldoc_release(This);
734 }
735
736 static HRESULT WINAPI OleDocument_CreateView(IOleDocument *iface, IOleInPlaceSite *pIPSite, IStream *pstm,
737 DWORD dwReserved, IOleDocumentView **ppView)
738 {
739 HTMLDocument *This = impl_from_IOleDocument(iface);
740 HRESULT hres;
741
742 TRACE("(%p)->(%p %p %d %p)\n", This, pIPSite, pstm, dwReserved, ppView);
743
744 if(!ppView)
745 return E_INVALIDARG;
746
747 /* FIXME:
748 * Windows implementation creates new IOleDocumentView when function is called for the
749 * first time and returns E_FAIL when it is called for the second time, but it doesn't matter
750 * if the application uses returned interfaces, passed to ActivateMe or returned by
751 * QueryInterface, so there is no reason to create new interface. This needs more testing.
752 */
753
754 if(pIPSite) {
755 hres = IOleDocumentView_SetInPlaceSite(&This->IOleDocumentView_iface, pIPSite);
756 if(FAILED(hres))
757 return hres;
758 }
759
760 if(pstm)
761 FIXME("pstm is not supported\n");
762
763 IOleDocumentView_AddRef(&This->IOleDocumentView_iface);
764 *ppView = &This->IOleDocumentView_iface;
765 return S_OK;
766 }
767
768 static HRESULT WINAPI OleDocument_GetDocMiscStatus(IOleDocument *iface, DWORD *pdwStatus)
769 {
770 HTMLDocument *This = impl_from_IOleDocument(iface);
771 FIXME("(%p)->(%p)\n", This, pdwStatus);
772 return E_NOTIMPL;
773 }
774
775 static HRESULT WINAPI OleDocument_EnumViews(IOleDocument *iface, IEnumOleDocumentViews **ppEnum,
776 IOleDocumentView **ppView)
777 {
778 HTMLDocument *This = impl_from_IOleDocument(iface);
779 FIXME("(%p)->(%p %p)\n", This, ppEnum, ppView);
780 return E_NOTIMPL;
781 }
782
783 static const IOleDocumentVtbl OleDocumentVtbl = {
784 OleDocument_QueryInterface,
785 OleDocument_AddRef,
786 OleDocument_Release,
787 OleDocument_CreateView,
788 OleDocument_GetDocMiscStatus,
789 OleDocument_EnumViews
790 };
791
792 /**********************************************************
793 * IOleControl implementation
794 */
795
796 static inline HTMLDocument *impl_from_IOleControl(IOleControl *iface)
797 {
798 return CONTAINING_RECORD(iface, HTMLDocument, IOleControl_iface);
799 }
800
801 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface, REFIID riid, void **ppv)
802 {
803 HTMLDocument *This = impl_from_IOleControl(iface);
804 return htmldoc_query_interface(This, riid, ppv);
805 }
806
807 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
808 {
809 HTMLDocument *This = impl_from_IOleControl(iface);
810 return htmldoc_addref(This);
811 }
812
813 static ULONG WINAPI OleControl_Release(IOleControl *iface)
814 {
815 HTMLDocument *This = impl_from_IOleControl(iface);
816 return htmldoc_release(This);
817 }
818
819 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, CONTROLINFO *pCI)
820 {
821 HTMLDocument *This = impl_from_IOleControl(iface);
822 FIXME("(%p)->(%p)\n", This, pCI);
823 return E_NOTIMPL;
824 }
825
826 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, MSG *pMsg)
827 {
828 HTMLDocument *This = impl_from_IOleControl(iface);
829 FIXME("(%p)->(%p)\n", This, pMsg);
830 return E_NOTIMPL;
831 }
832
833 HRESULT get_client_disp_property(IOleClientSite *client, DISPID dispid, VARIANT *res)
834 {
835 IDispatch *disp = NULL;
836 DISPPARAMS dispparams = {NULL, 0};
837 UINT err;
838 HRESULT hres;
839
840 hres = IOleClientSite_QueryInterface(client, &IID_IDispatch, (void**)&disp);
841 if(FAILED(hres)) {
842 TRACE("Could not get IDispatch\n");
843 return hres;
844 }
845
846 VariantInit(res);
847
848 hres = IDispatch_Invoke(disp, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT,
849 DISPATCH_PROPERTYGET, &dispparams, res, NULL, &err);
850
851 IDispatch_Release(disp);
852
853 return hres;
854 }
855
856 static HRESULT on_change_dlcontrol(HTMLDocument *This)
857 {
858 VARIANT res;
859 HRESULT hres;
860
861 hres = get_client_disp_property(This->doc_obj->client, DISPID_AMBIENT_DLCONTROL, &res);
862 if(SUCCEEDED(hres))
863 FIXME("unsupported dlcontrol %08x\n", V_I4(&res));
864
865 return S_OK;
866 }
867
868 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispID)
869 {
870 HTMLDocument *This = impl_from_IOleControl(iface);
871 IOleClientSite *client;
872 VARIANT res;
873 HRESULT hres;
874
875 client = This->doc_obj->client;
876 if(!client) {
877 TRACE("client = NULL\n");
878 return S_OK;
879 }
880
881 switch(dispID) {
882 case DISPID_AMBIENT_USERMODE:
883 TRACE("(%p)->(DISPID_AMBIENT_USERMODE)\n", This);
884 hres = get_client_disp_property(client, DISPID_AMBIENT_USERMODE, &res);
885 if(FAILED(hres))
886 return S_OK;
887
888 if(V_VT(&res) == VT_BOOL) {
889 if(V_BOOL(&res)) {
890 This->doc_obj->usermode = BROWSEMODE;
891 }else {
892 FIXME("edit mode is not supported\n");
893 This->doc_obj->usermode = EDITMODE;
894 }
895 }else {
896 FIXME("usermode=%s\n", debugstr_variant(&res));
897 }
898 return S_OK;
899 case DISPID_AMBIENT_DLCONTROL:
900 TRACE("(%p)->(DISPID_AMBIENT_DLCONTROL)\n", This);
901 return on_change_dlcontrol(This);
902 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
903 TRACE("(%p)->(DISPID_AMBIENT_OFFLINEIFNOTCONNECTED)\n", This);
904 on_change_dlcontrol(This);
905 hres = get_client_disp_property(client, DISPID_AMBIENT_OFFLINEIFNOTCONNECTED, &res);
906 if(FAILED(hres))
907 return S_OK;
908
909 if(V_VT(&res) == VT_BOOL) {
910 if(V_BOOL(&res)) {
911 FIXME("offline connection is not supported\n");
912 hres = E_FAIL;
913 }
914 }else {
915 FIXME("offlineconnected=%s\n", debugstr_variant(&res));
916 }
917 return S_OK;
918 case DISPID_AMBIENT_SILENT:
919 TRACE("(%p)->(DISPID_AMBIENT_SILENT)\n", This);
920 on_change_dlcontrol(This);
921 hres = get_client_disp_property(client, DISPID_AMBIENT_SILENT, &res);
922 if(FAILED(hres))
923 return S_OK;
924
925 if(V_VT(&res) == VT_BOOL) {
926 if(V_BOOL(&res)) {
927 FIXME("silent mode is not supported\n");
928 hres = E_FAIL;
929 }
930 }else {
931 FIXME("silent=%s\n", debugstr_variant(&res));
932 }
933 return S_OK;
934 case DISPID_AMBIENT_USERAGENT:
935 TRACE("(%p)->(DISPID_AMBIENT_USERAGENT)\n", This);
936 hres = get_client_disp_property(client, DISPID_AMBIENT_USERAGENT, &res);
937 if(FAILED(hres))
938 return S_OK;
939
940 FIXME("not supported AMBIENT_USERAGENT\n");
941 hres = E_FAIL;
942 return S_OK;
943 case DISPID_AMBIENT_PALETTE:
944 TRACE("(%p)->(DISPID_AMBIENT_PALETTE)\n", This);
945 hres = get_client_disp_property(client, DISPID_AMBIENT_PALETTE, &res);
946 if(FAILED(hres))
947 return S_OK;
948
949 FIXME("not supported AMBIENT_PALETTE\n");
950 hres = E_FAIL;
951 return S_OK;
952 }
953
954 FIXME("(%p) unsupported dispID=%d\n", This, dispID);
955 return E_FAIL;
956 }
957
958 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL bFreeze)
959 {
960 HTMLDocument *This = impl_from_IOleControl(iface);
961 FIXME("(%p)->(%x)\n", This, bFreeze);
962 return E_NOTIMPL;
963 }
964
965 static const IOleControlVtbl OleControlVtbl = {
966 OleControl_QueryInterface,
967 OleControl_AddRef,
968 OleControl_Release,
969 OleControl_GetControlInfo,
970 OleControl_OnMnemonic,
971 OleControl_OnAmbientPropertyChange,
972 OleControl_FreezeEvents
973 };
974
975 /**********************************************************
976 * IObjectWithSite implementation
977 */
978
979 static inline HTMLDocument *impl_from_IObjectWithSite(IObjectWithSite *iface)
980 {
981 return CONTAINING_RECORD(iface, HTMLDocument, IObjectWithSite_iface);
982 }
983
984 static HRESULT WINAPI ObjectWithSite_QueryInterface(IObjectWithSite *iface, REFIID riid, void **ppv)
985 {
986 HTMLDocument *This = impl_from_IObjectWithSite(iface);
987 return htmldoc_query_interface(This, riid, ppv);
988 }
989
990 static ULONG WINAPI ObjectWithSite_AddRef(IObjectWithSite *iface)
991 {
992 HTMLDocument *This = impl_from_IObjectWithSite(iface);
993 return htmldoc_addref(This);
994 }
995
996 static ULONG WINAPI ObjectWithSite_Release(IObjectWithSite *iface)
997 {
998 HTMLDocument *This = impl_from_IObjectWithSite(iface);
999 return htmldoc_release(This);
1000 }
1001
1002 static HRESULT WINAPI ObjectWithSite_SetSite(IObjectWithSite *iface, IUnknown *pUnkSite)
1003 {
1004 HTMLDocument *This = impl_from_IObjectWithSite(iface);
1005 FIXME("(%p)->(%p)\n", This, pUnkSite);
1006 return E_NOTIMPL;
1007 }
1008
1009 static HRESULT WINAPI ObjectWithSite_GetSite(IObjectWithSite* iface, REFIID riid, PVOID *ppvSite)
1010 {
1011 HTMLDocument *This = impl_from_IObjectWithSite(iface);
1012 FIXME("(%p)->(%p)\n", This, ppvSite);
1013 return E_NOTIMPL;
1014 }
1015
1016 static const IObjectWithSiteVtbl ObjectWithSiteVtbl = {
1017 ObjectWithSite_QueryInterface,
1018 ObjectWithSite_AddRef,
1019 ObjectWithSite_Release,
1020 ObjectWithSite_SetSite,
1021 ObjectWithSite_GetSite
1022 };
1023
1024 /**********************************************************
1025 * IOleContainer implementation
1026 */
1027
1028 static inline HTMLDocument *impl_from_IOleContainer(IOleContainer *iface)
1029 {
1030 return CONTAINING_RECORD(iface, HTMLDocument, IOleContainer_iface);
1031 }
1032
1033 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
1034 {
1035 HTMLDocument *This = impl_from_IOleContainer(iface);
1036 return htmldoc_query_interface(This, riid, ppv);
1037 }
1038
1039 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
1040 {
1041 HTMLDocument *This = impl_from_IOleContainer(iface);
1042 return htmldoc_addref(This);
1043 }
1044
1045 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
1046 {
1047 HTMLDocument *This = impl_from_IOleContainer(iface);
1048 return htmldoc_release(This);
1049 }
1050
1051 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc, LPOLESTR pszDisplayName,
1052 ULONG *pchEaten, IMoniker **ppmkOut)
1053 {
1054 HTMLDocument *This = impl_from_IOleContainer(iface);
1055 FIXME("(%p)->(%p %s %p %p)\n", This, pbc, debugstr_w(pszDisplayName), pchEaten, ppmkOut);
1056 return E_NOTIMPL;
1057 }
1058
1059 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags, IEnumUnknown **ppenum)
1060 {
1061 HTMLDocument *This = impl_from_IOleContainer(iface);
1062 EnumUnknown *ret;
1063
1064 TRACE("(%p)->(%x %p)\n", This, grfFlags, ppenum);
1065
1066 ret = heap_alloc(sizeof(*ret));
1067 if(!ret)
1068 return E_OUTOFMEMORY;
1069
1070 ret->IEnumUnknown_iface.lpVtbl = &EnumUnknownVtbl;
1071 ret->ref = 1;
1072
1073 *ppenum = &ret->IEnumUnknown_iface;
1074 return S_OK;
1075 }
1076
1077 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
1078 {
1079 HTMLDocument *This = impl_from_IOleContainer(iface);
1080 FIXME("(%p)->(%x)\n", This, fLock);
1081 return E_NOTIMPL;
1082 }
1083
1084 static const IOleContainerVtbl OleContainerVtbl = {
1085 OleContainer_QueryInterface,
1086 OleContainer_AddRef,
1087 OleContainer_Release,
1088 OleContainer_ParseDisplayName,
1089 OleContainer_EnumObjects,
1090 OleContainer_LockContainer
1091 };
1092
1093 static inline HTMLDocumentObj *impl_from_ITargetContainer(ITargetContainer *iface)
1094 {
1095 return CONTAINING_RECORD(iface, HTMLDocumentObj, ITargetContainer_iface);
1096 }
1097
1098 static HRESULT WINAPI TargetContainer_QueryInterface(ITargetContainer *iface, REFIID riid, void **ppv)
1099 {
1100 HTMLDocumentObj *This = impl_from_ITargetContainer(iface);
1101 return ICustomDoc_QueryInterface(&This->ICustomDoc_iface, riid, ppv);
1102 }
1103
1104 static ULONG WINAPI TargetContainer_AddRef(ITargetContainer *iface)
1105 {
1106 HTMLDocumentObj *This = impl_from_ITargetContainer(iface);
1107 return ICustomDoc_AddRef(&This->ICustomDoc_iface);
1108 }
1109
1110 static ULONG WINAPI TargetContainer_Release(ITargetContainer *iface)
1111 {
1112 HTMLDocumentObj *This = impl_from_ITargetContainer(iface);
1113 return ICustomDoc_Release(&This->ICustomDoc_iface);
1114 }
1115
1116 static HRESULT WINAPI TargetContainer_GetFrameUrl(ITargetContainer *iface, LPWSTR *ppszFrameSrc)
1117 {
1118 HTMLDocumentObj *This = impl_from_ITargetContainer(iface);
1119 FIXME("(%p)->(%p)\n", This, ppszFrameSrc);
1120 return E_NOTIMPL;
1121 }
1122
1123 static HRESULT WINAPI TargetContainer_GetFramesContainer(ITargetContainer *iface, IOleContainer **ppContainer)
1124 {
1125 HTMLDocumentObj *This = impl_from_ITargetContainer(iface);
1126
1127 TRACE("(%p)->(%p)\n", This, ppContainer);
1128
1129 /* NOTE: we should return wrapped interface here */
1130 IOleContainer_AddRef(&This->basedoc.IOleContainer_iface);
1131 *ppContainer = &This->basedoc.IOleContainer_iface;
1132 return S_OK;
1133 }
1134
1135 static const ITargetContainerVtbl TargetContainerVtbl = {
1136 TargetContainer_QueryInterface,
1137 TargetContainer_AddRef,
1138 TargetContainer_Release,
1139 TargetContainer_GetFrameUrl,
1140 TargetContainer_GetFramesContainer
1141 };
1142
1143 void TargetContainer_Init(HTMLDocumentObj *This)
1144 {
1145 This->ITargetContainer_iface.lpVtbl = &TargetContainerVtbl;
1146 }
1147
1148 /**********************************************************
1149 * IObjectSafety implementation
1150 */
1151
1152 static inline HTMLDocument *impl_from_IObjectSafety(IObjectSafety *iface)
1153 {
1154 return CONTAINING_RECORD(iface, HTMLDocument, IObjectSafety_iface);
1155 }
1156
1157 static HRESULT WINAPI ObjectSafety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv)
1158 {
1159 HTMLDocument *This = impl_from_IObjectSafety(iface);
1160 return htmldoc_query_interface(This, riid, ppv);
1161 }
1162
1163 static ULONG WINAPI ObjectSafety_AddRef(IObjectSafety *iface)
1164 {
1165 HTMLDocument *This = impl_from_IObjectSafety(iface);
1166 return htmldoc_addref(This);
1167 }
1168
1169 static ULONG WINAPI ObjectSafety_Release(IObjectSafety *iface)
1170 {
1171 HTMLDocument *This = impl_from_IObjectSafety(iface);
1172 return htmldoc_release(This);
1173 }
1174
1175 static HRESULT WINAPI ObjectSafety_GetInterfaceSafetyOptions(IObjectSafety *iface,
1176 REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
1177 {
1178 HTMLDocument *This = impl_from_IObjectSafety(iface);
1179 FIXME("(%p)->(%s %p %p)\n", This, debugstr_guid(riid), pdwSupportedOptions, pdwEnabledOptions);
1180 return E_NOTIMPL;
1181 }
1182
1183 static HRESULT WINAPI ObjectSafety_SetInterfaceSafetyOptions(IObjectSafety *iface,
1184 REFIID riid, DWORD dwOptionSetMask, DWORD dwEnabledOptions)
1185 {
1186 HTMLDocument *This = impl_from_IObjectSafety(iface);
1187 FIXME("(%p)->(%s %x %x)\n", This, debugstr_guid(riid), dwOptionSetMask, dwEnabledOptions);
1188
1189 if(IsEqualGUID(&IID_IPersistMoniker, riid) &&
1190 dwOptionSetMask==INTERFACESAFE_FOR_UNTRUSTED_DATA &&
1191 dwEnabledOptions==INTERFACESAFE_FOR_UNTRUSTED_DATA)
1192 return S_OK;
1193
1194 return E_NOTIMPL;
1195 }
1196
1197 static const IObjectSafetyVtbl ObjectSafetyVtbl = {
1198 ObjectSafety_QueryInterface,
1199 ObjectSafety_AddRef,
1200 ObjectSafety_Release,
1201 ObjectSafety_GetInterfaceSafetyOptions,
1202 ObjectSafety_SetInterfaceSafetyOptions
1203 };
1204
1205 void HTMLDocument_LockContainer(HTMLDocumentObj *This, BOOL fLock)
1206 {
1207 IOleContainer *container;
1208 HRESULT hres;
1209
1210 if(!This->client || This->container_locked == fLock)
1211 return;
1212
1213 hres = IOleClientSite_GetContainer(This->client, &container);
1214 if(SUCCEEDED(hres)) {
1215 IOleContainer_LockContainer(container, fLock);
1216 This->container_locked = fLock;
1217 IOleContainer_Release(container);
1218 }
1219 }
1220
1221 void HTMLDocument_OleObj_Init(HTMLDocument *This)
1222 {
1223 This->IOleObject_iface.lpVtbl = &OleObjectVtbl;
1224 This->IOleDocument_iface.lpVtbl = &OleDocumentVtbl;
1225 This->IOleControl_iface.lpVtbl = &OleControlVtbl;
1226 This->IObjectWithSite_iface.lpVtbl = &ObjectWithSiteVtbl;
1227 This->IOleContainer_iface.lpVtbl = &OleContainerVtbl;
1228 This->IObjectSafety_iface.lpVtbl = &ObjectSafetyVtbl;
1229 }