diff options
author | Christian Lippka <christian.lippka@sun.com> | 2010-04-28 18:43:47 +0200 |
---|---|---|
committer | Christian Lippka <christian.lippka@sun.com> | 2010-04-28 18:43:47 +0200 |
commit | cfc9c68d07db4275041ee52e977f53c9b614934e (patch) | |
tree | 27164f4ca257766b523b2e63cbc3049b765c45c9 /svtools | |
parent | d22c384fac4fbf9977010da0b1348c1ab9d565e8 (diff) |
#i107213# finaly got orca to read the toolbar menu!
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/control/toolbarmenu.cxx | 170 | ||||
-rw-r--r--[-rwxr-xr-x] | svtools/source/control/toolbarmenuacc.cxx | 8 | ||||
-rw-r--r--[-rwxr-xr-x] | svtools/source/control/toolbarmenuimp.hxx | 9 | ||||
-rw-r--r--[-rwxr-xr-x] | svtools/source/control/valueset.cxx | 31 |
4 files changed, 105 insertions, 113 deletions
diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx index 6f7be376266e..8ff327f26731 100644 --- a/svtools/source/control/toolbarmenu.cxx +++ b/svtools/source/control/toolbarmenu.cxx @@ -307,6 +307,25 @@ Reference< XAccessible > ToolbarMenu_Impl::getAccessibleChild( sal_Int32 index ) throw IndexOutOfBoundsException(); } +// -------------------------------------------------------------------- + +Reference< XAccessible > ToolbarMenu_Impl::getAccessibleChild( Control* pControl, sal_Int32 childIndex ) throw (IndexOutOfBoundsException, RuntimeException) +{ + const int nEntryCount = maEntryVector.size(); + for( int nEntry = 0; nEntry < nEntryCount; nEntry++ ) + { + ToolbarMenuEntry* pEntry = maEntryVector[nEntry]; + if( pEntry && (pEntry->mpControl == pControl) ) + { + return pEntry->getAccessibleChild( childIndex ); + } + } + + throw IndexOutOfBoundsException(); +} + +// -------------------------------------------------------------------- + void ToolbarMenu_Impl::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) { const int nEntryCount = maEntryVector.size(); @@ -381,13 +400,60 @@ void ToolbarMenu_Impl::clearAccessibleSelection() } } + +// -------------------------------------------------------------------- + +void ToolbarMenu_Impl::notifyHighlightedEntry() +{ + if( hasAccessibleListeners() ) + { + ToolbarMenuEntry* pEntry = implGetEntry( mnHighlightedEntry ); + if( pEntry && pEntry->mbEnabled && (pEntry->mnEntryId != TITLE_ID) ) + { + Any aNew; + Any aOld( mxOldSelection ); + if( pEntry->mpControl ) + { + sal_Int32 nChildIndex = 0; + // todo: if other controls than ValueSet are allowed, addapt this code + ValueSet* pValueSet = dynamic_cast< ValueSet* >( pEntry->mpControl ); + if( pValueSet ) + nChildIndex = static_cast< sal_Int32 >( pValueSet->GetItemPos( pValueSet->GetSelectItemId() ) ); + + if( nChildIndex >= pEntry->getAccessibleChildCount() ) + return; + + aNew <<= getAccessibleChild( pEntry->mpControl, nChildIndex ); + } + else + { + aNew <<= pEntry->GetAccessible(true); + } + + fireAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOld, aNew ); + fireAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, aOld, aNew ); + aNew >>= mxOldSelection; + } + } +} + +// -------------------------------------------------------------------- + +ToolbarMenuEntry* ToolbarMenu_Impl::implGetEntry( int nEntry ) const +{ + if( (nEntry < 0) || (nEntry >= (int)maEntryVector.size() ) ) + return NULL; + + return maEntryVector[nEntry]; +} + + // -------------------------------------------------------------------- IMPL_LINK( ToolbarMenu, HighlightHdl, Control *, pControl ) { (void)pControl; - if( mpImpl->hasAccessibleListeners() ) - mpImpl->fireAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); + mpImpl->notifyHighlightedEntry(); return 0; } @@ -723,77 +789,6 @@ void ToolbarMenu::appendEntry( int nEntryId, const String& rStr, MenuItemBits nI appendEntry( new ToolbarMenuEntry( *this, nEntryId, rStr, nItemBits ) ); } - -#if 0 -todo acc selectentry? - if( ImplHasAccessibleListeners() ) - { - // focus event (deselect) - if( nOldItem ) - { - const USHORT nPos = GetItemPos( nItemId ); - - if( nPos != VALUESET_ITEM_NOTFOUND ) - { - ValueItemAcc* pItemAcc = ValueItemAcc::getImplementation( - mpImpl->mpItemList->GetObject( nPos )->GetAccessible( mpImpl->mbIsTransientChildrenDisabled ) ); - - if( pItemAcc ) - { - ::com::sun::star::uno::Any aOldAny, aNewAny; - if( !mpImpl->mbIsTransientChildrenDisabled) - { - aOldAny <<= ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >( - static_cast< ::cppu::OWeakObject* >( pItemAcc )); - ImplFireAccessibleEvent (::com::sun::star::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny ); - } - else - { - aOldAny <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED; - pItemAcc->FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny ); - } - } - } - } - - // focus event (select) - const USHORT nPos = GetItemPos( mnSelItemId ); - - ValueSetItem* pItem; - if( nPos != VALUESET_ITEM_NOTFOUND ) - pItem = mpImpl->mpItemList->GetObject(nPos); - else - pItem = mpNoneItem; - - ValueItemAcc* pItemAcc = NULL; - if (pItem != NULL) - pItemAcc = ValueItemAcc::getImplementation(pItem->GetAccessible( mpImpl->mbIsTransientChildrenDisabled ) ); - - if( pItemAcc ) - { - ::com::sun::star::uno::Any aOldAny, aNewAny; - if( !mpImpl->mbIsTransientChildrenDisabled) - { - aNewAny <<= ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >( - static_cast< ::cppu::OWeakObject* >( pItemAcc )); - ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny ); - } - else - { - aNewAny <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED; - pItemAcc->FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny ); - } - } - - // selection event - ::com::sun::star::uno::Any aOldAny, aNewAny; - ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny ); - } - } -} - -#endif - // -------------------------------------------------------------------- void ToolbarMenu::appendEntry( int nEntryId, const Image& rImage, MenuItemBits nItemBits ) @@ -848,10 +843,7 @@ ValueSet* ToolbarMenu::createEmptyValueSetControl() ToolbarMenuEntry* ToolbarMenu::implGetEntry( int nEntry ) const { - if( (nEntry < 0) || (nEntry >= (int)mpImpl->maEntryVector.size() ) ) - return NULL; - - return mpImpl->maEntryVector[nEntry]; + return mpImpl->implGetEntry( nEntry ); } // -------------------------------------------------------------------- @@ -888,7 +880,17 @@ void ToolbarMenu::implHighlightEntry( int nHighlightEntry, bool bHighlight ) { // no highlights for controls only items if( pEntry->mpControl ) + { + if( !bHighlight ) + { + ValueSet* pValueSet = dynamic_cast< ValueSet* >( pEntry->mpControl ); + if( pValueSet ) + { + pValueSet->SetNoSelection(); + } + } break; + } bool bRestoreLineColor = false; Color oldLineColor; @@ -1070,8 +1072,7 @@ void ToolbarMenu::implChangeHighlightEntry( int nEntry ) implHighlightEntry( mpImpl->mnHighlightedEntry, true ); } - if( mpImpl->hasAccessibleListeners() ) - mpImpl->fireAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); + mpImpl->notifyHighlightedEntry(); } // -------------------------------------------------------------------- @@ -1184,7 +1185,7 @@ ToolbarMenuEntry* ToolbarMenu::implCursorUpDown( bool bUp, bool bHomeEnd ) // -------------------------------------------------------------------- -static void implHighlightControl( USHORT nCode, Control* pControl, int nLastColumn ) +void ToolbarMenu_Impl::implHighlightControl( USHORT nCode, Control* pControl ) { ValueSet* pValueSet = dynamic_cast< ValueSet* >( pControl ); if( pValueSet ) @@ -1197,11 +1198,11 @@ static void implHighlightControl( USHORT nCode, Control* pControl, int nLastColu { const USHORT nColCount = pValueSet->GetColCount(); const USHORT nLastLine = nItemCount / nColCount; - nItemPos = std::min( ((nLastLine-1) * nColCount) + nLastColumn, nItemCount-1 ); + nItemPos = std::min( ((nLastLine-1) * nColCount) + mnLastColumn, nItemCount-1 ); break; } case KEY_DOWN: - nItemPos = std::min( nLastColumn, nItemCount-1 ); + nItemPos = std::min( mnLastColumn, nItemCount-1 ); break; case KEY_END: nItemPos = nItemCount -1; @@ -1211,6 +1212,7 @@ static void implHighlightControl( USHORT nCode, Control* pControl, int nLastColu break; } pValueSet->SelectItem( pValueSet->GetItemId( nItemPos ) ); + notifyHighlightedEntry(); } } @@ -1231,7 +1233,7 @@ void ToolbarMenu::KeyInput( const KeyEvent& rKEvent ) { if( nOldEntry != mpImpl->mnHighlightedEntry ) { - implHighlightControl( nCode, p->mpControl, mpImpl->mnLastColumn ); + mpImpl->implHighlightControl( nCode, p->mpControl ); } else { @@ -1247,7 +1249,7 @@ void ToolbarMenu::KeyInput( const KeyEvent& rKEvent ) ToolbarMenuEntry* p = implCursorUpDown( nCode == KEY_END, true ); if( p && p->mpControl ) { - implHighlightControl( nCode, p->mpControl, mpImpl->mnLastColumn ); + mpImpl->implHighlightControl( nCode, p->mpControl ); } } break; diff --git a/svtools/source/control/toolbarmenuacc.cxx b/svtools/source/control/toolbarmenuacc.cxx index f227a4cb2558..14586ecd422b 100755..100644 --- a/svtools/source/control/toolbarmenuacc.cxx +++ b/svtools/source/control/toolbarmenuacc.cxx @@ -96,9 +96,6 @@ void ToolbarMenuAcc::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { Any aOldValue, aNewValue; - Window* pAccWindow = rVclWindowEvent.GetWindow(); - DBG_ASSERT( pAccWindow, "VCLXAccessibleComponent::ProcessWindowEvent - Window?" ); - switch ( rVclWindowEvent.GetId() ) { case VCLEVENT_OBJECT_DYING: @@ -112,8 +109,7 @@ void ToolbarMenuAcc::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { if( !mbIsFocused ) { - aNewValue <<= accessibility::AccessibleStateType::FOCUSED; - FireAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); + mpParent->notifyHighlightedEntry(); mbIsFocused = true; } } @@ -122,8 +118,6 @@ void ToolbarMenuAcc::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { if( mbIsFocused ) { - aOldValue <<= accessibility::AccessibleStateType::FOCUSED; - FireAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue ); mbIsFocused = false; } } diff --git a/svtools/source/control/toolbarmenuimp.hxx b/svtools/source/control/toolbarmenuimp.hxx index 051fe23883a4..d1de4f704b76 100755..100644 --- a/svtools/source/control/toolbarmenuimp.hxx +++ b/svtools/source/control/toolbarmenuimp.hxx @@ -273,6 +273,8 @@ struct ToolbarMenu_Impl rtl::Reference< svt::FrameStatusListener > mxStatusListener; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxServiceManager; rtl::Reference< ToolbarMenuAcc > mxAccessible; + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxOldSelection; + ToolbarMenuEntryVector maEntryVector; int mnCheckPos; @@ -297,9 +299,16 @@ struct ToolbarMenu_Impl sal_Int32 getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException); ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getAccessibleChild( sal_Int32 index ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getAccessibleChild( Control* pControl, sal_Int32 childIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + void selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); sal_Bool isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); void clearAccessibleSelection(); + + ToolbarMenuEntry* implGetEntry( int nEntry ) const; + void notifyHighlightedEntry(); + + void implHighlightControl( USHORT nCode, Control* pControl ); }; } diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 92c51bd6640e..62193eadf735 100755..100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -1526,32 +1526,20 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt ) nCalcPos - ( nLineCount * mnCols )); else { -#if 0 - if( (KEY_UP == rKEvt.GetKeyCode().GetCode() ) && (GetStyle() & WB_MENUSTYLEVALUESET) ) + if ( mpNoneItem ) { - Window* pParent = GetParent(); - pParent->GrabFocus(); - pParent->KeyInput( rKEvt ); - break; + mnCurCol = nCalcPos%mnCols; + nItemPos = VALUESET_ITEM_NONEITEM; } else -#endif { - if ( mpNoneItem ) - { - mnCurCol = nCalcPos%mnCols; - nItemPos = VALUESET_ITEM_NONEITEM; - } + if ( nLastItem+1 <= mnCols ) + nItemPos = nCalcPos; else { - if ( nLastItem+1 <= mnCols ) - nItemPos = nCalcPos; - else - { - nItemPos = ((((nLastItem+1)/mnCols)-1)*mnCols)+(nCalcPos%mnCols); - if ( nItemPos+mnCols <= nLastItem ) - nItemPos = nItemPos + mnCols; - } + nItemPos = ((((nLastItem+1)/mnCols)-1)*mnCols)+(nCalcPos%mnCols); + if ( nItemPos+mnCols <= nLastItem ) + nItemPos = nItemPos + mnCols; } } } @@ -2279,9 +2267,8 @@ void ValueSet::SelectItem( USHORT nItemId ) // selection event ::com::sun::star::uno::Any aOldAny, aNewAny; ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny ); - - mpImpl->maHighlightHdl.Call(this); } + mpImpl->maHighlightHdl.Call(this); } } |