diff options
Diffstat (limited to 'editeng/source/accessibility/AccessibleContextBase.cxx')
-rw-r--r-- | editeng/source/accessibility/AccessibleContextBase.cxx | 100 |
1 files changed, 40 insertions, 60 deletions
diff --git a/editeng/source/accessibility/AccessibleContextBase.cxx b/editeng/source/accessibility/AccessibleContextBase.cxx index ef09f28cde8c..df52b70e78a4 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> @@ -43,27 +42,26 @@ namespace accessibility { // internal AccessibleContextBase::AccessibleContextBase ( - const uno::Reference<XAccessible>& rxParent, + uno::Reference<XAccessible> xParent, const sal_Int16 aRole) : WeakComponentImplHelper(m_aMutex), - mxParent(rxParent), + mxParent(std::move(xParent)), meDescriptionOrigin(NotSet), meNameOrigin(NotSet), mnClientId(0), 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,14 +71,12 @@ AccessibleContextBase::~AccessibleContextBase() { } -bool AccessibleContextBase::SetState (sal_Int16 aState) +bool AccessibleContextBase::SetState (sal_Int64 aState) { ::osl::ClearableMutexGuard aGuard (m_aMutex); - ::utl::AccessibleStateSetHelper* pStateSet = - static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); - if ((pStateSet != nullptr) && !pStateSet->contains(aState)) + if (!(mnStateSet & aState)) { - pStateSet->AddState (aState); + mnStateSet |= aState; // Clear the mutex guard so that it is not locked during calls to // listeners. aGuard.clear(); @@ -93,7 +89,7 @@ bool AccessibleContextBase::SetState (sal_Int16 aState) CommitChange( AccessibleEventId::STATE_CHANGED, aNewValue, - uno::Any()); + uno::Any(), -1); } return true; } @@ -102,14 +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); - ::utl::AccessibleStateSetHelper* pStateSet = - static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); - if ((pStateSet != nullptr) && pStateSet->contains(aState)) + if (mnStateSet & aState) { - pStateSet->RemoveState (aState); + mnStateSet &= ~aState; // Clear the mutex guard so that it is not locked during calls to listeners. aGuard.clear(); @@ -118,7 +112,7 @@ bool AccessibleContextBase::ResetState (sal_Int16 aState) CommitChange( AccessibleEventId::STATE_CHANGED, uno::Any(), - aOldValue); + aOldValue, -1); return true; } else @@ -126,21 +120,15 @@ bool AccessibleContextBase::ResetState (sal_Int16 aState) } -bool AccessibleContextBase::GetState (sal_Int16 aState) +bool AccessibleContextBase::GetState (sal_Int64 aState) { ::osl::MutexGuard aGuard (m_aMutex); - ::utl::AccessibleStateSetHelper* pStateSet = - static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); - if (pStateSet != nullptr) - return pStateSet->contains(aState); - else - // If there is no state set then return false as a default value. - return false; + return mnStateSet & aState; } void AccessibleContextBase::SetRelationSet ( - const uno::Reference<XAccessibleRelationSet>& rxNewRelationSet) + const rtl::Reference<utl::AccessibleRelationSetHelper>& rxNewRelationSet) { // Try to emit some meaningful events indicating differing relations in // both sets. @@ -156,7 +144,7 @@ void AccessibleContextBase::SetRelationSet ( for (int i=0; aRelationDescriptors[i].first!=AccessibleRelationType::INVALID; i++) if (mxRelationSet->containsRelation(aRelationDescriptors[i].first) != rxNewRelationSet->containsRelation(aRelationDescriptors[i].first)) - CommitChange (aRelationDescriptors[i].second, uno::Any(), uno::Any()); + CommitChange (aRelationDescriptors[i].second, uno::Any(), uno::Any(), -1); mxRelationSet = rxNewRelationSet; } @@ -175,7 +163,7 @@ uno::Reference< XAccessibleContext> SAL_CALL /** No children. */ -sal_Int32 SAL_CALL +sal_Int64 SAL_CALL AccessibleContextBase::getAccessibleChildCount() { return 0; @@ -186,7 +174,7 @@ sal_Int32 SAL_CALL an exception for a wrong index. */ uno::Reference<XAccessible> SAL_CALL - AccessibleContextBase::getAccessibleChild (sal_Int32 nIndex) + AccessibleContextBase::getAccessibleChild (sal_Int64 nIndex) { ThrowIfDisposed (); throw lang::IndexOutOfBoundsException ( @@ -203,7 +191,7 @@ uno::Reference<XAccessible> SAL_CALL } -sal_Int32 SAL_CALL +sal_Int64 SAL_CALL AccessibleContextBase::getAccessibleIndexInParent() { ThrowIfDisposed (); @@ -219,8 +207,8 @@ sal_Int32 SAL_CALL mxParent->getAccessibleContext()); if (xParentContext.is()) { - sal_Int32 nChildCount = xParentContext->getAccessibleChildCount(); - for (sal_Int32 i=0; i<nChildCount; i++) + sal_Int64 nChildCount = xParentContext->getAccessibleChildCount(); + for (sal_Int64 i=0; i<nChildCount; i++) { uno::Reference<XAccessible> xChild (xParentContext->getAccessibleChild (i)); if (xChild.is()) @@ -280,12 +268,9 @@ uno::Reference<XAccessibleRelationSet> SAL_CALL ThrowIfDisposed (); // Create a copy of the relation set and return it. - ::utl::AccessibleRelationSetHelper* pRelationSet = - static_cast< ::utl::AccessibleRelationSetHelper*>(mxRelationSet.get()); - if (pRelationSet != nullptr) + if (mxRelationSet) { - return uno::Reference<XAccessibleRelationSet> ( - new ::utl::AccessibleRelationSetHelper (*pRelationSet)); + return new ::utl::AccessibleRelationSetHelper(*mxRelationSet); } else return uno::Reference<XAccessibleRelationSet>(nullptr); @@ -298,28 +283,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 = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); - - if (pStateSet != nullptr) - pStateSet = new ::utl::AccessibleStateSetHelper (*pStateSet); + return mnStateSet; } - - return pStateSet; } @@ -425,6 +401,8 @@ void SAL_CALL AccessibleContextBase::disposing() comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); mnClientId = 0; } + mxParent.clear(); + mxRelationSet.clear(); } @@ -446,7 +424,7 @@ void AccessibleContextBase::SetAccessibleDescription ( CommitChange( AccessibleEventId::DESCRIPTION_CHANGED, aNewValue, - aOldValue); + aOldValue, -1); } @@ -468,7 +446,7 @@ void AccessibleContextBase::SetAccessibleName ( CommitChange( AccessibleEventId::NAME_CHANGED, aNewValue, - aOldValue); + aOldValue, -1); } @@ -481,7 +459,8 @@ OUString AccessibleContextBase::CreateAccessibleName() void AccessibleContextBase::CommitChange ( sal_Int16 nEventId, const uno::Any& rNewValue, - const uno::Any& rOldValue) + const uno::Any& rOldValue, + sal_Int32 nValueIndex) { // Do not call FireEvent and do not even create the event object when no // listener has been registered yet. Creating the event object can @@ -492,7 +471,8 @@ void AccessibleContextBase::CommitChange ( static_cast<XAccessibleContext*>(this), nEventId, rNewValue, - rOldValue); + rOldValue, + nValueIndex); FireEvent (aEvent); } @@ -511,7 +491,7 @@ void AccessibleContextBase::ThrowIfDisposed() if (rBHelper.bDisposed || rBHelper.bInDispose) { throw lang::DisposedException ("object has been already disposed", - static_cast<uno::XWeak*>(this)); + getXWeak()); } } |