summaryrefslogtreecommitdiffstats
path: root/accessibility/source/extended/accessiblelistboxentry.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'accessibility/source/extended/accessiblelistboxentry.cxx')
-rw-r--r--accessibility/source/extended/accessiblelistboxentry.cxx241
1 files changed, 113 insertions, 128 deletions
diff --git a/accessibility/source/extended/accessiblelistboxentry.cxx b/accessibility/source/extended/accessiblelistboxentry.cxx
index be1d98650324..6c8fa6fc26dc 100644
--- a/accessibility/source/extended/accessiblelistboxentry.cxx
+++ b/accessibility/source/extended/accessiblelistboxentry.cxx
@@ -23,6 +23,7 @@
#include <svtools/stringtransfer.hxx>
#include <vcl/toolkit/svlbitm.hxx>
#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
@@ -31,27 +32,12 @@
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
#include <toolkit/helper/convert.hxx>
-#include <unotools/accessiblestatesethelper.hxx>
#include <unotools/accessiblerelationsethelper.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/accessibleeventnotifier.hxx>
#include <helper/accresmgr.hxx>
#include <strings.hrc>
-#define ACCESSIBLE_ACTION_COUNT 1
-
-namespace
-{
- /// @throws css::lang::IndexOutOfBoundsException
- void checkActionIndex_Impl( sal_Int32 _nIndex )
- {
- if ( _nIndex < 0 || _nIndex >= ACCESSIBLE_ACTION_COUNT )
- // only three actions
- throw css::lang::IndexOutOfBoundsException();
- }
-}
-
-
namespace accessibility
{
// class AccessibleListBoxEntry -----------------------------------------------------
@@ -74,7 +60,6 @@ namespace accessibility
, m_pSvLBoxEntry(&rEntry)
, m_nClientId( 0 )
, m_wListBox(&rListBox)
- , m_rListBox(rListBox)
{
m_pTreeListBox->AddEventListener( LINK( this, AccessibleListBoxEntry, WindowEventListener ) );
_rListBox.FillEntryPath( m_pSvLBoxEntry, m_aEntryPath );
@@ -100,6 +85,22 @@ namespace accessibility
switch ( rEvent.GetId() )
{
+ case VclEventId::CheckboxToggle:
+ {
+ // assert this object is represented as a checkbox on a11y layer (LABEL role is used for
+ // SvButtonState::Tristate, s. AccessibleListBoxEntry::getAccessibleRole)
+ assert(getAccessibleRole() == AccessibleRole::CHECK_BOX
+ || getAccessibleRole() == AccessibleRole::LABEL);
+ Any aOldValue;
+ Any aNewValue;
+ if (getAccessibleStateSet() & AccessibleStateType::CHECKED)
+ aNewValue <<= AccessibleStateType::CHECKED;
+ else
+ aOldValue <<= AccessibleStateType::CHECKED;
+
+ NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue);
+ break;
+ }
case VclEventId::ObjectDying :
{
if ( m_pTreeListBox )
@@ -117,7 +118,7 @@ namespace accessibility
const css::uno::Any& _aNewValue )
{
Reference< uno::XInterface > xSource( *this );
- AccessibleEventObject aEventObj( xSource, _nEventId, _aNewValue, _aOldValue );
+ AccessibleEventObject aEventObj( xSource, _nEventId, _aNewValue, _aOldValue, -1 );
if (m_nClientId)
comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEventObj );
@@ -152,7 +153,7 @@ namespace accessibility
{
aRect = m_pTreeListBox->GetBoundingRect( pEntry );
Point aTopLeft = aRect.TopLeft();
- aTopLeft += m_pTreeListBox->GetWindowExtentsRelative( nullptr ).TopLeft();
+ aTopLeft += Point(m_pTreeListBox->GetWindowExtentsAbsolute().TopLeft());
aRect = tools::Rectangle( aTopLeft, aRect.GetSize() );
}
@@ -199,6 +200,12 @@ namespace accessibility
return GetBoundingBoxOnScreen_Impl();
}
+ void AccessibleListBoxEntry::CheckActionIndex(sal_Int32 nIndex)
+ {
+ if (nIndex < 0 || nIndex >= getAccessibleActionCount())
+ throw css::lang::IndexOutOfBoundsException();
+ }
+
void AccessibleListBoxEntry::EnsureIsAlive() const
{
if ( !IsAlive_Impl() )
@@ -207,11 +214,10 @@ namespace accessibility
OUString AccessibleListBoxEntry::implGetText()
{
- OUString sRet;
SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
- if ( pEntry )
- sRet = SvTreeListBox::SearchEntryTextWithHeadTitle( pEntry );
- return sRet;
+ if (pEntry)
+ return SvTreeListBox::SearchEntryTextWithHeadTitle(pEntry);
+ return OUString();
}
Locale AccessibleListBoxEntry::implGetLocale()
@@ -225,8 +231,6 @@ namespace accessibility
}
// XTypeProvider
-
-
Sequence< sal_Int8 > AccessibleListBoxEntry::getImplementationId()
{
return css::uno::Sequence<sal_Int8>();
@@ -262,14 +266,14 @@ namespace accessibility
OUString SAL_CALL AccessibleListBoxEntry::getImplementationName()
{
- return "com.sun.star.comp.svtools.AccessibleTreeListBoxEntry";
+ return u"com.sun.star.comp.svtools.AccessibleTreeListBoxEntry"_ustr;
}
Sequence< OUString > SAL_CALL AccessibleListBoxEntry::getSupportedServiceNames()
{
- return {"com.sun.star.accessibility.AccessibleContext",
- "com.sun.star.accessibility.AccessibleComponent",
- "com.sun.star.awt.AccessibleTreeListBoxEntry"};
+ return {u"com.sun.star.accessibility.AccessibleContext"_ustr,
+ u"com.sun.star.accessibility.AccessibleComponent"_ustr,
+ u"com.sun.star.awt.AccessibleTreeListBoxEntry"_ustr};
}
sal_Bool SAL_CALL AccessibleListBoxEntry::supportsService( const OUString& _rServiceName )
@@ -287,7 +291,7 @@ namespace accessibility
// XAccessibleContext
- sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleChildCount( )
+ sal_Int64 SAL_CALL AccessibleListBoxEntry::getAccessibleChildCount( )
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( m_aMutex );
@@ -301,7 +305,7 @@ namespace accessibility
return nCount;
}
- Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleChild( sal_Int32 i )
+ Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleChild( sal_Int64 i )
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( m_aMutex );
@@ -311,45 +315,39 @@ namespace accessibility
if ( !pEntry )
throw IndexOutOfBoundsException();
- uno::Reference<XAccessible> xListBox(m_wListBox);
+ rtl::Reference<AccessibleListBox> xListBox(m_wListBox);
assert(xListBox.is());
- return m_rListBox.implGetAccessible(*pEntry);
+ return xListBox->implGetAccessible(*pEntry);
}
Reference< XAccessible > AccessibleListBoxEntry::implGetParentAccessible( ) const
{
Reference< XAccessible > xParent;
- if ( !xParent.is() )
- {
- OSL_ENSURE( m_aEntryPath.size(), "AccessibleListBoxEntry::getAccessibleParent: invalid path!" );
- if ( m_aEntryPath.size() == 1 )
- { // we're a top level entry
- // -> our parent is the tree listbox itself
- if ( m_pTreeListBox )
- xParent = m_pTreeListBox->GetAccessible( );
- }
- else
- { // we have an entry as parent -> get its accessible
-
- // shorten our access path by one
- std::deque< sal_Int32 > aParentPath( m_aEntryPath );
- aParentPath.pop_back();
-
- // get the entry for this shortened access path
- SvTreeListEntry* pParentEntry = m_pTreeListBox->GetEntryFromPath( aParentPath );
- OSL_ENSURE( pParentEntry, "AccessibleListBoxEntry::implGetParentAccessible: could not obtain a parent entry!" );
-
- if ( pParentEntry )
- pParentEntry = m_pTreeListBox->GetParent(pParentEntry);
- if ( pParentEntry )
- {
- uno::Reference<XAccessible> xListBox(m_wListBox);
- assert(xListBox.is());
- return m_rListBox.implGetAccessible(*pParentEntry);
- // the AccessibleListBoxEntry class will create its parent
- // when needed
- }
+ assert( m_aEntryPath.size() ); // invalid path
+ if ( m_aEntryPath.size() == 1 )
+ { // we're a top level entry
+ // -> our parent is the tree listbox itself
+ if ( m_pTreeListBox )
+ xParent = m_pTreeListBox->GetAccessible( );
+ }
+ else
+ { // we have an entry as parent -> get its accessible
+
+ // shorten our access path by one
+ std::deque< sal_Int32 > aParentPath( m_aEntryPath );
+ aParentPath.pop_back();
+
+ // get the entry for this shortened access path
+ SvTreeListEntry* pParentEntry = m_pTreeListBox->GetEntryFromPath( aParentPath );
+ assert(pParentEntry && "AccessibleListBoxEntry::implGetParentAccessible: could not obtain a parent entry!");
+ if ( pParentEntry )
+ {
+ rtl::Reference<AccessibleListBox> xListBox(m_wListBox);
+ assert(xListBox.is());
+ return xListBox->implGetAccessible(*pParentEntry);
+ // the AccessibleListBoxEntry class will create its parent
+ // when needed
}
}
@@ -366,7 +364,7 @@ namespace accessibility
return implGetParentAccessible( );
}
- sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleIndexInParent( )
+ sal_Int64 SAL_CALL AccessibleListBoxEntry::getAccessibleIndexInParent( )
{
::osl::MutexGuard aGuard( m_aMutex );
@@ -439,33 +437,12 @@ namespace accessibility
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( m_aMutex );
- SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
if( getAccessibleRole() == AccessibleRole::TREE_ITEM )
{
return OUString();
}
- //want to count the real column number in the list box.
- sal_uInt16 iRealItemCount = 0;
- sal_uInt16 iCount = 0;
- sal_uInt16 iTotleItemCount = pEntry->ItemCount();
- while( iCount < iTotleItemCount )
- {
- const SvLBoxItem& rItem = pEntry->GetItem( iCount );
- if ( rItem.GetType() == SvLBoxItemType::String &&
- !static_cast<const SvLBoxString&>( rItem ).GetText().isEmpty() )
- {
- iRealItemCount++;
- }
- iCount++;
- }
- if(iRealItemCount<=1 )
- {
- return OUString();
- }
- else
- {
- return SvTreeListBox::SearchEntryTextWithHeadTitle( pEntry );
- }
+ return m_pTreeListBox->GetEntryAccessibleDescription(
+ m_pTreeListBox->GetEntryFromPath(m_aEntryPath));
}
OUString SAL_CALL AccessibleListBoxEntry::getAccessibleName( )
@@ -494,41 +471,41 @@ namespace accessibility
return xRelSet;
}
- Reference< XAccessibleStateSet > SAL_CALL AccessibleListBoxEntry::getAccessibleStateSet( )
+ sal_Int64 SAL_CALL AccessibleListBoxEntry::getAccessibleStateSet( )
{
::osl::MutexGuard aGuard( m_aMutex );
- rtl::Reference<utl::AccessibleStateSetHelper> pStateSetHelper = new utl::AccessibleStateSetHelper;
+ sal_Int64 nStateSet = 0;
if ( IsAlive_Impl() )
{
switch(getAccessibleRole())
{
case AccessibleRole::LABEL:
- pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
- pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
- pStateSetHelper->AddState( AccessibleStateType::ENABLED );
+ nStateSet |= AccessibleStateType::TRANSIENT;
+ nStateSet |= AccessibleStateType::SELECTABLE;
+ nStateSet |= AccessibleStateType::ENABLED;
if (m_pTreeListBox->IsInplaceEditingEnabled())
- pStateSetHelper->AddState( AccessibleStateType::EDITABLE );
+ nStateSet |= AccessibleStateType::EDITABLE;
if (IsShowing_Impl())
- pStateSetHelper->AddState( AccessibleStateType::SHOWING );
+ nStateSet |= AccessibleStateType::SHOWING;
break;
case AccessibleRole::CHECK_BOX:
- pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
- pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
- pStateSetHelper->AddState( AccessibleStateType::ENABLED );
+ nStateSet |= AccessibleStateType::TRANSIENT;
+ nStateSet |= AccessibleStateType::SELECTABLE;
+ nStateSet |= AccessibleStateType::ENABLED;
if (IsShowing_Impl())
- pStateSetHelper->AddState( AccessibleStateType::SHOWING );
+ nStateSet |= AccessibleStateType::SHOWING;
break;
}
SvTreeListEntry *pEntry = m_pTreeListBox->GetEntryFromPath(m_aEntryPath);
if (pEntry)
- m_pTreeListBox->FillAccessibleEntryStateSet(pEntry, *pStateSetHelper);
+ m_pTreeListBox->FillAccessibleEntryStateSet(pEntry, nStateSet);
}
else
- pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
+ nStateSet |= AccessibleStateType::DEFUNC;
- return pStateSetHelper;
+ return nStateSet;
}
Locale SAL_CALL AccessibleListBoxEntry::getLocale( )
@@ -554,12 +531,12 @@ namespace accessibility
EnsureIsAlive();
SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry( VCLPoint( _aPoint ) );
if ( !pEntry )
- throw RuntimeException();
+ throw RuntimeException("AccessibleListBoxEntry::getAccessibleAtPoint - pEntry cannot be empty!");
Reference< XAccessible > xAcc;
- uno::Reference<XAccessible> xListBox(m_wListBox);
+ rtl::Reference<AccessibleListBox> xListBox(m_wListBox);
assert(xListBox.is());
- auto pAccEntry = m_rListBox.implGetAccessible(*pEntry);
+ auto pAccEntry = xListBox->implGetAccessible(*pEntry);
tools::Rectangle aRect = pAccEntry->GetBoundingBox_Impl();
if ( aRect.Contains( VCLPoint( _aPoint ) ) )
xAcc = pAccEntry.get();
@@ -749,7 +726,7 @@ namespace accessibility
return 0;
}
else
- return ACCESSIBLE_ACTION_COUNT;
+ return 1;
return 0;
}
@@ -759,7 +736,7 @@ namespace accessibility
::osl::MutexGuard aGuard( m_aMutex );
bool bRet = false;
- checkActionIndex_Impl( nIndex );
+ CheckActionIndex(nIndex);
EnsureIsAlive();
SvTreeFlags treeFlag = m_pTreeListBox->GetTreeFlags();
@@ -796,7 +773,7 @@ namespace accessibility
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( m_aMutex );
- checkActionIndex_Impl( nIndex );
+ CheckActionIndex(nIndex);
EnsureIsAlive();
SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
@@ -816,9 +793,10 @@ namespace accessibility
//Sometimes, a List or Tree may have both checkbox and label at the same time
return OUString();
}
- }else if( (nIndex == 1 && (treeFlag & SvTreeFlags::CHKBTN)) || nIndex == 0 )
+ }
+ else if( (nIndex == 1 && (treeFlag & SvTreeFlags::CHKBTN)) || nIndex == 0 )
{
- if( pEntry->HasChildren() || pEntry->HasChildrenOnDemand() )
+ if( pEntry && (pEntry->HasChildren() || pEntry->HasChildrenOnDemand()) )
return m_pTreeListBox->IsExpanded( pEntry ) ?
AccResId(STR_SVT_ACC_ACTION_COLLAPSE) :
AccResId(STR_SVT_ACC_ACTION_EXPAND);
@@ -830,23 +808,24 @@ namespace accessibility
Reference< XAccessibleKeyBinding > AccessibleListBoxEntry::getAccessibleActionKeyBinding( sal_Int32 nIndex )
{
- ::osl::MutexGuard aGuard( m_aMutex );
-
Reference< XAccessibleKeyBinding > xRet;
- checkActionIndex_Impl( nIndex );
+ CheckActionIndex(nIndex);
// ... which key?
return xRet;
}
// XAccessibleSelection
- void SAL_CALL AccessibleListBoxEntry::selectAccessibleChild( sal_Int32 nChildIndex )
+ void SAL_CALL AccessibleListBoxEntry::selectAccessibleChild( sal_Int64 nChildIndex )
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( m_aMutex );
EnsureIsAlive();
+ if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
+ throw IndexOutOfBoundsException();
+
SvTreeListEntry* pEntry = GetRealChild(nChildIndex);
if ( !pEntry )
throw IndexOutOfBoundsException();
@@ -854,13 +833,16 @@ namespace accessibility
m_pTreeListBox->Select( pEntry );
}
- sal_Bool SAL_CALL AccessibleListBoxEntry::isAccessibleChildSelected( sal_Int32 nChildIndex )
+ sal_Bool SAL_CALL AccessibleListBoxEntry::isAccessibleChildSelected( sal_Int64 nChildIndex )
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( m_aMutex );
EnsureIsAlive();
+ if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
+ throw IndexOutOfBoundsException();
+
SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry( pParent, nChildIndex );
if ( !pEntry )
@@ -878,7 +860,7 @@ namespace accessibility
SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
if ( !pParent )
- throw RuntimeException();
+ throw RuntimeException("AccessibleListBoxEntry::clearAccessibleSelection - pParent cannot be empty!");
sal_Int32 nCount = m_pTreeListBox->GetLevelChildCount( pParent );
for ( sal_Int32 i = 0; i < nCount; ++i )
{
@@ -897,7 +879,7 @@ namespace accessibility
SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
if ( !pParent )
- throw RuntimeException();
+ throw RuntimeException("AccessibleListBoxEntry::selectAllAccessibleChildren - pParent cannot be empty!");
sal_Int32 nCount = m_pTreeListBox->GetLevelChildCount( pParent );
for ( sal_Int32 i = 0; i < nCount; ++i )
{
@@ -907,20 +889,20 @@ namespace accessibility
}
}
- sal_Int32 SAL_CALL AccessibleListBoxEntry::getSelectedAccessibleChildCount( )
+ sal_Int64 SAL_CALL AccessibleListBoxEntry::getSelectedAccessibleChildCount( )
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( m_aMutex );
EnsureIsAlive();
- sal_Int32 i, nSelCount = 0, nCount = 0;
+ sal_Int64 nSelCount = 0;
SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
if ( !pParent )
- throw RuntimeException();
- nCount = m_pTreeListBox->GetLevelChildCount( pParent );
- for ( i = 0; i < nCount; ++i )
+ throw RuntimeException("AccessibleListBoxEntry::getSelectedAccessibleChildCount - pParent cannot be empty!");
+ sal_Int32 nCount = m_pTreeListBox->GetLevelChildCount( pParent );
+ for (sal_Int32 i = 0; i < nCount; ++i )
{
SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry( pParent, i );
if ( m_pTreeListBox->IsSelected( pEntry ) )
@@ -930,7 +912,7 @@ namespace accessibility
return nSelCount;
}
- Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex )
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( m_aMutex );
@@ -941,13 +923,13 @@ namespace accessibility
throw IndexOutOfBoundsException();
Reference< XAccessible > xChild;
- sal_Int32 i, nSelCount = 0, nCount = 0;
+ sal_Int64 nSelCount = 0;
SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
if ( !pParent )
- throw RuntimeException();
- nCount = m_pTreeListBox->GetLevelChildCount( pParent );
- for ( i = 0; i < nCount; ++i )
+ throw RuntimeException("AccessibleListBoxEntry::getSelectedAccessibleChild - pParent cannot be empty!");
+ sal_Int32 nCount = m_pTreeListBox->GetLevelChildCount( pParent );
+ for (sal_Int32 i = 0; i < nCount; ++i )
{
SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry( pParent, i );
if ( m_pTreeListBox->IsSelected( pEntry ) )
@@ -955,9 +937,9 @@ namespace accessibility
if ( nSelCount == ( nSelectedChildIndex + 1 ) )
{
- uno::Reference<XAccessible> xListBox(m_wListBox);
+ rtl::Reference<AccessibleListBox> xListBox(m_wListBox);
assert(xListBox.is());
- xChild = m_rListBox.implGetAccessible(*pEntry).get();
+ xChild = xListBox->implGetAccessible(*pEntry).get();
break;
}
}
@@ -965,13 +947,16 @@ namespace accessibility
return xChild;
}
- void SAL_CALL AccessibleListBoxEntry::deselectAccessibleChild( sal_Int32 nSelectedChildIndex )
+ void SAL_CALL AccessibleListBoxEntry::deselectAccessibleChild( sal_Int64 nSelectedChildIndex )
{
SolarMutexGuard aSolarGuard;
::osl::MutexGuard aGuard( m_aMutex );
EnsureIsAlive();
+ if (nSelectedChildIndex < 0 || nSelectedChildIndex >= getAccessibleChildCount())
+ throw IndexOutOfBoundsException();
+
SvTreeListEntry* pParent = m_pTreeListBox->GetEntryFromPath( m_aEntryPath );
SvTreeListEntry* pEntry = m_pTreeListBox->GetEntry( pParent, nSelectedChildIndex );
if ( !pEntry )