winaccessibility/source/UAccCOM/AccTableCell.cxx |   23 +++++++++++++++++++++++
 winaccessibility/source/UAccCOM/AccTableCell.h   |    2 +-
 2 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit a3ddcc9247351324e410f240e1599eaabb5bde5d
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Aug 5 07:46:57 2022 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Aug 5 13:22:23 2022 +0200

    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
        <POINTER(IUnknown) ptr=0x7cc5b24 at 13f3850>
        >>> cell.table.QueryInterface(IA2.IAccessibleTable)
        <POINTER(IAccessibleTable) ptr=0x378d47c at 13f38f0>
        >>> 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 "<console>", line 1, in <module>
          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 <m.wegh...@posteo.de>

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 <vcl/svapp.hxx>
 #include <com/sun/star/accessibility/XAccessible.hpp>
@@ -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<XAccessible> 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<css::accessibility::XAccessibleTable> m_xTable;

Reply via email to