UiaGridItem.cpp (3098B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #include "ia2AccessibleTableCell.h" 8 #include "mozilla/a11y/TableAccessible.h" 9 #include "mozilla/a11y/TableCellAccessible.h" 10 #include "UiaGridItem.h" 11 12 using namespace mozilla; 13 using namespace mozilla::a11y; 14 15 // UiaGridItem 16 17 TableCellAccessible* UiaGridItem::CellAcc() { 18 auto* derived = static_cast<ia2AccessibleTableCell*>(this); 19 Accessible* acc = derived->Acc(); 20 return acc ? acc->AsTableCell() : nullptr; 21 } 22 23 // IGridItemProvider methods 24 25 STDMETHODIMP 26 UiaGridItem::get_Row(__RPC__out int* aRetVal) { 27 if (!aRetVal) { 28 return E_INVALIDARG; 29 } 30 TableCellAccessible* cell = CellAcc(); 31 if (!cell) { 32 return CO_E_OBJNOTCONNECTED; 33 } 34 *aRetVal = cell->RowIdx(); 35 return S_OK; 36 } 37 38 STDMETHODIMP 39 UiaGridItem::get_Column(__RPC__out int* aRetVal) { 40 if (!aRetVal) { 41 return E_INVALIDARG; 42 } 43 TableCellAccessible* cell = CellAcc(); 44 if (!cell) { 45 return CO_E_OBJNOTCONNECTED; 46 } 47 *aRetVal = cell->ColIdx(); 48 return S_OK; 49 } 50 51 STDMETHODIMP 52 UiaGridItem::get_RowSpan(__RPC__out int* aRetVal) { 53 if (!aRetVal) { 54 return E_INVALIDARG; 55 } 56 TableCellAccessible* cell = CellAcc(); 57 if (!cell) { 58 return CO_E_OBJNOTCONNECTED; 59 } 60 *aRetVal = cell->RowExtent(); 61 return S_OK; 62 } 63 64 STDMETHODIMP 65 UiaGridItem::get_ColumnSpan(__RPC__out int* aRetVal) { 66 if (!aRetVal) { 67 return E_INVALIDARG; 68 } 69 TableCellAccessible* cell = CellAcc(); 70 if (!cell) { 71 return CO_E_OBJNOTCONNECTED; 72 } 73 *aRetVal = cell->ColExtent(); 74 return S_OK; 75 } 76 77 STDMETHODIMP 78 UiaGridItem::get_ContainingGrid( 79 __RPC__deref_out_opt IRawElementProviderSimple** aRetVal) { 80 if (!aRetVal) { 81 return E_INVALIDARG; 82 } 83 *aRetVal = nullptr; 84 TableCellAccessible* cell = CellAcc(); 85 if (!cell) { 86 return CO_E_OBJNOTCONNECTED; 87 } 88 TableAccessible* table = cell->Table(); 89 if (!table) { 90 return E_FAIL; 91 } 92 Accessible* tableAcc = table->AsAccessible(); 93 RefPtr<IRawElementProviderSimple> uia = MsaaAccessible::GetFrom(tableAcc); 94 uia.forget(aRetVal); 95 return S_OK; 96 } 97 98 // ITableItemProvider methods 99 100 STDMETHODIMP 101 UiaGridItem::GetRowHeaderItems(__RPC__deref_out_opt SAFEARRAY** aRetVal) { 102 if (!aRetVal) { 103 return E_INVALIDARG; 104 } 105 *aRetVal = nullptr; 106 TableCellAccessible* cell = CellAcc(); 107 if (!cell) { 108 return CO_E_OBJNOTCONNECTED; 109 } 110 AutoTArray<Accessible*, 10> cells; 111 cell->RowHeaderCells(&cells); 112 *aRetVal = AccessibleArrayToUiaArray(cells); 113 return S_OK; 114 } 115 116 STDMETHODIMP 117 UiaGridItem::GetColumnHeaderItems(__RPC__deref_out_opt SAFEARRAY** aRetVal) { 118 if (!aRetVal) { 119 return E_INVALIDARG; 120 } 121 *aRetVal = nullptr; 122 TableCellAccessible* cell = CellAcc(); 123 if (!cell) { 124 return CO_E_OBJNOTCONNECTED; 125 } 126 AutoTArray<Accessible*, 10> cells; 127 cell->ColHeaderCells(&cells); 128 *aRetVal = AccessibleArrayToUiaArray(cells); 129 return S_OK; 130 }