accessible/src/windows/ia2/ia2AccessibleTableCell.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/src/windows/ia2/ia2AccessibleTableCell.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,257 @@
     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 "ia2AccessibleTableCell.h"
    1.12 +
    1.13 +#include "Accessible2.h"
    1.14 +#include "AccessibleTable2_i.c"
    1.15 +#include "AccessibleTableCell_i.c"
    1.16 +
    1.17 +#include "AccessibleWrap.h"
    1.18 +#include "TableAccessible.h"
    1.19 +#include "TableCellAccessible.h"
    1.20 +#include "IUnknownImpl.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 +ia2AccessibleTableCell::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_IAccessibleTableCell == iid) {
    1.38 +    *ppv = static_cast<IAccessibleTableCell*>(this);
    1.39 +    (reinterpret_cast<IUnknown*>(*ppv))->AddRef();
    1.40 +    return S_OK;
    1.41 +  }
    1.42 +
    1.43 +  return E_NOINTERFACE;
    1.44 +}
    1.45 +
    1.46 +////////////////////////////////////////////////////////////////////////////////
    1.47 +// IAccessibleTableCell
    1.48 +
    1.49 +STDMETHODIMP
    1.50 +ia2AccessibleTableCell::get_table(IUnknown** aTable)
    1.51 +{
    1.52 +  A11Y_TRYBLOCK_BEGIN
    1.53 +
    1.54 +  if (!aTable)
    1.55 +    return E_INVALIDARG;
    1.56 +
    1.57 +  *aTable = nullptr;
    1.58 +  if (!mTableCell)
    1.59 +    return CO_E_OBJNOTCONNECTED;
    1.60 +
    1.61 +  TableAccessible* table = mTableCell->Table();
    1.62 +  if (!table)
    1.63 +    return E_FAIL;
    1.64 +
    1.65 +  AccessibleWrap* wrap = static_cast<AccessibleWrap*>(table->AsAccessible());
    1.66 +  *aTable = static_cast<IAccessible*>(wrap);
    1.67 +  (*aTable)->AddRef();
    1.68 +  return S_OK;
    1.69 +
    1.70 +  A11Y_TRYBLOCK_END
    1.71 +}
    1.72 +
    1.73 +STDMETHODIMP
    1.74 +ia2AccessibleTableCell::get_columnExtent(long* aSpan)
    1.75 +{
    1.76 +  A11Y_TRYBLOCK_BEGIN
    1.77 +
    1.78 +  if (!aSpan)
    1.79 +    return E_INVALIDARG;
    1.80 +
    1.81 +  *aSpan = 0;
    1.82 +  if (!mTableCell)
    1.83 +    return CO_E_OBJNOTCONNECTED;
    1.84 +
    1.85 +  *aSpan = mTableCell->ColExtent();
    1.86 +
    1.87 +  return S_OK;
    1.88 +
    1.89 +  A11Y_TRYBLOCK_END
    1.90 +}
    1.91 +
    1.92 +STDMETHODIMP
    1.93 +ia2AccessibleTableCell::get_columnHeaderCells(IUnknown*** aCellAccessibles,
    1.94 +                                              long* aNColumnHeaderCells)
    1.95 +{
    1.96 +  A11Y_TRYBLOCK_BEGIN
    1.97 +
    1.98 +  if (!aCellAccessibles || !aNColumnHeaderCells)
    1.99 +    return E_INVALIDARG;
   1.100 +
   1.101 +  *aCellAccessibles = nullptr;
   1.102 +  *aNColumnHeaderCells = 0;
   1.103 +  if (!mTableCell)
   1.104 +    return CO_E_OBJNOTCONNECTED;
   1.105 +
   1.106 +  nsAutoTArray<Accessible*, 10> cells;
   1.107 +  mTableCell->ColHeaderCells(&cells);
   1.108 +
   1.109 +  *aNColumnHeaderCells = cells.Length();
   1.110 +  *aCellAccessibles =
   1.111 +    static_cast<IUnknown**>(::CoTaskMemAlloc(sizeof(IUnknown*) *
   1.112 +                                             cells.Length()));
   1.113 +
   1.114 +  if (!*aCellAccessibles)
   1.115 +    return E_OUTOFMEMORY;
   1.116 +
   1.117 +  for (uint32_t i = 0; i < cells.Length(); i++) {
   1.118 +    AccessibleWrap* cell = static_cast<AccessibleWrap*>(cells[i]);
   1.119 +    (*aCellAccessibles)[i] = static_cast<IAccessible*>(cell);
   1.120 +    (*aCellAccessibles)[i]->AddRef();
   1.121 +  }
   1.122 +
   1.123 +  return S_OK;
   1.124 +
   1.125 +  A11Y_TRYBLOCK_END
   1.126 +}
   1.127 +
   1.128 +STDMETHODIMP
   1.129 +ia2AccessibleTableCell::get_columnIndex(long* aColIdx)
   1.130 +{
   1.131 +  A11Y_TRYBLOCK_BEGIN
   1.132 +
   1.133 +  if (!aColIdx)
   1.134 +    return E_INVALIDARG;
   1.135 +
   1.136 +  *aColIdx = -1;
   1.137 +  if (!mTableCell)
   1.138 +    return CO_E_OBJNOTCONNECTED;
   1.139 +
   1.140 +  *aColIdx = mTableCell->ColIdx();
   1.141 +  return S_OK;
   1.142 +
   1.143 +  A11Y_TRYBLOCK_END
   1.144 +}
   1.145 +
   1.146 +STDMETHODIMP
   1.147 +ia2AccessibleTableCell::get_rowExtent(long* aSpan)
   1.148 +{
   1.149 +  A11Y_TRYBLOCK_BEGIN
   1.150 +
   1.151 +  if (!aSpan)
   1.152 +    return E_INVALIDARG;
   1.153 +
   1.154 +  *aSpan = 0;
   1.155 +  if (!mTableCell)
   1.156 +    return CO_E_OBJNOTCONNECTED;
   1.157 +
   1.158 +  *aSpan = mTableCell->RowExtent();
   1.159 +  return S_OK;
   1.160 +
   1.161 +  A11Y_TRYBLOCK_END
   1.162 +}
   1.163 +
   1.164 +STDMETHODIMP
   1.165 +ia2AccessibleTableCell::get_rowHeaderCells(IUnknown*** aCellAccessibles,
   1.166 +                                           long* aNRowHeaderCells)
   1.167 +{
   1.168 +  A11Y_TRYBLOCK_BEGIN
   1.169 +
   1.170 +  if (!aCellAccessibles || !aNRowHeaderCells)
   1.171 +    return E_INVALIDARG;
   1.172 +
   1.173 +  *aCellAccessibles = nullptr;
   1.174 +  *aNRowHeaderCells = 0;
   1.175 +  if (!mTableCell)
   1.176 +    return CO_E_OBJNOTCONNECTED;
   1.177 +
   1.178 +  nsAutoTArray<Accessible*, 10> cells;
   1.179 +  mTableCell->RowHeaderCells(&cells);
   1.180 +
   1.181 +  *aNRowHeaderCells = cells.Length();
   1.182 +  *aCellAccessibles =
   1.183 +    static_cast<IUnknown**>(::CoTaskMemAlloc(sizeof(IUnknown*) *
   1.184 +                                             cells.Length()));
   1.185 +  if (!*aCellAccessibles)
   1.186 +    return E_OUTOFMEMORY;
   1.187 +
   1.188 +  for (uint32_t i = 0; i < cells.Length(); i++) {
   1.189 +    AccessibleWrap* cell = static_cast<AccessibleWrap*>(cells[i]);
   1.190 +    (*aCellAccessibles)[i] = static_cast<IAccessible*>(cell);
   1.191 +    (*aCellAccessibles)[i]->AddRef();
   1.192 +  }
   1.193 +
   1.194 +  return S_OK;
   1.195 +
   1.196 +  A11Y_TRYBLOCK_END
   1.197 +}
   1.198 +
   1.199 +STDMETHODIMP
   1.200 +ia2AccessibleTableCell::get_rowIndex(long* aRowIdx)
   1.201 +{
   1.202 +  A11Y_TRYBLOCK_BEGIN
   1.203 +
   1.204 +  if (!aRowIdx)
   1.205 +    return E_INVALIDARG;
   1.206 +
   1.207 +  *aRowIdx = -1;
   1.208 +  if (!mTableCell)
   1.209 +    return CO_E_OBJNOTCONNECTED;
   1.210 +
   1.211 +  *aRowIdx = mTableCell->RowIdx();
   1.212 +  return S_OK;
   1.213 +
   1.214 +  A11Y_TRYBLOCK_END
   1.215 +}
   1.216 +
   1.217 +STDMETHODIMP
   1.218 +ia2AccessibleTableCell::get_rowColumnExtents(long* aRowIdx, long* aColIdx,
   1.219 +                                             long* aRowExtents,
   1.220 +                                             long* aColExtents,
   1.221 +                                             boolean* aIsSelected)
   1.222 +{
   1.223 +  A11Y_TRYBLOCK_BEGIN
   1.224 +
   1.225 +  if (!aRowIdx || !aColIdx || !aRowExtents || !aColExtents || !aIsSelected)
   1.226 +    return E_INVALIDARG;
   1.227 +
   1.228 +  *aRowIdx = *aColIdx = *aRowExtents = *aColExtents = 0;
   1.229 +  *aIsSelected = false;
   1.230 +  if (!mTableCell)
   1.231 +    return CO_E_OBJNOTCONNECTED;
   1.232 +
   1.233 +  *aRowIdx = mTableCell->RowIdx();
   1.234 +  *aColIdx = mTableCell->ColIdx();
   1.235 +  *aRowExtents = mTableCell->RowExtent();
   1.236 +  *aColExtents = mTableCell->ColExtent();
   1.237 +  *aIsSelected = mTableCell->Selected();
   1.238 +
   1.239 +  return S_OK;
   1.240 +
   1.241 +  A11Y_TRYBLOCK_END
   1.242 +}
   1.243 +
   1.244 +STDMETHODIMP
   1.245 +ia2AccessibleTableCell::get_isSelected(boolean* aIsSelected)
   1.246 +{
   1.247 +  A11Y_TRYBLOCK_BEGIN
   1.248 +
   1.249 +  if (!aIsSelected)
   1.250 +    return E_INVALIDARG;
   1.251 +
   1.252 +  *aIsSelected = false;
   1.253 +  if (!mTableCell)
   1.254 +    return CO_E_OBJNOTCONNECTED;
   1.255 +
   1.256 +  *aIsSelected = mTableCell->Selected();
   1.257 +  return S_OK;
   1.258 +
   1.259 +  A11Y_TRYBLOCK_END
   1.260 +}

mercurial