summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorArnaud Versini <arnaud.versini@libreoffice.org>2020-09-06 19:01:24 +0200
committerArnaud Versini <arnaud.versini@libreoffice.org>2020-09-07 11:20:09 +0200
commit54cbe9458033f50d9f608b1462d65e8514cbb636 (patch)
tree8e702ce9c6c40a0c5d9874fd96915e0a16728105 /unotools
parentac9c80ab08515ee2eab56293e24a5ed96ba06e5b (diff)
UNOTOOLS : simplify AccessibleStateSetHelper by not using an impl class
Change-Id: Iae7a028d2845d8b0bef2aefdce2ae00fa7f5660f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102110 Tested-by: Jenkins Reviewed-by: Arnaud Versini <arnaud.versini@libreoffice.org>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/accessibility/accessiblestatesethelper.cxx133
1 files changed, 37 insertions, 96 deletions
diff --git a/unotools/source/accessibility/accessiblestatesethelper.cxx b/unotools/source/accessibility/accessiblestatesethelper.cxx
index 9a180a4677ad..cec1f6bcd615 100644
--- a/unotools/source/accessibility/accessiblestatesethelper.cxx
+++ b/unotools/source/accessibility/accessiblestatesethelper.cxx
@@ -28,110 +28,32 @@ using namespace ::utl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::accessibility;
-class AccessibleStateSetHelperImpl
+namespace
{
-public:
- AccessibleStateSetHelperImpl();
- AccessibleStateSetHelperImpl(const AccessibleStateSetHelperImpl& rImpl);
-
- /// @throws uno::RuntimeException
- bool IsEmpty () const;
- /// @throws uno::RuntimeException
- bool Contains (sal_Int16 aState) const;
- /// @throws uno::RuntimeException
- uno::Sequence<sal_Int16> GetStates() const;
- /// @throws uno::RuntimeException
- void AddState(sal_Int16 aState);
- /// @throws uno::RuntimeException
- void RemoveState(sal_Int16 aState);
-
- inline void AddStates( const sal_Int64 _nStates );
-
-private:
- sal_uInt64 maStates;
-};
-
-AccessibleStateSetHelperImpl::AccessibleStateSetHelperImpl()
- : maStates(0)
-{
-}
-
-AccessibleStateSetHelperImpl::AccessibleStateSetHelperImpl(const AccessibleStateSetHelperImpl& rImpl)
- : maStates(rImpl.maStates)
-{
-}
-
-inline bool AccessibleStateSetHelperImpl::IsEmpty () const
-{
- return maStates == 0;
-}
-
-inline bool AccessibleStateSetHelperImpl::Contains (sal_Int16 aState) const
-{
- DBG_ASSERT(aState < BITFIELDSIZE, "the statesset is too small");
- sal_uInt64 aTempBitSet(1);
- aTempBitSet <<= aState;
- return ((aTempBitSet & maStates) != 0);
-}
-
-inline uno::Sequence<sal_Int16> AccessibleStateSetHelperImpl::GetStates() const
-{
- uno::Sequence<sal_Int16> aRet(BITFIELDSIZE);
- sal_Int16* pSeq = aRet.getArray();
- sal_Int16 nStateCount(0);
- for (sal_Int16 i = 0; i < BITFIELDSIZE; ++i)
- if (Contains(i))
- {
- *pSeq = i;
- ++pSeq;
- ++nStateCount;
- }
- aRet.realloc(nStateCount);
- return aRet;
-}
-
-inline void AccessibleStateSetHelperImpl::AddStates( const sal_Int64 _nStates )
-{
- maStates |= _nStates;
+ bool lcl_contains(sal_uInt64 aStates, sal_uInt64 aState)
+ {
+ DBG_ASSERT(aState < BITFIELDSIZE, "the statesset is too small");
+ sal_uInt64 aTempBitSet(1);
+ aTempBitSet <<= aState;
+ return ((aTempBitSet & aStates) != 0);
+ }
}
-
-inline void AccessibleStateSetHelperImpl::AddState(sal_Int16 aState)
-{
- DBG_ASSERT(aState < BITFIELDSIZE, "the statesset is too small");
- sal_uInt64 aTempBitSet(1);
- aTempBitSet <<= aState;
- maStates |= aTempBitSet;
-}
-
-inline void AccessibleStateSetHelperImpl::RemoveState(sal_Int16 aState)
-{
- DBG_ASSERT(aState < BITFIELDSIZE, "the statesset is too small");
- sal_uInt64 aTempBitSet(1);
- aTempBitSet <<= aState;
- aTempBitSet = ~aTempBitSet;
- maStates &= aTempBitSet;
-}
-
//===== internal ============================================================
AccessibleStateSetHelper::AccessibleStateSetHelper ()
- : mpHelperImpl(new AccessibleStateSetHelperImpl)
+ : maStates(0)
{
}
AccessibleStateSetHelper::AccessibleStateSetHelper ( const sal_Int64 _nInitialStates )
- : mpHelperImpl(new AccessibleStateSetHelperImpl)
+ : maStates(_nInitialStates)
{
- mpHelperImpl->AddStates( _nInitialStates );
}
AccessibleStateSetHelper::AccessibleStateSetHelper (const AccessibleStateSetHelper& rHelper)
- : cppu::WeakImplHelper<XAccessibleStateSet>(rHelper)
+ : cppu::WeakImplHelper<XAccessibleStateSet>(rHelper),
+ maStates(rHelper.maStates)
{
- if (rHelper.mpHelperImpl)
- mpHelperImpl.reset(new AccessibleStateSetHelperImpl(*rHelper.mpHelperImpl));
- else
- mpHelperImpl.reset(new AccessibleStateSetHelperImpl());
}
AccessibleStateSetHelper::~AccessibleStateSetHelper()
@@ -149,7 +71,7 @@ AccessibleStateSetHelper::~AccessibleStateSetHelper()
sal_Bool SAL_CALL AccessibleStateSetHelper::isEmpty ()
{
osl::MutexGuard aGuard (maMutex);
- return mpHelperImpl->IsEmpty();
+ return maStates == 0;
}
/** Checks if the given state is a member of the state set of this
@@ -166,7 +88,8 @@ sal_Bool SAL_CALL AccessibleStateSetHelper::isEmpty ()
sal_Bool SAL_CALL AccessibleStateSetHelper::contains (sal_Int16 aState)
{
osl::MutexGuard aGuard (maMutex);
- return mpHelperImpl->Contains(aState);
+
+ return lcl_contains(maStates, aState);
}
/** Checks if all of the given states are in this object's state
@@ -189,25 +112,43 @@ sal_Bool SAL_CALL AccessibleStateSetHelper::containsAll
{
osl::MutexGuard aGuard (maMutex);
return std::all_of(rStateSet.begin(), rStateSet.end(),
- [this](const sal_Int16 nState) { return mpHelperImpl->Contains(nState); });
+ [this](const sal_Int16 nState) { return lcl_contains(maStates, nState); });
}
uno::Sequence<sal_Int16> SAL_CALL AccessibleStateSetHelper::getStates()
{
osl::MutexGuard aGuard(maMutex);
- return mpHelperImpl->GetStates();
+ uno::Sequence<sal_Int16> aRet(BITFIELDSIZE);
+ sal_Int16* pSeq = aRet.getArray();
+ sal_Int16 nStateCount(0);
+ for (sal_Int16 i = 0; i < BITFIELDSIZE; ++i)
+ if (lcl_contains(maStates, i))
+ {
+ *pSeq = i;
+ ++pSeq;
+ ++nStateCount;
+ }
+ aRet.realloc(nStateCount);
+ return aRet;
}
void AccessibleStateSetHelper::AddState(sal_Int16 aState)
{
osl::MutexGuard aGuard (maMutex);
- mpHelperImpl->AddState(aState);
+ DBG_ASSERT(aState < BITFIELDSIZE, "the statesset is too small");
+ sal_uInt64 aTempBitSet(1);
+ aTempBitSet <<= aState;
+ maStates |= aTempBitSet;
}
void AccessibleStateSetHelper::RemoveState(sal_Int16 aState)
{
osl::MutexGuard aGuard (maMutex);
- mpHelperImpl->RemoveState(aState);
+ DBG_ASSERT(aState < BITFIELDSIZE, "the statesset is too small");
+ sal_uInt64 aTempBitSet(1);
+ aTempBitSet <<= aState;
+ aTempBitSet = ~aTempBitSet;
+ maStates &= aTempBitSet;
}
//===== XTypeProvider =======================================================