From a3ddcc9247351324e410f240e1599eaabb5bde5d Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 5 Aug 2022 07:46:57 +0100 Subject: wina11y: Implement IAccessibleTableCell::get_table Tested using NVDA's Python Console as follows: 1) start LO Writer, "Table" -> "Insert Table" 2) select to create table with 2 rows, 2 columns 3) make sure "Heading" is checked, "Heading rows": 1 4) "Insert" 5) in the first row, type "First heading" into first column, "Second heading" into second column 5) start NVDA 6) make sure cursor is in the first table cell ("Heading 1") 7) press KP_Insert+Ctrl+Z to start NVDA's Python console 8) Use NVDA's Python console to call the corresponding IAccessible2 methods and check the result: >>> from IAccessibleHandler import IA2 >>> cell = focus.parent.IAccessibleObject.QueryInterface(IA2.IAccessibleTableCell) >>> cell.table >>> cell.table.QueryInterface(IA2.IAccessibleTable) >>> cell.table.QueryInterface(IA2.IAccessibleTable).nRows 2 >>> cell.table.QueryInterface(IA2.IAccessibleTable).nColumns 2 Without this commit in place, this would fail as follows: >>> from IAccessibleHandler import IA2 >>> cell = focus.parent.IAccessibleObject.QueryInterface(IA2.IAccessibleTableCell) >>> cell.table Traceback (most recent call last): File "", line 1, in File "monkeyPatches\comtypesMonkeyPatches.pyc", line 32, in __call__ _ctypes.COMError: (-2147467259, 'Unspecified error', (None, None, None, 0, None)) Change-Id: I67b84f1fd9d397a3aa40b5336c3baafad35eec29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137846 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- winaccessibility/source/UAccCOM/AccTableCell.cxx | 23 +++++++++++++++++++++++ winaccessibility/source/UAccCOM/AccTableCell.h | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'winaccessibility') diff --git a/winaccessibility/source/UAccCOM/AccTableCell.cxx b/winaccessibility/source/UAccCOM/AccTableCell.cxx index b8db728009ea..5e793af9ec96 100644 --- a/winaccessibility/source/UAccCOM/AccTableCell.cxx +++ b/winaccessibility/source/UAccCOM/AccTableCell.cxx @@ -18,6 +18,7 @@ */ #include "AccTableCell.h" +#include "MAccessible.h" #include #include @@ -206,4 +207,26 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_rowColumnExtents(long* pRow return S_OK; } +COM_DECLSPEC_NOTHROW STDMETHODIMP CAccTableCell::get_table(IUnknown** ppTable) +{ + if (!ppTable) + return E_INVALIDARG; + + if (!m_xTable.is()) + return E_FAIL; + + Reference xAcc(m_xTable, UNO_QUERY); + if (!xAcc.is()) + return E_FAIL; + + IAccessible* pRet = nullptr; + bool bOK = CMAccessible::get_IAccessibleFromXAccessible(xAcc.get(), &pRet); + if (!bOK) + return E_FAIL; + + *ppTable = pRet; + pRet->AddRef(); + return S_OK; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/winaccessibility/source/UAccCOM/AccTableCell.h b/winaccessibility/source/UAccCOM/AccTableCell.h index 914794a04f66..0b85a6c245d1 100644 --- a/winaccessibility/source/UAccCOM/AccTableCell.h +++ b/winaccessibility/source/UAccCOM/AccTableCell.h @@ -77,7 +77,7 @@ public: STDMETHOD(get_rowIndex)(long*) override; STDMETHOD(get_isSelected)(boolean*) override; STDMETHOD(get_rowColumnExtents)(long*, long*, long*, long*, boolean*) override; - STDMETHOD(get_table)(IUnknown**) { return E_FAIL; } + STDMETHOD(get_table)(IUnknown**) override; private: css::uno::Reference m_xTable; -- cgit