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