xref: /AOO41X/main/accessibility/source/standard/vclxaccessibletoolboxitem.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
30*cdf0e10cSrcweir #include <accessibility/standard/vclxaccessibletoolboxitem.hxx>
31*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
32*cdf0e10cSrcweir #include <accessibility/helper/accresmgr.hxx>
33*cdf0e10cSrcweir #include <accessibility/helper/accessiblestrings.hrc>
34*cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
43*cdf0e10cSrcweir #include <tools/debug.hxx>
44*cdf0e10cSrcweir #include <vcl/svapp.hxx>
45*cdf0e10cSrcweir #include <vcl/toolbox.hxx>
46*cdf0e10cSrcweir #include <vcl/unohelp2.hxx>
47*cdf0e10cSrcweir #include <vcl/help.hxx>
48*cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx>
49*cdf0e10cSrcweir #include <toolkit/helper/externallock.hxx>
50*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
51*cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx>
52*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
53*cdf0e10cSrcweir #include <comphelper/sequence.hxx>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir // class VCLXAccessibleToolBoxItem ------------------------------------------
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
60*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
61*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
62*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
63*cdf0e10cSrcweir using namespace ::com::sun::star;
64*cdf0e10cSrcweir using namespace ::comphelper;
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir DBG_NAME(VCLXAccessibleToolBoxItem)
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir // -----------------------------------------------------------------------------
69*cdf0e10cSrcweir // Ctor() and Dtor()
70*cdf0e10cSrcweir // -----------------------------------------------------------------------------
71*cdf0e10cSrcweir VCLXAccessibleToolBoxItem::VCLXAccessibleToolBoxItem( ToolBox* _pToolBox, sal_Int32 _nPos ) :
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 	AccessibleTextHelper_BASE( new VCLExternalSolarLock() ),
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 	m_pToolBox		( _pToolBox ),
76*cdf0e10cSrcweir 	m_nIndexInParent( _nPos ),
77*cdf0e10cSrcweir 	m_nRole			( AccessibleRole::PUSH_BUTTON ),
78*cdf0e10cSrcweir 	m_nItemId		( 0 ),
79*cdf0e10cSrcweir 	m_bHasFocus		( sal_False ),
80*cdf0e10cSrcweir 	m_bIsChecked	( sal_False ),
81*cdf0e10cSrcweir     m_bIndeterminate( false )
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir 	DBG_CTOR( VCLXAccessibleToolBoxItem, NULL );
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir 	m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock( ) );
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	DBG_ASSERT( m_pToolBox, "invalid toolbox" );
89*cdf0e10cSrcweir 	m_nItemId = m_pToolBox->GetItemId( (sal_uInt16)m_nIndexInParent );
90*cdf0e10cSrcweir 	m_sOldName = GetText( true );
91*cdf0e10cSrcweir     m_bIsChecked = m_pToolBox->IsItemChecked( m_nItemId );
92*cdf0e10cSrcweir     m_bIndeterminate = ( m_pToolBox->GetItemState( m_nItemId ) == STATE_DONTKNOW );
93*cdf0e10cSrcweir 	ToolBoxItemType eType = m_pToolBox->GetItemType( (sal_uInt16)m_nIndexInParent );
94*cdf0e10cSrcweir 	switch ( eType )
95*cdf0e10cSrcweir 	{
96*cdf0e10cSrcweir 		case TOOLBOXITEM_BUTTON :
97*cdf0e10cSrcweir 		{
98*cdf0e10cSrcweir     		ToolBoxItemBits nBits = m_pToolBox->GetItemBits( m_nItemId );
99*cdf0e10cSrcweir             if (( nBits & TIB_DROPDOWN ) == TIB_DROPDOWN)
100*cdf0e10cSrcweir 				m_nRole	= AccessibleRole::BUTTON_DROPDOWN;
101*cdf0e10cSrcweir 			else if (( ( nBits & TIB_CHECKABLE ) == TIB_CHECKABLE ) ||
102*cdf0e10cSrcweir                 ( ( nBits & TIB_AUTOCHECK ) == TIB_AUTOCHECK ) )
103*cdf0e10cSrcweir 				m_nRole	= AccessibleRole::TOGGLE_BUTTON;
104*cdf0e10cSrcweir 			else if ( m_pToolBox->GetItemWindow( m_nItemId ) )
105*cdf0e10cSrcweir 				m_nRole	= AccessibleRole::PANEL;
106*cdf0e10cSrcweir 			break;
107*cdf0e10cSrcweir 		}
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 		case TOOLBOXITEM_SPACE :
110*cdf0e10cSrcweir 			m_nRole = AccessibleRole::FILLER;
111*cdf0e10cSrcweir 			break;
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 		case TOOLBOXITEM_SEPARATOR :
114*cdf0e10cSrcweir 		case TOOLBOXITEM_BREAK :
115*cdf0e10cSrcweir 			m_nRole = AccessibleRole::SEPARATOR;
116*cdf0e10cSrcweir 			break;
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 		default:
119*cdf0e10cSrcweir 		{
120*cdf0e10cSrcweir 			DBG_ERRORFILE( "unsupported toolbox itemtype" );
121*cdf0e10cSrcweir 		}
122*cdf0e10cSrcweir 	}
123*cdf0e10cSrcweir }
124*cdf0e10cSrcweir // -----------------------------------------------------------------------------
125*cdf0e10cSrcweir VCLXAccessibleToolBoxItem::~VCLXAccessibleToolBoxItem()
126*cdf0e10cSrcweir {
127*cdf0e10cSrcweir 	DBG_DTOR( VCLXAccessibleToolBoxItem, NULL );
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir 	delete m_pExternalLock;
130*cdf0e10cSrcweir 	m_pExternalLock = NULL;
131*cdf0e10cSrcweir }
132*cdf0e10cSrcweir // -----------------------------------------------------------------------------
133*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleToolBoxItem::GetText( bool _bAsName )
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir 	::rtl::OUString sRet;
136*cdf0e10cSrcweir 	// no text for separators and spaces
137*cdf0e10cSrcweir 	if ( m_pToolBox && m_nItemId > 0 && ( _bAsName || m_pToolBox->GetButtonType() != BUTTON_SYMBOL ) )
138*cdf0e10cSrcweir 	{
139*cdf0e10cSrcweir 		sRet = m_pToolBox->GetItemText( m_nItemId );
140*cdf0e10cSrcweir //OJ #108243# we only read the name of the toolboxitem
141*cdf0e10cSrcweir //
142*cdf0e10cSrcweir //		Window* pItemWindow = m_pToolBox->GetItemWindow( m_nItemId );
143*cdf0e10cSrcweir //		if ( pItemWindow && pItemWindow->GetAccessible().is() &&
144*cdf0e10cSrcweir //			 pItemWindow->GetAccessible()->getAccessibleContext().is() )
145*cdf0e10cSrcweir //		{
146*cdf0e10cSrcweir //			::rtl::OUString sWinText = pItemWindow->GetAccessible()->getAccessibleContext()->getAccessibleName();
147*cdf0e10cSrcweir //			if ( ( sRet.getLength() > 0 ) && ( sWinText.getLength() > 0 ) )
148*cdf0e10cSrcweir //				sRet += String( RTL_CONSTASCII_USTRINGPARAM( " " ) );
149*cdf0e10cSrcweir //			sRet += sWinText;
150*cdf0e10cSrcweir //		}
151*cdf0e10cSrcweir 	}
152*cdf0e10cSrcweir 	return sRet;
153*cdf0e10cSrcweir }
154*cdf0e10cSrcweir // -----------------------------------------------------------------------------
155*cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::SetFocus( sal_Bool _bFocus )
156*cdf0e10cSrcweir {
157*cdf0e10cSrcweir 	if ( m_bHasFocus != _bFocus )
158*cdf0e10cSrcweir 	{
159*cdf0e10cSrcweir 		Any aOldValue;
160*cdf0e10cSrcweir 		Any aNewValue;
161*cdf0e10cSrcweir 		if ( m_bHasFocus )
162*cdf0e10cSrcweir 			aOldValue <<= AccessibleStateType::FOCUSED;
163*cdf0e10cSrcweir 		else
164*cdf0e10cSrcweir 			aNewValue <<= AccessibleStateType::FOCUSED;
165*cdf0e10cSrcweir 		m_bHasFocus = _bFocus;
166*cdf0e10cSrcweir  	    NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
167*cdf0e10cSrcweir 	}
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir // -----------------------------------------------------------------------------
170*cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::SetChecked( sal_Bool _bCheck )
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir 	if ( m_bIsChecked != _bCheck )
173*cdf0e10cSrcweir 	{
174*cdf0e10cSrcweir 		Any aOldValue;
175*cdf0e10cSrcweir 		Any aNewValue;
176*cdf0e10cSrcweir 		if ( m_bIsChecked )
177*cdf0e10cSrcweir 			aOldValue <<= AccessibleStateType::CHECKED;
178*cdf0e10cSrcweir 		else
179*cdf0e10cSrcweir 			aNewValue <<= AccessibleStateType::CHECKED;
180*cdf0e10cSrcweir 		m_bIsChecked = _bCheck;
181*cdf0e10cSrcweir 	    NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
182*cdf0e10cSrcweir 	}
183*cdf0e10cSrcweir }
184*cdf0e10cSrcweir // -----------------------------------------------------------------------------
185*cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::SetIndeterminate( bool _bIndeterminate )
186*cdf0e10cSrcweir {
187*cdf0e10cSrcweir 	if ( m_bIndeterminate != _bIndeterminate )
188*cdf0e10cSrcweir 	{
189*cdf0e10cSrcweir 		Any aOldValue, aNewValue;
190*cdf0e10cSrcweir 		if ( m_bIndeterminate )
191*cdf0e10cSrcweir 			aOldValue <<= AccessibleStateType::INDETERMINATE;
192*cdf0e10cSrcweir 		else
193*cdf0e10cSrcweir 			aNewValue <<= AccessibleStateType::INDETERMINATE;
194*cdf0e10cSrcweir 		m_bIndeterminate = _bIndeterminate;
195*cdf0e10cSrcweir 	    NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
196*cdf0e10cSrcweir 	}
197*cdf0e10cSrcweir }
198*cdf0e10cSrcweir // -----------------------------------------------------------------------------
199*cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::NameChanged()
200*cdf0e10cSrcweir {
201*cdf0e10cSrcweir 	::rtl::OUString sNewName = implGetText();
202*cdf0e10cSrcweir 	if ( sNewName != m_sOldName )
203*cdf0e10cSrcweir 	{
204*cdf0e10cSrcweir 		Any aOldValue, aNewValue;
205*cdf0e10cSrcweir 		aOldValue <<= m_sOldName;
206*cdf0e10cSrcweir 		// save new name as old name for next change
207*cdf0e10cSrcweir 		m_sOldName = sNewName;
208*cdf0e10cSrcweir 		aNewValue <<= m_sOldName;
209*cdf0e10cSrcweir 		NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
210*cdf0e10cSrcweir 	}
211*cdf0e10cSrcweir }
212*cdf0e10cSrcweir // -----------------------------------------------------------------------------
213*cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::SetChild( const Reference< XAccessible >& _xChild )
214*cdf0e10cSrcweir {
215*cdf0e10cSrcweir     m_xChild = _xChild;
216*cdf0e10cSrcweir }
217*cdf0e10cSrcweir // -----------------------------------------------------------------------------
218*cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::NotifyChildEvent( const Reference< XAccessible >& _xChild, bool _bShow )
219*cdf0e10cSrcweir {
220*cdf0e10cSrcweir     Any aOld = _bShow ? Any() : makeAny( _xChild );
221*cdf0e10cSrcweir     Any aNew = _bShow ? makeAny( _xChild ) : Any();
222*cdf0e10cSrcweir     NotifyAccessibleEvent( AccessibleEventId::CHILD, aOld, aNew );
223*cdf0e10cSrcweir }
224*cdf0e10cSrcweir // -----------------------------------------------------------------------------
225*cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::ToggleEnableState()
226*cdf0e10cSrcweir {
227*cdf0e10cSrcweir     Any aOldValue[2], aNewValue[2];
228*cdf0e10cSrcweir     if ( m_pToolBox->IsItemEnabled( m_nItemId ) )
229*cdf0e10cSrcweir     {
230*cdf0e10cSrcweir         aNewValue[0] <<= AccessibleStateType::SENSITIVE;
231*cdf0e10cSrcweir         aNewValue[1] <<= AccessibleStateType::ENABLED;
232*cdf0e10cSrcweir     }
233*cdf0e10cSrcweir     else
234*cdf0e10cSrcweir     {
235*cdf0e10cSrcweir         aOldValue[0] <<= AccessibleStateType::ENABLED;
236*cdf0e10cSrcweir         aOldValue[1] <<= AccessibleStateType::SENSITIVE;
237*cdf0e10cSrcweir     }
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir     NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[0], aNewValue[0] );
240*cdf0e10cSrcweir     NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[1], aNewValue[1] );
241*cdf0e10cSrcweir }
242*cdf0e10cSrcweir // -----------------------------------------------------------------------------
243*cdf0e10cSrcweir awt::Rectangle SAL_CALL VCLXAccessibleToolBoxItem::implGetBounds(  ) throw (RuntimeException)
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir 	awt::Rectangle aRect;
246*cdf0e10cSrcweir 	if ( m_pToolBox )
247*cdf0e10cSrcweir 		aRect = AWTRectangle( m_pToolBox->GetItemPosRect( (sal_uInt16)m_nIndexInParent ) );
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir 	return aRect;
250*cdf0e10cSrcweir }
251*cdf0e10cSrcweir // -----------------------------------------------------------------------------
252*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleToolBoxItem::implGetText()
253*cdf0e10cSrcweir {
254*cdf0e10cSrcweir 	return GetText (true);
255*cdf0e10cSrcweir }
256*cdf0e10cSrcweir // -----------------------------------------------------------------------------
257*cdf0e10cSrcweir Locale VCLXAccessibleToolBoxItem::implGetLocale()
258*cdf0e10cSrcweir {
259*cdf0e10cSrcweir 	return Application::GetSettings().GetUILocale();
260*cdf0e10cSrcweir }
261*cdf0e10cSrcweir // -----------------------------------------------------------------------------
262*cdf0e10cSrcweir void VCLXAccessibleToolBoxItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
263*cdf0e10cSrcweir {
264*cdf0e10cSrcweir 	nStartIndex = 0;
265*cdf0e10cSrcweir 	nEndIndex = 0;
266*cdf0e10cSrcweir }
267*cdf0e10cSrcweir // -----------------------------------------------------------------------------
268*cdf0e10cSrcweir // XInterface
269*cdf0e10cSrcweir // -----------------------------------------------------------------------------
270*cdf0e10cSrcweir IMPLEMENT_FORWARD_REFCOUNT( VCLXAccessibleToolBoxItem, AccessibleTextHelper_BASE )
271*cdf0e10cSrcweir Any SAL_CALL VCLXAccessibleToolBoxItem::queryInterface( const Type& _rType ) throw (RuntimeException)
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir 	// --> PB 2004-09-03 #i33611# - toolbox buttons without text don't support XAccessibleText
274*cdf0e10cSrcweir 	if ( _rType == ::getCppuType( ( const Reference< XAccessibleText >* ) 0 )
275*cdf0e10cSrcweir 		&& ( !m_pToolBox || m_pToolBox->GetButtonType() == BUTTON_SYMBOL ) )
276*cdf0e10cSrcweir 		return Any();
277*cdf0e10cSrcweir 	// <--
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir 	::com::sun::star::uno::Any aReturn = AccessibleTextHelper_BASE::queryInterface( _rType );
280*cdf0e10cSrcweir 	if ( !aReturn.hasValue() )
281*cdf0e10cSrcweir 		aReturn = VCLXAccessibleToolBoxItem_BASE::queryInterface( _rType );
282*cdf0e10cSrcweir 	return aReturn;
283*cdf0e10cSrcweir }
284*cdf0e10cSrcweir // -----------------------------------------------------------------------------
285*cdf0e10cSrcweir // XTypeProvider
286*cdf0e10cSrcweir // -----------------------------------------------------------------------------
287*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleToolBoxItem, AccessibleTextHelper_BASE, VCLXAccessibleToolBoxItem_BASE )
288*cdf0e10cSrcweir // -----------------------------------------------------------------------------
289*cdf0e10cSrcweir // XComponent
290*cdf0e10cSrcweir // -----------------------------------------------------------------------------
291*cdf0e10cSrcweir void SAL_CALL VCLXAccessibleToolBoxItem::disposing()
292*cdf0e10cSrcweir {
293*cdf0e10cSrcweir 	AccessibleTextHelper_BASE::disposing();
294*cdf0e10cSrcweir 	m_pToolBox = NULL;
295*cdf0e10cSrcweir }
296*cdf0e10cSrcweir // -----------------------------------------------------------------------------
297*cdf0e10cSrcweir // XServiceInfo
298*cdf0e10cSrcweir // -----------------------------------------------------------------------------
299*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleToolBoxItem::getImplementationName() throw (RuntimeException)
300*cdf0e10cSrcweir {
301*cdf0e10cSrcweir 	return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleToolBoxItem" );
302*cdf0e10cSrcweir }
303*cdf0e10cSrcweir // -----------------------------------------------------------------------------
304*cdf0e10cSrcweir sal_Bool VCLXAccessibleToolBoxItem::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
305*cdf0e10cSrcweir {
306*cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
307*cdf0e10cSrcweir 	const ::rtl::OUString* pNames = aNames.getConstArray();
308*cdf0e10cSrcweir 	const ::rtl::OUString* pEnd = pNames + aNames.getLength();
309*cdf0e10cSrcweir 	for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
310*cdf0e10cSrcweir 		;
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 	return pNames != pEnd;
313*cdf0e10cSrcweir }
314*cdf0e10cSrcweir // -----------------------------------------------------------------------------
315*cdf0e10cSrcweir Sequence< ::rtl::OUString > VCLXAccessibleToolBoxItem::getSupportedServiceNames() throw (RuntimeException)
316*cdf0e10cSrcweir {
317*cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aNames(4);
318*cdf0e10cSrcweir 	aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleContext" );
319*cdf0e10cSrcweir 	aNames[1] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleComponent" );
320*cdf0e10cSrcweir 	aNames[2] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleExtendedComponent" );
321*cdf0e10cSrcweir 	aNames[3] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleToolBoxItem" );
322*cdf0e10cSrcweir 	return aNames;
323*cdf0e10cSrcweir }
324*cdf0e10cSrcweir // -----------------------------------------------------------------------------
325*cdf0e10cSrcweir // XAccessible
326*cdf0e10cSrcweir // -----------------------------------------------------------------------------
327*cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleContext(  ) throw (RuntimeException)
328*cdf0e10cSrcweir {
329*cdf0e10cSrcweir 	return this;
330*cdf0e10cSrcweir }
331*cdf0e10cSrcweir // -----------------------------------------------------------------------------
332*cdf0e10cSrcweir // XAccessibleContext
333*cdf0e10cSrcweir // -----------------------------------------------------------------------------
334*cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleChildCount(  ) throw (RuntimeException)
335*cdf0e10cSrcweir {
336*cdf0e10cSrcweir 	OContextEntryGuard aGuard( this );
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir 	return m_xChild.is() ? 1 : 0;
339*cdf0e10cSrcweir }
340*cdf0e10cSrcweir // -----------------------------------------------------------------------------
341*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleChild( sal_Int32 i ) throw (RuntimeException,  com::sun::star::lang::IndexOutOfBoundsException)
342*cdf0e10cSrcweir {
343*cdf0e10cSrcweir 	OContextEntryGuard aGuard( this );
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 	// no child -> so index is out of bounds
346*cdf0e10cSrcweir 	if ( !m_xChild.is() || i != 0 )
347*cdf0e10cSrcweir 		throw IndexOutOfBoundsException();
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir 	return m_xChild;
350*cdf0e10cSrcweir }
351*cdf0e10cSrcweir // -----------------------------------------------------------------------------
352*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleParent(  ) throw (RuntimeException)
353*cdf0e10cSrcweir {
354*cdf0e10cSrcweir 	OContextEntryGuard aGuard( this );
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir     return m_pToolBox->GetAccessible();
357*cdf0e10cSrcweir }
358*cdf0e10cSrcweir // -----------------------------------------------------------------------------
359*cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleIndexInParent(  ) throw (RuntimeException)
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir 	OContextEntryGuard aGuard( this );
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 	return m_nIndexInParent;
364*cdf0e10cSrcweir }
365*cdf0e10cSrcweir // -----------------------------------------------------------------------------
366*cdf0e10cSrcweir sal_Int16 SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleRole(  ) throw (RuntimeException)
367*cdf0e10cSrcweir {
368*cdf0e10cSrcweir 	OContextEntryGuard aGuard( this );
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir 	return m_nRole;
371*cdf0e10cSrcweir }
372*cdf0e10cSrcweir // -----------------------------------------------------------------------------
373*cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleDescription(  ) throw (RuntimeException)
374*cdf0e10cSrcweir {
375*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir 	::rtl::OUString sDescription;
378*cdf0e10cSrcweir 	if ( m_pToolBox )
379*cdf0e10cSrcweir 		sDescription = m_pToolBox->GetHelpText( m_nItemId );
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 	return sDescription;
382*cdf0e10cSrcweir }
383*cdf0e10cSrcweir // -----------------------------------------------------------------------------
384*cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleName(  ) throw (RuntimeException)
385*cdf0e10cSrcweir {
386*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir 	// entry text == accessible name
389*cdf0e10cSrcweir 	return GetText( true );
390*cdf0e10cSrcweir }
391*cdf0e10cSrcweir // -----------------------------------------------------------------------------
392*cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleRelationSet(  ) throw (RuntimeException)
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir 	OContextEntryGuard aGuard( this );
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir 	utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
397*cdf0e10cSrcweir 	Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
398*cdf0e10cSrcweir     return xSet;
399*cdf0e10cSrcweir }
400*cdf0e10cSrcweir // -----------------------------------------------------------------------------
401*cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleStateSet(  ) throw (RuntimeException)
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir     utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
406*cdf0e10cSrcweir 	Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir 	if ( m_pToolBox && !rBHelper.bDisposed && !rBHelper.bInDispose )
409*cdf0e10cSrcweir 	{
410*cdf0e10cSrcweir         pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
411*cdf0e10cSrcweir 		if ( m_bIsChecked )
412*cdf0e10cSrcweir 	        pStateSetHelper->AddState( AccessibleStateType::CHECKED );
413*cdf0e10cSrcweir         if ( m_bIndeterminate )
414*cdf0e10cSrcweir 	        pStateSetHelper->AddState( AccessibleStateType::INDETERMINATE );
415*cdf0e10cSrcweir 		if ( m_pToolBox->IsItemEnabled( m_nItemId ) )
416*cdf0e10cSrcweir         {
417*cdf0e10cSrcweir             pStateSetHelper->AddState( AccessibleStateType::ENABLED );
418*cdf0e10cSrcweir             pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
419*cdf0e10cSrcweir         }
420*cdf0e10cSrcweir 		if ( m_pToolBox->IsItemVisible( m_nItemId ) )
421*cdf0e10cSrcweir 	        pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
422*cdf0e10cSrcweir         if ( m_pToolBox->IsItemReallyVisible( m_nItemId ) )
423*cdf0e10cSrcweir 			pStateSetHelper->AddState( AccessibleStateType::SHOWING );
424*cdf0e10cSrcweir 		if ( m_bHasFocus )
425*cdf0e10cSrcweir 	        pStateSetHelper->AddState( AccessibleStateType::FOCUSED );
426*cdf0e10cSrcweir 	}
427*cdf0e10cSrcweir 	else
428*cdf0e10cSrcweir         pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir     return xStateSet;
431*cdf0e10cSrcweir }
432*cdf0e10cSrcweir // -----------------------------------------------------------------------------
433*cdf0e10cSrcweir // XAccessibleText
434*cdf0e10cSrcweir // -----------------------------------------------------------------------------
435*cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getCaretPosition() throw (RuntimeException)
436*cdf0e10cSrcweir {
437*cdf0e10cSrcweir 	return -1;
438*cdf0e10cSrcweir }
439*cdf0e10cSrcweir // -----------------------------------------------------------------------------
440*cdf0e10cSrcweir sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
441*cdf0e10cSrcweir {
442*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir     if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
445*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir 	return sal_False;
448*cdf0e10cSrcweir }
449*cdf0e10cSrcweir // -----------------------------------------------------------------------------
450*cdf0e10cSrcweir Sequence< PropertyValue > SAL_CALL VCLXAccessibleToolBoxItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& ) throw (IndexOutOfBoundsException, RuntimeException)
451*cdf0e10cSrcweir {
452*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 	::rtl::OUString sText( implGetText() );
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir     if ( !implIsValidIndex( nIndex, sText.getLength() ) )
457*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir 	return Sequence< PropertyValue >();
460*cdf0e10cSrcweir }
461*cdf0e10cSrcweir // -----------------------------------------------------------------------------
462*cdf0e10cSrcweir awt::Rectangle SAL_CALL VCLXAccessibleToolBoxItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
463*cdf0e10cSrcweir {
464*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
465*cdf0e10cSrcweir 
466*cdf0e10cSrcweir 	::rtl::OUString sText( implGetText() );
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir     if ( !implIsValidIndex( nIndex, sText.getLength() ) )
469*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir 	awt::Rectangle aBounds( 0, 0, 0, 0 );
472*cdf0e10cSrcweir 	if ( m_pToolBox && m_pToolBox->GetButtonType() != BUTTON_SYMBOL ) // symbol buttons have no character bounds
473*cdf0e10cSrcweir 	{
474*cdf0e10cSrcweir 		Rectangle aCharRect = m_pToolBox->GetCharacterBounds( m_nItemId, nIndex );
475*cdf0e10cSrcweir 		Rectangle aItemRect = m_pToolBox->GetItemRect( m_nItemId );
476*cdf0e10cSrcweir 		aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
477*cdf0e10cSrcweir 		aBounds = AWTRectangle( aCharRect );
478*cdf0e10cSrcweir 	}
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir 	return aBounds;
481*cdf0e10cSrcweir }
482*cdf0e10cSrcweir // -----------------------------------------------------------------------------
483*cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
484*cdf0e10cSrcweir {
485*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir 	sal_Int32 nIndex = -1;
488*cdf0e10cSrcweir 	if ( m_pToolBox && m_pToolBox->GetButtonType() != BUTTON_SYMBOL ) // symbol buttons have no character bounds
489*cdf0e10cSrcweir 	{
490*cdf0e10cSrcweir 		sal_uInt16 nItemId = 0;
491*cdf0e10cSrcweir 		Rectangle aItemRect = m_pToolBox->GetItemRect( m_nItemId );
492*cdf0e10cSrcweir 		Point aPnt( VCLPoint( aPoint ) );
493*cdf0e10cSrcweir 		aPnt += aItemRect.TopLeft();
494*cdf0e10cSrcweir 		sal_Int32 nIdx = m_pToolBox->GetIndexForPoint( aPnt, nItemId );
495*cdf0e10cSrcweir 		if ( nIdx != -1 && nItemId == m_nItemId )
496*cdf0e10cSrcweir 			nIndex = nIdx;
497*cdf0e10cSrcweir 	}
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir 	return nIndex;
500*cdf0e10cSrcweir }
501*cdf0e10cSrcweir // -----------------------------------------------------------------------------
502*cdf0e10cSrcweir sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
503*cdf0e10cSrcweir {
504*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir     if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
507*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
508*cdf0e10cSrcweir 
509*cdf0e10cSrcweir 	return sal_False;
510*cdf0e10cSrcweir }
511*cdf0e10cSrcweir // -----------------------------------------------------------------------------
512*cdf0e10cSrcweir sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
513*cdf0e10cSrcweir {
514*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir     if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
517*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir 	if ( m_pToolBox )
522*cdf0e10cSrcweir 	{
523*cdf0e10cSrcweir 		Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pToolBox->GetClipboard();
524*cdf0e10cSrcweir 		if ( xClipboard.is() )
525*cdf0e10cSrcweir 		{
526*cdf0e10cSrcweir 			::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir 			::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
529*cdf0e10cSrcweir 			const sal_uInt32 nRef = Application::ReleaseSolarMutex();
530*cdf0e10cSrcweir 			xClipboard->setContents( pDataObj, NULL );
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir 			Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
533*cdf0e10cSrcweir 			if( xFlushableClipboard.is() )
534*cdf0e10cSrcweir 				xFlushableClipboard->flushClipboard();
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir 			Application::AcquireSolarMutex( nRef );
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir 			bReturn = sal_True;
539*cdf0e10cSrcweir 		}
540*cdf0e10cSrcweir 	}
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 	return bReturn;
543*cdf0e10cSrcweir }
544*cdf0e10cSrcweir // -----------------------------------------------------------------------------
545*cdf0e10cSrcweir // XAccessibleComponent
546*cdf0e10cSrcweir // -----------------------------------------------------------------------------
547*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL VCLXAccessibleToolBoxItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
548*cdf0e10cSrcweir {
549*cdf0e10cSrcweir 	return Reference< XAccessible >();
550*cdf0e10cSrcweir }
551*cdf0e10cSrcweir // -----------------------------------------------------------------------------
552*cdf0e10cSrcweir void SAL_CALL VCLXAccessibleToolBoxItem::grabFocus(  ) throw (RuntimeException)
553*cdf0e10cSrcweir {
554*cdf0e10cSrcweir     Reference< XAccessible > xParent(getAccessibleParent());
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir     if( xParent.is() )
557*cdf0e10cSrcweir     {
558*cdf0e10cSrcweir         Reference< XAccessibleSelection > rxAccessibleSelection(xParent->getAccessibleContext(), UNO_QUERY);
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir         if ( rxAccessibleSelection.is() )
561*cdf0e10cSrcweir         {
562*cdf0e10cSrcweir             rxAccessibleSelection -> selectAccessibleChild ( getAccessibleIndexInParent() );
563*cdf0e10cSrcweir         }
564*cdf0e10cSrcweir     }
565*cdf0e10cSrcweir }
566*cdf0e10cSrcweir // -----------------------------------------------------------------------------
567*cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getForeground(  ) throw (RuntimeException)
568*cdf0e10cSrcweir {
569*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir 	sal_Int32 nColor = 0;
572*cdf0e10cSrcweir 	if ( m_pToolBox )
573*cdf0e10cSrcweir 	   nColor = m_pToolBox->GetControlForeground().GetColor();
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir 	return nColor;
576*cdf0e10cSrcweir }
577*cdf0e10cSrcweir // -----------------------------------------------------------------------------
578*cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleToolBoxItem::getBackground(  ) throw (RuntimeException)
579*cdf0e10cSrcweir {
580*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir 	sal_Int32 nColor = 0;
583*cdf0e10cSrcweir 	if ( m_pToolBox )
584*cdf0e10cSrcweir 	   nColor = m_pToolBox->GetControlBackground().GetColor();
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir 	return nColor;
587*cdf0e10cSrcweir }
588*cdf0e10cSrcweir // -----------------------------------------------------------------------------
589*cdf0e10cSrcweir // XAccessibleExtendedComponent
590*cdf0e10cSrcweir // -----------------------------------------------------------------------------
591*cdf0e10cSrcweir Reference< awt::XFont > SAL_CALL VCLXAccessibleToolBoxItem::getFont(	) throw (RuntimeException)
592*cdf0e10cSrcweir {
593*cdf0e10cSrcweir 	return uno::Reference< awt::XFont >();
594*cdf0e10cSrcweir }
595*cdf0e10cSrcweir // -----------------------------------------------------------------------------
596*cdf0e10cSrcweir awt::FontDescriptor SAL_CALL VCLXAccessibleToolBoxItem::getFontMetrics( const Reference< awt::XFont >& xFont ) throw (RuntimeException)
597*cdf0e10cSrcweir {
598*cdf0e10cSrcweir 	return xFont->getFontDescriptor();
599*cdf0e10cSrcweir }
600*cdf0e10cSrcweir // -----------------------------------------------------------------------------
601*cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleToolBoxItem::getTitledBorderText(  ) throw (RuntimeException)
602*cdf0e10cSrcweir {
603*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir 	::rtl::OUString sRet;
606*cdf0e10cSrcweir 	if ( m_pToolBox )
607*cdf0e10cSrcweir 		sRet = m_pToolBox->GetItemText( m_nItemId );
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir 	return sRet;
610*cdf0e10cSrcweir }
611*cdf0e10cSrcweir // -----------------------------------------------------------------------------
612*cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleToolBoxItem::getToolTipText(  ) throw (RuntimeException)
613*cdf0e10cSrcweir {
614*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir 	::rtl::OUString sRet;
617*cdf0e10cSrcweir 	if ( m_pToolBox )
618*cdf0e10cSrcweir 	{
619*cdf0e10cSrcweir         if ( Help::IsExtHelpEnabled() )
620*cdf0e10cSrcweir             sRet = m_pToolBox->GetHelpText( m_nItemId );
621*cdf0e10cSrcweir         else
622*cdf0e10cSrcweir             sRet = m_pToolBox->GetQuickHelpText( m_nItemId );
623*cdf0e10cSrcweir 		if ( !sRet.getLength() )
624*cdf0e10cSrcweir 			// no help text set, so use item text
625*cdf0e10cSrcweir 			sRet = m_pToolBox->GetItemText( m_nItemId );
626*cdf0e10cSrcweir 	}
627*cdf0e10cSrcweir 	return sRet;
628*cdf0e10cSrcweir }
629*cdf0e10cSrcweir // -----------------------------------------------------------------------------
630*cdf0e10cSrcweir // XAccessibleAction
631*cdf0e10cSrcweir // -----------------------------------------------------------------------------
632*cdf0e10cSrcweir sal_Int32 VCLXAccessibleToolBoxItem::getAccessibleActionCount( ) throw (RuntimeException)
633*cdf0e10cSrcweir {
634*cdf0e10cSrcweir 	// only one action -> "Click"
635*cdf0e10cSrcweir 	return 1;
636*cdf0e10cSrcweir }
637*cdf0e10cSrcweir // -----------------------------------------------------------------------------
638*cdf0e10cSrcweir sal_Bool VCLXAccessibleToolBoxItem::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
639*cdf0e10cSrcweir {
640*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir 	if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
643*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir 	if ( m_pToolBox )
646*cdf0e10cSrcweir 		m_pToolBox->TriggerItem( m_nItemId );
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir 	return sal_True;
649*cdf0e10cSrcweir }
650*cdf0e10cSrcweir // -----------------------------------------------------------------------------
651*cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleToolBoxItem::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
652*cdf0e10cSrcweir {
653*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir 	if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
656*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir 	return ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_CLICK ) );
659*cdf0e10cSrcweir }
660*cdf0e10cSrcweir // -----------------------------------------------------------------------------
661*cdf0e10cSrcweir Reference< XAccessibleKeyBinding > VCLXAccessibleToolBoxItem::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
662*cdf0e10cSrcweir {
663*cdf0e10cSrcweir 	OContextEntryGuard aGuard( this );
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir 	if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
666*cdf0e10cSrcweir         throw IndexOutOfBoundsException();
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir 	return Reference< XAccessibleKeyBinding >();
669*cdf0e10cSrcweir }
670*cdf0e10cSrcweir // -----------------------------------------------------------------------------
671*cdf0e10cSrcweir // XAccessibleValue
672*cdf0e10cSrcweir // -----------------------------------------------------------------------------
673*cdf0e10cSrcweir Any VCLXAccessibleToolBoxItem::getCurrentValue(  ) throw (RuntimeException)
674*cdf0e10cSrcweir {
675*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir 	Any aValue;
678*cdf0e10cSrcweir 	if ( m_pToolBox )
679*cdf0e10cSrcweir 		aValue <<= (sal_Int32)m_pToolBox->IsItemChecked( m_nItemId );
680*cdf0e10cSrcweir 
681*cdf0e10cSrcweir 	return aValue;
682*cdf0e10cSrcweir }
683*cdf0e10cSrcweir // -----------------------------------------------------------------------------
684*cdf0e10cSrcweir sal_Bool VCLXAccessibleToolBoxItem::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
685*cdf0e10cSrcweir {
686*cdf0e10cSrcweir 	OExternalLockGuard aGuard( this );
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 	sal_Bool bReturn = sal_False;
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir 	if ( m_pToolBox )
691*cdf0e10cSrcweir 	{
692*cdf0e10cSrcweir 		sal_Int32 nValue = 0;
693*cdf0e10cSrcweir 		OSL_VERIFY( aNumber >>= nValue );
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir 		if ( nValue < 0 )
696*cdf0e10cSrcweir 			nValue = 0;
697*cdf0e10cSrcweir 		else if ( nValue > 1 )
698*cdf0e10cSrcweir 			nValue = 1;
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir 		m_pToolBox->CheckItem( m_nItemId, (sal_Bool) nValue );
701*cdf0e10cSrcweir 		bReturn = sal_True;
702*cdf0e10cSrcweir 	}
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir 	return bReturn;
705*cdf0e10cSrcweir }
706*cdf0e10cSrcweir // -----------------------------------------------------------------------------
707*cdf0e10cSrcweir Any VCLXAccessibleToolBoxItem::getMaximumValue(  ) throw (RuntimeException)
708*cdf0e10cSrcweir {
709*cdf0e10cSrcweir 	return makeAny((sal_Int32)1);
710*cdf0e10cSrcweir }
711*cdf0e10cSrcweir // -----------------------------------------------------------------------------
712*cdf0e10cSrcweir Any VCLXAccessibleToolBoxItem::getMinimumValue(  ) throw (RuntimeException)
713*cdf0e10cSrcweir {
714*cdf0e10cSrcweir 	return makeAny((sal_Int32)0);
715*cdf0e10cSrcweir }
716*cdf0e10cSrcweir // -----------------------------------------------------------------------------
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir 
719