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
30 #include "wine/debug.h"
31 #include "wine/list.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(msscript
);
37 #define IActiveScriptParse_Release IActiveScriptParse64_Release
38 #define IActiveScriptParse_InitNew IActiveScriptParse64_InitNew
39 #define IActiveScriptParse_ParseScriptText IActiveScriptParse64_ParseScriptText
43 #define IActiveScriptParse_Release IActiveScriptParse32_Release
44 #define IActiveScriptParse_InitNew IActiveScriptParse32_InitNew
45 #define IActiveScriptParse_ParseScriptText IActiveScriptParse32_ParseScriptText
50 typedef struct ConnectionPoint ConnectionPoint
;
52 struct ConnectionPoint
{
53 IConnectionPoint IConnectionPoint_iface
;
54 ScriptControl
*control
;
56 ConnectionPoint
*next
;
65 typedef struct ScriptHost
{
66 IActiveScriptSite IActiveScriptSite_iface
;
67 IActiveScriptSiteWindow IActiveScriptSiteWindow_iface
;
68 IServiceProvider IServiceProvider_iface
;
71 IActiveScript
*script
;
72 IActiveScriptParse
*parse
;
75 struct list named_items
;
78 struct ScriptControl
{
79 IScriptControl IScriptControl_iface
;
80 IPersistStreamInit IPersistStreamInit_iface
;
81 IOleObject IOleObject_iface
;
82 IOleControl IOleControl_iface
;
83 IQuickActivate IQuickActivate_iface
;
84 IViewObjectEx IViewObjectEx_iface
;
85 IPointerInactive IPointerInactive_iface
;
86 IConnectionPointContainer IConnectionPointContainer_iface
;
92 /* connection points */
93 ConnectionPoint
*cp_list
;
94 ConnectionPoint cp_scsource
;
95 ConnectionPoint cp_propnotif
;
97 /* IViewObject sink */
98 IAdviseSink
*view_sink
;
99 DWORD view_sink_flags
;
104 static HINSTANCE msscript_instance
;
106 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len
)
108 return HeapAlloc(GetProcessHeap(), 0, len
);
111 static inline BOOL
heap_free(void *mem
)
113 return HeapFree(GetProcessHeap(), 0, mem
);
121 static ITypeLib
*typelib
;
122 static ITypeInfo
*typeinfos
[LAST_tid
];
124 static REFIID tid_ids
[] = {
128 static HRESULT
load_typelib(void)
133 hres
= LoadRegTypeLib(&LIBID_MSScriptControl
, 1, 0, LOCALE_SYSTEM_DEFAULT
, &tl
);
135 ERR("LoadRegTypeLib failed: %08x\n", hres
);
139 if(InterlockedCompareExchangePointer((void**)&typelib
, tl
, NULL
))
140 ITypeLib_Release(tl
);
144 static HRESULT
get_typeinfo(tid_t tid
, ITypeInfo
**typeinfo
)
149 hres
= load_typelib();
153 if(!typeinfos
[tid
]) {
156 hres
= ITypeLib_GetTypeInfoOfGuid(typelib
, tid_ids
[tid
], &ti
);
158 ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids
[tid
]), hres
);
162 if(InterlockedCompareExchangePointer((void**)(typeinfos
+tid
), ti
, NULL
))
163 ITypeInfo_Release(ti
);
166 *typeinfo
= typeinfos
[tid
];
167 ITypeInfo_AddRef(typeinfos
[tid
]);
171 static void release_typelib(void)
178 for(i
=0; i
< sizeof(typeinfos
)/sizeof(*typeinfos
); i
++)
180 ITypeInfo_Release(typeinfos
[i
]);
182 ITypeLib_Release(typelib
);
185 static void clear_named_items(ScriptHost
*host
)
187 struct named_item
*item
, *item1
;
188 LIST_FOR_EACH_ENTRY_SAFE(item
, item1
, &host
->named_items
, struct named_item
, entry
) {
189 list_remove(&item
->entry
);
190 SysFreeString(item
->name
);
191 IDispatch_Release(item
->disp
);
196 static struct named_item
*host_get_named_item(ScriptHost
*host
, const WCHAR
*nameW
)
198 struct named_item
*item
;
200 LIST_FOR_EACH_ENTRY(item
, &host
->named_items
, struct named_item
, entry
) {
201 if (!lstrcmpW(item
->name
, nameW
))
208 static inline ScriptControl
*impl_from_IScriptControl(IScriptControl
*iface
)
210 return CONTAINING_RECORD(iface
, ScriptControl
, IScriptControl_iface
);
213 static inline ScriptControl
*impl_from_IOleObject(IOleObject
*iface
)
215 return CONTAINING_RECORD(iface
, ScriptControl
, IOleObject_iface
);
218 static inline ScriptControl
*impl_from_IPersistStreamInit(IPersistStreamInit
*iface
)
220 return CONTAINING_RECORD(iface
, ScriptControl
, IPersistStreamInit_iface
);
223 static inline ScriptControl
*impl_from_IOleControl(IOleControl
*iface
)
225 return CONTAINING_RECORD(iface
, ScriptControl
, IOleControl_iface
);
228 static inline ScriptControl
*impl_from_IQuickActivate(IQuickActivate
*iface
)
230 return CONTAINING_RECORD(iface
, ScriptControl
, IQuickActivate_iface
);
233 static inline ScriptControl
*impl_from_IViewObjectEx(IViewObjectEx
*iface
)
235 return CONTAINING_RECORD(iface
, ScriptControl
, IViewObjectEx_iface
);
238 static inline ScriptControl
*impl_from_IPointerInactive(IPointerInactive
*iface
)
240 return CONTAINING_RECORD(iface
, ScriptControl
, IPointerInactive_iface
);
243 static inline ScriptControl
*impl_from_IConnectionPointContainer(IConnectionPointContainer
*iface
)
245 return CONTAINING_RECORD(iface
, ScriptControl
, IConnectionPointContainer_iface
);
248 static inline ConnectionPoint
*impl_from_IConnectionPoint(IConnectionPoint
*iface
)
250 return CONTAINING_RECORD(iface
, ConnectionPoint
, IConnectionPoint_iface
);
253 static inline ScriptHost
*impl_from_IActiveScriptSite(IActiveScriptSite
*iface
)
255 return CONTAINING_RECORD(iface
, ScriptHost
, IActiveScriptSite_iface
);
258 static inline ScriptHost
*impl_from_IActiveScriptSiteWindow(IActiveScriptSiteWindow
*iface
)
260 return CONTAINING_RECORD(iface
, ScriptHost
, IActiveScriptSiteWindow_iface
);
263 static inline ScriptHost
*impl_from_IServiceProvider(IServiceProvider
*iface
)
265 return CONTAINING_RECORD(iface
, ScriptHost
, IServiceProvider_iface
);
268 /* IActiveScriptSite */
269 static HRESULT WINAPI
ActiveScriptSite_QueryInterface(IActiveScriptSite
*iface
, REFIID riid
, void **ppv
)
271 ScriptHost
*This
= impl_from_IActiveScriptSite(iface
);
273 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
274 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
275 *ppv
= &This
->IActiveScriptSite_iface
;
276 }else if(IsEqualGUID(&IID_IActiveScriptSite
, riid
)) {
277 TRACE("(%p)->(IID_IActiveScriptSite %p)\n", This
, ppv
);
278 *ppv
= &This
->IActiveScriptSite_iface
;
279 }else if(IsEqualGUID(&IID_IActiveScriptSiteWindow
, riid
)) {
280 TRACE("(%p)->(IID_IActiveScriptSiteWindow %p)\n", This
, ppv
);
281 *ppv
= &This
->IActiveScriptSiteWindow_iface
;
282 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
283 TRACE("(%p)->(IID_IServiceProvider %p)\n", This
, ppv
);
284 *ppv
= &This
->IServiceProvider_iface
;
286 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
288 return E_NOINTERFACE
;
291 IUnknown_AddRef((IUnknown
*)*ppv
);
295 static ULONG WINAPI
ActiveScriptSite_AddRef(IActiveScriptSite
*iface
)
297 ScriptHost
*This
= impl_from_IActiveScriptSite(iface
);
298 LONG ref
= InterlockedIncrement(&This
->ref
);
300 TRACE("(%p) ref=%d\n", This
, ref
);
305 static void release_script_engine(ScriptHost
*host
)
308 IActiveScript_Close(host
->script
);
309 IActiveScript_Release(host
->script
);
313 IActiveScriptParse_Release(host
->parse
);
318 IActiveScriptSite_Release(&host
->IActiveScriptSite_iface
);
321 static ULONG WINAPI
ActiveScriptSite_Release(IActiveScriptSite
*iface
)
323 ScriptHost
*This
= impl_from_IActiveScriptSite(iface
);
324 LONG ref
= InterlockedDecrement(&This
->ref
);
326 TRACE("(%p) ref=%d\n", This
, ref
);
329 clear_named_items(This
);
336 static HRESULT WINAPI
ActiveScriptSite_GetLCID(IActiveScriptSite
*iface
, LCID
*lcid
)
338 ScriptHost
*This
= impl_from_IActiveScriptSite(iface
);
340 TRACE("(%p, %p)\n", This
, lcid
);
342 *lcid
= GetUserDefaultLCID();
346 static HRESULT WINAPI
ActiveScriptSite_GetItemInfo(IActiveScriptSite
*iface
, LPCOLESTR name
, DWORD mask
,
347 IUnknown
**unk
, ITypeInfo
**ti
)
349 ScriptHost
*This
= impl_from_IActiveScriptSite(iface
);
350 struct named_item
*item
;
352 TRACE("(%p, %s, %#x, %p, %p)\n", This
, debugstr_w(name
), mask
, unk
, ti
);
354 item
= host_get_named_item(This
, name
);
356 return TYPE_E_ELEMENTNOTFOUND
;
358 if (mask
!= SCRIPTINFO_IUNKNOWN
) {
359 FIXME("mask %#x is not supported\n", mask
);
363 *unk
= (IUnknown
*)item
->disp
;
364 IUnknown_AddRef(*unk
);
369 static HRESULT WINAPI
ActiveScriptSite_GetDocVersionString(IActiveScriptSite
*iface
, BSTR
*version
)
371 ScriptHost
*This
= impl_from_IActiveScriptSite(iface
);
373 FIXME("(%p, %p)\n", This
, version
);
378 static HRESULT WINAPI
ActiveScriptSite_OnScriptTerminate(IActiveScriptSite
*iface
, const VARIANT
*result
,
381 ScriptHost
*This
= impl_from_IActiveScriptSite(iface
);
383 FIXME("(%p, %s, %p)\n", This
, debugstr_variant(result
), ei
);
388 static HRESULT WINAPI
ActiveScriptSite_OnStateChange(IActiveScriptSite
*iface
, SCRIPTSTATE state
)
390 ScriptHost
*This
= impl_from_IActiveScriptSite(iface
);
392 FIXME("(%p, %d)\n", This
, state
);
397 static HRESULT WINAPI
ActiveScriptSite_OnScriptError(IActiveScriptSite
*iface
, IActiveScriptError
*script_error
)
399 ScriptHost
*This
= impl_from_IActiveScriptSite(iface
);
401 FIXME("(%p, %p)\n", This
, script_error
);
406 static HRESULT WINAPI
ActiveScriptSite_OnEnterScript(IActiveScriptSite
*iface
)
408 ScriptHost
*This
= impl_from_IActiveScriptSite(iface
);
410 FIXME("(%p)\n", This
);
415 static HRESULT WINAPI
ActiveScriptSite_OnLeaveScript(IActiveScriptSite
*iface
)
417 ScriptHost
*This
= impl_from_IActiveScriptSite(iface
);
419 FIXME("(%p)\n", This
);
424 static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl
= {
425 ActiveScriptSite_QueryInterface
,
426 ActiveScriptSite_AddRef
,
427 ActiveScriptSite_Release
,
428 ActiveScriptSite_GetLCID
,
429 ActiveScriptSite_GetItemInfo
,
430 ActiveScriptSite_GetDocVersionString
,
431 ActiveScriptSite_OnScriptTerminate
,
432 ActiveScriptSite_OnStateChange
,
433 ActiveScriptSite_OnScriptError
,
434 ActiveScriptSite_OnEnterScript
,
435 ActiveScriptSite_OnLeaveScript
438 /* IActiveScriptSiteWindow */
439 static HRESULT WINAPI
ActiveScriptSiteWindow_QueryInterface(IActiveScriptSiteWindow
*iface
, REFIID riid
, void **obj
)
441 ScriptHost
*This
= impl_from_IActiveScriptSiteWindow(iface
);
442 return IActiveScriptSite_QueryInterface(&This
->IActiveScriptSite_iface
, riid
, obj
);
445 static ULONG WINAPI
ActiveScriptSiteWindow_AddRef(IActiveScriptSiteWindow
*iface
)
447 ScriptHost
*This
= impl_from_IActiveScriptSiteWindow(iface
);
448 return IActiveScriptSite_AddRef(&This
->IActiveScriptSite_iface
);
451 static ULONG WINAPI
ActiveScriptSiteWindow_Release(IActiveScriptSiteWindow
*iface
)
453 ScriptHost
*This
= impl_from_IActiveScriptSiteWindow(iface
);
454 return IActiveScriptSite_Release(&This
->IActiveScriptSite_iface
);
457 static HRESULT WINAPI
ActiveScriptSiteWindow_GetWindow(IActiveScriptSiteWindow
*iface
, HWND
*hwnd
)
459 ScriptHost
*This
= impl_from_IActiveScriptSiteWindow(iface
);
461 FIXME("(%p, %p)\n", This
, hwnd
);
466 static HRESULT WINAPI
ActiveScriptSiteWindow_EnableModeless(IActiveScriptSiteWindow
*iface
, BOOL enable
)
468 ScriptHost
*This
= impl_from_IActiveScriptSiteWindow(iface
);
470 FIXME("(%p, %d)\n", This
, enable
);
475 static const IActiveScriptSiteWindowVtbl ActiveScriptSiteWindowVtbl
= {
476 ActiveScriptSiteWindow_QueryInterface
,
477 ActiveScriptSiteWindow_AddRef
,
478 ActiveScriptSiteWindow_Release
,
479 ActiveScriptSiteWindow_GetWindow
,
480 ActiveScriptSiteWindow_EnableModeless
483 /* IServiceProvider */
484 static HRESULT WINAPI
ServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **obj
)
486 ScriptHost
*This
= impl_from_IServiceProvider(iface
);
487 return IActiveScriptSite_QueryInterface(&This
->IActiveScriptSite_iface
, riid
, obj
);
490 static ULONG WINAPI
ServiceProvider_AddRef(IServiceProvider
*iface
)
492 ScriptHost
*This
= impl_from_IServiceProvider(iface
);
493 return IActiveScriptSite_AddRef(&This
->IActiveScriptSite_iface
);
496 static ULONG WINAPI
ServiceProvider_Release(IServiceProvider
*iface
)
498 ScriptHost
*This
= impl_from_IServiceProvider(iface
);
499 return IActiveScriptSite_Release(&This
->IActiveScriptSite_iface
);
502 static HRESULT WINAPI
ServiceProvider_QueryService(IServiceProvider
*iface
, REFGUID service
,
503 REFIID riid
, void **obj
)
505 ScriptHost
*This
= impl_from_IServiceProvider(iface
);
507 FIXME("(%p)->(%s %s %p)\n", This
, debugstr_guid(service
), debugstr_guid(riid
), obj
);
512 static const IServiceProviderVtbl ServiceProviderVtbl
= {
513 ServiceProvider_QueryInterface
,
514 ServiceProvider_AddRef
,
515 ServiceProvider_Release
,
516 ServiceProvider_QueryService
519 static HRESULT
init_script_host(const CLSID
*clsid
, ScriptHost
**ret
)
521 IObjectSafety
*objsafety
;
527 host
= heap_alloc(sizeof(*host
));
529 return E_OUTOFMEMORY
;
531 host
->IActiveScriptSite_iface
.lpVtbl
= &ActiveScriptSiteVtbl
;
532 host
->IActiveScriptSiteWindow_iface
.lpVtbl
= &ActiveScriptSiteWindowVtbl
;
533 host
->IServiceProvider_iface
.lpVtbl
= &ServiceProviderVtbl
;
537 host
->clsid
= *clsid
;
538 list_init(&host
->named_items
);
540 hr
= CoCreateInstance(&host
->clsid
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
541 &IID_IActiveScript
, (void**)&host
->script
);
543 WARN("Failed to create an instance for %s, %#x\n", debugstr_guid(clsid
), hr
);
547 hr
= IActiveScript_QueryInterface(host
->script
, &IID_IObjectSafety
, (void**)&objsafety
);
549 FIXME("Could not get IObjectSafety, %#x\n", hr
);
553 hr
= IObjectSafety_SetInterfaceSafetyOptions(objsafety
, &IID_IActiveScriptParse
, INTERFACESAFE_FOR_UNTRUSTED_DATA
, 0);
554 IObjectSafety_Release(objsafety
);
556 FIXME("SetInterfaceSafetyOptions failed, %#x\n", hr
);
560 hr
= IActiveScript_SetScriptSite(host
->script
, &host
->IActiveScriptSite_iface
);
562 WARN("SetScriptSite failed, %#x\n", hr
);
566 hr
= IActiveScript_QueryInterface(host
->script
, &IID_IActiveScriptParse
, (void**)&host
->parse
);
568 WARN("Failed to get IActiveScriptParse, %#x\n", hr
);
572 hr
= IActiveScriptParse_InitNew(host
->parse
);
574 WARN("InitNew failed, %#x\n", hr
);
582 release_script_engine(host
);
586 static HRESULT WINAPI
ScriptControl_QueryInterface(IScriptControl
*iface
, REFIID riid
, void **ppv
)
588 ScriptControl
*This
= impl_from_IScriptControl(iface
);
590 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
591 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
592 *ppv
= &This
->IScriptControl_iface
;
593 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
594 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
595 *ppv
= &This
->IScriptControl_iface
;
596 }else if(IsEqualGUID(&IID_IScriptControl
, riid
)) {
597 TRACE("(%p)->(IID_IScriptControl %p)\n", This
, ppv
);
598 *ppv
= &This
->IScriptControl_iface
;
599 }else if(IsEqualGUID(&IID_IOleObject
, riid
)) {
600 TRACE("(%p)->(IID_IOleObject %p)\n", This
, ppv
);
601 *ppv
= &This
->IOleObject_iface
;
602 }else if(IsEqualGUID(&IID_IPersistStreamInit
, riid
)) {
603 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This
, ppv
);
604 *ppv
= &This
->IPersistStreamInit_iface
;
605 }else if(IsEqualGUID(&IID_IPersist
, riid
)) {
606 TRACE("(%p)->(IID_IPersist %p)\n", This
, ppv
);
607 *ppv
= &This
->IPersistStreamInit_iface
;
608 }else if(IsEqualGUID(&IID_IOleControl
, riid
)) {
609 TRACE("(%p)->(IID_IOleControl %p)\n", This
, ppv
);
610 *ppv
= &This
->IOleControl_iface
;
611 }else if(IsEqualGUID(&IID_IQuickActivate
, riid
)) {
612 TRACE("(%p)->(IID_IQuickActivate %p)\n", This
, ppv
);
613 *ppv
= &This
->IQuickActivate_iface
;
614 }else if(IsEqualGUID(&IID_IViewObject
, riid
)) {
615 TRACE("(%p)->(IID_IViewObject %p)\n", This
, ppv
);
616 *ppv
= &This
->IViewObjectEx_iface
;
617 }else if(IsEqualGUID(&IID_IViewObject2
, riid
)) {
618 TRACE("(%p)->(IID_IViewObject2 %p)\n", This
, ppv
);
619 *ppv
= &This
->IViewObjectEx_iface
;
620 }else if(IsEqualGUID(&IID_IViewObjectEx
, riid
)) {
621 TRACE("(%p)->(IID_IViewObjectEx %p)\n", This
, ppv
);
622 *ppv
= &This
->IViewObjectEx_iface
;
623 }else if(IsEqualGUID(&IID_IPointerInactive
, riid
)) {
624 TRACE("(%p)->(IID_IPointerInactive %p)\n", This
, ppv
);
625 *ppv
= &This
->IPointerInactive_iface
;
626 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
627 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
628 *ppv
= &This
->IConnectionPointContainer_iface
;
630 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
632 return E_NOINTERFACE
;
635 IUnknown_AddRef((IUnknown
*)*ppv
);
639 static ULONG WINAPI
ScriptControl_AddRef(IScriptControl
*iface
)
641 ScriptControl
*This
= impl_from_IScriptControl(iface
);
642 LONG ref
= InterlockedIncrement(&This
->ref
);
644 TRACE("(%p) ref=%d\n", This
, ref
);
649 static ULONG WINAPI
ScriptControl_Release(IScriptControl
*iface
)
651 ScriptControl
*This
= impl_from_IScriptControl(iface
);
652 LONG ref
= InterlockedDecrement(&This
->ref
);
654 TRACE("(%p) ref=%d\n", This
, ref
);
658 IOleClientSite_Release(This
->site
);
660 release_script_engine(This
->host
);
667 static HRESULT WINAPI
ScriptControl_GetTypeInfoCount(IScriptControl
*iface
, UINT
*pctinfo
)
669 ScriptControl
*This
= impl_from_IScriptControl(iface
);
670 TRACE("(%p)->(%p)\n", This
, pctinfo
);
675 static HRESULT WINAPI
ScriptControl_GetTypeInfo(IScriptControl
*iface
, UINT iTInfo
,
676 LCID lcid
, ITypeInfo
**ppTInfo
)
678 ScriptControl
*This
= impl_from_IScriptControl(iface
);
679 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
680 return get_typeinfo(IScriptControl_tid
, ppTInfo
);
683 static HRESULT WINAPI
ScriptControl_GetIDsOfNames(IScriptControl
*iface
, REFIID riid
,
684 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
686 ScriptControl
*This
= impl_from_IScriptControl(iface
);
690 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
692 hres
= get_typeinfo(IScriptControl_tid
, &typeinfo
);
693 if(SUCCEEDED(hres
)) {
694 hres
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
695 ITypeInfo_Release(typeinfo
);
701 static HRESULT WINAPI
ScriptControl_Invoke(IScriptControl
*iface
, DISPID dispIdMember
,
702 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
,
703 EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
705 ScriptControl
*This
= impl_from_IScriptControl(iface
);
709 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
710 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
712 hres
= get_typeinfo(IScriptControl_tid
, &typeinfo
);
713 if(SUCCEEDED(hres
)) {
714 hres
= ITypeInfo_Invoke(typeinfo
, iface
, dispIdMember
, wFlags
,
715 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
716 ITypeInfo_Release(typeinfo
);
722 static HRESULT WINAPI
ScriptControl_get_Language(IScriptControl
*iface
, BSTR
*p
)
724 ScriptControl
*This
= impl_from_IScriptControl(iface
);
728 TRACE("(%p)->(%p)\n", This
, p
);
738 hr
= ProgIDFromCLSID(&This
->host
->clsid
, &progidW
);
742 *p
= SysAllocString(progidW
);
743 CoTaskMemFree(progidW
);
744 return *p
? S_OK
: E_OUTOFMEMORY
;
747 static HRESULT WINAPI
ScriptControl_put_Language(IScriptControl
*iface
, BSTR language
)
749 ScriptControl
*This
= impl_from_IScriptControl(iface
);
752 TRACE("(%p)->(%s)\n", This
, debugstr_w(language
));
754 if (language
&& FAILED(CLSIDFromProgID(language
, &clsid
)))
755 return CTL_E_INVALIDPROPERTYVALUE
;
758 release_script_engine(This
->host
);
765 return init_script_host(&clsid
, &This
->host
);
768 static HRESULT WINAPI
ScriptControl_get_State(IScriptControl
*iface
, ScriptControlStates
*p
)
770 ScriptControl
*This
= impl_from_IScriptControl(iface
);
771 FIXME("(%p)->(%p)\n", This
, p
);
775 static HRESULT WINAPI
ScriptControl_put_State(IScriptControl
*iface
, ScriptControlStates state
)
777 ScriptControl
*This
= impl_from_IScriptControl(iface
);
778 FIXME("(%p)->(%x)\n", This
, state
);
782 static HRESULT WINAPI
ScriptControl_put_SitehWnd(IScriptControl
*iface
, LONG hwnd
)
784 ScriptControl
*This
= impl_from_IScriptControl(iface
);
785 FIXME("(%p)->(%x)\n", This
, hwnd
);
789 static HRESULT WINAPI
ScriptControl_get_SitehWnd(IScriptControl
*iface
, LONG
*p
)
791 ScriptControl
*This
= impl_from_IScriptControl(iface
);
792 FIXME("(%p)->(%p)\n", This
, p
);
796 static HRESULT WINAPI
ScriptControl_get_Timeout(IScriptControl
*iface
, LONG
*p
)
798 ScriptControl
*This
= impl_from_IScriptControl(iface
);
800 TRACE("(%p)->(%p)\n", This
, p
);
809 static HRESULT WINAPI
ScriptControl_put_Timeout(IScriptControl
*iface
, LONG timeout
)
811 ScriptControl
*This
= impl_from_IScriptControl(iface
);
813 TRACE("(%p)->(%d)\n", This
, timeout
);
816 return CTL_E_INVALIDPROPERTYVALUE
;
819 FIXME("execution timeout ignored\n");
821 This
->timeout
= timeout
;
825 static HRESULT WINAPI
ScriptControl_get_AllowUI(IScriptControl
*iface
, VARIANT_BOOL
*p
)
827 ScriptControl
*This
= impl_from_IScriptControl(iface
);
828 FIXME("(%p)->(%p)\n", This
, p
);
832 static HRESULT WINAPI
ScriptControl_put_AllowUI(IScriptControl
*iface
, VARIANT_BOOL allow_ui
)
834 ScriptControl
*This
= impl_from_IScriptControl(iface
);
835 FIXME("(%p)->(%x)\n", This
, allow_ui
);
839 static HRESULT WINAPI
ScriptControl_get_UseSafeSubset(IScriptControl
*iface
, VARIANT_BOOL
*p
)
841 ScriptControl
*This
= impl_from_IScriptControl(iface
);
842 FIXME("(%p)->(%p)\n", This
, p
);
846 static HRESULT WINAPI
ScriptControl_put_UseSafeSubset(IScriptControl
*iface
, VARIANT_BOOL v
)
848 ScriptControl
*This
= impl_from_IScriptControl(iface
);
849 FIXME("(%p)->(%x)\n", This
, v
);
853 static HRESULT WINAPI
ScriptControl_get_Modules(IScriptControl
*iface
, IScriptModuleCollection
**p
)
855 ScriptControl
*This
= impl_from_IScriptControl(iface
);
856 FIXME("(%p)->(%p)\n", This
, p
);
860 static HRESULT WINAPI
ScriptControl_get_Error(IScriptControl
*iface
, IScriptError
**p
)
862 ScriptControl
*This
= impl_from_IScriptControl(iface
);
863 FIXME("(%p)->(%p)\n", This
, p
);
867 static HRESULT WINAPI
ScriptControl_get_CodeObject(IScriptControl
*iface
, IDispatch
**p
)
869 ScriptControl
*This
= impl_from_IScriptControl(iface
);
870 FIXME("(%p)->(%p)\n", This
, p
);
874 static HRESULT WINAPI
ScriptControl_get_Procedures(IScriptControl
*iface
, IScriptProcedureCollection
**p
)
876 ScriptControl
*This
= impl_from_IScriptControl(iface
);
877 FIXME("(%p)->(%p)\n", This
, p
);
881 static HRESULT WINAPI
ScriptControl__AboutBox(IScriptControl
*iface
)
883 ScriptControl
*This
= impl_from_IScriptControl(iface
);
884 FIXME("(%p)\n", This
);
888 static HRESULT WINAPI
ScriptControl_AddObject(IScriptControl
*iface
, BSTR name
, IDispatch
*object
, VARIANT_BOOL add_members
)
890 ScriptControl
*This
= impl_from_IScriptControl(iface
);
891 DWORD flags
= SCRIPTITEM_ISVISIBLE
| SCRIPTITEM_ISSOURCE
;
892 struct named_item
*item
;
895 TRACE("(%p)->(%s %p %x)\n", This
, debugstr_w(name
), object
, add_members
);
903 if (host_get_named_item(This
->host
, name
))
906 item
= heap_alloc(sizeof(*item
));
908 return E_OUTOFMEMORY
;
910 item
->name
= SysAllocString(name
);
911 IDispatch_AddRef(item
->disp
= object
);
912 list_add_tail(&This
->host
->named_items
, &item
->entry
);
915 flags
|= SCRIPTITEM_GLOBALMEMBERS
;
916 hr
= IActiveScript_AddNamedItem(This
->host
->script
, name
, flags
);
918 list_remove(&item
->entry
);
919 IDispatch_Release(item
->disp
);
920 SysFreeString(item
->name
);
929 static HRESULT WINAPI
ScriptControl_Reset(IScriptControl
*iface
)
931 ScriptControl
*This
= impl_from_IScriptControl(iface
);
933 TRACE("(%p)\n", This
);
938 clear_named_items(This
->host
);
939 return IActiveScript_SetScriptState(This
->host
->script
, SCRIPTSTATE_INITIALIZED
);
942 static HRESULT WINAPI
ScriptControl_AddCode(IScriptControl
*iface
, BSTR code
)
944 ScriptControl
*This
= impl_from_IScriptControl(iface
);
945 FIXME("(%p)->(%s)\n", This
, debugstr_w(code
));
949 static HRESULT WINAPI
ScriptControl_Eval(IScriptControl
*iface
, BSTR expression
, VARIANT
*res
)
951 ScriptControl
*This
= impl_from_IScriptControl(iface
);
952 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(expression
), res
);
956 static HRESULT WINAPI
ScriptControl_ExecuteStatement(IScriptControl
*iface
, BSTR statement
)
958 ScriptControl
*This
= impl_from_IScriptControl(iface
);
959 FIXME("(%p)->(%s)\n", This
, debugstr_w(statement
));
963 static HRESULT WINAPI
ScriptControl_Run(IScriptControl
*iface
, BSTR procedure_name
, SAFEARRAY
**parameters
, VARIANT
*res
)
965 ScriptControl
*This
= impl_from_IScriptControl(iface
);
966 FIXME("(%p)->(%s %p %p)\n", This
, debugstr_w(procedure_name
), parameters
, res
);
970 static const IScriptControlVtbl ScriptControlVtbl
= {
971 ScriptControl_QueryInterface
,
972 ScriptControl_AddRef
,
973 ScriptControl_Release
,
974 ScriptControl_GetTypeInfoCount
,
975 ScriptControl_GetTypeInfo
,
976 ScriptControl_GetIDsOfNames
,
977 ScriptControl_Invoke
,
978 ScriptControl_get_Language
,
979 ScriptControl_put_Language
,
980 ScriptControl_get_State
,
981 ScriptControl_put_State
,
982 ScriptControl_put_SitehWnd
,
983 ScriptControl_get_SitehWnd
,
984 ScriptControl_get_Timeout
,
985 ScriptControl_put_Timeout
,
986 ScriptControl_get_AllowUI
,
987 ScriptControl_put_AllowUI
,
988 ScriptControl_get_UseSafeSubset
,
989 ScriptControl_put_UseSafeSubset
,
990 ScriptControl_get_Modules
,
991 ScriptControl_get_Error
,
992 ScriptControl_get_CodeObject
,
993 ScriptControl_get_Procedures
,
994 ScriptControl__AboutBox
,
995 ScriptControl_AddObject
,
997 ScriptControl_AddCode
,
999 ScriptControl_ExecuteStatement
,
1003 static HRESULT WINAPI
OleObject_QueryInterface(IOleObject
*iface
, REFIID riid
, void **obj
)
1005 ScriptControl
*This
= impl_from_IOleObject(iface
);
1006 return IScriptControl_QueryInterface(&This
->IScriptControl_iface
, riid
, obj
);
1009 static ULONG WINAPI
OleObject_AddRef(IOleObject
*iface
)
1011 ScriptControl
*This
= impl_from_IOleObject(iface
);
1012 return IScriptControl_AddRef(&This
->IScriptControl_iface
);
1015 static ULONG WINAPI
OleObject_Release(IOleObject
*iface
)
1017 ScriptControl
*This
= impl_from_IOleObject(iface
);
1018 return IScriptControl_Release(&This
->IScriptControl_iface
);
1021 static HRESULT WINAPI
OleObject_SetClientSite(IOleObject
*iface
, IOleClientSite
*site
)
1023 ScriptControl
*This
= impl_from_IOleObject(iface
);
1025 TRACE("(%p)->(%p)\n", This
, site
);
1028 IOleClientSite_Release(This
->site
);
1030 if ((This
->site
= site
))
1031 IOleClientSite_AddRef(site
);
1036 static HRESULT WINAPI
OleObject_GetClientSite(IOleObject
*iface
, IOleClientSite
**site
)
1038 ScriptControl
*This
= impl_from_IOleObject(iface
);
1040 TRACE("(%p)->(%p)\n", This
, site
);
1045 if ((*site
= This
->site
))
1046 IOleClientSite_AddRef(*site
);
1051 static HRESULT WINAPI
OleObject_SetHostNames(IOleObject
*iface
, LPCOLESTR containerapp
, LPCOLESTR containerobj
)
1053 ScriptControl
*This
= impl_from_IOleObject(iface
);
1055 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(containerapp
), debugstr_w(containerobj
));
1060 static HRESULT WINAPI
OleObject_Close(IOleObject
*iface
, DWORD save
)
1062 ScriptControl
*This
= impl_from_IOleObject(iface
);
1064 FIXME("(%p)->(%d)\n", This
, save
);
1069 static HRESULT WINAPI
OleObject_SetMoniker(IOleObject
*iface
, DWORD which
, IMoniker
*moniker
)
1071 ScriptControl
*This
= impl_from_IOleObject(iface
);
1073 FIXME("(%p)->(%d %p)\n", This
, which
, moniker
);
1078 static HRESULT WINAPI
OleObject_GetMoniker(IOleObject
*iface
, DWORD assign
, DWORD which
, IMoniker
**moniker
)
1080 ScriptControl
*This
= impl_from_IOleObject(iface
);
1082 FIXME("(%p)->(%d %d %p)\n", This
, assign
, which
, moniker
);
1087 static HRESULT WINAPI
OleObject_InitFromData(IOleObject
*iface
, IDataObject
*dataobj
, BOOL creation
,
1090 ScriptControl
*This
= impl_from_IOleObject(iface
);
1092 FIXME("(%p)->(%p %d %d)\n", This
, dataobj
, creation
, reserved
);
1097 static HRESULT WINAPI
OleObject_GetClipboardData(IOleObject
*iface
, DWORD reserved
, IDataObject
**dataobj
)
1099 ScriptControl
*This
= impl_from_IOleObject(iface
);
1101 FIXME("(%p)->(%d %p)\n", This
, reserved
, dataobj
);
1106 static HRESULT WINAPI
OleObject_DoVerb(IOleObject
*iface
, LONG verb
, LPMSG msg
, IOleClientSite
*active_site
,
1107 LONG index
, HWND hwndParent
, LPCRECT rect
)
1109 ScriptControl
*This
= impl_from_IOleObject(iface
);
1111 FIXME("(%p)->(%d %p %p %d %p %p)\n", This
, verb
, msg
, active_site
, index
, hwndParent
, rect
);
1116 static HRESULT WINAPI
OleObject_EnumVerbs(IOleObject
*iface
, IEnumOLEVERB
**enumoleverb
)
1118 ScriptControl
*This
= impl_from_IOleObject(iface
);
1120 FIXME("(%p)->(%p)\n", This
, enumoleverb
);
1125 static HRESULT WINAPI
OleObject_Update(IOleObject
*iface
)
1127 ScriptControl
*This
= impl_from_IOleObject(iface
);
1129 FIXME("(%p)\n", This
);
1134 static HRESULT WINAPI
OleObject_IsUpToDate(IOleObject
*iface
)
1136 ScriptControl
*This
= impl_from_IOleObject(iface
);
1138 FIXME("(%p)\n", This
);
1143 static HRESULT WINAPI
OleObject_GetUserClassID(IOleObject
*iface
, CLSID
*clsid
)
1145 ScriptControl
*This
= impl_from_IOleObject(iface
);
1147 FIXME("(%p)->(%p)\n", This
, clsid
);
1152 static HRESULT WINAPI
OleObject_GetUserType(IOleObject
*iface
, DWORD form_of_type
, LPOLESTR
*usertype
)
1154 ScriptControl
*This
= impl_from_IOleObject(iface
);
1156 FIXME("(%p)->(%d %p)\n", This
, form_of_type
, usertype
);
1161 static HRESULT WINAPI
OleObject_SetExtent(IOleObject
*iface
, DWORD aspect
, SIZEL
*size
)
1163 ScriptControl
*This
= impl_from_IOleObject(iface
);
1165 FIXME("(%p)->(%d %p)\n", This
, aspect
, size
);
1170 static HRESULT WINAPI
OleObject_GetExtent(IOleObject
*iface
, DWORD aspect
, SIZEL
*size
)
1172 ScriptControl
*This
= impl_from_IOleObject(iface
);
1174 TRACE("(%p)->(%d %p)\n", This
, aspect
, size
);
1176 if (aspect
!= DVASPECT_CONTENT
)
1177 return DV_E_DVASPECT
;
1179 *size
= This
->extent
;
1183 static HRESULT WINAPI
OleObject_Advise(IOleObject
*iface
, IAdviseSink
*sink
, DWORD
*connection
)
1185 ScriptControl
*This
= impl_from_IOleObject(iface
);
1187 FIXME("(%p)->(%p %p)\n", This
, sink
, connection
);
1192 static HRESULT WINAPI
OleObject_Unadvise(IOleObject
*iface
, DWORD connection
)
1194 ScriptControl
*This
= impl_from_IOleObject(iface
);
1196 FIXME("(%p)->(%d)\n", This
, connection
);
1201 static HRESULT WINAPI
OleObject_EnumAdvise(IOleObject
*iface
, IEnumSTATDATA
**enumadvise
)
1203 ScriptControl
*This
= impl_from_IOleObject(iface
);
1205 FIXME("(%p)->(%p)\n", This
, enumadvise
);
1210 static HRESULT WINAPI
OleObject_GetMiscStatus(IOleObject
*iface
, DWORD aspect
, DWORD
*status
)
1212 ScriptControl
*This
= impl_from_IOleObject(iface
);
1214 TRACE("(%p)->(%d %p)\n", This
, aspect
, status
);
1216 return OleRegGetMiscStatus(&CLSID_ScriptControl
, aspect
, status
);
1219 static HRESULT WINAPI
OleObject_SetColorScheme(IOleObject
*iface
, LOGPALETTE
*logpal
)
1221 ScriptControl
*This
= impl_from_IOleObject(iface
);
1223 FIXME("(%p)->(%p)\n", This
, logpal
);
1228 static const IOleObjectVtbl OleObjectVtbl
= {
1229 OleObject_QueryInterface
,
1232 OleObject_SetClientSite
,
1233 OleObject_GetClientSite
,
1234 OleObject_SetHostNames
,
1236 OleObject_SetMoniker
,
1237 OleObject_GetMoniker
,
1238 OleObject_InitFromData
,
1239 OleObject_GetClipboardData
,
1241 OleObject_EnumVerbs
,
1243 OleObject_IsUpToDate
,
1244 OleObject_GetUserClassID
,
1245 OleObject_GetUserType
,
1246 OleObject_SetExtent
,
1247 OleObject_GetExtent
,
1250 OleObject_EnumAdvise
,
1251 OleObject_GetMiscStatus
,
1252 OleObject_SetColorScheme
1255 static HRESULT WINAPI
PersistStreamInit_QueryInterface(IPersistStreamInit
*iface
, REFIID riid
, void **obj
)
1257 ScriptControl
*This
= impl_from_IPersistStreamInit(iface
);
1258 return IScriptControl_QueryInterface(&This
->IScriptControl_iface
, riid
, obj
);
1261 static ULONG WINAPI
PersistStreamInit_AddRef(IPersistStreamInit
*iface
)
1263 ScriptControl
*This
= impl_from_IPersistStreamInit(iface
);
1264 return IScriptControl_AddRef(&This
->IScriptControl_iface
);
1267 static ULONG WINAPI
PersistStreamInit_Release(IPersistStreamInit
*iface
)
1269 ScriptControl
*This
= impl_from_IPersistStreamInit(iface
);
1270 return IScriptControl_Release(&This
->IScriptControl_iface
);
1273 static HRESULT WINAPI
PersistStreamInit_GetClassID(IPersistStreamInit
*iface
, CLSID
*clsid
)
1275 ScriptControl
*This
= impl_from_IPersistStreamInit(iface
);
1277 FIXME("(%p)->(%p)\n", This
, clsid
);
1282 static HRESULT WINAPI
PersistStreamInit_IsDirty(IPersistStreamInit
*iface
)
1284 ScriptControl
*This
= impl_from_IPersistStreamInit(iface
);
1286 FIXME("(%p)\n", This
);
1291 static HRESULT WINAPI
PersistStreamInit_Load(IPersistStreamInit
*iface
, IStream
*stream
)
1293 ScriptControl
*This
= impl_from_IPersistStreamInit(iface
);
1295 FIXME("(%p)->(%p)\n", This
, stream
);
1300 static HRESULT WINAPI
PersistStreamInit_Save(IPersistStreamInit
*iface
, IStream
*stream
, BOOL clear_dirty
)
1302 ScriptControl
*This
= impl_from_IPersistStreamInit(iface
);
1304 FIXME("(%p)->(%p %d)\n", This
, stream
, clear_dirty
);
1309 static HRESULT WINAPI
PersistStreamInit_GetSizeMax(IPersistStreamInit
*iface
, ULARGE_INTEGER
*size
)
1311 ScriptControl
*This
= impl_from_IPersistStreamInit(iface
);
1313 FIXME("(%p)->(%p)\n", This
, size
);
1318 static HRESULT WINAPI
PersistStreamInit_InitNew(IPersistStreamInit
*iface
)
1320 ScriptControl
*This
= impl_from_IPersistStreamInit(iface
);
1322 FIXME("(%p)\n", This
);
1327 static const IPersistStreamInitVtbl PersistStreamInitVtbl
= {
1328 PersistStreamInit_QueryInterface
,
1329 PersistStreamInit_AddRef
,
1330 PersistStreamInit_Release
,
1331 PersistStreamInit_GetClassID
,
1332 PersistStreamInit_IsDirty
,
1333 PersistStreamInit_Load
,
1334 PersistStreamInit_Save
,
1335 PersistStreamInit_GetSizeMax
,
1336 PersistStreamInit_InitNew
1339 static HRESULT WINAPI
OleControl_QueryInterface(IOleControl
*iface
, REFIID riid
, void **obj
)
1341 ScriptControl
*This
= impl_from_IOleControl(iface
);
1342 return IScriptControl_QueryInterface(&This
->IScriptControl_iface
, riid
, obj
);
1345 static ULONG WINAPI
OleControl_AddRef(IOleControl
*iface
)
1347 ScriptControl
*This
= impl_from_IOleControl(iface
);
1348 return IScriptControl_AddRef(&This
->IScriptControl_iface
);
1351 static ULONG WINAPI
OleControl_Release(IOleControl
*iface
)
1353 ScriptControl
*This
= impl_from_IOleControl(iface
);
1354 return IScriptControl_Release(&This
->IScriptControl_iface
);
1357 static HRESULT WINAPI
OleControl_GetControlInfo(IOleControl
*iface
, CONTROLINFO
*info
)
1359 ScriptControl
*This
= impl_from_IOleControl(iface
);
1361 TRACE("(%p)->(%p)\n", This
, info
);
1366 info
->hAccel
= NULL
;
1372 static HRESULT WINAPI
OleControl_OnMnemonic(IOleControl
*iface
, MSG
*msg
)
1374 ScriptControl
*This
= impl_from_IOleControl(iface
);
1376 FIXME("(%p)->(%p)\n", This
, msg
);
1381 static HRESULT WINAPI
OleControl_OnAmbientPropertyChange(IOleControl
*iface
, DISPID dispid
)
1383 ScriptControl
*This
= impl_from_IOleControl(iface
);
1385 FIXME("(%p)->(%#x)\n", This
, dispid
);
1390 static HRESULT WINAPI
OleControl_FreezeEvents(IOleControl
*iface
, BOOL freeze
)
1392 ScriptControl
*This
= impl_from_IOleControl(iface
);
1394 FIXME("(%p)->(%d)\n", This
, freeze
);
1399 static const IOleControlVtbl OleControlVtbl
= {
1400 OleControl_QueryInterface
,
1403 OleControl_GetControlInfo
,
1404 OleControl_OnMnemonic
,
1405 OleControl_OnAmbientPropertyChange
,
1406 OleControl_FreezeEvents
1409 static HRESULT WINAPI
QuickActivate_QueryInterface(IQuickActivate
*iface
, REFIID riid
, void **obj
)
1411 ScriptControl
*This
= impl_from_IQuickActivate(iface
);
1412 return IScriptControl_QueryInterface(&This
->IScriptControl_iface
, riid
, obj
);
1415 static ULONG WINAPI
QuickActivate_AddRef(IQuickActivate
*iface
)
1417 ScriptControl
*This
= impl_from_IQuickActivate(iface
);
1418 return IScriptControl_AddRef(&This
->IScriptControl_iface
);
1421 static ULONG WINAPI
QuickActivate_Release(IQuickActivate
*iface
)
1423 ScriptControl
*This
= impl_from_IQuickActivate(iface
);
1424 return IScriptControl_Release(&This
->IScriptControl_iface
);
1427 static HRESULT WINAPI
QuickActivate_QuickActivate(IQuickActivate
*iface
, QACONTAINER
*container
, QACONTROL
*control
)
1429 ScriptControl
*This
= impl_from_IQuickActivate(iface
);
1431 FIXME("(%p)->(%p %p)\n", This
, container
, control
);
1436 static HRESULT WINAPI
QuickActivate_SetContentExtent(IQuickActivate
*iface
, SIZEL
*size
)
1438 ScriptControl
*This
= impl_from_IQuickActivate(iface
);
1440 FIXME("(%p)->(%p)\n", This
, size
);
1445 static HRESULT WINAPI
QuickActivate_GetContentExtent(IQuickActivate
*iface
, SIZEL
*size
)
1447 ScriptControl
*This
= impl_from_IQuickActivate(iface
);
1449 FIXME("(%p)->(%p)\n", This
, size
);
1454 static const IQuickActivateVtbl QuickActivateVtbl
= {
1455 QuickActivate_QueryInterface
,
1456 QuickActivate_AddRef
,
1457 QuickActivate_Release
,
1458 QuickActivate_QuickActivate
,
1459 QuickActivate_SetContentExtent
,
1460 QuickActivate_GetContentExtent
1463 static HRESULT WINAPI
ViewObject_QueryInterface(IViewObjectEx
*iface
, REFIID riid
, void **obj
)
1465 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1466 return IScriptControl_QueryInterface(&This
->IScriptControl_iface
, riid
, obj
);
1469 static ULONG WINAPI
ViewObject_AddRef(IViewObjectEx
*iface
)
1471 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1472 return IScriptControl_AddRef(&This
->IScriptControl_iface
);
1475 static ULONG WINAPI
ViewObject_Release(IViewObjectEx
*iface
)
1477 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1478 return IScriptControl_Release(&This
->IScriptControl_iface
);
1481 static HRESULT WINAPI
ViewObject_Draw(IViewObjectEx
*iface
, DWORD drawaspect
, LONG index
, void *aspect
,
1482 DVTARGETDEVICE
*device
, HDC target_dev
, HDC hdc_draw
, const RECTL
*bounds
, const RECTL
*win_bounds
,
1483 BOOL (STDMETHODCALLTYPE
*fn_continue
)(ULONG_PTR cont
), ULONG_PTR cont
)
1485 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1487 FIXME("(%p)->(%d %d %p %p %p %p %p %p %p %lu)\n", This
, drawaspect
, index
, aspect
, device
, target_dev
,
1488 hdc_draw
, bounds
, win_bounds
, fn_continue
, cont
);
1493 static HRESULT WINAPI
ViewObject_GetColorSet(IViewObjectEx
*iface
, DWORD drawaspect
, LONG index
, void *aspect
,
1494 DVTARGETDEVICE
*device
, HDC hic_target
, LOGPALETTE
**colorset
)
1496 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1498 FIXME("(%p)->(%d %d %p %p %p %p)\n", This
, drawaspect
, index
, aspect
, device
, hic_target
,
1504 static HRESULT WINAPI
ViewObject_Freeze(IViewObjectEx
*iface
, DWORD drawaspect
, LONG index
, void *aspect
,
1507 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1509 FIXME("(%p)->(%d %d %p %p)\n", This
, drawaspect
, index
, aspect
, freeze
);
1514 static HRESULT WINAPI
ViewObject_Unfreeze(IViewObjectEx
*iface
, DWORD freeze
)
1516 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1518 FIXME("(%p)->(%d)\n", This
, freeze
);
1523 static HRESULT WINAPI
ViewObject_SetAdvise(IViewObjectEx
*iface
, DWORD aspects
, DWORD flags
, IAdviseSink
*sink
)
1525 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1527 TRACE("(%p)->(%d %#x %p)\n", This
, aspects
, flags
, sink
);
1529 if (aspects
!= DVASPECT_CONTENT
)
1530 return DV_E_DVASPECT
;
1532 This
->view_sink_flags
= flags
;
1533 if (This
->view_sink
)
1534 IAdviseSink_Release(This
->view_sink
);
1535 This
->view_sink
= sink
;
1536 if (This
->view_sink
)
1537 IAdviseSink_AddRef(This
->view_sink
);
1542 static HRESULT WINAPI
ViewObject_GetAdvise(IViewObjectEx
*iface
, DWORD
*aspects
, DWORD
*flags
, IAdviseSink
**sink
)
1544 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1546 TRACE("(%p)->(%p %p %p)\n", This
, aspects
, flags
, sink
);
1549 *aspects
= DVASPECT_CONTENT
;
1551 *flags
= This
->view_sink_flags
;
1553 *sink
= This
->view_sink
;
1555 IAdviseSink_AddRef(*sink
);
1561 static HRESULT WINAPI
ViewObject_GetExtent(IViewObjectEx
*iface
, DWORD draw_aspect
, LONG index
,
1562 DVTARGETDEVICE
*device
, SIZEL
*size
)
1564 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1566 FIXME("(%p)->(%d %d %p %p)\n", This
, draw_aspect
, index
, device
, size
);
1571 static HRESULT WINAPI
ViewObject_GetRect(IViewObjectEx
*iface
, DWORD aspect
, RECTL
*rect
)
1573 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1575 FIXME("(%p)->(%d %p)\n", This
, aspect
, rect
);
1580 static HRESULT WINAPI
ViewObject_GetViewStatus(IViewObjectEx
*iface
, DWORD
*status
)
1582 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1584 TRACE("(%p)->(%p)\n", This
, status
);
1586 *status
= VIEWSTATUS_OPAQUE
;
1590 static HRESULT WINAPI
ViewObject_QueryHitPoint(IViewObjectEx
*iface
, DWORD aspect
, const RECT
*bounds
,
1591 POINT pt
, LONG close_hint
, DWORD
*hit_result
)
1593 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1595 FIXME("(%p)->(%d %s %s %d %p)\n", This
, aspect
, wine_dbgstr_rect(bounds
), wine_dbgstr_point(&pt
), close_hint
, hit_result
);
1600 static HRESULT WINAPI
ViewObject_QueryHitRect(IViewObjectEx
*iface
, DWORD aspect
, const RECT
*bounds
,
1601 const RECT
*loc
, LONG close_hint
, DWORD
*hit_result
)
1603 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1605 FIXME("(%p)->(%d %s %s %d %p)\n", This
, aspect
, wine_dbgstr_rect(bounds
), wine_dbgstr_rect(loc
), close_hint
, hit_result
);
1610 static HRESULT WINAPI
ViewObject_GetNaturalExtent(IViewObjectEx
*iface
, DWORD aspect
, LONG index
,
1611 DVTARGETDEVICE
*device
, HDC target_hdc
, DVEXTENTINFO
*extent_info
, SIZEL
*size
)
1613 ScriptControl
*This
= impl_from_IViewObjectEx(iface
);
1615 FIXME("(%p)->(%d %d %p %p %p %p)\n", This
, aspect
, index
, device
, target_hdc
, extent_info
, size
);
1620 static const IViewObjectExVtbl ViewObjectExVtbl
= {
1621 ViewObject_QueryInterface
,
1625 ViewObject_GetColorSet
,
1627 ViewObject_Unfreeze
,
1628 ViewObject_SetAdvise
,
1629 ViewObject_GetAdvise
,
1630 ViewObject_GetExtent
,
1632 ViewObject_GetViewStatus
,
1633 ViewObject_QueryHitPoint
,
1634 ViewObject_QueryHitRect
,
1635 ViewObject_GetNaturalExtent
1638 static HRESULT WINAPI
PointerInactive_QueryInterface(IPointerInactive
*iface
, REFIID riid
, void **obj
)
1640 ScriptControl
*This
= impl_from_IPointerInactive(iface
);
1641 return IScriptControl_QueryInterface(&This
->IScriptControl_iface
, riid
, obj
);
1644 static ULONG WINAPI
PointerInactive_AddRef(IPointerInactive
*iface
)
1646 ScriptControl
*This
= impl_from_IPointerInactive(iface
);
1647 return IScriptControl_AddRef(&This
->IScriptControl_iface
);
1650 static ULONG WINAPI
PointerInactive_Release(IPointerInactive
*iface
)
1652 ScriptControl
*This
= impl_from_IPointerInactive(iface
);
1653 return IScriptControl_Release(&This
->IScriptControl_iface
);
1656 static HRESULT WINAPI
PointerInactive_GetActivationPolicy(IPointerInactive
*iface
, DWORD
*policy
)
1658 ScriptControl
*This
= impl_from_IPointerInactive(iface
);
1660 TRACE("(%p)->(%p)\n", This
, policy
);
1669 static HRESULT WINAPI
PointerInactive_OnInactiveMouseMove(IPointerInactive
*iface
, const RECT
*bounds
,
1670 LONG x
, LONG y
, DWORD key_state
)
1672 ScriptControl
*This
= impl_from_IPointerInactive(iface
);
1674 FIXME("(%p)->(%s %d %d %#x)\n", This
, wine_dbgstr_rect(bounds
), x
, y
, key_state
);
1679 static HRESULT WINAPI
PointerInactive_OnInactiveSetCursor(IPointerInactive
*iface
, const RECT
*bounds
,
1680 LONG x
, LONG y
, DWORD msg
, BOOL set_always
)
1682 ScriptControl
*This
= impl_from_IPointerInactive(iface
);
1684 FIXME("(%p)->(%s %d %d %#x %d)\n", This
, wine_dbgstr_rect(bounds
), x
, y
, msg
, set_always
);
1689 static const IPointerInactiveVtbl PointerInactiveVtbl
= {
1690 PointerInactive_QueryInterface
,
1691 PointerInactive_AddRef
,
1692 PointerInactive_Release
,
1693 PointerInactive_GetActivationPolicy
,
1694 PointerInactive_OnInactiveMouseMove
,
1695 PointerInactive_OnInactiveSetCursor
1698 static HRESULT WINAPI
ConnectionPointContainer_QueryInterface(IConnectionPointContainer
*iface
, REFIID riid
, void **obj
)
1700 ScriptControl
*This
= impl_from_IConnectionPointContainer(iface
);
1701 return IScriptControl_QueryInterface(&This
->IScriptControl_iface
, riid
, obj
);
1704 static ULONG WINAPI
ConnectionPointContainer_AddRef(IConnectionPointContainer
*iface
)
1706 ScriptControl
*This
= impl_from_IConnectionPointContainer(iface
);
1707 return IScriptControl_AddRef(&This
->IScriptControl_iface
);
1710 static ULONG WINAPI
ConnectionPointContainer_Release(IConnectionPointContainer
*iface
)
1712 ScriptControl
*This
= impl_from_IConnectionPointContainer(iface
);
1713 return IScriptControl_Release(&This
->IScriptControl_iface
);
1716 static HRESULT WINAPI
ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer
*iface
, IEnumConnectionPoints
**enum_points
)
1718 ScriptControl
*This
= impl_from_IConnectionPointContainer(iface
);
1720 FIXME("(%p)->(%p)\n", This
, enum_points
);
1725 static HRESULT WINAPI
ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer
*iface
, REFIID riid
, IConnectionPoint
**cp
)
1727 ScriptControl
*This
= impl_from_IConnectionPointContainer(iface
);
1728 ConnectionPoint
*iter
;
1730 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), cp
);
1734 for (iter
= This
->cp_list
; iter
; iter
= iter
->next
) {
1735 if (IsEqualIID(iter
->riid
, riid
))
1736 *cp
= &iter
->IConnectionPoint_iface
;
1740 IConnectionPoint_AddRef(*cp
);
1744 FIXME("unsupported connection point %s\n", debugstr_guid(riid
));
1745 return CONNECT_E_NOCONNECTION
;
1748 static const IConnectionPointContainerVtbl ConnectionPointContainerVtbl
= {
1749 ConnectionPointContainer_QueryInterface
,
1750 ConnectionPointContainer_AddRef
,
1751 ConnectionPointContainer_Release
,
1752 ConnectionPointContainer_EnumConnectionPoints
,
1753 ConnectionPointContainer_FindConnectionPoint
1756 static HRESULT WINAPI
ConnectionPoint_QueryInterface(IConnectionPoint
*iface
,
1757 REFIID riid
, void **ppv
)
1759 ConnectionPoint
*This
= impl_from_IConnectionPoint(iface
);
1761 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1762 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1763 *ppv
= &This
->IConnectionPoint_iface
;
1764 }else if(IsEqualGUID(&IID_IConnectionPoint
, riid
)) {
1765 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1766 *ppv
= &This
->IConnectionPoint_iface
;
1768 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
1770 return E_NOINTERFACE
;
1773 IUnknown_AddRef((IUnknown
*)*ppv
);
1777 static ULONG WINAPI
ConnectionPoint_AddRef(IConnectionPoint
*iface
)
1779 ConnectionPoint
*This
= impl_from_IConnectionPoint(iface
);
1780 return IConnectionPointContainer_AddRef(&This
->control
->IConnectionPointContainer_iface
);
1783 static ULONG WINAPI
ConnectionPoint_Release(IConnectionPoint
*iface
)
1785 ConnectionPoint
*This
= impl_from_IConnectionPoint(iface
);
1786 return IConnectionPointContainer_Release(&This
->control
->IConnectionPointContainer_iface
);
1789 static HRESULT WINAPI
ConnectionPoint_GetConnectionInterface(IConnectionPoint
*iface
, IID
*iid
)
1791 ConnectionPoint
*This
= impl_from_IConnectionPoint(iface
);
1793 TRACE("(%p)->(%p)\n", This
, iid
);
1799 static HRESULT WINAPI
ConnectionPoint_GetConnectionPointContainer(IConnectionPoint
*iface
,
1800 IConnectionPointContainer
**container
)
1802 ConnectionPoint
*This
= impl_from_IConnectionPoint(iface
);
1804 TRACE("(%p)->(%p)\n", This
, container
);
1809 *container
= &This
->control
->IConnectionPointContainer_iface
;
1810 IConnectionPointContainer_AddRef(*container
);
1815 static HRESULT WINAPI
ConnectionPoint_Advise(IConnectionPoint
*iface
, IUnknown
*unk_sink
,
1818 ConnectionPoint
*This
= impl_from_IConnectionPoint(iface
);
1820 FIXME("(%p)->(%p %p)\n", This
, unk_sink
, cookie
);
1825 static HRESULT WINAPI
ConnectionPoint_Unadvise(IConnectionPoint
*iface
, DWORD cookie
)
1827 ConnectionPoint
*This
= impl_from_IConnectionPoint(iface
);
1829 FIXME("(%p)->(%d)\n", This
, cookie
);
1834 static HRESULT WINAPI
ConnectionPoint_EnumConnections(IConnectionPoint
*iface
,
1835 IEnumConnections
**ppEnum
)
1837 ConnectionPoint
*This
= impl_from_IConnectionPoint(iface
);
1839 FIXME("(%p)->(%p): stub\n", This
, ppEnum
);
1844 static const IConnectionPointVtbl ConnectionPointVtbl
=
1846 ConnectionPoint_QueryInterface
,
1847 ConnectionPoint_AddRef
,
1848 ConnectionPoint_Release
,
1849 ConnectionPoint_GetConnectionInterface
,
1850 ConnectionPoint_GetConnectionPointContainer
,
1851 ConnectionPoint_Advise
,
1852 ConnectionPoint_Unadvise
,
1853 ConnectionPoint_EnumConnections
1856 static void ConnectionPoint_Init(ConnectionPoint
*cp
, ScriptControl
*sc
, REFIID riid
)
1858 cp
->IConnectionPoint_iface
.lpVtbl
= &ConnectionPointVtbl
;
1862 cp
->next
= sc
->cp_list
;
1866 static HRESULT WINAPI
ScriptControl_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
1868 ScriptControl
*script_control
;
1873 TRACE("(%p %s %p)\n", outer
, debugstr_guid(riid
), ppv
);
1875 script_control
= heap_alloc(sizeof(*script_control
));
1877 return E_OUTOFMEMORY
;
1879 script_control
->IScriptControl_iface
.lpVtbl
= &ScriptControlVtbl
;
1880 script_control
->IPersistStreamInit_iface
.lpVtbl
= &PersistStreamInitVtbl
;
1881 script_control
->IOleObject_iface
.lpVtbl
= &OleObjectVtbl
;
1882 script_control
->IOleControl_iface
.lpVtbl
= &OleControlVtbl
;
1883 script_control
->IQuickActivate_iface
.lpVtbl
= &QuickActivateVtbl
;
1884 script_control
->IViewObjectEx_iface
.lpVtbl
= &ViewObjectExVtbl
;
1885 script_control
->IPointerInactive_iface
.lpVtbl
= &PointerInactiveVtbl
;
1886 script_control
->IConnectionPointContainer_iface
.lpVtbl
= &ConnectionPointContainerVtbl
;
1887 script_control
->ref
= 1;
1888 script_control
->site
= NULL
;
1889 script_control
->cp_list
= NULL
;
1890 script_control
->host
= NULL
;
1891 script_control
->timeout
= 10000;
1892 script_control
->view_sink_flags
= 0;
1893 script_control
->view_sink
= NULL
;
1895 ConnectionPoint_Init(&script_control
->cp_scsource
, script_control
, &DIID_DScriptControlSource
);
1896 ConnectionPoint_Init(&script_control
->cp_propnotif
, script_control
, &IID_IPropertyNotifySink
);
1899 dpi_x
= GetDeviceCaps(hdc
, LOGPIXELSX
);
1900 dpi_y
= GetDeviceCaps(hdc
, LOGPIXELSY
);
1903 script_control
->extent
.cx
= MulDiv(38, 2540, dpi_x
);
1904 script_control
->extent
.cy
= MulDiv(38, 2540, dpi_y
);
1906 hres
= IScriptControl_QueryInterface(&script_control
->IScriptControl_iface
, riid
, ppv
);
1907 IScriptControl_Release(&script_control
->IScriptControl_iface
);
1911 /******************************************************************
1912 * DllMain (msscript.ocx.@)
1914 BOOL WINAPI
DllMain(HINSTANCE instance
, DWORD reason
, void *reserved
)
1916 TRACE("(%p %d %p)\n", instance
, reason
, reserved
);
1919 case DLL_WINE_PREATTACH
:
1920 return FALSE
; /* prefer native version */
1921 case DLL_PROCESS_ATTACH
:
1922 msscript_instance
= instance
;
1923 DisableThreadLibraryCalls(instance
);
1925 case DLL_PROCESS_DETACH
:
1934 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
1938 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1939 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
1941 }else if(IsEqualGUID(&IID_IClassFactory
, riid
)) {
1942 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
1947 IUnknown_AddRef((IUnknown
*)*ppv
);
1951 WARN("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
1952 return E_NOINTERFACE
;
1955 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
1957 TRACE("(%p)\n", iface
);
1961 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
1963 TRACE("(%p)\n", iface
);
1967 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL fLock
)
1969 TRACE("(%p)->(%x)\n", iface
, fLock
);
1973 static const IClassFactoryVtbl ScriptControlFactoryVtbl
= {
1974 ClassFactory_QueryInterface
,
1975 ClassFactory_AddRef
,
1976 ClassFactory_Release
,
1977 ScriptControl_CreateInstance
,
1978 ClassFactory_LockServer
1981 static IClassFactory ScriptControlFactory
= { &ScriptControlFactoryVtbl
};
1983 /***********************************************************************
1984 * DllGetClassObject (msscript.ocx.@)
1986 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
1988 if(IsEqualGUID(&CLSID_ScriptControl
, rclsid
)) {
1989 TRACE("(CLSID_ScriptControl %s %p)\n", debugstr_guid(riid
), ppv
);
1990 return IClassFactory_QueryInterface(&ScriptControlFactory
, riid
, ppv
);
1993 FIXME("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
1994 return CLASS_E_CLASSNOTAVAILABLE
;
1997 /***********************************************************************
1998 * DllCanUnloadNow (msscript.ocx.@)
2000 HRESULT WINAPI
DllCanUnloadNow(void)
2006 /***********************************************************************
2007 * DllRegisterServer (msscript.ocx.@)
2009 HRESULT WINAPI
DllRegisterServer(void)
2012 return __wine_register_resources(msscript_instance
);
2015 /***********************************************************************
2016 * DllUnregisterServer (msscript.ocx.@)
2018 HRESULT WINAPI
DllUnregisterServer(void)
2021 return __wine_unregister_resources(msscript_instance
);