d2d1: Implement ID2D1EffectContext_GetDpi().
[wine.git] / dlls / uiribbon / main.c
blobb7749ae4710d09be326da8eda6038b659d83cc52
1 /*
2 * Copyright 2017 Fabian Maurer
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 #include <stdarg.h>
20 #include <string.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
29 #include "ole2.h"
30 #include "rpcproxy.h"
32 /* Define GUIDs, but only our own */
33 #include <unknwn.h>
34 #include <propsys.h>
35 #include "initguid.h"
36 #include "uiribbon_private.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(uiribbon);
42 typedef struct {
43 IClassFactory IClassFactory_iface;
45 LONG ref;
46 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, void **ppObj);
47 } IClassFactoryImpl;
49 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
51 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
54 struct object_creation_info
56 const CLSID *clsid;
57 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, void **ppObj);
60 static const struct object_creation_info object_creation[] =
62 { &CLSID_UIRibbonFramework, UIRibbonFrameworkImpl_Create },
65 static HRESULT WINAPI XFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid, void **ppobj)
67 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
69 if (IsEqualGUID(riid, &IID_IUnknown)
70 || IsEqualGUID(riid, &IID_IClassFactory))
72 IClassFactory_AddRef(iface);
73 *ppobj = &This->IClassFactory_iface;
74 return S_OK;
77 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
78 return E_NOINTERFACE;
81 static ULONG WINAPI XFCF_AddRef(LPCLASSFACTORY iface)
83 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
84 return InterlockedIncrement(&This->ref);
87 static ULONG WINAPI XFCF_Release(LPCLASSFACTORY iface)
89 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
91 ULONG ref = InterlockedDecrement(&This->ref);
93 if (ref == 0)
94 HeapFree(GetProcessHeap(), 0, This);
96 return ref;
99 static HRESULT WINAPI XFCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, void **ppobj)
101 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
102 HRESULT hres;
103 LPUNKNOWN punk;
105 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
107 *ppobj = NULL;
108 hres = This->pfnCreateInstance(pOuter, (void **) &punk);
109 if (SUCCEEDED(hres)) {
110 hres = IUnknown_QueryInterface(punk, riid, ppobj);
111 IUnknown_Release(punk);
113 return hres;
116 static HRESULT WINAPI XFCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
118 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
119 FIXME("(%p)->(%d), stub!\n",This,dolock);
120 return S_OK;
123 static const IClassFactoryVtbl XFCF_Vtbl =
125 XFCF_QueryInterface,
126 XFCF_AddRef,
127 XFCF_Release,
128 XFCF_CreateInstance,
129 XFCF_LockServer
132 /*******************************************************************************
133 * Retrieves class object from a DLL object
135 * NOTES
136 * Docs say returns STDAPI
138 * PARAMS
139 * rclsid [I] CLSID for the class object
140 * riid [I] Reference to identifier of interface for class object
141 * ppv [O] Address of variable to receive interface pointer for riid
143 * RETURNS
144 * Success: S_OK
145 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
146 * E_UNEXPECTED
148 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
150 unsigned int i;
151 IClassFactoryImpl *factory;
153 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
155 if ( !IsEqualGUID( &IID_IClassFactory, riid )
156 && ! IsEqualGUID( &IID_IUnknown, riid) )
157 return E_NOINTERFACE;
159 for (i = 0; i < ARRAY_SIZE(object_creation); i++)
161 if (IsEqualGUID(object_creation[i].clsid, rclsid))
162 break;
165 if (i == ARRAY_SIZE(object_creation))
167 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
168 return CLASS_E_CLASSNOTAVAILABLE;
171 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
172 if (factory == NULL) return E_OUTOFMEMORY;
174 factory->IClassFactory_iface.lpVtbl = &XFCF_Vtbl;
175 factory->ref = 1;
177 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
179 *ppv = &(factory->IClassFactory_iface);
180 return S_OK;