winaccessibility/inc/AccObject.hxx                                  |    2 
 winaccessibility/inc/AccObjectManagerAgent.hxx                      |    3 
 winaccessibility/inc/AccObjectWinManager.hxx                        |    3 
 winaccessibility/source/UAccCOM/MAccessible.cxx                     |   43 
++--------
 winaccessibility/source/UAccCOM/MAccessible.h                       |    2 
 winaccessibility/source/UAccCOMIDL/UAccCOM.idl                      |    1 
 winaccessibility/source/service/AccContainerEventListener.cxx       |    2 
 winaccessibility/source/service/AccEventListener.cxx                |    1 
 winaccessibility/source/service/AccObject.cxx                       |   32 
-------
 winaccessibility/source/service/AccObjectContainerEventListener.cxx |    1 
 winaccessibility/source/service/AccObjectManagerAgent.cxx           |   18 ----
 winaccessibility/source/service/AccObjectWinManager.cxx             |   20 ----
 12 files changed, 9 insertions(+), 119 deletions(-)

New commits:
commit fcf4a26275d7503835f9aa23cb94938809840300
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Jan 5 13:41:53 2022 +0000
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Jan 6 10:10:11 2022 +0100

    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.
    
    Change-Id: I57f4c523ca8b10afad3f9c347c8ff5e9420ad968
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128006
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/winaccessibility/inc/AccObject.hxx 
b/winaccessibility/inc/AccObject.hxx
index 2a246ce43b29..6da9d6621c5e 100644
--- a/winaccessibility/inc/AccObject.hxx
+++ b/winaccessibility/inc/AccObject.hxx
@@ -114,7 +114,6 @@ public:
 
     void  SetName( css::uno::Any newName);
     void  SetValue( css::uno::Any pAny );
-    void  SetDescription( css::uno::Any newDesc );
     void  SetRole( short Role );
 
     short GetRole() const;
@@ -123,7 +122,6 @@ public:
     void  UpdateName();
     void  UpdateValue();
     void  UpdateAction();
-    void  UpdateDescription();
     void  UpdateValidWindow();
     void  UpdateLocation();
 
diff --git a/winaccessibility/inc/AccObjectManagerAgent.hxx 
b/winaccessibility/inc/AccObjectManagerAgent.hxx
index 579a785b41bb..a0f3daec579b 100644
--- a/winaccessibility/inc/AccObjectManagerAgent.hxx
+++ b/winaccessibility/inc/AccObjectManagerAgent.hxx
@@ -76,9 +76,6 @@ public:
     void  UpdateAccName( css::accessibility::XAccessible* pXAcc, css::uno::Any 
newName);
     void  UpdateAccName( css::accessibility::XAccessible* pXAcc);
 
-    void  UpdateDescription( css::accessibility::XAccessible* pXAcc, 
css::uno::Any newDesc );
-    void  UpdateDescription( css::accessibility::XAccessible* pXAcc );
-
     void NotifyDestroy(css::accessibility::XAccessible* pXAcc);
 
     css::accessibility::XAccessible* GetParentXAccessible( 
css::accessibility::XAccessible* pXAcc );
diff --git a/winaccessibility/inc/AccObjectWinManager.hxx 
b/winaccessibility/inc/AccObjectWinManager.hxx
index 4f35668c56ef..911c83ea2a8f 100644
--- a/winaccessibility/inc/AccObjectWinManager.hxx
+++ b/winaccessibility/inc/AccObjectWinManager.hxx
@@ -122,9 +122,6 @@ public:
     void  SetAccName( css::accessibility::XAccessible* pXAcc, css::uno::Any 
newName);
     void  UpdateAccName( css::accessibility::XAccessible* pXAcc );
 
-    void  SetDescription( css::accessibility::XAccessible* pXAcc, 
css::uno::Any newDesc );
-    void UpdateDescription( css::accessibility::XAccessible* pXAcc );
-
     void  SetRole( css::accessibility::XAccessible* pXAcc, long Role );
 
     void  UpdateAccFocus( css::accessibility::XAccessible* newFocus );
diff --git a/winaccessibility/source/UAccCOM/MAccessible.cxx 
b/winaccessibility/source/UAccCOM/MAccessible.cxx
index 7437f8a586c9..0e3de1af1b53 100644
--- a/winaccessibility/source/UAccCOM/MAccessible.cxx
+++ b/winaccessibility/source/UAccCOM/MAccessible.cxx
@@ -200,7 +200,6 @@ m_pszValue(nullptr),
 m_pszActionDescription(nullptr),
 m_iRole(0x00),
 m_dState(0x00),
-m_pszDescription(nullptr),
 m_pIParent(nullptr),
 m_dChildID(0x00),
 m_dFocusChildID(UACC_NO_FOCUS),
@@ -227,10 +226,6 @@ CMAccessible::~CMAccessible()
     {
         SAFE_SYSFREESTRING(m_pszValue);
     }
-    if(m_pszDescription!=nullptr)
-    {
-        SAFE_SYSFREESTRING(m_pszDescription);
-    }
 
     if(m_pszActionDescription!=nullptr)
     {
@@ -462,8 +457,16 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP 
CMAccessible::get_accDescription(VARIANT varCh
         {
             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 sDescription = 
xContext->getAccessibleDescription();
                 SAFE_SYSFREESTRING(*pszDescription);
-                *pszDescription = SysAllocString(m_pszDescription);
+                *pszDescription = 
SysAllocString(o3tl::toW(sDescription.getStr()));
                 return S_OK;
             }
 
@@ -1199,34 +1202,6 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP 
CMAccessible::SetState(DWORD pXSate)
     return S_OK;
 }
 
-
-/**
-* Set the accessible description of the current COM object self from UNO.
-* @param    pszDescription, the name used to set the description of the 
current object.
-* @return   S_OK if successful and E_FAIL if failure.
-*/
-COM_DECLSPEC_NOTHROW STDMETHODIMP CMAccessible::Put_XAccDescription(const 
OLECHAR __RPC_FAR *pszDescription)
-{
-    // internal IMAccessible - no mutex meeded
-
-    ENTER_PROTECTED_BLOCK
-        ISDESTROY()
-        // #CHECK#
-        if(pszDescription == nullptr)
-        {
-            return E_INVALIDARG;
-        }
-
-        SAFE_SYSFREESTRING(m_pszDescription);
-        m_pszDescription = SysAllocString(pszDescription);
-
-        if(m_pszDescription==nullptr)
-            return E_FAIL;
-        return S_OK;
-
-        LEAVE_PROTECTED_BLOCK
-}
-
 /**
 * Set the accessible value of the current COM object self from UNO.
 * @param    pszAccValue, the name used to set the value of the current object.
diff --git a/winaccessibility/source/UAccCOM/MAccessible.h 
b/winaccessibility/source/UAccCOM/MAccessible.h
index 3c662c1f12fb..1d052eae5ad4 100644
--- a/winaccessibility/source/UAccCOM/MAccessible.h
+++ b/winaccessibility/source/UAccCOM/MAccessible.h
@@ -139,7 +139,6 @@ public:
     STDMETHOD(DecreaseState)(DWORD pXSate) override;
     STDMETHOD(IncreaseState)(DWORD pXSate) override;
     STDMETHOD(SetState)(DWORD pXSate) override;
-    STDMETHOD(Put_XAccDescription)(const OLECHAR __RPC_FAR *pszDescription) 
override;
     STDMETHOD(Put_XAccValue)(const OLECHAR __RPC_FAR *pszAccValue) override;
     STDMETHOD(Put_XAccLocation)(const Location sLocation) override;
     STDMETHOD(Put_XAccFocus)(long dChildID) override;
@@ -159,7 +158,6 @@ private:
     BSTR m_pszActionDescription;
     unsigned short m_iRole;
     DWORD   m_dState;
-    BSTR m_pszDescription;
     IMAccessible* m_pIParent;
     Location m_sLocation;
 
diff --git a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl 
b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl
index da123ab7f972..bcf20686dfa7 100644
--- a/winaccessibility/source/UAccCOMIDL/UAccCOM.idl
+++ b/winaccessibility/source/UAccCOMIDL/UAccCOM.idl
@@ -36,7 +36,6 @@ import "defines.idl";
         [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);
-        [id(5), helpstring("method Put_XDescription")] HRESULT 
Put_XAccDescription(const OLECHAR* pszDescription);
         [id(6), helpstring("method Put_XAccValue")] HRESULT 
Put_XAccValue(const OLECHAR* pszAccValue);
         [id(7), helpstring("method SetState")] HRESULT SetState(DWORD pXSate);
         [id(8), helpstring("method Put_XAccLocation")] HRESULT 
Put_XAccLocation(const Location sLocation);
diff --git a/winaccessibility/source/service/AccContainerEventListener.cxx 
b/winaccessibility/source/service/AccContainerEventListener.cxx
index 9587255acd28..ae4cccba9e0e 100644
--- a/winaccessibility/source/service/AccContainerEventListener.cxx
+++ b/winaccessibility/source/service/AccContainerEventListener.cxx
@@ -362,10 +362,8 @@ void 
AccContainerEventListener::FireStateFocusedChange(bool enable)
                 || parentRole == AccessibleRole::PANEL) // sidebar
                 pAgent->NotifyAccEvent(UM_EVENT_STATE_FOCUSED, 
m_xAccessible.get());
         }
-        //to update ComboBox's description
         else if (role == AccessibleRole::COMBO_BOX )
         {
-            pAgent->UpdateDescription(m_xAccessible.get());
             //for editable combobox, send focus event on only edit control,
             bool bSendFocusOnCombobox = true;
             //send focused event to the first text child
diff --git a/winaccessibility/source/service/AccEventListener.cxx 
b/winaccessibility/source/service/AccEventListener.cxx
index 3168476c5935..1d378040ce3f 100644
--- a/winaccessibility/source/service/AccEventListener.cxx
+++ b/winaccessibility/source/service/AccEventListener.cxx
@@ -99,7 +99,6 @@ void AccEventListener::HandleNameChangedEvent(Any name)
  */
 void AccEventListener::HandleDescriptionChangedEvent(Any desc)
 {
-    pAgent->UpdateDescription(m_xAccessible.get(), desc);
     pAgent->NotifyAccEvent(UM_EVENT_OBJECT_DESCRIPTIONCHANGE, 
m_xAccessible.get());
 }
 
diff --git a/winaccessibility/source/service/AccObject.cxx 
b/winaccessibility/source/service/AccObject.cxx
index e9ca101207fe..781c58c82e71 100644
--- a/winaccessibility/source/service/AccObject.cxx
+++ b/winaccessibility/source/service/AccObject.cxx
@@ -285,22 +285,6 @@ void  AccObject::UpdateName( )
 
     return ;
 }
-/**
-   * Update description property to com object.
-   * no content for update description
-   * @param
-   * @return
-   */
-void AccObject::UpdateDescription()
-{
-    if (!m_pIMAcc)
-    {
-        return;
-    }
-
-    
m_pIMAcc->Put_XAccDescription(o3tl::toW(m_xAccContextRef->getAccessibleDescription().getStr()));
-    return ;
-}
 
 /**
    * Update default action property to com object.
@@ -501,18 +485,6 @@ void  AccObject::SetName( Any pAny)
 
 }
 
-/**
-   * Set description property via pAny.
-   * @param pAny New accessible description.
-   * @return
-   */
-void  AccObject::SetDescription( Any pAny )
-{
-    if( nullptr == m_pIMAcc )
-        return ;
-    m_pIMAcc->Put_XAccDescription( 
o3tl::toW(GetMAccessibleValueFromAny(pAny).getStr()) );
-}
-
 /**
    * Set role property via pAny
    * @param Role New accessible role.
@@ -1023,8 +995,6 @@ bool AccObject:: UpdateAccessibleInfoFromUnoToMSAA ( )
 
     UpdateValue();
 
-    UpdateDescription();
-
     UpdateActionDesc();
 
     UpdateRole();
diff --git 
a/winaccessibility/source/service/AccObjectContainerEventListener.cxx 
b/winaccessibility/source/service/AccObjectContainerEventListener.cxx
index dc99d3394c4a..429e99734e78 100644
--- a/winaccessibility/source/service/AccObjectContainerEventListener.cxx
+++ b/winaccessibility/source/service/AccObjectContainerEventListener.cxx
@@ -52,7 +52,6 @@ void 
AccObjectContainerEventListener::HandleStateChangedEvent(Any oldValue, Any
         if (newV == AccessibleStateType::FOCUSED)
         {
             pAgent->UpdateAccName(m_xAccessible.get());
-            pAgent->UpdateDescription(m_xAccessible.get());
         }
     }
     AccContainerEventListener::HandleStateChangedEvent(oldValue, newValue);
diff --git a/winaccessibility/source/service/AccObjectManagerAgent.cxx 
b/winaccessibility/source/service/AccObjectManagerAgent.cxx
index 62d58f384f17..f28dd766b9e7 100644
--- a/winaccessibility/source/service/AccObjectManagerAgent.cxx
+++ b/winaccessibility/source/service/AccObjectManagerAgent.cxx
@@ -122,18 +122,6 @@ void  AccObjectManagerAgent::UpdateLocation( XAccessible* 
/* pXAcc */, long /*to
 #endif
 }
 
-/**
-   * Interface of updating MSAA name when UNO description_changed event occurs.
-   * @param pXAcc Uno XAccessible interface of control.
-   * @param newDesc New UNO accessible description.
-   * @return
-   */
-void  AccObjectManagerAgent::UpdateDescription( XAccessible* pXAcc, Any 
newDesc )
-{
-    if( pWinManager )
-        pWinManager->SetDescription( pXAcc, newDesc );
-}
-
 /**
    * When a new UNO XAccessible object is found by listener, we create a 
corresponding
    * com object and insert it to our manager list.
@@ -333,12 +321,6 @@ short AccObjectManagerAgent::GetParentRole( XAccessible* 
pXAcc )
     return -1;
 }
 
-void AccObjectManagerAgent::UpdateDescription( XAccessible* pXAcc )
-{
-    if(pWinManager)
-        pWinManager->UpdateDescription( pXAcc );
-}
-
 void AccObjectManagerAgent::UpdateChildState(XAccessible* pXAcc)
 {
     if(pWinManager)
diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx 
b/winaccessibility/source/service/AccObjectWinManager.cxx
index f180127acf65..69d8af6ee65a 100644
--- a/winaccessibility/source/service/AccObjectWinManager.cxx
+++ b/winaccessibility/source/service/AccObjectWinManager.cxx
@@ -924,13 +924,6 @@ void  AccObjectWinManager::UpdateAction( XAccessible* 
pXAcc )
         pAccObj->UpdateAction();
 }
 
-void AccObjectWinManager::UpdateDescription( XAccessible* pXAcc )
-{
-    AccObject* pAccObj = GetAccObjByXAcc( pXAcc );
-    if ( pAccObj )
-        pAccObj->UpdateDescription();
-}
-
 /**
    * Set corresponding com object's accessible location via XAccessible 
interface and new
    * location.
@@ -984,19 +977,6 @@ void  AccObjectWinManager::SetAccName( XAccessible* pXAcc, 
Any newName)
         pAccObj->SetName( newName );
 }
 
-/**
-   * Set corresponding com object's description via XAccessible interface and 
new description.
-   * @param pXAcc XAccessible interface.
-   * @param newDesc new description
-   * @return
-   */
-void  AccObjectWinManager::SetDescription( XAccessible* pXAcc, Any newDesc )
-{
-    AccObject* pAccObj = GetAccObjByXAcc( pXAcc );
-    if( pAccObj )
-        pAccObj->SetDescription( newDesc );
-}
-
 /**
    * Set corresponding com object's role via XAccessible interface and new 
role.
    * @param pXAcc XAccessible interface.
commit e9b6eedd66257decf7ac36b71b06e91609f1e02e
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Jan 5 12:23:23 2022 +0000
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Jan 6 10:09:55 2022 +0100

    wina11y: Use existing method to update description
    
    The accessible description and the accessibile *action*
    description are two different things.
    
    'AccObject::UpdateActionDesc' was (IMHO somewhat confusingly)
    handling both.
    Drop the handling of the accessible description from there
    and call the already existing 'AccObject::UpdateDescription'
    at the only call site of 'AccObject::UpdateActionDesc' in
    addition, which does exactly the same thing.
    
    Change-Id: I220df676f128a5db69ab4cebe7772d92f6b9b0ff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128005
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/winaccessibility/source/service/AccObject.cxx 
b/winaccessibility/source/service/AccObject.cxx
index b69507486e25..e9ca101207fe 100644
--- a/winaccessibility/source/service/AccObject.cxx
+++ b/winaccessibility/source/service/AccObject.cxx
@@ -747,12 +747,8 @@ AccObject* AccObject::NextChild()
 void AccObject::UpdateActionDesc()
 {
     if (!m_pIMAcc)
-    {
         return;
-    }
 
-    OUString pXString = m_xAccContextRef->getAccessibleDescription();
-    m_pIMAcc->Put_XAccDescription(o3tl::toW(pXString.getStr()));
     long Role = m_accRole;
 
     if(  Role == PUSH_BUTTON || Role == RADIO_BUTTON || Role == MENU_ITEM ||
@@ -1027,6 +1023,8 @@ bool AccObject:: UpdateAccessibleInfoFromUnoToMSAA ( )
 
     UpdateValue();
 
+    UpdateDescription();
+
     UpdateActionDesc();
 
     UpdateRole();

Reply via email to