diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-07-03 20:29:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-07-08 10:10:11 +0200 |
commit | 8d8e6c84e512c1a8b33aac75965b84481d1a1d13 (patch) | |
tree | 9ed209d057081d4283eb44b51c0d9af18f976eab /editeng/source/accessibility | |
parent | 911ac42485b690df5cbbff6e3c04b111c1723aca (diff) |
[API CHANGE] Drop css::accessibility::XAccessibleStateSet
which is internal API, unused (as far as I can tell) by external
users.
This state is purely a bitset
(as implemented by utl::AccessibleStateSetHelper)
so we can just return it as a 64-bit value.
This shaves significant time off the performance profiles
of code that loads very complex shapes, because this state
is frequently used, and we no longer need to allocate a return
value on the heap for every call.
Change-Id: Icf1b3bd367c256646ae9015f9127025f59459c2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136786
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng/source/accessibility')
5 files changed, 72 insertions, 102 deletions
diff --git a/editeng/source/accessibility/AccessibleContextBase.cxx b/editeng/source/accessibility/AccessibleContextBase.cxx index 4cd16d735386..b54509a3e845 100644 --- a/editeng/source/accessibility/AccessibleContextBase.cxx +++ b/editeng/source/accessibility/AccessibleContextBase.cxx @@ -26,7 +26,6 @@ #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp> -#include <unotools/accessiblestatesethelper.hxx> #include <unotools/accessiblerelationsethelper.hxx> #include <comphelper/accessibleeventnotifier.hxx> #include <cppuhelper/supportsservice.hxx> @@ -53,17 +52,16 @@ AccessibleContextBase::AccessibleContextBase ( maRole(aRole) { // Create the state set. - rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet = new ::utl::AccessibleStateSetHelper (); - mxStateSet = pStateSet; + mnStateSet = 0; // Set some states. Don't use the SetState method because no events // shall be broadcasted (that is not yet initialized anyway). - pStateSet->AddState (AccessibleStateType::ENABLED); - pStateSet->AddState (AccessibleStateType::SENSITIVE); - pStateSet->AddState (AccessibleStateType::SHOWING); - pStateSet->AddState (AccessibleStateType::VISIBLE); - pStateSet->AddState (AccessibleStateType::FOCUSABLE); - pStateSet->AddState (AccessibleStateType::SELECTABLE); + mnStateSet |= AccessibleStateType::ENABLED; + mnStateSet |= AccessibleStateType::SENSITIVE; + mnStateSet |= AccessibleStateType::SHOWING; + mnStateSet |= AccessibleStateType::VISIBLE; + mnStateSet |= AccessibleStateType::FOCUSABLE; + mnStateSet |= AccessibleStateType::SELECTABLE; // Create the relation set. mxRelationSet = new ::utl::AccessibleRelationSetHelper (); @@ -73,12 +71,12 @@ AccessibleContextBase::~AccessibleContextBase() { } -bool AccessibleContextBase::SetState (sal_Int16 aState) +bool AccessibleContextBase::SetState (sal_Int64 aState) { ::osl::ClearableMutexGuard aGuard (m_aMutex); - if ((mxStateSet != nullptr) && !mxStateSet->contains(aState)) + if (!(mnStateSet & aState)) { - mxStateSet->AddState (aState); + mnStateSet |= aState; // Clear the mutex guard so that it is not locked during calls to // listeners. aGuard.clear(); @@ -100,12 +98,12 @@ bool AccessibleContextBase::SetState (sal_Int16 aState) } -bool AccessibleContextBase::ResetState (sal_Int16 aState) +bool AccessibleContextBase::ResetState (sal_Int64 aState) { ::osl::ClearableMutexGuard aGuard (m_aMutex); - if ((mxStateSet != nullptr) && mxStateSet->contains(aState)) + if (mnStateSet & aState) { - mxStateSet->RemoveState (aState); + mnStateSet &= ~aState; // Clear the mutex guard so that it is not locked during calls to listeners. aGuard.clear(); @@ -122,14 +120,10 @@ bool AccessibleContextBase::ResetState (sal_Int16 aState) } -bool AccessibleContextBase::GetState (sal_Int16 aState) +bool AccessibleContextBase::GetState (sal_Int64 aState) { ::osl::MutexGuard aGuard (m_aMutex); - if (mxStateSet != nullptr) - return mxStateSet->contains(aState); - else - // If there is no state set then return false as a default value. - return false; + return mnStateSet & aState; } @@ -292,28 +286,19 @@ uno::Reference<XAccessibleRelationSet> SAL_CALL SHOWING VISIBLE */ -uno::Reference<XAccessibleStateSet> SAL_CALL +sal_Int64 SAL_CALL AccessibleContextBase::getAccessibleStateSet() { - rtl::Reference<::utl::AccessibleStateSetHelper> pStateSet; - if (rBHelper.bDisposed) { // We are already disposed! // Create a new state set that has only set the DEFUNC state. - pStateSet = new ::utl::AccessibleStateSetHelper (); - pStateSet->AddState (AccessibleStateType::DEFUNC); + return AccessibleStateType::DEFUNC; } else { - // Create a copy of the state set and return it. - pStateSet = mxStateSet; - - if (pStateSet != nullptr) - pStateSet = new ::utl::AccessibleStateSetHelper (*pStateSet); + return mnStateSet; } - - return pStateSet; } diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index c6c6520cc545..df32457ecd5c 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -42,7 +42,6 @@ #include <comphelper/accessibleeventnotifier.hxx> #include <comphelper/sequenceashashmap.hxx> #include <cppuhelper/supportsservice.hxx> -#include <unotools/accessiblestatesethelper.hxx> #include <unotools/accessiblerelationsethelper.hxx> #include <com/sun/star/accessibility/AccessibleRelationType.hpp> #include <vcl/unohelp.hxx> @@ -120,22 +119,16 @@ namespace accessibility mpParaManager( _pParaManager ) { - try - { - // Create the state set. - mxStateSet = new ::utl::AccessibleStateSetHelper (); + // Create the state set. + mnStateSet = 0; - // these are always on - mxStateSet->AddState( AccessibleStateType::MULTI_LINE ); - mxStateSet->AddState( AccessibleStateType::FOCUSABLE ); - mxStateSet->AddState( AccessibleStateType::VISIBLE ); - mxStateSet->AddState( AccessibleStateType::SHOWING ); - mxStateSet->AddState( AccessibleStateType::ENABLED ); - mxStateSet->AddState( AccessibleStateType::SENSITIVE ); - } - catch (const uno::Exception&) - { - } + // these are always on + mnStateSet |= AccessibleStateType::MULTI_LINE; + mnStateSet |= AccessibleStateType::FOCUSABLE; + mnStateSet |= AccessibleStateType::VISIBLE; + mnStateSet |= AccessibleStateType::SHOWING; + mnStateSet |= AccessibleStateType::ENABLED; + mnStateSet |= AccessibleStateType::SENSITIVE; } AccessibleEditableTextPara::~AccessibleEditableTextPara() @@ -567,22 +560,20 @@ namespace accessibility aEvent ); } - void AccessibleEditableTextPara::SetState( const sal_Int16 nStateId ) + void AccessibleEditableTextPara::SetState( const sal_Int64 nStateId ) { - if( mxStateSet != nullptr && - !mxStateSet->contains(nStateId) ) + if( !(mnStateSet & nStateId) ) { - mxStateSet->AddState( nStateId ); + mnStateSet |= nStateId; FireEvent( AccessibleEventId::STATE_CHANGED, uno::Any( nStateId ) ); } } - void AccessibleEditableTextPara::UnSetState( const sal_Int16 nStateId ) + void AccessibleEditableTextPara::UnSetState( const sal_Int64 nStateId ) { - if( mxStateSet != nullptr && - mxStateSet->contains(nStateId) ) + if( mnStateSet & nStateId ) { - mxStateSet->RemoveState( nStateId ); + mnStateSet &= ~nStateId; FireEvent( AccessibleEventId::STATE_CHANGED, uno::Any(), uno::Any( nStateId ) ); } } @@ -930,25 +921,23 @@ namespace accessibility return OUString(); } - uno::Reference< XAccessibleStateSet > SAL_CALL AccessibleEditableTextPara::getAccessibleStateSet() + sal_Int64 SAL_CALL AccessibleEditableTextPara::getAccessibleStateSet() { SolarMutexGuard aGuard; // Create a copy of the state set and return it. - if( !mxStateSet ) - return uno::Reference<XAccessibleStateSet>(); - uno::Reference<XAccessibleStateSet> xParentStates; + sal_Int64 nParentStates = 0; if (getAccessibleParent().is()) { uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); - xParentStates = xParentContext->getAccessibleStateSet(); + nParentStates = xParentContext->getAccessibleStateSet(); } - if (xParentStates.is() && xParentStates->contains(AccessibleStateType::EDITABLE) ) + if (nParentStates & AccessibleStateType::EDITABLE) { - mxStateSet->AddState(AccessibleStateType::EDITABLE); + mnStateSet |= AccessibleStateType::EDITABLE; } - return uno::Reference<XAccessibleStateSet>( new ::utl::AccessibleStateSetHelper (*mxStateSet) ); + return mnStateSet; } lang::Locale SAL_CALL AccessibleEditableTextPara::getLocale() diff --git a/editeng/source/accessibility/AccessibleImageBullet.cxx b/editeng/source/accessibility/AccessibleImageBullet.cxx index da157b919eb7..8a9f58b7fa75 100644 --- a/editeng/source/accessibility/AccessibleImageBullet.cxx +++ b/editeng/source/accessibility/AccessibleImageBullet.cxx @@ -31,7 +31,6 @@ #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <comphelper/accessibleeventnotifier.hxx> #include <cppuhelper/supportsservice.hxx> -#include <unotools/accessiblestatesethelper.hxx> #include <i18nlangtag/languagetag.hxx> #include <editeng/AccessibleEditableTextPara.hxx> #include <editeng/eerdll.hxx> @@ -66,13 +65,13 @@ namespace accessibility try { // Create the state set. - mxStateSet = new ::utl::AccessibleStateSetHelper (); + mnStateSet = 0; // these are always on - mxStateSet->AddState( AccessibleStateType::VISIBLE ); - mxStateSet->AddState( AccessibleStateType::SHOWING ); - mxStateSet->AddState( AccessibleStateType::ENABLED ); - mxStateSet->AddState( AccessibleStateType::SENSITIVE ); + mnStateSet |= AccessibleStateType::VISIBLE; + mnStateSet |= AccessibleStateType::SHOWING; + mnStateSet |= AccessibleStateType::ENABLED; + mnStateSet |= AccessibleStateType::SENSITIVE; } catch( const uno::Exception& ) {} } @@ -148,17 +147,13 @@ namespace accessibility return uno::Reference< XAccessibleRelationSet >(); } - uno::Reference< XAccessibleStateSet > SAL_CALL AccessibleImageBullet::getAccessibleStateSet() + sal_Int64 SAL_CALL AccessibleImageBullet::getAccessibleStateSet() { - SolarMutexGuard aGuard; // Create a copy of the state set and return it. - if( !mxStateSet ) - return uno::Reference<XAccessibleStateSet>(); - - return uno::Reference<XAccessibleStateSet>( new ::utl::AccessibleStateSetHelper (*mxStateSet) ); + return mnStateSet; } lang::Locale SAL_CALL AccessibleImageBullet::getLocale() @@ -420,22 +415,20 @@ namespace accessibility aEvent ); } - void AccessibleImageBullet::SetState( const sal_Int16 nStateId ) + void AccessibleImageBullet::SetState( const sal_Int64 nStateId ) { - if( mxStateSet != nullptr && - !mxStateSet->contains(nStateId) ) + if( !(mnStateSet & nStateId) ) { - mxStateSet->AddState( nStateId ); + mnStateSet |= nStateId; FireEvent( AccessibleEventId::STATE_CHANGED, uno::Any( nStateId ) ); } } - void AccessibleImageBullet::UnSetState( const sal_Int16 nStateId ) + void AccessibleImageBullet::UnSetState( const sal_Int64 nStateId ) { - if( mxStateSet != nullptr && - mxStateSet->contains(nStateId) ) + if( mnStateSet & nStateId ) { - mxStateSet->RemoveState( nStateId ); + mnStateSet &= ~nStateId; FireEvent( AccessibleEventId::STATE_CHANGED, uno::Any(), uno::Any( nStateId ) ); } } diff --git a/editeng/source/accessibility/AccessibleImageBullet.hxx b/editeng/source/accessibility/AccessibleImageBullet.hxx index 85f1011fbe7c..52a48dbd0ddb 100644 --- a/editeng/source/accessibility/AccessibleImageBullet.hxx +++ b/editeng/source/accessibility/AccessibleImageBullet.hxx @@ -33,7 +33,6 @@ class SvxEditSource; class SvxTextForwarder; class SvxViewForwarder; -namespace utl { class AccessibleStateSetHelper; } namespace accessibility { @@ -66,7 +65,7 @@ namespace accessibility virtual OUString SAL_CALL getAccessibleDescription() override; virtual OUString SAL_CALL getAccessibleName() override; virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override; - virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet() override; virtual css::lang::Locale SAL_CALL getLocale() override; // XAccessibleEventBroadcaster @@ -148,8 +147,8 @@ namespace accessibility AccessibleImageBullet& operator= ( const AccessibleImageBullet& ) = delete; // maintain state set and send STATE_CHANGE events - void SetState( const sal_Int16 nStateId ); - void UnSetState( const sal_Int16 nStateId ); + void SetState( const sal_Int64 nStateId ); + void UnSetState( const sal_Int64 nStateId ); SvxEditSource& GetEditSource() const; @@ -188,7 +187,7 @@ namespace accessibility Point maEEOffset; // the current state set (updated from SetState/UnSetState and guarded by solar mutex) - rtl::Reference< utl::AccessibleStateSetHelper > mxStateSet; + sal_Int64 mnStateSet = 0; /// The shape we're the accessible for (unguarded) css::uno::Reference< css::accessibility::XAccessible > mxParent; diff --git a/editeng/source/accessibility/AccessibleParaManager.cxx b/editeng/source/accessibility/AccessibleParaManager.cxx index f597bba6adce..7fd82781168e 100644 --- a/editeng/source/accessibility/AccessibleParaManager.cxx +++ b/editeng/source/accessibility/AccessibleParaManager.cxx @@ -56,9 +56,9 @@ namespace accessibility // owner is responsible for possible child death } - void AccessibleParaManager::SetAdditionalChildStates( VectorOfStates&& rChildStates ) + void AccessibleParaManager::SetAdditionalChildStates( sal_Int64 nChildStates ) { - maChildStates = std::move(rChildStates); + mnChildStates = nChildStates; } void AccessibleParaManager::SetNum( sal_Int32 nNumParas ) @@ -243,35 +243,39 @@ namespace accessibility rChild.SetState( AccessibleStateType::FOCUSED ); // add states passed from outside - for( const auto& rState : maChildStates ) - rChild.SetState( rState ); + for (int i=0; i<63; i++) + { + sal_Int64 nState = sal_Int64(1) << i; + if ( nState & mnChildStates ) + rChild.SetState( nState ); + } } - void AccessibleParaManager::SetState( sal_Int32 nChild, const sal_Int16 nStateId ) + void AccessibleParaManager::SetState( sal_Int32 nChild, const sal_Int64 nStateId ) { - MemFunAdapter< const sal_Int16 > aFunc( &AccessibleEditableTextPara::SetState, + MemFunAdapter< const sal_Int64 > aFunc( &AccessibleEditableTextPara::SetState, nStateId ); aFunc( GetChild(nChild) ); } - void AccessibleParaManager::SetState( const sal_Int16 nStateId ) + void AccessibleParaManager::SetState( const sal_Int64 nStateId ) { std::for_each( begin(), end(), - MemFunAdapter< const sal_Int16 >( &AccessibleEditableTextPara::SetState, + MemFunAdapter< const sal_Int64 >( &AccessibleEditableTextPara::SetState, nStateId ) ); } - void AccessibleParaManager::UnSetState( sal_Int32 nChild, const sal_Int16 nStateId ) + void AccessibleParaManager::UnSetState( sal_Int32 nChild, const sal_Int64 nStateId ) { - MemFunAdapter< const sal_Int16 > aFunc( &AccessibleEditableTextPara::UnSetState, + MemFunAdapter< const sal_Int64 > aFunc( &AccessibleEditableTextPara::UnSetState, nStateId ); aFunc( GetChild(nChild) ); } - void AccessibleParaManager::UnSetState( const sal_Int16 nStateId ) + void AccessibleParaManager::UnSetState( const sal_Int64 nStateId ) { std::for_each( begin(), end(), - MemFunAdapter< const sal_Int16 >( &AccessibleEditableTextPara::UnSetState, + MemFunAdapter< const sal_Int64 >( &AccessibleEditableTextPara::UnSetState, nStateId ) ); } |