From c0ccd263a77c53a2951d6afb9b3c40acfaa57077 Mon Sep 17 00:00:00 2001
From: Marcus Meissner <marcus@jet.franken.de>
Date: Tue, 24 Jul 2001 00:59:28 +0000
Subject: [PATCH] OLEAUT32.DllGetClassObject and support for the Ole StdFont
 added (just giving back a 8 point System font for now).

---
 dlls/oleaut32/oleaut.c      | 24 ++++++++++++
 dlls/oleaut32/oleaut32.spec |  4 +-
 dlls/oleaut32/olefont.c     | 74 +++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+), 2 deletions(-)

diff --git a/dlls/oleaut32/oleaut.c b/dlls/oleaut32/oleaut.c
index c70492e55f6..f70215ba127 100644
--- a/dlls/oleaut32/oleaut.c
+++ b/dlls/oleaut32/oleaut.c
@@ -11,6 +11,9 @@
 #include "winerror.h"
 
 #include "ole2.h"
+#include "olectl.h"
+#include "wine/obj_oleaut.h"
+#include "wine/obj_olefont.h"
 #include "heap.h"
 #include "debugtools.h"
 
@@ -135,3 +138,24 @@ HRESULT WINAPI OLEAUT32_DllUnregisterServer() {
     FIXME("stub!\n");
     return S_OK;
 }
+
+extern void _get_STDFONT_CF(LPVOID);
+
+HRESULT WINAPI OLEAUT32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
+{
+    *ppv = NULL;
+    if (IsEqualGUID(rclsid,&CLSID_StdFont)) {
+	if (IsEqualGUID(iid,&IID_IClassFactory)) {
+	    _get_STDFONT_CF(ppv);
+	    IClassFactory_AddRef((IClassFactory*)*ppv);
+	    return S_OK;
+	}
+    }
+    FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
+    return CLASS_E_CLASSNOTAVAILABLE;
+}
+
+HRESULT WINAPI OLEAUT32_DllCanUnloadNow() {
+    FIXME("(), stub!\n");
+    return S_FALSE;
+}
diff --git a/dlls/oleaut32/oleaut32.spec b/dlls/oleaut32/oleaut32.spec
index 10bff4a98e9..a7f60c4734c 100644
--- a/dlls/oleaut32/oleaut32.spec
+++ b/dlls/oleaut32/oleaut32.spec
@@ -11,7 +11,7 @@ import ntdll.dll
 
 debug_channels (ole typelib)
 
-1 stub DllGetClassObject
+1 stdcall DllGetClassObject(ptr ptr ptr) OLEAUT32_DllGetClassObject
 2 stdcall SysAllocString(wstr) SysAllocString
 3 stdcall SysReAllocString(ptr wstr) SysReAllocString
 4 stdcall SysAllocStringLen(wstr long) SysAllocStringLen
@@ -286,7 +286,7 @@ debug_channels (ole typelib)
 397 stub UserMSG_to_local
 398 stub UserMSG_free_inst
 399 stub UserMSG_free_local
-410 stub DllCanUnloadNow
+410 stdcall DllCanUnloadNow() OLEAUT32_DllCanUnloadNow
 411 stdcall SafeArrayCreateVector(long long long) SafeArrayCreateVector
 412 stdcall SafeArrayCopyData(ptr ptr) SafeArrayCopyData
 413 stub VectorFromBstr
diff --git a/dlls/oleaut32/olefont.c b/dlls/oleaut32/olefont.c
index 9a5b30a9ff3..1e552537bc1 100644
--- a/dlls/oleaut32/olefont.c
+++ b/dlls/oleaut32/olefont.c
@@ -14,6 +14,7 @@
 #include "winuser.h"
 #include "wine/unicode.h"
 #include "oleauto.h"    /* for SysAllocString(....) */
+#include "wine/obj_base.h"
 #include "wine/obj_olefont.h"
 #include "wine/obj_storage.h"
 #include "ole2.h"
@@ -1588,3 +1589,76 @@ static HRESULT WINAPI OLEFontImpl_FindConnectionPoint(
   }
 }
 
+/*******************************************************************************
+ * StdFont ClassFactory
+ */
+typedef struct
+{
+    /* IUnknown fields */
+    ICOM_VFIELD(IClassFactory);
+    DWORD                       ref;
+} IClassFactoryImpl;
+
+static HRESULT WINAPI 
+SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+static ULONG WINAPI
+SFCF_AddRef(LPCLASSFACTORY iface) {
+	ICOM_THIS(IClassFactoryImpl,iface);
+	return ++(This->ref);
+}
+
+static ULONG WINAPI SFCF_Release(LPCLASSFACTORY iface) {
+	ICOM_THIS(IClassFactoryImpl,iface);
+	/* static class, won't be  freed */
+	return --(This->ref);
+}
+
+static HRESULT WINAPI SFCF_CreateInstance(
+	LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
+) {
+	ICOM_THIS(IClassFactoryImpl,iface);
+
+	if (IsEqualGUID(riid,&IID_IFont)) {
+	    FONTDESC fd;
+
+	    WCHAR fname[] = { 'S','y','s','t','e','m',0 };
+
+	    fd.cbSizeofstruct = sizeof(fd);
+	    fd.lpstrName      = fname;
+	    fd.cySize.s.Lo    = 80000;
+	    fd.cySize.s.Hi    = 0;
+	    fd.sWeight 	      = 0;
+	    fd.sCharset       = 0;
+	    fd.fItalic	      = 0;
+	    fd.fUnderline     = 0;
+	    fd.fStrikethrough = 0;
+	    return OleCreateFontIndirect(&fd,riid,ppobj);
+	}
+
+	FIXME("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
+	return E_NOINTERFACE;
+}
+
+static HRESULT WINAPI SFCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
+	ICOM_THIS(IClassFactoryImpl,iface);
+	FIXME("(%p)->(%d),stub!\n",This,dolock);
+	return S_OK;
+}
+
+static ICOM_VTABLE(IClassFactory) SFCF_Vtbl = {
+	ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
+	SFCF_QueryInterface,
+	SFCF_AddRef,
+	SFCF_Release,
+	SFCF_CreateInstance,
+	SFCF_LockServer
+};
+static IClassFactoryImpl STDFONT_CF = {&SFCF_Vtbl, 1 };
+
+void _get_STDFONT_CF(LPVOID *ppv) { *ppv = (LPVOID)&STDFONT_CF; }
-- 
GitLab