1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <accessibility/standard/vclxaccessibletoolboxitem.hxx>
21 #include <toolkit/helper/convert.hxx>
22 #include <accessibility/helper/accresmgr.hxx>
23 #include <accessibility/helper/accessiblestrings.hrc>
24 #include <com/sun/star/awt/Point.hpp>
25 #include <com/sun/star/awt/Rectangle.hpp>
26 #include <com/sun/star/awt/Size.hpp>
28 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
29 #include <com/sun/star/accessibility/AccessibleRole.hpp>
30 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
31 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
32 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
33 #include <cppuhelper/supportsservice.hxx>
34 #include <vcl/svapp.hxx>
35 #include <vcl/toolbox.hxx>
36 #include <vcl/unohelp2.hxx>
37 #include <vcl/help.hxx>
38 #include <toolkit/awt/vclxwindow.hxx>
39 #include <toolkit/helper/externallock.hxx>
40 #include <unotools/accessiblestatesethelper.hxx>
41 #include <unotools/accessiblerelationsethelper.hxx>
42 #include <cppuhelper/typeprovider.hxx>
43 #include <comphelper/sequence.hxx>
45 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
47 // class VCLXAccessibleToolBoxItem ------------------------------------------
49 using namespace ::com::sun::star::accessibility
;
50 using namespace ::com::sun::star::uno
;
51 using namespace ::com::sun::star::beans
;
52 using namespace ::com::sun::star::lang
;
53 using namespace ::com::sun::star
;
54 using namespace ::comphelper
;
56 // -----------------------------------------------------------------------------
58 // -----------------------------------------------------------------------------
59 VCLXAccessibleToolBoxItem::VCLXAccessibleToolBoxItem( ToolBox
* _pToolBox
, sal_Int32 _nPos
) :
61 AccessibleTextHelper_BASE( new VCLExternalSolarLock() ),
63 m_pToolBox ( _pToolBox
),
64 m_nIndexInParent( _nPos
),
65 m_nRole ( AccessibleRole::PUSH_BUTTON
),
67 m_bHasFocus ( sal_False
),
68 m_bIsChecked ( sal_False
),
69 m_bIndeterminate( false )
72 m_pExternalLock
= static_cast< VCLExternalSolarLock
* >( getExternalLock( ) );
74 OSL_ENSURE( m_pToolBox
, "invalid toolbox" );
75 m_nItemId
= m_pToolBox
->GetItemId( (sal_uInt16
)m_nIndexInParent
);
76 m_sOldName
= GetText( true );
77 m_bIsChecked
= m_pToolBox
->IsItemChecked( m_nItemId
);
78 m_bIndeterminate
= ( m_pToolBox
->GetItemState( m_nItemId
) == STATE_DONTKNOW
);
79 ToolBoxItemType eType
= m_pToolBox
->GetItemType( (sal_uInt16
)m_nIndexInParent
);
82 case TOOLBOXITEM_BUTTON
:
84 ToolBoxItemBits nBits
= m_pToolBox
->GetItemBits( m_nItemId
);
85 if (( nBits
& TIB_DROPDOWN
) == TIB_DROPDOWN
)
86 m_nRole
= AccessibleRole::BUTTON_DROPDOWN
;
87 else if (( ( nBits
& TIB_CHECKABLE
) == TIB_CHECKABLE
) ||
88 ( ( nBits
& TIB_AUTOCHECK
) == TIB_AUTOCHECK
) )
89 m_nRole
= AccessibleRole::TOGGLE_BUTTON
;
90 else if ( m_pToolBox
->GetItemWindow( m_nItemId
) )
91 m_nRole
= AccessibleRole::PANEL
;
95 case TOOLBOXITEM_SPACE
:
96 m_nRole
= AccessibleRole::FILLER
;
99 case TOOLBOXITEM_SEPARATOR
:
100 case TOOLBOXITEM_BREAK
:
101 m_nRole
= AccessibleRole::SEPARATOR
;
106 SAL_WARN( "accessibility", "unsupported toolbox itemtype" );
110 // -----------------------------------------------------------------------------
111 VCLXAccessibleToolBoxItem::~VCLXAccessibleToolBoxItem()
113 delete m_pExternalLock
;
114 m_pExternalLock
= NULL
;
116 // -----------------------------------------------------------------------------
117 OUString
VCLXAccessibleToolBoxItem::GetText( bool _bAsName
)
120 // no text for separators and spaces
121 if ( m_pToolBox
&& m_nItemId
> 0 && ( _bAsName
|| m_pToolBox
->GetButtonType() != BUTTON_SYMBOL
) )
123 sRet
= m_pToolBox
->GetItemText( m_nItemId
);
127 // -----------------------------------------------------------------------------
128 void VCLXAccessibleToolBoxItem::SetFocus( sal_Bool _bFocus
)
130 if ( m_bHasFocus
!= _bFocus
)
135 aOldValue
<<= AccessibleStateType::FOCUSED
;
137 aNewValue
<<= AccessibleStateType::FOCUSED
;
138 m_bHasFocus
= _bFocus
;
139 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
142 // -----------------------------------------------------------------------------
143 void VCLXAccessibleToolBoxItem::SetChecked( sal_Bool _bCheck
)
145 if ( m_bIsChecked
!= _bCheck
)
150 aOldValue
<<= AccessibleStateType::CHECKED
;
152 aNewValue
<<= AccessibleStateType::CHECKED
;
153 m_bIsChecked
= _bCheck
;
154 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
157 // -----------------------------------------------------------------------------
158 void VCLXAccessibleToolBoxItem::SetIndeterminate( bool _bIndeterminate
)
160 if ( m_bIndeterminate
!= _bIndeterminate
)
162 Any aOldValue
, aNewValue
;
163 if ( m_bIndeterminate
)
164 aOldValue
<<= AccessibleStateType::INDETERMINATE
;
166 aNewValue
<<= AccessibleStateType::INDETERMINATE
;
167 m_bIndeterminate
= _bIndeterminate
;
168 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
171 // -----------------------------------------------------------------------------
172 void VCLXAccessibleToolBoxItem::NameChanged()
174 OUString sNewName
= implGetText();
175 if ( sNewName
!= m_sOldName
)
177 Any aOldValue
, aNewValue
;
178 aOldValue
<<= m_sOldName
;
179 // save new name as old name for next change
180 m_sOldName
= sNewName
;
181 aNewValue
<<= m_sOldName
;
182 NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED
, aOldValue
, aNewValue
);
185 // -----------------------------------------------------------------------------
186 void VCLXAccessibleToolBoxItem::SetChild( const Reference
< XAccessible
>& _xChild
)
190 // -----------------------------------------------------------------------------
191 void VCLXAccessibleToolBoxItem::NotifyChildEvent( const Reference
< XAccessible
>& _xChild
, bool _bShow
)
193 Any aOld
= _bShow
? Any() : makeAny( _xChild
);
194 Any aNew
= _bShow
? makeAny( _xChild
) : Any();
195 NotifyAccessibleEvent( AccessibleEventId::CHILD
, aOld
, aNew
);
197 // -----------------------------------------------------------------------------
198 void VCLXAccessibleToolBoxItem::ToggleEnableState()
200 Any aOldValue
[2], aNewValue
[2];
201 if ( m_pToolBox
->IsItemEnabled( m_nItemId
) )
203 aNewValue
[0] <<= AccessibleStateType::SENSITIVE
;
204 aNewValue
[1] <<= AccessibleStateType::ENABLED
;
208 aOldValue
[0] <<= AccessibleStateType::ENABLED
;
209 aOldValue
[1] <<= AccessibleStateType::SENSITIVE
;
212 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
[0], aNewValue
[0] );
213 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
[1], aNewValue
[1] );
215 // -----------------------------------------------------------------------------
216 awt::Rectangle SAL_CALL
VCLXAccessibleToolBoxItem::implGetBounds( ) throw (RuntimeException
)
218 awt::Rectangle aRect
;
220 aRect
= AWTRectangle( m_pToolBox
->GetItemPosRect( (sal_uInt16
)m_nIndexInParent
) );
224 // -----------------------------------------------------------------------------
225 OUString
VCLXAccessibleToolBoxItem::implGetText()
227 return GetText (true);
229 // -----------------------------------------------------------------------------
230 Locale
VCLXAccessibleToolBoxItem::implGetLocale()
232 return Application::GetSettings().GetUILanguageTag().getLocale();
234 // -----------------------------------------------------------------------------
235 void VCLXAccessibleToolBoxItem::implGetSelection( sal_Int32
& nStartIndex
, sal_Int32
& nEndIndex
)
240 // -----------------------------------------------------------------------------
242 // -----------------------------------------------------------------------------
243 IMPLEMENT_FORWARD_REFCOUNT( VCLXAccessibleToolBoxItem
, AccessibleTextHelper_BASE
)
244 Any SAL_CALL
VCLXAccessibleToolBoxItem::queryInterface( const Type
& _rType
) throw (RuntimeException
)
246 // #i33611# - toolbox buttons without text don't support XAccessibleText
247 if ( _rType
== ::getCppuType( ( const Reference
< XAccessibleText
>* ) 0 )
248 && ( !m_pToolBox
|| m_pToolBox
->GetButtonType() == BUTTON_SYMBOL
) )
251 ::com::sun::star::uno::Any aReturn
= AccessibleTextHelper_BASE::queryInterface( _rType
);
252 if ( !aReturn
.hasValue() )
253 aReturn
= VCLXAccessibleToolBoxItem_BASE::queryInterface( _rType
);
256 // -----------------------------------------------------------------------------
258 // -----------------------------------------------------------------------------
259 IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleToolBoxItem
, AccessibleTextHelper_BASE
, VCLXAccessibleToolBoxItem_BASE
)
260 // -----------------------------------------------------------------------------
262 // -----------------------------------------------------------------------------
263 void SAL_CALL
VCLXAccessibleToolBoxItem::disposing()
265 AccessibleTextHelper_BASE::disposing();
268 // -----------------------------------------------------------------------------
270 // -----------------------------------------------------------------------------
271 OUString
VCLXAccessibleToolBoxItem::getImplementationName() throw (RuntimeException
)
273 return OUString( "com.sun.star.comp.toolkit.AccessibleToolBoxItem" );
275 // -----------------------------------------------------------------------------
276 sal_Bool
VCLXAccessibleToolBoxItem::supportsService( const OUString
& rServiceName
) throw (RuntimeException
)
278 return cppu::supportsService(this, rServiceName
);
280 // -----------------------------------------------------------------------------
281 Sequence
< OUString
> VCLXAccessibleToolBoxItem::getSupportedServiceNames() throw (RuntimeException
)
283 Sequence
< OUString
> aNames(4);
284 aNames
[0] = "com.sun.star.accessibility.AccessibleContext";
285 aNames
[1] = "com.sun.star.accessibility.AccessibleComponent";
286 aNames
[2] = "com.sun.star.accessibility.AccessibleExtendedComponent";
287 aNames
[3] = "com.sun.star.accessibility.AccessibleToolBoxItem";
290 // -----------------------------------------------------------------------------
292 // -----------------------------------------------------------------------------
293 Reference
< XAccessibleContext
> SAL_CALL
VCLXAccessibleToolBoxItem::getAccessibleContext( ) throw (RuntimeException
)
297 // -----------------------------------------------------------------------------
298 // XAccessibleContext
299 // -----------------------------------------------------------------------------
300 sal_Int32 SAL_CALL
VCLXAccessibleToolBoxItem::getAccessibleChildCount( ) throw (RuntimeException
)
302 OContextEntryGuard
aGuard( this );
304 return m_xChild
.is() ? 1 : 0;
306 // -----------------------------------------------------------------------------
307 Reference
< XAccessible
> SAL_CALL
VCLXAccessibleToolBoxItem::getAccessibleChild( sal_Int32 i
) throw (RuntimeException
, com::sun::star::lang::IndexOutOfBoundsException
)
309 OContextEntryGuard
aGuard( this );
311 // no child -> so index is out of bounds
312 if ( !m_xChild
.is() || i
!= 0 )
313 throw IndexOutOfBoundsException();
317 // -----------------------------------------------------------------------------
318 Reference
< XAccessible
> SAL_CALL
VCLXAccessibleToolBoxItem::getAccessibleParent( ) throw (RuntimeException
)
320 OContextEntryGuard
aGuard( this );
322 return m_pToolBox
->GetAccessible();
324 // -----------------------------------------------------------------------------
325 sal_Int32 SAL_CALL
VCLXAccessibleToolBoxItem::getAccessibleIndexInParent( ) throw (RuntimeException
)
327 OContextEntryGuard
aGuard( this );
329 return m_nIndexInParent
;
331 // -----------------------------------------------------------------------------
332 sal_Int16 SAL_CALL
VCLXAccessibleToolBoxItem::getAccessibleRole( ) throw (RuntimeException
)
334 OContextEntryGuard
aGuard( this );
338 // -----------------------------------------------------------------------------
339 OUString SAL_CALL
VCLXAccessibleToolBoxItem::getAccessibleDescription( ) throw (RuntimeException
)
341 OExternalLockGuard
aGuard( this );
343 OUString sDescription
;
345 sDescription
= m_pToolBox
->GetHelpText( m_nItemId
);
349 // -----------------------------------------------------------------------------
350 OUString SAL_CALL
VCLXAccessibleToolBoxItem::getAccessibleName( ) throw (RuntimeException
)
352 OExternalLockGuard
aGuard( this );
354 // entry text == accessible name
355 return GetText( true );
357 // -----------------------------------------------------------------------------
358 Reference
< XAccessibleRelationSet
> SAL_CALL
VCLXAccessibleToolBoxItem::getAccessibleRelationSet( ) throw (RuntimeException
)
360 OContextEntryGuard
aGuard( this );
362 utl::AccessibleRelationSetHelper
* pRelationSetHelper
= new utl::AccessibleRelationSetHelper
;
363 Reference
< XAccessibleRelationSet
> xSet
= pRelationSetHelper
;
366 // -----------------------------------------------------------------------------
367 Reference
< XAccessibleStateSet
> SAL_CALL
VCLXAccessibleToolBoxItem::getAccessibleStateSet( ) throw (RuntimeException
)
369 OExternalLockGuard
aGuard( this );
371 utl::AccessibleStateSetHelper
* pStateSetHelper
= new utl::AccessibleStateSetHelper
;
372 Reference
< XAccessibleStateSet
> xStateSet
= pStateSetHelper
;
374 if ( m_pToolBox
&& !rBHelper
.bDisposed
&& !rBHelper
.bInDispose
)
376 pStateSetHelper
->AddState( AccessibleStateType::FOCUSABLE
);
378 pStateSetHelper
->AddState( AccessibleStateType::CHECKED
);
379 if ( m_bIndeterminate
)
380 pStateSetHelper
->AddState( AccessibleStateType::INDETERMINATE
);
381 if ( m_pToolBox
->IsItemEnabled( m_nItemId
) )
383 pStateSetHelper
->AddState( AccessibleStateType::ENABLED
);
384 pStateSetHelper
->AddState( AccessibleStateType::SENSITIVE
);
386 if ( m_pToolBox
->IsItemVisible( m_nItemId
) )
387 pStateSetHelper
->AddState( AccessibleStateType::VISIBLE
);
388 if ( m_pToolBox
->IsItemReallyVisible( m_nItemId
) )
389 pStateSetHelper
->AddState( AccessibleStateType::SHOWING
);
391 pStateSetHelper
->AddState( AccessibleStateType::FOCUSED
);
394 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
398 // -----------------------------------------------------------------------------
400 // -----------------------------------------------------------------------------
401 sal_Int32 SAL_CALL
VCLXAccessibleToolBoxItem::getCaretPosition() throw (RuntimeException
)
405 // -----------------------------------------------------------------------------
406 sal_Bool SAL_CALL
VCLXAccessibleToolBoxItem::setCaretPosition( sal_Int32 nIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
408 OExternalLockGuard
aGuard( this );
410 if ( !implIsValidRange( nIndex
, nIndex
, implGetText().getLength() ) )
411 throw IndexOutOfBoundsException();
415 // -----------------------------------------------------------------------------
416 Sequence
< PropertyValue
> SAL_CALL
VCLXAccessibleToolBoxItem::getCharacterAttributes( sal_Int32 nIndex
, const Sequence
< OUString
>& ) throw (IndexOutOfBoundsException
, RuntimeException
)
418 OExternalLockGuard
aGuard( this );
420 OUString
sText( implGetText() );
422 if ( !implIsValidIndex( nIndex
, sText
.getLength() ) )
423 throw IndexOutOfBoundsException();
425 return Sequence
< PropertyValue
>();
427 // -----------------------------------------------------------------------------
428 awt::Rectangle SAL_CALL
VCLXAccessibleToolBoxItem::getCharacterBounds( sal_Int32 nIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
430 OExternalLockGuard
aGuard( this );
432 OUString
sText( implGetText() );
434 if ( !implIsValidIndex( nIndex
, sText
.getLength() ) )
435 throw IndexOutOfBoundsException();
437 awt::Rectangle
aBounds( 0, 0, 0, 0 );
438 if ( m_pToolBox
&& m_pToolBox
->GetButtonType() != BUTTON_SYMBOL
) // symbol buttons have no character bounds
440 Rectangle aCharRect
= m_pToolBox
->GetCharacterBounds( m_nItemId
, nIndex
);
441 Rectangle aItemRect
= m_pToolBox
->GetItemRect( m_nItemId
);
442 aCharRect
.Move( -aItemRect
.Left(), -aItemRect
.Top() );
443 aBounds
= AWTRectangle( aCharRect
);
448 // -----------------------------------------------------------------------------
449 sal_Int32 SAL_CALL
VCLXAccessibleToolBoxItem::getIndexAtPoint( const awt::Point
& aPoint
) throw (RuntimeException
)
451 OExternalLockGuard
aGuard( this );
453 sal_Int32 nIndex
= -1;
454 if ( m_pToolBox
&& m_pToolBox
->GetButtonType() != BUTTON_SYMBOL
) // symbol buttons have no character bounds
456 sal_uInt16 nItemId
= 0;
457 Rectangle aItemRect
= m_pToolBox
->GetItemRect( m_nItemId
);
458 Point
aPnt( VCLPoint( aPoint
) );
459 aPnt
+= aItemRect
.TopLeft();
460 sal_Int32 nIdx
= m_pToolBox
->GetIndexForPoint( aPnt
, nItemId
);
461 if ( nIdx
!= -1 && nItemId
== m_nItemId
)
467 // -----------------------------------------------------------------------------
468 sal_Bool SAL_CALL
VCLXAccessibleToolBoxItem::setSelection( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
470 OExternalLockGuard
aGuard( this );
472 if ( !implIsValidRange( nStartIndex
, nEndIndex
, implGetText().getLength() ) )
473 throw IndexOutOfBoundsException();
477 // -----------------------------------------------------------------------------
478 sal_Bool SAL_CALL
VCLXAccessibleToolBoxItem::copyText( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
480 OExternalLockGuard
aGuard( this );
482 if ( !implIsValidRange( nStartIndex
, nEndIndex
, implGetText().getLength() ) )
483 throw IndexOutOfBoundsException();
485 sal_Bool bReturn
= sal_False
;
489 Reference
< datatransfer::clipboard::XClipboard
> xClipboard
= m_pToolBox
->GetClipboard();
490 if ( xClipboard
.is() )
492 OUString
sText( getTextRange( nStartIndex
, nEndIndex
) );
494 ::vcl::unohelper::TextDataObject
* pDataObj
= new ::vcl::unohelper::TextDataObject( sText
);
495 const sal_uInt32 nRef
= Application::ReleaseSolarMutex();
496 xClipboard
->setContents( pDataObj
, NULL
);
498 Reference
< datatransfer::clipboard::XFlushableClipboard
> xFlushableClipboard( xClipboard
, uno::UNO_QUERY
);
499 if( xFlushableClipboard
.is() )
500 xFlushableClipboard
->flushClipboard();
502 Application::AcquireSolarMutex( nRef
);
510 // -----------------------------------------------------------------------------
511 // XAccessibleComponent
512 // -----------------------------------------------------------------------------
513 Reference
< XAccessible
> SAL_CALL
VCLXAccessibleToolBoxItem::getAccessibleAtPoint( const awt::Point
& ) throw (RuntimeException
)
515 return Reference
< XAccessible
>();
517 // -----------------------------------------------------------------------------
518 void SAL_CALL
VCLXAccessibleToolBoxItem::grabFocus( ) throw (RuntimeException
)
520 Reference
< XAccessible
> xParent(getAccessibleParent());
524 Reference
< XAccessibleSelection
> rxAccessibleSelection(xParent
->getAccessibleContext(), UNO_QUERY
);
526 if ( rxAccessibleSelection
.is() )
528 rxAccessibleSelection
-> selectAccessibleChild ( getAccessibleIndexInParent() );
532 // -----------------------------------------------------------------------------
533 sal_Int32 SAL_CALL
VCLXAccessibleToolBoxItem::getForeground( ) throw (RuntimeException
)
535 OExternalLockGuard
aGuard( this );
537 sal_Int32 nColor
= 0;
539 nColor
= m_pToolBox
->GetControlForeground().GetColor();
543 // -----------------------------------------------------------------------------
544 sal_Int32 SAL_CALL
VCLXAccessibleToolBoxItem::getBackground( ) throw (RuntimeException
)
546 OExternalLockGuard
aGuard( this );
548 sal_Int32 nColor
= 0;
550 nColor
= m_pToolBox
->GetControlBackground().GetColor();
554 // -----------------------------------------------------------------------------
555 // XAccessibleExtendedComponent
556 // -----------------------------------------------------------------------------
557 Reference
< awt::XFont
> SAL_CALL
VCLXAccessibleToolBoxItem::getFont( ) throw (RuntimeException
)
559 return uno::Reference
< awt::XFont
>();
561 // -----------------------------------------------------------------------------
562 awt::FontDescriptor SAL_CALL
VCLXAccessibleToolBoxItem::getFontMetrics( const Reference
< awt::XFont
>& xFont
) throw (RuntimeException
)
564 return xFont
->getFontDescriptor();
566 // -----------------------------------------------------------------------------
567 OUString SAL_CALL
VCLXAccessibleToolBoxItem::getTitledBorderText( ) throw (RuntimeException
)
569 OExternalLockGuard
aGuard( this );
573 sRet
= m_pToolBox
->GetItemText( m_nItemId
);
577 // -----------------------------------------------------------------------------
578 OUString SAL_CALL
VCLXAccessibleToolBoxItem::getToolTipText( ) throw (RuntimeException
)
580 OExternalLockGuard
aGuard( this );
585 if ( Help::IsExtHelpEnabled() )
586 sRet
= m_pToolBox
->GetHelpText( m_nItemId
);
588 sRet
= m_pToolBox
->GetQuickHelpText( m_nItemId
);
589 if ( sRet
.isEmpty() )
590 // no help text set, so use item text
591 sRet
= m_pToolBox
->GetItemText( m_nItemId
);
595 // -----------------------------------------------------------------------------
597 // -----------------------------------------------------------------------------
598 sal_Int32
VCLXAccessibleToolBoxItem::getAccessibleActionCount( ) throw (RuntimeException
)
600 // only one action -> "Click"
603 // -----------------------------------------------------------------------------
604 sal_Bool
VCLXAccessibleToolBoxItem::doAccessibleAction ( sal_Int32 nIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
606 OExternalLockGuard
aGuard( this );
608 if ( nIndex
< 0 || nIndex
>= getAccessibleActionCount() )
609 throw IndexOutOfBoundsException();
612 m_pToolBox
->TriggerItem( m_nItemId
);
616 // -----------------------------------------------------------------------------
617 OUString
VCLXAccessibleToolBoxItem::getAccessibleActionDescription ( sal_Int32 nIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
619 OExternalLockGuard
aGuard( this );
621 if ( nIndex
< 0 || nIndex
>= getAccessibleActionCount() )
622 throw IndexOutOfBoundsException();
624 return OUString( TK_RES_STRING( RID_STR_ACC_ACTION_CLICK
) );
626 // -----------------------------------------------------------------------------
627 Reference
< XAccessibleKeyBinding
> VCLXAccessibleToolBoxItem::getAccessibleActionKeyBinding( sal_Int32 nIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
629 OContextEntryGuard
aGuard( this );
631 if ( nIndex
< 0 || nIndex
>= getAccessibleActionCount() )
632 throw IndexOutOfBoundsException();
634 return Reference
< XAccessibleKeyBinding
>();
636 // -----------------------------------------------------------------------------
638 // -----------------------------------------------------------------------------
639 Any
VCLXAccessibleToolBoxItem::getCurrentValue( ) throw (RuntimeException
)
641 OExternalLockGuard
aGuard( this );
645 aValue
<<= (sal_Int32
)m_pToolBox
->IsItemChecked( m_nItemId
);
649 // -----------------------------------------------------------------------------
650 sal_Bool
VCLXAccessibleToolBoxItem::setCurrentValue( const Any
& aNumber
) throw (RuntimeException
)
652 OExternalLockGuard
aGuard( this );
654 sal_Bool bReturn
= sal_False
;
658 sal_Int32 nValue
= 0;
659 OSL_VERIFY( aNumber
>>= nValue
);
663 else if ( nValue
> 1 )
666 m_pToolBox
->CheckItem( m_nItemId
, (sal_Bool
) nValue
);
672 // -----------------------------------------------------------------------------
673 Any
VCLXAccessibleToolBoxItem::getMaximumValue( ) throw (RuntimeException
)
675 return makeAny((sal_Int32
)1);
677 // -----------------------------------------------------------------------------
678 Any
VCLXAccessibleToolBoxItem::getMinimumValue( ) throw (RuntimeException
)
680 return makeAny((sal_Int32
)0);
682 // -----------------------------------------------------------------------------
685 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */