accessible/src/windows/ia2/ia2AccessibleTable.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/src/windows/ia2/ia2AccessibleTable.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,747 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:expandtab:shiftwidth=2:tabstop=2:
     1.6 + */
     1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.10 +
    1.11 +#include "ia2AccessibleTable.h"
    1.12 +
    1.13 +#include "Accessible2.h"
    1.14 +#include "AccessibleTable_i.c"
    1.15 +#include "AccessibleTable2_i.c"
    1.16 +
    1.17 +#include "AccessibleWrap.h"
    1.18 +#include "IUnknownImpl.h"
    1.19 +#include "Statistics.h"
    1.20 +#include "TableAccessible.h"
    1.21 +
    1.22 +#include "nsCOMPtr.h"
    1.23 +#include "nsString.h"
    1.24 +
    1.25 +using namespace mozilla::a11y;
    1.26 +
    1.27 +// IUnknown
    1.28 +
    1.29 +STDMETHODIMP
    1.30 +ia2AccessibleTable::QueryInterface(REFIID iid, void** ppv)
    1.31 +{
    1.32 +  if (!ppv)
    1.33 +    return E_INVALIDARG;
    1.34 +
    1.35 +  *ppv = nullptr;
    1.36 +
    1.37 +  if (IID_IAccessibleTable == iid) {
    1.38 +    statistics::IAccessibleTableUsed();
    1.39 +    *ppv = static_cast<IAccessibleTable*>(this);
    1.40 +    (reinterpret_cast<IUnknown*>(*ppv))->AddRef();
    1.41 +    return S_OK;
    1.42 +  }
    1.43 +
    1.44 +  if (IID_IAccessibleTable2 == iid) {
    1.45 +    *ppv = static_cast<IAccessibleTable2*>(this);
    1.46 +    (reinterpret_cast<IUnknown*>(*ppv))->AddRef();
    1.47 +    return S_OK;
    1.48 +  }
    1.49 +
    1.50 +  return E_NOINTERFACE;
    1.51 +}
    1.52 +
    1.53 +////////////////////////////////////////////////////////////////////////////////
    1.54 +// IAccessibleTable
    1.55 +
    1.56 +STDMETHODIMP
    1.57 +ia2AccessibleTable::get_accessibleAt(long aRowIdx, long aColIdx,
    1.58 +                                     IUnknown** aAccessible)
    1.59 +{
    1.60 +  return get_cellAt(aRowIdx, aColIdx, aAccessible);
    1.61 +}
    1.62 +
    1.63 +STDMETHODIMP
    1.64 +ia2AccessibleTable::get_caption(IUnknown** aAccessible)
    1.65 +{
    1.66 +  A11Y_TRYBLOCK_BEGIN
    1.67 +
    1.68 +  if (!aAccessible)
    1.69 +    return E_INVALIDARG;
    1.70 +
    1.71 +  *aAccessible = nullptr;
    1.72 +  if (!mTable)
    1.73 +    return CO_E_OBJNOTCONNECTED;
    1.74 +
    1.75 +  AccessibleWrap* caption = static_cast<AccessibleWrap*>(mTable->Caption());
    1.76 +  if (!caption)
    1.77 +    return S_FALSE;
    1.78 +
    1.79 +  (*aAccessible = static_cast<IAccessible*>(caption))->AddRef();
    1.80 +  return S_OK;
    1.81 +
    1.82 +  A11Y_TRYBLOCK_END
    1.83 +}
    1.84 +
    1.85 +STDMETHODIMP
    1.86 +ia2AccessibleTable::get_childIndex(long aRowIdx, long aColIdx,
    1.87 +                                   long* aChildIdx)
    1.88 +{
    1.89 +  A11Y_TRYBLOCK_BEGIN
    1.90 +
    1.91 +  if (!aChildIdx)
    1.92 +    return E_INVALIDARG;
    1.93 +
    1.94 +  *aChildIdx = 0;
    1.95 +  if (!mTable)
    1.96 +    return CO_E_OBJNOTCONNECTED;
    1.97 +
    1.98 +  if (aRowIdx < 0 || aColIdx < 0 ||
    1.99 +      static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
   1.100 +      static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
   1.101 +    return E_INVALIDARG;
   1.102 +
   1.103 +  *aChildIdx = mTable->CellIndexAt(aRowIdx, aColIdx);
   1.104 +  return S_OK;
   1.105 +
   1.106 +  A11Y_TRYBLOCK_END
   1.107 +}
   1.108 +
   1.109 +STDMETHODIMP
   1.110 +ia2AccessibleTable::get_columnDescription(long aColIdx, BSTR* aDescription)
   1.111 +{
   1.112 +  A11Y_TRYBLOCK_BEGIN
   1.113 +
   1.114 +  if (!aDescription)
   1.115 +    return E_INVALIDARG;
   1.116 +
   1.117 +  *aDescription = nullptr;
   1.118 +  if (!mTable)
   1.119 +    return CO_E_OBJNOTCONNECTED;
   1.120 +
   1.121 +  if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
   1.122 +    return E_INVALIDARG;
   1.123 +
   1.124 +  nsAutoString descr;
   1.125 +  mTable->ColDescription(aColIdx, descr);
   1.126 +  if (descr.IsEmpty())
   1.127 +    return S_FALSE;
   1.128 +
   1.129 +  *aDescription = ::SysAllocStringLen(descr.get(), descr.Length());
   1.130 +  return *aDescription ? S_OK : E_OUTOFMEMORY;
   1.131 +
   1.132 +  A11Y_TRYBLOCK_END
   1.133 +}
   1.134 +
   1.135 +STDMETHODIMP
   1.136 +ia2AccessibleTable::get_columnExtentAt(long aRowIdx, long aColIdx,
   1.137 +                                      long* aSpan)
   1.138 +{
   1.139 +  A11Y_TRYBLOCK_BEGIN
   1.140 +
   1.141 +  if (!aSpan)
   1.142 +    return E_INVALIDARG;
   1.143 +
   1.144 +  *aSpan = 0;
   1.145 +  if (!mTable)
   1.146 +    return CO_E_OBJNOTCONNECTED;
   1.147 +
   1.148 +  if (aRowIdx < 0 || aColIdx < 0 ||
   1.149 +      static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
   1.150 +      static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
   1.151 +    return E_INVALIDARG;
   1.152 +
   1.153 +  *aSpan = mTable->ColExtentAt(aRowIdx, aColIdx);
   1.154 +  return S_OK;
   1.155 +
   1.156 +  A11Y_TRYBLOCK_END
   1.157 +}
   1.158 +
   1.159 +STDMETHODIMP
   1.160 +ia2AccessibleTable::get_columnHeader(IAccessibleTable** aAccessibleTable,
   1.161 +                                    long* aStartingRowIndex)
   1.162 +{
   1.163 +  A11Y_TRYBLOCK_BEGIN
   1.164 +
   1.165 +  if (!aAccessibleTable || !aStartingRowIndex)
   1.166 +    return E_INVALIDARG;
   1.167 +
   1.168 +  *aAccessibleTable = nullptr;
   1.169 +  *aStartingRowIndex = -1;
   1.170 +  return E_NOTIMPL;
   1.171 +
   1.172 +  A11Y_TRYBLOCK_END
   1.173 +}
   1.174 +
   1.175 +STDMETHODIMP
   1.176 +ia2AccessibleTable::get_columnIndex(long aCellIdx, long* aColIdx)
   1.177 +{
   1.178 +  A11Y_TRYBLOCK_BEGIN
   1.179 +
   1.180 +  if (!aColIdx)
   1.181 +    return E_INVALIDARG;
   1.182 +
   1.183 +  *aColIdx = 0;
   1.184 +  if (!mTable)
   1.185 +    return CO_E_OBJNOTCONNECTED;
   1.186 +
   1.187 +  if (aCellIdx < 0 ||
   1.188 +      static_cast<uint32_t>(aCellIdx) >= mTable->ColCount() * mTable->RowCount())
   1.189 +    return E_INVALIDARG;
   1.190 +
   1.191 +  *aColIdx = mTable->ColIndexAt(aCellIdx);
   1.192 +  return S_OK;
   1.193 +
   1.194 +  A11Y_TRYBLOCK_END
   1.195 +}
   1.196 +
   1.197 +STDMETHODIMP
   1.198 +ia2AccessibleTable::get_nColumns(long* aColCount)
   1.199 +{
   1.200 +  A11Y_TRYBLOCK_BEGIN
   1.201 +
   1.202 +  if (!aColCount)
   1.203 +    return E_INVALIDARG;
   1.204 +
   1.205 +  *aColCount = 0;
   1.206 +  if (!mTable)
   1.207 +    return CO_E_OBJNOTCONNECTED;
   1.208 +
   1.209 +  *aColCount = mTable->ColCount();
   1.210 +  return S_OK;
   1.211 +
   1.212 +  A11Y_TRYBLOCK_END
   1.213 +}
   1.214 +
   1.215 +STDMETHODIMP
   1.216 +ia2AccessibleTable::get_nRows(long* aRowCount)
   1.217 +{
   1.218 +  A11Y_TRYBLOCK_BEGIN
   1.219 +
   1.220 +  if (!aRowCount)
   1.221 +    return E_INVALIDARG;
   1.222 +
   1.223 +  *aRowCount = 0;
   1.224 +  if (!mTable)
   1.225 +    return CO_E_OBJNOTCONNECTED;
   1.226 +
   1.227 +  *aRowCount = mTable->RowCount();
   1.228 +  return S_OK;
   1.229 +
   1.230 +  A11Y_TRYBLOCK_END
   1.231 +}
   1.232 +
   1.233 +STDMETHODIMP
   1.234 +ia2AccessibleTable::get_nSelectedChildren(long* aChildCount)
   1.235 +{
   1.236 +  return get_nSelectedCells(aChildCount);
   1.237 +}
   1.238 +
   1.239 +STDMETHODIMP
   1.240 +ia2AccessibleTable::get_nSelectedColumns(long* aColCount)
   1.241 +{
   1.242 +  A11Y_TRYBLOCK_BEGIN
   1.243 +
   1.244 +  if (!aColCount)
   1.245 +    return E_INVALIDARG;
   1.246 +
   1.247 +  *aColCount = 0;
   1.248 +  if (!mTable)
   1.249 +    return CO_E_OBJNOTCONNECTED;
   1.250 +
   1.251 +  *aColCount = mTable->SelectedColCount();
   1.252 +  return S_OK;
   1.253 +
   1.254 +  A11Y_TRYBLOCK_END
   1.255 +}
   1.256 +
   1.257 +STDMETHODIMP
   1.258 +ia2AccessibleTable::get_nSelectedRows(long* aRowCount)
   1.259 +{
   1.260 +  A11Y_TRYBLOCK_BEGIN
   1.261 +
   1.262 +  if (!aRowCount)
   1.263 +    return E_INVALIDARG;
   1.264 +
   1.265 +  *aRowCount = 0;
   1.266 +  if (!mTable)
   1.267 +    return CO_E_OBJNOTCONNECTED;
   1.268 +
   1.269 +  *aRowCount = mTable->SelectedRowCount();
   1.270 +
   1.271 +  return S_OK;
   1.272 +
   1.273 +  A11Y_TRYBLOCK_END
   1.274 +}
   1.275 +
   1.276 +STDMETHODIMP
   1.277 +ia2AccessibleTable::get_rowDescription(long aRowIdx, BSTR* aDescription)
   1.278 +{
   1.279 +  A11Y_TRYBLOCK_BEGIN
   1.280 +
   1.281 +  if (!aDescription)
   1.282 +    return E_INVALIDARG;
   1.283 +
   1.284 +  *aDescription = nullptr;
   1.285 +  if (!mTable)
   1.286 +    return CO_E_OBJNOTCONNECTED;
   1.287 +
   1.288 +  if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
   1.289 +    return E_INVALIDARG;
   1.290 +
   1.291 +  nsAutoString descr;
   1.292 +  mTable->RowDescription(aRowIdx, descr);
   1.293 +  if (descr.IsEmpty())
   1.294 +    return S_FALSE;
   1.295 +
   1.296 +  *aDescription = ::SysAllocStringLen(descr.get(), descr.Length());
   1.297 +  return *aDescription ? S_OK : E_OUTOFMEMORY;
   1.298 +
   1.299 +  A11Y_TRYBLOCK_END
   1.300 +}
   1.301 +
   1.302 +STDMETHODIMP
   1.303 +ia2AccessibleTable::get_rowExtentAt(long aRowIdx, long aColIdx, long* aSpan)
   1.304 +{
   1.305 +  A11Y_TRYBLOCK_BEGIN
   1.306 +
   1.307 +  if (!aSpan)
   1.308 +    return E_INVALIDARG;
   1.309 +
   1.310 +  *aSpan = 0;
   1.311 +  if (!mTable)
   1.312 +    return CO_E_OBJNOTCONNECTED;
   1.313 +
   1.314 +  if (aRowIdx < 0 || aColIdx < 0 ||
   1.315 +      static_cast<uint32_t>(aRowIdx) >= mTable->RowCount() ||
   1.316 +      static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
   1.317 +    return E_INVALIDARG;
   1.318 +
   1.319 +  *aSpan = mTable->RowExtentAt(aRowIdx, aColIdx);
   1.320 +  return S_OK;
   1.321 +
   1.322 +  A11Y_TRYBLOCK_END
   1.323 +}
   1.324 +
   1.325 +STDMETHODIMP
   1.326 +ia2AccessibleTable::get_rowHeader(IAccessibleTable** aAccessibleTable,
   1.327 +                                  long* aStartingColumnIndex)
   1.328 +{
   1.329 +  A11Y_TRYBLOCK_BEGIN
   1.330 +
   1.331 +  if (!aAccessibleTable || !aStartingColumnIndex)
   1.332 +    return E_INVALIDARG;
   1.333 +
   1.334 +  *aAccessibleTable = nullptr;
   1.335 +  *aStartingColumnIndex = -1;
   1.336 +  return E_NOTIMPL;
   1.337 +
   1.338 +  A11Y_TRYBLOCK_END
   1.339 +}
   1.340 +
   1.341 +STDMETHODIMP
   1.342 +ia2AccessibleTable::get_rowIndex(long aCellIdx, long* aRowIdx)
   1.343 +{
   1.344 +  A11Y_TRYBLOCK_BEGIN
   1.345 +
   1.346 +  if (!aRowIdx)
   1.347 +    return E_INVALIDARG;
   1.348 +
   1.349 +  *aRowIdx = 0;
   1.350 +  if (!mTable)
   1.351 +    return CO_E_OBJNOTCONNECTED;
   1.352 +
   1.353 +  if (aCellIdx < 0 ||
   1.354 +      static_cast<uint32_t>(aCellIdx) >= mTable->ColCount() * mTable->RowCount())
   1.355 +    return E_INVALIDARG;
   1.356 +
   1.357 +  *aRowIdx = mTable->RowIndexAt(aCellIdx);
   1.358 +  return S_OK;
   1.359 +
   1.360 +  A11Y_TRYBLOCK_END
   1.361 +}
   1.362 +
   1.363 +STDMETHODIMP
   1.364 +ia2AccessibleTable::get_selectedChildren(long aMaxChildren, long** aChildren,
   1.365 +                                         long* aNChildren)
   1.366 +{
   1.367 +  A11Y_TRYBLOCK_BEGIN
   1.368 +
   1.369 +  if (!aChildren || !aNChildren)
   1.370 +    return E_INVALIDARG;
   1.371 +
   1.372 +  *aChildren = nullptr;
   1.373 +  *aNChildren = 0;
   1.374 +  if (!mTable)
   1.375 +    return CO_E_OBJNOTCONNECTED;
   1.376 +
   1.377 +  nsAutoTArray<uint32_t, 30> cellIndices;
   1.378 +  mTable->SelectedCellIndices(&cellIndices);
   1.379 +
   1.380 +  uint32_t maxCells = cellIndices.Length();
   1.381 +  if (maxCells == 0)
   1.382 +    return S_FALSE;
   1.383 +
   1.384 +  *aChildren = static_cast<LONG*>(moz_xmalloc(sizeof(LONG) * maxCells));
   1.385 +  *aNChildren = maxCells;
   1.386 +  for (uint32_t i = 0; i < maxCells; i++)
   1.387 +    (*aChildren)[i] = cellIndices[i];
   1.388 +
   1.389 +  return S_OK;
   1.390 +
   1.391 +  A11Y_TRYBLOCK_END
   1.392 +}
   1.393 +
   1.394 +STDMETHODIMP
   1.395 +ia2AccessibleTable::get_selectedColumns(long aMaxColumns, long** aColumns,
   1.396 +                                        long* aNColumns)
   1.397 +{
   1.398 +  A11Y_TRYBLOCK_BEGIN
   1.399 +
   1.400 +  return get_selectedColumns(aColumns, aNColumns);
   1.401 +
   1.402 +  A11Y_TRYBLOCK_END
   1.403 +}
   1.404 +
   1.405 +STDMETHODIMP
   1.406 +ia2AccessibleTable::get_selectedRows(long aMaxRows, long** aRows, long* aNRows)
   1.407 +{
   1.408 +  A11Y_TRYBLOCK_BEGIN
   1.409 +
   1.410 +  return get_selectedRows(aRows, aNRows);
   1.411 +
   1.412 +  A11Y_TRYBLOCK_END
   1.413 +}
   1.414 +
   1.415 +STDMETHODIMP
   1.416 +ia2AccessibleTable::get_summary(IUnknown** aAccessible)
   1.417 +{
   1.418 +  A11Y_TRYBLOCK_BEGIN
   1.419 +
   1.420 +  if (!aAccessible)
   1.421 +    return E_INVALIDARG;
   1.422 +
   1.423 +  // Neither html:table nor xul:tree nor ARIA grid/tree have an ability to
   1.424 +  // link an accessible object to specify a summary. There is closes method
   1.425 +  // in nsIAccessibleTable::summary to get a summary as a string which is not
   1.426 +  // mapped directly to IAccessible2.
   1.427 +
   1.428 +  *aAccessible = nullptr;
   1.429 +  return S_FALSE;
   1.430 +
   1.431 +  A11Y_TRYBLOCK_END
   1.432 +}
   1.433 +
   1.434 +STDMETHODIMP
   1.435 +ia2AccessibleTable::get_isColumnSelected(long aColIdx, boolean* aIsSelected)
   1.436 +{
   1.437 +  A11Y_TRYBLOCK_BEGIN
   1.438 +
   1.439 +  if (!aIsSelected)
   1.440 +    return E_INVALIDARG;
   1.441 +
   1.442 +  *aIsSelected = false;
   1.443 +  if (!mTable)
   1.444 +    return CO_E_OBJNOTCONNECTED;
   1.445 +
   1.446 +  if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
   1.447 +    return E_INVALIDARG;
   1.448 +
   1.449 +  *aIsSelected = mTable->IsColSelected(aColIdx);
   1.450 +  return S_OK;
   1.451 +
   1.452 +  A11Y_TRYBLOCK_END
   1.453 +}
   1.454 +
   1.455 +STDMETHODIMP
   1.456 +ia2AccessibleTable::get_isRowSelected(long aRowIdx, boolean* aIsSelected)
   1.457 +{
   1.458 +  A11Y_TRYBLOCK_BEGIN
   1.459 +
   1.460 +  if (!aIsSelected)
   1.461 +    return E_INVALIDARG;
   1.462 +
   1.463 +  *aIsSelected = false;
   1.464 +  if (!mTable)
   1.465 +    return CO_E_OBJNOTCONNECTED;
   1.466 +
   1.467 +  if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
   1.468 +    return E_INVALIDARG;
   1.469 +
   1.470 +  *aIsSelected = mTable->IsRowSelected(aRowIdx);
   1.471 +  return S_OK;
   1.472 +
   1.473 +  A11Y_TRYBLOCK_END
   1.474 +}
   1.475 +
   1.476 +STDMETHODIMP
   1.477 +ia2AccessibleTable::get_isSelected(long aRowIdx, long aColIdx,
   1.478 +                                   boolean* aIsSelected)
   1.479 +{
   1.480 +  A11Y_TRYBLOCK_BEGIN
   1.481 +
   1.482 +  if (!aIsSelected)
   1.483 +    return E_INVALIDARG;
   1.484 +
   1.485 +  *aIsSelected = false;
   1.486 +  if (!mTable)
   1.487 +    return CO_E_OBJNOTCONNECTED;
   1.488 +
   1.489 +  if (aRowIdx < 0 || aColIdx < 0 ||
   1.490 +      static_cast<uint32_t>(aColIdx) >= mTable->ColCount() ||
   1.491 +      static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
   1.492 +    return E_INVALIDARG;
   1.493 +
   1.494 +  *aIsSelected = mTable->IsCellSelected(aRowIdx, aColIdx);
   1.495 +  return S_OK;
   1.496 +
   1.497 +  A11Y_TRYBLOCK_END
   1.498 +}
   1.499 +
   1.500 +STDMETHODIMP
   1.501 +ia2AccessibleTable::selectRow(long aRowIdx)
   1.502 +{
   1.503 +  A11Y_TRYBLOCK_BEGIN
   1.504 +
   1.505 +  if (!mTable)
   1.506 +    return CO_E_OBJNOTCONNECTED;
   1.507 +
   1.508 +  if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
   1.509 +    return E_INVALIDARG;
   1.510 +
   1.511 +  mTable->SelectRow(aRowIdx);
   1.512 +  return S_OK;
   1.513 +
   1.514 +  A11Y_TRYBLOCK_END
   1.515 +}
   1.516 +
   1.517 +STDMETHODIMP
   1.518 +ia2AccessibleTable::selectColumn(long aColIdx)
   1.519 +{
   1.520 +  A11Y_TRYBLOCK_BEGIN
   1.521 +
   1.522 +  if (!mTable)
   1.523 +    return CO_E_OBJNOTCONNECTED;
   1.524 +
   1.525 +  if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
   1.526 +    return E_INVALIDARG;
   1.527 +
   1.528 +  mTable->SelectCol(aColIdx);
   1.529 +  return S_OK;
   1.530 +
   1.531 +  A11Y_TRYBLOCK_END
   1.532 +}
   1.533 +
   1.534 +STDMETHODIMP
   1.535 +ia2AccessibleTable::unselectRow(long aRowIdx)
   1.536 +{
   1.537 +  A11Y_TRYBLOCK_BEGIN
   1.538 +
   1.539 +  if (!mTable)
   1.540 +    return CO_E_OBJNOTCONNECTED;
   1.541 +
   1.542 +  if (aRowIdx < 0 || static_cast<uint32_t>(aRowIdx) >= mTable->RowCount())
   1.543 +    return E_INVALIDARG;
   1.544 +
   1.545 +  mTable->UnselectRow(aRowIdx);
   1.546 +  return S_OK;
   1.547 +
   1.548 +  A11Y_TRYBLOCK_END
   1.549 +}
   1.550 +
   1.551 +STDMETHODIMP
   1.552 +ia2AccessibleTable::unselectColumn(long aColIdx)
   1.553 +{
   1.554 +  A11Y_TRYBLOCK_BEGIN
   1.555 +
   1.556 +  if (!mTable)
   1.557 +    return CO_E_OBJNOTCONNECTED;
   1.558 +
   1.559 +  if (aColIdx < 0 || static_cast<uint32_t>(aColIdx) >= mTable->ColCount())
   1.560 +    return E_INVALIDARG;
   1.561 +
   1.562 +  mTable->UnselectCol(aColIdx);
   1.563 +  return S_OK;
   1.564 +
   1.565 +  A11Y_TRYBLOCK_END
   1.566 +}
   1.567 +
   1.568 +STDMETHODIMP
   1.569 +ia2AccessibleTable::get_rowColumnExtentsAtIndex(long aCellIdx, long* aRowIdx,
   1.570 +                                                long* aColIdx,
   1.571 +                                                long* aRowExtents,
   1.572 +                                                long* aColExtents,
   1.573 +                                                boolean* aIsSelected)
   1.574 +{
   1.575 +  A11Y_TRYBLOCK_BEGIN
   1.576 +
   1.577 +  if (!aRowIdx || !aColIdx || !aRowExtents || !aColExtents || !aIsSelected)
   1.578 +    return E_INVALIDARG;
   1.579 +
   1.580 +  *aRowIdx = 0;
   1.581 +  *aColIdx = 0;
   1.582 +  *aRowExtents = 0;
   1.583 +  *aColExtents = 0;
   1.584 +  *aIsSelected = false;
   1.585 +  if (!mTable)
   1.586 +    return CO_E_OBJNOTCONNECTED;
   1.587 +
   1.588 +  if (aCellIdx < 0 ||
   1.589 +      static_cast<uint32_t>(aCellIdx) >= mTable->ColCount() * mTable->RowCount())
   1.590 +    return E_INVALIDARG;
   1.591 +
   1.592 +  int32_t colIdx = 0, rowIdx = 0;
   1.593 +  mTable->RowAndColIndicesAt(aCellIdx, &rowIdx, &colIdx);
   1.594 +  *aRowIdx = rowIdx;
   1.595 +  *aColIdx = colIdx;
   1.596 +  *aRowExtents = mTable->RowExtentAt(rowIdx, colIdx);
   1.597 +  *aColExtents = mTable->ColExtentAt(rowIdx, colIdx);
   1.598 +  *aIsSelected = mTable->IsCellSelected(rowIdx, colIdx);
   1.599 +
   1.600 +  return S_OK;
   1.601 +
   1.602 +  A11Y_TRYBLOCK_END
   1.603 +}
   1.604 +
   1.605 +STDMETHODIMP
   1.606 +ia2AccessibleTable::get_modelChange(IA2TableModelChange* aModelChange)
   1.607 +{
   1.608 +  return E_NOTIMPL;
   1.609 +}
   1.610 +
   1.611 +////////////////////////////////////////////////////////////////////////////////
   1.612 +// IAccessibleTable2
   1.613 +
   1.614 +STDMETHODIMP
   1.615 +ia2AccessibleTable::get_cellAt(long aRowIdx, long aColIdx, IUnknown** aCell)
   1.616 +{
   1.617 +  A11Y_TRYBLOCK_BEGIN
   1.618 +
   1.619 +  if (!aCell)
   1.620 +    return E_INVALIDARG;
   1.621 +
   1.622 +  *aCell = nullptr;
   1.623 +
   1.624 +  if (!mTable)
   1.625 +    return CO_E_OBJNOTCONNECTED;
   1.626 +
   1.627 +  AccessibleWrap* cell =
   1.628 +    static_cast<AccessibleWrap*>(mTable->CellAt(aRowIdx, aColIdx));
   1.629 +  if (!cell)
   1.630 +    return E_INVALIDARG;
   1.631 +
   1.632 +  (*aCell = static_cast<IAccessible*>(cell))->AddRef();
   1.633 +  return S_OK;
   1.634 +
   1.635 +  A11Y_TRYBLOCK_END
   1.636 +}
   1.637 +
   1.638 +STDMETHODIMP
   1.639 +ia2AccessibleTable::get_nSelectedCells(long* aCellCount)
   1.640 +{
   1.641 +  A11Y_TRYBLOCK_BEGIN
   1.642 +
   1.643 +  if (!aCellCount)
   1.644 +    return E_INVALIDARG;
   1.645 +
   1.646 +  *aCellCount = 0;
   1.647 +  if (!mTable)
   1.648 +    return CO_E_OBJNOTCONNECTED;
   1.649 +
   1.650 +  *aCellCount = mTable->SelectedCellCount();
   1.651 +  return S_OK;
   1.652 +
   1.653 +  A11Y_TRYBLOCK_END
   1.654 +}
   1.655 +
   1.656 +STDMETHODIMP
   1.657 +ia2AccessibleTable::get_selectedCells(IUnknown*** aCells, long* aNSelectedCells)
   1.658 +{
   1.659 +  A11Y_TRYBLOCK_BEGIN
   1.660 +
   1.661 +  if (!aCells || !aNSelectedCells)
   1.662 +    return E_INVALIDARG;
   1.663 +
   1.664 +  *aCells = nullptr;
   1.665 +  *aNSelectedCells = 0;
   1.666 +  if (!mTable)
   1.667 +    return CO_E_OBJNOTCONNECTED;
   1.668 +
   1.669 +  nsAutoTArray<Accessible*, 30> cells;
   1.670 +  mTable->SelectedCells(&cells);
   1.671 +  if (cells.IsEmpty())
   1.672 +    return S_FALSE;
   1.673 +
   1.674 +  *aCells =
   1.675 +    static_cast<IUnknown**>(::CoTaskMemAlloc(sizeof(IUnknown*) *
   1.676 +                                             cells.Length()));
   1.677 +  if (!*aCells)
   1.678 +    return E_OUTOFMEMORY;
   1.679 +
   1.680 +  for (uint32_t i = 0; i < cells.Length(); i++) {
   1.681 +    (*aCells)[i] =
   1.682 +      static_cast<IAccessible*>(static_cast<AccessibleWrap*>(cells[i]));
   1.683 +    ((*aCells)[i])->AddRef();
   1.684 +  }
   1.685 +
   1.686 +  *aNSelectedCells = cells.Length();
   1.687 +  return S_OK;
   1.688 +
   1.689 +  A11Y_TRYBLOCK_END
   1.690 +}
   1.691 +
   1.692 +STDMETHODIMP
   1.693 +ia2AccessibleTable::get_selectedColumns(long** aColumns, long* aNColumns)
   1.694 +{
   1.695 +  A11Y_TRYBLOCK_BEGIN
   1.696 +
   1.697 +  if (!aColumns || !aNColumns)
   1.698 +    return E_INVALIDARG;
   1.699 +
   1.700 +  *aColumns = nullptr;
   1.701 +  *aNColumns = 0;
   1.702 +  if (!mTable)
   1.703 +    return CO_E_OBJNOTCONNECTED;
   1.704 +
   1.705 +  nsAutoTArray<uint32_t, 30> colIndices;
   1.706 +  mTable->SelectedColIndices(&colIndices);
   1.707 +
   1.708 +  uint32_t maxCols = colIndices.Length();
   1.709 +  if (maxCols == 0)
   1.710 +    return S_FALSE;
   1.711 +
   1.712 +  *aColumns = static_cast<LONG*>(moz_xmalloc(sizeof(LONG) * maxCols));
   1.713 +  *aNColumns = maxCols;
   1.714 +  for (uint32_t i = 0; i < maxCols; i++)
   1.715 +    (*aColumns)[i] = colIndices[i];
   1.716 +
   1.717 +  return S_OK;
   1.718 +
   1.719 +  A11Y_TRYBLOCK_END
   1.720 +}
   1.721 +
   1.722 +STDMETHODIMP
   1.723 +ia2AccessibleTable::get_selectedRows(long** aRows, long* aNRows)
   1.724 +{
   1.725 +  A11Y_TRYBLOCK_BEGIN
   1.726 +
   1.727 +  if (!aRows || !aNRows)
   1.728 +    return E_INVALIDARG;
   1.729 +
   1.730 +  *aRows = nullptr;
   1.731 +  *aNRows = 0;
   1.732 +  if (!mTable)
   1.733 +    return CO_E_OBJNOTCONNECTED;
   1.734 +
   1.735 +  nsAutoTArray<uint32_t, 30> rowIndices;
   1.736 +  mTable->SelectedRowIndices(&rowIndices);
   1.737 +
   1.738 +  uint32_t maxRows = rowIndices.Length();
   1.739 +  if (maxRows == 0)
   1.740 +    return S_FALSE;
   1.741 +
   1.742 +  *aRows = static_cast<LONG*>(moz_xmalloc(sizeof(LONG) * maxRows));
   1.743 +  *aNRows = maxRows;
   1.744 +  for (uint32_t i = 0; i < maxRows; i++)
   1.745 +    (*aRows)[i] = rowIndices[i];
   1.746 +
   1.747 +  return S_OK;
   1.748 +
   1.749 +  A11Y_TRYBLOCK_END
   1.750 +}

mercurial