15900e8ecSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
35900e8ecSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
45900e8ecSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
55900e8ecSAndrew Rist  * distributed with this work for additional information
65900e8ecSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
75900e8ecSAndrew Rist  * to you under the Apache License, Version 2.0 (the
85900e8ecSAndrew Rist  * "License"); you may not use this file except in compliance
95900e8ecSAndrew Rist  * with the License.  You may obtain a copy of the License at
105900e8ecSAndrew Rist  *
115900e8ecSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
125900e8ecSAndrew Rist  *
135900e8ecSAndrew Rist  * Unless required by applicable law or agreed to in writing,
145900e8ecSAndrew Rist  * software distributed under the License is distributed on an
155900e8ecSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165900e8ecSAndrew Rist  * KIND, either express or implied.  See the License for the
175900e8ecSAndrew Rist  * specific language governing permissions and limitations
185900e8ecSAndrew Rist  * under the License.
195900e8ecSAndrew Rist  *
205900e8ecSAndrew Rist  *************************************************************/
215900e8ecSAndrew Rist 
225900e8ecSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svtools.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #define _SV_VALUESET_CXX
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
30cdf0e10cSrcweir #include <vcl/svapp.hxx>
31cdf0e10cSrcweir #include <svtools/valueset.hxx>
32cdf0e10cSrcweir #include "valueimp.hxx"
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 
37*2bfcd321SSteve Yin //IAccessibility2 Implementation 2009-----
38*2bfcd321SSteve Yin #include <com/sun/star/accessibility/AccessibleEventId.hpp>
39*2bfcd321SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLERELATIONTYPE_HPP_
40*2bfcd321SSteve Yin #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
41*2bfcd321SSteve Yin #endif
42*2bfcd321SSteve Yin #ifndef _UTL_ACCESSIBLERELATIONSETHELPER_HXX_
43*2bfcd321SSteve Yin #include <unotools/accessiblerelationsethelper.hxx>
44*2bfcd321SSteve Yin #endif
45*2bfcd321SSteve Yin //-----IAccessibility2 Implementation 2009
46cdf0e10cSrcweir using namespace ::com::sun::star;
47cdf0e10cSrcweir 
48cdf0e10cSrcweir // ----------------
49cdf0e10cSrcweir // - ValueSetItem -
50cdf0e10cSrcweir // ----------------
51cdf0e10cSrcweir 
52cdf0e10cSrcweir ValueSetItem::ValueSetItem( ValueSet& rParent ) :
53cdf0e10cSrcweir     mrParent( rParent ),
54cdf0e10cSrcweir     mnId( 0 ),
55cdf0e10cSrcweir 	mnBits( 0 ),
56cdf0e10cSrcweir 	mpData( NULL ),
57cdf0e10cSrcweir     mpxAcc( NULL )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir // -----------------------------------------------------------------------
62cdf0e10cSrcweir 
63cdf0e10cSrcweir ValueSetItem::~ValueSetItem()
64cdf0e10cSrcweir {
65cdf0e10cSrcweir     if( mpxAcc )
66cdf0e10cSrcweir     {
67cdf0e10cSrcweir         static_cast< ValueItemAcc* >( mpxAcc->get() )->ParentDestroyed();
68cdf0e10cSrcweir         delete mpxAcc;
69cdf0e10cSrcweir     }
70cdf0e10cSrcweir }
71cdf0e10cSrcweir 
72cdf0e10cSrcweir // -----------------------------------------------------------------------
73cdf0e10cSrcweir 
74cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > ValueSetItem::GetAccessible( bool bIsTransientChildrenDisabled )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     if( !mpxAcc )
77cdf0e10cSrcweir         mpxAcc = new uno::Reference< accessibility::XAccessible >( new ValueItemAcc( this, bIsTransientChildrenDisabled ) );
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     return *mpxAcc;
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir // -----------------------------------------------------------------------
83cdf0e10cSrcweir 
84cdf0e10cSrcweir void ValueSetItem::ClearAccessible()
85cdf0e10cSrcweir {
86cdf0e10cSrcweir     if( mpxAcc )
87cdf0e10cSrcweir         delete mpxAcc, mpxAcc = NULL;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 
91cdf0e10cSrcweir // ---------------
92cdf0e10cSrcweir // - ValueSetAcc -
93cdf0e10cSrcweir // ---------------
94cdf0e10cSrcweir 
95cdf0e10cSrcweir ValueSetAcc::ValueSetAcc( ValueSet* pParent, bool bIsTransientChildrenDisabled ) :
96cdf0e10cSrcweir     ValueSetAccComponentBase (m_aMutex),
97cdf0e10cSrcweir     mpParent( pParent ),
98cdf0e10cSrcweir     mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled ),
99cdf0e10cSrcweir     mbIsFocused(false)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir // -----------------------------------------------------------------------------
104cdf0e10cSrcweir 
105cdf0e10cSrcweir ValueSetAcc::~ValueSetAcc()
106cdf0e10cSrcweir {
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir // -----------------------------------------------------------------------
110cdf0e10cSrcweir 
111cdf0e10cSrcweir void ValueSetAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir     if( nEventId )
114cdf0e10cSrcweir     {
115cdf0e10cSrcweir         ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >                  aTmpListeners( mxEventListeners );
116cdf0e10cSrcweir         ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator  aIter( aTmpListeners.begin() );
117cdf0e10cSrcweir         accessibility::AccessibleEventObject                                                        aEvtObject;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir         aEvtObject.EventId = nEventId;
120cdf0e10cSrcweir         aEvtObject.Source = static_cast<uno::XWeak*>(this);
121cdf0e10cSrcweir         aEvtObject.NewValue = rNewValue;
122cdf0e10cSrcweir 	    aEvtObject.OldValue = rOldValue;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 		while( aIter != aTmpListeners.end() )
125cdf0e10cSrcweir         {
126cdf0e10cSrcweir 			try
127cdf0e10cSrcweir 			{
128cdf0e10cSrcweir 				(*aIter)->notifyEvent( aEvtObject );
129cdf0e10cSrcweir 			}
130cdf0e10cSrcweir 			catch( uno::Exception& )
131cdf0e10cSrcweir 			{
132cdf0e10cSrcweir 			}
133cdf0e10cSrcweir 
134cdf0e10cSrcweir             aIter++;
135cdf0e10cSrcweir         }
136cdf0e10cSrcweir     }
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
139cdf0e10cSrcweir // -----------------------------------------------------------------------------
140cdf0e10cSrcweir 
141cdf0e10cSrcweir const uno::Sequence< sal_Int8 >& ValueSetAcc::getUnoTunnelId()
142cdf0e10cSrcweir {
143cdf0e10cSrcweir     static uno::Sequence< sal_Int8 > aSeq;
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	if( !aSeq.getLength() )
146cdf0e10cSrcweir 	{
147cdf0e10cSrcweir 		static osl::Mutex           aCreateMutex;
148cdf0e10cSrcweir     	osl::Guard< osl::Mutex >    aGuard( aCreateMutex );
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 		aSeq.realloc( 16 );
151cdf0e10cSrcweir     	rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True );
152cdf0e10cSrcweir 	}
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     return aSeq;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir // -----------------------------------------------------------------------------
158cdf0e10cSrcweir 
159cdf0e10cSrcweir ValueSetAcc* ValueSetAcc::getImplementation( const uno::Reference< uno::XInterface >& rxData )
160cdf0e10cSrcweir     throw()
161cdf0e10cSrcweir {
162cdf0e10cSrcweir     try
163cdf0e10cSrcweir     {
164cdf0e10cSrcweir 	    uno::Reference< lang::XUnoTunnel > xUnoTunnel( rxData, uno::UNO_QUERY );
165cdf0e10cSrcweir         return( xUnoTunnel.is() ? reinterpret_cast<ValueSetAcc*>(sal::static_int_cast<sal_IntPtr>(xUnoTunnel->getSomething( ValueSetAcc::getUnoTunnelId() ))) : NULL );
166cdf0e10cSrcweir     }
167cdf0e10cSrcweir     catch( const ::com::sun::star::uno::Exception& )
168cdf0e10cSrcweir 	{
169cdf0e10cSrcweir         return NULL;
170cdf0e10cSrcweir 	}
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 
174cdf0e10cSrcweir // -----------------------------------------------------------------------------
175cdf0e10cSrcweir 
176cdf0e10cSrcweir void ValueSetAcc::GetFocus (void)
177cdf0e10cSrcweir {
178cdf0e10cSrcweir     mbIsFocused = true;
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     // Boradcast the state change.
181cdf0e10cSrcweir     ::com::sun::star::uno::Any aOldState, aNewState;
182cdf0e10cSrcweir     aNewState <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
183cdf0e10cSrcweir     FireAccessibleEvent(
184cdf0e10cSrcweir         ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED,
185cdf0e10cSrcweir         aOldState, aNewState);
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir // -----------------------------------------------------------------------------
189cdf0e10cSrcweir 
190cdf0e10cSrcweir void ValueSetAcc::LoseFocus (void)
191cdf0e10cSrcweir {
192cdf0e10cSrcweir     mbIsFocused = false;
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     // Boradcast the state change.
195cdf0e10cSrcweir     ::com::sun::star::uno::Any aOldState, aNewState;
196cdf0e10cSrcweir     aOldState <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
197cdf0e10cSrcweir     FireAccessibleEvent(
198cdf0e10cSrcweir         ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED,
199cdf0e10cSrcweir         aOldState, aNewState);
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir // -----------------------------------------------------------------------------
203cdf0e10cSrcweir 
204cdf0e10cSrcweir uno::Reference< accessibility::XAccessibleContext > SAL_CALL ValueSetAcc::getAccessibleContext()
205cdf0e10cSrcweir     throw (uno::RuntimeException)
206cdf0e10cSrcweir {
207cdf0e10cSrcweir     ThrowIfDisposed();
208cdf0e10cSrcweir     return this;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir // -----------------------------------------------------------------------------
212cdf0e10cSrcweir 
213cdf0e10cSrcweir sal_Int32 SAL_CALL ValueSetAcc::getAccessibleChildCount()
214cdf0e10cSrcweir     throw (uno::RuntimeException)
215cdf0e10cSrcweir {
216cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
217cdf0e10cSrcweir     ThrowIfDisposed();
218cdf0e10cSrcweir 
219cdf0e10cSrcweir     sal_Int32 nCount = mpParent->ImplGetVisibleItemCount();
220cdf0e10cSrcweir     if (HasNoneField())
221cdf0e10cSrcweir         nCount += 1;
222cdf0e10cSrcweir     return nCount;
223cdf0e10cSrcweir }
224cdf0e10cSrcweir 
225cdf0e10cSrcweir // -----------------------------------------------------------------------------
226cdf0e10cSrcweir 
227cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessibleChild( sal_Int32 i )
228cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
229cdf0e10cSrcweir {
230cdf0e10cSrcweir     ThrowIfDisposed();
231cdf0e10cSrcweir     const vos::OGuard                               aSolarGuard( Application::GetSolarMutex() );
232cdf0e10cSrcweir     uno::Reference< accessibility::XAccessible >    xRet;
233cdf0e10cSrcweir     ValueSetItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(i));
234cdf0e10cSrcweir 
235cdf0e10cSrcweir     if( pItem )
236cdf0e10cSrcweir         xRet = pItem->GetAccessible( mbIsTransientChildrenDisabled );
237cdf0e10cSrcweir     else
238cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
239cdf0e10cSrcweir 
240cdf0e10cSrcweir     return xRet;
241cdf0e10cSrcweir }
242cdf0e10cSrcweir 
243cdf0e10cSrcweir // -----------------------------------------------------------------------------
244cdf0e10cSrcweir 
245cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessibleParent()
246cdf0e10cSrcweir     throw (uno::RuntimeException)
247cdf0e10cSrcweir {
248cdf0e10cSrcweir     ThrowIfDisposed();
249cdf0e10cSrcweir     const vos::OGuard                               aSolarGuard( Application::GetSolarMutex() );
250cdf0e10cSrcweir     Window*                                         pParent = mpParent->GetParent();
251cdf0e10cSrcweir     uno::Reference< accessibility::XAccessible >    xRet;
252cdf0e10cSrcweir 
253cdf0e10cSrcweir     if( pParent )
254cdf0e10cSrcweir         xRet = pParent->GetAccessible();
255cdf0e10cSrcweir 
256cdf0e10cSrcweir     return xRet;
257cdf0e10cSrcweir }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir // -----------------------------------------------------------------------------
260cdf0e10cSrcweir 
261cdf0e10cSrcweir sal_Int32 SAL_CALL ValueSetAcc::getAccessibleIndexInParent()
262cdf0e10cSrcweir     throw (uno::RuntimeException)
263cdf0e10cSrcweir {
264cdf0e10cSrcweir     ThrowIfDisposed();
265cdf0e10cSrcweir     const vos::OGuard       aSolarGuard( Application::GetSolarMutex() );
266cdf0e10cSrcweir     Window*                 pParent = mpParent->GetParent();
267cdf0e10cSrcweir     sal_Int32               nRet = 0;
268cdf0e10cSrcweir 
269cdf0e10cSrcweir     if( pParent )
270cdf0e10cSrcweir     {
271cdf0e10cSrcweir         sal_Bool bFound = sal_False;
272cdf0e10cSrcweir 
273cdf0e10cSrcweir         for( sal_uInt16 i = 0, nCount = pParent->GetChildCount(); ( i < nCount ) && !bFound; i++ )
274cdf0e10cSrcweir         {
275cdf0e10cSrcweir             if( pParent->GetChild( i ) == mpParent )
276cdf0e10cSrcweir             {
277cdf0e10cSrcweir                 nRet = i;
278cdf0e10cSrcweir                 bFound = sal_True;
279cdf0e10cSrcweir             }
280cdf0e10cSrcweir         }
281cdf0e10cSrcweir     }
282cdf0e10cSrcweir 
283cdf0e10cSrcweir     return nRet;
284cdf0e10cSrcweir }
285cdf0e10cSrcweir 
286cdf0e10cSrcweir // -----------------------------------------------------------------------------
287cdf0e10cSrcweir 
288cdf0e10cSrcweir sal_Int16 SAL_CALL ValueSetAcc::getAccessibleRole()
289cdf0e10cSrcweir     throw (uno::RuntimeException)
290cdf0e10cSrcweir {
291cdf0e10cSrcweir     ThrowIfDisposed();
292cdf0e10cSrcweir     // #i73746# As the Java Access Bridge (v 2.0.1) uses "managesDescendants"
293cdf0e10cSrcweir     // always if the role is LIST, we need a different role in this case
294cdf0e10cSrcweir     return (mbIsTransientChildrenDisabled
295cdf0e10cSrcweir             ? accessibility::AccessibleRole::PANEL
296cdf0e10cSrcweir             : accessibility::AccessibleRole::LIST );
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
299cdf0e10cSrcweir // -----------------------------------------------------------------------------
300cdf0e10cSrcweir 
301cdf0e10cSrcweir ::rtl::OUString SAL_CALL ValueSetAcc::getAccessibleDescription()
302cdf0e10cSrcweir     throw (uno::RuntimeException)
303cdf0e10cSrcweir {
304cdf0e10cSrcweir     ThrowIfDisposed();
305cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
306cdf0e10cSrcweir     String              aRet( RTL_CONSTASCII_USTRINGPARAM( "ValueSet" ) );
307cdf0e10cSrcweir 
308cdf0e10cSrcweir     return aRet;
309cdf0e10cSrcweir }
310cdf0e10cSrcweir 
311cdf0e10cSrcweir // -----------------------------------------------------------------------------
312cdf0e10cSrcweir 
313cdf0e10cSrcweir ::rtl::OUString SAL_CALL ValueSetAcc::getAccessibleName()
314cdf0e10cSrcweir     throw (uno::RuntimeException)
315cdf0e10cSrcweir {
316cdf0e10cSrcweir     ThrowIfDisposed();
317cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
318cdf0e10cSrcweir     String              aRet;
319cdf0e10cSrcweir 
320cdf0e10cSrcweir     if ( mpParent )
321cdf0e10cSrcweir         aRet = mpParent->GetAccessibleName();
322cdf0e10cSrcweir 
323cdf0e10cSrcweir     if ( !aRet.Len() )
324cdf0e10cSrcweir     {
325cdf0e10cSrcweir         Window* pLabel = mpParent->GetAccessibleRelationLabeledBy();
326cdf0e10cSrcweir         if ( pLabel && pLabel != mpParent )
327cdf0e10cSrcweir             aRet = OutputDevice::GetNonMnemonicString( pLabel->GetText() );
328*2bfcd321SSteve Yin 
329*2bfcd321SSteve Yin         if ( !aRet.Len() )
330*2bfcd321SSteve Yin          	aRet = mpParent->GetQuickHelpText();
331cdf0e10cSrcweir     }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir     return aRet;
334cdf0e10cSrcweir }
335cdf0e10cSrcweir 
336cdf0e10cSrcweir // -----------------------------------------------------------------------------
337cdf0e10cSrcweir 
338cdf0e10cSrcweir uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueSetAcc::getAccessibleRelationSet()
339cdf0e10cSrcweir     throw (uno::RuntimeException)
340cdf0e10cSrcweir {
341cdf0e10cSrcweir     ThrowIfDisposed();
342*2bfcd321SSteve Yin //IAccessibility2 Implementation 2009-----
343*2bfcd321SSteve Yin 	uno::Reference< accessibility::XAccessibleRelationSet > xRelSet;
344*2bfcd321SSteve Yin 	Window* pWindow = (Window*)mpParent;
345*2bfcd321SSteve Yin 	if ( pWindow )
346*2bfcd321SSteve Yin 	{
347*2bfcd321SSteve Yin 		utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper;
348*2bfcd321SSteve Yin 		xRelSet = pRelationSet;
349*2bfcd321SSteve Yin 
350*2bfcd321SSteve Yin 		Window *pLabeledBy = pWindow->GetAccessibleRelationLabeledBy();
351*2bfcd321SSteve Yin 		if ( pLabeledBy && pLabeledBy != pWindow )
352*2bfcd321SSteve Yin 		{
353*2bfcd321SSteve Yin 			uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
354*2bfcd321SSteve Yin 			aSequence[0] = pLabeledBy->GetAccessible();
355*2bfcd321SSteve Yin 			pRelationSet->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY, aSequence ) );
356*2bfcd321SSteve Yin 		}
357*2bfcd321SSteve Yin 
358*2bfcd321SSteve Yin 		Window* pMemberOf = pWindow->GetAccessibleRelationMemberOf();
359*2bfcd321SSteve Yin 		if ( pMemberOf && pMemberOf != pWindow )
360*2bfcd321SSteve Yin 		{
361*2bfcd321SSteve Yin 			uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1);
362*2bfcd321SSteve Yin 			aSequence[0] = pMemberOf->GetAccessible();
363*2bfcd321SSteve Yin 			pRelationSet->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) );
364*2bfcd321SSteve Yin 		}
365*2bfcd321SSteve Yin 	}
366*2bfcd321SSteve Yin     return xRelSet;
367*2bfcd321SSteve Yin //-----IAccessibility2 Implementation 2009
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir // -----------------------------------------------------------------------------
371cdf0e10cSrcweir 
372cdf0e10cSrcweir uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ValueSetAcc::getAccessibleStateSet()
373cdf0e10cSrcweir     throw (uno::RuntimeException)
374cdf0e10cSrcweir {
375cdf0e10cSrcweir     ThrowIfDisposed();
376cdf0e10cSrcweir     ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
377cdf0e10cSrcweir 
378cdf0e10cSrcweir     // Set some states.
379cdf0e10cSrcweir     pStateSet->AddState (accessibility::AccessibleStateType::ENABLED);
380cdf0e10cSrcweir     pStateSet->AddState (accessibility::AccessibleStateType::SENSITIVE);
381cdf0e10cSrcweir     pStateSet->AddState (accessibility::AccessibleStateType::SHOWING);
382cdf0e10cSrcweir     pStateSet->AddState (accessibility::AccessibleStateType::VISIBLE);
383cdf0e10cSrcweir     if ( !mbIsTransientChildrenDisabled )
384cdf0e10cSrcweir         pStateSet->AddState (accessibility::AccessibleStateType::MANAGES_DESCENDANTS);
385cdf0e10cSrcweir     pStateSet->AddState (accessibility::AccessibleStateType::FOCUSABLE);
386cdf0e10cSrcweir     if (mbIsFocused)
387cdf0e10cSrcweir         pStateSet->AddState (accessibility::AccessibleStateType::FOCUSED);
388cdf0e10cSrcweir 
389cdf0e10cSrcweir     return pStateSet;
390cdf0e10cSrcweir }
391cdf0e10cSrcweir 
392cdf0e10cSrcweir // -----------------------------------------------------------------------------
393cdf0e10cSrcweir 
394cdf0e10cSrcweir lang::Locale SAL_CALL ValueSetAcc::getLocale()
395cdf0e10cSrcweir     throw (accessibility::IllegalAccessibleComponentStateException, uno::RuntimeException)
396cdf0e10cSrcweir {
397cdf0e10cSrcweir     ThrowIfDisposed();
398cdf0e10cSrcweir     const vos::OGuard                               aSolarGuard( Application::GetSolarMutex() );
399cdf0e10cSrcweir     const ::rtl::OUString                           aEmptyStr;
400cdf0e10cSrcweir     uno::Reference< accessibility::XAccessible >    xParent( getAccessibleParent() );
401cdf0e10cSrcweir     lang::Locale                                    aRet( aEmptyStr, aEmptyStr, aEmptyStr );
402cdf0e10cSrcweir 
403cdf0e10cSrcweir     if( xParent.is() )
404cdf0e10cSrcweir     {
405cdf0e10cSrcweir         uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
406cdf0e10cSrcweir 
407cdf0e10cSrcweir         if( xParentContext.is() )
408cdf0e10cSrcweir             aRet = xParentContext->getLocale ();
409cdf0e10cSrcweir     }
410cdf0e10cSrcweir 
411cdf0e10cSrcweir     return aRet;
412cdf0e10cSrcweir }
413cdf0e10cSrcweir 
414cdf0e10cSrcweir // -----------------------------------------------------------------------------
415cdf0e10cSrcweir 
416cdf0e10cSrcweir void SAL_CALL ValueSetAcc::addEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
417cdf0e10cSrcweir     throw (uno::RuntimeException)
418cdf0e10cSrcweir {
419cdf0e10cSrcweir     ThrowIfDisposed();
420cdf0e10cSrcweir     ::osl::MutexGuard aGuard (m_aMutex);
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 	if( rxListener.is() )
423cdf0e10cSrcweir     {
424cdf0e10cSrcweir        	::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin();
425cdf0e10cSrcweir 		sal_Bool bFound = sal_False;
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 		while( !bFound && ( aIter != mxEventListeners.end() ) )
428cdf0e10cSrcweir         {
429cdf0e10cSrcweir 			if( *aIter == rxListener )
430cdf0e10cSrcweir                 bFound = sal_True;
431cdf0e10cSrcweir             else
432cdf0e10cSrcweir                 aIter++;
433cdf0e10cSrcweir         }
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 		if (!bFound)
436cdf0e10cSrcweir             mxEventListeners.push_back( rxListener );
437cdf0e10cSrcweir     }
438cdf0e10cSrcweir }
439cdf0e10cSrcweir 
440cdf0e10cSrcweir // -----------------------------------------------------------------------------
441cdf0e10cSrcweir 
442cdf0e10cSrcweir void SAL_CALL ValueSetAcc::removeEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
443cdf0e10cSrcweir     throw (uno::RuntimeException)
444cdf0e10cSrcweir {
445cdf0e10cSrcweir     ThrowIfDisposed();
446cdf0e10cSrcweir     ::osl::MutexGuard aGuard (m_aMutex);
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 	if( rxListener.is() )
449cdf0e10cSrcweir     {
450cdf0e10cSrcweir        	::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter = mxEventListeners.begin();
451cdf0e10cSrcweir 		sal_Bool bFound = sal_False;
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 		while( !bFound && ( aIter != mxEventListeners.end() ) )
454cdf0e10cSrcweir         {
455cdf0e10cSrcweir 			if( *aIter == rxListener )
456cdf0e10cSrcweir             {
457cdf0e10cSrcweir                 mxEventListeners.erase( aIter );
458cdf0e10cSrcweir                 bFound = sal_True;
459cdf0e10cSrcweir             }
460cdf0e10cSrcweir             else
461cdf0e10cSrcweir                 aIter++;
462cdf0e10cSrcweir         }
463cdf0e10cSrcweir     }
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
466cdf0e10cSrcweir // -----------------------------------------------------------------------------
467cdf0e10cSrcweir 
468cdf0e10cSrcweir sal_Bool SAL_CALL ValueSetAcc::containsPoint( const awt::Point& aPoint )
469cdf0e10cSrcweir     throw (uno::RuntimeException)
470cdf0e10cSrcweir {
471cdf0e10cSrcweir     ThrowIfDisposed();
472cdf0e10cSrcweir     const awt::Rectangle    aRect( getBounds() );
473cdf0e10cSrcweir     const Point             aSize( aRect.Width, aRect.Height );
474cdf0e10cSrcweir     const Point             aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
475cdf0e10cSrcweir 
476cdf0e10cSrcweir     return Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
477cdf0e10cSrcweir }
478cdf0e10cSrcweir 
479cdf0e10cSrcweir // -----------------------------------------------------------------------------
480cdf0e10cSrcweir 
481cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getAccessibleAtPoint( const awt::Point& aPoint )
482cdf0e10cSrcweir     throw (uno::RuntimeException)
483cdf0e10cSrcweir {
484cdf0e10cSrcweir     ThrowIfDisposed();
485cdf0e10cSrcweir     const vos::OGuard                               aSolarGuard( Application::GetSolarMutex() );
486cdf0e10cSrcweir     const sal_uInt16                                    nItemId = mpParent->GetItemId( Point( aPoint.X, aPoint.Y ) );
487cdf0e10cSrcweir     uno::Reference< accessibility::XAccessible >    xRet;
488cdf0e10cSrcweir 
489cdf0e10cSrcweir     if( VALUESET_ITEM_NOTFOUND != nItemId )
490cdf0e10cSrcweir     {
491cdf0e10cSrcweir         const sal_uInt16 nItemPos = mpParent->GetItemPos( nItemId );
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 	    if( VALUESET_ITEM_NONEITEM != nItemPos )
494cdf0e10cSrcweir         {
495cdf0e10cSrcweir             ValueSetItem* pItem = mpParent->mpImpl->mpItemList->GetObject( nItemPos );
496cdf0e10cSrcweir 
497cdf0e10cSrcweir             if( ( pItem->meType != VALUESETITEM_SPACE ) && !pItem->maRect.IsEmpty() )
498cdf0e10cSrcweir                xRet = pItem->GetAccessible( mbIsTransientChildrenDisabled );
499cdf0e10cSrcweir         }
500cdf0e10cSrcweir     }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir     return xRet;
503cdf0e10cSrcweir }
504cdf0e10cSrcweir 
505cdf0e10cSrcweir // -----------------------------------------------------------------------------
506cdf0e10cSrcweir 
507cdf0e10cSrcweir awt::Rectangle SAL_CALL ValueSetAcc::getBounds()
508cdf0e10cSrcweir     throw (uno::RuntimeException)
509cdf0e10cSrcweir {
510cdf0e10cSrcweir     ThrowIfDisposed();
511cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
512cdf0e10cSrcweir     const Point         aOutPos( mpParent->GetPosPixel() );
513cdf0e10cSrcweir     const Size          aOutSize( mpParent->GetOutputSizePixel() );
514cdf0e10cSrcweir     awt::Rectangle      aRet;
515cdf0e10cSrcweir 
516cdf0e10cSrcweir     aRet.X = aOutPos.X();
517cdf0e10cSrcweir     aRet.Y = aOutPos.Y();
518cdf0e10cSrcweir     aRet.Width = aOutSize.Width();
519cdf0e10cSrcweir     aRet.Height = aOutSize.Height();
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     return aRet;
522cdf0e10cSrcweir }
523cdf0e10cSrcweir 
524cdf0e10cSrcweir // -----------------------------------------------------------------------------
525cdf0e10cSrcweir 
526cdf0e10cSrcweir awt::Point SAL_CALL ValueSetAcc::getLocation()
527cdf0e10cSrcweir     throw (uno::RuntimeException)
528cdf0e10cSrcweir {
529cdf0e10cSrcweir     ThrowIfDisposed();
530cdf0e10cSrcweir     const awt::Rectangle    aRect( getBounds() );
531cdf0e10cSrcweir     awt::Point              aRet;
532cdf0e10cSrcweir 
533cdf0e10cSrcweir     aRet.X = aRect.X;
534cdf0e10cSrcweir     aRet.Y = aRect.Y;
535cdf0e10cSrcweir 
536cdf0e10cSrcweir     return aRet;
537cdf0e10cSrcweir }
538cdf0e10cSrcweir 
539cdf0e10cSrcweir // -----------------------------------------------------------------------------
540cdf0e10cSrcweir 
541cdf0e10cSrcweir awt::Point SAL_CALL ValueSetAcc::getLocationOnScreen()
542cdf0e10cSrcweir     throw (uno::RuntimeException)
543cdf0e10cSrcweir {
544cdf0e10cSrcweir     ThrowIfDisposed();
545cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
546cdf0e10cSrcweir     const Point         aScreenPos( mpParent->OutputToAbsoluteScreenPixel( Point() ) );
547cdf0e10cSrcweir     awt::Point          aRet;
548cdf0e10cSrcweir 
549cdf0e10cSrcweir     aRet.X = aScreenPos.X();
550cdf0e10cSrcweir     aRet.Y = aScreenPos.Y();
551cdf0e10cSrcweir 
552cdf0e10cSrcweir     return aRet;
553cdf0e10cSrcweir }
554cdf0e10cSrcweir 
555cdf0e10cSrcweir // -----------------------------------------------------------------------------
556cdf0e10cSrcweir 
557cdf0e10cSrcweir awt::Size SAL_CALL ValueSetAcc::getSize()
558cdf0e10cSrcweir     throw (uno::RuntimeException)
559cdf0e10cSrcweir {
560cdf0e10cSrcweir     ThrowIfDisposed();
561cdf0e10cSrcweir     const awt::Rectangle    aRect( getBounds() );
562cdf0e10cSrcweir     awt::Size               aRet;
563cdf0e10cSrcweir 
564cdf0e10cSrcweir     aRet.Width = aRect.Width;
565cdf0e10cSrcweir     aRet.Height = aRect.Height;
566cdf0e10cSrcweir 
567cdf0e10cSrcweir     return aRet;
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
570cdf0e10cSrcweir // -----------------------------------------------------------------------------
571cdf0e10cSrcweir 
572cdf0e10cSrcweir void SAL_CALL ValueSetAcc::grabFocus()
573cdf0e10cSrcweir     throw (uno::RuntimeException)
574cdf0e10cSrcweir {
575cdf0e10cSrcweir     ThrowIfDisposed();
576cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
577cdf0e10cSrcweir     mpParent->GrabFocus();
578cdf0e10cSrcweir }
579cdf0e10cSrcweir 
580cdf0e10cSrcweir // -----------------------------------------------------------------------------
581cdf0e10cSrcweir 
582cdf0e10cSrcweir uno::Any SAL_CALL ValueSetAcc::getAccessibleKeyBinding()
583cdf0e10cSrcweir     throw (uno::RuntimeException)
584cdf0e10cSrcweir {
585cdf0e10cSrcweir     ThrowIfDisposed();
586cdf0e10cSrcweir     return uno::Any();
587cdf0e10cSrcweir }
588cdf0e10cSrcweir 
589cdf0e10cSrcweir // -----------------------------------------------------------------------------
590cdf0e10cSrcweir 
591cdf0e10cSrcweir sal_Int32 SAL_CALL ValueSetAcc::getForeground(  )
592cdf0e10cSrcweir     throw (uno::RuntimeException)
593cdf0e10cSrcweir {
594cdf0e10cSrcweir     ThrowIfDisposed();
595cdf0e10cSrcweir     sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
596cdf0e10cSrcweir     return static_cast<sal_Int32>(nColor);
597cdf0e10cSrcweir }
598cdf0e10cSrcweir 
599cdf0e10cSrcweir // -----------------------------------------------------------------------------
600cdf0e10cSrcweir 
601cdf0e10cSrcweir sal_Int32 SAL_CALL ValueSetAcc::getBackground(  )
602cdf0e10cSrcweir     throw (uno::RuntimeException)
603cdf0e10cSrcweir {
604cdf0e10cSrcweir     ThrowIfDisposed();
605cdf0e10cSrcweir     sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
606cdf0e10cSrcweir     return static_cast<sal_Int32>(nColor);
607cdf0e10cSrcweir }
608cdf0e10cSrcweir 
609cdf0e10cSrcweir // -----------------------------------------------------------------------------
610cdf0e10cSrcweir 
611cdf0e10cSrcweir void SAL_CALL ValueSetAcc::selectAccessibleChild( sal_Int32 nChildIndex )
612cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
613cdf0e10cSrcweir {
614cdf0e10cSrcweir     ThrowIfDisposed();
615cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
616cdf0e10cSrcweir     ValueSetItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
617cdf0e10cSrcweir 
618cdf0e10cSrcweir     if(pItem != NULL)
619cdf0e10cSrcweir     {
620cdf0e10cSrcweir         mpParent->SelectItem( pItem->mnId );
621cdf0e10cSrcweir         mpParent->Select ();
622cdf0e10cSrcweir     }
623cdf0e10cSrcweir     else
624cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
625cdf0e10cSrcweir }
626cdf0e10cSrcweir 
627cdf0e10cSrcweir // -----------------------------------------------------------------------------
628cdf0e10cSrcweir 
629cdf0e10cSrcweir sal_Bool SAL_CALL ValueSetAcc::isAccessibleChildSelected( sal_Int32 nChildIndex )
630cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
631cdf0e10cSrcweir {
632cdf0e10cSrcweir     ThrowIfDisposed();
633cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
634cdf0e10cSrcweir     ValueSetItem* pItem = getItem (sal::static_int_cast< sal_uInt16 >(nChildIndex));
635cdf0e10cSrcweir     sal_Bool            bRet = sal_False;
636cdf0e10cSrcweir 
637cdf0e10cSrcweir     if (pItem != NULL)
638cdf0e10cSrcweir         bRet = mpParent->IsItemSelected( pItem->mnId );
639cdf0e10cSrcweir     else
640cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
641cdf0e10cSrcweir 
642cdf0e10cSrcweir     return bRet;
643cdf0e10cSrcweir }
644cdf0e10cSrcweir 
645cdf0e10cSrcweir // -----------------------------------------------------------------------------
646cdf0e10cSrcweir 
647cdf0e10cSrcweir void SAL_CALL ValueSetAcc::clearAccessibleSelection()
648cdf0e10cSrcweir     throw (uno::RuntimeException)
649cdf0e10cSrcweir {
650cdf0e10cSrcweir     ThrowIfDisposed();
651cdf0e10cSrcweir     const vos::OGuard aSolarGuard( Application::GetSolarMutex() );
652cdf0e10cSrcweir     mpParent->SetNoSelection();
653cdf0e10cSrcweir }
654cdf0e10cSrcweir 
655cdf0e10cSrcweir // -----------------------------------------------------------------------------
656cdf0e10cSrcweir 
657cdf0e10cSrcweir void SAL_CALL ValueSetAcc::selectAllAccessibleChildren()
658cdf0e10cSrcweir     throw (uno::RuntimeException)
659cdf0e10cSrcweir {
660cdf0e10cSrcweir     ThrowIfDisposed();
661cdf0e10cSrcweir     // unsupported due to single selection only
662cdf0e10cSrcweir }
663cdf0e10cSrcweir 
664cdf0e10cSrcweir // -----------------------------------------------------------------------------
665cdf0e10cSrcweir 
666cdf0e10cSrcweir sal_Int32 SAL_CALL ValueSetAcc::getSelectedAccessibleChildCount()
667cdf0e10cSrcweir     throw (uno::RuntimeException)
668cdf0e10cSrcweir {
669cdf0e10cSrcweir     ThrowIfDisposed();
670cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
671cdf0e10cSrcweir     sal_Int32           nRet = 0;
672cdf0e10cSrcweir 
673cdf0e10cSrcweir     for( sal_uInt16 i = 0, nCount = getItemCount(); i < nCount; i++ )
674cdf0e10cSrcweir     {
675cdf0e10cSrcweir         ValueSetItem* pItem = getItem (i);
676cdf0e10cSrcweir 
677cdf0e10cSrcweir         if( pItem && mpParent->IsItemSelected( pItem->mnId ) )
678cdf0e10cSrcweir             ++nRet;
679cdf0e10cSrcweir     }
680cdf0e10cSrcweir 
681cdf0e10cSrcweir     return nRet;
682cdf0e10cSrcweir }
683cdf0e10cSrcweir 
684cdf0e10cSrcweir // -----------------------------------------------------------------------------
685cdf0e10cSrcweir 
686cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL ValueSetAcc::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
687cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
688cdf0e10cSrcweir {
689cdf0e10cSrcweir     ThrowIfDisposed();
690cdf0e10cSrcweir     const vos::OGuard                               aSolarGuard( Application::GetSolarMutex() );
691cdf0e10cSrcweir     uno::Reference< accessibility::XAccessible >    xRet;
692cdf0e10cSrcweir 
693cdf0e10cSrcweir     for( sal_uInt16 i = 0, nCount = getItemCount(), nSel = 0; ( i < nCount ) && !xRet.is(); i++ )
694cdf0e10cSrcweir     {
695cdf0e10cSrcweir         ValueSetItem* pItem = getItem(i);
696cdf0e10cSrcweir 
697cdf0e10cSrcweir         if( pItem && mpParent->IsItemSelected( pItem->mnId ) && ( nSelectedChildIndex == static_cast< sal_Int32 >( nSel++ ) ) )
698cdf0e10cSrcweir             xRet = pItem->GetAccessible( mbIsTransientChildrenDisabled );
699cdf0e10cSrcweir     }
700cdf0e10cSrcweir 
701cdf0e10cSrcweir     return xRet;
702cdf0e10cSrcweir }
703cdf0e10cSrcweir 
704cdf0e10cSrcweir // -----------------------------------------------------------------------------
705cdf0e10cSrcweir 
706cdf0e10cSrcweir void SAL_CALL ValueSetAcc::deselectAccessibleChild( sal_Int32 nChildIndex )
707cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
708cdf0e10cSrcweir {
709cdf0e10cSrcweir     ThrowIfDisposed();
710cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
711cdf0e10cSrcweir     // Because of the single selection we can reset the whole selection when
712cdf0e10cSrcweir     // the specified child is currently selected.
713cdf0e10cSrcweir     if (isAccessibleChildSelected(nChildIndex))
714cdf0e10cSrcweir         mpParent->SetNoSelection();
715cdf0e10cSrcweir }
716cdf0e10cSrcweir 
717cdf0e10cSrcweir // -----------------------------------------------------------------------------
718cdf0e10cSrcweir 
719cdf0e10cSrcweir sal_Int64 SAL_CALL ValueSetAcc::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw( uno::RuntimeException )
720cdf0e10cSrcweir {
721cdf0e10cSrcweir     sal_Int64 nRet;
722cdf0e10cSrcweir 
723cdf0e10cSrcweir     if( ( rId.getLength() == 16 ) && ( 0 == rtl_compareMemory( ValueSetAcc::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
724cdf0e10cSrcweir         nRet = reinterpret_cast< sal_Int64 >( this );
725cdf0e10cSrcweir     else
726cdf0e10cSrcweir         nRet = 0;
727cdf0e10cSrcweir 
728cdf0e10cSrcweir 	return nRet;
729cdf0e10cSrcweir }
730cdf0e10cSrcweir 
731cdf0e10cSrcweir 
732cdf0e10cSrcweir 
733cdf0e10cSrcweir 
734cdf0e10cSrcweir void SAL_CALL ValueSetAcc::disposing (void)
735cdf0e10cSrcweir {
736cdf0e10cSrcweir     ::std::vector<uno::Reference<accessibility::XAccessibleEventListener> > aListenerListCopy;
737cdf0e10cSrcweir 
738cdf0e10cSrcweir     {
739cdf0e10cSrcweir         // Make a copy of the list and clear the original.
740cdf0e10cSrcweir         const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
741cdf0e10cSrcweir         ::osl::MutexGuard aGuard (m_aMutex);
742cdf0e10cSrcweir         aListenerListCopy = mxEventListeners;
743cdf0e10cSrcweir         mxEventListeners.clear();
744cdf0e10cSrcweir 
745cdf0e10cSrcweir         // Reset the pointer to the parent.  It has to be the one who has
746cdf0e10cSrcweir         // disposed us because he is dying.
747cdf0e10cSrcweir         mpParent = NULL;
748cdf0e10cSrcweir     }
749cdf0e10cSrcweir 
750cdf0e10cSrcweir     // Inform all listeners that this objects is disposing.
751cdf0e10cSrcweir     ::std::vector<uno::Reference<accessibility::XAccessibleEventListener> >::const_iterator
752cdf0e10cSrcweir           aListenerIterator (aListenerListCopy.begin());
753cdf0e10cSrcweir     lang::EventObject aEvent (static_cast<accessibility::XAccessible*>(this));
754cdf0e10cSrcweir     while (aListenerIterator != aListenerListCopy.end())
755cdf0e10cSrcweir     {
756cdf0e10cSrcweir         try
757cdf0e10cSrcweir         {
758cdf0e10cSrcweir             (*aListenerIterator)->disposing (aEvent);
759cdf0e10cSrcweir         }
760cdf0e10cSrcweir         catch( uno::Exception& )
761cdf0e10cSrcweir         {
762cdf0e10cSrcweir             // Ignore exceptions.
763cdf0e10cSrcweir         }
764cdf0e10cSrcweir 
765cdf0e10cSrcweir         ++aListenerIterator;
766cdf0e10cSrcweir     }
767cdf0e10cSrcweir }
768cdf0e10cSrcweir 
769cdf0e10cSrcweir 
770cdf0e10cSrcweir sal_uInt16 ValueSetAcc::getItemCount (void) const
771cdf0e10cSrcweir {
772cdf0e10cSrcweir     sal_uInt16 nCount = mpParent->ImplGetVisibleItemCount();
773cdf0e10cSrcweir     // When the None-Item is visible then increase the number of items by
774cdf0e10cSrcweir     // one.
775cdf0e10cSrcweir     if (HasNoneField())
776cdf0e10cSrcweir         nCount += 1;
777cdf0e10cSrcweir     return nCount;
778cdf0e10cSrcweir }
779cdf0e10cSrcweir 
780cdf0e10cSrcweir 
781cdf0e10cSrcweir ValueSetItem* ValueSetAcc::getItem (sal_uInt16 nIndex) const
782cdf0e10cSrcweir {
783cdf0e10cSrcweir     ValueSetItem* pItem = NULL;
784cdf0e10cSrcweir 
785cdf0e10cSrcweir     if (HasNoneField())
786cdf0e10cSrcweir     {
787cdf0e10cSrcweir         if (nIndex == 0)
788cdf0e10cSrcweir             // When present the first item is the then allways visible none field.
789cdf0e10cSrcweir             pItem = mpParent->ImplGetItem (VALUESET_ITEM_NONEITEM);
790cdf0e10cSrcweir         else
791cdf0e10cSrcweir             // Shift down the index to compensate for the none field.
792cdf0e10cSrcweir             nIndex -= 1;
793cdf0e10cSrcweir     }
794cdf0e10cSrcweir     if (pItem == NULL)
795*2bfcd321SSteve Yin //IAccessibility2 Implementation 2009-----
796*2bfcd321SSteve Yin         //pItem = mpParent->ImplGetVisibleItem (static_cast<sal_uInt16>(nIndex));
797*2bfcd321SSteve Yin 	pItem = mpParent->ImplGetItem (static_cast<sal_uInt16>(nIndex));
798*2bfcd321SSteve Yin //-----IAccessibility2 Implementation 2009
799cdf0e10cSrcweir 
800cdf0e10cSrcweir     return pItem;
801cdf0e10cSrcweir }
802cdf0e10cSrcweir 
803cdf0e10cSrcweir 
804cdf0e10cSrcweir 
805cdf0e10cSrcweir 
806cdf0e10cSrcweir void ValueSetAcc::ThrowIfDisposed (void)
807cdf0e10cSrcweir     throw (::com::sun::star::lang::DisposedException)
808cdf0e10cSrcweir {
809cdf0e10cSrcweir     if (rBHelper.bDisposed || rBHelper.bInDispose)
810cdf0e10cSrcweir     {
811cdf0e10cSrcweir         OSL_TRACE ("Calling disposed object. Throwing exception:");
812cdf0e10cSrcweir         throw lang::DisposedException (
813cdf0e10cSrcweir             ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("object has been already disposed")),
814cdf0e10cSrcweir             static_cast<uno::XWeak*>(this));
815cdf0e10cSrcweir     }
816cdf0e10cSrcweir     else
817cdf0e10cSrcweir     {
818cdf0e10cSrcweir         DBG_ASSERT (mpParent!=NULL, "ValueSetAcc not disposed but mpParent == NULL");
819cdf0e10cSrcweir     }
820cdf0e10cSrcweir }
821cdf0e10cSrcweir 
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 
824cdf0e10cSrcweir sal_Bool ValueSetAcc::IsDisposed (void)
825cdf0e10cSrcweir {
826cdf0e10cSrcweir 	return (rBHelper.bDisposed || rBHelper.bInDispose);
827cdf0e10cSrcweir }
828cdf0e10cSrcweir 
829cdf0e10cSrcweir 
830cdf0e10cSrcweir 
831cdf0e10cSrcweir 
832cdf0e10cSrcweir bool ValueSetAcc::HasNoneField (void) const
833cdf0e10cSrcweir {
834cdf0e10cSrcweir     DBG_ASSERT (mpParent!=NULL, "ValueSetAcc::HasNoneField called with mpParent==NULL");
835cdf0e10cSrcweir     return ((mpParent->GetStyle() & WB_NONEFIELD) != 0);
836cdf0e10cSrcweir }
837cdf0e10cSrcweir 
838cdf0e10cSrcweir 
839cdf0e10cSrcweir 
840cdf0e10cSrcweir 
841cdf0e10cSrcweir // ----------------
842cdf0e10cSrcweir // - ValueItemAcc -
843cdf0e10cSrcweir // ----------------
844cdf0e10cSrcweir 
845cdf0e10cSrcweir ValueItemAcc::ValueItemAcc( ValueSetItem* pParent, bool bIsTransientChildrenDisabled ) :
846cdf0e10cSrcweir     mpParent( pParent ),
847cdf0e10cSrcweir     mbIsTransientChildrenDisabled( bIsTransientChildrenDisabled )
848cdf0e10cSrcweir {
849cdf0e10cSrcweir }
850cdf0e10cSrcweir 
851cdf0e10cSrcweir // -----------------------------------------------------------------------------
852cdf0e10cSrcweir 
853cdf0e10cSrcweir ValueItemAcc::~ValueItemAcc()
854cdf0e10cSrcweir {
855cdf0e10cSrcweir }
856cdf0e10cSrcweir 
857cdf0e10cSrcweir // -----------------------------------------------------------------------
858cdf0e10cSrcweir 
859cdf0e10cSrcweir void ValueItemAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue )
860cdf0e10cSrcweir {
861cdf0e10cSrcweir     if( nEventId )
862cdf0e10cSrcweir     {
863cdf0e10cSrcweir         ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >                  aTmpListeners( mxEventListeners );
864cdf0e10cSrcweir         ::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator  aIter( aTmpListeners.begin() );
865cdf0e10cSrcweir         accessibility::AccessibleEventObject                                                        aEvtObject;
866cdf0e10cSrcweir 
867cdf0e10cSrcweir         aEvtObject.EventId = nEventId;
868cdf0e10cSrcweir         aEvtObject.Source = static_cast<uno::XWeak*>(this);
869cdf0e10cSrcweir         aEvtObject.NewValue = rNewValue;
870cdf0e10cSrcweir 	    aEvtObject.OldValue = rOldValue;
871cdf0e10cSrcweir 
872cdf0e10cSrcweir 		while( aIter != aTmpListeners.end() )
873cdf0e10cSrcweir         {
874cdf0e10cSrcweir             (*aIter)->notifyEvent( aEvtObject );
875cdf0e10cSrcweir             aIter++;
876cdf0e10cSrcweir         }
877cdf0e10cSrcweir     }
878cdf0e10cSrcweir }
879cdf0e10cSrcweir 
880cdf0e10cSrcweir // -----------------------------------------------------------------------------
881cdf0e10cSrcweir 
882cdf0e10cSrcweir void ValueItemAcc::ParentDestroyed()
883cdf0e10cSrcweir {
884cdf0e10cSrcweir     const ::vos::OGuard aGuard( maMutex );
885cdf0e10cSrcweir     mpParent = NULL;
886cdf0e10cSrcweir }
887cdf0e10cSrcweir 
888cdf0e10cSrcweir // -----------------------------------------------------------------------------
889cdf0e10cSrcweir 
890cdf0e10cSrcweir const uno::Sequence< sal_Int8 >& ValueItemAcc::getUnoTunnelId()
891cdf0e10cSrcweir {
892cdf0e10cSrcweir     static uno::Sequence< sal_Int8 > aSeq;
893cdf0e10cSrcweir 
894cdf0e10cSrcweir 	if( !aSeq.getLength() )
895cdf0e10cSrcweir 	{
896cdf0e10cSrcweir 		static osl::Mutex           aCreateMutex;
897cdf0e10cSrcweir     	osl::Guard< osl::Mutex >    aGuard( aCreateMutex );
898cdf0e10cSrcweir 
899cdf0e10cSrcweir 		aSeq.realloc( 16 );
900cdf0e10cSrcweir     	rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True );
901cdf0e10cSrcweir 	}
902cdf0e10cSrcweir 
903cdf0e10cSrcweir     return aSeq;
904cdf0e10cSrcweir }
905cdf0e10cSrcweir 
906cdf0e10cSrcweir // -----------------------------------------------------------------------------
907cdf0e10cSrcweir 
908cdf0e10cSrcweir ValueItemAcc* ValueItemAcc::getImplementation( const uno::Reference< uno::XInterface >& rxData )
909cdf0e10cSrcweir     throw()
910cdf0e10cSrcweir {
911cdf0e10cSrcweir     try
912cdf0e10cSrcweir     {
913cdf0e10cSrcweir 	    uno::Reference< lang::XUnoTunnel > xUnoTunnel( rxData, uno::UNO_QUERY );
914cdf0e10cSrcweir         return( xUnoTunnel.is() ? reinterpret_cast<ValueItemAcc*>(sal::static_int_cast<sal_IntPtr>(xUnoTunnel->getSomething( ValueItemAcc::getUnoTunnelId() ))) : NULL );
915cdf0e10cSrcweir     }
916cdf0e10cSrcweir     catch( const ::com::sun::star::uno::Exception& )
917cdf0e10cSrcweir 	{
918cdf0e10cSrcweir         return NULL;
919cdf0e10cSrcweir 	}
920cdf0e10cSrcweir }
921cdf0e10cSrcweir 
922cdf0e10cSrcweir // -----------------------------------------------------------------------------
923cdf0e10cSrcweir 
924cdf0e10cSrcweir uno::Reference< accessibility::XAccessibleContext > SAL_CALL ValueItemAcc::getAccessibleContext()
925cdf0e10cSrcweir     throw (uno::RuntimeException)
926cdf0e10cSrcweir {
927cdf0e10cSrcweir     return this;
928cdf0e10cSrcweir }
929cdf0e10cSrcweir 
930cdf0e10cSrcweir // -----------------------------------------------------------------------------
931cdf0e10cSrcweir 
932cdf0e10cSrcweir sal_Int32 SAL_CALL ValueItemAcc::getAccessibleChildCount()
933cdf0e10cSrcweir     throw (uno::RuntimeException)
934cdf0e10cSrcweir {
935cdf0e10cSrcweir     return 0;
936cdf0e10cSrcweir }
937cdf0e10cSrcweir 
938cdf0e10cSrcweir // -----------------------------------------------------------------------------
939cdf0e10cSrcweir 
940cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleChild( sal_Int32 )
941cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
942cdf0e10cSrcweir {
943cdf0e10cSrcweir     throw lang::IndexOutOfBoundsException();
944cdf0e10cSrcweir }
945cdf0e10cSrcweir 
946cdf0e10cSrcweir // -----------------------------------------------------------------------------
947cdf0e10cSrcweir 
948cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleParent()
949cdf0e10cSrcweir     throw (uno::RuntimeException)
950cdf0e10cSrcweir {
951cdf0e10cSrcweir     const vos::OGuard                               aSolarGuard( Application::GetSolarMutex() );
952cdf0e10cSrcweir     uno::Reference< accessibility::XAccessible >    xRet;
953cdf0e10cSrcweir 
954cdf0e10cSrcweir     if( mpParent )
955cdf0e10cSrcweir         xRet = mpParent->mrParent.GetAccessible();
956cdf0e10cSrcweir 
957cdf0e10cSrcweir     return xRet;
958cdf0e10cSrcweir }
959cdf0e10cSrcweir 
960cdf0e10cSrcweir // -----------------------------------------------------------------------------
961cdf0e10cSrcweir 
962cdf0e10cSrcweir sal_Int32 SAL_CALL ValueItemAcc::getAccessibleIndexInParent()
963cdf0e10cSrcweir     throw (uno::RuntimeException)
964cdf0e10cSrcweir {
965cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
966cdf0e10cSrcweir     // The index defaults to -1 to indicate the child does not belong to its
967cdf0e10cSrcweir     // parent.
968cdf0e10cSrcweir     sal_Int32 nIndexInParent = -1;
969cdf0e10cSrcweir 
970cdf0e10cSrcweir     if( mpParent )
971cdf0e10cSrcweir     {
972cdf0e10cSrcweir         bool bDone = false;
973cdf0e10cSrcweir 
974cdf0e10cSrcweir         sal_uInt16 nCount = mpParent->mrParent.ImplGetVisibleItemCount();
975cdf0e10cSrcweir         ValueSetItem* pItem;
976cdf0e10cSrcweir         for (sal_uInt16 i=0; i<nCount && !bDone; i++)
977cdf0e10cSrcweir         {
978cdf0e10cSrcweir             // Guard the retrieval of the i-th child with a try/catch block
979cdf0e10cSrcweir             // just in case the number of children changes in the mean time.
980cdf0e10cSrcweir             try
981cdf0e10cSrcweir             {
982*2bfcd321SSteve Yin //IAccessibility2 Implementation 2009-----
983*2bfcd321SSteve Yin                 //pItem = mpParent->mrParent.ImplGetVisibleItem (i);
984*2bfcd321SSteve Yin                 pItem = mpParent->mrParent.ImplGetItem(i);
985*2bfcd321SSteve Yin //-----IAccessibility2 Implementation 2009
986cdf0e10cSrcweir             }
987cdf0e10cSrcweir             catch (lang::IndexOutOfBoundsException aException)
988cdf0e10cSrcweir             {
989cdf0e10cSrcweir                 pItem = NULL;
990cdf0e10cSrcweir             }
991cdf0e10cSrcweir 
992cdf0e10cSrcweir             // Do not create an accessible object for the test.
993cdf0e10cSrcweir             if (pItem != NULL && pItem->mpxAcc != NULL)
994cdf0e10cSrcweir                 if (pItem->GetAccessible( mbIsTransientChildrenDisabled ).get() == this )
995cdf0e10cSrcweir                 {
996cdf0e10cSrcweir                     nIndexInParent = i;
997cdf0e10cSrcweir                     bDone = true;
998cdf0e10cSrcweir                 }
999cdf0e10cSrcweir         }
1000cdf0e10cSrcweir     }
1001cdf0e10cSrcweir 
1002*2bfcd321SSteve Yin //IAccessibility2 Implementation 2009-----
1003*2bfcd321SSteve Yin 	//if this valueset contain a none field(common value is default), then we should increase the real index and set the noitem index value equal 0.
1004*2bfcd321SSteve Yin 	if ( mpParent && ( (mpParent->mrParent.GetStyle() & WB_NONEFIELD) != 0 ) )
1005*2bfcd321SSteve Yin 	{
1006*2bfcd321SSteve Yin 		ValueSetItem* pFirstItem = mpParent->mrParent.ImplGetItem (VALUESET_ITEM_NONEITEM);
1007*2bfcd321SSteve Yin 		if( pFirstItem && pFirstItem ->GetAccessible(mbIsTransientChildrenDisabled).get() == this )
1008*2bfcd321SSteve Yin 			nIndexInParent = 0;
1009*2bfcd321SSteve Yin 		else
1010*2bfcd321SSteve Yin 			nIndexInParent++;
1011*2bfcd321SSteve Yin 	}
1012*2bfcd321SSteve Yin //-----IAccessibility2 Implementation 2009
1013cdf0e10cSrcweir     return nIndexInParent;
1014cdf0e10cSrcweir }
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir // -----------------------------------------------------------------------------
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir sal_Int16 SAL_CALL ValueItemAcc::getAccessibleRole()
1019cdf0e10cSrcweir     throw (uno::RuntimeException)
1020cdf0e10cSrcweir {
1021cdf0e10cSrcweir     return accessibility::AccessibleRole::LIST_ITEM;
1022cdf0e10cSrcweir }
1023cdf0e10cSrcweir 
1024cdf0e10cSrcweir // -----------------------------------------------------------------------------
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir ::rtl::OUString SAL_CALL ValueItemAcc::getAccessibleDescription()
1027cdf0e10cSrcweir     throw (uno::RuntimeException)
1028cdf0e10cSrcweir {
1029cdf0e10cSrcweir 	return ::rtl::OUString();
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir // -----------------------------------------------------------------------------
1033cdf0e10cSrcweir 
1034cdf0e10cSrcweir ::rtl::OUString SAL_CALL ValueItemAcc::getAccessibleName()
1035cdf0e10cSrcweir     throw (uno::RuntimeException)
1036cdf0e10cSrcweir {
1037cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
1038cdf0e10cSrcweir     String              aRet;
1039cdf0e10cSrcweir 
1040cdf0e10cSrcweir     if( mpParent )
1041cdf0e10cSrcweir     {
1042cdf0e10cSrcweir         aRet = mpParent->maText;
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir         if( !aRet.Len() )
1045cdf0e10cSrcweir         {
1046cdf0e10cSrcweir             aRet = String( RTL_CONSTASCII_USTRINGPARAM( "Item " ) );
1047cdf0e10cSrcweir             aRet += String::CreateFromInt32( mpParent->mnId );
1048cdf0e10cSrcweir         }
1049cdf0e10cSrcweir     }
1050cdf0e10cSrcweir 
1051cdf0e10cSrcweir     return aRet;
1052cdf0e10cSrcweir }
1053cdf0e10cSrcweir 
1054cdf0e10cSrcweir // -----------------------------------------------------------------------------
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL ValueItemAcc::getAccessibleRelationSet()
1057cdf0e10cSrcweir     throw (uno::RuntimeException)
1058cdf0e10cSrcweir {
1059cdf0e10cSrcweir     return uno::Reference< accessibility::XAccessibleRelationSet >();
1060cdf0e10cSrcweir }
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir // -----------------------------------------------------------------------------
1063cdf0e10cSrcweir 
1064cdf0e10cSrcweir uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL ValueItemAcc::getAccessibleStateSet()
1065cdf0e10cSrcweir     throw (uno::RuntimeException)
1066cdf0e10cSrcweir {
1067cdf0e10cSrcweir     const vos::OGuard                   aSolarGuard( Application::GetSolarMutex() );
1068cdf0e10cSrcweir     ::utl::AccessibleStateSetHelper*    pStateSet = new ::utl::AccessibleStateSetHelper;
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir     if( mpParent )
1071cdf0e10cSrcweir     {
1072cdf0e10cSrcweir         pStateSet->AddState (accessibility::AccessibleStateType::ENABLED);
1073cdf0e10cSrcweir         pStateSet->AddState (accessibility::AccessibleStateType::SENSITIVE);
1074cdf0e10cSrcweir         pStateSet->AddState (accessibility::AccessibleStateType::SHOWING);
1075cdf0e10cSrcweir         pStateSet->AddState (accessibility::AccessibleStateType::VISIBLE);
1076cdf0e10cSrcweir         if ( !mbIsTransientChildrenDisabled )
1077cdf0e10cSrcweir             pStateSet->AddState (accessibility::AccessibleStateType::TRANSIENT);
1078cdf0e10cSrcweir 
1079cdf0e10cSrcweir 	    // SELECTABLE
1080cdf0e10cSrcweir 	    pStateSet->AddState( accessibility::AccessibleStateType::SELECTABLE );
1081cdf0e10cSrcweir         //	    pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir 	    // SELECTED
1084cdf0e10cSrcweir         if( mpParent->mrParent.GetSelectItemId() == mpParent->mnId )
1085cdf0e10cSrcweir         {
1086cdf0e10cSrcweir             pStateSet->AddState( accessibility::AccessibleStateType::SELECTED );
1087cdf0e10cSrcweir             //       	    pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED );
1088cdf0e10cSrcweir         }
1089cdf0e10cSrcweir     }
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir     return pStateSet;
1092cdf0e10cSrcweir }
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir // -----------------------------------------------------------------------------
1095cdf0e10cSrcweir 
1096cdf0e10cSrcweir lang::Locale SAL_CALL ValueItemAcc::getLocale()
1097cdf0e10cSrcweir     throw (accessibility::IllegalAccessibleComponentStateException, uno::RuntimeException)
1098cdf0e10cSrcweir {
1099cdf0e10cSrcweir     const vos::OGuard                               aSolarGuard( Application::GetSolarMutex() );
1100cdf0e10cSrcweir     const ::rtl::OUString                           aEmptyStr;
1101cdf0e10cSrcweir     uno::Reference< accessibility::XAccessible >    xParent( getAccessibleParent() );
1102cdf0e10cSrcweir     lang::Locale                                    aRet( aEmptyStr, aEmptyStr, aEmptyStr );
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir     if( xParent.is() )
1105cdf0e10cSrcweir     {
1106cdf0e10cSrcweir         uno::Reference< accessibility::XAccessibleContext > xParentContext( xParent->getAccessibleContext() );
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir         if( xParentContext.is() )
1109cdf0e10cSrcweir             aRet = xParentContext->getLocale();
1110cdf0e10cSrcweir     }
1111cdf0e10cSrcweir 
1112cdf0e10cSrcweir     return aRet;
1113cdf0e10cSrcweir }
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir // -----------------------------------------------------------------------------
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir void SAL_CALL ValueItemAcc::addEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
1118cdf0e10cSrcweir     throw (uno::RuntimeException)
1119cdf0e10cSrcweir {
1120cdf0e10cSrcweir     const ::vos::OGuard aGuard( maMutex );
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir 	if( rxListener.is() )
1123cdf0e10cSrcweir     {
1124cdf0e10cSrcweir        	::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter = mxEventListeners.begin();
1125cdf0e10cSrcweir 		sal_Bool bFound = sal_False;
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir 		while( !bFound && ( aIter != mxEventListeners.end() ) )
1128cdf0e10cSrcweir         {
1129cdf0e10cSrcweir 			if( *aIter == rxListener )
1130cdf0e10cSrcweir                 bFound = sal_True;
1131cdf0e10cSrcweir             else
1132cdf0e10cSrcweir                 aIter++;
1133cdf0e10cSrcweir         }
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir 		if (!bFound)
1136cdf0e10cSrcweir             mxEventListeners.push_back( rxListener );
1137cdf0e10cSrcweir     }
1138cdf0e10cSrcweir }
1139cdf0e10cSrcweir 
1140cdf0e10cSrcweir // -----------------------------------------------------------------------------
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir void SAL_CALL ValueItemAcc::removeEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
1143cdf0e10cSrcweir     throw (uno::RuntimeException)
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir     const ::vos::OGuard aGuard( maMutex );
1146cdf0e10cSrcweir 
1147cdf0e10cSrcweir 	if( rxListener.is() )
1148cdf0e10cSrcweir     {
1149cdf0e10cSrcweir        	::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter = mxEventListeners.begin();
1150cdf0e10cSrcweir 		sal_Bool bFound = sal_False;
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir 		while( !bFound && ( aIter != mxEventListeners.end() ) )
1153cdf0e10cSrcweir         {
1154cdf0e10cSrcweir 			if( *aIter == rxListener )
1155cdf0e10cSrcweir             {
1156cdf0e10cSrcweir                 mxEventListeners.erase( aIter );
1157cdf0e10cSrcweir                 bFound = sal_True;
1158cdf0e10cSrcweir             }
1159cdf0e10cSrcweir             else
1160cdf0e10cSrcweir                 aIter++;
1161cdf0e10cSrcweir         }
1162cdf0e10cSrcweir     }
1163cdf0e10cSrcweir }
1164cdf0e10cSrcweir 
1165cdf0e10cSrcweir // -----------------------------------------------------------------------------
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir sal_Bool SAL_CALL ValueItemAcc::containsPoint( const awt::Point& aPoint )
1168cdf0e10cSrcweir     throw (uno::RuntimeException)
1169cdf0e10cSrcweir {
1170cdf0e10cSrcweir     const awt::Rectangle    aRect( getBounds() );
1171cdf0e10cSrcweir     const Point             aSize( aRect.Width, aRect.Height );
1172cdf0e10cSrcweir     const Point             aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir     return Rectangle( aNullPoint, aSize ).IsInside( aTestPoint );
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir 
1177cdf0e10cSrcweir // -----------------------------------------------------------------------------
1178cdf0e10cSrcweir 
1179cdf0e10cSrcweir uno::Reference< accessibility::XAccessible > SAL_CALL ValueItemAcc::getAccessibleAtPoint( const awt::Point& )
1180cdf0e10cSrcweir     throw (uno::RuntimeException)
1181cdf0e10cSrcweir {
1182cdf0e10cSrcweir     uno::Reference< accessibility::XAccessible > xRet;
1183cdf0e10cSrcweir     return xRet;
1184cdf0e10cSrcweir }
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir // -----------------------------------------------------------------------------
1187cdf0e10cSrcweir 
1188cdf0e10cSrcweir awt::Rectangle SAL_CALL ValueItemAcc::getBounds()
1189cdf0e10cSrcweir     throw (uno::RuntimeException)
1190cdf0e10cSrcweir {
1191cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
1192cdf0e10cSrcweir     awt::Rectangle      aRet;
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir     if( mpParent )
1195cdf0e10cSrcweir     {
1196cdf0e10cSrcweir         Rectangle   aRect( mpParent->maRect );
1197cdf0e10cSrcweir         Point       aOrigin;
1198cdf0e10cSrcweir         Rectangle   aParentRect( aOrigin, mpParent->mrParent.GetOutputSizePixel() );
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir         aRect.Intersection( aParentRect );
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir         aRet.X = aRect.Left();
1203cdf0e10cSrcweir         aRet.Y = aRect.Top();
1204cdf0e10cSrcweir         aRet.Width = aRect.GetWidth();
1205cdf0e10cSrcweir         aRet.Height = aRect.GetHeight();
1206cdf0e10cSrcweir     }
1207cdf0e10cSrcweir 
1208cdf0e10cSrcweir     return aRet;
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir // -----------------------------------------------------------------------------
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir awt::Point SAL_CALL ValueItemAcc::getLocation()
1214cdf0e10cSrcweir     throw (uno::RuntimeException)
1215cdf0e10cSrcweir {
1216cdf0e10cSrcweir     const awt::Rectangle    aRect( getBounds() );
1217cdf0e10cSrcweir     awt::Point              aRet;
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir     aRet.X = aRect.X;
1220cdf0e10cSrcweir     aRet.Y = aRect.Y;
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir     return aRet;
1223cdf0e10cSrcweir }
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir // -----------------------------------------------------------------------------
1226cdf0e10cSrcweir 
1227cdf0e10cSrcweir awt::Point SAL_CALL ValueItemAcc::getLocationOnScreen()
1228cdf0e10cSrcweir     throw (uno::RuntimeException)
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir     const vos::OGuard   aSolarGuard( Application::GetSolarMutex() );
1231cdf0e10cSrcweir     awt::Point          aRet;
1232cdf0e10cSrcweir 
1233cdf0e10cSrcweir     if( mpParent )
1234cdf0e10cSrcweir     {
1235cdf0e10cSrcweir         const Point aScreenPos( mpParent->mrParent.OutputToAbsoluteScreenPixel( mpParent->maRect.TopLeft() ) );
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir         aRet.X = aScreenPos.X();
1238cdf0e10cSrcweir         aRet.Y = aScreenPos.Y();
1239cdf0e10cSrcweir     }
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir     return aRet;
1242cdf0e10cSrcweir }
1243cdf0e10cSrcweir 
1244cdf0e10cSrcweir // -----------------------------------------------------------------------------
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir awt::Size SAL_CALL ValueItemAcc::getSize()
1247cdf0e10cSrcweir     throw (uno::RuntimeException)
1248cdf0e10cSrcweir {
1249cdf0e10cSrcweir     const awt::Rectangle    aRect( getBounds() );
1250cdf0e10cSrcweir     awt::Size               aRet;
1251cdf0e10cSrcweir 
1252cdf0e10cSrcweir     aRet.Width = aRect.Width;
1253cdf0e10cSrcweir     aRet.Height = aRect.Height;
1254cdf0e10cSrcweir 
1255cdf0e10cSrcweir     return aRet;
1256cdf0e10cSrcweir }
1257cdf0e10cSrcweir 
1258cdf0e10cSrcweir // -----------------------------------------------------------------------------
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir void SAL_CALL ValueItemAcc::grabFocus()
1261cdf0e10cSrcweir     throw (uno::RuntimeException)
1262cdf0e10cSrcweir {
1263cdf0e10cSrcweir     // nothing to do
1264cdf0e10cSrcweir }
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir // -----------------------------------------------------------------------------
1267cdf0e10cSrcweir 
1268cdf0e10cSrcweir uno::Any SAL_CALL ValueItemAcc::getAccessibleKeyBinding()
1269cdf0e10cSrcweir     throw (uno::RuntimeException)
1270cdf0e10cSrcweir {
1271cdf0e10cSrcweir     return uno::Any();
1272cdf0e10cSrcweir }
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir // -----------------------------------------------------------------------------
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir sal_Int32 SAL_CALL ValueItemAcc::getForeground(  )
1277cdf0e10cSrcweir     throw (uno::RuntimeException)
1278cdf0e10cSrcweir {
1279cdf0e10cSrcweir     sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
1280cdf0e10cSrcweir     return static_cast<sal_Int32>(nColor);
1281cdf0e10cSrcweir }
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir // -----------------------------------------------------------------------------
1284cdf0e10cSrcweir 
1285cdf0e10cSrcweir sal_Int32 SAL_CALL ValueItemAcc::getBackground(  )
1286cdf0e10cSrcweir     throw (uno::RuntimeException)
1287cdf0e10cSrcweir {
1288cdf0e10cSrcweir     sal_uInt32 nColor;
1289cdf0e10cSrcweir     if (mpParent && mpParent->meType == VALUESETITEM_COLOR)
1290cdf0e10cSrcweir         nColor = mpParent->maColor.GetColor();
1291cdf0e10cSrcweir     else
1292cdf0e10cSrcweir         nColor = Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
1293cdf0e10cSrcweir     return static_cast<sal_Int32>(nColor);
1294cdf0e10cSrcweir }
1295cdf0e10cSrcweir 
1296cdf0e10cSrcweir // -----------------------------------------------------------------------------
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir sal_Int64 SAL_CALL ValueItemAcc::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw( uno::RuntimeException )
1299cdf0e10cSrcweir {
1300cdf0e10cSrcweir     sal_Int64 nRet;
1301cdf0e10cSrcweir 
1302cdf0e10cSrcweir     if( ( rId.getLength() == 16 ) && ( 0 == rtl_compareMemory( ValueItemAcc::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
1303cdf0e10cSrcweir         nRet = reinterpret_cast< sal_Int64 >( this );
1304cdf0e10cSrcweir     else
1305cdf0e10cSrcweir         nRet = 0;
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir 	return nRet;
1308cdf0e10cSrcweir }
1309