winaccessibility/source/UAccCOM/EnumVariant.cxx |   10 ++++++----
 winaccessibility/source/UAccCOM/MAccessible.cxx |   16 ++--------------
 winaccessibility/source/UAccCOM/MAccessible.h   |    1 -
 winaccessibility/source/UAccCOMIDL/UAccCOM.idl  |    1 -
 4 files changed, 8 insertions(+), 20 deletions(-)

New commits:
commit 00c0ee8cf0fac0c933c5ae600e99a64b1c7d4397
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Jan 31 07:41:14 2022 +0000
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Mon Jan 31 17:31:11 2022 +0100

    tdf#147083 wina11y: Return a11y object instead of child ID
    
    Quoting MSAA doc about implementing child IDs [1]:
    
    > # How Servers Implement Child IDs
    >
    > Server developers can assign child IDs to both simple elements and
    > accessible objects. However, the recommended approach is to support the
    > standard Component Object Model (COM) interface IEnumVARIANT in every
    > accessible object that has children.
    >
    > If you implement IEnumVARIANT, you must:
    >
    > * Enumerate all children, both simple elements and accessible objects.
    >   Provide child IDs for all simple elements and provide the IDispatch to
    >   each accessible object.
    > * For accessible objects, set the vt member of the VARIANT to
    >   VT_DISPATCH. The pdispVal member must contain a pointer to the IDispatch
    >   interface. Note that the VARIANT is allocated and freed by the client.
    > * For simple elements, the child ID is any 32-bit positive integer.
    >   Note that zero and negative integers are reserved by Microsoft Active
    >   Accessibility. Set the VARIANT structure vt member to VT_I4 and the lVal
    >   member to the child ID.
    >
    > If you do not support IEnumVARIANT, you must assign child IDs and
    > number the children in each object sequentially starting with one.
    
    So far, LibreOffice was returning negative "child IDs" instead of pointers
    to accessible objects, which were not conformant to the MSAA
    specification and not accepted by NVDA as valid child IDs
    (s.a. discussion on the first version of my related NVDA pull request
    to fix the announcement of a single selected cell in Calc, [2]).
    
    Adapt that to return pointers to accessible objects and
    drop the now unused 'CMAccessible::Get_XAccChildID'.
    
    [1] 
https://docs.microsoft.com/en-us/windows/win32/winauto/how-servers-implement-child-ids
    [2] https://github.com/nvaccess/nvda/pull/13277
    
    Change-Id: I52a6f637adf334dee66627e6992451e6d81a7c9a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129201
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/winaccessibility/source/UAccCOM/EnumVariant.cxx 
b/winaccessibility/source/UAccCOM/EnumVariant.cxx
index ffda36a25bcc..26cd75b254f9 100644
--- a/winaccessibility/source/UAccCOM/EnumVariant.cxx
+++ b/winaccessibility/source/UAccCOM/EnumVariant.cxx
@@ -69,8 +69,9 @@ HRESULT STDMETHODCALLTYPE CEnumVariant::Next(ULONG 
cElements,VARIANT __RPC_FAR *
                         &pChild);
         if(isGet)
         {
-            pvar[l2].vt = VT_I4;
-            
static_cast<IMAccessible*>(pChild)->Get_XAccChildID(&pvar[l2].lVal);
+            pvar[l2].vt = VT_DISPATCH;
+            pvar[l2].pdispVal = pChild;
+            pChild->AddRef();
         }
         else if(pRXAcc.is())
         {
@@ -80,8 +81,9 @@ HRESULT STDMETHODCALLTYPE CEnumVariant::Next(ULONG 
cElements,VARIANT __RPC_FAR *
                             pRXAcc.get(), &pChild);
             if(isGet)
             {
-                pvar[l2].vt = VT_I4;
-                
static_cast<IMAccessible*>(pChild)->Get_XAccChildID(&pvar[l2].lVal);
+                pvar[l2].vt = VT_DISPATCH;
+                pvar[l2].pdispVal = pChild;
+                pChild->AddRef();
             }
         }
     }
diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx 
b/winaccessibility/source/UAccCOM/MAccessible.cxx
index 495f8b49f196..a24536c8f36f 100644
--- a/winaccessibility/source/UAccCOM/MAccessible.cxx
+++ b/winaccessibility/source/UAccCOM/MAccessible.cxx
@@ -856,8 +856,8 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP 
CMAccessible::get_accSelection(VARIANT *pvarCh
             m_pEnumVar->Next(1,varTmp,&count);
             if(count!=1)
                 return S_FALSE;
-            pvarChildren->vt = VT_I4;
-            pvarChildren->lVal = varTmp[0].lVal;
+            pvarChildren->vt = VT_DISPATCH;
+            pvarChildren->pdispVal = varTmp[0].pdispVal;
             VariantClear(&varTmp[0]);
             m_pEnumVar->Reset();
             break;
@@ -2989,18 +2989,6 @@ void CMAccessible::ConvertAnyToVariant(const 
css::uno::Any &rAnyVal, VARIANT *pv
     }
 }
 
-COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::Get_XAccChildID(long* childID)
-{
-    // internal IMAccessible - no mutex meeded
-
-    if(childID == nullptr)
-    {
-        return E_FAIL;
-    }
-    *childID = m_dChildID;
-    return S_OK;
-}
-
 COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::get_states(AccessibleStates 
__RPC_FAR *states)
 {
     SolarMutexGuard g;
diff --git a/winaccessibility/source/UAccCOM/MAccessible.h 
b/winaccessibility/source/UAccCOM/MAccessible.h
index 1d052eae5ad4..c265d9f7ce82 100644
--- a/winaccessibility/source/UAccCOM/MAccessible.h
+++ b/winaccessibility/source/UAccCOM/MAccessible.h
@@ -209,7 +209,6 @@ private:
     HRESULT WINAPI SmartQI(void* pv, REFIID iid, void** ppvObject);
 
 public:
-    STDMETHOD(Get_XAccChildID)(/*[out,retval]*/ long* childID) override;
     // AccObjectManagerAgent is a management object in UNO, here keep its 
pointer for
     // the implementation of accNavigate when descendant manage happens for 
List,Tree, or Table
     // AccObjectManagerAgent and the following UNO objects 
XAccessible,XAccessibleSelection,
diff --git a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl 
b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl
index bcf20686dfa7..f48b66ddd227 100644
--- a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl
+++ b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl
@@ -49,7 +49,6 @@ import "defines.idl";
         [id(24), helpstring("method Put_ActionDescription")] HRESULT 
Put_ActionDescription( const OLECHAR* szAction);
         [id(25), helpstring("method Put_XAccAgent")] HRESULT 
Put_XAccAgent(hyper pAgent);
         [id(26), helpstring("method NotifyDestroy")] HRESULT NotifyDestroy();
-        [id(30), helpstring("method Get_XAccChildID")] HRESULT 
Get_XAccChildID([out,retval] long* childID);
     };
     [
         object,

Reply via email to