1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
|
// 24 december 2014
struct tableAcc {
IAccessibleVtbl *vtbl;
ULONG refcount;
struct table *t;
IAccessible *std;
};
#define TA ((struct tableAcc *) this)
static HRESULT STDMETHODCALLTYPE tableAccQueryInterface(IAccessible *this, REFIID riid, void **ppvObject)
{
if (ppvObject == NULL)
return E_POINTER;
if (IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_IDispatch) ||
IsEqualIID(riid, &IID_IAccessible)) {
// TODO figure out what pointer to use here
TA->vtbl->AddRef(TA);
*ppvObject = (void *) this;
return S_OK;
}
*ppvObject = NULL;
return E_NOINTERFACE;
}
// TODO use InterlockedIncrement()/InterlockedDecrement() for these?
static ULONG STDMETHODCALLTYPE tableAccAddRef(IAccessible *this)
{
TA->refcount++;
// TODO correct?
return TA->refcount;
}
static ULONG STDMETHODCALLTYPE tableAccRelease(IAccessible *this)
{
TA->refcount--;
if (TA->refcount == 0) {
IAccessible_Release(TA->std);
tableFree(TA, "error freeing Table accessibility object");
return 0;
}
return TA->refcount;
}
// disregard IDispatch: http://msdn.microsoft.com/en-us/library/windows/desktop/cc307844.aspx
// TODO DISP_E_MEMBERNOTFOUND? http://blogs.msdn.com/b/saraford/archive/2004/08/20/which-controls-support-which-msaa-properties-and-how-these-controls-implement-msaa-properties.aspx
// TODO relegate these to the standard object?
static HRESULT STDMETHODCALLTYPE tableAccGetTypeInfoCount(IAccessible *this, UINT *pctinfo)
{
if (pctinfo == NULL)
return E_INVALIDARG;
// TODO assign something to *pctinfo?
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE tableAccGetTypeInfo(IAccessible *this, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
{
if (ppTInfo == NULL)
return E_INVALIDARG;
*ppTInfo = NULL;
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE tableAccGetIDsOfNames(IAccessible *this, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
{
// TODO verify this one
if (rgDispId == NULL)
return E_INVALIDARG;
// TODO overwrite rgDispId?
return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE tableAccInvoke(IAccessible *this, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
// TODO check this one
return E_NOTIMPL;
}
// IAccessible
static HRESULT STDMETHODCALLTYPE tableAccget_accParent(IAccessible *this, IDispatch **ppdispParent)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accChildCount(IAccessible *this, long *pcountChildren)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accChild(IAccessible *this, VARIANT varChild, IDispatch **ppdispChild)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accName(IAccessible *this, VARIANT varChild, BSTR *pszName)
{
printf("tableAccget_accName()\n");
// TODO check pointer
if (varChild.vt != VT_I4) {
printf("invalid arg\n");
*pszName = NULL;
return E_INVALIDARG;
}
if (varChild.lVal == CHILDID_SELF)
; // TODO standard accessible object
// TODO actually get the real name
printf("returning name\n");
*pszName = SysAllocString(L"This is a test of the accessibility interface.");
// TODO check null pointer
return S_OK;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accValue(IAccessible *this, VARIANT varChild, BSTR *pszValue)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accDescription(IAccessible *this, VARIANT varChild, BSTR *pszDescription)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accRole(IAccessible *this, VARIANT varChild, VARIANT *pvarRole)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accState(IAccessible *this, VARIANT varChild, VARIANT *pvarState)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accHelp(IAccessible *this, VARIANT varChild, BSTR *pszHelp)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accHelpTopic(IAccessible *this, BSTR *pszHelpFile, VARIANT varChild, long *pidTopic)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accKeyboardShortcut(IAccessible *this, VARIANT varChild, BSTR *pszKeyboardShortcut)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accFocus(IAccessible *this, VARIANT *pvarChild)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accSelection(IAccessible *this, VARIANT *pvarChildren)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccget_accDefaultAction(IAccessible *this, VARIANT varChild, BSTR *pszDefaultAction)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccaccSelect(IAccessible *this, long flagsSelect, VARIANT varChild)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccaccLocation(IAccessible *this, long *pxLeft, long *pyTop, long *pcxWidth, long *pcyHeight, VARIANT varChild)
{
// TODO
return IAccessible_accLocation(TA->std, pxLeft, pyTop, pcxWidth, pcyHeight, varChild);
}
static HRESULT STDMETHODCALLTYPE tableAccaccNavigate(IAccessible *this, long navDir, VARIANT varStart, VARIANT *pvarEndUpAt)
{
// TODO
return IAccessible_accNavigate(TA->std, navDir, varStart, pvarEndUpAt);
}
static HRESULT STDMETHODCALLTYPE tableAccaccHitTest(IAccessible *this, long xLeft, long yTop, VARIANT *pvarChild)
{
// TODO
return IAccessible_accHitTest(TA->std, xLeft, yTop, pvarChild);
}
static HRESULT STDMETHODCALLTYPE tableAccaccDoDefaultAction(IAccessible *this, VARIANT varChild)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccput_accName(IAccessible *this, VARIANT varChild, BSTR szName)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static HRESULT STDMETHODCALLTYPE tableAccput_accValue(IAccessible *this, VARIANT varChild, BSTR szValue)
{
// TODO
return DISP_E_MEMBERNOTFOUND;
}
static const IAccessibleVtbl tableAccVtbl = {
.QueryInterface = tableAccQueryInterface,
.AddRef = tableAccAddRef,
.Release = tableAccRelease,
.GetTypeInfoCount = tableAccGetTypeInfoCount,
.GetTypeInfo = tableAccGetTypeInfo,
.GetIDsOfNames = tableAccGetIDsOfNames,
.Invoke = tableAccInvoke,
.get_accParent = tableAccget_accParent,
.get_accChildCount = tableAccget_accChildCount,
.get_accChild = tableAccget_accChild,
.get_accName = tableAccget_accName,
.get_accValue = tableAccget_accValue,
.get_accDescription = tableAccget_accDescription,
.get_accRole = tableAccget_accRole,
.get_accState = tableAccget_accState,
.get_accHelp = tableAccget_accHelp,
.get_accHelpTopic = tableAccget_accHelpTopic,
.get_accKeyboardShortcut = tableAccget_accKeyboardShortcut,
.get_accFocus = tableAccget_accFocus,
.get_accSelection = tableAccget_accSelection,
.get_accDefaultAction = tableAccget_accDefaultAction,
.accSelect = tableAccaccSelect,
.accLocation = tableAccaccLocation,
.accNavigate = tableAccaccNavigate,
.accHitTest = tableAccaccHitTest,
.accDoDefaultAction = tableAccaccDoDefaultAction,
.put_accName = tableAccput_accName,
.put_accValue = tableAccput_accValue,
};
static struct tableAcc *newTableAcc(struct table *t)
{
struct tableAcc *ta;
HRESULT hr;
IAccessible *std;
ta = (struct tableAcc *) tableAlloc(sizeof (struct tableAcc), "error creating Table accessibility object");
ta->vtbl = &tableAccVtbl;
ta->vtbl->AddRef(ta);
ta->t = t;
hr = CreateStdAccessibleObject(t->hwnd, OBJID_CLIENT, &IID_IAccessible, &std);
if (hr != S_OK)
// TODO panichresult
panic("error creating standard accessible object for Table");
ta->std = std;
return ta;
}
static void freeTableAcc(struct tableAcc *ta)
{
ta->t = NULL;
ta->vtbl->Release(ta);
}
HANDLER(accessibilityHandler)
{
if (uMsg != WM_GETOBJECT)
return FALSE;
if (((DWORD) lParam) != OBJID_CLIENT)
return FALSE;
*lResult = LresultFromObject(&IID_IAccessible, wParam, t->ta);
// TODO check *lResult
return TRUE;
}
|