|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim:expandtab:shiftwidth=2:tabstop=2: |
|
3 */ |
|
4 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
7 |
|
8 #include "ia2AccessibleTable.h" |
|
9 |
|
10 #include "Accessible2.h" |
|
11 #include "AccessibleTable_i.c" |
|
12 #include "AccessibleTable2_i.c" |
|
13 |
|
14 #include "AccessibleWrap.h" |
|
15 #include "IUnknownImpl.h" |
|
16 #include "Statistics.h" |
|
17 #include "TableAccessible.h" |
|
18 |
|
19 #include "nsCOMPtr.h" |
|
20 #include "nsString.h" |
|
21 |
|
22 using namespace mozilla::a11y; |
|
23 |
|
24 // IUnknown |
|
25 |
|
26 STDMETHODIMP |
|
27 ia2AccessibleTable::QueryInterface(REFIID iid, void** ppv) |
|
28 { |
|
29 if (!ppv) |
|
30 return E_INVALIDARG; |
|
31 |
|
32 *ppv = nullptr; |
|
33 |
|
34 if (IID_IAccessibleTable == iid) { |
|
35 statistics::IAccessibleTableUsed(); |
|
36 *ppv = static_cast<IAccessibleTable*>(this); |
|
37 (reinterpret_cast<IUnknown*>(*ppv))->AddRef(); |
|
38 return S_OK; |
|
39 } |
|
40 |
|
41 if (IID_IAccessibleTable2 == iid) { |
|
42 *ppv = static_cast<IAccessibleTable2*>(this); |
|
43 (reinterpret_cast<IUnknown*>(*ppv))->AddRef(); |
|
44 return S_OK; |
|
45 } |
|
46 |
|
47 return E_NOINTERFACE; |
|
48 } |
|
49 |
|
50 //////////////////////////////////////////////////////////////////////////////// |
|
51 // IAccessibleTable |
|
52 |
|
53 STDMETHODIMP |
|
54 ia2AccessibleTable::get_accessibleAt(long aRowIdx, long aColIdx, |
|
55 IUnknown** aAccessible) |
|
56 { |
|
57 return get_cellAt(aRowIdx, aColIdx, aAccessible); |
|
58 } |
|
59 |
|
60 STDMETHODIMP |
|
61 ia2AccessibleTable::get_caption(IUnknown** aAccessible) |
|
62 { |
|
63 A11Y_TRYBLOCK_BEGIN |
|
64 |
|
65 if (!aAccessible) |
|
66 return E_INVALIDARG; |
|
67 |
|
68 *aAccessible = nullptr; |
|
69 if (!mTable) |
|
70 return CO_E_OBJNOTCONNECTED; |
|
71 |
|
72 AccessibleWrap* caption = static_cast<AccessibleWrap*>(mTable->Caption()); |
|
73 if (!caption) |
|
74 return S_FALSE; |
|
75 |
|
76 (*aAccessible = static_cast<IAccessible*>(caption))->AddRef(); |
|
77 return S_OK; |
|
78 |
|
79 A11Y_TRYBLOCK_END |
|
80 } |
|
81 |
|
82 STDMETHODIMP |
|
83 ia2AccessibleTable::get_childIndex(long aRowIdx, long aColIdx, |
|
84 long* aChildIdx) |
|
85 { |
|
86 A11Y_TRYBLOCK_BEGIN |
|
87 |
|
88 if (!aChildIdx) |
|
89 return E_INVALIDARG; |
|
90 |
|
91 *aChildIdx = 0; |
|
92 if (!mTable) |
|
93 return CO_E_OBJNOTCONNECTED; |
|
94 |
|
95 if (aRowIdx < 0 || aColIdx < 0 || |
|
96 static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() || |
|
97 static_cast<uint32_t>(aColIdx) >= mTable->ColCount()) |
|
98 return E_INVALIDARG; |
|
99 |
|
100 *aChildIdx = mTable->CellIndexAt(aRowIdx, aColIdx); |
|
101 return S_OK; |
|
102 |
|
103 A11Y_TRYBLOCK_END |
|
104 } |
|
105 |
|
106 STDMETHODIMP |
|
107 ia2AccessibleTable::get_columnDescription(long aColIdx, BSTR* aDescription) |
|
108 { |
|
109 A11Y_TRYBLOCK_BEGIN |
|
110 |
|
111 if (!aDescription) |
|
112 return E_INVALIDARG; |
|
113 |
|
114 *aDescription = nullptr; |
|
115 if (!mTable) |
|
116 return CO_E_OBJNOTCONNECTED; |
|
117 |
|
118 if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount()) |
|
119 return E_INVALIDARG; |
|
120 |
|
121 nsAutoString descr; |
|
122 mTable->ColDescription(aColIdx, descr); |
|
123 if (descr.IsEmpty()) |
|
124 return S_FALSE; |
|
125 |
|
126 *aDescription = ::SysAllocStringLen(descr.get(), descr.Length()); |
|
127 return *aDescription ? S_OK : E_OUTOFMEMORY; |
|
128 |
|
129 A11Y_TRYBLOCK_END |
|
130 } |
|
131 |
|
132 STDMETHODIMP |
|
133 ia2AccessibleTable::get_columnExtentAt(long aRowIdx, long aColIdx, |
|
134 long* aSpan) |
|
135 { |
|
136 A11Y_TRYBLOCK_BEGIN |
|
137 |
|
138 if (!aSpan) |
|
139 return E_INVALIDARG; |
|
140 |
|
141 *aSpan = 0; |
|
142 if (!mTable) |
|
143 return CO_E_OBJNOTCONNECTED; |
|
144 |
|
145 if (aRowIdx < 0 || aColIdx < 0 || |
|
146 static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() || |
|
147 static_cast<uint32_t>(aColIdx) >= mTable->ColCount()) |
|
148 return E_INVALIDARG; |
|
149 |
|
150 *aSpan = mTable->ColExtentAt(aRowIdx, aColIdx); |
|
151 return S_OK; |
|
152 |
|
153 A11Y_TRYBLOCK_END |
|
154 } |
|
155 |
|
156 STDMETHODIMP |
|
157 ia2AccessibleTable::get_columnHeader(IAccessibleTable** aAccessibleTable, |
|
158 long* aStartingRowIndex) |
|
159 { |
|
160 A11Y_TRYBLOCK_BEGIN |
|
161 |
|
162 if (!aAccessibleTable || !aStartingRowIndex) |
|
163 return E_INVALIDARG; |
|
164 |
|
165 *aAccessibleTable = nullptr; |
|
166 *aStartingRowIndex = -1; |
|
167 return E_NOTIMPL; |
|
168 |
|
169 A11Y_TRYBLOCK_END |
|
170 } |
|
171 |
|
172 STDMETHODIMP |
|
173 ia2AccessibleTable::get_columnIndex(long aCellIdx, long* aColIdx) |
|
174 { |
|
175 A11Y_TRYBLOCK_BEGIN |
|
176 |
|
177 if (!aColIdx) |
|
178 return E_INVALIDARG; |
|
179 |
|
180 *aColIdx = 0; |
|
181 if (!mTable) |
|
182 return CO_E_OBJNOTCONNECTED; |
|
183 |
|
184 if (aCellIdx < 0 || |
|
185 static_cast<uint32_t>(aCellIdx) >= mTable->ColCount() * mTable->RowCount()) |
|
186 return E_INVALIDARG; |
|
187 |
|
188 *aColIdx = mTable->ColIndexAt(aCellIdx); |
|
189 return S_OK; |
|
190 |
|
191 A11Y_TRYBLOCK_END |
|
192 } |
|
193 |
|
194 STDMETHODIMP |
|
195 ia2AccessibleTable::get_nColumns(long* aColCount) |
|
196 { |
|
197 A11Y_TRYBLOCK_BEGIN |
|
198 |
|
199 if (!aColCount) |
|
200 return E_INVALIDARG; |
|
201 |
|
202 *aColCount = 0; |
|
203 if (!mTable) |
|
204 return CO_E_OBJNOTCONNECTED; |
|
205 |
|
206 *aColCount = mTable->ColCount(); |
|
207 return S_OK; |
|
208 |
|
209 A11Y_TRYBLOCK_END |
|
210 } |
|
211 |
|
212 STDMETHODIMP |
|
213 ia2AccessibleTable::get_nRows(long* aRowCount) |
|
214 { |
|
215 A11Y_TRYBLOCK_BEGIN |
|
216 |
|
217 if (!aRowCount) |
|
218 return E_INVALIDARG; |
|
219 |
|
220 *aRowCount = 0; |
|
221 if (!mTable) |
|
222 return CO_E_OBJNOTCONNECTED; |
|
223 |
|
224 *aRowCount = mTable->RowCount(); |
|
225 return S_OK; |
|
226 |
|
227 A11Y_TRYBLOCK_END |
|
228 } |
|
229 |
|
230 STDMETHODIMP |
|
231 ia2AccessibleTable::get_nSelectedChildren(long* aChildCount) |
|
232 { |
|
233 return get_nSelectedCells(aChildCount); |
|
234 } |
|
235 |
|
236 STDMETHODIMP |
|
237 ia2AccessibleTable::get_nSelectedColumns(long* aColCount) |
|
238 { |
|
239 A11Y_TRYBLOCK_BEGIN |
|
240 |
|
241 if (!aColCount) |
|
242 return E_INVALIDARG; |
|
243 |
|
244 *aColCount = 0; |
|
245 if (!mTable) |
|
246 return CO_E_OBJNOTCONNECTED; |
|
247 |
|
248 *aColCount = mTable->SelectedColCount(); |
|
249 return S_OK; |
|
250 |
|
251 A11Y_TRYBLOCK_END |
|
252 } |
|
253 |
|
254 STDMETHODIMP |
|
255 ia2AccessibleTable::get_nSelectedRows(long* aRowCount) |
|
256 { |
|
257 A11Y_TRYBLOCK_BEGIN |
|
258 |
|
259 if (!aRowCount) |
|
260 return E_INVALIDARG; |
|
261 |
|
262 *aRowCount = 0; |
|
263 if (!mTable) |
|
264 return CO_E_OBJNOTCONNECTED; |
|
265 |
|
266 *aRowCount = mTable->SelectedRowCount(); |
|
267 |
|
268 return S_OK; |
|
269 |
|
270 A11Y_TRYBLOCK_END |
|
271 } |
|
272 |
|
273 STDMETHODIMP |
|
274 ia2AccessibleTable::get_rowDescription(long aRowIdx, BSTR* aDescription) |
|
275 { |
|
276 A11Y_TRYBLOCK_BEGIN |
|
277 |
|
278 if (!aDescription) |
|
279 return E_INVALIDARG; |
|
280 |
|
281 *aDescription = nullptr; |
|
282 if (!mTable) |
|
283 return CO_E_OBJNOTCONNECTED; |
|
284 |
|
285 if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount()) |
|
286 return E_INVALIDARG; |
|
287 |
|
288 nsAutoString descr; |
|
289 mTable->RowDescription(aRowIdx, descr); |
|
290 if (descr.IsEmpty()) |
|
291 return S_FALSE; |
|
292 |
|
293 *aDescription = ::SysAllocStringLen(descr.get(), descr.Length()); |
|
294 return *aDescription ? S_OK : E_OUTOFMEMORY; |
|
295 |
|
296 A11Y_TRYBLOCK_END |
|
297 } |
|
298 |
|
299 STDMETHODIMP |
|
300 ia2AccessibleTable::get_rowExtentAt(long aRowIdx, long aColIdx, long* aSpan) |
|
301 { |
|
302 A11Y_TRYBLOCK_BEGIN |
|
303 |
|
304 if (!aSpan) |
|
305 return E_INVALIDARG; |
|
306 |
|
307 *aSpan = 0; |
|
308 if (!mTable) |
|
309 return CO_E_OBJNOTCONNECTED; |
|
310 |
|
311 if (aRowIdx < 0 || aColIdx < 0 || |
|
312 static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() || |
|
313 static_cast<uint32_t>(aColIdx) >= mTable->ColCount()) |
|
314 return E_INVALIDARG; |
|
315 |
|
316 *aSpan = mTable->RowExtentAt(aRowIdx, aColIdx); |
|
317 return S_OK; |
|
318 |
|
319 A11Y_TRYBLOCK_END |
|
320 } |
|
321 |
|
322 STDMETHODIMP |
|
323 ia2AccessibleTable::get_rowHeader(IAccessibleTable** aAccessibleTable, |
|
324 long* aStartingColumnIndex) |
|
325 { |
|
326 A11Y_TRYBLOCK_BEGIN |
|
327 |
|
328 if (!aAccessibleTable || !aStartingColumnIndex) |
|
329 return E_INVALIDARG; |
|
330 |
|
331 *aAccessibleTable = nullptr; |
|
332 *aStartingColumnIndex = -1; |
|
333 return E_NOTIMPL; |
|
334 |
|
335 A11Y_TRYBLOCK_END |
|
336 } |
|
337 |
|
338 STDMETHODIMP |
|
339 ia2AccessibleTable::get_rowIndex(long aCellIdx, long* aRowIdx) |
|
340 { |
|
341 A11Y_TRYBLOCK_BEGIN |
|
342 |
|
343 if (!aRowIdx) |
|
344 return E_INVALIDARG; |
|
345 |
|
346 *aRowIdx = 0; |
|
347 if (!mTable) |
|
348 return CO_E_OBJNOTCONNECTED; |
|
349 |
|
350 if (aCellIdx < 0 || |
|
351 static_cast<uint32_t>(aCellIdx) >= mTable->ColCount() * mTable->RowCount()) |
|
352 return E_INVALIDARG; |
|
353 |
|
354 *aRowIdx = mTable->RowIndexAt(aCellIdx); |
|
355 return S_OK; |
|
356 |
|
357 A11Y_TRYBLOCK_END |
|
358 } |
|
359 |
|
360 STDMETHODIMP |
|
361 ia2AccessibleTable::get_selectedChildren(long aMaxChildren, long** aChildren, |
|
362 long* aNChildren) |
|
363 { |
|
364 A11Y_TRYBLOCK_BEGIN |
|
365 |
|
366 if (!aChildren || !aNChildren) |
|
367 return E_INVALIDARG; |
|
368 |
|
369 *aChildren = nullptr; |
|
370 *aNChildren = 0; |
|
371 if (!mTable) |
|
372 return CO_E_OBJNOTCONNECTED; |
|
373 |
|
374 nsAutoTArray<uint32_t, 30> cellIndices; |
|
375 mTable->SelectedCellIndices(&cellIndices); |
|
376 |
|
377 uint32_t maxCells = cellIndices.Length(); |
|
378 if (maxCells == 0) |
|
379 return S_FALSE; |
|
380 |
|
381 *aChildren = static_cast<LONG*>(moz_xmalloc(sizeof(LONG) * maxCells)); |
|
382 *aNChildren = maxCells; |
|
383 for (uint32_t i = 0; i < maxCells; i++) |
|
384 (*aChildren)[i] = cellIndices[i]; |
|
385 |
|
386 return S_OK; |
|
387 |
|
388 A11Y_TRYBLOCK_END |
|
389 } |
|
390 |
|
391 STDMETHODIMP |
|
392 ia2AccessibleTable::get_selectedColumns(long aMaxColumns, long** aColumns, |
|
393 long* aNColumns) |
|
394 { |
|
395 A11Y_TRYBLOCK_BEGIN |
|
396 |
|
397 return get_selectedColumns(aColumns, aNColumns); |
|
398 |
|
399 A11Y_TRYBLOCK_END |
|
400 } |
|
401 |
|
402 STDMETHODIMP |
|
403 ia2AccessibleTable::get_selectedRows(long aMaxRows, long** aRows, long* aNRows) |
|
404 { |
|
405 A11Y_TRYBLOCK_BEGIN |
|
406 |
|
407 return get_selectedRows(aRows, aNRows); |
|
408 |
|
409 A11Y_TRYBLOCK_END |
|
410 } |
|
411 |
|
412 STDMETHODIMP |
|
413 ia2AccessibleTable::get_summary(IUnknown** aAccessible) |
|
414 { |
|
415 A11Y_TRYBLOCK_BEGIN |
|
416 |
|
417 if (!aAccessible) |
|
418 return E_INVALIDARG; |
|
419 |
|
420 // Neither html:table nor xul:tree nor ARIA grid/tree have an ability to |
|
421 // link an accessible object to specify a summary. There is closes method |
|
422 // in nsIAccessibleTable::summary to get a summary as a string which is not |
|
423 // mapped directly to IAccessible2. |
|
424 |
|
425 *aAccessible = nullptr; |
|
426 return S_FALSE; |
|
427 |
|
428 A11Y_TRYBLOCK_END |
|
429 } |
|
430 |
|
431 STDMETHODIMP |
|
432 ia2AccessibleTable::get_isColumnSelected(long aColIdx, boolean* aIsSelected) |
|
433 { |
|
434 A11Y_TRYBLOCK_BEGIN |
|
435 |
|
436 if (!aIsSelected) |
|
437 return E_INVALIDARG; |
|
438 |
|
439 *aIsSelected = false; |
|
440 if (!mTable) |
|
441 return CO_E_OBJNOTCONNECTED; |
|
442 |
|
443 if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount()) |
|
444 return E_INVALIDARG; |
|
445 |
|
446 *aIsSelected = mTable->IsColSelected(aColIdx); |
|
447 return S_OK; |
|
448 |
|
449 A11Y_TRYBLOCK_END |
|
450 } |
|
451 |
|
452 STDMETHODIMP |
|
453 ia2AccessibleTable::get_isRowSelected(long aRowIdx, boolean* aIsSelected) |
|
454 { |
|
455 A11Y_TRYBLOCK_BEGIN |
|
456 |
|
457 if (!aIsSelected) |
|
458 return E_INVALIDARG; |
|
459 |
|
460 *aIsSelected = false; |
|
461 if (!mTable) |
|
462 return CO_E_OBJNOTCONNECTED; |
|
463 |
|
464 if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount()) |
|
465 return E_INVALIDARG; |
|
466 |
|
467 *aIsSelected = mTable->IsRowSelected(aRowIdx); |
|
468 return S_OK; |
|
469 |
|
470 A11Y_TRYBLOCK_END |
|
471 } |
|
472 |
|
473 STDMETHODIMP |
|
474 ia2AccessibleTable::get_isSelected(long aRowIdx, long aColIdx, |
|
475 boolean* aIsSelected) |
|
476 { |
|
477 A11Y_TRYBLOCK_BEGIN |
|
478 |
|
479 if (!aIsSelected) |
|
480 return E_INVALIDARG; |
|
481 |
|
482 *aIsSelected = false; |
|
483 if (!mTable) |
|
484 return CO_E_OBJNOTCONNECTED; |
|
485 |
|
486 if (aRowIdx < 0 || aColIdx < 0 || |
|
487 static_cast<uint32_t>(aColIdx) >= mTable->ColCount() || |
|
488 static_cast<uint32_t>(aRowIdx) >= mTable->RowCount()) |
|
489 return E_INVALIDARG; |
|
490 |
|
491 *aIsSelected = mTable->IsCellSelected(aRowIdx, aColIdx); |
|
492 return S_OK; |
|
493 |
|
494 A11Y_TRYBLOCK_END |
|
495 } |
|
496 |
|
497 STDMETHODIMP |
|
498 ia2AccessibleTable::selectRow(long aRowIdx) |
|
499 { |
|
500 A11Y_TRYBLOCK_BEGIN |
|
501 |
|
502 if (!mTable) |
|
503 return CO_E_OBJNOTCONNECTED; |
|
504 |
|
505 if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount()) |
|
506 return E_INVALIDARG; |
|
507 |
|
508 mTable->SelectRow(aRowIdx); |
|
509 return S_OK; |
|
510 |
|
511 A11Y_TRYBLOCK_END |
|
512 } |
|
513 |
|
514 STDMETHODIMP |
|
515 ia2AccessibleTable::selectColumn(long aColIdx) |
|
516 { |
|
517 A11Y_TRYBLOCK_BEGIN |
|
518 |
|
519 if (!mTable) |
|
520 return CO_E_OBJNOTCONNECTED; |
|
521 |
|
522 if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount()) |
|
523 return E_INVALIDARG; |
|
524 |
|
525 mTable->SelectCol(aColIdx); |
|
526 return S_OK; |
|
527 |
|
528 A11Y_TRYBLOCK_END |
|
529 } |
|
530 |
|
531 STDMETHODIMP |
|
532 ia2AccessibleTable::unselectRow(long aRowIdx) |
|
533 { |
|
534 A11Y_TRYBLOCK_BEGIN |
|
535 |
|
536 if (!mTable) |
|
537 return CO_E_OBJNOTCONNECTED; |
|
538 |
|
539 if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount()) |
|
540 return E_INVALIDARG; |
|
541 |
|
542 mTable->UnselectRow(aRowIdx); |
|
543 return S_OK; |
|
544 |
|
545 A11Y_TRYBLOCK_END |
|
546 } |
|
547 |
|
548 STDMETHODIMP |
|
549 ia2AccessibleTable::unselectColumn(long aColIdx) |
|
550 { |
|
551 A11Y_TRYBLOCK_BEGIN |
|
552 |
|
553 if (!mTable) |
|
554 return CO_E_OBJNOTCONNECTED; |
|
555 |
|
556 if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount()) |
|
557 return E_INVALIDARG; |
|
558 |
|
559 mTable->UnselectCol(aColIdx); |
|
560 return S_OK; |
|
561 |
|
562 A11Y_TRYBLOCK_END |
|
563 } |
|
564 |
|
565 STDMETHODIMP |
|
566 ia2AccessibleTable::get_rowColumnExtentsAtIndex(long aCellIdx, long* aRowIdx, |
|
567 long* aColIdx, |
|
568 long* aRowExtents, |
|
569 long* aColExtents, |
|
570 boolean* aIsSelected) |
|
571 { |
|
572 A11Y_TRYBLOCK_BEGIN |
|
573 |
|
574 if (!aRowIdx || !aColIdx || !aRowExtents || !aColExtents || !aIsSelected) |
|
575 return E_INVALIDARG; |
|
576 |
|
577 *aRowIdx = 0; |
|
578 *aColIdx = 0; |
|
579 *aRowExtents = 0; |
|
580 *aColExtents = 0; |
|
581 *aIsSelected = false; |
|
582 if (!mTable) |
|
583 return CO_E_OBJNOTCONNECTED; |
|
584 |
|
585 if (aCellIdx < 0 || |
|
586 static_cast<uint32_t>(aCellIdx) >= mTable->ColCount() * mTable->RowCount()) |
|
587 return E_INVALIDARG; |
|
588 |
|
589 int32_t colIdx = 0, rowIdx = 0; |
|
590 mTable->RowAndColIndicesAt(aCellIdx, &rowIdx, &colIdx); |
|
591 *aRowIdx = rowIdx; |
|
592 *aColIdx = colIdx; |
|
593 *aRowExtents = mTable->RowExtentAt(rowIdx, colIdx); |
|
594 *aColExtents = mTable->ColExtentAt(rowIdx, colIdx); |
|
595 *aIsSelected = mTable->IsCellSelected(rowIdx, colIdx); |
|
596 |
|
597 return S_OK; |
|
598 |
|
599 A11Y_TRYBLOCK_END |
|
600 } |
|
601 |
|
602 STDMETHODIMP |
|
603 ia2AccessibleTable::get_modelChange(IA2TableModelChange* aModelChange) |
|
604 { |
|
605 return E_NOTIMPL; |
|
606 } |
|
607 |
|
608 //////////////////////////////////////////////////////////////////////////////// |
|
609 // IAccessibleTable2 |
|
610 |
|
611 STDMETHODIMP |
|
612 ia2AccessibleTable::get_cellAt(long aRowIdx, long aColIdx, IUnknown** aCell) |
|
613 { |
|
614 A11Y_TRYBLOCK_BEGIN |
|
615 |
|
616 if (!aCell) |
|
617 return E_INVALIDARG; |
|
618 |
|
619 *aCell = nullptr; |
|
620 |
|
621 if (!mTable) |
|
622 return CO_E_OBJNOTCONNECTED; |
|
623 |
|
624 AccessibleWrap* cell = |
|
625 static_cast<AccessibleWrap*>(mTable->CellAt(aRowIdx, aColIdx)); |
|
626 if (!cell) |
|
627 return E_INVALIDARG; |
|
628 |
|
629 (*aCell = static_cast<IAccessible*>(cell))->AddRef(); |
|
630 return S_OK; |
|
631 |
|
632 A11Y_TRYBLOCK_END |
|
633 } |
|
634 |
|
635 STDMETHODIMP |
|
636 ia2AccessibleTable::get_nSelectedCells(long* aCellCount) |
|
637 { |
|
638 A11Y_TRYBLOCK_BEGIN |
|
639 |
|
640 if (!aCellCount) |
|
641 return E_INVALIDARG; |
|
642 |
|
643 *aCellCount = 0; |
|
644 if (!mTable) |
|
645 return CO_E_OBJNOTCONNECTED; |
|
646 |
|
647 *aCellCount = mTable->SelectedCellCount(); |
|
648 return S_OK; |
|
649 |
|
650 A11Y_TRYBLOCK_END |
|
651 } |
|
652 |
|
653 STDMETHODIMP |
|
654 ia2AccessibleTable::get_selectedCells(IUnknown*** aCells, long* aNSelectedCells) |
|
655 { |
|
656 A11Y_TRYBLOCK_BEGIN |
|
657 |
|
658 if (!aCells || !aNSelectedCells) |
|
659 return E_INVALIDARG; |
|
660 |
|
661 *aCells = nullptr; |
|
662 *aNSelectedCells = 0; |
|
663 if (!mTable) |
|
664 return CO_E_OBJNOTCONNECTED; |
|
665 |
|
666 nsAutoTArray<Accessible*, 30> cells; |
|
667 mTable->SelectedCells(&cells); |
|
668 if (cells.IsEmpty()) |
|
669 return S_FALSE; |
|
670 |
|
671 *aCells = |
|
672 static_cast<IUnknown**>(::CoTaskMemAlloc(sizeof(IUnknown*) * |
|
673 cells.Length())); |
|
674 if (!*aCells) |
|
675 return E_OUTOFMEMORY; |
|
676 |
|
677 for (uint32_t i = 0; i < cells.Length(); i++) { |
|
678 (*aCells)[i] = |
|
679 static_cast<IAccessible*>(static_cast<AccessibleWrap*>(cells[i])); |
|
680 ((*aCells)[i])->AddRef(); |
|
681 } |
|
682 |
|
683 *aNSelectedCells = cells.Length(); |
|
684 return S_OK; |
|
685 |
|
686 A11Y_TRYBLOCK_END |
|
687 } |
|
688 |
|
689 STDMETHODIMP |
|
690 ia2AccessibleTable::get_selectedColumns(long** aColumns, long* aNColumns) |
|
691 { |
|
692 A11Y_TRYBLOCK_BEGIN |
|
693 |
|
694 if (!aColumns || !aNColumns) |
|
695 return E_INVALIDARG; |
|
696 |
|
697 *aColumns = nullptr; |
|
698 *aNColumns = 0; |
|
699 if (!mTable) |
|
700 return CO_E_OBJNOTCONNECTED; |
|
701 |
|
702 nsAutoTArray<uint32_t, 30> colIndices; |
|
703 mTable->SelectedColIndices(&colIndices); |
|
704 |
|
705 uint32_t maxCols = colIndices.Length(); |
|
706 if (maxCols == 0) |
|
707 return S_FALSE; |
|
708 |
|
709 *aColumns = static_cast<LONG*>(moz_xmalloc(sizeof(LONG) * maxCols)); |
|
710 *aNColumns = maxCols; |
|
711 for (uint32_t i = 0; i < maxCols; i++) |
|
712 (*aColumns)[i] = colIndices[i]; |
|
713 |
|
714 return S_OK; |
|
715 |
|
716 A11Y_TRYBLOCK_END |
|
717 } |
|
718 |
|
719 STDMETHODIMP |
|
720 ia2AccessibleTable::get_selectedRows(long** aRows, long* aNRows) |
|
721 { |
|
722 A11Y_TRYBLOCK_BEGIN |
|
723 |
|
724 if (!aRows || !aNRows) |
|
725 return E_INVALIDARG; |
|
726 |
|
727 *aRows = nullptr; |
|
728 *aNRows = 0; |
|
729 if (!mTable) |
|
730 return CO_E_OBJNOTCONNECTED; |
|
731 |
|
732 nsAutoTArray<uint32_t, 30> rowIndices; |
|
733 mTable->SelectedRowIndices(&rowIndices); |
|
734 |
|
735 uint32_t maxRows = rowIndices.Length(); |
|
736 if (maxRows == 0) |
|
737 return S_FALSE; |
|
738 |
|
739 *aRows = static_cast<LONG*>(moz_xmalloc(sizeof(LONG) * maxRows)); |
|
740 *aNRows = maxRows; |
|
741 for (uint32_t i = 0; i < maxRows; i++) |
|
742 (*aRows)[i] = rowIndices[i]; |
|
743 |
|
744 return S_OK; |
|
745 |
|
746 A11Y_TRYBLOCK_END |
|
747 } |