xref: /AOO41X/main/sc/source/ui/Accessibility/AccessibleDataPilotControl.cxx (revision 5fa474865bd1ef366a21e2477014a2b707635425)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 #include "AccessibleDataPilotControl.hxx"
27 #include "unoguard.hxx"
28 #include "fieldwnd.hxx"
29 
30 #include <com/sun/star/accessibility/AccessibleRole.hpp>
31 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
32 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
33 
34 #include <unotools/accessiblestatesethelper.hxx>
35 #include <rtl/uuid.h>
36 #include <tools/gen.hxx>
37 #include <toolkit/helper/convert.hxx>
38 #include <tools/debug.hxx>
39 
40 using namespace	::com::sun::star;
41 using namespace	::com::sun::star::accessibility;
42 
43 class ScAccessibleDataPilotButton
44 	:	public ScAccessibleContextBase
45 {
46 public:
47 	//=====  internal  ========================================================
48 	ScAccessibleDataPilotButton(
49         const ::com::sun::star::uno::Reference<
50         ::com::sun::star::accessibility::XAccessible>& rxParent,
51         ScPivotFieldWindow* pFieldWindow,
52         sal_Int32 nIndex);
53 
54 	virtual void Init();
55 
56     using ScAccessibleContextBase::disposing;
57     virtual void SAL_CALL disposing();
58 
59     void SetIndex(sal_Int32 nIndex) { mnIndex = nIndex; }
60     void NameChanged();
61     void SetFocused();
62     void ResetFocused();
63 protected:
64 	virtual ~ScAccessibleDataPilotButton(void);
65 public:
66 	///=====  XAccessibleComponent  ============================================
67 
68     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
69 		SAL_CALL getAccessibleAtPoint(
70 		const ::com::sun::star::awt::Point& rPoint )
71 		throw (::com::sun::star::uno::RuntimeException);
72 
73     virtual sal_Bool SAL_CALL isVisible(  )
74 		throw (::com::sun::star::uno::RuntimeException);
75 
76     virtual void SAL_CALL grabFocus(  )
77 		throw (::com::sun::star::uno::RuntimeException);
78 
79     virtual sal_Int32 SAL_CALL getForeground(  )
80         throw (::com::sun::star::uno::RuntimeException);
81 
82     virtual sal_Int32 SAL_CALL getBackground(  )
83         throw (::com::sun::star::uno::RuntimeException);
84 
85     ///=====  XAccessibleContext  ==============================================
86 
87     ///	Return the number of currently visible children.
88     virtual sal_Int32 SAL_CALL
89     	getAccessibleChildCount(void) throw (::com::sun::star::uno::RuntimeException);
90 
91     ///	Return the specified child or NULL if index is invalid.
92     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
93     	getAccessibleChild(sal_Int32 nIndex)
94         throw (::com::sun::star::uno::RuntimeException,
95 				::com::sun::star::lang::IndexOutOfBoundsException);
96 
97     ///	Return this objects index among the parents children.
98 	virtual	sal_Int32 SAL_CALL
99     	getAccessibleIndexInParent(void)
100         throw (::com::sun::star::uno::RuntimeException);
101 
102     ///	Return the set of current states.
103 	virtual ::com::sun::star::uno::Reference<
104             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
105     	getAccessibleStateSet(void)
106         throw (::com::sun::star::uno::RuntimeException);
107 
108 	///=====  XServiceInfo  ====================================================
109 
110     /**	Returns an identifier for the implementation of this object.
111     */
112 	virtual ::rtl::OUString SAL_CALL
113     	getImplementationName(void)
114         throw (::com::sun::star::uno::RuntimeException);
115 
116 	///=====  XTypeProvider  ===================================================
117 
118 	/**	Returns a implementation id.
119     */
120     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
121         getImplementationId(void)
122         throw (::com::sun::star::uno::RuntimeException);
123 
124 protected:
125     ///	Return this object's description.
126 	virtual ::rtl::OUString SAL_CALL
127     	createAccessibleDescription(void)
128         throw (::com::sun::star::uno::RuntimeException);
129 
130     ///	Return the object's current name.
131 	virtual ::rtl::OUString SAL_CALL
132     	createAccessibleName(void)
133         throw (::com::sun::star::uno::RuntimeException);
134 
135     ///	Return the object's current bounding box relative to the desktop.
136 	virtual Rectangle GetBoundingBoxOnScreen(void) const
137 		throw (::com::sun::star::uno::RuntimeException);
138 
139 	///	Return the object's current bounding box relative to the parent object.
140 	virtual Rectangle GetBoundingBox(void) const
141 		throw (::com::sun::star::uno::RuntimeException);
142 
143 private:
144     ScPivotFieldWindow* mpFieldWindow;
145     sal_Int32        mnIndex;
146 };
147 
148 	//=====  internal  ========================================================
149 ScAccessibleDataPilotControl::ScAccessibleDataPilotControl(
150         const uno::Reference<XAccessible>& rxParent,
151         ScPivotFieldWindow* pFieldWindow)
152         :
153     ScAccessibleContextBase(rxParent, AccessibleRole::GROUP_BOX),
154     mpFieldWindow(pFieldWindow)
155 {
156     if (mpFieldWindow)
157         maChildren.resize(mpFieldWindow->GetFieldCount());
158 }
159 
160 ScAccessibleDataPilotControl::~ScAccessibleDataPilotControl(void)
161 {
162 	if (!IsDefunc() && !rBHelper.bInDispose)
163 	{
164 		// increment refcount to prevent double call off dtor
165 		osl_incrementInterlockedCount( &m_refCount );
166 		// call dispose to inform object wich have a weak reference to this object
167 		dispose();
168 	}
169 }
170 
171 void ScAccessibleDataPilotControl::Init()
172 {
173 }
174 
175 void SAL_CALL ScAccessibleDataPilotControl::disposing()
176 {
177     ScUnoGuard aGuard;
178     mpFieldWindow = NULL;
179 
180     ScAccessibleContextBase::disposing();
181 }
182 
183 void ScAccessibleDataPilotControl::AddField(sal_Int32 nNewIndex)
184 {
185     sal_Bool bAdded(sal_False);
186     if (static_cast<size_t>(nNewIndex) == maChildren.size())
187     {
188         maChildren.push_back(AccessibleWeak());
189         bAdded = sal_True;
190     }
191     else if (static_cast<size_t>(nNewIndex) < maChildren.size())
192     {
193         ::std::vector < AccessibleWeak >::iterator aItr = maChildren.begin() + nNewIndex;
194         maChildren.insert(aItr, AccessibleWeak());
195 
196         ::std::vector < AccessibleWeak >::iterator aEndItr = maChildren.end();
197         aItr = maChildren.begin() + nNewIndex + 1;
198         uno::Reference< XAccessible > xTempAcc;
199         sal_Int32 nIndex = nNewIndex + 1;
200         while (aItr != aEndItr)
201         {
202             xTempAcc = aItr->xWeakAcc;
203             if (xTempAcc.is() && aItr->pAcc)
204                 aItr->pAcc->SetIndex(nIndex);
205             ++nIndex;
206             ++aItr;
207         }
208         bAdded = sal_True;
209     }
210     else
211     {
212         DBG_ERRORFILE("did not recognize a child count change");
213     }
214 
215     if (bAdded)
216     {
217 		AccessibleEventObject aEvent;
218 		aEvent.EventId = AccessibleEventId::CHILD;
219 		aEvent.Source = uno::Reference< XAccessibleContext >(this);
220 		aEvent.NewValue <<= getAccessibleChild(nNewIndex);
221 
222 		CommitChange(aEvent); // new child - event
223     }
224 }
225 
226 void ScAccessibleDataPilotControl::RemoveField(sal_Int32 nOldIndex)
227 {
228     sal_Bool bRemoved(sal_False);
229     uno::Reference< XAccessible > xTempAcc;
230     ScAccessibleDataPilotButton* pField = NULL;
231     if (static_cast<size_t>(nOldIndex) < maChildren.size())
232     {
233         xTempAcc = getAccessibleChild(nOldIndex);
234         pField = maChildren[nOldIndex].pAcc;
235 
236         ::std::vector < AccessibleWeak >::iterator aItr = maChildren.begin() + nOldIndex;
237         aItr = maChildren.erase(aItr);
238 
239         ::std::vector < AccessibleWeak >::iterator aEndItr = maChildren.end();
240         uno::Reference< XAccessible > xItrAcc;
241         while (aItr != aEndItr)
242         {
243             xItrAcc = aItr->xWeakAcc;
244             if (xItrAcc.is() && aItr->pAcc)
245                 aItr->pAcc->SetIndex(nOldIndex);
246             ++nOldIndex;
247             ++aItr;
248         }
249         bRemoved = sal_True;
250     }
251     else
252     {
253         DBG_ERRORFILE("did not recognize a child count change");
254     }
255 
256     if (bRemoved)
257     {
258 		AccessibleEventObject aEvent;
259 		aEvent.EventId = AccessibleEventId::CHILD;
260 		aEvent.Source = uno::Reference< XAccessibleContext >(this);
261 		aEvent.NewValue <<= xTempAcc;
262 
263 		CommitChange(aEvent); // gone child - event
264 
265         if (pField)
266             pField->dispose();
267     }
268 }
269 
270 void ScAccessibleDataPilotControl::FieldFocusChange(sal_Int32 nOldIndex, sal_Int32 nNewIndex)
271 {
272     DBG_ASSERT(static_cast<size_t>(nOldIndex) < maChildren.size() &&
273                 static_cast<size_t>(nNewIndex) < maChildren.size(), "did not recognize a child count change");
274 
275     uno::Reference < XAccessible > xTempAcc = maChildren[nOldIndex].xWeakAcc;
276     if (xTempAcc.is() && maChildren[nOldIndex].pAcc)
277         maChildren[nOldIndex].pAcc->ResetFocused();
278 
279     xTempAcc = maChildren[nNewIndex].xWeakAcc;
280     if (xTempAcc.is() && maChildren[nNewIndex].pAcc)
281         maChildren[nNewIndex].pAcc->SetFocused();
282 }
283 
284 void ScAccessibleDataPilotControl::FieldNameChange(sal_Int32 nIndex)
285 {
286     DBG_ASSERT(static_cast<size_t>(nIndex) < maChildren.size(), "did not recognize a child count change");
287 
288     uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc;
289     if (xTempAcc.is() && maChildren[nIndex].pAcc)
290         maChildren[nIndex].pAcc->ChangeName();
291 }
292 
293 void ScAccessibleDataPilotControl::GotFocus()
294 {
295     if (mpFieldWindow)
296     {
297         DBG_ASSERT(mpFieldWindow->GetFieldCount() == maChildren.size(), "did not recognize a child count change");
298 
299         sal_Int32 nIndex(mpFieldWindow->GetSelectedIndex());
300         uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc;
301         if (xTempAcc.is() && maChildren[nIndex].pAcc)
302             maChildren[nIndex].pAcc->SetFocused();
303     }
304 }
305 
306 void ScAccessibleDataPilotControl::LostFocus()
307 {
308     if (mpFieldWindow)
309     {
310         DBG_ASSERT(mpFieldWindow->GetFieldCount() == maChildren.size(), "did not recognize a child count change");
311 
312         sal_Int32 nIndex(mpFieldWindow->GetSelectedIndex());
313         uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc;
314         if (xTempAcc.is() && maChildren[nIndex].pAcc)
315             maChildren[nIndex].pAcc->ResetFocused();
316     }
317 }
318 
319 	///=====  XAccessibleComponent  ============================================
320 
321 uno::Reference< XAccessible > SAL_CALL ScAccessibleDataPilotControl::getAccessibleAtPoint(
322 		const awt::Point& rPoint )
323 		throw (uno::RuntimeException)
324 {
325     uno::Reference<XAccessible> xAcc;
326     if (containsPoint(rPoint))
327     {
328         ScUnoGuard aGuard;
329         IsObjectValid();
330         if (mpFieldWindow)
331         {
332             Point aAbsPoint(VCLPoint(rPoint));
333             Point aControlEdge(GetBoundingBoxOnScreen().TopLeft());
334             Point aRelPoint(aAbsPoint - aControlEdge);
335             size_t nChildIndex = mpFieldWindow->GetFieldIndex( aRelPoint );
336             if( nChildIndex != PIVOTFIELD_INVALID )
337                 xAcc = getAccessibleChild(static_cast< long >( nChildIndex ));
338         }
339     }
340     return xAcc;
341 }
342 
343 sal_Bool SAL_CALL ScAccessibleDataPilotControl::isVisible(  )
344         throw (uno::RuntimeException)
345 {
346     return sal_True;
347 }
348 
349 void SAL_CALL ScAccessibleDataPilotControl::grabFocus(  )
350 		throw (uno::RuntimeException)
351 {
352     ScUnoGuard aGuard;
353     IsObjectValid();
354     if (mpFieldWindow)
355         mpFieldWindow->GrabFocus();
356 }
357 
358 sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getForeground(  )
359     throw (uno::RuntimeException)
360 {
361     ScUnoGuard aGuard;
362     IsObjectValid();
363     sal_Int32 nColor(0);
364     if (mpFieldWindow)
365     {
366         nColor = mpFieldWindow->GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
367     }
368     return nColor;
369 }
370 
371 sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getBackground(  )
372     throw (uno::RuntimeException)
373 {
374     ScUnoGuard aGuard;
375     IsObjectValid();
376     sal_Int32 nColor(0);
377     if (mpFieldWindow)
378     {
379         const StyleSettings& rStyleSett = mpFieldWindow->GetSettings().GetStyleSettings();
380         nColor = (mpFieldWindow->GetType() == PIVOTFIELDTYPE_SELECT) ? rStyleSett.GetFaceColor().GetColor() : rStyleSett.GetWindowColor().GetColor();
381     }
382     return nColor;
383 }
384 
385 	///=====  XAccessibleContext  ==============================================
386 
387 sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getAccessibleChildCount(void)
388         throw (uno::RuntimeException)
389 {
390     ScUnoGuard aGuard;
391     IsObjectValid();
392     if (mpFieldWindow)
393         return mpFieldWindow->GetFieldCount();
394     else
395         return 0;
396 }
397 
398 uno::Reference< XAccessible> SAL_CALL ScAccessibleDataPilotControl::getAccessibleChild(sal_Int32 nIndex)
399         throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
400 {
401     ScUnoGuard aGuard;
402     IsObjectValid();
403     uno::Reference<XAccessible> xAcc;
404     if (mpFieldWindow)
405     {
406         if (nIndex < 0 || static_cast< size_t >( nIndex ) >= mpFieldWindow->GetFieldCount())
407             throw lang::IndexOutOfBoundsException();
408 
409         DBG_ASSERT(mpFieldWindow->GetFieldCount() == maChildren.size(), "did not recognize a child count change");
410 
411         uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc;
412         if (!xTempAcc.is())
413         {
414             maChildren[nIndex].pAcc = new ScAccessibleDataPilotButton(this, mpFieldWindow, nIndex);
415             xTempAcc = maChildren[nIndex].pAcc;
416             maChildren[nIndex].xWeakAcc = xTempAcc;
417         }
418 
419         xAcc = xTempAcc;
420     }
421     return xAcc;
422 }
423 
424 uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDataPilotControl::getAccessibleStateSet(void)
425         throw (uno::RuntimeException)
426 {
427 	ScUnoGuard aGuard;
428     IsObjectValid();
429 
430 	utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
431 
432     if (IsDefunc())
433         pStateSet->AddState(AccessibleStateType::DEFUNC);
434     else
435     {
436         pStateSet->AddState(AccessibleStateType::ENABLED);
437         pStateSet->AddState(AccessibleStateType::OPAQUE);
438         if (isShowing())
439             pStateSet->AddState(AccessibleStateType::SHOWING);
440         if (isVisible())
441             pStateSet->AddState(AccessibleStateType::VISIBLE);
442     }
443 
444     return pStateSet;
445 }
446 
447 	///=====  XServiceInfo  ====================================================
448 
449 ::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::getImplementationName(void)
450         throw (uno::RuntimeException)
451 {
452     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDataPilotControl"));
453 }
454 
455 	///=====  XTypeProvider  ===================================================
456 
457 uno::Sequence<sal_Int8> SAL_CALL ScAccessibleDataPilotControl::getImplementationId(void)
458         throw (uno::RuntimeException)
459 {
460     ScUnoGuard aGuard;
461     IsObjectValid();
462 	static uno::Sequence<sal_Int8> aId;
463 	if (aId.getLength() == 0)
464 	{
465 		aId.realloc (16);
466 		rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
467 	}
468 	return aId;
469 }
470 
471 	//=====  internal  ========================================================
472 
473 ::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::createAccessibleDescription(void)
474         throw (uno::RuntimeException)
475 {
476     ScUnoGuard aGuard;
477     IsObjectValid();
478     if (mpFieldWindow)
479         return mpFieldWindow->GetDescription();
480 
481     return rtl::OUString();
482 }
483 
484 ::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::createAccessibleName(void)
485         throw (uno::RuntimeException)
486 {
487     ScUnoGuard aGuard;
488     IsObjectValid();
489     if (mpFieldWindow)
490         return mpFieldWindow->GetName();
491 
492     return rtl::OUString();
493 }
494 
495 Rectangle ScAccessibleDataPilotControl::GetBoundingBoxOnScreen(void) const
496 		throw (uno::RuntimeException)
497 {
498 	if (mpFieldWindow)
499 		return mpFieldWindow->GetWindowExtentsRelative(NULL);
500     else
501 	    return Rectangle();
502 }
503 
504 Rectangle ScAccessibleDataPilotControl::GetBoundingBox(void) const
505 		throw (uno::RuntimeException)
506 {
507     if (mpFieldWindow)
508         return mpFieldWindow->GetWindowExtentsRelative(mpFieldWindow->GetAccessibleParentWindow());
509     else
510         return Rectangle();
511 }
512 
513 
514 //===============================================================================
515 
516 ScAccessibleDataPilotButton::ScAccessibleDataPilotButton(
517         const ::com::sun::star::uno::Reference<
518         ::com::sun::star::accessibility::XAccessible>& rxParent,
519         ScPivotFieldWindow* pFieldWindow,
520         sal_Int32 nIndex)
521     : ScAccessibleContextBase(rxParent, AccessibleRole::PUSH_BUTTON),
522     mpFieldWindow(pFieldWindow),
523     mnIndex(nIndex)
524 {
525 }
526 
527 ScAccessibleDataPilotButton::~ScAccessibleDataPilotButton(void)
528 {
529 	if (!IsDefunc() && !rBHelper.bInDispose)
530 	{
531 		// increment refcount to prevent double call off dtor
532 		osl_incrementInterlockedCount( &m_refCount );
533 		// call dispose to inform object wich have a weak reference to this object
534 		dispose();
535 	}
536 }
537 
538 void ScAccessibleDataPilotButton::Init()
539 {
540 }
541 
542 void SAL_CALL ScAccessibleDataPilotButton::disposing()
543 {
544     ScUnoGuard aGuard;
545     mpFieldWindow = NULL;
546 
547     ScAccessibleContextBase::disposing();
548 }
549 
550 void ScAccessibleDataPilotButton::SetFocused()
551 {
552 	CommitFocusGained();
553 }
554 
555 void ScAccessibleDataPilotButton::ResetFocused()
556 {
557 	CommitFocusLost();
558 }
559 
560 	///=====  XAccessibleComponent  ============================================
561 
562 uno::Reference< XAccessible > SAL_CALL ScAccessibleDataPilotButton::getAccessibleAtPoint(
563         const ::com::sun::star::awt::Point& /* rPoint */ )
564 		throw (::com::sun::star::uno::RuntimeException)
565 {
566     return NULL;
567 }
568 
569 sal_Bool SAL_CALL ScAccessibleDataPilotButton::isVisible(  )
570 		throw (::com::sun::star::uno::RuntimeException)
571 {
572     return sal_True;
573 }
574 
575 void SAL_CALL ScAccessibleDataPilotButton::grabFocus(  )
576 		throw (::com::sun::star::uno::RuntimeException)
577 {
578     ScUnoGuard aGuard;
579     IsObjectValid();
580     if (mpFieldWindow)
581     {
582         mpFieldWindow->GrabFocusAndSelect(getAccessibleIndexInParent());
583     }
584 }
585 
586 sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getForeground(  )
587 throw (uno::RuntimeException)
588 {
589     ScUnoGuard aGuard;
590     IsObjectValid();
591     sal_Int32 nColor(0);
592     if (mpFieldWindow)
593     {
594         nColor = mpFieldWindow->GetSettings().GetStyleSettings().GetButtonTextColor().GetColor();
595     }
596     return nColor;
597 }
598 
599 sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getBackground(  )
600 throw (uno::RuntimeException)
601 {
602     ScUnoGuard aGuard;
603     IsObjectValid();
604     sal_Int32 nColor(0);
605     if (mpFieldWindow)
606     {
607         nColor = mpFieldWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor();
608     }
609     return nColor;
610 }
611 
612 	///=====  XAccessibleContext  ==============================================
613 
614 sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getAccessibleChildCount(void)
615     throw (::com::sun::star::uno::RuntimeException)
616 {
617     return 0;
618 }
619 
620 uno::Reference< XAccessible> SAL_CALL ScAccessibleDataPilotButton::getAccessibleChild(sal_Int32 /* nIndex */)
621         throw (::com::sun::star::uno::RuntimeException,
622 				::com::sun::star::lang::IndexOutOfBoundsException)
623 {
624     throw lang::IndexOutOfBoundsException();
625 }
626 
627 sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getAccessibleIndexInParent(void)
628         throw (::com::sun::star::uno::RuntimeException)
629 {
630     ScUnoGuard aGuard;
631     IsObjectValid();
632     return mnIndex;
633 }
634 
635 uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDataPilotButton::getAccessibleStateSet(void)
636         throw (::com::sun::star::uno::RuntimeException)
637 {
638 	ScUnoGuard aGuard;
639     IsObjectValid();
640 
641 	utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
642 
643     if (IsDefunc())
644         pStateSet->AddState(AccessibleStateType::DEFUNC);
645     else
646     {
647         pStateSet->AddState(AccessibleStateType::ENABLED);
648         pStateSet->AddState(AccessibleStateType::OPAQUE);
649         pStateSet->AddState(AccessibleStateType::FOCUSABLE);
650         if (mpFieldWindow && (sal::static_int_cast<sal_Int32>(mpFieldWindow->GetSelectedIndex()) == mnIndex))
651             pStateSet->AddState(AccessibleStateType::FOCUSED);
652         if (isShowing())
653             pStateSet->AddState(AccessibleStateType::SHOWING);
654         if (isVisible())
655             pStateSet->AddState(AccessibleStateType::VISIBLE);
656     }
657 
658     return pStateSet;
659 }
660 
661 	///=====  XServiceInfo  ====================================================
662 
663 ::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::getImplementationName(void)
664         throw (::com::sun::star::uno::RuntimeException)
665 {
666     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDataPilotButton"));
667 }
668 
669 	///=====  XTypeProvider  ===================================================
670 
671 uno::Sequence<sal_Int8> SAL_CALL ScAccessibleDataPilotButton::getImplementationId(void)
672         throw (::com::sun::star::uno::RuntimeException)
673 {
674     ScUnoGuard aGuard;
675     IsObjectValid();
676 	static uno::Sequence<sal_Int8> aId;
677 	if (aId.getLength() == 0)
678 	{
679 		aId.realloc (16);
680 		rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
681 	}
682 	return aId;
683 }
684 
685 ::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::createAccessibleDescription(void)
686         throw (::com::sun::star::uno::RuntimeException)
687 {
688     return rtl::OUString();
689 }
690 
691 ::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::createAccessibleName(void)
692         throw (::com::sun::star::uno::RuntimeException)
693 {
694     ScUnoGuard aGuard;
695     IsObjectValid();
696     if (mpFieldWindow)
697         return mpFieldWindow->GetFieldText(getAccessibleIndexInParent());
698 
699     return rtl::OUString();
700 }
701 
702 Rectangle ScAccessibleDataPilotButton::GetBoundingBoxOnScreen(void) const
703 		throw (::com::sun::star::uno::RuntimeException)
704 {
705     Rectangle aRect(GetBoundingBox());
706 
707     if (mpFieldWindow)
708     {
709         Point aParentPos(mpFieldWindow->GetWindowExtentsRelative(NULL).TopLeft());
710         aRect.Move(aParentPos.getX(), aParentPos.getY());
711     }
712 
713     return aRect;
714 }
715 
716 Rectangle ScAccessibleDataPilotButton::GetBoundingBox(void) const
717 		throw (::com::sun::star::uno::RuntimeException)
718 {
719     if (mpFieldWindow)
720         return Rectangle (mpFieldWindow->GetFieldPosition(const_cast<ScAccessibleDataPilotButton*> (this)->getAccessibleIndexInParent()), mpFieldWindow->GetFieldSize());
721     else
722         return Rectangle();
723 }
724