winaccessibility/Library_uacccom.mk | 1 winaccessibility/source/UAccCOM/AccTable.cxx | 99 +++++++++++++ winaccessibility/source/UAccCOM/AccTable.h | 18 ++ winaccessibility/source/UAccCOM/AccTableCell.cxx | 168 +++++++++++++++++++++++ winaccessibility/source/UAccCOM/AccTableCell.h | 87 +++++++++++ winaccessibility/source/UAccCOM/MAccessible.cxx | 31 ++++ winaccessibility/source/UAccCOM/UAccCOM.cxx | 2 winaccessibility/source/UAccCOMIDL/UAccCOM.idl | 8 + 8 files changed, 407 insertions(+), 7 deletions(-)
New commits: commit 97a88e30e2e084ab860635ff4e0a03442d8a12af Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Sep 8 14:37:53 2021 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Sep 8 20:06:00 2021 +0200 tdf#100086 tdf#124832 wina11y: Implement IAccessibleTableCell Add a new class 'AccTableCell' that implements the IAccessibleTableCell interface from the IAccessible2 spec and add what's needed to expose it to accessibility tools via COM. Since there's no specific XInterface for table cells that an XAccessible's context could be queried for, make use of the fact that a table cell's parent is a table, i.e. its accessible context implements XAccessibleTable. AccTableCell keeps a reference to that table and remembers the cell's index in the parent to retrieve information on the cell from there. This addresses the > At least for LibreOffice Table Cells don't implement > IAccessibleTableCell, and therefore there's no way to get the row and > column span. LibreOffice itself also does not expose the merged state in > the accessible name of the cell. comment from [1] (which is the NVDA counterpart for LO's tdf#124832) and may also help for tdf#100086, though more work will be needed on LibreOffice and/or NVDA side for both issues. [1] https://github.com/nvaccess/nvda/issues/9310 Change-Id: I0f53212d14ee17c760b9e6c91be2154a1b25d862 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121821 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/winaccessibility/Library_uacccom.mk b/winaccessibility/Library_uacccom.mk index 9fbb3b7b5bc6..8c3d3c1596e5 100644 --- a/winaccessibility/Library_uacccom.mk +++ b/winaccessibility/Library_uacccom.mk @@ -38,6 +38,7 @@ $(eval $(call gb_Library_add_exception_objects,UAccCOM,\ winaccessibility/source/UAccCOM/AccImage \ winaccessibility/source/UAccCOM/AccRelation \ winaccessibility/source/UAccCOM/AccTable \ + winaccessibility/source/UAccCOM/AccTableCell \ winaccessibility/source/UAccCOM/AccText \ winaccessibility/source/UAccCOM/AccTextBase \ winaccessibility/source/UAccCOM/AccValue \ diff --git a/winaccessibility/source/UAccCOM/AccTableCell.cxx b/winaccessibility/source/UAccCOM/AccTableCell.cxx new file mode 100644 index 000000000000..2cc9a2963ff2 --- /dev/null +++ b/winaccessibility/source/UAccCOM/AccTableCell.cxx @@ -0,0 +1,168 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "AccTableCell.h" + +#include <vcl/svapp.hxx> +#include <com/sun/star/accessibility/XAccessible.hpp> + +using namespace com::sun::star::accessibility; +using namespace com::sun::star::uno; + +CAccTableCell::CAccTableCell() + : m_nIndexInParent(0) +{ +} + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::put_XInterface(hyper pXInterface) +{ + // internal IUNOXWrapper - no mutex meeded + + ENTER_PROTECTED_BLOCK + + CUNOXWrapper::put_XInterface(pXInterface); + if (pUNOInterface == nullptr) + return E_INVALIDARG; + + Reference<XAccessibleContext> xContext = pUNOInterface->getAccessibleContext(); + if (!xContext.is()) + return E_FAIL; + + // retrieve reference to table (parent of the cell) + Reference<XAccessibleContext> xParentContext + = xContext->getAccessibleParent()->getAccessibleContext(); + Reference<XAccessibleTable> xTable(xParentContext, UNO_QUERY); + + if (!xTable.is()) + { + m_xTable.clear(); + return E_FAIL; + } + + m_xTable = xTable; + m_nIndexInParent = xContext->getAccessibleIndexInParent(); + return S_OK; + + LEAVE_PROTECTED_BLOCK +} + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_columnExtent(long* pColumnsSpanned) +{ + SolarMutexGuard g; + + ENTER_PROTECTED_BLOCK + + if (pColumnsSpanned == nullptr) + return E_INVALIDARG; + + if (!m_xTable.is()) + return E_FAIL; + + long nRow = 0, nColumn = 0; + get_rowIndex(&nRow); + get_columnIndex(&nColumn); + + *pColumnsSpanned = m_xTable->getAccessibleColumnExtentAt(nRow, nColumn); + return S_OK; + + LEAVE_PROTECTED_BLOCK +} + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_columnIndex(long* pColumnIndex) +{ + SolarMutexGuard g; + + ENTER_PROTECTED_BLOCK + + if (pColumnIndex == nullptr) + return E_INVALIDARG; + + if (!m_xTable.is()) + return E_FAIL; + + *pColumnIndex = m_xTable->getAccessibleColumn(m_nIndexInParent); + return S_OK; + + LEAVE_PROTECTED_BLOCK +} + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_rowExtent(long* pRowsSpanned) +{ + SolarMutexGuard g; + + ENTER_PROTECTED_BLOCK + + if (pRowsSpanned == nullptr) + return E_INVALIDARG; + + if (!m_xTable.is()) + return E_FAIL; + + long nRow = 0, nColumn = 0; + get_rowIndex(&nRow); + get_columnIndex(&nColumn); + + *pRowsSpanned = m_xTable->getAccessibleRowExtentAt(nRow, nColumn); + + return S_OK; + + LEAVE_PROTECTED_BLOCK +} + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_rowIndex(long* pRowIndex) +{ + SolarMutexGuard g; + + ENTER_PROTECTED_BLOCK + + if (pRowIndex == nullptr) + return E_INVALIDARG; + + if (!m_xTable.is()) + return E_FAIL; + + *pRowIndex = m_xTable->getAccessibleRow(m_nIndexInParent); + return S_OK; + + LEAVE_PROTECTED_BLOCK +} + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_isSelected(boolean* pIsSelected) +{ + SolarMutexGuard g; + + ENTER_PROTECTED_BLOCK + + if (pIsSelected == nullptr) + return E_INVALIDARG; + + if (!m_xTable.is()) + return E_FAIL; + + long nRow = 0, nColumn = 0; + get_rowIndex(&nRow); + get_columnIndex(&nColumn); + + *pIsSelected = m_xTable->isAccessibleSelected(nRow, nColumn); + return S_OK; + + LEAVE_PROTECTED_BLOCK +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/winaccessibility/source/UAccCOM/AccTableCell.h b/winaccessibility/source/UAccCOM/AccTableCell.h new file mode 100644 index 000000000000..9b9315d5ca47 --- /dev/null +++ b/winaccessibility/source/UAccCOM/AccTableCell.h @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * 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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include "Resource.h" + +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/accessibility/XAccessibleTable.hpp> +#include "UNOXWrapper.h" + +/** + * CAccTableCell implements the IAccessibleTableCell interface. + */ +class ATL_NO_VTABLE CAccTableCell : public CComObjectRoot, + public CComCoClass<CAccTableCell, &CLSID_AccTableCell>, + public IAccessibleTableCell, + public CUNOXWrapper + +{ +public: + CAccTableCell(); + virtual ~CAccTableCell() {} + + BEGIN_COM_MAP(CAccTableCell) + COM_INTERFACE_ENTRY(IAccessibleTableCell) + COM_INTERFACE_ENTRY(IUNOXWrapper) + COM_INTERFACE_ENTRY_FUNC_BLIND(NULL, SmartQI_) +#if defined __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Winconsistent-missing-override" +#endif + END_COM_MAP() +#if defined __clang__ +#pragma clang diagnostic pop +#endif + + static HRESULT WINAPI SmartQI_(void* pv, REFIID iid, void** ppvObject, DWORD_PTR) + { + return static_cast<CAccTableCell*>(pv)->SmartQI(iid, ppvObject); + } + + HRESULT SmartQI(REFIID iid, void** ppvObject) + { + if (m_pOuterUnknown) + return OuterQueryInterface(iid, ppvObject); + return E_FAIL; + } + + DECLARE_NO_REGISTRY() + +public: + STDMETHOD(put_XInterface)(hyper pXInterface) override; + + // IAccessibleTableCell interfaces + STDMETHOD(get_columnExtent)(long*) override; + STDMETHOD(get_columnHeaderCells)(IUnknown***, long*) override { return E_FAIL; } + STDMETHOD(get_columnIndex)(long*) override; + STDMETHOD(get_rowExtent)(long*) override; + STDMETHOD(get_rowHeaderCells)(IUnknown***, long*) override { return E_FAIL; } + STDMETHOD(get_rowIndex)(long*) override; + STDMETHOD(get_isSelected)(boolean*) override; + STDMETHOD(get_rowColumnExtents)(long*, long*, long*, long*, boolean*) { return E_FAIL; } + STDMETHOD(get_table)(IUnknown**) { return E_FAIL; } + +private: + css::uno::Reference<css::accessibility::XAccessibleTable> m_xTable; + sal_Int32 m_nIndexInParent; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index 9c100ea5fc4a..ed0796c43ec1 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -38,6 +38,7 @@ #include "AccEditableText.h" #include "AccImage.h" #include "AccTable.h" +#include "AccTableCell.h" #include "AccValue.h" #include "AccHypertext.h" #include "AccHyperLink.h" @@ -77,6 +78,7 @@ enum class XInterfaceType { XI_COMPONENT, XI_TEXT, XI_TABLE, + XI_TABLECELL, XI_EDITABLETEXT, XI_IMAGE, XI_SELECTION, @@ -107,6 +109,30 @@ bool queryXInterface(XAccessible* pXAcc, XInterface** ppXI) return true; } +// Since there's no specific XInterface for table cells, this +// method checks that the accessible's parent is a table +// (implements XAccessibleTable) and pXAcc's context implements +// XAccessibleComponent. +bool queryTableCell(XAccessible* pXAcc, XInterface** ppXI) +{ + XInterface* pXInterface = nullptr; + + const bool bSupportsInterface = queryXInterface<XAccessibleComponent>(pXAcc, &pXInterface); + if (!bSupportsInterface) + return false; + + // check whether parent is a table (its accessible context implements XAccessibleTable) + XInterface* pParentXInterface = nullptr; + Reference<XAccessible> xParentAcc = pXAcc->getAccessibleContext()->getAccessibleParent(); + const bool bParentIsTable = queryXInterface<XAccessibleTable>(xParentAcc.get(), &pParentXInterface); + + if (!bParentIsTable) + return false; + + *ppXI = pXInterface; + return true; +} + } // IA2 states mapping, and name @@ -2498,6 +2524,9 @@ bool CMAccessible::GetXInterfaceFromXAccessible(XAccessible* pXAcc, XInterface** return queryXInterface<XAccessibleEditableText>(pXAcc, ppXI); case XInterfaceType::XI_TABLE: return queryXInterface<XAccessibleTable>(pXAcc, ppXI); + case XInterfaceType::XI_TABLECELL: + // needs specific handling, since there's no XInterface for table cells + return queryTableCell(pXAcc, ppXI); case XInterfaceType::XI_SELECTION: return queryXInterface<XAccessibleSelection>(pXAcc, ppXI); case XInterfaceType::XI_EXTENDEDCOMP: @@ -2551,6 +2580,7 @@ static AggMapEntry g_CMAccessible_AggMap[] = { { &IID_IAccessibleImage, &createAggInstance<CAccImage>, XInterfaceType::XI_IMAGE }, { &IID_IAccessibleTable, &createAggInstance<CAccTable>, XInterfaceType::XI_TABLE }, { &IID_IAccessibleTable2, &createAggInstance<CAccTable>, XInterfaceType::XI_TABLE }, + { &IID_IAccessibleTableCell, &createAggInstance<CAccTableCell>, XInterfaceType::XI_TABLECELL }, { &IID_IAccessibleAction, &createAggInstance<CAccAction>, XInterfaceType::XI_ACTION }, { &IID_IAccessibleValue, &createAggInstance<CAccValue>, XInterfaceType::XI_VALUE }, { &IID_IAccessibleHypertext, &createAggInstance<CAccHypertext>, XInterfaceType::XI_HYPERTEXT }, diff --git a/winaccessibility/source/UAccCOM/UAccCOM.cxx b/winaccessibility/source/UAccCOM/UAccCOM.cxx index 0a981541cc3a..944db5c94c10 100644 --- a/winaccessibility/source/UAccCOM/UAccCOM.cxx +++ b/winaccessibility/source/UAccCOM/UAccCOM.cxx @@ -53,6 +53,7 @@ #include "AccImage.h" #include "AccValue.h" #include "AccTable.h" +#include "AccTableCell.h" #include "AccHyperLink.h" #include "AccHypertext.h" @@ -69,6 +70,7 @@ OBJECT_ENTRY(CLSID_AccEditableText, CAccEditableText) OBJECT_ENTRY(CLSID_AccImage, CAccImage) OBJECT_ENTRY(CLSID_AccValue, CAccValue) OBJECT_ENTRY(CLSID_AccTable, CAccTable) +OBJECT_ENTRY(CLSID_AccTableCell, CAccTableCell) OBJECT_ENTRY(CLSID_AccHyperLink, CAccHyperLink) OBJECT_ENTRY(CLSID_AccHypertext, CAccHypertext) #if defined __clang__ diff --git a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl index 72c43c92dab9..1a0705754114 100644 --- a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl +++ b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl @@ -192,6 +192,14 @@ library UACCCOMLib { [default] interface IAccessibleTable; }; + [ + uuid(77948F17-05C8-4DAA-93D4-BCCD16ADC660), + helpstring("AccTableCell Class") + ] + coclass AccTableCell + { + [default] interface IAccessibleTableCell; + }; [ uuid(519A64CD-F6A6-4793-BE50-4E36C4C593EF), commit 839dbf9ecf9f8fbec7de983d1a2e16d7de6f868c Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Sep 8 14:05:48 2021 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Sep 8 20:05:47 2021 +0200 tdf#100086 tdf#124832 wina11y: Implement IAccessibleTable2 Extend 'CAccTable' to implement the 'IAccessibleTable2' interface in addition to the (deprecated) 'IAccessibleTable' interface from the IAccessible2 spec. 'IAccessibleTable2::get_cellAt' and 'IAccessibleTable2:get_nSelectedCells' are basically the same as 'IAccessibleTable::get_accessibleAt' and 'IAccessibleTable::get_nSelectedChildren' under new names. 'IAccessibleTable2::get_selectedRows' and 'IAccessibleTable2::getSelectedColumns' are essentially the same as their 'IAccessibleTable' counterparts, except that they have the first param removed (which is ignored in the IAccessibleTable version anyway). 'IAccessibleTable2::get_selectedCells' is similar to 'IAccessibleTable::get_selectedChildren', but returns an array of references to selected cells, while the latter just returns an array of their indices. Note: Just having the IAccessibleTable2 interface, but not the IAccessibleTableCell one implemented makes the experience when using the NVDA screen reader temporarily worse, e.g. it now only says "selected" instead of the name of the currently focused cell in Calc. Implementation of IAccessibleTableCell is added in an upcoming commit (Change-Id: I0f53212d14ee17c760b9e6c91be2154a1b25d862, "tdf#100086 tdf#124832 wina11y: Implement IAccessibleTableCell") and makes NVDA announce the name of the cell again. Change-Id: I75346efc3b6e79d5ebf5e1954e9c516244efb887 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121820 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/winaccessibility/source/UAccCOM/AccTable.cxx b/winaccessibility/source/UAccCOM/AccTable.cxx index 7a628d2e9409..f32a8af0c435 100644 --- a/winaccessibility/source/UAccCOM/AccTable.cxx +++ b/winaccessibility/source/UAccCOM/AccTable.cxx @@ -99,6 +99,11 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_accessibleAt(long row, long col LEAVE_PROTECTED_BLOCK } +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_cellAt(long row, long column, IUnknown * * cell) +{ + return get_accessibleAt(row, column, cell); +} + /** * Gets accessible table caption. * @@ -433,11 +438,10 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_rowHeader(IAccessibleTable __RP /** * Gets list of row indexes currently selected (0-based). * - * @param maxRows the max number of the rows. * @param accessible the accessible object array of the selected rows. * @param nRows the actual size of the accessible object array. */ -COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedRows(long, long ** rows, long * nRows) +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedRows(long** rows, long* nRows) { SolarMutexGuard g; @@ -469,14 +473,25 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedRows(long, long ** rows LEAVE_PROTECTED_BLOCK } +/** + * Gets list of row indexes currently selected (0-based). + * + * @param maxRows This parameter is ignored. + * @param accessible the accessible object array of the selected rows. + * @param nRows the actual size of the accessible object array. + */ +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedRows(long, long ** rows, long * nRows) +{ + return get_selectedRows(rows, nRows); +} + /** * Gets list of column indexes currently selected (0-based). * - * @param maxColumns the max number of the columns. * @param accessible the accessible object array of the selected columns. * @param numColumns the actual size of accessible object array. */ -COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedColumns(long, long ** columns, long * numColumns) +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedColumns(long ** columns, long * numColumns) { SolarMutexGuard g; @@ -508,6 +523,18 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedColumns(long, long ** c LEAVE_PROTECTED_BLOCK } +/** + * Gets list of column indexes currently selected (0-based). + * + * @param maxColumns This parameter is ignored + * @param accessible the accessible object array of the selected columns. + * @param numColumns the actual size of accessible object array. + */ +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedColumns(long, long ** columns, long * numColumns) +{ + return get_selectedColumns(columns, numColumns); +} + /** * Gets accessible table summary. * @@ -835,6 +862,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::put_XInterface(hyper pXInterface) LEAVE_PROTECTED_BLOCK } + /** * Gets columnIndex of childIndex. * @@ -883,6 +911,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_rowIndex(long childIndex, long LEAVE_PROTECTED_BLOCK } + /** * Gets childIndex of childIndex. * @@ -950,6 +979,13 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nSelectedChildren(long *childCo LEAVE_PROTECTED_BLOCK } + + +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_nSelectedCells(long *cellCount) +{ + return get_nSelectedChildren(cellCount); +} + // @brief Returns a list of child indexes currently selected (0-based). // @param [in] maxChildren // Max children requested (possibly from IAccessibleTable::nSelectedChildren) @@ -1001,4 +1037,59 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedChildren(long, long **c } +/** + * @brief Returns a list of accessibles currently selected. + * @param cells Pointer to an array of references to selected accessibles. + * The array is allocated by the server with CoTaskMemAlloc and + * freed by the client with CoTaskMemFree. + * @param nSelectedCells The number of accessibles returned; the size of the returned array. + * @return S_FALSE if there are none, [out] values are NULL and 0 respectively, otherwise S_OK + */ +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedCells(IUnknown * * * cells, long *nSelectedCells) +{ + SolarMutexGuard g; + + ENTER_PROTECTED_BLOCK + + if (cells == nullptr || nSelectedCells == nullptr) + return E_INVALIDARG; + + if (!pRXTable.is()) + return E_FAIL; + + Reference<XAccessibleSelection> xSelection(pRXTable, UNO_QUERY); + if (!xSelection.is()) + return E_FAIL; + + const long nSelected = xSelection->getSelectedAccessibleChildCount(); + *nSelectedCells = nSelected; + + *cells = static_cast<IUnknown**>(CoTaskMemAlloc(nSelected * sizeof(IUnknown*))); + + for (long i = 0; i < nSelected; i++) + { + Reference<XAccessible> xAcc = xSelection->getSelectedAccessibleChild(i); + assert(xAcc.is()); + + IAccessible* pIAccessible; + bool bOK = CMAccessible::get_IAccessibleFromXAccessible(xAcc.get(), &pIAccessible); + + if (!bOK) + { + Reference<XAccessible> xTable(pRXTable, UNO_QUERY); + CMAccessible::g_pAgent->InsertAccObj(xAcc.get(), xTable.get()); + bOK = CMAccessible::get_IAccessibleFromXAccessible(xAcc.get(), &pIAccessible); + } + + assert(bOK && "Couldn't retrieve IAccessible object"); + + pIAccessible->AddRef(); + (*cells)[i] = pIAccessible; + } + + return S_OK; + + LEAVE_PROTECTED_BLOCK +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/winaccessibility/source/UAccCOM/AccTable.h b/winaccessibility/source/UAccCOM/AccTable.h index b373339bc369..d4062986147c 100644 --- a/winaccessibility/source/UAccCOM/AccTable.h +++ b/winaccessibility/source/UAccCOM/AccTable.h @@ -26,12 +26,13 @@ #include "UNOXWrapper.h" /** - * CAccTable implements IAccessibleTable interface. + * CAccTable implements the IAccessibleTable and IAccessibleTable2 interfaces. */ class ATL_NO_VTABLE CAccTable : public CComObjectRoot, public CComCoClass<CAccTable, &CLSID_AccTable>, public IAccessibleTable, + public IAccessibleTable2, public CUNOXWrapper { @@ -45,6 +46,7 @@ public: BEGIN_COM_MAP(CAccTable) COM_INTERFACE_ENTRY(IAccessibleTable) + COM_INTERFACE_ENTRY(IAccessibleTable2) COM_INTERFACE_ENTRY(IUNOXWrapper) COM_INTERFACE_ENTRY_FUNC_BLIND(NULL,SmartQI_) #if defined __clang__ @@ -72,11 +74,14 @@ public: DECLARE_NO_REGISTRY() public: - // IAccessibleTable + // IAccessibleTable and IAccessibleTable2 - // Gets accessible table cell. + // Gets accessible table cell (IAccessibleTable version). STDMETHOD(get_accessibleAt)(long row, long column, IUnknown * * accessible) override; + // Gets accessible table cell (IAccessibleTable2 version). + STDMETHOD(get_cellAt)(long row, long column, IUnknown * * cell) override; + // Gets accessible table caption. STDMETHOD(get_caption)(IUnknown * * accessible) override; @@ -111,9 +116,11 @@ public: STDMETHOD(get_rowHeader)(IAccessibleTable __RPC_FAR *__RPC_FAR *accessibleTable, long *startingColumnIndex) override; // Gets list of row indexes currently selected (0-based). + STDMETHOD(get_selectedRows)(long **rows, long * nRows) override; STDMETHOD(get_selectedRows)(long maxRows, long **rows, long * nRows) override; // Gets list of column indexes currently selected (0-based). + STDMETHOD(get_selectedColumns)(long **columns, long * numColumns) override; STDMETHOD(get_selectedColumns)(long maxColumns, long **columns, long * numColumns) override; // Gets accessible table summary. @@ -149,10 +156,15 @@ public: STDMETHOD(get_childIndex)(long rowIndex,long columnIndex, long * childIndex) override; + // get total number of selected cells STDMETHOD(get_nSelectedChildren)(long *childCount) override; + STDMETHOD(get_nSelectedCells)(long *childCount) override; STDMETHOD(get_selectedChildren)(long maxChildren, long **children, long *nChildren) override; + // Returns a list of accessibles currently selected + STDMETHOD(get_selectedCells)(IUnknown * * * cells, long *nSelectedCells) override; + STDMETHOD(get_rowColumnExtentsAtIndex)( long index, long *row, long *column, diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx index 7ac0e67b9eff..9c100ea5fc4a 100644 --- a/winaccessibility/source/UAccCOM/MAccessible.cxx +++ b/winaccessibility/source/UAccCOM/MAccessible.cxx @@ -2550,6 +2550,7 @@ static AggMapEntry g_CMAccessible_AggMap[] = { { &IID_IAccessibleEditableText, &createAggInstance<CAccEditableText>, XInterfaceType::XI_EDITABLETEXT }, { &IID_IAccessibleImage, &createAggInstance<CAccImage>, XInterfaceType::XI_IMAGE }, { &IID_IAccessibleTable, &createAggInstance<CAccTable>, XInterfaceType::XI_TABLE }, + { &IID_IAccessibleTable2, &createAggInstance<CAccTable>, XInterfaceType::XI_TABLE }, { &IID_IAccessibleAction, &createAggInstance<CAccAction>, XInterfaceType::XI_ACTION }, { &IID_IAccessibleValue, &createAggInstance<CAccValue>, XInterfaceType::XI_VALUE }, { &IID_IAccessibleHypertext, &createAggInstance<CAccHypertext>, XInterfaceType::XI_HYPERTEXT },