summaryrefslogtreecommitdiff
path: root/winaccessibility
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-08-22 09:37:01 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2024-08-23 07:40:10 +0200
commit002a29b8dd0d4c61194227e4151b4847480cb8b1 (patch)
tree748d1b4ce02e77113105799ffdfc115f6320ac6e /winaccessibility
parentd38de2e655617c72976e9df327c89fef73abf422 (diff)
tdf#91739 wina11y: Add skeleton IAccessible2_2 implementation
Derive from the `IAccessible2_2` insterface [1] instead of directly from (its base interface) `IAccessible2` and add dummy implementations for the corresponding methods that return `E_NOTIMPL` to indicate that there's no real implementation yet. An actual implementations for at least `CMAccessible::get_relationTargetsOfType` is planned for a separate upcoming commit. Support for the interface can be checked e.g. in Accerciser's Python console: Before: >>> from comInterfaces import IAccessible2Lib as IA2 >>> focus.IAccessibleObject <POINTER(IAccessible2) ptr=0x9667f24 at 6841850> >>> focus.IAccessibleObject.QueryInterface(IA2.IAccessible2) <POINTER(IAccessible2) ptr=0x9667f24 at 6822120> >>> focus.IAccessibleObject.QueryInterface(IA2.IAccessible2_2) Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\tools\cygwin\home\user\development\git\nvda\.venv\Lib\site-packages\comtypes\__init__.py", line 831, in QueryInterface self.__com_QueryInterface(byref(iid), byref(p)) File "C:\tools\cygwin\home\user\development\git\nvda\source\monkeyPatches\comtypesMonkeyPatches.py", line 33, in __call__ return super().__call__(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ctypes.COMError: (-2147467262, 'No such interface supported', (None, None, None, 0, None)) With this commit in place: >>> from comInterfaces import IAccessible2Lib as IA2 >>> focus.IAccessibleObject <POINTER(IAccessible2) ptr=0x988c784 at 6363580> >>> focus.IAccessibleObject.QueryInterface(IA2.IAccessible2) <POINTER(IAccessible2) ptr=0x988c784 at c55d7b0> >>> focus.IAccessibleObject.QueryInterface(IA2.IAccessible2_2) <POINTER(IAccessible2_2) ptr=0x974d824 at 6847f80> And calling one of the methods gives a "Not Implemented" COMError as expected: >>> ia2_2 = focus.IAccessibleObject.QueryInterface(IA2.IAccessible2_2) >>> ia2_2.attribute("dummy") Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\tools\cygwin\home\user\development\git\nvda\.venv\Lib\site-packages\comtypes\_memberspec.py", line 482, in __call__ return self.fget(self.instance, *args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ctypes.COMError: (-2147467263, 'Not implemented', (None, None, None, 0, None)) [1] https://github.com/LinuxA11y/IAccessible2/blob/34f96c2a28f4974ad488703b41599a6c6059a7e0/api/Accessible2_2.idl Change-Id: I77bed1f27353c4d08229ffe17afee03b813a4d4f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172256 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'winaccessibility')
-rw-r--r--winaccessibility/source/UAccCOM/MAccessible.cxx16
-rw-r--r--winaccessibility/source/UAccCOM/MAccessible.h6
-rw-r--r--winaccessibility/source/UAccCOMIDL/UAccCOM.idl2
3 files changed, 23 insertions, 1 deletions
diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx b/winaccessibility/source/UAccCOM/MAccessible.cxx
index cdc90cfb82bd..549fee11a92f 100644
--- a/winaccessibility/source/UAccCOM/MAccessible.cxx
+++ b/winaccessibility/source/UAccCOM/MAccessible.cxx
@@ -2676,4 +2676,20 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_attributes(/*[out]*/ BSTR *p
} catch(...) { return E_FAIL; }
}
+// IAccessible2_2 methods
+COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_attribute(BSTR, VARIANT*)
+{
+ return E_NOTIMPL;
+}
+
+COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_accessibleWithCaret(IUnknown**, long*)
+{
+ return E_NOTIMPL;
+}
+
+COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_relationTargetsOfType(BSTR, long, IUnknown***, long*)
+{
+ return E_NOTIMPL;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/winaccessibility/source/UAccCOM/MAccessible.h b/winaccessibility/source/UAccCOM/MAccessible.h
index b17a8d78b7d9..7bd2153bf344 100644
--- a/winaccessibility/source/UAccCOM/MAccessible.h
+++ b/winaccessibility/source/UAccCOM/MAccessible.h
@@ -64,6 +64,7 @@ public:
COM_INTERFACE_ENTRY(IMAccessible)
COM_INTERFACE_ENTRY(IAccessible)
COM_INTERFACE_ENTRY(IAccessible2)
+ COM_INTERFACE_ENTRY(IAccessible2_2)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IAccessibleApplication)
COM_INTERFACE_ENTRY(IServiceProvider)
@@ -121,6 +122,11 @@ public:
STDMETHOD(get_locale)( IA2Locale __RPC_FAR *locale ) override;
STDMETHOD(get_attributes)(/*[out]*/ BSTR *pAttr) override;
+ // IAccessible2_2 methods
+ STDMETHOD(get_attribute)(BSTR name, VARIANT* attribute) override;
+ STDMETHOD(get_accessibleWithCaret)(IUnknown** accessible, long* caretOffset) override;
+ STDMETHOD(get_relationTargetsOfType)(BSTR type, long maxTargets, IUnknown*** targets, long* nTargets) override;
+
//IServiceProvider.
STDMETHOD(QueryService)(REFGUID guidService, REFIID riid, void** ppvObject) override;
diff --git a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl
index 8c63a5a3bfdf..f006146fd58f 100644
--- a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl
+++ b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl
@@ -30,7 +30,7 @@ import "defines.idl";
helpstring("IMAccessible Interface"),
pointer_default(unique)
]
- interface IMAccessible : IAccessible2
+ interface IMAccessible : IAccessible2_2
{
[id(2), helpstring("method Put_XAccRole")] HRESULT Put_XAccRole(unsigned short pRole);
[id(3), helpstring("method DecreaseState")] HRESULT DecreaseState(DWORD pXSate);