summaryrefslogtreecommitdiff
path: root/winaccessibility
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2021-09-08 14:05:48 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2021-09-08 20:05:47 +0200
commit839dbf9ecf9f8fbec7de983d1a2e16d7de6f868c (patch)
tree5fc8ffe6cc669b1ae4e0bfa0f569df32623e935c /winaccessibility
parentb298885ceaab0c892ffc449e09c2967a3a9e3ea6 (diff)
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.weghorn@posteo.de>
Diffstat (limited to 'winaccessibility')
-rw-r--r--winaccessibility/source/UAccCOM/AccTable.cxx99
-rw-r--r--winaccessibility/source/UAccCOM/AccTable.h18
-rw-r--r--winaccessibility/source/UAccCOM/MAccessible.cxx1
3 files changed, 111 insertions, 7 deletions
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;
@@ -470,13 +474,24 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedRows(long, long ** rows
}
/**
+ * 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;
@@ -509,6 +524,18 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTable::get_selectedColumns(long, long ** c
}
/**
+ * 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.
*
* @param accessible the accessible object of the 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 },