diff options
Diffstat (limited to 'sw/source/core/access/accselectionhelper.cxx')
-rw-r--r-- | sw/source/core/access/accselectionhelper.cxx | 105 |
1 files changed, 97 insertions, 8 deletions
diff --git a/sw/source/core/access/accselectionhelper.cxx b/sw/source/core/access/accselectionhelper.cxx index 0a651f3b5d42..9be9421fffd6 100644 --- a/sw/source/core/access/accselectionhelper.cxx +++ b/sw/source/core/access/accselectionhelper.cxx @@ -38,6 +38,14 @@ #include <flyfrm.hxx> +//IAccessibility2 Implementation 2009----- +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/accessibility/XAccessibleStateSet.hpp> +#include <fmtanchr.hxx> +//-----IAccessibility2 Implementation 2009 + +using namespace ::com::sun::star::accessibility; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -111,6 +119,43 @@ void SwAccessibleSelectionHelper::selectAccessibleChild( // return bRet; } +//IAccessibility2 Implementation 2009----- +//When the selected state of the SwFrmOrObj is setted, return true. +static sal_Bool lcl_getSelectedState(const SwAccessibleChild& aChild, + SwAccessibleContext* pContext, + SwAccessibleMap* pMap) +{ + Reference< XAccessible > xAcc; + if ( aChild.GetSwFrm() ) + { + xAcc = pMap->GetContext( aChild.GetSwFrm(), sal_False ); + } + else if ( aChild.GetDrawObject() ) + { + xAcc = pMap->GetContext( aChild.GetDrawObject(), pContext, sal_False ); + } + + if( xAcc.is() ) + { + Reference< XAccessibleContext > pRContext = xAcc->getAccessibleContext(); + if(!pRContext.is()) + return sal_False; + Reference<XAccessibleStateSet> pRStateSet = pRContext->getAccessibleStateSet(); + if( pRStateSet.is() ) + { + Sequence<short> pStates = pRStateSet->getStates(); + long count = pStates.getLength(); + for( int i = 0; i < count; i++ ) + { + if( pStates[i] == AccessibleStateType::SELECTED) + return sal_True; + } + } + } + return sal_False; +} +//-----IAccessibility2 Implementation 2009 + sal_Bool SwAccessibleSelectionHelper::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw ( lang::IndexOutOfBoundsException, @@ -137,6 +182,14 @@ sal_Bool SwAccessibleSelectionHelper::isAccessibleChildSelected( { bRet = pFEShell->IsObjSelected( *aChild.GetDrawObject() ); } + //IAccessibility2 Implementation 2009----- + //If the SwFrmOrObj is not selected directly in the UI, we should check whether it is selected in the selection cursor. + if( !bRet ) + { + if( lcl_getSelectedState( aChild, &rContext, rContext.GetMap() ) == sal_True) + bRet = sal_True; + } + //-----IAccessibility2 Implementation 2009 } return bRet; @@ -194,11 +247,11 @@ sal_Int32 SwAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) const SwFlyFrm* pFlyFrm = pFEShell->GetCurrFlyFrm(); if( pFlyFrm ) { - if( rContext.GetParent( SwAccessibleChild(pFlyFrm), rContext.IsInPagePreview()) == - rContext.GetFrm() ) - { + //IAccessibility2 Implementation 2009----- + //if( rContext.GetParent( SwAccessibleChild(pFlyFrm), rContext.IsInPagePreview()) == + // rContext.GetFrm() ) nCount = 1; - } + //-----IAccessibility2 Implementation 2009 } else { @@ -226,6 +279,26 @@ sal_Int32 SwAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) } } } + //IAccessibility2 Implementation 2009----- + //If the SwFrmOrObj is not selected directly in the UI, + //we should check whether it is selected in the selection cursor. + if( nCount == 0 ) + { + ::std::list< SwAccessibleChild > aChildren; + rContext.GetChildren( *(rContext.GetMap()), aChildren ); + ::std::list< SwAccessibleChild >::const_iterator aIter = + aChildren.begin(); + ::std::list< SwAccessibleChild >::const_iterator aEndIter = + aChildren.end(); + while( aIter != aEndIter ) + { + const SwAccessibleChild& aChild = *aIter; + if( lcl_getSelectedState( aChild, &rContext, rContext.GetMap() ) ) + nCount++; + ++aIter; + } + } + //-----IAccessibility2 Implementation 2009 } return nCount; } @@ -249,12 +322,28 @@ Reference<XAccessible> SwAccessibleSelectionHelper::getSelectedAccessibleChild( const SwFlyFrm *pFlyFrm = pFEShell->GetCurrFlyFrm(); if( pFlyFrm ) { - if( 0 == nSelectedChildIndex && - rContext.GetParent( SwAccessibleChild(pFlyFrm), rContext.IsInPagePreview()) == - rContext.GetFrm() ) + //IAccessibility2 Implementation 2009----- + if( 0 == nSelectedChildIndex ) { - aChild = pFlyFrm; + if(rContext.GetParent( SwAccessibleChild(pFlyFrm), rContext.IsInPagePreview()) == rContext.GetFrm() ) + { + aChild = pFlyFrm; + } + else + { + const SwFrmFmt *pFrmFmt = pFlyFrm->GetFmt(); + if (pFrmFmt) + { + const SwFmtAnchor& pAnchor = pFrmFmt->GetAnchor(); + if( pAnchor.GetAnchorId() == FLY_AS_CHAR ) + { + const SwFrm *pParaFrm = rContext.GetParent( SwAccessibleChild(pFlyFrm), rContext.IsInPagePreview() ); + aChild = pParaFrm; + } + } + } } + //-----IAccessibility2 Implementation 2009 } else { |