makefiles: Don't use standard libs for programs that specify -nodefaultlibs.
[wine/zf.git] / dlls / msscript.ocx / msscript.c
blobc4c6485980c486299c3cf2e7ffb25421175b69c4
1 /*
2 * Copyright 2015 Jacek Caban for CodeWeavers
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
21 #include "windows.h"
22 #include "initguid.h"
23 #include "dispex.h"
24 #include "ole2.h"
25 #include "olectl.h"
26 #include "objsafe.h"
27 #include "activscp.h"
28 #include "rpcproxy.h"
29 #include "msscript.h"
30 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
32 #include "wine/debug.h"
33 #include "wine/heap.h"
34 #include "wine/list.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msscript);
38 #ifdef _WIN64
40 #define IActiveScriptParse_Release IActiveScriptParse64_Release
41 #define IActiveScriptParse_InitNew IActiveScriptParse64_InitNew
42 #define IActiveScriptParse_ParseScriptText IActiveScriptParse64_ParseScriptText
44 #else
46 #define IActiveScriptParse_Release IActiveScriptParse32_Release
47 #define IActiveScriptParse_InitNew IActiveScriptParse32_InitNew
48 #define IActiveScriptParse_ParseScriptText IActiveScriptParse32_ParseScriptText
50 #endif
52 struct ScriptControl;
53 typedef struct ConnectionPoint ConnectionPoint;
55 struct ConnectionPoint {
56 IConnectionPoint IConnectionPoint_iface;
57 ScriptControl *control;
58 const IID *riid;
59 ConnectionPoint *next;
62 struct named_item {
63 struct list entry;
64 BSTR name;
65 IDispatch *disp;
68 typedef struct ScriptHost {
69 IActiveScriptSite IActiveScriptSite_iface;
70 IActiveScriptSiteWindow IActiveScriptSiteWindow_iface;
71 IServiceProvider IServiceProvider_iface;
72 LONG ref;
74 IActiveScript *script;
75 IActiveScriptParse *parse;
76 IDispatch *script_dispatch;
77 SCRIPTSTATE script_state;
78 CLSID clsid;
80 struct list named_items;
81 } ScriptHost;
83 struct ScriptControl {
84 IScriptControl IScriptControl_iface;
85 IPersistStreamInit IPersistStreamInit_iface;
86 IOleObject IOleObject_iface;
87 IOleControl IOleControl_iface;
88 IQuickActivate IQuickActivate_iface;
89 IViewObjectEx IViewObjectEx_iface;
90 IPointerInactive IPointerInactive_iface;
91 IConnectionPointContainer IConnectionPointContainer_iface;
92 LONG ref;
93 IOleClientSite *site;
94 SIZEL extent;
95 LONG timeout;
96 VARIANT_BOOL allow_ui;
97 VARIANT_BOOL use_safe_subset;
98 ScriptControlStates state;
100 /* connection points */
101 ConnectionPoint *cp_list;
102 ConnectionPoint cp_scsource;
103 ConnectionPoint cp_propnotif;
105 /* IViewObject sink */
106 IAdviseSink *view_sink;
107 DWORD view_sink_flags;
109 ScriptHost *host;
112 static HINSTANCE msscript_instance;
114 typedef enum tid_t {
115 IScriptControl_tid,
116 LAST_tid
117 } tid_t;
119 static ITypeLib *typelib;
120 static ITypeInfo *typeinfos[LAST_tid];
122 static REFIID tid_ids[] = {
123 &IID_IScriptControl
126 static HRESULT load_typelib(void)
128 HRESULT hres;
129 ITypeLib *tl;
131 hres = LoadRegTypeLib(&LIBID_MSScriptControl, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
132 if(FAILED(hres)) {
133 ERR("LoadRegTypeLib failed: %08x\n", hres);
134 return hres;
137 if(InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
138 ITypeLib_Release(tl);
139 return hres;
142 static HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
144 HRESULT hres;
146 if (!typelib)
147 hres = load_typelib();
148 if (!typelib)
149 return hres;
151 if(!typeinfos[tid]) {
152 ITypeInfo *ti;
154 hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
155 if(FAILED(hres)) {
156 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
157 return hres;
160 if(InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
161 ITypeInfo_Release(ti);
164 *typeinfo = typeinfos[tid];
165 ITypeInfo_AddRef(typeinfos[tid]);
166 return S_OK;
169 static void release_typelib(void)
171 unsigned i;
173 if(!typelib)
174 return;
176 for(i = 0; i < ARRAY_SIZE(typeinfos); i++)
177 if(typeinfos[i])
178 ITypeInfo_Release(typeinfos[i]);
180 ITypeLib_Release(typelib);
183 static void clear_named_items(ScriptHost *host)
185 struct named_item *item, *item1;
186 LIST_FOR_EACH_ENTRY_SAFE(item, item1, &host->named_items, struct named_item, entry) {
187 list_remove(&item->entry);
188 SysFreeString(item->name);
189 IDispatch_Release(item->disp);
190 heap_free(item);
194 static struct named_item *host_get_named_item(ScriptHost *host, const WCHAR *nameW)
196 struct named_item *item;
198 LIST_FOR_EACH_ENTRY(item, &host->named_items, struct named_item, entry) {
199 if (!wcscmp(item->name, nameW))
200 return item;
203 return NULL;
206 static HRESULT get_script_dispatch(struct ScriptControl *control, IDispatch **disp)
208 if (!control->host->script_dispatch)
210 HRESULT hr = IActiveScript_GetScriptDispatch(control->host->script, NULL, &control->host->script_dispatch);
211 if (FAILED(hr)) return hr;
213 *disp = control->host->script_dispatch;
214 return S_OK;
217 static HRESULT set_script_state(ScriptHost *host, SCRIPTSTATE state)
219 HRESULT hr;
221 hr = IActiveScript_SetScriptState(host->script, state);
222 if (SUCCEEDED(hr))
223 host->script_state = state;
224 return hr;
227 static HRESULT start_script(struct ScriptControl *control)
229 HRESULT hr = S_OK;
231 if (!control->host || control->state != Initialized)
232 return E_FAIL;
234 if (control->host->script_state != SCRIPTSTATE_STARTED)
235 hr = set_script_state(control->host, SCRIPTSTATE_STARTED);
237 return hr;
240 static inline ScriptControl *impl_from_IScriptControl(IScriptControl *iface)
242 return CONTAINING_RECORD(iface, ScriptControl, IScriptControl_iface);
245 static inline ScriptControl *impl_from_IOleObject(IOleObject *iface)
247 return CONTAINING_RECORD(iface, ScriptControl, IOleObject_iface);
250 static inline ScriptControl *impl_from_IPersistStreamInit(IPersistStreamInit *iface)
252 return CONTAINING_RECORD(iface, ScriptControl, IPersistStreamInit_iface);
255 static inline ScriptControl *impl_from_IOleControl(IOleControl *iface)
257 return CONTAINING_RECORD(iface, ScriptControl, IOleControl_iface);
260 static inline ScriptControl *impl_from_IQuickActivate(IQuickActivate *iface)
262 return CONTAINING_RECORD(iface, ScriptControl, IQuickActivate_iface);
265 static inline ScriptControl *impl_from_IViewObjectEx(IViewObjectEx *iface)
267 return CONTAINING_RECORD(iface, ScriptControl, IViewObjectEx_iface);
270 static inline ScriptControl *impl_from_IPointerInactive(IPointerInactive *iface)
272 return CONTAINING_RECORD(iface, ScriptControl, IPointerInactive_iface);
275 static inline ScriptControl *impl_from_IConnectionPointContainer(IConnectionPointContainer *iface)
277 return CONTAINING_RECORD(iface, ScriptControl, IConnectionPointContainer_iface);
280 static inline ConnectionPoint *impl_from_IConnectionPoint(IConnectionPoint *iface)
282 return CONTAINING_RECORD(iface, ConnectionPoint, IConnectionPoint_iface);
285 static inline ScriptHost *impl_from_IActiveScriptSite(IActiveScriptSite *iface)
287 return CONTAINING_RECORD(iface, ScriptHost, IActiveScriptSite_iface);
290 static inline ScriptHost *impl_from_IActiveScriptSiteWindow(IActiveScriptSiteWindow *iface)
292 return CONTAINING_RECORD(iface, ScriptHost, IActiveScriptSiteWindow_iface);
295 static inline ScriptHost *impl_from_IServiceProvider(IServiceProvider *iface)
297 return CONTAINING_RECORD(iface, ScriptHost, IServiceProvider_iface);
300 /* IActiveScriptSite */
301 static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)
303 ScriptHost *This = impl_from_IActiveScriptSite(iface);
305 if(IsEqualGUID(&IID_IUnknown, riid)) {
306 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
307 *ppv = &This->IActiveScriptSite_iface;
308 }else if(IsEqualGUID(&IID_IActiveScriptSite, riid)) {
309 TRACE("(%p)->(IID_IActiveScriptSite %p)\n", This, ppv);
310 *ppv = &This->IActiveScriptSite_iface;
311 }else if(IsEqualGUID(&IID_IActiveScriptSiteWindow, riid)) {
312 TRACE("(%p)->(IID_IActiveScriptSiteWindow %p)\n", This, ppv);
313 *ppv = &This->IActiveScriptSiteWindow_iface;
314 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
315 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
316 *ppv = &This->IServiceProvider_iface;
317 }else {
318 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
319 *ppv = NULL;
320 return E_NOINTERFACE;
323 IUnknown_AddRef((IUnknown*)*ppv);
324 return S_OK;
327 static ULONG WINAPI ActiveScriptSite_AddRef(IActiveScriptSite *iface)
329 ScriptHost *This = impl_from_IActiveScriptSite(iface);
330 LONG ref = InterlockedIncrement(&This->ref);
332 TRACE("(%p) ref=%d\n", This, ref);
334 return ref;
337 static void release_script_engine(ScriptHost *host)
339 if (host->script) {
340 IActiveScript_Close(host->script);
341 IActiveScript_Release(host->script);
344 if (host->parse)
345 IActiveScriptParse_Release(host->parse);
346 if (host->script_dispatch)
347 IDispatch_Release(host->script_dispatch);
349 host->script_dispatch = NULL;
350 host->parse = NULL;
351 host->script = NULL;
353 IActiveScriptSite_Release(&host->IActiveScriptSite_iface);
356 static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface)
358 ScriptHost *This = impl_from_IActiveScriptSite(iface);
359 LONG ref = InterlockedDecrement(&This->ref);
361 TRACE("(%p) ref=%d\n", This, ref);
363 if(!ref) {
364 clear_named_items(This);
365 heap_free(This);
368 return ref;
371 static HRESULT WINAPI ActiveScriptSite_GetLCID(IActiveScriptSite *iface, LCID *lcid)
373 ScriptHost *This = impl_from_IActiveScriptSite(iface);
375 TRACE("(%p, %p)\n", This, lcid);
377 *lcid = GetUserDefaultLCID();
378 return S_OK;
381 static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR name, DWORD mask,
382 IUnknown **unk, ITypeInfo **ti)
384 ScriptHost *This = impl_from_IActiveScriptSite(iface);
385 struct named_item *item;
387 TRACE("(%p, %s, %#x, %p, %p)\n", This, debugstr_w(name), mask, unk, ti);
389 item = host_get_named_item(This, name);
390 if (!item)
391 return TYPE_E_ELEMENTNOTFOUND;
393 if (mask != SCRIPTINFO_IUNKNOWN) {
394 FIXME("mask %#x is not supported\n", mask);
395 return E_NOTIMPL;
398 *unk = (IUnknown*)item->disp;
399 IUnknown_AddRef(*unk);
401 return S_OK;
404 static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *version)
406 ScriptHost *This = impl_from_IActiveScriptSite(iface);
408 FIXME("(%p, %p)\n", This, version);
410 return E_NOTIMPL;
413 static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface, const VARIANT *result,
414 const EXCEPINFO *ei)
416 ScriptHost *This = impl_from_IActiveScriptSite(iface);
418 FIXME("(%p, %s, %p)\n", This, debugstr_variant(result), ei);
420 return E_NOTIMPL;
423 static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE state)
425 ScriptHost *This = impl_from_IActiveScriptSite(iface);
427 FIXME("(%p, %d)\n", This, state);
429 return E_NOTIMPL;
432 static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *script_error)
434 ScriptHost *This = impl_from_IActiveScriptSite(iface);
436 FIXME("(%p, %p)\n", This, script_error);
438 return E_NOTIMPL;
441 static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface)
443 ScriptHost *This = impl_from_IActiveScriptSite(iface);
445 FIXME("(%p)\n", This);
447 return E_NOTIMPL;
450 static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface)
452 ScriptHost *This = impl_from_IActiveScriptSite(iface);
454 FIXME("(%p)\n", This);
456 return E_NOTIMPL;
459 static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl = {
460 ActiveScriptSite_QueryInterface,
461 ActiveScriptSite_AddRef,
462 ActiveScriptSite_Release,
463 ActiveScriptSite_GetLCID,
464 ActiveScriptSite_GetItemInfo,
465 ActiveScriptSite_GetDocVersionString,
466 ActiveScriptSite_OnScriptTerminate,
467 ActiveScriptSite_OnStateChange,
468 ActiveScriptSite_OnScriptError,
469 ActiveScriptSite_OnEnterScript,
470 ActiveScriptSite_OnLeaveScript
473 /* IActiveScriptSiteWindow */
474 static HRESULT WINAPI ActiveScriptSiteWindow_QueryInterface(IActiveScriptSiteWindow *iface, REFIID riid, void **obj)
476 ScriptHost *This = impl_from_IActiveScriptSiteWindow(iface);
477 return IActiveScriptSite_QueryInterface(&This->IActiveScriptSite_iface, riid, obj);
480 static ULONG WINAPI ActiveScriptSiteWindow_AddRef(IActiveScriptSiteWindow *iface)
482 ScriptHost *This = impl_from_IActiveScriptSiteWindow(iface);
483 return IActiveScriptSite_AddRef(&This->IActiveScriptSite_iface);
486 static ULONG WINAPI ActiveScriptSiteWindow_Release(IActiveScriptSiteWindow *iface)
488 ScriptHost *This = impl_from_IActiveScriptSiteWindow(iface);
489 return IActiveScriptSite_Release(&This->IActiveScriptSite_iface);
492 static HRESULT WINAPI ActiveScriptSiteWindow_GetWindow(IActiveScriptSiteWindow *iface, HWND *hwnd)
494 ScriptHost *This = impl_from_IActiveScriptSiteWindow(iface);
496 FIXME("(%p, %p)\n", This, hwnd);
498 return E_NOTIMPL;
501 static HRESULT WINAPI ActiveScriptSiteWindow_EnableModeless(IActiveScriptSiteWindow *iface, BOOL enable)
503 ScriptHost *This = impl_from_IActiveScriptSiteWindow(iface);
505 FIXME("(%p, %d)\n", This, enable);
507 return E_NOTIMPL;
510 static const IActiveScriptSiteWindowVtbl ActiveScriptSiteWindowVtbl = {
511 ActiveScriptSiteWindow_QueryInterface,
512 ActiveScriptSiteWindow_AddRef,
513 ActiveScriptSiteWindow_Release,
514 ActiveScriptSiteWindow_GetWindow,
515 ActiveScriptSiteWindow_EnableModeless
518 /* IServiceProvider */
519 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **obj)
521 ScriptHost *This = impl_from_IServiceProvider(iface);
522 return IActiveScriptSite_QueryInterface(&This->IActiveScriptSite_iface, riid, obj);
525 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
527 ScriptHost *This = impl_from_IServiceProvider(iface);
528 return IActiveScriptSite_AddRef(&This->IActiveScriptSite_iface);
531 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
533 ScriptHost *This = impl_from_IServiceProvider(iface);
534 return IActiveScriptSite_Release(&This->IActiveScriptSite_iface);
537 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID service,
538 REFIID riid, void **obj)
540 ScriptHost *This = impl_from_IServiceProvider(iface);
542 FIXME("(%p)->(%s %s %p)\n", This, debugstr_guid(service), debugstr_guid(riid), obj);
544 return E_NOTIMPL;
547 static const IServiceProviderVtbl ServiceProviderVtbl = {
548 ServiceProvider_QueryInterface,
549 ServiceProvider_AddRef,
550 ServiceProvider_Release,
551 ServiceProvider_QueryService
554 static HRESULT init_script_host(const CLSID *clsid, ScriptHost **ret)
556 IObjectSafety *objsafety;
557 ScriptHost *host;
558 HRESULT hr;
560 *ret = NULL;
562 host = heap_alloc(sizeof(*host));
563 if (!host)
564 return E_OUTOFMEMORY;
566 host->IActiveScriptSite_iface.lpVtbl = &ActiveScriptSiteVtbl;
567 host->IActiveScriptSiteWindow_iface.lpVtbl = &ActiveScriptSiteWindowVtbl;
568 host->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
569 host->ref = 1;
570 host->script = NULL;
571 host->parse = NULL;
572 host->script_dispatch = NULL;
573 host->clsid = *clsid;
574 list_init(&host->named_items);
576 hr = CoCreateInstance(&host->clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
577 &IID_IActiveScript, (void**)&host->script);
578 if (FAILED(hr)) {
579 WARN("Failed to create an instance for %s, %#x\n", debugstr_guid(clsid), hr);
580 goto failed;
583 hr = IActiveScript_QueryInterface(host->script, &IID_IObjectSafety, (void**)&objsafety);
584 if (FAILED(hr)) {
585 FIXME("Could not get IObjectSafety, %#x\n", hr);
586 goto failed;
589 hr = IObjectSafety_SetInterfaceSafetyOptions(objsafety, &IID_IActiveScriptParse, INTERFACESAFE_FOR_UNTRUSTED_DATA, 0);
590 IObjectSafety_Release(objsafety);
591 if (FAILED(hr)) {
592 FIXME("SetInterfaceSafetyOptions failed, %#x\n", hr);
593 goto failed;
596 hr = IActiveScript_SetScriptSite(host->script, &host->IActiveScriptSite_iface);
597 if (FAILED(hr)) {
598 WARN("SetScriptSite failed, %#x\n", hr);
599 goto failed;
602 hr = IActiveScript_QueryInterface(host->script, &IID_IActiveScriptParse, (void**)&host->parse);
603 if (FAILED(hr)) {
604 WARN("Failed to get IActiveScriptParse, %#x\n", hr);
605 goto failed;
608 hr = IActiveScriptParse_InitNew(host->parse);
609 if (FAILED(hr)) {
610 WARN("InitNew failed, %#x\n", hr);
611 goto failed;
613 host->script_state = SCRIPTSTATE_INITIALIZED;
615 *ret = host;
616 return S_OK;
618 failed:
619 release_script_engine(host);
620 return hr;
623 static HRESULT WINAPI ScriptControl_QueryInterface(IScriptControl *iface, REFIID riid, void **ppv)
625 ScriptControl *This = impl_from_IScriptControl(iface);
627 if(IsEqualGUID(&IID_IUnknown, riid)) {
628 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
629 *ppv = &This->IScriptControl_iface;
630 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
631 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
632 *ppv = &This->IScriptControl_iface;
633 }else if(IsEqualGUID(&IID_IScriptControl, riid)) {
634 TRACE("(%p)->(IID_IScriptControl %p)\n", This, ppv);
635 *ppv = &This->IScriptControl_iface;
636 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
637 TRACE("(%p)->(IID_IOleObject %p)\n", This, ppv);
638 *ppv = &This->IOleObject_iface;
639 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
640 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
641 *ppv = &This->IPersistStreamInit_iface;
642 }else if(IsEqualGUID(&IID_IPersist, riid)) {
643 TRACE("(%p)->(IID_IPersist %p)\n", This, ppv);
644 *ppv = &This->IPersistStreamInit_iface;
645 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
646 TRACE("(%p)->(IID_IOleControl %p)\n", This, ppv);
647 *ppv = &This->IOleControl_iface;
648 }else if(IsEqualGUID(&IID_IQuickActivate, riid)) {
649 TRACE("(%p)->(IID_IQuickActivate %p)\n", This, ppv);
650 *ppv = &This->IQuickActivate_iface;
651 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
652 TRACE("(%p)->(IID_IViewObject %p)\n", This, ppv);
653 *ppv = &This->IViewObjectEx_iface;
654 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
655 TRACE("(%p)->(IID_IViewObject2 %p)\n", This, ppv);
656 *ppv = &This->IViewObjectEx_iface;
657 }else if(IsEqualGUID(&IID_IViewObjectEx, riid)) {
658 TRACE("(%p)->(IID_IViewObjectEx %p)\n", This, ppv);
659 *ppv = &This->IViewObjectEx_iface;
660 }else if(IsEqualGUID(&IID_IPointerInactive, riid)) {
661 TRACE("(%p)->(IID_IPointerInactive %p)\n", This, ppv);
662 *ppv = &This->IPointerInactive_iface;
663 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
664 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
665 *ppv = &This->IConnectionPointContainer_iface;
666 }else {
667 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
668 *ppv = NULL;
669 return E_NOINTERFACE;
672 IUnknown_AddRef((IUnknown*)*ppv);
673 return S_OK;
676 static ULONG WINAPI ScriptControl_AddRef(IScriptControl *iface)
678 ScriptControl *This = impl_from_IScriptControl(iface);
679 LONG ref = InterlockedIncrement(&This->ref);
681 TRACE("(%p) ref=%d\n", This, ref);
683 return ref;
686 static ULONG WINAPI ScriptControl_Release(IScriptControl *iface)
688 ScriptControl *This = impl_from_IScriptControl(iface);
689 LONG ref = InterlockedDecrement(&This->ref);
691 TRACE("(%p) ref=%d\n", This, ref);
693 if(!ref) {
694 if (This->site)
695 IOleClientSite_Release(This->site);
696 if (This->host)
697 release_script_engine(This->host);
698 heap_free(This);
701 return ref;
704 static HRESULT WINAPI ScriptControl_GetTypeInfoCount(IScriptControl *iface, UINT *pctinfo)
706 ScriptControl *This = impl_from_IScriptControl(iface);
707 TRACE("(%p)->(%p)\n", This, pctinfo);
708 *pctinfo = 1;
709 return S_OK;
712 static HRESULT WINAPI ScriptControl_GetTypeInfo(IScriptControl *iface, UINT iTInfo,
713 LCID lcid, ITypeInfo **ppTInfo)
715 ScriptControl *This = impl_from_IScriptControl(iface);
716 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
717 return get_typeinfo(IScriptControl_tid, ppTInfo);
720 static HRESULT WINAPI ScriptControl_GetIDsOfNames(IScriptControl *iface, REFIID riid,
721 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
723 ScriptControl *This = impl_from_IScriptControl(iface);
724 ITypeInfo *typeinfo;
725 HRESULT hres;
727 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
729 hres = get_typeinfo(IScriptControl_tid, &typeinfo);
730 if(SUCCEEDED(hres)) {
731 hres = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
732 ITypeInfo_Release(typeinfo);
735 return hres;
738 static HRESULT WINAPI ScriptControl_Invoke(IScriptControl *iface, DISPID dispIdMember,
739 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
740 EXCEPINFO *pExcepInfo, UINT *puArgErr)
742 ScriptControl *This = impl_from_IScriptControl(iface);
743 ITypeInfo *typeinfo;
744 HRESULT hres;
746 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
747 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
749 hres = get_typeinfo(IScriptControl_tid, &typeinfo);
750 if(SUCCEEDED(hres)) {
751 hres = ITypeInfo_Invoke(typeinfo, iface, dispIdMember, wFlags,
752 pDispParams, pVarResult, pExcepInfo, puArgErr);
753 ITypeInfo_Release(typeinfo);
756 return hres;
759 static HRESULT WINAPI ScriptControl_get_Language(IScriptControl *iface, BSTR *p)
761 ScriptControl *This = impl_from_IScriptControl(iface);
762 LPOLESTR progidW;
763 HRESULT hr;
765 TRACE("(%p)->(%p)\n", This, p);
767 if (!p)
768 return E_POINTER;
770 *p = NULL;
772 if (!This->host)
773 return S_OK;
775 hr = ProgIDFromCLSID(&This->host->clsid, &progidW);
776 if (FAILED(hr))
777 return hr;
779 *p = SysAllocString(progidW);
780 CoTaskMemFree(progidW);
781 return *p ? S_OK : E_OUTOFMEMORY;
784 static HRESULT WINAPI ScriptControl_put_Language(IScriptControl *iface, BSTR language)
786 ScriptControl *This = impl_from_IScriptControl(iface);
787 CLSID clsid;
789 TRACE("(%p)->(%s)\n", This, debugstr_w(language));
791 if (language && FAILED(CLSIDFromProgID(language, &clsid)))
792 return CTL_E_INVALIDPROPERTYVALUE;
794 if (This->host) {
795 release_script_engine(This->host);
796 This->host = NULL;
799 if (!language)
800 return S_OK;
802 return init_script_host(&clsid, &This->host);
805 static HRESULT WINAPI ScriptControl_get_State(IScriptControl *iface, ScriptControlStates *p)
807 ScriptControl *This = impl_from_IScriptControl(iface);
808 TRACE("(%p)->(%p)\n", This, p);
810 if(!p)
811 return E_POINTER;
813 if(!This->host)
814 return E_FAIL;
816 *p = This->state;
817 return S_OK;
820 static HRESULT WINAPI ScriptControl_put_State(IScriptControl *iface, ScriptControlStates state)
822 ScriptControl *This = impl_from_IScriptControl(iface);
823 TRACE("(%p)->(%x)\n", This, state);
825 if(!This->host)
826 return E_FAIL;
828 if(state != Initialized && state != Connected)
829 return CTL_E_INVALIDPROPERTYVALUE;
831 This->state = state;
832 return S_OK;
835 static HRESULT WINAPI ScriptControl_put_SitehWnd(IScriptControl *iface, LONG hwnd)
837 ScriptControl *This = impl_from_IScriptControl(iface);
839 FIXME("(%p)->(%x)\n", This, hwnd);
841 return S_OK;
844 static HRESULT WINAPI ScriptControl_get_SitehWnd(IScriptControl *iface, LONG *p)
846 ScriptControl *This = impl_from_IScriptControl(iface);
847 FIXME("(%p)->(%p)\n", This, p);
848 return E_NOTIMPL;
851 static HRESULT WINAPI ScriptControl_get_Timeout(IScriptControl *iface, LONG *p)
853 ScriptControl *This = impl_from_IScriptControl(iface);
855 TRACE("(%p)->(%p)\n", This, p);
857 if (!p)
858 return E_POINTER;
860 *p = This->timeout;
861 return S_OK;
864 static HRESULT WINAPI ScriptControl_put_Timeout(IScriptControl *iface, LONG timeout)
866 ScriptControl *This = impl_from_IScriptControl(iface);
868 TRACE("(%p)->(%d)\n", This, timeout);
870 if (timeout < -1)
871 return CTL_E_INVALIDPROPERTYVALUE;
873 if (timeout != -1)
874 FIXME("execution timeout ignored\n");
876 This->timeout = timeout;
877 return S_OK;
880 static HRESULT WINAPI ScriptControl_get_AllowUI(IScriptControl *iface, VARIANT_BOOL *p)
882 ScriptControl *This = impl_from_IScriptControl(iface);
883 TRACE("(%p)->(%p)\n", This, p);
885 if(!p)
886 return E_POINTER;
888 *p = This->allow_ui;
889 return S_OK;
892 static HRESULT WINAPI ScriptControl_put_AllowUI(IScriptControl *iface, VARIANT_BOOL allow_ui)
894 ScriptControl *This = impl_from_IScriptControl(iface);
895 TRACE("(%p)->(%x)\n", This, allow_ui);
897 This->allow_ui = allow_ui;
898 return S_OK;
901 static HRESULT WINAPI ScriptControl_get_UseSafeSubset(IScriptControl *iface, VARIANT_BOOL *p)
903 ScriptControl *This = impl_from_IScriptControl(iface);
904 TRACE("(%p)->(%p)\n", This, p);
906 if(!p)
907 return E_POINTER;
909 *p = This->use_safe_subset;
910 return S_OK;
913 static HRESULT WINAPI ScriptControl_put_UseSafeSubset(IScriptControl *iface, VARIANT_BOOL use_safe_subset)
915 ScriptControl *This = impl_from_IScriptControl(iface);
916 TRACE("(%p)->(%x)\n", This, use_safe_subset);
918 This->use_safe_subset = use_safe_subset;
919 return S_OK;
922 static HRESULT WINAPI ScriptControl_get_Modules(IScriptControl *iface, IScriptModuleCollection **p)
924 ScriptControl *This = impl_from_IScriptControl(iface);
925 FIXME("(%p)->(%p)\n", This, p);
926 return E_NOTIMPL;
929 static HRESULT WINAPI ScriptControl_get_Error(IScriptControl *iface, IScriptError **p)
931 ScriptControl *This = impl_from_IScriptControl(iface);
932 FIXME("(%p)->(%p)\n", This, p);
933 return E_NOTIMPL;
936 static HRESULT WINAPI ScriptControl_get_CodeObject(IScriptControl *iface, IDispatch **p)
938 ScriptControl *This = impl_from_IScriptControl(iface);
939 FIXME("(%p)->(%p)\n", This, p);
940 return E_NOTIMPL;
943 static HRESULT WINAPI ScriptControl_get_Procedures(IScriptControl *iface, IScriptProcedureCollection **p)
945 ScriptControl *This = impl_from_IScriptControl(iface);
946 FIXME("(%p)->(%p)\n", This, p);
947 return E_NOTIMPL;
950 static HRESULT WINAPI ScriptControl__AboutBox(IScriptControl *iface)
952 ScriptControl *This = impl_from_IScriptControl(iface);
953 FIXME("(%p)\n", This);
954 return E_NOTIMPL;
957 static HRESULT WINAPI ScriptControl_AddObject(IScriptControl *iface, BSTR name, IDispatch *object, VARIANT_BOOL add_members)
959 ScriptControl *This = impl_from_IScriptControl(iface);
960 DWORD flags = SCRIPTITEM_ISVISIBLE | SCRIPTITEM_ISSOURCE;
961 struct named_item *item;
962 HRESULT hr;
964 TRACE("(%p)->(%s %p %x)\n", This, debugstr_w(name), object, add_members);
966 if (!object)
967 return E_INVALIDARG;
969 if (!This->host)
970 return E_FAIL;
972 if (host_get_named_item(This->host, name))
973 return E_INVALIDARG;
975 item = heap_alloc(sizeof(*item));
976 if (!item)
977 return E_OUTOFMEMORY;
979 item->name = SysAllocString(name);
980 IDispatch_AddRef(item->disp = object);
981 list_add_tail(&This->host->named_items, &item->entry);
983 if (add_members)
984 flags |= SCRIPTITEM_GLOBALMEMBERS;
985 hr = IActiveScript_AddNamedItem(This->host->script, name, flags);
986 if (FAILED(hr)) {
987 list_remove(&item->entry);
988 IDispatch_Release(item->disp);
989 SysFreeString(item->name);
990 heap_free(item);
991 return hr;
995 return hr;
998 static HRESULT WINAPI ScriptControl_Reset(IScriptControl *iface)
1000 ScriptControl *This = impl_from_IScriptControl(iface);
1002 TRACE("(%p)\n", This);
1004 if (!This->host)
1005 return E_FAIL;
1007 clear_named_items(This->host);
1008 return set_script_state(This->host, SCRIPTSTATE_INITIALIZED);
1011 static HRESULT parse_script_text(ScriptControl *control, BSTR script_text, DWORD flag, VARIANT *res)
1013 EXCEPINFO excepinfo;
1014 HRESULT hr;
1016 hr = start_script(control);
1017 if (FAILED(hr)) return hr;
1019 hr = IActiveScriptParse_ParseScriptText(control->host->parse, script_text, NULL,
1020 NULL, NULL, 0, 1, flag, res, &excepinfo);
1021 /* FIXME: more error handling */
1022 return hr;
1025 static HRESULT WINAPI ScriptControl_AddCode(IScriptControl *iface, BSTR code)
1027 ScriptControl *This = impl_from_IScriptControl(iface);
1029 TRACE("(%p)->(%s).\n", This, debugstr_w(code));
1031 return parse_script_text(This, code, SCRIPTTEXT_ISVISIBLE, NULL);
1034 static HRESULT WINAPI ScriptControl_Eval(IScriptControl *iface, BSTR expression, VARIANT *res)
1036 ScriptControl *This = impl_from_IScriptControl(iface);
1038 TRACE("(%p)->(%s, %p).\n", This, debugstr_w(expression), res);
1040 if (!res)
1041 return E_POINTER;
1042 V_VT(res) = VT_EMPTY;
1044 return parse_script_text(This, expression, SCRIPTTEXT_ISEXPRESSION, res);
1047 static HRESULT WINAPI ScriptControl_ExecuteStatement(IScriptControl *iface, BSTR statement)
1049 ScriptControl *This = impl_from_IScriptControl(iface);
1051 TRACE("(%p)->(%s)\n", This, debugstr_w(statement));
1053 return parse_script_text(This, statement, 0, NULL);
1056 static HRESULT WINAPI ScriptControl_Run(IScriptControl *iface, BSTR procedure_name, SAFEARRAY **parameters, VARIANT *res)
1058 ScriptControl *This = impl_from_IScriptControl(iface);
1059 IDispatchEx *dispex;
1060 IDispatch *disp;
1061 SAFEARRAY *sa;
1062 DISPPARAMS dp;
1063 DISPID dispid;
1064 HRESULT hr;
1065 UINT i;
1067 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(procedure_name), parameters, res);
1069 if (!parameters || !res) return E_POINTER;
1070 if (!(sa = *parameters)) return E_POINTER;
1072 V_VT(res) = VT_EMPTY;
1073 if (sa->cDims == 0) return DISP_E_BADINDEX;
1074 if (!(sa->fFeatures & FADF_VARIANT)) return DISP_E_BADVARTYPE;
1076 hr = start_script(This);
1077 if (FAILED(hr)) return hr;
1079 hr = get_script_dispatch(This, &disp);
1080 if (FAILED(hr)) return hr;
1082 hr = IDispatch_GetIDsOfNames(disp, &IID_NULL, &procedure_name, 1, LOCALE_USER_DEFAULT, &dispid);
1083 if (FAILED(hr)) return hr;
1085 dp.cArgs = sa->rgsabound[0].cElements;
1086 dp.rgdispidNamedArgs = NULL;
1087 dp.cNamedArgs = 0;
1088 dp.rgvarg = heap_alloc(dp.cArgs * sizeof(*dp.rgvarg));
1089 if (!dp.rgvarg) return E_OUTOFMEMORY;
1091 hr = SafeArrayLock(sa);
1092 if (SUCCEEDED(hr))
1094 /* The DISPPARAMS are stored in reverse order */
1095 for (i = 0; i < dp.cArgs; i++)
1096 dp.rgvarg[i] = *(VARIANT*)((char*)(sa->pvData) + (dp.cArgs - i - 1) * sa->cbElements);
1097 SafeArrayUnlock(sa);
1099 hr = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
1100 if (FAILED(hr))
1102 hr = IDispatch_Invoke(disp, dispid, &IID_NULL, LOCALE_USER_DEFAULT,
1103 DISPATCH_METHOD, &dp, res, NULL, NULL);
1105 else
1107 hr = IDispatchEx_InvokeEx(dispex, dispid, LOCALE_USER_DEFAULT,
1108 DISPATCH_METHOD, &dp, res, NULL, NULL);
1109 IDispatchEx_Release(dispex);
1112 heap_free(dp.rgvarg);
1114 return hr;
1117 static const IScriptControlVtbl ScriptControlVtbl = {
1118 ScriptControl_QueryInterface,
1119 ScriptControl_AddRef,
1120 ScriptControl_Release,
1121 ScriptControl_GetTypeInfoCount,
1122 ScriptControl_GetTypeInfo,
1123 ScriptControl_GetIDsOfNames,
1124 ScriptControl_Invoke,
1125 ScriptControl_get_Language,
1126 ScriptControl_put_Language,
1127 ScriptControl_get_State,
1128 ScriptControl_put_State,
1129 ScriptControl_put_SitehWnd,
1130 ScriptControl_get_SitehWnd,
1131 ScriptControl_get_Timeout,
1132 ScriptControl_put_Timeout,
1133 ScriptControl_get_AllowUI,
1134 ScriptControl_put_AllowUI,
1135 ScriptControl_get_UseSafeSubset,
1136 ScriptControl_put_UseSafeSubset,
1137 ScriptControl_get_Modules,
1138 ScriptControl_get_Error,
1139 ScriptControl_get_CodeObject,
1140 ScriptControl_get_Procedures,
1141 ScriptControl__AboutBox,
1142 ScriptControl_AddObject,
1143 ScriptControl_Reset,
1144 ScriptControl_AddCode,
1145 ScriptControl_Eval,
1146 ScriptControl_ExecuteStatement,
1147 ScriptControl_Run
1150 static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **obj)
1152 ScriptControl *This = impl_from_IOleObject(iface);
1153 return IScriptControl_QueryInterface(&This->IScriptControl_iface, riid, obj);
1156 static ULONG WINAPI OleObject_AddRef(IOleObject *iface)
1158 ScriptControl *This = impl_from_IOleObject(iface);
1159 return IScriptControl_AddRef(&This->IScriptControl_iface);
1162 static ULONG WINAPI OleObject_Release(IOleObject *iface)
1164 ScriptControl *This = impl_from_IOleObject(iface);
1165 return IScriptControl_Release(&This->IScriptControl_iface);
1168 static HRESULT WINAPI OleObject_SetClientSite(IOleObject *iface, IOleClientSite *site)
1170 ScriptControl *This = impl_from_IOleObject(iface);
1172 TRACE("(%p)->(%p)\n", This, site);
1174 if (This->site)
1175 IOleClientSite_Release(This->site);
1177 if ((This->site = site))
1178 IOleClientSite_AddRef(site);
1180 return S_OK;
1183 static HRESULT WINAPI OleObject_GetClientSite(IOleObject *iface, IOleClientSite **site)
1185 ScriptControl *This = impl_from_IOleObject(iface);
1187 TRACE("(%p)->(%p)\n", This, site);
1189 if (!site)
1190 return E_POINTER;
1192 if ((*site = This->site))
1193 IOleClientSite_AddRef(*site);
1195 return S_OK;
1198 static HRESULT WINAPI OleObject_SetHostNames(IOleObject *iface, LPCOLESTR containerapp, LPCOLESTR containerobj)
1200 ScriptControl *This = impl_from_IOleObject(iface);
1202 FIXME("(%p)->(%s %s)\n", This, debugstr_w(containerapp), debugstr_w(containerobj));
1204 return E_NOTIMPL;
1207 static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD save)
1209 ScriptControl *This = impl_from_IOleObject(iface);
1211 FIXME("(%p)->(%d)\n", This, save);
1213 return E_NOTIMPL;
1216 static HRESULT WINAPI OleObject_SetMoniker(IOleObject *iface, DWORD which, IMoniker *moniker)
1218 ScriptControl *This = impl_from_IOleObject(iface);
1220 FIXME("(%p)->(%d %p)\n", This, which, moniker);
1222 return E_NOTIMPL;
1225 static HRESULT WINAPI OleObject_GetMoniker(IOleObject *iface, DWORD assign, DWORD which, IMoniker **moniker)
1227 ScriptControl *This = impl_from_IOleObject(iface);
1229 FIXME("(%p)->(%d %d %p)\n", This, assign, which, moniker);
1231 return E_NOTIMPL;
1234 static HRESULT WINAPI OleObject_InitFromData(IOleObject *iface, IDataObject *dataobj, BOOL creation,
1235 DWORD reserved)
1237 ScriptControl *This = impl_from_IOleObject(iface);
1239 FIXME("(%p)->(%p %d %d)\n", This, dataobj, creation, reserved);
1241 return E_NOTIMPL;
1244 static HRESULT WINAPI OleObject_GetClipboardData(IOleObject *iface, DWORD reserved, IDataObject **dataobj)
1246 ScriptControl *This = impl_from_IOleObject(iface);
1248 FIXME("(%p)->(%d %p)\n", This, reserved, dataobj);
1250 return E_NOTIMPL;
1253 static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG verb, LPMSG msg, IOleClientSite *active_site,
1254 LONG index, HWND hwndParent, LPCRECT rect)
1256 ScriptControl *This = impl_from_IOleObject(iface);
1258 FIXME("(%p)->(%d %p %p %d %p %p)\n", This, verb, msg, active_site, index, hwndParent, rect);
1260 return E_NOTIMPL;
1263 static HRESULT WINAPI OleObject_EnumVerbs(IOleObject *iface, IEnumOLEVERB **enumoleverb)
1265 ScriptControl *This = impl_from_IOleObject(iface);
1267 FIXME("(%p)->(%p)\n", This, enumoleverb);
1269 return E_NOTIMPL;
1272 static HRESULT WINAPI OleObject_Update(IOleObject *iface)
1274 ScriptControl *This = impl_from_IOleObject(iface);
1276 FIXME("(%p)\n", This);
1278 return E_NOTIMPL;
1281 static HRESULT WINAPI OleObject_IsUpToDate(IOleObject *iface)
1283 ScriptControl *This = impl_from_IOleObject(iface);
1285 FIXME("(%p)\n", This);
1287 return E_NOTIMPL;
1290 static HRESULT WINAPI OleObject_GetUserClassID(IOleObject *iface, CLSID *clsid)
1292 ScriptControl *This = impl_from_IOleObject(iface);
1294 FIXME("(%p)->(%p)\n", This, clsid);
1296 return E_NOTIMPL;
1299 static HRESULT WINAPI OleObject_GetUserType(IOleObject *iface, DWORD form_of_type, LPOLESTR *usertype)
1301 ScriptControl *This = impl_from_IOleObject(iface);
1303 FIXME("(%p)->(%d %p)\n", This, form_of_type, usertype);
1305 return E_NOTIMPL;
1308 static HRESULT WINAPI OleObject_SetExtent(IOleObject *iface, DWORD aspect, SIZEL *size)
1310 ScriptControl *This = impl_from_IOleObject(iface);
1312 FIXME("(%p)->(%d %p)\n", This, aspect, size);
1314 return E_NOTIMPL;
1317 static HRESULT WINAPI OleObject_GetExtent(IOleObject *iface, DWORD aspect, SIZEL *size)
1319 ScriptControl *This = impl_from_IOleObject(iface);
1321 TRACE("(%p)->(%d %p)\n", This, aspect, size);
1323 if (aspect != DVASPECT_CONTENT)
1324 return DV_E_DVASPECT;
1326 *size = This->extent;
1327 return S_OK;
1330 static HRESULT WINAPI OleObject_Advise(IOleObject *iface, IAdviseSink *sink, DWORD *connection)
1332 ScriptControl *This = impl_from_IOleObject(iface);
1334 FIXME("(%p)->(%p %p)\n", This, sink, connection);
1336 return E_NOTIMPL;
1339 static HRESULT WINAPI OleObject_Unadvise(IOleObject *iface, DWORD connection)
1341 ScriptControl *This = impl_from_IOleObject(iface);
1343 FIXME("(%p)->(%d)\n", This, connection);
1345 return E_NOTIMPL;
1348 static HRESULT WINAPI OleObject_EnumAdvise(IOleObject *iface, IEnumSTATDATA **enumadvise)
1350 ScriptControl *This = impl_from_IOleObject(iface);
1352 FIXME("(%p)->(%p)\n", This, enumadvise);
1354 return E_NOTIMPL;
1357 static HRESULT WINAPI OleObject_GetMiscStatus(IOleObject *iface, DWORD aspect, DWORD *status)
1359 ScriptControl *This = impl_from_IOleObject(iface);
1361 TRACE("(%p)->(%d %p)\n", This, aspect, status);
1363 return OleRegGetMiscStatus(&CLSID_ScriptControl, aspect, status);
1366 static HRESULT WINAPI OleObject_SetColorScheme(IOleObject *iface, LOGPALETTE *logpal)
1368 ScriptControl *This = impl_from_IOleObject(iface);
1370 FIXME("(%p)->(%p)\n", This, logpal);
1372 return E_NOTIMPL;
1375 static const IOleObjectVtbl OleObjectVtbl = {
1376 OleObject_QueryInterface,
1377 OleObject_AddRef,
1378 OleObject_Release,
1379 OleObject_SetClientSite,
1380 OleObject_GetClientSite,
1381 OleObject_SetHostNames,
1382 OleObject_Close,
1383 OleObject_SetMoniker,
1384 OleObject_GetMoniker,
1385 OleObject_InitFromData,
1386 OleObject_GetClipboardData,
1387 OleObject_DoVerb,
1388 OleObject_EnumVerbs,
1389 OleObject_Update,
1390 OleObject_IsUpToDate,
1391 OleObject_GetUserClassID,
1392 OleObject_GetUserType,
1393 OleObject_SetExtent,
1394 OleObject_GetExtent,
1395 OleObject_Advise,
1396 OleObject_Unadvise,
1397 OleObject_EnumAdvise,
1398 OleObject_GetMiscStatus,
1399 OleObject_SetColorScheme
1402 static HRESULT WINAPI PersistStreamInit_QueryInterface(IPersistStreamInit *iface, REFIID riid, void **obj)
1404 ScriptControl *This = impl_from_IPersistStreamInit(iface);
1405 return IScriptControl_QueryInterface(&This->IScriptControl_iface, riid, obj);
1408 static ULONG WINAPI PersistStreamInit_AddRef(IPersistStreamInit *iface)
1410 ScriptControl *This = impl_from_IPersistStreamInit(iface);
1411 return IScriptControl_AddRef(&This->IScriptControl_iface);
1414 static ULONG WINAPI PersistStreamInit_Release(IPersistStreamInit *iface)
1416 ScriptControl *This = impl_from_IPersistStreamInit(iface);
1417 return IScriptControl_Release(&This->IScriptControl_iface);
1420 static HRESULT WINAPI PersistStreamInit_GetClassID(IPersistStreamInit *iface, CLSID *clsid)
1422 ScriptControl *This = impl_from_IPersistStreamInit(iface);
1424 FIXME("(%p)->(%p)\n", This, clsid);
1426 return E_NOTIMPL;
1429 static HRESULT WINAPI PersistStreamInit_IsDirty(IPersistStreamInit *iface)
1431 ScriptControl *This = impl_from_IPersistStreamInit(iface);
1433 FIXME("(%p)\n", This);
1435 return E_NOTIMPL;
1438 static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, IStream *stream)
1440 ScriptControl *This = impl_from_IPersistStreamInit(iface);
1442 FIXME("(%p)->(%p)\n", This, stream);
1444 return E_NOTIMPL;
1447 static HRESULT WINAPI PersistStreamInit_Save(IPersistStreamInit *iface, IStream *stream, BOOL clear_dirty)
1449 ScriptControl *This = impl_from_IPersistStreamInit(iface);
1451 FIXME("(%p)->(%p %d)\n", This, stream, clear_dirty);
1453 return E_NOTIMPL;
1456 static HRESULT WINAPI PersistStreamInit_GetSizeMax(IPersistStreamInit *iface, ULARGE_INTEGER *size)
1458 ScriptControl *This = impl_from_IPersistStreamInit(iface);
1460 FIXME("(%p)->(%p)\n", This, size);
1462 return E_NOTIMPL;
1465 static HRESULT WINAPI PersistStreamInit_InitNew(IPersistStreamInit *iface)
1467 ScriptControl *This = impl_from_IPersistStreamInit(iface);
1469 FIXME("(%p)\n", This);
1471 return S_OK;
1474 static const IPersistStreamInitVtbl PersistStreamInitVtbl = {
1475 PersistStreamInit_QueryInterface,
1476 PersistStreamInit_AddRef,
1477 PersistStreamInit_Release,
1478 PersistStreamInit_GetClassID,
1479 PersistStreamInit_IsDirty,
1480 PersistStreamInit_Load,
1481 PersistStreamInit_Save,
1482 PersistStreamInit_GetSizeMax,
1483 PersistStreamInit_InitNew
1486 static HRESULT WINAPI OleControl_QueryInterface(IOleControl *iface, REFIID riid, void **obj)
1488 ScriptControl *This = impl_from_IOleControl(iface);
1489 return IScriptControl_QueryInterface(&This->IScriptControl_iface, riid, obj);
1492 static ULONG WINAPI OleControl_AddRef(IOleControl *iface)
1494 ScriptControl *This = impl_from_IOleControl(iface);
1495 return IScriptControl_AddRef(&This->IScriptControl_iface);
1498 static ULONG WINAPI OleControl_Release(IOleControl *iface)
1500 ScriptControl *This = impl_from_IOleControl(iface);
1501 return IScriptControl_Release(&This->IScriptControl_iface);
1504 static HRESULT WINAPI OleControl_GetControlInfo(IOleControl *iface, CONTROLINFO *info)
1506 ScriptControl *This = impl_from_IOleControl(iface);
1508 TRACE("(%p)->(%p)\n", This, info);
1510 if (!info)
1511 return E_POINTER;
1513 info->hAccel = NULL;
1514 info->cAccel = 0;
1516 return S_OK;
1519 static HRESULT WINAPI OleControl_OnMnemonic(IOleControl *iface, MSG *msg)
1521 ScriptControl *This = impl_from_IOleControl(iface);
1523 FIXME("(%p)->(%p)\n", This, msg);
1525 return E_NOTIMPL;
1528 static HRESULT WINAPI OleControl_OnAmbientPropertyChange(IOleControl *iface, DISPID dispid)
1530 ScriptControl *This = impl_from_IOleControl(iface);
1532 FIXME("(%p)->(%#x)\n", This, dispid);
1534 return E_NOTIMPL;
1537 static HRESULT WINAPI OleControl_FreezeEvents(IOleControl *iface, BOOL freeze)
1539 ScriptControl *This = impl_from_IOleControl(iface);
1541 FIXME("(%p)->(%d)\n", This, freeze);
1543 return E_NOTIMPL;
1546 static const IOleControlVtbl OleControlVtbl = {
1547 OleControl_QueryInterface,
1548 OleControl_AddRef,
1549 OleControl_Release,
1550 OleControl_GetControlInfo,
1551 OleControl_OnMnemonic,
1552 OleControl_OnAmbientPropertyChange,
1553 OleControl_FreezeEvents
1556 static HRESULT WINAPI QuickActivate_QueryInterface(IQuickActivate *iface, REFIID riid, void **obj)
1558 ScriptControl *This = impl_from_IQuickActivate(iface);
1559 return IScriptControl_QueryInterface(&This->IScriptControl_iface, riid, obj);
1562 static ULONG WINAPI QuickActivate_AddRef(IQuickActivate *iface)
1564 ScriptControl *This = impl_from_IQuickActivate(iface);
1565 return IScriptControl_AddRef(&This->IScriptControl_iface);
1568 static ULONG WINAPI QuickActivate_Release(IQuickActivate *iface)
1570 ScriptControl *This = impl_from_IQuickActivate(iface);
1571 return IScriptControl_Release(&This->IScriptControl_iface);
1574 static HRESULT WINAPI QuickActivate_QuickActivate(IQuickActivate *iface, QACONTAINER *container, QACONTROL *control)
1576 ScriptControl *This = impl_from_IQuickActivate(iface);
1578 FIXME("(%p)->(%p %p)\n", This, container, control);
1580 return E_NOTIMPL;
1583 static HRESULT WINAPI QuickActivate_SetContentExtent(IQuickActivate *iface, SIZEL *size)
1585 ScriptControl *This = impl_from_IQuickActivate(iface);
1587 FIXME("(%p)->(%p)\n", This, size);
1589 return E_NOTIMPL;
1592 static HRESULT WINAPI QuickActivate_GetContentExtent(IQuickActivate *iface, SIZEL *size)
1594 ScriptControl *This = impl_from_IQuickActivate(iface);
1596 FIXME("(%p)->(%p)\n", This, size);
1598 return E_NOTIMPL;
1601 static const IQuickActivateVtbl QuickActivateVtbl = {
1602 QuickActivate_QueryInterface,
1603 QuickActivate_AddRef,
1604 QuickActivate_Release,
1605 QuickActivate_QuickActivate,
1606 QuickActivate_SetContentExtent,
1607 QuickActivate_GetContentExtent
1610 static HRESULT WINAPI ViewObject_QueryInterface(IViewObjectEx *iface, REFIID riid, void **obj)
1612 ScriptControl *This = impl_from_IViewObjectEx(iface);
1613 return IScriptControl_QueryInterface(&This->IScriptControl_iface, riid, obj);
1616 static ULONG WINAPI ViewObject_AddRef(IViewObjectEx *iface)
1618 ScriptControl *This = impl_from_IViewObjectEx(iface);
1619 return IScriptControl_AddRef(&This->IScriptControl_iface);
1622 static ULONG WINAPI ViewObject_Release(IViewObjectEx *iface)
1624 ScriptControl *This = impl_from_IViewObjectEx(iface);
1625 return IScriptControl_Release(&This->IScriptControl_iface);
1628 static HRESULT WINAPI ViewObject_Draw(IViewObjectEx *iface, DWORD drawaspect, LONG index, void *aspect,
1629 DVTARGETDEVICE *device, HDC target_dev, HDC hdc_draw, const RECTL *bounds, const RECTL *win_bounds,
1630 BOOL (STDMETHODCALLTYPE *fn_continue)(ULONG_PTR cont), ULONG_PTR cont)
1632 ScriptControl *This = impl_from_IViewObjectEx(iface);
1634 FIXME("(%p)->(%d %d %p %p %p %p %p %p %p %lu)\n", This, drawaspect, index, aspect, device, target_dev,
1635 hdc_draw, bounds, win_bounds, fn_continue, cont);
1637 return E_NOTIMPL;
1640 static HRESULT WINAPI ViewObject_GetColorSet(IViewObjectEx *iface, DWORD drawaspect, LONG index, void *aspect,
1641 DVTARGETDEVICE *device, HDC hic_target, LOGPALETTE **colorset)
1643 ScriptControl *This = impl_from_IViewObjectEx(iface);
1645 FIXME("(%p)->(%d %d %p %p %p %p)\n", This, drawaspect, index, aspect, device, hic_target,
1646 colorset);
1648 return E_NOTIMPL;
1651 static HRESULT WINAPI ViewObject_Freeze(IViewObjectEx *iface, DWORD drawaspect, LONG index, void *aspect,
1652 DWORD *freeze)
1654 ScriptControl *This = impl_from_IViewObjectEx(iface);
1656 FIXME("(%p)->(%d %d %p %p)\n", This, drawaspect, index, aspect, freeze);
1658 return E_NOTIMPL;
1661 static HRESULT WINAPI ViewObject_Unfreeze(IViewObjectEx *iface, DWORD freeze)
1663 ScriptControl *This = impl_from_IViewObjectEx(iface);
1665 FIXME("(%p)->(%d)\n", This, freeze);
1667 return E_NOTIMPL;
1670 static HRESULT WINAPI ViewObject_SetAdvise(IViewObjectEx *iface, DWORD aspects, DWORD flags, IAdviseSink *sink)
1672 ScriptControl *This = impl_from_IViewObjectEx(iface);
1674 TRACE("(%p)->(%d %#x %p)\n", This, aspects, flags, sink);
1676 if (aspects != DVASPECT_CONTENT)
1677 return DV_E_DVASPECT;
1679 This->view_sink_flags = flags;
1680 if (This->view_sink)
1681 IAdviseSink_Release(This->view_sink);
1682 This->view_sink = sink;
1683 if (This->view_sink)
1684 IAdviseSink_AddRef(This->view_sink);
1686 return S_OK;
1689 static HRESULT WINAPI ViewObject_GetAdvise(IViewObjectEx *iface, DWORD *aspects, DWORD *flags, IAdviseSink **sink)
1691 ScriptControl *This = impl_from_IViewObjectEx(iface);
1693 TRACE("(%p)->(%p %p %p)\n", This, aspects, flags, sink);
1695 if (aspects)
1696 *aspects = DVASPECT_CONTENT;
1697 if (flags)
1698 *flags = This->view_sink_flags;
1699 if (sink) {
1700 *sink = This->view_sink;
1701 if (*sink)
1702 IAdviseSink_AddRef(*sink);
1705 return S_OK;
1708 static HRESULT WINAPI ViewObject_GetExtent(IViewObjectEx *iface, DWORD draw_aspect, LONG index,
1709 DVTARGETDEVICE *device, SIZEL *size)
1711 ScriptControl *This = impl_from_IViewObjectEx(iface);
1713 FIXME("(%p)->(%d %d %p %p)\n", This, draw_aspect, index, device, size);
1715 return E_NOTIMPL;
1718 static HRESULT WINAPI ViewObject_GetRect(IViewObjectEx *iface, DWORD aspect, RECTL *rect)
1720 ScriptControl *This = impl_from_IViewObjectEx(iface);
1722 FIXME("(%p)->(%d %p)\n", This, aspect, rect);
1724 return E_NOTIMPL;
1727 static HRESULT WINAPI ViewObject_GetViewStatus(IViewObjectEx *iface, DWORD *status)
1729 ScriptControl *This = impl_from_IViewObjectEx(iface);
1731 TRACE("(%p)->(%p)\n", This, status);
1733 *status = VIEWSTATUS_OPAQUE;
1734 return S_OK;
1737 static HRESULT WINAPI ViewObject_QueryHitPoint(IViewObjectEx *iface, DWORD aspect, const RECT *bounds,
1738 POINT pt, LONG close_hint, DWORD *hit_result)
1740 ScriptControl *This = impl_from_IViewObjectEx(iface);
1742 FIXME("(%p)->(%d %s %s %d %p)\n", This, aspect, wine_dbgstr_rect(bounds), wine_dbgstr_point(&pt), close_hint, hit_result);
1744 return E_NOTIMPL;
1747 static HRESULT WINAPI ViewObject_QueryHitRect(IViewObjectEx *iface, DWORD aspect, const RECT *bounds,
1748 const RECT *loc, LONG close_hint, DWORD *hit_result)
1750 ScriptControl *This = impl_from_IViewObjectEx(iface);
1752 FIXME("(%p)->(%d %s %s %d %p)\n", This, aspect, wine_dbgstr_rect(bounds), wine_dbgstr_rect(loc), close_hint, hit_result);
1754 return E_NOTIMPL;
1757 static HRESULT WINAPI ViewObject_GetNaturalExtent(IViewObjectEx *iface, DWORD aspect, LONG index,
1758 DVTARGETDEVICE *device, HDC target_hdc, DVEXTENTINFO *extent_info, SIZEL *size)
1760 ScriptControl *This = impl_from_IViewObjectEx(iface);
1762 FIXME("(%p)->(%d %d %p %p %p %p)\n", This, aspect, index, device, target_hdc, extent_info, size);
1764 return E_NOTIMPL;
1767 static const IViewObjectExVtbl ViewObjectExVtbl = {
1768 ViewObject_QueryInterface,
1769 ViewObject_AddRef,
1770 ViewObject_Release,
1771 ViewObject_Draw,
1772 ViewObject_GetColorSet,
1773 ViewObject_Freeze,
1774 ViewObject_Unfreeze,
1775 ViewObject_SetAdvise,
1776 ViewObject_GetAdvise,
1777 ViewObject_GetExtent,
1778 ViewObject_GetRect,
1779 ViewObject_GetViewStatus,
1780 ViewObject_QueryHitPoint,
1781 ViewObject_QueryHitRect,
1782 ViewObject_GetNaturalExtent
1785 static HRESULT WINAPI PointerInactive_QueryInterface(IPointerInactive *iface, REFIID riid, void **obj)
1787 ScriptControl *This = impl_from_IPointerInactive(iface);
1788 return IScriptControl_QueryInterface(&This->IScriptControl_iface, riid, obj);
1791 static ULONG WINAPI PointerInactive_AddRef(IPointerInactive *iface)
1793 ScriptControl *This = impl_from_IPointerInactive(iface);
1794 return IScriptControl_AddRef(&This->IScriptControl_iface);
1797 static ULONG WINAPI PointerInactive_Release(IPointerInactive *iface)
1799 ScriptControl *This = impl_from_IPointerInactive(iface);
1800 return IScriptControl_Release(&This->IScriptControl_iface);
1803 static HRESULT WINAPI PointerInactive_GetActivationPolicy(IPointerInactive *iface, DWORD *policy)
1805 ScriptControl *This = impl_from_IPointerInactive(iface);
1807 TRACE("(%p)->(%p)\n", This, policy);
1809 if (!policy)
1810 return E_POINTER;
1812 *policy = 0;
1813 return S_OK;
1816 static HRESULT WINAPI PointerInactive_OnInactiveMouseMove(IPointerInactive *iface, const RECT *bounds,
1817 LONG x, LONG y, DWORD key_state)
1819 ScriptControl *This = impl_from_IPointerInactive(iface);
1821 FIXME("(%p)->(%s %d %d %#x)\n", This, wine_dbgstr_rect(bounds), x, y, key_state);
1823 return E_NOTIMPL;
1826 static HRESULT WINAPI PointerInactive_OnInactiveSetCursor(IPointerInactive *iface, const RECT *bounds,
1827 LONG x, LONG y, DWORD msg, BOOL set_always)
1829 ScriptControl *This = impl_from_IPointerInactive(iface);
1831 FIXME("(%p)->(%s %d %d %#x %d)\n", This, wine_dbgstr_rect(bounds), x, y, msg, set_always);
1833 return E_NOTIMPL;
1836 static const IPointerInactiveVtbl PointerInactiveVtbl = {
1837 PointerInactive_QueryInterface,
1838 PointerInactive_AddRef,
1839 PointerInactive_Release,
1840 PointerInactive_GetActivationPolicy,
1841 PointerInactive_OnInactiveMouseMove,
1842 PointerInactive_OnInactiveSetCursor
1845 static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface, REFIID riid, void **obj)
1847 ScriptControl *This = impl_from_IConnectionPointContainer(iface);
1848 return IScriptControl_QueryInterface(&This->IScriptControl_iface, riid, obj);
1851 static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
1853 ScriptControl *This = impl_from_IConnectionPointContainer(iface);
1854 return IScriptControl_AddRef(&This->IScriptControl_iface);
1857 static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
1859 ScriptControl *This = impl_from_IConnectionPointContainer(iface);
1860 return IScriptControl_Release(&This->IScriptControl_iface);
1863 static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface, IEnumConnectionPoints **enum_points)
1865 ScriptControl *This = impl_from_IConnectionPointContainer(iface);
1867 FIXME("(%p)->(%p)\n", This, enum_points);
1869 return E_NOTIMPL;
1872 static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface, REFIID riid, IConnectionPoint **cp)
1874 ScriptControl *This = impl_from_IConnectionPointContainer(iface);
1875 ConnectionPoint *iter;
1877 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), cp);
1879 *cp = NULL;
1881 for (iter = This->cp_list; iter; iter = iter->next) {
1882 if (IsEqualIID(iter->riid, riid))
1883 *cp = &iter->IConnectionPoint_iface;
1886 if (*cp) {
1887 IConnectionPoint_AddRef(*cp);
1888 return S_OK;
1891 FIXME("unsupported connection point %s\n", debugstr_guid(riid));
1892 return CONNECT_E_NOCONNECTION;
1895 static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl = {
1896 ConnectionPointContainer_QueryInterface,
1897 ConnectionPointContainer_AddRef,
1898 ConnectionPointContainer_Release,
1899 ConnectionPointContainer_EnumConnectionPoints,
1900 ConnectionPointContainer_FindConnectionPoint
1903 static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface,
1904 REFIID riid, void **ppv)
1906 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
1908 if(IsEqualGUID(&IID_IUnknown, riid)) {
1909 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1910 *ppv = &This->IConnectionPoint_iface;
1911 }else if(IsEqualGUID(&IID_IConnectionPoint, riid)) {
1912 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1913 *ppv = &This->IConnectionPoint_iface;
1914 }else {
1915 FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
1916 *ppv = NULL;
1917 return E_NOINTERFACE;
1920 IUnknown_AddRef((IUnknown*)*ppv);
1921 return S_OK;
1924 static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
1926 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
1927 return IConnectionPointContainer_AddRef(&This->control->IConnectionPointContainer_iface);
1930 static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
1932 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
1933 return IConnectionPointContainer_Release(&This->control->IConnectionPointContainer_iface);
1936 static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *iid)
1938 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
1940 TRACE("(%p)->(%p)\n", This, iid);
1942 *iid = *This->riid;
1943 return S_OK;
1946 static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
1947 IConnectionPointContainer **container)
1949 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
1951 TRACE("(%p)->(%p)\n", This, container);
1953 if (!container)
1954 return E_POINTER;
1956 *container = &This->control->IConnectionPointContainer_iface;
1957 IConnectionPointContainer_AddRef(*container);
1959 return S_OK;
1962 static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *unk_sink,
1963 DWORD *cookie)
1965 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
1967 FIXME("(%p)->(%p %p)\n", This, unk_sink, cookie);
1969 return E_NOTIMPL;
1972 static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD cookie)
1974 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
1976 FIXME("(%p)->(%d)\n", This, cookie);
1978 return E_NOTIMPL;
1981 static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
1982 IEnumConnections **ppEnum)
1984 ConnectionPoint *This = impl_from_IConnectionPoint(iface);
1986 FIXME("(%p)->(%p): stub\n", This, ppEnum);
1988 return E_NOTIMPL;
1991 static const IConnectionPointVtbl ConnectionPointVtbl =
1993 ConnectionPoint_QueryInterface,
1994 ConnectionPoint_AddRef,
1995 ConnectionPoint_Release,
1996 ConnectionPoint_GetConnectionInterface,
1997 ConnectionPoint_GetConnectionPointContainer,
1998 ConnectionPoint_Advise,
1999 ConnectionPoint_Unadvise,
2000 ConnectionPoint_EnumConnections
2003 static void ConnectionPoint_Init(ConnectionPoint *cp, ScriptControl *sc, REFIID riid)
2005 cp->IConnectionPoint_iface.lpVtbl = &ConnectionPointVtbl;
2006 cp->control = sc;
2007 cp->riid = riid;
2009 cp->next = sc->cp_list;
2010 sc->cp_list = cp;
2013 static HRESULT WINAPI ScriptControl_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
2015 ScriptControl *script_control;
2016 DWORD dpi_x, dpi_y;
2017 HRESULT hres;
2018 HDC hdc;
2020 TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
2022 script_control = heap_alloc(sizeof(*script_control));
2023 if(!script_control)
2024 return E_OUTOFMEMORY;
2026 script_control->IScriptControl_iface.lpVtbl = &ScriptControlVtbl;
2027 script_control->IPersistStreamInit_iface.lpVtbl = &PersistStreamInitVtbl;
2028 script_control->IOleObject_iface.lpVtbl = &OleObjectVtbl;
2029 script_control->IOleControl_iface.lpVtbl = &OleControlVtbl;
2030 script_control->IQuickActivate_iface.lpVtbl = &QuickActivateVtbl;
2031 script_control->IViewObjectEx_iface.lpVtbl = &ViewObjectExVtbl;
2032 script_control->IPointerInactive_iface.lpVtbl = &PointerInactiveVtbl;
2033 script_control->IConnectionPointContainer_iface.lpVtbl = &ConnectionPointContainerVtbl;
2034 script_control->ref = 1;
2035 script_control->site = NULL;
2036 script_control->cp_list = NULL;
2037 script_control->host = NULL;
2038 script_control->timeout = 10000;
2039 script_control->view_sink_flags = 0;
2040 script_control->view_sink = NULL;
2041 script_control->allow_ui = VARIANT_TRUE;
2042 script_control->use_safe_subset = VARIANT_FALSE;
2043 script_control->state = Initialized;
2045 ConnectionPoint_Init(&script_control->cp_scsource, script_control, &DIID_DScriptControlSource);
2046 ConnectionPoint_Init(&script_control->cp_propnotif, script_control, &IID_IPropertyNotifySink);
2048 hdc = GetDC(0);
2049 dpi_x = GetDeviceCaps(hdc, LOGPIXELSX);
2050 dpi_y = GetDeviceCaps(hdc, LOGPIXELSY);
2051 ReleaseDC(0, hdc);
2053 script_control->extent.cx = MulDiv(38, 2540, dpi_x);
2054 script_control->extent.cy = MulDiv(38, 2540, dpi_y);
2056 hres = IScriptControl_QueryInterface(&script_control->IScriptControl_iface, riid, ppv);
2057 IScriptControl_Release(&script_control->IScriptControl_iface);
2058 return hres;
2061 /******************************************************************
2062 * DllMain (msscript.ocx.@)
2064 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
2066 TRACE("(%p %d %p)\n", instance, reason, reserved);
2068 switch(reason) {
2069 case DLL_WINE_PREATTACH:
2070 return FALSE; /* prefer native version */
2071 case DLL_PROCESS_ATTACH:
2072 msscript_instance = instance;
2073 DisableThreadLibraryCalls(instance);
2074 break;
2075 case DLL_PROCESS_DETACH:
2076 if(!reserved)
2077 release_typelib();
2078 break;
2081 return TRUE;
2084 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
2086 *ppv = NULL;
2088 if(IsEqualGUID(&IID_IUnknown, riid)) {
2089 TRACE("(%p)->(IID_IUnknown %p)\n", iface, ppv);
2090 *ppv = iface;
2091 }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
2092 TRACE("(%p)->(IID_IClassFactory %p)\n", iface, ppv);
2093 *ppv = iface;
2096 if(*ppv) {
2097 IUnknown_AddRef((IUnknown*)*ppv);
2098 return S_OK;
2101 WARN("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
2102 return E_NOINTERFACE;
2105 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
2107 TRACE("(%p)\n", iface);
2108 return 2;
2111 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
2113 TRACE("(%p)\n", iface);
2114 return 1;
2117 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
2119 TRACE("(%p)->(%x)\n", iface, fLock);
2120 return S_OK;
2123 static const IClassFactoryVtbl ScriptControlFactoryVtbl = {
2124 ClassFactory_QueryInterface,
2125 ClassFactory_AddRef,
2126 ClassFactory_Release,
2127 ScriptControl_CreateInstance,
2128 ClassFactory_LockServer
2131 static IClassFactory ScriptControlFactory = { &ScriptControlFactoryVtbl };
2133 /***********************************************************************
2134 * DllGetClassObject (msscript.ocx.@)
2136 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
2138 if(IsEqualGUID(&CLSID_ScriptControl, rclsid)) {
2139 TRACE("(CLSID_ScriptControl %s %p)\n", debugstr_guid(riid), ppv);
2140 return IClassFactory_QueryInterface(&ScriptControlFactory, riid, ppv);
2143 FIXME("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
2144 return CLASS_E_CLASSNOTAVAILABLE;
2147 /***********************************************************************
2148 * DllCanUnloadNow (msscript.ocx.@)
2150 HRESULT WINAPI DllCanUnloadNow(void)
2152 TRACE("\n");
2153 return S_FALSE;
2156 /***********************************************************************
2157 * DllRegisterServer (msscript.ocx.@)
2159 HRESULT WINAPI DllRegisterServer(void)
2161 TRACE("()\n");
2162 return __wine_register_resources(msscript_instance);
2165 /***********************************************************************
2166 * DllUnregisterServer (msscript.ocx.@)
2168 HRESULT WINAPI DllUnregisterServer(void)
2170 TRACE("()\n");
2171 return __wine_unregister_resources(msscript_instance);