2011-04-27 13:42:27 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2011-05-27 22:37:24 +00:00
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
#include "InterfaceInitFuncs.h"
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
#include "AccessibleWrap.h"
|
2010-04-27 06:52:03 +00:00
|
|
|
#include "nsAccUtils.h"
|
2012-03-20 04:02:50 +00:00
|
|
|
#include "nsIAccessibleTable.h"
|
2012-03-28 00:53:58 +00:00
|
|
|
#include "TableAccessible.h"
|
2012-03-20 04:02:50 +00:00
|
|
|
#include "nsMai.h"
|
2010-04-27 06:52:03 +00:00
|
|
|
|
2009-09-11 01:07:56 +00:00
|
|
|
#include "nsArrayUtils.h"
|
|
|
|
|
2012-03-28 00:53:58 +00:00
|
|
|
using namespace mozilla::a11y;
|
2012-03-28 00:32:49 +00:00
|
|
|
|
2012-03-28 00:53:58 +00:00
|
|
|
extern "C" {
|
2012-03-20 04:02:50 +00:00
|
|
|
static AtkObject*
|
2003-05-06 02:23:50 +00:00
|
|
|
refAtCB(AtkTable *aTable, gint aRow, gint aColumn)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return nsnull;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, nsnull);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessible> cell;
|
2009-09-11 01:07:56 +00:00
|
|
|
nsresult rv = accTable->GetCellAt(aRow, aColumn,getter_AddRefs(cell));
|
2003-05-06 02:23:50 +00:00
|
|
|
if (NS_FAILED(rv) || !cell)
|
|
|
|
return nsnull;
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
AtkObject* cellAtkObj = AccessibleWrap::GetAtkObject(cell);
|
2007-06-08 09:09:24 +00:00
|
|
|
if (cellAtkObj) {
|
|
|
|
g_object_ref(cellAtkObj);
|
|
|
|
}
|
2007-06-04 09:39:15 +00:00
|
|
|
return cellAtkObj;
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gint
|
2012-05-08 20:50:46 +00:00
|
|
|
getIndexAtCB(AtkTable* aTable, gint aRow, gint aColumn)
|
2003-05-06 02:23:50 +00:00
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
2012-05-08 20:50:46 +00:00
|
|
|
if (!accWrap)
|
|
|
|
return -1;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2012-05-08 20:50:46 +00:00
|
|
|
TableAccessible* table = accWrap->AsTable();
|
|
|
|
NS_ENSURE_TRUE(table, -1);
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2012-05-08 20:50:46 +00:00
|
|
|
return static_cast<gint>(table->CellIndexAt(aRow, aColumn));
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gint
|
2003-05-06 02:23:50 +00:00
|
|
|
getColumnAtIndexCB(AtkTable *aTable, gint aIndex)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return -1;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, -1);
|
|
|
|
|
|
|
|
PRInt32 col;
|
2009-09-11 01:07:56 +00:00
|
|
|
nsresult rv = accTable->GetColumnIndexAt(aIndex, &col);
|
2003-05-06 02:23:50 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, -1);
|
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
return static_cast<gint>(col);
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gint
|
2003-05-06 02:23:50 +00:00
|
|
|
getRowAtIndexCB(AtkTable *aTable, gint aIndex)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return -1;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, -1);
|
|
|
|
|
|
|
|
PRInt32 row;
|
2009-09-11 01:07:56 +00:00
|
|
|
nsresult rv = accTable->GetRowIndexAt(aIndex, &row);
|
2003-05-06 02:23:50 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, -1);
|
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
return static_cast<gint>(row);
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gint
|
2003-05-06 02:23:50 +00:00
|
|
|
getColumnCountCB(AtkTable *aTable)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return -1;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, -1);
|
|
|
|
|
|
|
|
PRInt32 count;
|
2009-09-11 01:07:56 +00:00
|
|
|
nsresult rv = accTable->GetColumnCount(&count);
|
2003-05-06 02:23:50 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, -1);
|
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
return static_cast<gint>(count);
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gint
|
2003-05-06 02:23:50 +00:00
|
|
|
getRowCountCB(AtkTable *aTable)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return -1;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, -1);
|
|
|
|
|
|
|
|
PRInt32 count;
|
2009-09-11 01:07:56 +00:00
|
|
|
nsresult rv = accTable->GetRowCount(&count);
|
2003-05-06 02:23:50 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, -1);
|
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
return static_cast<gint>(count);
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gint
|
2003-05-06 02:23:50 +00:00
|
|
|
getColumnExtentAtCB(AtkTable *aTable,
|
|
|
|
gint aRow, gint aColumn)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return -1;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, -1);
|
|
|
|
|
|
|
|
PRInt32 extent;
|
|
|
|
nsresult rv = accTable->GetColumnExtentAt(aRow, aColumn, &extent);
|
|
|
|
NS_ENSURE_SUCCESS(rv, -1);
|
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
return static_cast<gint>(extent);
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gint
|
2003-05-06 02:23:50 +00:00
|
|
|
getRowExtentAtCB(AtkTable *aTable,
|
|
|
|
gint aRow, gint aColumn)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return -1;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, -1);
|
|
|
|
|
|
|
|
PRInt32 extent;
|
|
|
|
nsresult rv = accTable->GetRowExtentAt(aRow, aColumn, &extent);
|
|
|
|
NS_ENSURE_SUCCESS(rv, -1);
|
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
return static_cast<gint>(extent);
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static AtkObject*
|
2012-03-28 00:53:58 +00:00
|
|
|
getCaptionCB(AtkTable* aTable)
|
2003-05-06 02:23:50 +00:00
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
2012-03-28 00:53:58 +00:00
|
|
|
if (!accWrap)
|
|
|
|
return nsnull;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2012-03-28 00:53:58 +00:00
|
|
|
TableAccessible* table = accWrap->AsTable();
|
|
|
|
NS_ENSURE_TRUE(table, nsnull);
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
Accessible* caption = table->Caption();
|
|
|
|
return caption ? AccessibleWrap::GetAtkObject(caption) : nsnull;
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static const gchar*
|
2003-05-06 02:23:50 +00:00
|
|
|
getColumnDescriptionCB(AtkTable *aTable, gint aColumn)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return nsnull;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, nsnull);
|
|
|
|
|
2006-05-29 05:46:38 +00:00
|
|
|
nsAutoString autoStr;
|
|
|
|
nsresult rv = accTable->GetColumnDescription(aColumn, autoStr);
|
|
|
|
NS_ENSURE_SUCCESS(rv, nsnull);
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
return AccessibleWrap::ReturnString(autoStr);
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static AtkObject*
|
2003-05-06 02:23:50 +00:00
|
|
|
getColumnHeaderCB(AtkTable *aTable, gint aColumn)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return nsnull;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, nsnull);
|
|
|
|
|
2009-09-11 01:07:56 +00:00
|
|
|
nsCOMPtr<nsIAccessible> accCell;
|
|
|
|
accTable->GetCellAt(0, aColumn, getter_AddRefs(accCell));
|
|
|
|
if (!accCell)
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
// If the cell at the first row is column header then assume it is column
|
|
|
|
// header for all rows,
|
|
|
|
if (nsAccUtils::Role(accCell) == nsIAccessibleRole::ROLE_COLUMNHEADER)
|
2012-05-29 01:18:45 +00:00
|
|
|
return AccessibleWrap::GetAtkObject(accCell);
|
2009-09-11 01:07:56 +00:00
|
|
|
|
|
|
|
// otherwise get column header for the data cell at the first row.
|
|
|
|
nsCOMPtr<nsIAccessibleTableCell> accTableCell =
|
|
|
|
do_QueryInterface(accCell);
|
|
|
|
|
|
|
|
if (accTableCell) {
|
|
|
|
nsCOMPtr<nsIArray> headerCells;
|
|
|
|
accTableCell->GetColumnHeaderCells(getter_AddRefs(headerCells));
|
|
|
|
if (headerCells) {
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIAccessible> accHeaderCell =
|
|
|
|
do_QueryElementAt(headerCells, 0, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, nsnull);
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
return AccessibleWrap::GetAtkObject(accHeaderCell);
|
2009-09-11 01:07:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsnull;
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static const gchar*
|
2003-05-06 02:23:50 +00:00
|
|
|
getRowDescriptionCB(AtkTable *aTable, gint aRow)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return nsnull;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, nsnull);
|
|
|
|
|
2005-02-01 09:26:13 +00:00
|
|
|
nsAutoString autoStr;
|
|
|
|
nsresult rv = accTable->GetRowDescription(aRow, autoStr);
|
|
|
|
NS_ENSURE_SUCCESS(rv, nsnull);
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
return AccessibleWrap::ReturnString(autoStr);
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static AtkObject*
|
2003-05-06 02:23:50 +00:00
|
|
|
getRowHeaderCB(AtkTable *aTable, gint aRow)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return nsnull;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, nsnull);
|
|
|
|
|
2009-09-11 01:07:56 +00:00
|
|
|
nsCOMPtr<nsIAccessible> accCell;
|
|
|
|
accTable->GetCellAt(aRow, 0, getter_AddRefs(accCell));
|
|
|
|
if (!accCell)
|
|
|
|
return nsnull;
|
|
|
|
|
|
|
|
// If the cell at the first column is row header then assume it is row
|
|
|
|
// header for all columns,
|
|
|
|
if (nsAccUtils::Role(accCell) == nsIAccessibleRole::ROLE_ROWHEADER)
|
2012-05-29 01:18:45 +00:00
|
|
|
return AccessibleWrap::GetAtkObject(accCell);
|
2009-09-11 01:07:56 +00:00
|
|
|
|
|
|
|
// otherwise get row header for the data cell at the first column.
|
|
|
|
nsCOMPtr<nsIAccessibleTableCell> accTableCell =
|
|
|
|
do_QueryInterface(accCell);
|
|
|
|
|
|
|
|
if (accTableCell) {
|
|
|
|
nsCOMPtr<nsIArray> headerCells;
|
|
|
|
accTableCell->GetRowHeaderCells(getter_AddRefs(headerCells));
|
|
|
|
if (headerCells) {
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIAccessible> accHeaderCell =
|
|
|
|
do_QueryElementAt(headerCells, 0, &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, nsnull);
|
|
|
|
|
2012-05-29 01:18:45 +00:00
|
|
|
return AccessibleWrap::GetAtkObject(accHeaderCell);
|
2009-09-11 01:07:56 +00:00
|
|
|
}
|
|
|
|
}
|
2003-05-06 02:23:50 +00:00
|
|
|
|
2009-09-11 01:07:56 +00:00
|
|
|
return nsnull;
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static AtkObject*
|
2003-05-06 02:23:50 +00:00
|
|
|
getSummaryCB(AtkTable *aTable)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
// Neither html:table nor xul:tree nor ARIA grid/tree have an ability to
|
|
|
|
// link an accessible object to specify a summary. There is closes method
|
|
|
|
// in nsIAccessibleTable::summary to get a summary as a string which is not
|
|
|
|
// mapped directly to ATK.
|
|
|
|
return nsnull;
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gint
|
2003-05-06 02:23:50 +00:00
|
|
|
getSelectedColumnsCB(AtkTable *aTable, gint **aSelected)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return 0;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, 0);
|
|
|
|
|
|
|
|
PRUint32 size = 0;
|
|
|
|
PRInt32 *columns = NULL;
|
2009-09-11 01:07:56 +00:00
|
|
|
nsresult rv = accTable->GetSelectedColumnIndices(&size, &columns);
|
2003-05-06 02:23:50 +00:00
|
|
|
if (NS_FAILED(rv) || (size == 0) || !columns) {
|
|
|
|
*aSelected = nsnull;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint *atkColumns = g_new(gint, size);
|
|
|
|
if (!atkColumns) {
|
|
|
|
NS_WARNING("OUT OF MEMORY");
|
2012-07-20 11:16:17 +00:00
|
|
|
return 0;
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//copy
|
|
|
|
for (PRUint32 index = 0; index < size; ++index)
|
2007-07-08 07:08:04 +00:00
|
|
|
atkColumns[index] = static_cast<gint>(columns[index]);
|
2003-05-06 02:23:50 +00:00
|
|
|
nsMemory::Free(columns);
|
|
|
|
|
|
|
|
*aSelected = atkColumns;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gint
|
2003-05-06 02:23:50 +00:00
|
|
|
getSelectedRowsCB(AtkTable *aTable, gint **aSelected)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
2007-06-08 09:09:24 +00:00
|
|
|
if (!accWrap)
|
|
|
|
return 0;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, 0);
|
|
|
|
|
|
|
|
PRUint32 size = 0;
|
|
|
|
PRInt32 *rows = NULL;
|
2009-09-11 01:07:56 +00:00
|
|
|
nsresult rv = accTable->GetSelectedRowIndices(&size, &rows);
|
2003-05-06 02:23:50 +00:00
|
|
|
if (NS_FAILED(rv) || (size == 0) || !rows) {
|
|
|
|
*aSelected = nsnull;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gint *atkRows = g_new(gint, size);
|
|
|
|
if (!atkRows) {
|
|
|
|
NS_WARNING("OUT OF MEMORY");
|
2012-07-20 11:16:17 +00:00
|
|
|
return 0;
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//copy
|
|
|
|
for (PRUint32 index = 0; index < size; ++index)
|
2007-07-08 07:08:04 +00:00
|
|
|
atkRows[index] = static_cast<gint>(rows[index]);
|
2003-05-06 02:23:50 +00:00
|
|
|
nsMemory::Free(rows);
|
|
|
|
|
|
|
|
*aSelected = atkRows;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gboolean
|
2003-05-06 02:23:50 +00:00
|
|
|
isColumnSelectedCB(AtkTable *aTable, gint aColumn)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
2007-06-08 09:09:24 +00:00
|
|
|
if (!accWrap)
|
|
|
|
return FALSE;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, FALSE);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool outValue;
|
2003-05-06 02:23:50 +00:00
|
|
|
nsresult rv = accTable->IsColumnSelected(aColumn, &outValue);
|
2007-07-08 07:08:04 +00:00
|
|
|
return NS_FAILED(rv) ? FALSE : static_cast<gboolean>(outValue);
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gboolean
|
2003-05-06 02:23:50 +00:00
|
|
|
isRowSelectedCB(AtkTable *aTable, gint aRow)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return FALSE;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, FALSE);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool outValue;
|
2003-05-06 02:23:50 +00:00
|
|
|
nsresult rv = accTable->IsRowSelected(aRow, &outValue);
|
2007-07-08 07:08:04 +00:00
|
|
|
return NS_FAILED(rv) ? FALSE : static_cast<gboolean>(outValue);
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 04:02:50 +00:00
|
|
|
static gboolean
|
2003-05-06 02:23:50 +00:00
|
|
|
isCellSelectedCB(AtkTable *aTable, gint aRow, gint aColumn)
|
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
|
|
|
|
if (!accWrap)
|
|
|
|
return FALSE;
|
2003-05-06 02:23:50 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAccessibleTable> accTable;
|
|
|
|
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
|
|
|
|
getter_AddRefs(accTable));
|
|
|
|
NS_ENSURE_TRUE(accTable, FALSE);
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool outValue;
|
2003-05-06 02:23:50 +00:00
|
|
|
nsresult rv = accTable->IsCellSelected(aRow, aColumn, &outValue);
|
2007-07-08 07:08:04 +00:00
|
|
|
return NS_FAILED(rv) ? FALSE : static_cast<gboolean>(outValue);
|
2003-05-06 02:23:50 +00:00
|
|
|
}
|
2012-03-20 04:02:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tableInterfaceInitCB(AtkTableIface* aIface)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aIface, "no interface!");
|
|
|
|
if (NS_UNLIKELY(!aIface))
|
|
|
|
return;
|
|
|
|
|
|
|
|
aIface->ref_at = refAtCB;
|
|
|
|
aIface->get_index_at = getIndexAtCB;
|
|
|
|
aIface->get_column_at_index = getColumnAtIndexCB;
|
|
|
|
aIface->get_row_at_index = getRowAtIndexCB;
|
|
|
|
aIface->get_n_columns = getColumnCountCB;
|
|
|
|
aIface->get_n_rows = getRowCountCB;
|
|
|
|
aIface->get_column_extent_at = getColumnExtentAtCB;
|
|
|
|
aIface->get_row_extent_at = getRowExtentAtCB;
|
|
|
|
aIface->get_caption = getCaptionCB;
|
|
|
|
aIface->get_column_description = getColumnDescriptionCB;
|
|
|
|
aIface->get_column_header = getColumnHeaderCB;
|
|
|
|
aIface->get_row_description = getRowDescriptionCB;
|
|
|
|
aIface->get_row_header = getRowHeaderCB;
|
|
|
|
aIface->get_summary = getSummaryCB;
|
|
|
|
aIface->get_selected_columns = getSelectedColumnsCB;
|
|
|
|
aIface->get_selected_rows = getSelectedRowsCB;
|
|
|
|
aIface->is_column_selected = isColumnSelectedCB;
|
|
|
|
aIface->is_row_selected = isRowSelectedCB;
|
|
|
|
aIface->is_selected = isCellSelectedCB;
|
|
|
|
}
|