michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:expandtab:shiftwidth=2:tabstop=2: michael@0: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "ia2AccessibleTable.h" michael@0: michael@0: #include "Accessible2.h" michael@0: #include "AccessibleTable_i.c" michael@0: #include "AccessibleTable2_i.c" michael@0: michael@0: #include "AccessibleWrap.h" michael@0: #include "IUnknownImpl.h" michael@0: #include "Statistics.h" michael@0: #include "TableAccessible.h" michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsString.h" michael@0: michael@0: using namespace mozilla::a11y; michael@0: michael@0: // IUnknown michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::QueryInterface(REFIID iid, void** ppv) michael@0: { michael@0: if (!ppv) michael@0: return E_INVALIDARG; michael@0: michael@0: *ppv = nullptr; michael@0: michael@0: if (IID_IAccessibleTable == iid) { michael@0: statistics::IAccessibleTableUsed(); michael@0: *ppv = static_cast(this); michael@0: (reinterpret_cast(*ppv))->AddRef(); michael@0: return S_OK; michael@0: } michael@0: michael@0: if (IID_IAccessibleTable2 == iid) { michael@0: *ppv = static_cast(this); michael@0: (reinterpret_cast(*ppv))->AddRef(); michael@0: return S_OK; michael@0: } michael@0: michael@0: return E_NOINTERFACE; michael@0: } michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // IAccessibleTable michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_accessibleAt(long aRowIdx, long aColIdx, michael@0: IUnknown** aAccessible) michael@0: { michael@0: return get_cellAt(aRowIdx, aColIdx, aAccessible); michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_caption(IUnknown** aAccessible) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aAccessible) michael@0: return E_INVALIDARG; michael@0: michael@0: *aAccessible = nullptr; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: AccessibleWrap* caption = static_cast(mTable->Caption()); michael@0: if (!caption) michael@0: return S_FALSE; michael@0: michael@0: (*aAccessible = static_cast(caption))->AddRef(); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_childIndex(long aRowIdx, long aColIdx, michael@0: long* aChildIdx) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aChildIdx) michael@0: return E_INVALIDARG; michael@0: michael@0: *aChildIdx = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aRowIdx < 0 || aColIdx < 0 || michael@0: static_cast(aRowIdx) >= mTable->RowCount() || michael@0: static_cast(aColIdx) >= mTable->ColCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: *aChildIdx = mTable->CellIndexAt(aRowIdx, aColIdx); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_columnDescription(long aColIdx, BSTR* aDescription) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aDescription) michael@0: return E_INVALIDARG; michael@0: michael@0: *aDescription = nullptr; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aColIdx < 0 || static_cast(aColIdx) >= mTable->ColCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: nsAutoString descr; michael@0: mTable->ColDescription(aColIdx, descr); michael@0: if (descr.IsEmpty()) michael@0: return S_FALSE; michael@0: michael@0: *aDescription = ::SysAllocStringLen(descr.get(), descr.Length()); michael@0: return *aDescription ? S_OK : E_OUTOFMEMORY; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_columnExtentAt(long aRowIdx, long aColIdx, michael@0: long* aSpan) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aSpan) michael@0: return E_INVALIDARG; michael@0: michael@0: *aSpan = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aRowIdx < 0 || aColIdx < 0 || michael@0: static_cast(aRowIdx) >= mTable->RowCount() || michael@0: static_cast(aColIdx) >= mTable->ColCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: *aSpan = mTable->ColExtentAt(aRowIdx, aColIdx); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_columnHeader(IAccessibleTable** aAccessibleTable, michael@0: long* aStartingRowIndex) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aAccessibleTable || !aStartingRowIndex) michael@0: return E_INVALIDARG; michael@0: michael@0: *aAccessibleTable = nullptr; michael@0: *aStartingRowIndex = -1; michael@0: return E_NOTIMPL; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_columnIndex(long aCellIdx, long* aColIdx) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aColIdx) michael@0: return E_INVALIDARG; michael@0: michael@0: *aColIdx = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aCellIdx < 0 || michael@0: static_cast(aCellIdx) >= mTable->ColCount() * mTable->RowCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: *aColIdx = mTable->ColIndexAt(aCellIdx); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_nColumns(long* aColCount) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aColCount) michael@0: return E_INVALIDARG; michael@0: michael@0: *aColCount = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: *aColCount = mTable->ColCount(); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_nRows(long* aRowCount) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aRowCount) michael@0: return E_INVALIDARG; michael@0: michael@0: *aRowCount = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: *aRowCount = mTable->RowCount(); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_nSelectedChildren(long* aChildCount) michael@0: { michael@0: return get_nSelectedCells(aChildCount); michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_nSelectedColumns(long* aColCount) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aColCount) michael@0: return E_INVALIDARG; michael@0: michael@0: *aColCount = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: *aColCount = mTable->SelectedColCount(); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_nSelectedRows(long* aRowCount) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aRowCount) michael@0: return E_INVALIDARG; michael@0: michael@0: *aRowCount = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: *aRowCount = mTable->SelectedRowCount(); michael@0: michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_rowDescription(long aRowIdx, BSTR* aDescription) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aDescription) michael@0: return E_INVALIDARG; michael@0: michael@0: *aDescription = nullptr; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aRowIdx < 0 || static_cast(aRowIdx) >= mTable->RowCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: nsAutoString descr; michael@0: mTable->RowDescription(aRowIdx, descr); michael@0: if (descr.IsEmpty()) michael@0: return S_FALSE; michael@0: michael@0: *aDescription = ::SysAllocStringLen(descr.get(), descr.Length()); michael@0: return *aDescription ? S_OK : E_OUTOFMEMORY; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_rowExtentAt(long aRowIdx, long aColIdx, long* aSpan) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aSpan) michael@0: return E_INVALIDARG; michael@0: michael@0: *aSpan = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aRowIdx < 0 || aColIdx < 0 || michael@0: static_cast(aRowIdx) >= mTable->RowCount() || michael@0: static_cast(aColIdx) >= mTable->ColCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: *aSpan = mTable->RowExtentAt(aRowIdx, aColIdx); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_rowHeader(IAccessibleTable** aAccessibleTable, michael@0: long* aStartingColumnIndex) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aAccessibleTable || !aStartingColumnIndex) michael@0: return E_INVALIDARG; michael@0: michael@0: *aAccessibleTable = nullptr; michael@0: *aStartingColumnIndex = -1; michael@0: return E_NOTIMPL; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_rowIndex(long aCellIdx, long* aRowIdx) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aRowIdx) michael@0: return E_INVALIDARG; michael@0: michael@0: *aRowIdx = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aCellIdx < 0 || michael@0: static_cast(aCellIdx) >= mTable->ColCount() * mTable->RowCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: *aRowIdx = mTable->RowIndexAt(aCellIdx); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_selectedChildren(long aMaxChildren, long** aChildren, michael@0: long* aNChildren) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aChildren || !aNChildren) michael@0: return E_INVALIDARG; michael@0: michael@0: *aChildren = nullptr; michael@0: *aNChildren = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: nsAutoTArray cellIndices; michael@0: mTable->SelectedCellIndices(&cellIndices); michael@0: michael@0: uint32_t maxCells = cellIndices.Length(); michael@0: if (maxCells == 0) michael@0: return S_FALSE; michael@0: michael@0: *aChildren = static_cast(moz_xmalloc(sizeof(LONG) * maxCells)); michael@0: *aNChildren = maxCells; michael@0: for (uint32_t i = 0; i < maxCells; i++) michael@0: (*aChildren)[i] = cellIndices[i]; michael@0: michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_selectedColumns(long aMaxColumns, long** aColumns, michael@0: long* aNColumns) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: return get_selectedColumns(aColumns, aNColumns); michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_selectedRows(long aMaxRows, long** aRows, long* aNRows) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: return get_selectedRows(aRows, aNRows); michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_summary(IUnknown** aAccessible) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aAccessible) michael@0: return E_INVALIDARG; michael@0: michael@0: // Neither html:table nor xul:tree nor ARIA grid/tree have an ability to michael@0: // link an accessible object to specify a summary. There is closes method michael@0: // in nsIAccessibleTable::summary to get a summary as a string which is not michael@0: // mapped directly to IAccessible2. michael@0: michael@0: *aAccessible = nullptr; michael@0: return S_FALSE; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_isColumnSelected(long aColIdx, boolean* aIsSelected) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aIsSelected) michael@0: return E_INVALIDARG; michael@0: michael@0: *aIsSelected = false; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aColIdx < 0 || static_cast(aColIdx) >= mTable->ColCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: *aIsSelected = mTable->IsColSelected(aColIdx); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_isRowSelected(long aRowIdx, boolean* aIsSelected) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aIsSelected) michael@0: return E_INVALIDARG; michael@0: michael@0: *aIsSelected = false; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aRowIdx < 0 || static_cast(aRowIdx) >= mTable->RowCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: *aIsSelected = mTable->IsRowSelected(aRowIdx); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_isSelected(long aRowIdx, long aColIdx, michael@0: boolean* aIsSelected) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aIsSelected) michael@0: return E_INVALIDARG; michael@0: michael@0: *aIsSelected = false; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aRowIdx < 0 || aColIdx < 0 || michael@0: static_cast(aColIdx) >= mTable->ColCount() || michael@0: static_cast(aRowIdx) >= mTable->RowCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: *aIsSelected = mTable->IsCellSelected(aRowIdx, aColIdx); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::selectRow(long aRowIdx) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aRowIdx < 0 || static_cast(aRowIdx) >= mTable->RowCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: mTable->SelectRow(aRowIdx); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::selectColumn(long aColIdx) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aColIdx < 0 || static_cast(aColIdx) >= mTable->ColCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: mTable->SelectCol(aColIdx); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::unselectRow(long aRowIdx) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aRowIdx < 0 || static_cast(aRowIdx) >= mTable->RowCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: mTable->UnselectRow(aRowIdx); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::unselectColumn(long aColIdx) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aColIdx < 0 || static_cast(aColIdx) >= mTable->ColCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: mTable->UnselectCol(aColIdx); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_rowColumnExtentsAtIndex(long aCellIdx, long* aRowIdx, michael@0: long* aColIdx, michael@0: long* aRowExtents, michael@0: long* aColExtents, michael@0: boolean* aIsSelected) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aRowIdx || !aColIdx || !aRowExtents || !aColExtents || !aIsSelected) michael@0: return E_INVALIDARG; michael@0: michael@0: *aRowIdx = 0; michael@0: *aColIdx = 0; michael@0: *aRowExtents = 0; michael@0: *aColExtents = 0; michael@0: *aIsSelected = false; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: if (aCellIdx < 0 || michael@0: static_cast(aCellIdx) >= mTable->ColCount() * mTable->RowCount()) michael@0: return E_INVALIDARG; michael@0: michael@0: int32_t colIdx = 0, rowIdx = 0; michael@0: mTable->RowAndColIndicesAt(aCellIdx, &rowIdx, &colIdx); michael@0: *aRowIdx = rowIdx; michael@0: *aColIdx = colIdx; michael@0: *aRowExtents = mTable->RowExtentAt(rowIdx, colIdx); michael@0: *aColExtents = mTable->ColExtentAt(rowIdx, colIdx); michael@0: *aIsSelected = mTable->IsCellSelected(rowIdx, colIdx); michael@0: michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_modelChange(IA2TableModelChange* aModelChange) michael@0: { michael@0: return E_NOTIMPL; michael@0: } michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // IAccessibleTable2 michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_cellAt(long aRowIdx, long aColIdx, IUnknown** aCell) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aCell) michael@0: return E_INVALIDARG; michael@0: michael@0: *aCell = nullptr; michael@0: michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: AccessibleWrap* cell = michael@0: static_cast(mTable->CellAt(aRowIdx, aColIdx)); michael@0: if (!cell) michael@0: return E_INVALIDARG; michael@0: michael@0: (*aCell = static_cast(cell))->AddRef(); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_nSelectedCells(long* aCellCount) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aCellCount) michael@0: return E_INVALIDARG; michael@0: michael@0: *aCellCount = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: *aCellCount = mTable->SelectedCellCount(); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_selectedCells(IUnknown*** aCells, long* aNSelectedCells) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aCells || !aNSelectedCells) michael@0: return E_INVALIDARG; michael@0: michael@0: *aCells = nullptr; michael@0: *aNSelectedCells = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: nsAutoTArray cells; michael@0: mTable->SelectedCells(&cells); michael@0: if (cells.IsEmpty()) michael@0: return S_FALSE; michael@0: michael@0: *aCells = michael@0: static_cast(::CoTaskMemAlloc(sizeof(IUnknown*) * michael@0: cells.Length())); michael@0: if (!*aCells) michael@0: return E_OUTOFMEMORY; michael@0: michael@0: for (uint32_t i = 0; i < cells.Length(); i++) { michael@0: (*aCells)[i] = michael@0: static_cast(static_cast(cells[i])); michael@0: ((*aCells)[i])->AddRef(); michael@0: } michael@0: michael@0: *aNSelectedCells = cells.Length(); michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_selectedColumns(long** aColumns, long* aNColumns) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aColumns || !aNColumns) michael@0: return E_INVALIDARG; michael@0: michael@0: *aColumns = nullptr; michael@0: *aNColumns = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: nsAutoTArray colIndices; michael@0: mTable->SelectedColIndices(&colIndices); michael@0: michael@0: uint32_t maxCols = colIndices.Length(); michael@0: if (maxCols == 0) michael@0: return S_FALSE; michael@0: michael@0: *aColumns = static_cast(moz_xmalloc(sizeof(LONG) * maxCols)); michael@0: *aNColumns = maxCols; michael@0: for (uint32_t i = 0; i < maxCols; i++) michael@0: (*aColumns)[i] = colIndices[i]; michael@0: michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: } michael@0: michael@0: STDMETHODIMP michael@0: ia2AccessibleTable::get_selectedRows(long** aRows, long* aNRows) michael@0: { michael@0: A11Y_TRYBLOCK_BEGIN michael@0: michael@0: if (!aRows || !aNRows) michael@0: return E_INVALIDARG; michael@0: michael@0: *aRows = nullptr; michael@0: *aNRows = 0; michael@0: if (!mTable) michael@0: return CO_E_OBJNOTCONNECTED; michael@0: michael@0: nsAutoTArray rowIndices; michael@0: mTable->SelectedRowIndices(&rowIndices); michael@0: michael@0: uint32_t maxRows = rowIndices.Length(); michael@0: if (maxRows == 0) michael@0: return S_FALSE; michael@0: michael@0: *aRows = static_cast(moz_xmalloc(sizeof(LONG) * maxRows)); michael@0: *aNRows = maxRows; michael@0: for (uint32_t i = 0; i < maxRows; i++) michael@0: (*aRows)[i] = rowIndices[i]; michael@0: michael@0: return S_OK; michael@0: michael@0: A11Y_TRYBLOCK_END michael@0: }