winaccessibility/inc/AccContainerEventListener.hxx                  |    2 
 winaccessibility/inc/AccObject.hxx                                  |    1 
 winaccessibility/inc/AccObjectContainerEventListener.hxx            |    3 
 winaccessibility/inc/AccObjectWinManager.hxx                        |    2 
 winaccessibility/source/UAccCOM/AccTable.cxx                        |    2 
 winaccessibility/source/UAccCOM/MAccessible.cxx                     |   41 
++--------
 winaccessibility/source/UAccCOM/MAccessible.h                       |    2 
 winaccessibility/source/UAccCOMIDL/UAccCOM.idl                      |    1 
 winaccessibility/source/service/AccContainerEventListener.cxx       |   22 
-----
 winaccessibility/source/service/AccEventListener.cxx                |    4 
 winaccessibility/source/service/AccObject.cxx                       |   15 ---
 winaccessibility/source/service/AccObjectContainerEventListener.cxx |   17 ----
 winaccessibility/source/service/AccObjectWinManager.cxx             |   13 ---
 13 files changed, 10 insertions(+), 115 deletions(-)

New commits:
commit c179bf9ae8d0d27d78b72c026256a56b5458d973
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Aug 20 16:29:05 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Aug 21 07:48:10 2024 +0200

    wina11y: Drop superfluous check in CAccTable::get_accessibleAt
    
    There's already a
    
            if(!pRAcc.is())
            {
                *accessible = nullptr;
                return E_FAIL;
            }
    
    further up in that method, so no need to check again.
    
    Change-Id: Ifb855dce067b3bff5a654917e79817da72e156be
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172153
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/winaccessibility/source/UAccCOM/AccTable.cxx 
b/winaccessibility/source/UAccCOM/AccTable.cxx
index 409db86273de..bf0cc9563515 100644
--- a/winaccessibility/source/UAccCOM/AccTable.cxx
+++ b/winaccessibility/source/UAccCOM/AccTable.cxx
@@ -70,7 +70,7 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP 
CAccTable::get_accessibleAt(long row, long col
         pRet->AddRef();
         return S_OK;
     }
-    else if(pRAcc.is())
+    else
     {
         Reference<XAccessible> pxTable(pRXTable, UNO_QUERY);
 
commit a10a99b0c6693b448d388793e451a49ed8c8b795
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Aug 20 15:34:57 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Aug 21 07:47:58 2024 +0200

    wina11y: Retrieve a11y name on demand
    
    Instead of doing extra bookkeeping to keep
    `CMAccessible::m_pszName` as a class member up
    to date with the current value of the accessible
    name, just retrieve the current a11y name directly
    from the underlying `XAccessible` when it is requested
    via the IAccessible2 API in `CMAccessible::get_accName`.
    
    This is basically the accessible name equivalent of the
    the following commit that did similarly for the
    accessible description:
    
        commit fcf4a26275d7503835f9aa23cb94938809840300
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Wed Jan 5 13:41:53 2022 +0000
    
            tdf#146306 wina11y: Retrieve accessible desc on demand
    
            Adapt 'MAccessible::get_accDescription' to directly
            retrieve the accessible description on demand via the
            corresponding XAccessible, rather than keeping
            track of it in a class member.
    
            This simplifies the handling and makes it
            unnecessary to "manually" update the description
            on 'accessibility::AccessibleEventId::DESCRIPTION_CHANGED'
            events, since the new value will
            be queried next time it is needed anyway.
    
            This also fixes the problem that a significant
            amount of time was spent generating accessible
            descriptions for all newly inserted a11y objects when
            entering values into Calc cells with the NVDA
            screen reader in use, resulting in several
            seconds of delay.
    
            Querying up-to-date values from the underlying
            UNO interfaces on demand instead of doing extra
            manual bookkeeping in the winaccessibility code
            may be possible for more a11y attributes in addition
            to the accessible description handled in this commit,
            but each one will have to be looked at separately.
    
    This also allows to drop the
    `AccContainerEventListener::HandleNameChangedEvent` and
    `AccObjectContainerEventListener::HandleStateChangedEvent`
    overrides of the base class implementations unnecessary,
    as the only thing they did in addition was updating the
    a11y name.
    
    This commit has no effect on events sent on the platform
    layer, those are still sent as before to notify about the
    name change.
    
    Change-Id: I4d1df1d0b73ce963cdaec91d642ff5bbf2b371bc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172148
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/winaccessibility/inc/AccContainerEventListener.hxx 
b/winaccessibility/inc/AccContainerEventListener.hxx
index b653b48e2518..5957a7e5099e 100644
--- a/winaccessibility/inc/AccContainerEventListener.hxx
+++ b/winaccessibility/inc/AccContainerEventListener.hxx
@@ -87,8 +87,6 @@ public:
             const css::uno::Any &oldValue, const css::uno::Any &newValue);
     virtual void HandleColumnChangedEvent(
             const css::uno::Any &oldValue, const css::uno::Any &newValue);
-
-    virtual void HandleNameChangedEvent() override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/winaccessibility/inc/AccObject.hxx 
b/winaccessibility/inc/AccObject.hxx
index 405dfa8f9ac1..9e909f5b92d1 100644
--- a/winaccessibility/inc/AccObject.hxx
+++ b/winaccessibility/inc/AccObject.hxx
@@ -108,7 +108,6 @@ public:
     short GetRole() const;
 
     void  UpdateState();
-    void  UpdateName();
     void  UpdateValue();
     void  UpdateAction();
     void  UpdateValidWindow();
diff --git a/winaccessibility/inc/AccObjectContainerEventListener.hxx 
b/winaccessibility/inc/AccObjectContainerEventListener.hxx
index 10e246f2cd2f..c3118796d8a0 100644
--- a/winaccessibility/inc/AccObjectContainerEventListener.hxx
+++ b/winaccessibility/inc/AccObjectContainerEventListener.hxx
@@ -37,9 +37,6 @@ public:
     AccObjectContainerEventListener(css::accessibility::XAccessible* pAcc, 
AccObjectWinManager& rManager);
     virtual ~AccObjectContainerEventListener() override;
 
-    virtual void HandleStateChangedEvent(
-            css::uno::Any oldValue, css::uno::Any newValue) override;
-
     //for visible data changed event, for shapes, the visibledatachanged 
should be mapped to LOCATION_CHANGED
     virtual void HandleVisibleDataChangedEvent() override;
 };
diff --git a/winaccessibility/inc/AccObjectWinManager.hxx 
b/winaccessibility/inc/AccObjectWinManager.hxx
index bbf4e579186f..a910fc71341b 100644
--- a/winaccessibility/inc/AccObjectWinManager.hxx
+++ b/winaccessibility/inc/AccObjectWinManager.hxx
@@ -113,8 +113,6 @@ public:
     void  SetValue( css::accessibility::XAccessible* pXAcc, css::uno::Any pAny 
);
     void  UpdateValue( css::accessibility::XAccessible* pXAcc );
 
-    void  UpdateAccName( css::accessibility::XAccessible* pXAcc );
-
     void  UpdateAccFocus( css::accessibility::XAccessible* newFocus );
     void  UpdateAction( css::accessibility::XAccessible* pXAcc );
 
diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx 
b/winaccessibility/source/UAccCOM/MAccessible.cxx
index 908c0b5ca527..cc08094eb1b1 100644
--- a/winaccessibility/source/UAccCOM/MAccessible.cxx
+++ b/winaccessibility/source/UAccCOM/MAccessible.cxx
@@ -192,7 +192,6 @@ void lcl_addIA2State(AccessibleStates& rStates, sal_Int64 
nUnoState, sal_Int16 n
 AccObjectWinManager* CMAccessible::g_pAccObjectManager = nullptr;
 
 CMAccessible::CMAccessible():
-m_pszName(nullptr),
 m_pszValue(nullptr),
 m_pszActionDescription(nullptr),
 m_iRole(0x00),
@@ -211,10 +210,6 @@ CMAccessible::~CMAccessible()
 {
     SolarMutexGuard g;
 
-    if(m_pszName!=nullptr)
-    {
-        SysFreeString(std::exchange(m_pszName, nullptr));
-    }
     if(m_pszValue!=nullptr)
     {
         SysFreeString(std::exchange(m_pszValue, nullptr));
@@ -374,8 +369,16 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP 
CMAccessible::get_accName(VARIANT varChild, BS
         {
             if(varChild.lVal==CHILDID_SELF)
             {
+                if (!m_xAccessible.is())
+                    return S_FALSE;
+
+                Reference<XAccessibleContext> xContext = 
m_xAccessible->getAccessibleContext();
+                if (!xContext.is())
+                    return S_FALSE;
+
+                const OUString sName = xContext->getAccessibleName();
                 SysFreeString(*pszName);
-                *pszName = SysAllocString(m_pszName);
+                *pszName = SysAllocString(o3tl::toW(sName.getStr()));
                 return S_OK;
             }
 
@@ -1073,32 +1076,6 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP 
CMAccessible::put_accValue(VARIANT varChild, B
         } catch(...) { return E_FAIL; }
 }
 
-/**
-* Set the accessible name of the current COM object self from UNO.
-* @param    pszName, the name value used to set the name of the current object.
-* @return   S_OK if successful and E_FAIL if failure.
-*/
-COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::Put_XAccName(const OLECHAR 
__RPC_FAR *pszName)
-{
-    // internal IMAccessible - no mutex meeded
-
-    try {
-        if (m_isDestroy) return S_FALSE;
-
-        if(pszName == nullptr)
-        {
-            return E_INVALIDARG;
-        }
-
-        SysFreeString(m_pszName);
-        m_pszName = SysAllocString(pszName);
-        if(m_pszName==nullptr)
-            return E_FAIL;
-        return S_OK;
-
-        } catch(...) { return E_FAIL; }
-}
-
 /**
 * Set the accessible role of the current COM object self from UNO.
 * @param    pRole, the role value used to set the role of the current object.
diff --git a/winaccessibility/source/UAccCOM/MAccessible.h 
b/winaccessibility/source/UAccCOM/MAccessible.h
index b0196267b7f3..13dfd9ab6c39 100644
--- a/winaccessibility/source/UAccCOM/MAccessible.h
+++ b/winaccessibility/source/UAccCOM/MAccessible.h
@@ -135,7 +135,6 @@ public:
     // These methods are provided for UNO management system.
     // The UNO management system use these methods to put Accessibility
     // information to COM.
-    STDMETHOD(Put_XAccName)(const OLECHAR __RPC_FAR *pszName) override;
     STDMETHOD(Put_XAccRole)(unsigned short pRole) override;
     STDMETHOD(DecreaseState)(DWORD pXSate) override;
     STDMETHOD(IncreaseState)(DWORD pXSate) override;
@@ -153,7 +152,6 @@ public:
     STDMETHOD(SetXAccessible)(hyper) override;
 
 private:
-    BSTR m_pszName;
     BSTR m_pszValue;
     BSTR m_pszActionDescription;
     unsigned short m_iRole;
diff --git a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl 
b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl
index 871e5c3084c2..8212df86e7ff 100644
--- a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl
+++ b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl
@@ -32,7 +32,6 @@ import "defines.idl";
     ]
     interface IMAccessible : IAccessible2
     {
-        [id(1), helpstring("method Put_XAccName")] HRESULT Put_XAccName(const 
OLECHAR* pszName);
         [id(2), helpstring("method Put_XAccRole")] HRESULT 
Put_XAccRole(unsigned short pRole);
         [id(3), helpstring("method DecreaseState")] HRESULT 
DecreaseState(DWORD pXSate);
         [id(4), helpstring("method IncreaseState")] HRESULT 
IncreaseState(DWORD pXSate);
diff --git a/winaccessibility/source/service/AccContainerEventListener.cxx 
b/winaccessibility/source/service/AccContainerEventListener.cxx
index 227893b22d1f..88160df6995a 100644
--- a/winaccessibility/source/service/AccContainerEventListener.cxx
+++ b/winaccessibility/source/service/AccContainerEventListener.cxx
@@ -473,26 +473,4 @@ void 
AccContainerEventListener::HandleColumnChangedEvent(const Any& /*oldValue*/
     m_rObjManager.NotifyAccEvent(m_xAccessible.get(), 
UnoMSAAEvent::COLUMN_CHANGED);
 }
 
-void AccContainerEventListener::HandleNameChangedEvent()
-{
-    if (GetRole() == AccessibleRole::COMBO_BOX)
-    {
-        Reference<XAccessibleContext> 
mxContext(m_xAccessible->getAccessibleContext());
-        if(mxContext.is())
-        {
-            Reference<XAccessible> mxChild = mxContext->getAccessibleChild(0);
-            if(mxChild.is())
-            {
-                Reference<XAccessibleContext> mxChildContext = 
mxChild->getAccessibleContext();
-                short childrole = mxChildContext->getAccessibleRole();
-                if (childrole == AccessibleRole::TEXT)
-                {
-                    m_rObjManager.UpdateAccName(mxChild.get());
-                }
-            }
-        }
-    }
-    AccEventListener::HandleNameChangedEvent();
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/winaccessibility/source/service/AccEventListener.cxx 
b/winaccessibility/source/service/AccEventListener.cxx
index 3d148c8d13a9..190037aa7751 100644
--- a/winaccessibility/source/service/AccEventListener.cxx
+++ b/winaccessibility/source/service/AccEventListener.cxx
@@ -85,13 +85,9 @@ void AccEventListener::HandleNameChangedEvent()
     {
         XAccessible* pAccDoc = 
m_rObjManager.GetAccDocByAccTopWin(m_xAccessible.get());
         if (pAccDoc)
-        {
-            m_rObjManager.UpdateAccName(pAccDoc);
             m_rObjManager.NotifyAccEvent(pAccDoc, 
UnoMSAAEvent::OBJECT_NAMECHANGE);
-        }
     }
 
-    m_rObjManager.UpdateAccName(m_xAccessible.get());
     m_rObjManager.NotifyAccEvent(m_xAccessible.get(), 
UnoMSAAEvent::OBJECT_NAMECHANGE);
 }
 
diff --git a/winaccessibility/source/service/AccObject.cxx 
b/winaccessibility/source/service/AccObject.cxx
index b39a6076a13d..b102c3b355b0 100644
--- a/winaccessibility/source/service/AccObject.cxx
+++ b/winaccessibility/source/service/AccObject.cxx
@@ -356,19 +356,6 @@ void AccObject::ImplInitializeCreateObj()
     assert(m_pIMAcc);
 }
 
-/**
-   * Update name property to com object.
-   * @param
-   * @return
-   */
-void  AccObject::UpdateName( )
-{
-    if (!m_pIMAcc)
-        return;
-
-    
m_pIMAcc->Put_XAccName(o3tl::toW(m_xAccContextRef->getAccessibleName().getStr()));
-}
-
 /**
    * Update default action property to com object.
    * @param
@@ -999,8 +986,6 @@ bool AccObject::UpdateAccessibleInfoFromUnoToMSAA()
         return false;
     }
 
-    UpdateName();
-
     UpdateValue();
 
     UpdateActionDesc();
diff --git 
a/winaccessibility/source/service/AccObjectContainerEventListener.cxx 
b/winaccessibility/source/service/AccObjectContainerEventListener.cxx
index 09beea09ee37..b9bbb6e2255b 100644
--- a/winaccessibility/source/service/AccObjectContainerEventListener.cxx
+++ b/winaccessibility/source/service/AccObjectContainerEventListener.cxx
@@ -39,23 +39,6 @@ 
AccObjectContainerEventListener::AccObjectContainerEventListener(
 }
 AccObjectContainerEventListener::~AccObjectContainerEventListener() {}
 
-/**
- *  handle the STATE_CHANGED event
- */
-void AccObjectContainerEventListener::HandleStateChangedEvent(Any oldValue, 
Any newValue)
-{
-    //set the accessible name before process for there is no NAME_CHANGED 
event when change
-    //the text in drawing objects.
-    sal_Int64 newV;
-    if (newValue >>= newV)
-    {
-        if (newV == AccessibleStateType::FOCUSED)
-        {
-            m_rObjManager.UpdateAccName(m_xAccessible.get());
-        }
-    }
-    AccContainerEventListener::HandleStateChangedEvent(oldValue, newValue);
-}
 /**
  *  handle the VISIBLE_DATA_CHANGED event
  *  For SHAPES, the visible_data_changed event should be mapped to 
LOCATION_CHANGED event
diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx 
b/winaccessibility/source/service/AccObjectWinManager.cxx
index 614df33f2ce0..8d62ace211cd 100644
--- a/winaccessibility/source/service/AccObjectWinManager.cxx
+++ b/winaccessibility/source/service/AccObjectWinManager.cxx
@@ -847,19 +847,6 @@ void  AccObjectWinManager::UpdateState( 
css::accessibility::XAccessible* pXAcc )
         pAccObj->UpdateState( );
 }
 
-/**
-   * Set corresponding com object's accessible name via XAccessible interface 
and new
-   * name
-   * @param pXAcc XAccessible interface.
-   * @return
-   */
-void  AccObjectWinManager::UpdateAccName( XAccessible* pXAcc )
-{
-    AccObject* pAccObj = GetAccObjByXAcc( pXAcc );
-    if( pAccObj )
-        pAccObj->UpdateName();
-}
-
 void  AccObjectWinManager::UpdateAction( XAccessible* pXAcc )
 {
     AccObject* pAccObj = GetAccObjByXAcc( pXAcc );

Reply via email to