10841af79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
30841af79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
40841af79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
50841af79SAndrew Rist  * distributed with this work for additional information
60841af79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
70841af79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
80841af79SAndrew Rist  * "License"); you may not use this file except in compliance
90841af79SAndrew Rist  * with the License.  You may obtain a copy of the License at
100841af79SAndrew Rist  *
110841af79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
120841af79SAndrew Rist  *
130841af79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
140841af79SAndrew Rist  * software distributed under the License is distributed on an
150841af79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
160841af79SAndrew Rist  * KIND, either express or implied.  See the License for the
170841af79SAndrew Rist  * specific language governing permissions and limitations
180841af79SAndrew Rist  * under the License.
190841af79SAndrew Rist  *
200841af79SAndrew Rist  *************************************************************/
210841af79SAndrew Rist 
220841af79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
26cdf0e10cSrcweir #include <accessibility/standard/vclxaccessiblelistitem.hxx>
27cdf0e10cSrcweir #include <toolkit/helper/convert.hxx>
28cdf0e10cSrcweir #include <accessibility/helper/listboxhelper.hxx>
29cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
30cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
31cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
34cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
35cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
36cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
37cdf0e10cSrcweir #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
38cdf0e10cSrcweir #include <tools/debug.hxx>
39cdf0e10cSrcweir #include <vcl/svapp.hxx>
40cdf0e10cSrcweir #include <vcl/controllayout.hxx>
41cdf0e10cSrcweir #include <vcl/unohelp2.hxx>
42cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx>
43cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
44cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx>
45cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
46cdf0e10cSrcweir #include <comphelper/sequence.hxx>
47cdf0e10cSrcweir #include <comphelper/accessibleeventnotifier.hxx>
48cdf0e10cSrcweir 
49cdf0e10cSrcweir namespace
50cdf0e10cSrcweir {
checkIndex_Impl(sal_Int32 _nIndex,const::rtl::OUString & _sText)51cdf0e10cSrcweir 	void checkIndex_Impl( sal_Int32 _nIndex, const ::rtl::OUString& _sText ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
52cdf0e10cSrcweir 	{
53cdf0e10cSrcweir 		if ( _nIndex < 0 || _nIndex > _sText.getLength() )
54cdf0e10cSrcweir 			throw ::com::sun::star::lang::IndexOutOfBoundsException();
55cdf0e10cSrcweir 	}
56cdf0e10cSrcweir }
57cdf0e10cSrcweir 
58cdf0e10cSrcweir // class VCLXAccessibleListItem ------------------------------------------
59cdf0e10cSrcweir 
60cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
61cdf0e10cSrcweir using namespace ::com::sun::star::uno;
62cdf0e10cSrcweir using namespace ::com::sun::star::beans;
63cdf0e10cSrcweir using namespace ::com::sun::star::lang;
64cdf0e10cSrcweir using namespace ::com::sun::star;
65cdf0e10cSrcweir 
DBG_NAME(VCLXAccessibleListItem)66cdf0e10cSrcweir DBG_NAME(VCLXAccessibleListItem)
67cdf0e10cSrcweir 
68cdf0e10cSrcweir // -----------------------------------------------------------------------------
69cdf0e10cSrcweir // Ctor() and Dtor()
70cdf0e10cSrcweir // -----------------------------------------------------------------------------
71cdf0e10cSrcweir VCLXAccessibleListItem::VCLXAccessibleListItem( ::accessibility::IComboListBoxHelper* _pListBoxHelper, sal_Int32 _nIndexInParent, const Reference< XAccessible >& _xParent ) :
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	VCLXAccessibleListItem_BASE	( m_aMutex ),
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	m_nIndexInParent( _nIndexInParent ),
76cdf0e10cSrcweir 	m_bSelected		( sal_False ),
77cdf0e10cSrcweir 	m_bVisible		( sal_False ),
78cdf0e10cSrcweir     m_nClientId     ( 0 ),
79cdf0e10cSrcweir 	m_pListBoxHelper( _pListBoxHelper ),
80cdf0e10cSrcweir 	m_xParent		( _xParent )
81cdf0e10cSrcweir 
82cdf0e10cSrcweir {
83cdf0e10cSrcweir 	DBG_CTOR( VCLXAccessibleListItem, NULL );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	if ( m_xParent.is() )
86cdf0e10cSrcweir 		m_xParentContext = m_xParent->getAccessibleContext();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	if ( m_pListBoxHelper )
89cdf0e10cSrcweir 		m_sEntryText = m_pListBoxHelper->GetEntry( (sal_uInt16)_nIndexInParent );
90cdf0e10cSrcweir }
91cdf0e10cSrcweir // -----------------------------------------------------------------------------
~VCLXAccessibleListItem()92cdf0e10cSrcweir VCLXAccessibleListItem::~VCLXAccessibleListItem()
93cdf0e10cSrcweir {
94cdf0e10cSrcweir 	DBG_DTOR( VCLXAccessibleListItem, NULL );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir // -----------------------------------------------------------------------------
SetSelected(sal_Bool _bSelected)97cdf0e10cSrcweir void VCLXAccessibleListItem::SetSelected( sal_Bool _bSelected )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	if ( m_bSelected != _bSelected )
100cdf0e10cSrcweir 	{
101cdf0e10cSrcweir 		Any aOldValue;
102cdf0e10cSrcweir 		Any aNewValue;
103cdf0e10cSrcweir 		if ( m_bSelected )
104cdf0e10cSrcweir 			aOldValue <<= AccessibleStateType::SELECTED;
105cdf0e10cSrcweir 		else
106cdf0e10cSrcweir 			aNewValue <<= AccessibleStateType::SELECTED;
107cdf0e10cSrcweir 		m_bSelected = _bSelected;
108cdf0e10cSrcweir         NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
109cdf0e10cSrcweir 	}
110cdf0e10cSrcweir }
111cdf0e10cSrcweir // -----------------------------------------------------------------------------
SetVisible(sal_Bool _bVisible)112cdf0e10cSrcweir void VCLXAccessibleListItem::SetVisible( sal_Bool _bVisible )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir 	if ( m_bVisible != _bVisible )
115cdf0e10cSrcweir 	{
116cdf0e10cSrcweir 		Any aOldValue, aNewValue;
117cdf0e10cSrcweir 		m_bVisible = _bVisible;
118cdf0e10cSrcweir 		(_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::VISIBLE;
119cdf0e10cSrcweir 		NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
120cdf0e10cSrcweir 		(_bVisible ? aNewValue : aOldValue ) <<= AccessibleStateType::SHOWING;
121cdf0e10cSrcweir 		NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
122cdf0e10cSrcweir 	}
123cdf0e10cSrcweir }
124cdf0e10cSrcweir // -----------------------------------------------------------------------------
NotifyAccessibleEvent(sal_Int16 _nEventId,const::com::sun::star::uno::Any & _aOldValue,const::com::sun::star::uno::Any & _aNewValue)125cdf0e10cSrcweir void VCLXAccessibleListItem::NotifyAccessibleEvent( sal_Int16 _nEventId,
126cdf0e10cSrcweir 													const ::com::sun::star::uno::Any& _aOldValue,
127cdf0e10cSrcweir 													const ::com::sun::star::uno::Any& _aNewValue )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	AccessibleEventObject aEvt;
130cdf0e10cSrcweir 	aEvt.Source = *this;
131cdf0e10cSrcweir 	aEvt.EventId = _nEventId;
132cdf0e10cSrcweir     aEvt.OldValue = _aOldValue;
133cdf0e10cSrcweir     aEvt.NewValue = _aNewValue;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	if (m_nClientId)
136cdf0e10cSrcweir 		comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEvt );
137cdf0e10cSrcweir }
138cdf0e10cSrcweir // -----------------------------------------------------------------------------
139cdf0e10cSrcweir // OCommonAccessibleText
140cdf0e10cSrcweir // -----------------------------------------------------------------------------
implGetText()141cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleListItem::implGetText()
142cdf0e10cSrcweir {
143cdf0e10cSrcweir 	return m_sEntryText;
144cdf0e10cSrcweir }
145cdf0e10cSrcweir // -----------------------------------------------------------------------------
implGetLocale()146cdf0e10cSrcweir Locale VCLXAccessibleListItem::implGetLocale()
147cdf0e10cSrcweir {
148cdf0e10cSrcweir 	return Application::GetSettings().GetLocale();
149cdf0e10cSrcweir }
150cdf0e10cSrcweir // -----------------------------------------------------------------------------
implGetSelection(sal_Int32 & nStartIndex,sal_Int32 & nEndIndex)151cdf0e10cSrcweir void VCLXAccessibleListItem::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
152cdf0e10cSrcweir {
153cdf0e10cSrcweir 	nStartIndex = 0;
154cdf0e10cSrcweir 	nEndIndex = 0;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir // -----------------------------------------------------------------------------
157cdf0e10cSrcweir // XInterface
158cdf0e10cSrcweir // -----------------------------------------------------------------------------
queryInterface(Type const & rType)159cdf0e10cSrcweir Any SAL_CALL VCLXAccessibleListItem::queryInterface( Type const & rType ) throw (RuntimeException)
160cdf0e10cSrcweir {
161cdf0e10cSrcweir 	return VCLXAccessibleListItem_BASE::queryInterface( rType );
162cdf0e10cSrcweir }
163cdf0e10cSrcweir // -----------------------------------------------------------------------------
acquire()164cdf0e10cSrcweir void SAL_CALL VCLXAccessibleListItem::acquire() throw ()
165cdf0e10cSrcweir {
166cdf0e10cSrcweir 	VCLXAccessibleListItem_BASE::acquire();
167cdf0e10cSrcweir }
168cdf0e10cSrcweir // -----------------------------------------------------------------------------
release()169cdf0e10cSrcweir void SAL_CALL VCLXAccessibleListItem::release() throw ()
170cdf0e10cSrcweir {
171cdf0e10cSrcweir 	VCLXAccessibleListItem_BASE::release();
172cdf0e10cSrcweir }
173cdf0e10cSrcweir // -----------------------------------------------------------------------------
174cdf0e10cSrcweir // XTypeProvider
175cdf0e10cSrcweir // -----------------------------------------------------------------------------
getTypes()176cdf0e10cSrcweir Sequence< Type > SAL_CALL VCLXAccessibleListItem::getTypes(  ) throw (RuntimeException)
177cdf0e10cSrcweir {
178cdf0e10cSrcweir 	return VCLXAccessibleListItem_BASE::getTypes();
179cdf0e10cSrcweir }
180cdf0e10cSrcweir // -----------------------------------------------------------------------------
getImplementationId()181cdf0e10cSrcweir Sequence< sal_Int8 > VCLXAccessibleListItem::getImplementationId() throw (RuntimeException)
182cdf0e10cSrcweir {
183cdf0e10cSrcweir 	static ::cppu::OImplementationId* pId = NULL;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	if ( !pId )
186cdf0e10cSrcweir 	{
187cdf0e10cSrcweir 		::osl::Guard< ::osl::Mutex > aGuard( m_aMutex );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 		if ( !pId )
190cdf0e10cSrcweir 		{
191cdf0e10cSrcweir 			static ::cppu::OImplementationId aId;
192cdf0e10cSrcweir 			pId = &aId;
193cdf0e10cSrcweir 		}
194cdf0e10cSrcweir 	}
195cdf0e10cSrcweir 	return pId->getImplementationId();
196cdf0e10cSrcweir }
197cdf0e10cSrcweir // -----------------------------------------------------------------------------
198cdf0e10cSrcweir // XComponent
199cdf0e10cSrcweir // -----------------------------------------------------------------------------
disposing()200cdf0e10cSrcweir void SAL_CALL VCLXAccessibleListItem::disposing()
201cdf0e10cSrcweir {
202cdf0e10cSrcweir 	comphelper::AccessibleEventNotifier::TClientId nId( 0 );
203cdf0e10cSrcweir 	Reference< XInterface > xEventSource;
204cdf0e10cSrcweir 	{
205cdf0e10cSrcweir 		::osl::MutexGuard aGuard( m_aMutex );
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 		VCLXAccessibleListItem_BASE::disposing();
208cdf0e10cSrcweir 		m_sEntryText		= ::rtl::OUString();
209cdf0e10cSrcweir 		m_pListBoxHelper	= NULL;
210cdf0e10cSrcweir 		m_xParent			= NULL;
211cdf0e10cSrcweir 		m_xParentContext	= NULL;
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 		nId = m_nClientId;
214cdf0e10cSrcweir 		m_nClientId =  0;
215cdf0e10cSrcweir 		if ( nId )
216cdf0e10cSrcweir 			xEventSource = *this;
217cdf0e10cSrcweir 	}
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     // Send a disposing to all listeners.
220cdf0e10cSrcweir 	if ( nId )
221cdf0e10cSrcweir         	comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this );
222cdf0e10cSrcweir }
223cdf0e10cSrcweir // -----------------------------------------------------------------------------
224cdf0e10cSrcweir // XServiceInfo
225cdf0e10cSrcweir // -----------------------------------------------------------------------------
getImplementationName()226cdf0e10cSrcweir ::rtl::OUString VCLXAccessibleListItem::getImplementationName() throw (RuntimeException)
227cdf0e10cSrcweir {
228cdf0e10cSrcweir 	return ::rtl::OUString::createFromAscii( "com.sun.star.comp.toolkit.AccessibleListItem" );
229cdf0e10cSrcweir }
230cdf0e10cSrcweir // -----------------------------------------------------------------------------
supportsService(const::rtl::OUString & rServiceName)231cdf0e10cSrcweir sal_Bool VCLXAccessibleListItem::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
232cdf0e10cSrcweir {
233cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
234cdf0e10cSrcweir 	const ::rtl::OUString* pNames = aNames.getConstArray();
235cdf0e10cSrcweir 	const ::rtl::OUString* pEnd = pNames + aNames.getLength();
236cdf0e10cSrcweir 	for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
237cdf0e10cSrcweir 		;
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 	return pNames != pEnd;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSupportedServiceNames()242cdf0e10cSrcweir Sequence< ::rtl::OUString > VCLXAccessibleListItem::getSupportedServiceNames() throw (RuntimeException)
243cdf0e10cSrcweir {
244cdf0e10cSrcweir 	Sequence< ::rtl::OUString > aNames(3);
245cdf0e10cSrcweir 	aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleContext" );
246cdf0e10cSrcweir 	aNames[1] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleComponent" );
247cdf0e10cSrcweir 	aNames[2] = ::rtl::OUString::createFromAscii( "com.sun.star.accessibility.AccessibleListItem" );
248cdf0e10cSrcweir 	return aNames;
249cdf0e10cSrcweir }
250cdf0e10cSrcweir // -----------------------------------------------------------------------------
251cdf0e10cSrcweir // XAccessible
252cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleContext()253cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL VCLXAccessibleListItem::getAccessibleContext(  ) throw (RuntimeException)
254cdf0e10cSrcweir {
255cdf0e10cSrcweir 	return this;
256cdf0e10cSrcweir }
257cdf0e10cSrcweir // -----------------------------------------------------------------------------
258cdf0e10cSrcweir // XAccessibleContext
259cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleChildCount()260cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleChildCount(  ) throw (RuntimeException)
261cdf0e10cSrcweir {
262cdf0e10cSrcweir 	return 0;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleChild(sal_Int32)265cdf0e10cSrcweir Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleChild( sal_Int32 ) throw (RuntimeException)
266cdf0e10cSrcweir {
267cdf0e10cSrcweir 	return Reference< XAccessible >();
268cdf0e10cSrcweir }
269cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleParent()270cdf0e10cSrcweir Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleParent(  ) throw (RuntimeException)
271cdf0e10cSrcweir {
272cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 	return m_xParent;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleIndexInParent()277cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleListItem::getAccessibleIndexInParent(  ) throw (RuntimeException)
278cdf0e10cSrcweir {
279cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
280cdf0e10cSrcweir 	return m_nIndexInParent;
281cdf0e10cSrcweir }
282cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleRole()283cdf0e10cSrcweir sal_Int16 SAL_CALL VCLXAccessibleListItem::getAccessibleRole(  ) throw (RuntimeException)
284cdf0e10cSrcweir {
285cdf0e10cSrcweir 	return AccessibleRole::LIST_ITEM;
286cdf0e10cSrcweir     //	return AccessibleRole::LABEL;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleDescription()289cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getAccessibleDescription(  ) throw (RuntimeException)
290cdf0e10cSrcweir {
291cdf0e10cSrcweir 	// no description for every item
292cdf0e10cSrcweir 	return ::rtl::OUString();
293cdf0e10cSrcweir }
294cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleName()295cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getAccessibleName(  ) throw (RuntimeException)
296cdf0e10cSrcweir {
297cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 	// entry text == accessible name
300cdf0e10cSrcweir 	return implGetText();
301cdf0e10cSrcweir }
302cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleRelationSet()303cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL VCLXAccessibleListItem::getAccessibleRelationSet(  ) throw (RuntimeException)
304cdf0e10cSrcweir {
305cdf0e10cSrcweir     utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
306cdf0e10cSrcweir 	Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
307cdf0e10cSrcweir     return xSet;
308cdf0e10cSrcweir }
309cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleStateSet()310cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL VCLXAccessibleListItem::getAccessibleStateSet(  ) throw (RuntimeException)
311cdf0e10cSrcweir {
312cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
313cdf0e10cSrcweir 
314cdf0e10cSrcweir     utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
315cdf0e10cSrcweir 	Reference< XAccessibleStateSet > xStateSet = pStateSetHelper;
316cdf0e10cSrcweir 
317cdf0e10cSrcweir 	if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
318cdf0e10cSrcweir 	{
319cdf0e10cSrcweir         pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
320*21075d77SSteve Yin 
321*21075d77SSteve Yin 		if(m_pListBoxHelper->IsEnabled())
322*21075d77SSteve Yin 		{
323*21075d77SSteve Yin 	    	pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
324*21075d77SSteve Yin 	    	pStateSetHelper->AddState( AccessibleStateType::ENABLED );
325*21075d77SSteve Yin 	    	pStateSetHelper->AddState( AccessibleStateType::SENSITIVE );
326*21075d77SSteve Yin 		}
327*21075d77SSteve Yin 
328cdf0e10cSrcweir         if ( m_bSelected )
329cdf0e10cSrcweir 			pStateSetHelper->AddState( AccessibleStateType::SELECTED );
330cdf0e10cSrcweir 		if ( m_bVisible )
331cdf0e10cSrcweir 		{
332cdf0e10cSrcweir 			pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
333cdf0e10cSrcweir 			pStateSetHelper->AddState( AccessibleStateType::SHOWING );
334cdf0e10cSrcweir 		}
335cdf0e10cSrcweir 	}
336cdf0e10cSrcweir 	else
337cdf0e10cSrcweir         pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
338cdf0e10cSrcweir 
339cdf0e10cSrcweir     return xStateSet;
340cdf0e10cSrcweir }
341cdf0e10cSrcweir // -----------------------------------------------------------------------------
getLocale()342cdf0e10cSrcweir Locale SAL_CALL VCLXAccessibleListItem::getLocale(  ) throw (IllegalAccessibleComponentStateException, RuntimeException)
343cdf0e10cSrcweir {
344cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
345cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
346cdf0e10cSrcweir 
347cdf0e10cSrcweir     return implGetLocale();
348cdf0e10cSrcweir }
349cdf0e10cSrcweir // -----------------------------------------------------------------------------
350cdf0e10cSrcweir // XAccessibleComponent
351cdf0e10cSrcweir // -----------------------------------------------------------------------------
containsPoint(const awt::Point & _aPoint)352cdf0e10cSrcweir sal_Bool SAL_CALL VCLXAccessibleListItem::containsPoint( const awt::Point& _aPoint ) throw (RuntimeException)
353cdf0e10cSrcweir {
354cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
355cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 	sal_Bool bInside = sal_False;
358cdf0e10cSrcweir 	if ( m_pListBoxHelper )
359cdf0e10cSrcweir 	{
360cdf0e10cSrcweir 		Rectangle aRect( m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ) );
361cdf0e10cSrcweir 		aRect.Move(-aRect.TopLeft().X(),-aRect.TopLeft().Y());
362cdf0e10cSrcweir 		bInside = aRect.IsInside( VCLPoint( _aPoint ) );
363cdf0e10cSrcweir 	}
364cdf0e10cSrcweir 	return bInside;
365cdf0e10cSrcweir }
366cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleAtPoint(const awt::Point &)367cdf0e10cSrcweir Reference< XAccessible > SAL_CALL VCLXAccessibleListItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
368cdf0e10cSrcweir {
369cdf0e10cSrcweir 	return Reference< XAccessible >();
370cdf0e10cSrcweir }
371cdf0e10cSrcweir // -----------------------------------------------------------------------------
getBounds()372cdf0e10cSrcweir awt::Rectangle SAL_CALL VCLXAccessibleListItem::getBounds(  ) throw (RuntimeException)
373cdf0e10cSrcweir {
374cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
375cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
376cdf0e10cSrcweir 
377cdf0e10cSrcweir 	awt::Rectangle aRect;
378cdf0e10cSrcweir 	if ( m_pListBoxHelper )
379cdf0e10cSrcweir 		aRect = AWTRectangle( m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ) );
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	return aRect;
382cdf0e10cSrcweir }
383cdf0e10cSrcweir // -----------------------------------------------------------------------------
getLocation()384cdf0e10cSrcweir awt::Point SAL_CALL VCLXAccessibleListItem::getLocation(  ) throw (RuntimeException)
385cdf0e10cSrcweir {
386cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
387cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 	Point aPoint(0,0);
390cdf0e10cSrcweir 	if ( m_pListBoxHelper )
391cdf0e10cSrcweir 	{
392cdf0e10cSrcweir 		Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
393cdf0e10cSrcweir 		aPoint = aRect.TopLeft();
394cdf0e10cSrcweir 	}
395cdf0e10cSrcweir 	return AWTPoint( aPoint );
396cdf0e10cSrcweir }
397cdf0e10cSrcweir // -----------------------------------------------------------------------------
getLocationOnScreen()398cdf0e10cSrcweir awt::Point SAL_CALL VCLXAccessibleListItem::getLocationOnScreen(  ) throw (RuntimeException)
399cdf0e10cSrcweir {
400cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
401cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 	Point aPoint(0,0);
404cdf0e10cSrcweir 	if ( m_pListBoxHelper )
405cdf0e10cSrcweir 	{
406cdf0e10cSrcweir 		Rectangle aRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
407cdf0e10cSrcweir 		aPoint = aRect.TopLeft();
408cdf0e10cSrcweir 		aPoint += m_pListBoxHelper->GetWindowExtentsRelative( NULL ).TopLeft();
409cdf0e10cSrcweir 	}
410cdf0e10cSrcweir 	return AWTPoint( aPoint );
411cdf0e10cSrcweir }
412cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSize()413cdf0e10cSrcweir awt::Size SAL_CALL VCLXAccessibleListItem::getSize(  ) throw (RuntimeException)
414cdf0e10cSrcweir {
415cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
416cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 	Size aSize;
419cdf0e10cSrcweir 	if ( m_pListBoxHelper )
420cdf0e10cSrcweir 		aSize = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent ).GetSize();
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 	return AWTSize( aSize );
423cdf0e10cSrcweir }
424cdf0e10cSrcweir // -----------------------------------------------------------------------------
grabFocus()425cdf0e10cSrcweir void SAL_CALL VCLXAccessibleListItem::grabFocus(  ) throw (RuntimeException)
426cdf0e10cSrcweir {
427cdf0e10cSrcweir 	// no focus for each item
428cdf0e10cSrcweir }
429cdf0e10cSrcweir // -----------------------------------------------------------------------------
430cdf0e10cSrcweir // XAccessibleText
431cdf0e10cSrcweir // -----------------------------------------------------------------------------
getCaretPosition()432cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleListItem::getCaretPosition() throw (RuntimeException)
433cdf0e10cSrcweir {
434cdf0e10cSrcweir 	return -1;
435cdf0e10cSrcweir }
436cdf0e10cSrcweir // -----------------------------------------------------------------------------
setCaretPosition(sal_Int32 nIndex)437cdf0e10cSrcweir sal_Bool SAL_CALL VCLXAccessibleListItem::setCaretPosition( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
438cdf0e10cSrcweir {
439cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
440cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
441cdf0e10cSrcweir 
442cdf0e10cSrcweir     if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
443cdf0e10cSrcweir         throw IndexOutOfBoundsException();
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 	return sal_False;
446cdf0e10cSrcweir }
447cdf0e10cSrcweir // -----------------------------------------------------------------------------
getCharacter(sal_Int32 nIndex)448cdf0e10cSrcweir sal_Unicode SAL_CALL VCLXAccessibleListItem::getCharacter( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
449cdf0e10cSrcweir {
450cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
451cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 	return OCommonAccessibleText::getCharacter( nIndex );
454cdf0e10cSrcweir }
455cdf0e10cSrcweir // -----------------------------------------------------------------------------
getCharacterAttributes(sal_Int32 nIndex,const Sequence<::rtl::OUString> &)456cdf0e10cSrcweir Sequence< PropertyValue > SAL_CALL VCLXAccessibleListItem::getCharacterAttributes( sal_Int32 nIndex, const Sequence< ::rtl::OUString >& ) throw (IndexOutOfBoundsException, RuntimeException)
457cdf0e10cSrcweir {
458cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
459cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
460cdf0e10cSrcweir 
461cdf0e10cSrcweir 	::rtl::OUString sText( implGetText() );
462cdf0e10cSrcweir     if ( !implIsValidIndex( nIndex, sText.getLength() ) )
463cdf0e10cSrcweir         throw IndexOutOfBoundsException();
464cdf0e10cSrcweir 
465cdf0e10cSrcweir 	return Sequence< PropertyValue >();
466cdf0e10cSrcweir }
467cdf0e10cSrcweir // -----------------------------------------------------------------------------
getCharacterBounds(sal_Int32 nIndex)468cdf0e10cSrcweir awt::Rectangle SAL_CALL VCLXAccessibleListItem::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
469cdf0e10cSrcweir {
470cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
471cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
472cdf0e10cSrcweir 
473cdf0e10cSrcweir 	::rtl::OUString sText( implGetText() );
474cdf0e10cSrcweir     if ( !implIsValidIndex( nIndex, sText.getLength() ) )
475cdf0e10cSrcweir         throw IndexOutOfBoundsException();
476cdf0e10cSrcweir 
477cdf0e10cSrcweir 	awt::Rectangle aBounds( 0, 0, 0, 0 );
478cdf0e10cSrcweir 	if ( m_pListBoxHelper )
479cdf0e10cSrcweir 	{
480cdf0e10cSrcweir 		Rectangle aCharRect = m_pListBoxHelper->GetEntryCharacterBounds( m_nIndexInParent, nIndex );
481cdf0e10cSrcweir 		Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
482cdf0e10cSrcweir 		aCharRect.Move( -aItemRect.Left(), -aItemRect.Top() );
483cdf0e10cSrcweir 		aBounds = AWTRectangle( aCharRect );
484cdf0e10cSrcweir 	}
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 	return aBounds;
487cdf0e10cSrcweir }
488cdf0e10cSrcweir // -----------------------------------------------------------------------------
getCharacterCount()489cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleListItem::getCharacterCount() throw (RuntimeException)
490cdf0e10cSrcweir {
491cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
492cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
493cdf0e10cSrcweir 
494cdf0e10cSrcweir 	return OCommonAccessibleText::getCharacterCount();
495cdf0e10cSrcweir }
496cdf0e10cSrcweir // -----------------------------------------------------------------------------
getIndexAtPoint(const awt::Point & aPoint)497cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleListItem::getIndexAtPoint( const awt::Point& aPoint ) throw (RuntimeException)
498cdf0e10cSrcweir {
499cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
500cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 	sal_Int32 nIndex = -1;
503cdf0e10cSrcweir 	if ( m_pListBoxHelper )
504cdf0e10cSrcweir 	{
505cdf0e10cSrcweir         sal_uInt16 nPos = LISTBOX_ENTRY_NOTFOUND;
506cdf0e10cSrcweir         Rectangle aItemRect = m_pListBoxHelper->GetBoundingRectangle( (sal_uInt16)m_nIndexInParent );
507cdf0e10cSrcweir 		Point aPnt( VCLPoint( aPoint ) );
508cdf0e10cSrcweir 		aPnt += aItemRect.TopLeft();
509cdf0e10cSrcweir         sal_Int32 nI = m_pListBoxHelper->GetIndexForPoint( aPnt, nPos );
510cdf0e10cSrcweir         if ( nI != -1 && (sal_uInt16)m_nIndexInParent == nPos )
511cdf0e10cSrcweir             nIndex = nI;
512cdf0e10cSrcweir 	}
513cdf0e10cSrcweir     return nIndex;
514cdf0e10cSrcweir }
515cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSelectedText()516cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getSelectedText() throw (RuntimeException)
517cdf0e10cSrcweir {
518cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
519cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
520cdf0e10cSrcweir 
521cdf0e10cSrcweir 	return OCommonAccessibleText::getSelectedText();
522cdf0e10cSrcweir }
523cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSelectionStart()524cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionStart() throw (RuntimeException)
525cdf0e10cSrcweir {
526cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
527cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 	return OCommonAccessibleText::getSelectionStart();
530cdf0e10cSrcweir }
531cdf0e10cSrcweir // -----------------------------------------------------------------------------
getSelectionEnd()532cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleListItem::getSelectionEnd() throw (RuntimeException)
533cdf0e10cSrcweir {
534cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
535cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 	return OCommonAccessibleText::getSelectionEnd();
538cdf0e10cSrcweir }
539cdf0e10cSrcweir // -----------------------------------------------------------------------------
setSelection(sal_Int32 nStartIndex,sal_Int32 nEndIndex)540cdf0e10cSrcweir sal_Bool SAL_CALL VCLXAccessibleListItem::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
541cdf0e10cSrcweir {
542cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
543cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
544cdf0e10cSrcweir 
545cdf0e10cSrcweir     if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
546cdf0e10cSrcweir         throw IndexOutOfBoundsException();
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 	return sal_False;
549cdf0e10cSrcweir }
550cdf0e10cSrcweir // -----------------------------------------------------------------------------
getText()551cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getText() throw (RuntimeException)
552cdf0e10cSrcweir {
553cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
554cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
555cdf0e10cSrcweir 
556cdf0e10cSrcweir 	return OCommonAccessibleText::getText();
557cdf0e10cSrcweir }
558cdf0e10cSrcweir // -----------------------------------------------------------------------------
getTextRange(sal_Int32 nStartIndex,sal_Int32 nEndIndex)559cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLXAccessibleListItem::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
560cdf0e10cSrcweir {
561cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
562cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 	return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
565cdf0e10cSrcweir }
566cdf0e10cSrcweir // -----------------------------------------------------------------------------
getTextAtIndex(sal_Int32 nIndex,sal_Int16 aTextType)567cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
568cdf0e10cSrcweir {
569cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
570cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 	return OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
573cdf0e10cSrcweir }
574cdf0e10cSrcweir // -----------------------------------------------------------------------------
getTextBeforeIndex(sal_Int32 nIndex,sal_Int16 aTextType)575cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
576cdf0e10cSrcweir {
577cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
578cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
579cdf0e10cSrcweir 
580cdf0e10cSrcweir 	return OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
581cdf0e10cSrcweir }
582cdf0e10cSrcweir // -----------------------------------------------------------------------------
getTextBehindIndex(sal_Int32 nIndex,sal_Int16 aTextType)583cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment SAL_CALL VCLXAccessibleListItem::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
584cdf0e10cSrcweir {
585cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
586cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 	return OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
589cdf0e10cSrcweir }
590cdf0e10cSrcweir // -----------------------------------------------------------------------------
copyText(sal_Int32 nStartIndex,sal_Int32 nEndIndex)591cdf0e10cSrcweir sal_Bool SAL_CALL VCLXAccessibleListItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (IndexOutOfBoundsException, RuntimeException)
592cdf0e10cSrcweir {
593cdf0e10cSrcweir 	vos::OGuard aSolarGuard( Application::GetSolarMutex() );
594cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
595cdf0e10cSrcweir 
596cdf0e10cSrcweir 	checkIndex_Impl( nStartIndex, m_sEntryText );
597cdf0e10cSrcweir 	checkIndex_Impl( nEndIndex, m_sEntryText );
598cdf0e10cSrcweir 
599cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
600cdf0e10cSrcweir 	if ( m_pListBoxHelper )
601cdf0e10cSrcweir 	{
602cdf0e10cSrcweir 		Reference< datatransfer::clipboard::XClipboard > xClipboard = m_pListBoxHelper->GetClipboard();
603cdf0e10cSrcweir 		if ( xClipboard.is() )
604cdf0e10cSrcweir 		{
605cdf0e10cSrcweir 			::rtl::OUString sText( getTextRange( nStartIndex, nEndIndex ) );
606cdf0e10cSrcweir 			::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
607cdf0e10cSrcweir 
608cdf0e10cSrcweir 			const sal_uInt32 nRef = Application::ReleaseSolarMutex();
609cdf0e10cSrcweir 			xClipboard->setContents( pDataObj, NULL );
610cdf0e10cSrcweir 			Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
611cdf0e10cSrcweir 			if( xFlushableClipboard.is() )
612cdf0e10cSrcweir 				xFlushableClipboard->flushClipboard();
613cdf0e10cSrcweir 			Application::AcquireSolarMutex( nRef );
614cdf0e10cSrcweir 
615cdf0e10cSrcweir 			bRet = sal_True;
616cdf0e10cSrcweir 		}
617cdf0e10cSrcweir 	}
618cdf0e10cSrcweir 
619cdf0e10cSrcweir     return bRet;
620cdf0e10cSrcweir }
621cdf0e10cSrcweir // -----------------------------------------------------------------------------
622cdf0e10cSrcweir // XAccessibleEventBroadcaster
623cdf0e10cSrcweir // -----------------------------------------------------------------------------
addEventListener(const Reference<XAccessibleEventListener> & xListener)624cdf0e10cSrcweir void SAL_CALL VCLXAccessibleListItem::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
625cdf0e10cSrcweir {
626cdf0e10cSrcweir 	if (xListener.is())
627cdf0e10cSrcweir     {
628cdf0e10cSrcweir 		if (!m_nClientId)
629cdf0e10cSrcweir             m_nClientId = comphelper::AccessibleEventNotifier::registerClient( );
630cdf0e10cSrcweir 		comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener );
631cdf0e10cSrcweir     }
632cdf0e10cSrcweir }
633cdf0e10cSrcweir // -----------------------------------------------------------------------------
removeEventListener(const Reference<XAccessibleEventListener> & xListener)634cdf0e10cSrcweir void SAL_CALL VCLXAccessibleListItem::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
635cdf0e10cSrcweir {
636cdf0e10cSrcweir 	if ( xListener.is() && m_nClientId )
637cdf0e10cSrcweir 	{
638cdf0e10cSrcweir         sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener );
639cdf0e10cSrcweir 		if ( !nListenerCount )
640cdf0e10cSrcweir 		{
641cdf0e10cSrcweir 			// no listeners anymore
642cdf0e10cSrcweir 			// -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
643cdf0e10cSrcweir 			// and at least to us not firing any events anymore, in case somebody calls
644cdf0e10cSrcweir 			// NotifyAccessibleEvent, again
645cdf0e10cSrcweir 			if ( m_nClientId )
646cdf0e10cSrcweir 			{
647cdf0e10cSrcweir 				comphelper::AccessibleEventNotifier::TClientId nId( m_nClientId );
648cdf0e10cSrcweir 				m_nClientId = 0;
649cdf0e10cSrcweir 				comphelper::AccessibleEventNotifier::revokeClient( nId );
650cdf0e10cSrcweir 			}
651cdf0e10cSrcweir 		}
652cdf0e10cSrcweir 	}
653cdf0e10cSrcweir }
654cdf0e10cSrcweir // -----------------------------------------------------------------------------
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 
657cdf0e10cSrcweir 
658cdf0e10cSrcweir // AF (Oct. 29 2002): Return black as constant foreground color.  This is an
659cdf0e10cSrcweir // initial implementation and has to be substituted by code that determines
660cdf0e10cSrcweir // the color that is actually used.
getForeground(void)661cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleListItem::getForeground (void)
662cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
663cdf0e10cSrcweir {
664cdf0e10cSrcweir     return COL_BLACK;
665cdf0e10cSrcweir }
666cdf0e10cSrcweir 
667cdf0e10cSrcweir // AF (Oct. 29 2002): Return white as constant background color.  This is an
668cdf0e10cSrcweir // initial implementation and has to be substituted by code that determines
669cdf0e10cSrcweir // the color that is actually used.
getBackground(void)670cdf0e10cSrcweir sal_Int32 SAL_CALL VCLXAccessibleListItem::getBackground (void)
671cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
672cdf0e10cSrcweir {
673cdf0e10cSrcweir     return COL_WHITE;
674cdf0e10cSrcweir }
675cdf0e10cSrcweir // -----------------------------------------------------------------------------
676