gdiplus: Implemented GdipSetClipHrgn.
[wine] / dlls / msctf / documentmgr.c
1 /*
2  *  ITfDocumentMgr implementation
3  *
4  *  Copyright 2009 Aric Stewart, CodeWeavers
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "config.h"
22
23 #include <stdarg.h>
24
25 #define COBJMACROS
26
27 #include "wine/debug.h"
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31 #include "winuser.h"
32 #include "shlwapi.h"
33 #include "winerror.h"
34 #include "objbase.h"
35
36 #include "wine/unicode.h"
37
38 #include "msctf.h"
39 #include "msctf_internal.h"
40
41 WINE_DEFAULT_DEBUG_CHANNEL(msctf);
42
43 typedef struct tagDocumentMgr {
44     const ITfDocumentMgrVtbl *DocumentMgrVtbl;
45     LONG refCount;
46 } DocumentMgr;
47
48 static void DocumentMgr_Destructor(DocumentMgr *This)
49 {
50     TRACE("destroying %p\n", This);
51     HeapFree(GetProcessHeap(),0,This);
52 }
53
54 static HRESULT WINAPI DocumentMgr_QueryInterface(ITfDocumentMgr *iface, REFIID iid, LPVOID *ppvOut)
55 {
56     DocumentMgr *This = (DocumentMgr *)iface;
57     *ppvOut = NULL;
58
59     if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfDocumentMgr))
60     {
61         *ppvOut = This;
62     }
63
64     if (*ppvOut)
65     {
66         IUnknown_AddRef(iface);
67         return S_OK;
68     }
69
70     WARN("unsupported interface: %s\n", debugstr_guid(iid));
71     return E_NOINTERFACE;
72 }
73
74 static ULONG WINAPI DocumentMgr_AddRef(ITfDocumentMgr *iface)
75 {
76     DocumentMgr *This = (DocumentMgr *)iface;
77     return InterlockedIncrement(&This->refCount);
78 }
79
80 static ULONG WINAPI DocumentMgr_Release(ITfDocumentMgr *iface)
81 {
82     DocumentMgr *This = (DocumentMgr *)iface;
83     ULONG ret;
84
85     ret = InterlockedDecrement(&This->refCount);
86     if (ret == 0)
87         DocumentMgr_Destructor(This);
88     return ret;
89 }
90
91 /*****************************************************
92  * ITfDocumentMgr functions
93  *****************************************************/
94 static HRESULT WINAPI DocumentMgr_CreateContext(ITfDocumentMgr *iface,
95         TfClientId tidOwner,
96         DWORD dwFlags, IUnknown *punk, ITfContext **ppic,
97         TfEditCookie *pecTextStore)
98 {
99     DocumentMgr *This = (DocumentMgr *)iface;
100     FIXME("STUB:(%p)\n",This);
101     return E_NOTIMPL;
102 }
103
104 static HRESULT WINAPI DocumentMgr_Push(ITfDocumentMgr *iface, ITfContext *pic)
105 {
106     DocumentMgr *This = (DocumentMgr *)iface;
107     FIXME("STUB:(%p)\n",This);
108     return E_NOTIMPL;
109 }
110
111 static HRESULT WINAPI DocumentMgr_Pop(ITfDocumentMgr *iface, DWORD dwFlags)
112 {
113     DocumentMgr *This = (DocumentMgr *)iface;
114     FIXME("STUB:(%p)\n",This);
115     return E_NOTIMPL;
116 }
117
118 static HRESULT WINAPI DocumentMgr_GetTop(ITfDocumentMgr *iface, ITfContext **ppic)
119 {
120     DocumentMgr *This = (DocumentMgr *)iface;
121     FIXME("STUB:(%p)\n",This);
122     return E_NOTIMPL;
123 }
124
125 static HRESULT WINAPI DocumentMgr_GetBase(ITfDocumentMgr *iface, ITfContext **ppic)
126 {
127     DocumentMgr *This = (DocumentMgr *)iface;
128     FIXME("STUB:(%p)\n",This);
129     return E_NOTIMPL;
130 }
131
132 static HRESULT WINAPI DocumentMgr_EnumContexts(ITfDocumentMgr *iface, IEnumTfContexts **ppEnum)
133 {
134     DocumentMgr *This = (DocumentMgr *)iface;
135     FIXME("STUB:(%p)\n",This);
136     return E_NOTIMPL;
137 }
138
139 static const ITfDocumentMgrVtbl DocumentMgr_DocumentMgrVtbl =
140 {
141     DocumentMgr_QueryInterface,
142     DocumentMgr_AddRef,
143     DocumentMgr_Release,
144
145     DocumentMgr_CreateContext,
146     DocumentMgr_Push,
147     DocumentMgr_Pop,
148     DocumentMgr_GetTop,
149     DocumentMgr_GetBase,
150     DocumentMgr_EnumContexts
151 };
152
153 HRESULT DocumentMgr_Constructor(ITfDocumentMgr **ppOut)
154 {
155     DocumentMgr *This;
156
157     This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(DocumentMgr));
158     if (This == NULL)
159         return E_OUTOFMEMORY;
160
161     This->DocumentMgrVtbl= &DocumentMgr_DocumentMgrVtbl;
162     This->refCount = 1;
163
164     TRACE("returning %p\n", This);
165     *ppOut = (ITfDocumentMgr*)This;
166     return S_OK;
167 }