From d49e808be01c827e1394709839c82d6a4656979a Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Fri, 10 Feb 2006 14:50:26 +0100 Subject: [PATCH] oleaut: Implement IFontEventsDisp connection point for the standard font implementation. --- dlls/oleaut32/olefont.c | 92 +++++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 17 deletions(-) diff --git a/dlls/oleaut32/olefont.c b/dlls/oleaut32/olefont.c index d2154d42471..dfb0d3c759c 100644 --- a/dlls/oleaut32/olefont.c +++ b/dlls/oleaut32/olefont.c @@ -40,6 +40,7 @@ #include "olectl.h" #include "wine/debug.h" #include "connpt.h" /* for CreateConnectionPoint */ +#include "oaidl.h" WINE_DEFAULT_DEBUG_CHANNEL(ole); @@ -95,7 +96,8 @@ struct OLEFontImpl long cyLogical; long cyHimetric; - IConnectionPoint *pCP; + IConnectionPoint *pPropertyNotifyCP; + IConnectionPoint *pFontEventsCP; }; /* @@ -378,24 +380,74 @@ HRESULT WINAPI OleCreateFontIndirect( */ static void OLEFont_SendNotify(OLEFontImpl* this, DISPID dispID) { + static const WCHAR wszName[] = {'N','a','m','e',0}; + static const WCHAR wszSize[] = {'S','i','z','e',0}; + static const WCHAR wszBold[] = {'B','o','l','d',0}; + static const WCHAR wszItalic[] = {'I','t','a','l','i','c',0}; + static const WCHAR wszUnder[] = {'U','n','d','e','r','l','i','n','e',0}; + static const WCHAR wszStrike[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0}; + static const WCHAR wszWeight[] = {'W','e','i','g','h','t',0}; + static const WCHAR wszCharset[] = {'C','h','a','r','s','s','e','t',0}; + static const LPCWSTR dispid_mapping[] = + { + wszName, + NULL, + wszSize, + wszBold, + wszItalic, + wszUnder, + wszStrike, + wszWeight, + wszCharset + }; + IEnumConnections *pEnum; CONNECTDATA CD; HRESULT hres; - hres = IConnectionPoint_EnumConnections(this->pCP, &pEnum); - if (FAILED(hres)) /* When we have 0 connections. */ - return; + hres = IConnectionPoint_EnumConnections(this->pPropertyNotifyCP, &pEnum); + if (SUCCEEDED(hres)) + { + while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) { + IPropertyNotifySink *sink; - while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) { - IPropertyNotifySink *sink; - - IUnknown_QueryInterface(CD.pUnk, &IID_IPropertyNotifySink, (LPVOID)&sink); - IPropertyNotifySink_OnChanged(sink, dispID); - IPropertyNotifySink_Release(sink); - IUnknown_Release(CD.pUnk); + IUnknown_QueryInterface(CD.pUnk, &IID_IPropertyNotifySink, (LPVOID)&sink); + IPropertyNotifySink_OnChanged(sink, dispID); + IPropertyNotifySink_Release(sink); + IUnknown_Release(CD.pUnk); + } + IEnumConnections_Release(pEnum); + } + + hres = IConnectionPoint_EnumConnections(this->pFontEventsCP, &pEnum); + if (SUCCEEDED(hres)) + { + DISPPARAMS dispparams; + VARIANTARG vararg; + + VariantInit(&vararg); + V_VT(&vararg) = VT_BSTR; + V_BSTR(&vararg) = SysAllocString(dispid_mapping[dispID]); + + dispparams.cArgs = 1; + dispparams.cNamedArgs = 0; + dispparams.rgdispidNamedArgs = NULL; + dispparams.rgvarg = &vararg; + + while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) { + IFontEventsDisp *disp; + + IUnknown_QueryInterface(CD.pUnk, &IID_IFontEventsDisp, (LPVOID)&disp); + IDispatch_Invoke(disp, DISPID_FONT_CHANGED, &IID_NULL, + LOCALE_NEUTRAL, INVOKE_FUNC, &dispparams, NULL, + NULL, NULL); + + IDispatch_Release(disp); + IUnknown_Release(CD.pUnk); + } + VariantClear(&vararg); + IEnumConnections_Release(pEnum); } - IEnumConnections_Release(pEnum); - return; } /************************************************************************ @@ -459,7 +511,8 @@ static OLEFontImpl* OLEFontImpl_Construct(LPFONTDESC fontDesc) newObject->fontLock = 0; newObject->cyLogical = 72L; newObject->cyHimetric = 2540L; - CreateConnectionPoint((IUnknown*)newObject, &IID_IPropertyNotifySink, &newObject->pCP); + CreateConnectionPoint((IUnknown*)newObject, &IID_IPropertyNotifySink, &newObject->pPropertyNotifyCP); + CreateConnectionPoint((IUnknown*)newObject, &IID_IFontEventsDisp, &newObject->pFontEventsCP); TRACE("returning %p\n", newObject); return newObject; } @@ -1839,9 +1892,14 @@ static HRESULT WINAPI OLEFontImpl_FindConnectionPoint( OLEFontImpl *this = impl_from_IConnectionPointContainer(iface); TRACE("(%p)->(%s, %p): stub\n", this, debugstr_guid(riid), ppCp); - if(memcmp(riid, &IID_IPropertyNotifySink, sizeof(IID_IPropertyNotifySink)) == 0) { - return IConnectionPoint_QueryInterface(this->pCP, &IID_IConnectionPoint, - (LPVOID)ppCp); + if(IsEqualIID(riid, &IID_IPropertyNotifySink)) { + return IConnectionPoint_QueryInterface(this->pPropertyNotifyCP, + &IID_IConnectionPoint, + (LPVOID)ppCp); + } else if(IsEqualIID(riid, &IID_IFontEventsDisp)) { + return IConnectionPoint_QueryInterface(this->pFontEventsCP, + &IID_IConnectionPoint, + (LPVOID)ppCp); } else { FIXME("Tried to find connection point on %s\n", debugstr_guid(riid)); return E_NOINTERFACE;