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