[PATCH v5 3/3] uiribbon: Add stubs for IUIFramework

Fabian Maurer dark.shadow4 at web.de
Sun Jul 30 12:40:33 CDT 2017


Code taken and adapted from d3dxof.

Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
 dlls/uiribbon/Makefile.in          |   5 +-
 dlls/uiribbon/main.c               | 143 ++++++++++++++++++++++++++++--
 dlls/uiribbon/uiribbon.c           | 175 +++++++++++++++++++++++++++++++++++++
 dlls/uiribbon/uiribbon_classes.idl |  21 +++++
 dlls/uiribbon/uiribbon_private.h   |  32 +++++++
 5 files changed, 368 insertions(+), 8 deletions(-)
 create mode 100644 dlls/uiribbon/uiribbon.c
 create mode 100644 dlls/uiribbon/uiribbon_classes.idl
 create mode 100644 dlls/uiribbon/uiribbon_private.h

diff --git a/dlls/uiribbon/Makefile.in b/dlls/uiribbon/Makefile.in
index 1ac13dfee0..0b9724d87a 100644
--- a/dlls/uiribbon/Makefile.in
+++ b/dlls/uiribbon/Makefile.in
@@ -2,4 +2,7 @@ MODULE    = uiribbon.dll
 IMPORTS   = uuid ole32
 
 C_SRCS = \
-	main.c
+	main.c \
+	uiribbon.c
+
+IDL_SRCS = uiribbon_classes.idl
diff --git a/dlls/uiribbon/main.c b/dlls/uiribbon/main.c
index 7326378def..9306338086 100644
--- a/dlls/uiribbon/main.c
+++ b/dlls/uiribbon/main.c
@@ -26,25 +26,126 @@
 #include "winuser.h"
 #include "winreg.h"
 
+#include "ole2.h"
+#include "rpcproxy.h"
+
+/* Define GUIDs, but only our own */
+#include <unknwn.h>
+#include <propsys.h>
+#include "initguid.h"
+#include "uiribbon_private.h"
+
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(uiribbon);
 
+static HINSTANCE instance;
+
 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
 {
     TRACE("(0x%p, %d, %p)\n", hInstDLL, fdwReason, lpvReserved);
 
     switch (fdwReason)
     {
-        case DLL_WINE_PREATTACH:
-            return FALSE;    /* prefer native version */
-        default:
+        case DLL_PROCESS_ATTACH:
+            instance = hInstDLL;
+            DisableThreadLibraryCalls(hInstDLL);
             break;
     }
 
     return TRUE;
 }
 
+typedef struct {
+    IClassFactory IClassFactory_iface;
+
+    LONG ref;
+    HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, void **ppObj);
+} IClassFactoryImpl;
+
+static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
+{
+    return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
+}
+
+struct object_creation_info
+{
+    const CLSID *clsid;
+    HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, void **ppObj);
+};
+
+static const struct object_creation_info object_creation[] =
+{
+    { &CLSID_UIRibbonFramework, UIRibbonFrameworkImpl_Create },
+};
+
+static HRESULT WINAPI XFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid, void **ppobj)
+{
+    IClassFactoryImpl *This = impl_from_IClassFactory(iface);
+
+    if (IsEqualGUID(riid, &IID_IUnknown)
+        || IsEqualGUID(riid, &IID_IClassFactory))
+    {
+        IClassFactory_AddRef(iface);
+        *ppobj = &This->IClassFactory_iface;
+        return S_OK;
+    }
+
+    WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI XFCF_AddRef(LPCLASSFACTORY iface)
+{
+    IClassFactoryImpl *This = impl_from_IClassFactory(iface);
+    return InterlockedIncrement(&This->ref);
+}
+
+static ULONG WINAPI XFCF_Release(LPCLASSFACTORY iface)
+{
+    IClassFactoryImpl *This = impl_from_IClassFactory(iface);
+
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    if (ref == 0)
+        HeapFree(GetProcessHeap(), 0, This);
+
+    return ref;
+}
+
+static HRESULT WINAPI XFCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, void **ppobj)
+{
+    IClassFactoryImpl *This = impl_from_IClassFactory(iface);
+    HRESULT hres;
+    LPUNKNOWN punk;
+
+    TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
+
+    *ppobj = NULL;
+    hres = This->pfnCreateInstance(pOuter, (void **) &punk);
+    if (SUCCEEDED(hres)) {
+        hres = IUnknown_QueryInterface(punk, riid, ppobj);
+        IUnknown_Release(punk);
+    }
+    return hres;
+}
+
+static HRESULT WINAPI XFCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
+{
+    IClassFactoryImpl *This = impl_from_IClassFactory(iface);
+    FIXME("(%p)->(%d), stub!\n",This,dolock);
+    return S_OK;
+}
+
+static const IClassFactoryVtbl XFCF_Vtbl =
+{
+    XFCF_QueryInterface,
+    XFCF_AddRef,
+    XFCF_Release,
+    XFCF_CreateInstance,
+    XFCF_LockServer
+};
+
 /*******************************************************************************
  * Retrieves class object from a DLL object
  *
@@ -63,9 +164,37 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
  */
 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
 {
-    FIXME("(%s,%s,%p) stub!\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+    unsigned int i;
+    IClassFactoryImpl *factory;
+
+    TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
+
+    if ( !IsEqualGUID( &IID_IClassFactory, riid )
+         && ! IsEqualGUID( &IID_IUnknown, riid) )
+        return E_NOINTERFACE;
 
-    return CLASS_E_CLASSNOTAVAILABLE;
+    for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
+    {
+        if (IsEqualGUID(object_creation[i].clsid, rclsid))
+            break;
+    }
+
+    if (i == sizeof(object_creation)/sizeof(object_creation[0]))
+    {
+        FIXME("%s: no class found.\n", debugstr_guid(rclsid));
+        return CLASS_E_CLASSNOTAVAILABLE;
+    }
+
+    factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
+    if (factory == NULL) return E_OUTOFMEMORY;
+
+    factory->IClassFactory_iface.lpVtbl = &XFCF_Vtbl;
+    factory->ref = 1;
+
+    factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
+
+    *ppv = &(factory->IClassFactory_iface);
+    return S_OK;
 }
 
 HRESULT WINAPI DllCanUnloadNow(void)
@@ -75,10 +204,10 @@ HRESULT WINAPI DllCanUnloadNow(void)
 
 HRESULT WINAPI DllRegisterServer(void)
 {
-    return S_OK;
+    return __wine_register_resources( instance );
 }
 
 HRESULT WINAPI DllUnregisterServer(void)
 {
-    return S_OK;
+    return __wine_unregister_resources( instance );
 }
diff --git a/dlls/uiribbon/uiribbon.c b/dlls/uiribbon/uiribbon.c
new file mode 100644
index 0000000000..58ac51aece
--- /dev/null
+++ b/dlls/uiribbon/uiribbon.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2017 Fabian Maurer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+#include "wine/debug.h"
+
+#define COBJMACROS
+
+#include "uiribbon_private.h"
+
+#include <stdio.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(uiribbon);
+
+static inline UIRibbonFrameworkImpl *impl_from_IUIFramework(IUIFramework *iface)
+{
+    return CONTAINING_RECORD(iface, UIRibbonFrameworkImpl, IUIFramework_iface);
+}
+
+/*** IUnknown methods ***/
+
+static HRESULT WINAPI UIRibbonFrameworkImpl_QueryInterface(IUIFramework *iface, REFIID riid, void **ppvObject)
+{
+    UIRibbonFrameworkImpl *This = impl_from_IUIFramework(iface);
+
+    TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
+
+    if (IsEqualGUID(riid, &IID_IUnknown)
+        || IsEqualGUID(riid, &IID_IUIFramework))
+    {
+        IUnknown_AddRef(iface);
+        *ppvObject = &This->IUIFramework_iface;
+        return S_OK;
+    }
+
+    ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI UIRibbonFrameworkImpl_AddRef(IUIFramework *iface)
+{
+    UIRibbonFrameworkImpl *This = impl_from_IUIFramework(iface);
+    ULONG ref = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
+
+    return ref;
+}
+
+static ULONG WINAPI UIRibbonFrameworkImpl_Release(IUIFramework *iface)
+{
+    UIRibbonFrameworkImpl *This = impl_from_IUIFramework(iface);
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p/%p)->(): new ref %d\n", iface, This, ref);
+
+    if (!ref)
+        HeapFree(GetProcessHeap(), 0, This);
+
+    return ref;
+}
+
+/*** IUIFramework methods ***/
+
+static HRESULT WINAPI UIRibbonFrameworkImpl_Initialize(IUIFramework *iface, HWND frameWnd, IUIApplication *application)
+{
+    FIXME("(%p, %p): stub!\n", frameWnd, application);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI UIRibbonFrameworkImpl_Destroy(IUIFramework *iface)
+{
+    FIXME("(): stub!\n");
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI UIRibbonFrameworkImpl_LoadUI(IUIFramework *iface, HINSTANCE instance, LPCWSTR resourceName)
+{
+    FIXME("(%p, %s): stub!\n", instance, debugstr_w(resourceName));
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI UIRibbonFrameworkImpl_GetView(IUIFramework *iface, UINT32 viewId, REFIID riid, void **ppv)
+{
+    FIXME("(%u, %p, %p): stub!\n", viewId, riid, ppv);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI UIRibbonFrameworkImpl_GetUICommandProperty(IUIFramework *iface, UINT32 commandId, REFPROPERTYKEY key, PROPVARIANT *value)
+{
+    FIXME("(%u, %p, %p): stub!\n", commandId, key, value);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI UIRibbonFrameworkImpl_SetUICommandProperty(IUIFramework *iface, UINT32 commandId, REFPROPERTYKEY key, PROPVARIANT value)
+{
+    FIXME("(%u, %p): stub!\n", commandId, key);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI UIRibbonFrameworkImpl_InvalidateUICommand(IUIFramework *iface, UINT32 commandId, UI_INVALIDATIONS flags, const PROPERTYKEY *key)
+{
+    FIXME("(%u, %#x, %p): stub!\n", commandId, flags, key);
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI UIRibbonFrameworkImpl_FlushPendingInvalidations(IUIFramework *iface)
+{
+    FIXME("(): stub!\n");
+
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI UIRibbonFrameworkImpl_SetModes(IUIFramework *iface, INT32 iModes)
+{
+    FIXME("(%d): stub!\n", iModes);
+
+    return E_NOTIMPL;
+}
+
+static const IUIFrameworkVtbl IUIFramework_Vtbl =
+{
+    UIRibbonFrameworkImpl_QueryInterface,
+    UIRibbonFrameworkImpl_AddRef,
+    UIRibbonFrameworkImpl_Release,
+    UIRibbonFrameworkImpl_Initialize,
+    UIRibbonFrameworkImpl_Destroy,
+    UIRibbonFrameworkImpl_LoadUI,
+    UIRibbonFrameworkImpl_GetView,
+    UIRibbonFrameworkImpl_GetUICommandProperty,
+    UIRibbonFrameworkImpl_SetUICommandProperty,
+    UIRibbonFrameworkImpl_InvalidateUICommand,
+    UIRibbonFrameworkImpl_FlushPendingInvalidations,
+    UIRibbonFrameworkImpl_SetModes
+};
+
+HRESULT UIRibbonFrameworkImpl_Create(IUnknown *pUnkOuter, void **ppObj)
+{
+    UIRibbonFrameworkImpl *object;
+
+    TRACE("(%p,%p)\n", pUnkOuter, ppObj);
+
+    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(UIRibbonFrameworkImpl));
+    if (!object)
+        return E_OUTOFMEMORY;
+
+    object->IUIFramework_iface.lpVtbl = &IUIFramework_Vtbl;
+    object->ref = 1;
+
+    *ppObj = &object->IUIFramework_iface;
+
+    return S_OK;
+}
diff --git a/dlls/uiribbon/uiribbon_classes.idl b/dlls/uiribbon/uiribbon_classes.idl
new file mode 100644
index 0000000000..bd8bdde6b6
--- /dev/null
+++ b/dlls/uiribbon/uiribbon_classes.idl
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2017 Fabian Maurer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#pragma makedep register
+
+#include "uiribbon.idl"
diff --git a/dlls/uiribbon/uiribbon_private.h b/dlls/uiribbon/uiribbon_private.h
new file mode 100644
index 0000000000..9d7481533d
--- /dev/null
+++ b/dlls/uiribbon/uiribbon_private.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2017 Fabian Maurer
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __UIRIBBON_PRIVATE_INCLUDED__
+#define __UIRIBBON_PRIVATE_INCLUDED__
+
+#include "uiribbon.h"
+
+typedef struct {
+    IUIFramework IUIFramework_iface;
+    LONG ref;
+} UIRibbonFrameworkImpl;
+
+HRESULT UIRibbonFrameworkImpl_Create(IUnknown *pUnkOuter, void **ppObj) DECLSPEC_HIDDEN;
+
+
+#endif /* __UIRIBBON_PRIVATE_INCLUDED__ */
-- 
2.13.3




More information about the wine-patches mailing list