xref: /AOO41X/main/svx/source/table/accessibletableshape.cxx (revision 9b8096d048072d5e312699b7e51b3b8a9f64fe9a)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/table/XMergeableCell.hpp>
28cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
29cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <comphelper/accessiblewrapper.hxx>
32cdf0e10cSrcweir #include <vos/mutex.hxx>
33cdf0e10cSrcweir #include <tools/debug.hxx>
34cdf0e10cSrcweir #include <vcl/svapp.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <svx/AccessibleTableShape.hxx>
37cdf0e10cSrcweir #include "tablecontroller.hxx"
38cdf0e10cSrcweir #include "accessiblecell.hxx"
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <algorithm>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
43*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
44*9b8096d0SSteve Yin #include <svx/svdotable.hxx>
45*9b8096d0SSteve Yin #include <com/sun/star/accessibility/AccessibleStateType.hpp>
46*9b8096d0SSteve Yin #include <com/sun/star/view/XSelectionSupplier.hpp>
47*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
48cdf0e10cSrcweir 
49cdf0e10cSrcweir using ::rtl::OUString;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir using namespace ::accessibility;
52cdf0e10cSrcweir using namespace ::sdr::table;
53cdf0e10cSrcweir using namespace	::com::sun::star::accessibility;
54cdf0e10cSrcweir using namespace	::com::sun::star::uno;
55cdf0e10cSrcweir using namespace	::com::sun::star::beans;
56cdf0e10cSrcweir using namespace	::com::sun::star::util;
57cdf0e10cSrcweir using namespace	::com::sun::star::lang;
58cdf0e10cSrcweir using namespace	::com::sun::star::drawing;
59cdf0e10cSrcweir using namespace	::com::sun::star::table;
60cdf0e10cSrcweir using namespace	::com::sun::star::container;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir #define C2U(x) OUString(RTL_CONSTASCII_USTRINGPARAM(x))
63cdf0e10cSrcweir 
64cdf0e10cSrcweir namespace accessibility
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 
67cdf0e10cSrcweir struct hash
68cdf0e10cSrcweir {
69cdf0e10cSrcweir 	std::size_t operator()( const Reference< XCell >& xCell ) const
70cdf0e10cSrcweir 	{
71cdf0e10cSrcweir 		return std::size_t( xCell.get() );
72cdf0e10cSrcweir 	}
73cdf0e10cSrcweir };
74cdf0e10cSrcweir 
75cdf0e10cSrcweir typedef std::hash_map< Reference< XCell >, rtl::Reference< AccessibleCell >, hash > AccessibleCellMap;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir //-----------------------------------------------------------------------------
78cdf0e10cSrcweir // AccessibleTableShapeImpl
79cdf0e10cSrcweir //-----------------------------------------------------------------------------
80cdf0e10cSrcweir 
81cdf0e10cSrcweir class AccessibleTableShapeImpl : public cppu::WeakImplHelper1< XModifyListener >
82cdf0e10cSrcweir {
83cdf0e10cSrcweir public:
84cdf0e10cSrcweir 	AccessibleTableShapeImpl( AccessibleShapeTreeInfo& rShapeTreeInfo );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	void init( const Reference< XAccessible>& xAccessible, const Reference< XTable >& xTable );
87cdf0e10cSrcweir 	void dispose();
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	Reference< XAccessible > getAccessibleChild( sal_Int32 i ) throw(IndexOutOfBoundsException);
90cdf0e10cSrcweir 	void getColumnAndRow( sal_Int32 nChildIndex, sal_Int32& rnColumn, sal_Int32& rnRow ) throw (IndexOutOfBoundsException );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     // XModifyListener
93cdf0e10cSrcweir     virtual void SAL_CALL modified( const EventObject& aEvent ) throw (RuntimeException);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     // XEventListener
96cdf0e10cSrcweir     virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	AccessibleShapeTreeInfo& mrShapeTreeInfo;
99cdf0e10cSrcweir 	Reference< XTable > mxTable;
100cdf0e10cSrcweir 	AccessibleCellMap maChildMap;
101cdf0e10cSrcweir 	Reference< XAccessible> mxAccessible;
102*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
103*9b8096d0SSteve Yin 	sal_Int32 mRowCount, mColCount;
104*9b8096d0SSteve Yin 	//get the cached AccessibleCell from XCell
105*9b8096d0SSteve Yin 	Reference< AccessibleCell > getAccessibleCell (Reference< XCell > xCell);
106*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
107cdf0e10cSrcweir };
108cdf0e10cSrcweir 
109cdf0e10cSrcweir //-----------------------------------------------------------------------------
110cdf0e10cSrcweir 
111cdf0e10cSrcweir AccessibleTableShapeImpl::AccessibleTableShapeImpl( AccessibleShapeTreeInfo& rShapeTreeInfo )
112cdf0e10cSrcweir : mrShapeTreeInfo( rShapeTreeInfo )
113*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
114*9b8096d0SSteve Yin , mRowCount(0)
115*9b8096d0SSteve Yin , mColCount(0)
116*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
117cdf0e10cSrcweir {
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir //-----------------------------------------------------------------------------
121cdf0e10cSrcweir 
122cdf0e10cSrcweir void AccessibleTableShapeImpl::init( const Reference< XAccessible>& xAccessible, const Reference< XTable >& xTable )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	mxAccessible = xAccessible;
125cdf0e10cSrcweir 	mxTable = xTable;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	if( mxTable.is() )
128cdf0e10cSrcweir 	{
129cdf0e10cSrcweir 		Reference< XModifyListener > xListener( this );
130cdf0e10cSrcweir 		mxTable->addModifyListener( xListener );
131*9b8096d0SSteve Yin 		//IAccessibility2 Implementation 2009-----
132*9b8096d0SSteve Yin 		//register the listener with table model
133*9b8096d0SSteve Yin 		Reference< ::com::sun::star::view::XSelectionSupplier > xSelSupplier(xTable, UNO_QUERY);
134*9b8096d0SSteve Yin 		Reference< ::com::sun::star::view::XSelectionChangeListener > xSelListener( xAccessible, UNO_QUERY );
135*9b8096d0SSteve Yin 		if (xSelSupplier.is())
136*9b8096d0SSteve Yin 			xSelSupplier->addSelectionChangeListener(xSelListener);
137*9b8096d0SSteve Yin 		mRowCount = mxTable->getRowCount();
138*9b8096d0SSteve Yin 		mColCount = mxTable->getColumnCount();
139cdf0e10cSrcweir 	}
140cdf0e10cSrcweir }
141cdf0e10cSrcweir 
142cdf0e10cSrcweir //-----------------------------------------------------------------------------
143cdf0e10cSrcweir 
144cdf0e10cSrcweir void AccessibleTableShapeImpl::dispose()
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	if( mxTable.is() )
147cdf0e10cSrcweir 	{
148*9b8096d0SSteve Yin 		//IAccessibility2 Implementation 2009-----, remove all the cell's acc object in table's dispose.
149*9b8096d0SSteve Yin 		for( AccessibleCellMap::iterator iter( maChildMap.begin() ); iter != maChildMap.end(); iter++ )
150*9b8096d0SSteve Yin 		{
151*9b8096d0SSteve Yin 			(*iter).second->dispose();
152*9b8096d0SSteve Yin 		}
153*9b8096d0SSteve Yin 		//-----IAccessibility2 Implementation 2009
154cdf0e10cSrcweir 		Reference< XModifyListener > xListener( this );
155cdf0e10cSrcweir 		mxTable->removeModifyListener( xListener );
156cdf0e10cSrcweir 		mxTable.clear();
157cdf0e10cSrcweir 	}
158cdf0e10cSrcweir 	mxAccessible.clear();
159cdf0e10cSrcweir }
160cdf0e10cSrcweir 
161cdf0e10cSrcweir //-----------------------------------------------------------------------------
162*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----, get the cached AccessibleCell from XCell
163*9b8096d0SSteve Yin Reference< AccessibleCell > AccessibleTableShapeImpl::getAccessibleCell (Reference< XCell > xCell)
164*9b8096d0SSteve Yin {
165*9b8096d0SSteve Yin 	AccessibleCellMap::iterator iter( maChildMap.find( xCell ) );
166cdf0e10cSrcweir 
167*9b8096d0SSteve Yin 	if( iter != maChildMap.end() )
168*9b8096d0SSteve Yin 	{
169*9b8096d0SSteve Yin 		Reference< AccessibleCell > xChild( (*iter).second.get() );
170*9b8096d0SSteve Yin 		return xChild;
171*9b8096d0SSteve Yin 	}
172*9b8096d0SSteve Yin 	return Reference< AccessibleCell >();
173*9b8096d0SSteve Yin }
174*9b8096d0SSteve Yin 
175*9b8096d0SSteve Yin //-----------------------------------------------------------------------------
176*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
177cdf0e10cSrcweir Reference< XAccessible > AccessibleTableShapeImpl::getAccessibleChild( sal_Int32 nChildIndex ) throw(IndexOutOfBoundsException)
178cdf0e10cSrcweir {
179cdf0e10cSrcweir 	sal_Int32 nColumn = 0, nRow = 0;
180cdf0e10cSrcweir 	getColumnAndRow( nChildIndex, nColumn, nRow );
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	Reference< XCell > xCell( mxTable->getCellByPosition( nColumn, nRow ) );
183cdf0e10cSrcweir 	AccessibleCellMap::iterator iter( maChildMap.find( xCell ) );
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	if( iter != maChildMap.end() )
186cdf0e10cSrcweir 	{
187cdf0e10cSrcweir 		Reference< XAccessible > xChild( (*iter).second.get() );
188cdf0e10cSrcweir 		return xChild;
189cdf0e10cSrcweir 	}
190cdf0e10cSrcweir 	else
191cdf0e10cSrcweir 	{
192cdf0e10cSrcweir 		CellRef xCellRef( dynamic_cast< Cell* >( xCell.get() ) );
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 		rtl::Reference< AccessibleCell > xAccessibleCell( new AccessibleCell( mxAccessible, xCellRef, nChildIndex, mrShapeTreeInfo ) );
195cdf0e10cSrcweir 
196*9b8096d0SSteve Yin 		//IAccessibility2 Implementation 2009-----
197*9b8096d0SSteve Yin 		xAccessibleCell->Init();
198*9b8096d0SSteve Yin 		//-----IAccessibility2 Implementation 2009
199cdf0e10cSrcweir 		maChildMap[xCell] = xAccessibleCell;
200cdf0e10cSrcweir 
201cdf0e10cSrcweir         xAccessibleCell->Init();
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 		Reference< XAccessible > xChild( xAccessibleCell.get() );
204cdf0e10cSrcweir 		return xChild;
205cdf0e10cSrcweir 	}
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir //-----------------------------------------------------------------------------
209cdf0e10cSrcweir 
210cdf0e10cSrcweir void AccessibleTableShapeImpl::getColumnAndRow( sal_Int32 nChildIndex, sal_Int32& rnColumn, sal_Int32& rnRow ) throw (IndexOutOfBoundsException )
211cdf0e10cSrcweir {
212cdf0e10cSrcweir 	rnRow = 0;
213cdf0e10cSrcweir 	rnColumn = nChildIndex;
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	if( mxTable.is() )
216cdf0e10cSrcweir 	{
217cdf0e10cSrcweir 		const sal_Int32 nColumnCount = mxTable->getColumnCount();
218cdf0e10cSrcweir 		while( rnColumn >= nColumnCount )
219cdf0e10cSrcweir 		{
220cdf0e10cSrcweir 			rnRow++;
221cdf0e10cSrcweir 			rnColumn -= nColumnCount;
222cdf0e10cSrcweir 		}
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 		if( rnRow < mxTable->getRowCount() )
225cdf0e10cSrcweir 			return;
226cdf0e10cSrcweir 	}
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
229cdf0e10cSrcweir }
230cdf0e10cSrcweir 
231cdf0e10cSrcweir // XModifyListener
232cdf0e10cSrcweir void SAL_CALL AccessibleTableShapeImpl::modified( const EventObject& /*aEvent*/ ) throw (RuntimeException)
233cdf0e10cSrcweir {
234cdf0e10cSrcweir 	if( mxTable.is() ) try
235cdf0e10cSrcweir 	{
236cdf0e10cSrcweir 		// structural changes may have happened to the table, validate all accessible cell instances
237cdf0e10cSrcweir 		AccessibleCellMap aTempChildMap;
238cdf0e10cSrcweir 		aTempChildMap.swap( maChildMap );
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 		// first move all still existing cells to maChildMap again and update their index
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 		const sal_Int32 nRowCount = mxTable->getRowCount();
243cdf0e10cSrcweir 		const sal_Int32 nColCount = mxTable->getColumnCount();
244cdf0e10cSrcweir 
245*9b8096d0SSteve Yin 		//IAccessibility2 Implementation 2009-----
246*9b8096d0SSteve Yin 		sal_Bool bRowOrColumnChanged = sal_False;
247*9b8096d0SSteve Yin 		if (mRowCount != nRowCount || mColCount != nColCount )
248*9b8096d0SSteve Yin 		{
249*9b8096d0SSteve Yin 			bRowOrColumnChanged = sal_True;
250*9b8096d0SSteve Yin 			mRowCount = nRowCount;
251*9b8096d0SSteve Yin 			mColCount = nColCount;
252*9b8096d0SSteve Yin 		}
253*9b8096d0SSteve Yin 		//-----IAccessibility2 Implementation 2009
254cdf0e10cSrcweir 		sal_Int32 nChildIndex = 0;
255cdf0e10cSrcweir 
256cdf0e10cSrcweir 		for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow )
257cdf0e10cSrcweir 		{
258cdf0e10cSrcweir 			for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol )
259cdf0e10cSrcweir 			{
260cdf0e10cSrcweir 				Reference< XCell > xCell( mxTable->getCellByPosition( nCol, nRow ) );
261cdf0e10cSrcweir 				AccessibleCellMap::iterator iter( aTempChildMap.find( xCell ) );
262cdf0e10cSrcweir 
263cdf0e10cSrcweir 				if( iter != aTempChildMap.end() )
264cdf0e10cSrcweir 				{
265cdf0e10cSrcweir 					rtl::Reference< AccessibleCell > xAccessibleCell( (*iter).second );
266cdf0e10cSrcweir 					xAccessibleCell->setIndexInParent( nChildIndex );
267*9b8096d0SSteve Yin 					//IAccessibility2 Implementation 2009-----, the children may need to updated
268*9b8096d0SSteve Yin 					//xAccessibleCell->CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, Any(), Any());
269*9b8096d0SSteve Yin 					xAccessibleCell->UpdateChildren();
270*9b8096d0SSteve Yin 					// If row or column count is changed, there is split or merge, so all cell's acc name should be updated
271*9b8096d0SSteve Yin 					if (bRowOrColumnChanged)
272*9b8096d0SSteve Yin 					{
273*9b8096d0SSteve Yin 						xAccessibleCell->SetAccessibleName(xAccessibleCell->getAccessibleName(), AccessibleContextBase::ManuallySet);
274*9b8096d0SSteve Yin 					}
275*9b8096d0SSteve Yin 					// For merged cell, add invisible & disabled state.
276*9b8096d0SSteve Yin 					Reference< XMergeableCell > xMergedCell( mxTable->getCellByPosition( nCol, nRow ),  UNO_QUERY );
277*9b8096d0SSteve Yin 					if (xMergedCell.is() && xMergedCell->isMerged())
278*9b8096d0SSteve Yin 					{
279*9b8096d0SSteve Yin 						xAccessibleCell->ResetState(AccessibleStateType::VISIBLE);
280*9b8096d0SSteve Yin 						xAccessibleCell->ResetState(AccessibleStateType::ENABLED);
281*9b8096d0SSteve Yin 						// IA2 CWS. MT: OFFSCREEN == !SHOWING, should stay consistent
282*9b8096d0SSteve Yin 						// xAccessibleCell->SetState(AccessibleStateType::OFFSCREEN);
283*9b8096d0SSteve Yin 						xAccessibleCell->ResetState(AccessibleStateType::SHOWING);
284*9b8096d0SSteve Yin 					}
285*9b8096d0SSteve Yin 					else
286*9b8096d0SSteve Yin 					{
287*9b8096d0SSteve Yin 						xAccessibleCell->SetState(AccessibleStateType::VISIBLE);
288*9b8096d0SSteve Yin 						xAccessibleCell->SetState(AccessibleStateType::ENABLED);
289*9b8096d0SSteve Yin 						// IA2 CWS. MT: OFFSCREEN == !SHOWING, should stay consistent
290*9b8096d0SSteve Yin 						// xAccessibleCell->ResetState(AccessibleStateType::OFFSCREEN);
291*9b8096d0SSteve Yin 						xAccessibleCell->SetState(AccessibleStateType::SHOWING);
292*9b8096d0SSteve Yin 					}
293*9b8096d0SSteve Yin 					//-----IAccessibility2 Implementation 2009
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 					// move still existing cell from temporary child map to our child map
296cdf0e10cSrcweir 					maChildMap[xCell] = xAccessibleCell;
297cdf0e10cSrcweir 					aTempChildMap.erase( iter );
298cdf0e10cSrcweir 				}
299*9b8096d0SSteve Yin 				//IAccessibility2 Implementation 2009-----, need to add the new added cell on demand
300*9b8096d0SSteve Yin 				else
301*9b8096d0SSteve Yin 				{
302*9b8096d0SSteve Yin 					CellRef xCellRef( dynamic_cast< Cell* >( xCell.get() ) );
303*9b8096d0SSteve Yin 
304*9b8096d0SSteve Yin 					rtl::Reference< AccessibleCell > xAccessibleCell( new AccessibleCell( mxAccessible, xCellRef, nChildIndex, mrShapeTreeInfo ) );
305*9b8096d0SSteve Yin 
306*9b8096d0SSteve Yin 					xAccessibleCell->Init();
307*9b8096d0SSteve Yin 					maChildMap[xCell] = xAccessibleCell;
308*9b8096d0SSteve Yin 				}
309*9b8096d0SSteve Yin 				//-----IAccessibility2 Implementation 2009
310cdf0e10cSrcweir 
311cdf0e10cSrcweir 				++nChildIndex;
312cdf0e10cSrcweir 			}
313cdf0e10cSrcweir 		}
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 		// all accessible cell instances still left in aTempChildMap must be disposed
316cdf0e10cSrcweir 		// as they are no longer part of the table
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 		for( AccessibleCellMap::iterator iter( aTempChildMap.begin() ); iter != aTempChildMap.end(); iter++ )
319cdf0e10cSrcweir 		{
320cdf0e10cSrcweir 			(*iter).second->dispose();
321cdf0e10cSrcweir 		}
322*9b8096d0SSteve Yin 		//IAccessibility2 Implementation 2009-----, notify bridge to update the acc cache.
323*9b8096d0SSteve Yin 		AccessibleTableShape *pAccTable = dynamic_cast <AccessibleTableShape *> (mxAccessible.get());
324*9b8096d0SSteve Yin 		pAccTable->CommitChange(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
325*9b8096d0SSteve Yin 		//-----IAccessibility2 Implementation 2009
326cdf0e10cSrcweir 	}
327cdf0e10cSrcweir 	catch( Exception& )
328cdf0e10cSrcweir 	{
329cdf0e10cSrcweir 		DBG_ERROR("svx::AccessibleTableShape::modified(), exception caught!");
330cdf0e10cSrcweir 	}
331cdf0e10cSrcweir }
332cdf0e10cSrcweir 
333cdf0e10cSrcweir // XEventListener
334cdf0e10cSrcweir void SAL_CALL AccessibleTableShapeImpl::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
335cdf0e10cSrcweir {
336cdf0e10cSrcweir }
337cdf0e10cSrcweir 
338cdf0e10cSrcweir //-----------------------------------------------------------------------------
339cdf0e10cSrcweir // AccessibleTableShape
340cdf0e10cSrcweir //-----------------------------------------------------------------------------
341cdf0e10cSrcweir 
342cdf0e10cSrcweir //-----------------------------------------------------------------------------
343cdf0e10cSrcweir 
344cdf0e10cSrcweir AccessibleTableShape::AccessibleTableShape( const AccessibleShapeInfo& rShapeInfo, const AccessibleShapeTreeInfo& rShapeTreeInfo)
345cdf0e10cSrcweir : AccessibleTableShape_Base(rShapeInfo, rShapeTreeInfo)
346cdf0e10cSrcweir , mxImpl( new AccessibleTableShapeImpl( maShapeTreeInfo ) )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir //-----------------------------------------------------------------------------
351cdf0e10cSrcweir 
352cdf0e10cSrcweir AccessibleTableShape::~AccessibleTableShape (void)
353cdf0e10cSrcweir {
354cdf0e10cSrcweir }
355cdf0e10cSrcweir 
356cdf0e10cSrcweir //-----------------------------------------------------------------------------
357cdf0e10cSrcweir 
358cdf0e10cSrcweir void AccessibleTableShape::Init()
359cdf0e10cSrcweir {
360cdf0e10cSrcweir 	try
361cdf0e10cSrcweir 	{
362*9b8096d0SSteve Yin 		mnPreviousSelectionCount = 0;
363cdf0e10cSrcweir 		Reference< XPropertySet > xSet( mxShape, UNO_QUERY_THROW );
364cdf0e10cSrcweir 		Reference< XTable > xTable( xSet->getPropertyValue(C2U("Model")), UNO_QUERY_THROW );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 		mxImpl->init( this, xTable );
367cdf0e10cSrcweir 	}
368cdf0e10cSrcweir 	catch( Exception& )
369cdf0e10cSrcweir 	{
370cdf0e10cSrcweir 		DBG_ERROR("AccessibleTableShape::init(), exception caught?");
371cdf0e10cSrcweir 	}
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 	AccessibleTableShape_Base::Init();
374cdf0e10cSrcweir }
375cdf0e10cSrcweir 
376cdf0e10cSrcweir //-----------------------------------------------------------------------------
377cdf0e10cSrcweir 
378cdf0e10cSrcweir SvxTableController* AccessibleTableShape::getTableController()
379cdf0e10cSrcweir {
380cdf0e10cSrcweir 	SdrView* pView = maShapeTreeInfo.GetSdrView ();
381cdf0e10cSrcweir 	if( pView )
382cdf0e10cSrcweir 		return dynamic_cast< SvxTableController* >( pView->getSelectionController().get() );
383cdf0e10cSrcweir 	else
384cdf0e10cSrcweir 		return 0;
385cdf0e10cSrcweir }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir //-----------------------------------------------------------------------------
388cdf0e10cSrcweir // XInterface
389cdf0e10cSrcweir //-----------------------------------------------------------------------------
390cdf0e10cSrcweir 
391cdf0e10cSrcweir Any SAL_CALL AccessibleTableShape::queryInterface( const Type& aType ) throw (RuntimeException)
392cdf0e10cSrcweir {
393*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
394*9b8096d0SSteve Yin 	if ( aType == ::getCppuType((Reference<XAccessibleTableSelection> *)0) )
395*9b8096d0SSteve Yin     {
396*9b8096d0SSteve Yin 		Reference<XAccessibleTableSelection> xThis( this );
397*9b8096d0SSteve Yin 		Any aRet;
398*9b8096d0SSteve Yin        	aRet <<= xThis;
399*9b8096d0SSteve Yin 		return aRet;
400*9b8096d0SSteve Yin 	}
401*9b8096d0SSteve Yin 	else
402*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
403cdf0e10cSrcweir 	return AccessibleTableShape_Base::queryInterface( aType );
404cdf0e10cSrcweir }
405cdf0e10cSrcweir 
406cdf0e10cSrcweir //-----------------------------------------------------------------------------
407cdf0e10cSrcweir 
408cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::acquire(  ) throw ()
409cdf0e10cSrcweir {
410cdf0e10cSrcweir 	AccessibleTableShape_Base::acquire();
411cdf0e10cSrcweir }
412cdf0e10cSrcweir 
413cdf0e10cSrcweir //-----------------------------------------------------------------------------
414cdf0e10cSrcweir 
415cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::release(  ) throw ()
416cdf0e10cSrcweir {
417cdf0e10cSrcweir 	AccessibleTableShape_Base::release();
418cdf0e10cSrcweir }
419cdf0e10cSrcweir 
420cdf0e10cSrcweir //-----------------------------------------------------------------------------
421cdf0e10cSrcweir // XAccessible
422cdf0e10cSrcweir //-----------------------------------------------------------------------------
423cdf0e10cSrcweir 
424cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL AccessibleTableShape::getAccessibleContext(void) throw (RuntimeException)
425cdf0e10cSrcweir {
426cdf0e10cSrcweir 	return AccessibleShape::getAccessibleContext ();
427cdf0e10cSrcweir }
428cdf0e10cSrcweir 
429cdf0e10cSrcweir //-----------------------------------------------------------------------------
430cdf0e10cSrcweir OUString SAL_CALL AccessibleTableShape::getImplementationName(void) throw (RuntimeException)
431cdf0e10cSrcweir {
432cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.accessibility.AccessibleTableShape" ) );
433cdf0e10cSrcweir }
434cdf0e10cSrcweir 
435cdf0e10cSrcweir //-----------------------------------------------------------------------------
436cdf0e10cSrcweir 
437cdf0e10cSrcweir OUString AccessibleTableShape::CreateAccessibleBaseName(void) throw (RuntimeException)
438cdf0e10cSrcweir {
439*9b8096d0SSteve Yin     return OUString (RTL_CONSTASCII_USTRINGPARAM("TableShape"));
440cdf0e10cSrcweir }
441cdf0e10cSrcweir 
442cdf0e10cSrcweir //--------------------------------------------------------------------
443cdf0e10cSrcweir 
444cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleChildCount( ) throw(RuntimeException)
445cdf0e10cSrcweir {
446cdf0e10cSrcweir     ::vos::OGuard aSolarGuard(::Application::GetSolarMutex());
447cdf0e10cSrcweir 	return mxImpl->mxTable.is() ? mxImpl->mxTable->getRowCount() * mxImpl->mxTable->getColumnCount() : 0;
448cdf0e10cSrcweir }
449cdf0e10cSrcweir 
450cdf0e10cSrcweir //--------------------------------------------------------------------
451cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleTableShape::getAccessibleChild( sal_Int32 i ) throw(IndexOutOfBoundsException, RuntimeException)
452cdf0e10cSrcweir {
453cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
454cdf0e10cSrcweir 	ThrowIfDisposed();
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 	return mxImpl->getAccessibleChild( i );
457cdf0e10cSrcweir }
458cdf0e10cSrcweir 
459cdf0e10cSrcweir //--------------------------------------------------------------------
460cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL AccessibleTableShape::getAccessibleRelationSet(  ) throw (RuntimeException)
461cdf0e10cSrcweir {
462cdf0e10cSrcweir 	return AccessibleShape::getAccessibleRelationSet( );
463cdf0e10cSrcweir }
464cdf0e10cSrcweir 
465cdf0e10cSrcweir //--------------------------------------------------------------------
466cdf0e10cSrcweir 
467cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleTableShape::getAccessibleRole (void) throw (RuntimeException)
468cdf0e10cSrcweir {
469cdf0e10cSrcweir 	return AccessibleRole::TABLE;
470cdf0e10cSrcweir }
471cdf0e10cSrcweir 
472cdf0e10cSrcweir //--------------------------------------------------------------------
473cdf0e10cSrcweir 
474cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::disposing (void)
475cdf0e10cSrcweir {
476cdf0e10cSrcweir 	mxImpl->dispose();
477cdf0e10cSrcweir 
478cdf0e10cSrcweir 	// let the base do it's stuff
479cdf0e10cSrcweir 	AccessibleShape::disposing();
480cdf0e10cSrcweir }
481cdf0e10cSrcweir 
482cdf0e10cSrcweir //--------------------------------------------------------------------
483cdf0e10cSrcweir // XAccessibleTable
484cdf0e10cSrcweir //--------------------------------------------------------------------
485cdf0e10cSrcweir 
486cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleRowCount() throw (RuntimeException)
487cdf0e10cSrcweir {
488cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
489cdf0e10cSrcweir 	return mxImpl->mxTable.is() ? mxImpl->mxTable->getRowCount() : 0;
490cdf0e10cSrcweir }
491cdf0e10cSrcweir 
492cdf0e10cSrcweir //--------------------------------------------------------------------
493cdf0e10cSrcweir 
494cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleColumnCount(  ) throw (RuntimeException)
495cdf0e10cSrcweir {
496cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
497cdf0e10cSrcweir 	return mxImpl->mxTable.is() ? mxImpl->mxTable->getColumnCount() : 0;
498cdf0e10cSrcweir }
499cdf0e10cSrcweir 
500cdf0e10cSrcweir //--------------------------------------------------------------------
501cdf0e10cSrcweir 
502cdf0e10cSrcweir OUString SAL_CALL AccessibleTableShape::getAccessibleRowDescription( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
503cdf0e10cSrcweir {
504cdf0e10cSrcweir 	checkCellPosition( 0, nRow );
505cdf0e10cSrcweir 	return OUString();
506cdf0e10cSrcweir }
507cdf0e10cSrcweir 
508cdf0e10cSrcweir //--------------------------------------------------------------------
509cdf0e10cSrcweir 
510cdf0e10cSrcweir OUString SAL_CALL AccessibleTableShape::getAccessibleColumnDescription( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
511cdf0e10cSrcweir {
512cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
513cdf0e10cSrcweir 	checkCellPosition( nColumn, 0 );
514cdf0e10cSrcweir 	return OUString();
515cdf0e10cSrcweir }
516cdf0e10cSrcweir 
517cdf0e10cSrcweir //--------------------------------------------------------------------
518cdf0e10cSrcweir 
519cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
520cdf0e10cSrcweir {
521cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
522cdf0e10cSrcweir 	checkCellPosition( nColumn, nRow );
523cdf0e10cSrcweir 	if( mxImpl->mxTable.is() )
524cdf0e10cSrcweir 	{
525cdf0e10cSrcweir 		Reference< XMergeableCell > xCell( mxImpl->mxTable->getCellByPosition( nColumn, nRow ), UNO_QUERY );
526cdf0e10cSrcweir 		if( xCell.is() )
527cdf0e10cSrcweir 			return xCell->getRowSpan();
528cdf0e10cSrcweir 	}
529cdf0e10cSrcweir 	return 1;
530cdf0e10cSrcweir }
531cdf0e10cSrcweir 
532cdf0e10cSrcweir //--------------------------------------------------------------------
533cdf0e10cSrcweir 
534cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
535cdf0e10cSrcweir {
536cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
537cdf0e10cSrcweir 	checkCellPosition( nColumn, nRow );
538cdf0e10cSrcweir 	if( mxImpl->mxTable.is() )
539cdf0e10cSrcweir 	{
540cdf0e10cSrcweir 		Reference< XMergeableCell > xCell( mxImpl->mxTable->getCellByPosition( nColumn, nRow ), UNO_QUERY );
541cdf0e10cSrcweir 		if( xCell.is() )
542cdf0e10cSrcweir 			return xCell->getColumnSpan();
543cdf0e10cSrcweir 	}
544cdf0e10cSrcweir 	return 1;
545cdf0e10cSrcweir }
546cdf0e10cSrcweir 
547cdf0e10cSrcweir //--------------------------------------------------------------------
548cdf0e10cSrcweir 
549cdf0e10cSrcweir Reference< XAccessibleTable > SAL_CALL AccessibleTableShape::getAccessibleRowHeaders(  ) throw (RuntimeException)
550cdf0e10cSrcweir {
551*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
552*9b8096d0SSteve Yin 	//Reference< XAccessibleTable > xRet( this ); // todo
553*9b8096d0SSteve Yin 	Reference< XAccessibleTable > xRet;
554*9b8096d0SSteve Yin 	SvxTableController* pController = getTableController();
555*9b8096d0SSteve Yin 	if( pController )
556*9b8096d0SSteve Yin 	{
557*9b8096d0SSteve Yin 		if( pController->isRowHeader() )
558*9b8096d0SSteve Yin 		{
559*9b8096d0SSteve Yin 			AccessibleTableHeaderShape* pTableHeader = new AccessibleTableHeaderShape( this, sal_True );
560*9b8096d0SSteve Yin 			xRet.set( pTableHeader );
561*9b8096d0SSteve Yin 		}
562*9b8096d0SSteve Yin 	}
563*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
564cdf0e10cSrcweir 	return xRet;
565cdf0e10cSrcweir }
566cdf0e10cSrcweir 
567cdf0e10cSrcweir //--------------------------------------------------------------------
568cdf0e10cSrcweir 
569cdf0e10cSrcweir Reference< XAccessibleTable > SAL_CALL AccessibleTableShape::getAccessibleColumnHeaders(  ) throw (RuntimeException)
570cdf0e10cSrcweir {
571*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
572*9b8096d0SSteve Yin 	//Reference< XAccessibleTable > xRet( this ); // todo
573*9b8096d0SSteve Yin 	Reference< XAccessibleTable > xRet;
574*9b8096d0SSteve Yin 	SvxTableController* pController = getTableController();
575*9b8096d0SSteve Yin 	if( pController )
576*9b8096d0SSteve Yin 	{
577*9b8096d0SSteve Yin 		if( pController->isColumnHeader() )
578*9b8096d0SSteve Yin 		{
579*9b8096d0SSteve Yin 			AccessibleTableHeaderShape* pTableHeader = new AccessibleTableHeaderShape( this, sal_False );
580*9b8096d0SSteve Yin 			xRet.set( pTableHeader );
581*9b8096d0SSteve Yin 		}
582*9b8096d0SSteve Yin 	}
583*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
584cdf0e10cSrcweir 	return xRet;
585cdf0e10cSrcweir }
586cdf0e10cSrcweir 
587cdf0e10cSrcweir //--------------------------------------------------------------------
588cdf0e10cSrcweir 
589cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL AccessibleTableShape::getSelectedAccessibleRows(  ) throw (RuntimeException)
590cdf0e10cSrcweir {
591*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
592*9b8096d0SSteve Yin 	/*Sequence< sal_Int32 > aRet;*/
593*9b8096d0SSteve Yin 	sal_Int32 nRow = getAccessibleRowCount();
594*9b8096d0SSteve Yin 	::std::vector< sal_Bool > aSelected( nRow, sal_True );
595*9b8096d0SSteve Yin 	sal_Int32 nCount = nRow;
596*9b8096d0SSteve Yin 	for( sal_Int32 i = 0; i < nRow; i++ )
597*9b8096d0SSteve Yin 	{
598*9b8096d0SSteve Yin 		try
599*9b8096d0SSteve Yin 		{
600*9b8096d0SSteve Yin 			aSelected[i] = isAccessibleRowSelected( i );
601*9b8096d0SSteve Yin 		}
602*9b8096d0SSteve Yin 		catch( ... )
603*9b8096d0SSteve Yin 		{
604*9b8096d0SSteve Yin 			return Sequence< sal_Int32 >();
605*9b8096d0SSteve Yin 		}
606*9b8096d0SSteve Yin 
607*9b8096d0SSteve Yin 		if( !aSelected[i] )
608*9b8096d0SSteve Yin 			nCount--;
609*9b8096d0SSteve Yin 	}
610*9b8096d0SSteve Yin 	Sequence < sal_Int32 > aRet( nCount );
611*9b8096d0SSteve Yin 	sal_Int32 *pRet = aRet.getArray();
612*9b8096d0SSteve Yin 	sal_Int32 nPos = 0;
613*9b8096d0SSteve Yin 	size_t nSize = aSelected.size();
614*9b8096d0SSteve Yin 	for( size_t i=0; i < nSize && nPos < nCount; i++ )
615*9b8096d0SSteve Yin 	{
616*9b8096d0SSteve Yin 		if( aSelected[i] )
617*9b8096d0SSteve Yin 		{
618*9b8096d0SSteve Yin 			*pRet++ = i;
619*9b8096d0SSteve Yin 			nPos++;
620*9b8096d0SSteve Yin 		}
621*9b8096d0SSteve Yin 	}
622*9b8096d0SSteve Yin 
623cdf0e10cSrcweir 	return aRet;
624*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
625cdf0e10cSrcweir }
626cdf0e10cSrcweir 
627cdf0e10cSrcweir //--------------------------------------------------------------------
628cdf0e10cSrcweir 
629cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL AccessibleTableShape::getSelectedAccessibleColumns(  ) throw (RuntimeException)
630cdf0e10cSrcweir {
631*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
632*9b8096d0SSteve Yin 	/*Sequence< sal_Int32 > aRet;*/
633*9b8096d0SSteve Yin 	sal_Int32 nColumn = getAccessibleColumnCount();
634*9b8096d0SSteve Yin 	::std::vector< sal_Bool > aSelected( nColumn, sal_True );
635*9b8096d0SSteve Yin 	sal_Int32 nCount = nColumn;
636*9b8096d0SSteve Yin 	for( sal_Int32 i = 0; i < nColumn; i++ )
637*9b8096d0SSteve Yin 	{
638*9b8096d0SSteve Yin 		try
639*9b8096d0SSteve Yin 		{
640*9b8096d0SSteve Yin 			aSelected[i] = isAccessibleColumnSelected( i );
641*9b8096d0SSteve Yin 		}
642*9b8096d0SSteve Yin 		catch( ... )
643*9b8096d0SSteve Yin 		{
644*9b8096d0SSteve Yin 			return Sequence< sal_Int32 >();
645*9b8096d0SSteve Yin 		}
646*9b8096d0SSteve Yin 
647*9b8096d0SSteve Yin 		if( !aSelected[i] )
648*9b8096d0SSteve Yin 			nCount--;
649*9b8096d0SSteve Yin 	}
650*9b8096d0SSteve Yin 	Sequence < sal_Int32 > aRet( nCount );
651*9b8096d0SSteve Yin 	sal_Int32 *pRet = aRet.getArray();
652*9b8096d0SSteve Yin 	sal_Int32 nPos = 0;
653*9b8096d0SSteve Yin 	size_t nSize = aSelected.size();
654*9b8096d0SSteve Yin 	for( size_t i=0; i < nSize && nPos < nCount; i++ )
655*9b8096d0SSteve Yin 	{
656*9b8096d0SSteve Yin 		if( aSelected[i] )
657*9b8096d0SSteve Yin 		{
658*9b8096d0SSteve Yin 			*pRet++ = i;
659*9b8096d0SSteve Yin 			nPos++;
660*9b8096d0SSteve Yin 		}
661*9b8096d0SSteve Yin 	}
662*9b8096d0SSteve Yin 
663cdf0e10cSrcweir 	return aRet;
664*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
665cdf0e10cSrcweir }
666cdf0e10cSrcweir 
667cdf0e10cSrcweir //--------------------------------------------------------------------
668cdf0e10cSrcweir 
669cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleTableShape::isAccessibleRowSelected( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
670cdf0e10cSrcweir {
671cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
672cdf0e10cSrcweir 	checkCellPosition( 0, nRow );
673*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
674*9b8096d0SSteve Yin 	SvxTableController* pController = getTableController();
675*9b8096d0SSteve Yin 	if( pController )
676*9b8096d0SSteve Yin 	{
677*9b8096d0SSteve Yin 		return pController->isRowSelected( nRow );
678*9b8096d0SSteve Yin 	}
679*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
680cdf0e10cSrcweir 	return sal_False;
681cdf0e10cSrcweir }
682cdf0e10cSrcweir 
683cdf0e10cSrcweir //--------------------------------------------------------------------
684cdf0e10cSrcweir 
685cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleTableShape::isAccessibleColumnSelected( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
686cdf0e10cSrcweir {
687cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
688cdf0e10cSrcweir 	checkCellPosition( nColumn, 0 );
689*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
690*9b8096d0SSteve Yin 	SvxTableController* pController = getTableController();
691*9b8096d0SSteve Yin 	if( pController )
692*9b8096d0SSteve Yin 	{
693*9b8096d0SSteve Yin 		return pController->isColumnSelected( nColumn );
694*9b8096d0SSteve Yin 	}
695*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
696cdf0e10cSrcweir 	return sal_False;
697cdf0e10cSrcweir }
698cdf0e10cSrcweir 
699cdf0e10cSrcweir //--------------------------------------------------------------------
700cdf0e10cSrcweir 
701cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleTableShape::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
702cdf0e10cSrcweir {
703cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
704cdf0e10cSrcweir 	checkCellPosition( nColumn, nRow );
705cdf0e10cSrcweir 
706cdf0e10cSrcweir     sal_Int32 nChildIndex = 0;
707cdf0e10cSrcweir 	if( mxImpl->mxTable.is() )
708cdf0e10cSrcweir 		nChildIndex = mxImpl->mxTable->getColumnCount() * nRow + nColumn;
709cdf0e10cSrcweir 
710cdf0e10cSrcweir     return getAccessibleChild( nChildIndex );
711cdf0e10cSrcweir }
712cdf0e10cSrcweir 
713cdf0e10cSrcweir //--------------------------------------------------------------------
714cdf0e10cSrcweir 
715cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleTableShape::getAccessibleCaption(  ) throw (RuntimeException)
716cdf0e10cSrcweir {
717cdf0e10cSrcweir 	Reference< XAccessible > xRet;
718cdf0e10cSrcweir 	return xRet;
719cdf0e10cSrcweir }
720cdf0e10cSrcweir 
721cdf0e10cSrcweir //--------------------------------------------------------------------
722cdf0e10cSrcweir 
723cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleTableShape::getAccessibleSummary(  ) throw (RuntimeException)
724cdf0e10cSrcweir {
725cdf0e10cSrcweir 	Reference< XAccessible > xRet;
726cdf0e10cSrcweir 	return xRet;
727cdf0e10cSrcweir }
728cdf0e10cSrcweir 
729cdf0e10cSrcweir //--------------------------------------------------------------------
730cdf0e10cSrcweir 
731cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleTableShape::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
732cdf0e10cSrcweir {
733cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
734cdf0e10cSrcweir 	checkCellPosition( nColumn, nRow );
735cdf0e10cSrcweir 
736cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
737cdf0e10cSrcweir 	if( pController && pController->hasSelectedCells() )
738cdf0e10cSrcweir 	{
739cdf0e10cSrcweir 		CellPos aFirstPos, aLastPos;
740cdf0e10cSrcweir 		pController->getSelectedCells( aFirstPos, aLastPos );
741cdf0e10cSrcweir 		if( (aFirstPos.mnRow <= nRow) && (aFirstPos.mnCol <= nColumn) && (nRow <= aLastPos.mnRow) && (nColumn <= aLastPos.mnCol) )
742cdf0e10cSrcweir 			return sal_True;
743cdf0e10cSrcweir 	}
744cdf0e10cSrcweir 
745cdf0e10cSrcweir 	return sal_False;
746cdf0e10cSrcweir }
747cdf0e10cSrcweir 
748cdf0e10cSrcweir //--------------------------------------------------------------------
749cdf0e10cSrcweir 
750cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
751cdf0e10cSrcweir {
752cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
753cdf0e10cSrcweir 	checkCellPosition( nColumn, nRow );
754cdf0e10cSrcweir 	return  mxImpl->mxTable.is() ? (nRow * mxImpl->mxTable->getColumnCount() + nColumn) : 0;
755cdf0e10cSrcweir }
756cdf0e10cSrcweir 
757cdf0e10cSrcweir //--------------------------------------------------------------------
758cdf0e10cSrcweir 
759cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleRow( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
760cdf0e10cSrcweir {
761cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
762cdf0e10cSrcweir 	sal_Int32 nColumn = 0, nRow = 0;
763cdf0e10cSrcweir 	mxImpl->getColumnAndRow( nChildIndex, nColumn, nRow );
764cdf0e10cSrcweir 	return nRow;
765cdf0e10cSrcweir }
766cdf0e10cSrcweir 
767cdf0e10cSrcweir //--------------------------------------------------------------------
768cdf0e10cSrcweir 
769cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleColumn( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
770cdf0e10cSrcweir {
771cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
772cdf0e10cSrcweir 	sal_Int32 nColumn = 0, nRow = 0;
773cdf0e10cSrcweir 	mxImpl->getColumnAndRow( nChildIndex, nColumn, nRow );
774*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
775*9b8096d0SSteve Yin 	//return nChildIndex;
776*9b8096d0SSteve Yin 	return nColumn;
777*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
778cdf0e10cSrcweir }
779cdf0e10cSrcweir 
780cdf0e10cSrcweir //--------------------------------------------------------------------
781cdf0e10cSrcweir // XAccessibleSelection
782cdf0e10cSrcweir //--------------------------------------------------------------------
783cdf0e10cSrcweir 
784cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::selectAccessibleChild( sal_Int32 nChildIndex ) throw ( IndexOutOfBoundsException, RuntimeException )
785cdf0e10cSrcweir {
786cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
787cdf0e10cSrcweir 	CellPos aPos;
788cdf0e10cSrcweir 	mxImpl->getColumnAndRow( nChildIndex, aPos.mnCol, aPos.mnRow );
789cdf0e10cSrcweir 
790cdf0e10cSrcweir 	// todo, select table shape?!?
791cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
792cdf0e10cSrcweir 	if( pController )
793cdf0e10cSrcweir 	{
794cdf0e10cSrcweir 		CellPos aFirstPos( aPos ), aLastPos( aPos );
795cdf0e10cSrcweir 		if( pController->hasSelectedCells() )
796cdf0e10cSrcweir 		{
797cdf0e10cSrcweir 			pController->getSelectedCells( aFirstPos, aLastPos );
798cdf0e10cSrcweir 
799cdf0e10cSrcweir 			aFirstPos.mnRow = std::min( aFirstPos.mnRow, aPos.mnRow );
800cdf0e10cSrcweir 			aFirstPos.mnCol = std::min( aFirstPos.mnCol, aPos.mnCol );
801cdf0e10cSrcweir 			aLastPos.mnRow = std::max( aLastPos.mnRow, aPos.mnRow );
802cdf0e10cSrcweir 			aLastPos.mnCol = std::max( aLastPos.mnCol, aPos.mnCol );
803cdf0e10cSrcweir 		}
804cdf0e10cSrcweir 		pController->setSelectedCells( aFirstPos, aLastPos );
805cdf0e10cSrcweir 	}
806cdf0e10cSrcweir }
807cdf0e10cSrcweir 
808cdf0e10cSrcweir //--------------------------------------------------------------------
809cdf0e10cSrcweir 
810cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleTableShape::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw ( IndexOutOfBoundsException, RuntimeException )
811cdf0e10cSrcweir {
812cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
813cdf0e10cSrcweir 	CellPos aPos;
814cdf0e10cSrcweir 	mxImpl->getColumnAndRow( nChildIndex, aPos.mnCol, aPos.mnRow );
815cdf0e10cSrcweir 
816*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
817*9b8096d0SSteve Yin 	// Para order is not correct
818*9b8096d0SSteve Yin 	//return isAccessibleSelected(aPos.mnCol, aPos.mnRow);
819*9b8096d0SSteve Yin 	return isAccessibleSelected(aPos.mnRow, aPos.mnCol);
820*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
821cdf0e10cSrcweir }
822cdf0e10cSrcweir 
823cdf0e10cSrcweir //--------------------------------------------------------------------
824cdf0e10cSrcweir 
825cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::clearAccessibleSelection() throw ( RuntimeException )
826cdf0e10cSrcweir {
827cdf0e10cSrcweir    ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
828cdf0e10cSrcweir 
829cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
830cdf0e10cSrcweir 	if( pController )
831cdf0e10cSrcweir 		pController->clearSelection();
832cdf0e10cSrcweir }
833cdf0e10cSrcweir //--------------------------------------------------------------------
834cdf0e10cSrcweir 
835cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::selectAllAccessibleChildren() throw ( RuntimeException )
836cdf0e10cSrcweir {
837cdf0e10cSrcweir    ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
838cdf0e10cSrcweir 
839cdf0e10cSrcweir    // todo: force selection of shape?
840cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
841cdf0e10cSrcweir 	if( pController )
842cdf0e10cSrcweir 		pController->selectAll();
843cdf0e10cSrcweir }
844cdf0e10cSrcweir 
845cdf0e10cSrcweir //--------------------------------------------------------------------
846cdf0e10cSrcweir 
847cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getSelectedAccessibleChildCount() throw ( RuntimeException )
848cdf0e10cSrcweir {
849cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
850cdf0e10cSrcweir 
851cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
852cdf0e10cSrcweir 	if( pController && pController->hasSelectedCells() )
853cdf0e10cSrcweir 	{
854cdf0e10cSrcweir 		CellPos aFirstPos, aLastPos;
855cdf0e10cSrcweir 		pController->getSelectedCells( aFirstPos, aLastPos );
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 		const sal_Int32 nSelectedColumns = std::max( (sal_Int32)0, aLastPos.mnCol - aFirstPos.mnCol ) + 1;
858cdf0e10cSrcweir 		const sal_Int32 nSelectedRows = std::max( (sal_Int32)0, aLastPos.mnRow - aFirstPos.mnRow ) + 1;
859cdf0e10cSrcweir 		return nSelectedRows * nSelectedColumns;
860cdf0e10cSrcweir 	}
861cdf0e10cSrcweir 
862cdf0e10cSrcweir 	return 0;
863cdf0e10cSrcweir }
864cdf0e10cSrcweir 
865cdf0e10cSrcweir //--------------------------------------------------------------------
866cdf0e10cSrcweir 
867cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleTableShape::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw ( IndexOutOfBoundsException, RuntimeException)
868cdf0e10cSrcweir {
869cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
870cdf0e10cSrcweir 
871*9b8096d0SSteve Yin 	//IAccessibility2 Implementation 2009-----
872*9b8096d0SSteve Yin 	/*SvxTableController* pController = getTableController();
873cdf0e10cSrcweir 	if( pController && pController->hasSelectedCells() )
874cdf0e10cSrcweir 	{
875cdf0e10cSrcweir 		CellPos aFirstPos, aLastPos;
876cdf0e10cSrcweir 		pController->getSelectedCells( aFirstPos, aLastPos );
877cdf0e10cSrcweir 
878cdf0e10cSrcweir 		const sal_Int32 nSelectedColumns = std::max( (sal_Int32)0, aLastPos.mnCol - aFirstPos.mnCol ) + 1;
879cdf0e10cSrcweir 		const sal_Int32 nSelectedRows = std::max( (sal_Int32)0, aLastPos.mnRow - aFirstPos.mnRow ) + 1;
880cdf0e10cSrcweir 
881cdf0e10cSrcweir 		if( nSelectedChildIndex < (nSelectedRows * nSelectedColumns) )
882cdf0e10cSrcweir 		{
883cdf0e10cSrcweir 			while( nSelectedChildIndex >= nSelectedColumns )
884cdf0e10cSrcweir 			{
885cdf0e10cSrcweir 				aFirstPos.mnRow++;
886cdf0e10cSrcweir 				nSelectedChildIndex -= nSelectedColumns;
887cdf0e10cSrcweir 			}
888cdf0e10cSrcweir 			return getAccessibleCellAt( nSelectedColumns, aFirstPos.mnRow );
889cdf0e10cSrcweir 		}
890cdf0e10cSrcweir 	}
891cdf0e10cSrcweir 
892cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
893*9b8096d0SSteve Yin 	*/
894*9b8096d0SSteve Yin 	if( nSelectedChildIndex < 0 )
895*9b8096d0SSteve Yin         throw IndexOutOfBoundsException();
896*9b8096d0SSteve Yin 
897*9b8096d0SSteve Yin 	sal_Int32 nChildIndex = GetIndexOfSelectedChild( nSelectedChildIndex );
898*9b8096d0SSteve Yin 
899*9b8096d0SSteve Yin 	if( nChildIndex < 0 )
900*9b8096d0SSteve Yin         throw IndexOutOfBoundsException();
901*9b8096d0SSteve Yin 
902*9b8096d0SSteve Yin 	if ( nChildIndex >= getAccessibleChildCount() )
903*9b8096d0SSteve Yin     {
904*9b8096d0SSteve Yin         throw IndexOutOfBoundsException();
905*9b8096d0SSteve Yin     }
906*9b8096d0SSteve Yin 
907*9b8096d0SSteve Yin 	return getAccessibleChild( nChildIndex );
908*9b8096d0SSteve Yin 	//-----IAccessibility2 Implementation 2009
909cdf0e10cSrcweir }
910cdf0e10cSrcweir 
911cdf0e10cSrcweir //--------------------------------------------------------------------
912cdf0e10cSrcweir 
913cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::deselectAccessibleChild( sal_Int32 nChildIndex )  throw ( IndexOutOfBoundsException, RuntimeException )
914cdf0e10cSrcweir {
915cdf0e10cSrcweir    ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
916cdf0e10cSrcweir 	CellPos aPos;
917cdf0e10cSrcweir 	mxImpl->getColumnAndRow( nChildIndex, aPos.mnCol, aPos.mnRow );
918cdf0e10cSrcweir 
919cdf0e10cSrcweir 	// todo, select table shape?!?
920cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
921cdf0e10cSrcweir 	if( pController && pController->hasSelectedCells() )
922cdf0e10cSrcweir 	{
923cdf0e10cSrcweir 		CellPos aFirstPos, aLastPos;
924cdf0e10cSrcweir 		pController->getSelectedCells( aFirstPos, aLastPos );
925cdf0e10cSrcweir 
926cdf0e10cSrcweir 		// create a selection where aPos is not part of anymore
927cdf0e10cSrcweir 		aFirstPos.mnRow = std::min( aFirstPos.mnRow, aPos.mnRow+1 );
928cdf0e10cSrcweir 		aFirstPos.mnCol = std::min( aFirstPos.mnCol, aPos.mnCol+1 );
929cdf0e10cSrcweir 		aLastPos.mnRow = std::max( aLastPos.mnRow, aPos.mnRow-1 );
930cdf0e10cSrcweir 		aLastPos.mnCol = std::max( aLastPos.mnCol, aPos.mnCol-1 );
931cdf0e10cSrcweir 
932cdf0e10cSrcweir 		// new selection may be invalid (child to deselect is not at a border of the selection but in between)
933cdf0e10cSrcweir 		if( (aFirstPos.mnRow > aLastPos.mnRow) || (aFirstPos.mnCol > aLastPos.mnCol) )
934cdf0e10cSrcweir 			pController->clearSelection(); // if selection is invalid, clear all
935cdf0e10cSrcweir 		else
936cdf0e10cSrcweir 			pController->setSelectedCells( aFirstPos, aLastPos );
937cdf0e10cSrcweir 	}
938cdf0e10cSrcweir }
939cdf0e10cSrcweir //--------------------------------------------------------------------
940cdf0e10cSrcweir 
941*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
942*9b8096d0SSteve Yin //=====  XAccessibleTableSelection  ============================================
943*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleTableShape::selectRow( sal_Int32 row )
944*9b8096d0SSteve Yin throw (IndexOutOfBoundsException, RuntimeException)
945*9b8096d0SSteve Yin {
946*9b8096d0SSteve Yin 	::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
947*9b8096d0SSteve Yin 	SvxTableController* pController = getTableController();
948*9b8096d0SSteve Yin 	if( !pController )
949*9b8096d0SSteve Yin 		return sal_False;
950*9b8096d0SSteve Yin 	return pController->selectRow( row );
951*9b8096d0SSteve Yin }
952*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleTableShape::selectColumn( sal_Int32 column )
953*9b8096d0SSteve Yin throw (IndexOutOfBoundsException, RuntimeException)
954*9b8096d0SSteve Yin {
955*9b8096d0SSteve Yin 	::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
956*9b8096d0SSteve Yin 	SvxTableController* pController = getTableController();
957*9b8096d0SSteve Yin 	if( !pController )
958*9b8096d0SSteve Yin 		return sal_False;
959*9b8096d0SSteve Yin 	return pController->selectColumn( column );
960*9b8096d0SSteve Yin }
961*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleTableShape::unselectRow( sal_Int32 row )
962*9b8096d0SSteve Yin throw (IndexOutOfBoundsException, RuntimeException)
963*9b8096d0SSteve Yin {
964*9b8096d0SSteve Yin 	::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
965*9b8096d0SSteve Yin 	SvxTableController* pController = getTableController();
966*9b8096d0SSteve Yin 	if( !pController )
967*9b8096d0SSteve Yin 		return sal_False;
968*9b8096d0SSteve Yin 	return pController->deselectRow( row );
969*9b8096d0SSteve Yin }
970*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleTableShape::unselectColumn( sal_Int32 column )
971*9b8096d0SSteve Yin throw (IndexOutOfBoundsException, RuntimeException)
972*9b8096d0SSteve Yin {
973*9b8096d0SSteve Yin 	::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
974*9b8096d0SSteve Yin 	SvxTableController* pController = getTableController();
975*9b8096d0SSteve Yin 	if( !pController )
976*9b8096d0SSteve Yin 		return sal_False;
977*9b8096d0SSteve Yin 	return pController->deselectColumn( column );
978*9b8096d0SSteve Yin }
979*9b8096d0SSteve Yin sal_Int32 AccessibleTableShape::GetIndexOfSelectedChild(
980*9b8096d0SSteve Yin 				sal_Int32 nSelectedChildIndex ) const
981*9b8096d0SSteve Yin {
982*9b8096d0SSteve Yin     sal_Int32 nChildren = const_cast<AccessibleTableShape*>(this)->getAccessibleChildCount();
983*9b8096d0SSteve Yin 
984*9b8096d0SSteve Yin 	if( nSelectedChildIndex >= nChildren )
985*9b8096d0SSteve Yin 		return -1L;
986*9b8096d0SSteve Yin 
987*9b8096d0SSteve Yin     sal_Int32 n = 0;
988*9b8096d0SSteve Yin     while( n < nChildren )
989*9b8096d0SSteve Yin     {
990*9b8096d0SSteve Yin         if( const_cast<AccessibleTableShape*>(this)->isAccessibleChildSelected( n ) )
991*9b8096d0SSteve Yin 		{
992*9b8096d0SSteve Yin 			if( 0 == nSelectedChildIndex )
993*9b8096d0SSteve Yin 				break;
994*9b8096d0SSteve Yin 			else
995*9b8096d0SSteve Yin 				--nSelectedChildIndex;
996*9b8096d0SSteve Yin 		}
997*9b8096d0SSteve Yin         ++n;
998*9b8096d0SSteve Yin     }
999*9b8096d0SSteve Yin 
1000*9b8096d0SSteve Yin 	return n < nChildren ? n : -1L;
1001*9b8096d0SSteve Yin }
1002*9b8096d0SSteve Yin void AccessibleTableShape::getColumnAndRow( sal_Int32 nChildIndex, sal_Int32& rnColumn, sal_Int32& rnRow ) throw (IndexOutOfBoundsException )
1003*9b8096d0SSteve Yin {
1004*9b8096d0SSteve Yin 	mxImpl->getColumnAndRow(nChildIndex, rnColumn, rnRow);
1005*9b8096d0SSteve Yin }
1006*9b8096d0SSteve Yin //--------------------------------------------------------------------
1007*9b8096d0SSteve Yin // XSelectionChangeListener
1008*9b8096d0SSteve Yin void SAL_CALL
1009*9b8096d0SSteve Yin     AccessibleTableShape::disposing (const EventObject& aEvent)
1010*9b8096d0SSteve Yin     throw (RuntimeException)
1011*9b8096d0SSteve Yin {
1012*9b8096d0SSteve Yin 	AccessibleShape::disposing(aEvent);
1013*9b8096d0SSteve Yin }
1014*9b8096d0SSteve Yin void  SAL_CALL AccessibleTableShape::selectionChanged (const EventObject& rEvent)
1015*9b8096d0SSteve Yin         throw (RuntimeException)
1016*9b8096d0SSteve Yin {
1017*9b8096d0SSteve Yin 	//::sdr::table::CellRef xCellRef = static_cast< ::sdr::table::CellRef > (rEvent.Source);
1018*9b8096d0SSteve Yin 	Reference< XCell > xCell(rEvent.Source, UNO_QUERY);
1019*9b8096d0SSteve Yin 	if (xCell.is())
1020*9b8096d0SSteve Yin 	{
1021*9b8096d0SSteve Yin 		Reference< AccessibleCell > xAccCell = mxImpl->getAccessibleCell( xCell );
1022*9b8096d0SSteve Yin 		if (xAccCell.is())
1023*9b8096d0SSteve Yin 		{
1024*9b8096d0SSteve Yin 			sal_Int32 nIndex = xAccCell->getAccessibleIndexInParent(),
1025*9b8096d0SSteve Yin 				nCount = getSelectedAccessibleChildCount();
1026*9b8096d0SSteve Yin 			sal_Bool bSelected = isAccessibleChildSelected(nIndex);
1027*9b8096d0SSteve Yin 			if (mnPreviousSelectionCount == 0 && nCount > 0 && bSelected)
1028*9b8096d0SSteve Yin 			{
1029*9b8096d0SSteve Yin 				xAccCell->SetState(AccessibleStateType::SELECTED);
1030*9b8096d0SSteve Yin 				xAccCell->CommitChange(AccessibleEventId::SELECTION_CHANGED, Any(), Any());
1031*9b8096d0SSteve Yin 			}
1032*9b8096d0SSteve Yin 			else if (bSelected)
1033*9b8096d0SSteve Yin 			{
1034*9b8096d0SSteve Yin 				xAccCell->SetState(AccessibleStateType::SELECTED);
1035*9b8096d0SSteve Yin 				xAccCell->CommitChange(AccessibleEventId::SELECTION_CHANGED_ADD, Any(), Any());
1036*9b8096d0SSteve Yin 			}
1037*9b8096d0SSteve Yin 			else
1038*9b8096d0SSteve Yin 			{
1039*9b8096d0SSteve Yin 				xAccCell->ResetState(AccessibleStateType::SELECTED);
1040*9b8096d0SSteve Yin 				xAccCell->CommitChange(AccessibleEventId::SELECTION_CHANGED_REMOVE, Any(), Any());
1041*9b8096d0SSteve Yin 			}
1042*9b8096d0SSteve Yin 			mnPreviousSelectionCount = nCount;
1043*9b8096d0SSteve Yin 		}
1044*9b8096d0SSteve Yin 	}
1045*9b8096d0SSteve Yin }
1046*9b8096d0SSteve Yin // Get the currently active cell which is text editing
1047*9b8096d0SSteve Yin AccessibleCell* AccessibleTableShape::GetActiveAccessibleCell()
1048*9b8096d0SSteve Yin {
1049*9b8096d0SSteve Yin 	sal_Bool bCellEditing = sal_False;
1050*9b8096d0SSteve Yin 	Reference< AccessibleCell > xAccCell;
1051*9b8096d0SSteve Yin 	AccessibleCell* pAccCell = NULL;
1052*9b8096d0SSteve Yin 	SvxTableController* pController = getTableController();
1053*9b8096d0SSteve Yin 	if (pController)
1054*9b8096d0SSteve Yin 	{
1055*9b8096d0SSteve Yin 		::sdr::table::SdrTableObj* pTableObj = pController->GetTableObj();
1056*9b8096d0SSteve Yin 		if ( pTableObj )
1057*9b8096d0SSteve Yin 		{
1058*9b8096d0SSteve Yin 			::sdr::table::CellRef xCellRef (pTableObj->getActiveCell());
1059*9b8096d0SSteve Yin 			if ( xCellRef.is() )
1060*9b8096d0SSteve Yin 			{
1061*9b8096d0SSteve Yin 				bCellEditing = xCellRef->IsTextEditActive();
1062*9b8096d0SSteve Yin 				if (bCellEditing)
1063*9b8096d0SSteve Yin 				{
1064*9b8096d0SSteve Yin 					//Reference< XCell > xCell(xCellRef.get(), UNO_QUERY);
1065*9b8096d0SSteve Yin 					xAccCell = mxImpl->getAccessibleCell(Reference< XCell >( xCellRef.get() ));
1066*9b8096d0SSteve Yin 					if (xAccCell.is())
1067*9b8096d0SSteve Yin 						pAccCell = xAccCell.get();
1068*9b8096d0SSteve Yin 				}
1069*9b8096d0SSteve Yin 			}
1070*9b8096d0SSteve Yin 		}
1071*9b8096d0SSteve Yin 	}
1072*9b8096d0SSteve Yin 	return pAccCell;
1073*9b8096d0SSteve Yin }
1074*9b8096d0SSteve Yin //--------------------------------------------------------------------
1075*9b8096d0SSteve Yin //If current active cell is in editing, the focus state should be set to internal text
1076*9b8096d0SSteve Yin sal_Bool AccessibleTableShape::SetState (sal_Int16 aState)
1077*9b8096d0SSteve Yin {
1078*9b8096d0SSteve Yin     AccessibleCell* pActiveAccessibleCell = GetActiveAccessibleCell();
1079*9b8096d0SSteve Yin     sal_Bool bStateHasChanged = sal_False;
1080*9b8096d0SSteve Yin     if (aState == AccessibleStateType::FOCUSED && pActiveAccessibleCell != NULL)
1081*9b8096d0SSteve Yin     {
1082*9b8096d0SSteve Yin 		return pActiveAccessibleCell->SetState(aState);
1083*9b8096d0SSteve Yin     }
1084*9b8096d0SSteve Yin     else
1085*9b8096d0SSteve Yin         bStateHasChanged = AccessibleShape::SetState (aState);
1086*9b8096d0SSteve Yin     return bStateHasChanged;
1087*9b8096d0SSteve Yin }
1088*9b8096d0SSteve Yin //--------------------------------------------------------------------
1089*9b8096d0SSteve Yin //If current active cell is in editing, the focus state should be reset to internal text
1090*9b8096d0SSteve Yin sal_Bool AccessibleTableShape::ResetState (sal_Int16 aState)
1091*9b8096d0SSteve Yin {
1092*9b8096d0SSteve Yin     AccessibleCell* pActiveAccessibleCell = GetActiveAccessibleCell();
1093*9b8096d0SSteve Yin     sal_Bool bStateHasChanged = sal_False;
1094*9b8096d0SSteve Yin     if (aState == AccessibleStateType::FOCUSED && pActiveAccessibleCell != NULL)
1095*9b8096d0SSteve Yin     {
1096*9b8096d0SSteve Yin 		return pActiveAccessibleCell->ResetState(aState);
1097*9b8096d0SSteve Yin     }
1098*9b8096d0SSteve Yin     else
1099*9b8096d0SSteve Yin         bStateHasChanged = AccessibleShape::ResetState (aState);
1100*9b8096d0SSteve Yin     return bStateHasChanged;
1101*9b8096d0SSteve Yin }
1102*9b8096d0SSteve Yin //--------------------------------------------------------------------
1103*9b8096d0SSteve Yin sal_Bool AccessibleTableShape::SetStateDirectly (sal_Int16 aState)
1104*9b8096d0SSteve Yin {
1105*9b8096d0SSteve Yin 	return AccessibleContextBase::SetState (aState);
1106*9b8096d0SSteve Yin }
1107*9b8096d0SSteve Yin //--------------------------------------------------------------------
1108*9b8096d0SSteve Yin sal_Bool AccessibleTableShape::ResetStateDirectly (sal_Int16 aState)
1109*9b8096d0SSteve Yin {
1110*9b8096d0SSteve Yin 	return AccessibleContextBase::ResetState (aState);
1111*9b8096d0SSteve Yin }
1112*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
1113cdf0e10cSrcweir void AccessibleTableShape::checkCellPosition( sal_Int32 nCol, sal_Int32 nRow ) throw ( IndexOutOfBoundsException )
1114cdf0e10cSrcweir {
1115cdf0e10cSrcweir 	if( (nCol >= 0) && (nRow >= 0) && mxImpl->mxTable.is() && (nCol < mxImpl->mxTable->getColumnCount()) && (nRow < mxImpl->mxTable->getRowCount()) )
1116cdf0e10cSrcweir 		return;
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
1119cdf0e10cSrcweir }
1120cdf0e10cSrcweir 
1121*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009-----
1122*9b8096d0SSteve Yin AccessibleTableHeaderShape::AccessibleTableHeaderShape( AccessibleTableShape* pTable, sal_Bool bRow )
1123*9b8096d0SSteve Yin {
1124*9b8096d0SSteve Yin 	mpTable = pTable;
1125*9b8096d0SSteve Yin 	mbRow = bRow;
1126*9b8096d0SSteve Yin }
1127*9b8096d0SSteve Yin 
1128*9b8096d0SSteve Yin AccessibleTableHeaderShape::~AccessibleTableHeaderShape (void)
1129*9b8096d0SSteve Yin {
1130*9b8096d0SSteve Yin 	mpTable = NULL;
1131*9b8096d0SSteve Yin }
1132*9b8096d0SSteve Yin 
1133*9b8096d0SSteve Yin // XAccessible
1134*9b8096d0SSteve Yin Reference< XAccessibleContext > SAL_CALL AccessibleTableHeaderShape::getAccessibleContext(void) throw (RuntimeException)
1135*9b8096d0SSteve Yin {
1136*9b8096d0SSteve Yin 	return this;
1137*9b8096d0SSteve Yin }
1138*9b8096d0SSteve Yin 
1139*9b8096d0SSteve Yin // XAccessibleContext
1140*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleTableHeaderShape::getAccessibleChildCount( ) throw(RuntimeException)
1141*9b8096d0SSteve Yin {
1142*9b8096d0SSteve Yin 	return getAccessibleRowCount() * getAccessibleColumnCount();
1143*9b8096d0SSteve Yin }
1144*9b8096d0SSteve Yin 
1145*9b8096d0SSteve Yin Reference< XAccessible > SAL_CALL AccessibleTableHeaderShape::getAccessibleChild( sal_Int32 i ) throw(IndexOutOfBoundsException, RuntimeException)
1146*9b8096d0SSteve Yin {
1147*9b8096d0SSteve Yin 	return mpTable->getAccessibleChild( i );
1148*9b8096d0SSteve Yin }
1149*9b8096d0SSteve Yin 
1150*9b8096d0SSteve Yin Reference< XAccessible > SAL_CALL AccessibleTableHeaderShape::getAccessibleParent (void) throw (RuntimeException)
1151*9b8096d0SSteve Yin {
1152*9b8096d0SSteve Yin 	Reference< XAccessible > XParent;
1153*9b8096d0SSteve Yin     return XParent;
1154*9b8096d0SSteve Yin }
1155*9b8096d0SSteve Yin 
1156*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleTableHeaderShape::getAccessibleIndexInParent (void) throw (RuntimeException)
1157*9b8096d0SSteve Yin {
1158*9b8096d0SSteve Yin 	return -1;
1159*9b8096d0SSteve Yin }
1160*9b8096d0SSteve Yin 
1161*9b8096d0SSteve Yin sal_Int16 SAL_CALL AccessibleTableHeaderShape::getAccessibleRole (void) throw (RuntimeException)
1162*9b8096d0SSteve Yin {
1163*9b8096d0SSteve Yin 	return mpTable->getAccessibleRole();
1164*9b8096d0SSteve Yin }
1165*9b8096d0SSteve Yin 
1166*9b8096d0SSteve Yin OUString SAL_CALL AccessibleTableHeaderShape::getAccessibleDescription (void) throw (RuntimeException)
1167*9b8096d0SSteve Yin {
1168*9b8096d0SSteve Yin     return mpTable->getAccessibleDescription();
1169*9b8096d0SSteve Yin }
1170*9b8096d0SSteve Yin 
1171*9b8096d0SSteve Yin OUString SAL_CALL AccessibleTableHeaderShape::getAccessibleName (void) throw (RuntimeException)
1172*9b8096d0SSteve Yin {
1173*9b8096d0SSteve Yin 	return mpTable->getAccessibleName();
1174*9b8096d0SSteve Yin }
1175*9b8096d0SSteve Yin 
1176*9b8096d0SSteve Yin Reference< XAccessibleStateSet > SAL_CALL AccessibleTableHeaderShape::getAccessibleStateSet (void) throw (RuntimeException)
1177*9b8096d0SSteve Yin {
1178*9b8096d0SSteve Yin 	return mpTable->getAccessibleStateSet();
1179*9b8096d0SSteve Yin }
1180*9b8096d0SSteve Yin 
1181*9b8096d0SSteve Yin Reference< XAccessibleRelationSet > SAL_CALL AccessibleTableHeaderShape::getAccessibleRelationSet (void) throw (RuntimeException)
1182*9b8096d0SSteve Yin {
1183*9b8096d0SSteve Yin 	return mpTable->getAccessibleRelationSet();
1184*9b8096d0SSteve Yin }
1185*9b8096d0SSteve Yin 
1186*9b8096d0SSteve Yin Locale SAL_CALL AccessibleTableHeaderShape::getLocale (void) throw (IllegalAccessibleComponentStateException, RuntimeException)
1187*9b8096d0SSteve Yin {
1188*9b8096d0SSteve Yin 	return mpTable->getLocale();
1189*9b8096d0SSteve Yin }
1190*9b8096d0SSteve Yin 
1191*9b8096d0SSteve Yin //XAccessibleComponent
1192*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleTableHeaderShape::containsPoint ( const ::com::sun::star::awt::Point& aPoint ) throw (RuntimeException)
1193*9b8096d0SSteve Yin {
1194*9b8096d0SSteve Yin 	return mpTable->containsPoint( aPoint );
1195*9b8096d0SSteve Yin }
1196*9b8096d0SSteve Yin 
1197*9b8096d0SSteve Yin Reference< XAccessible > SAL_CALL AccessibleTableHeaderShape::getAccessibleAtPoint ( const ::com::sun::star::awt::Point& aPoint) throw (RuntimeException)
1198*9b8096d0SSteve Yin {
1199*9b8096d0SSteve Yin 	return mpTable->getAccessibleAtPoint( aPoint );
1200*9b8096d0SSteve Yin }
1201*9b8096d0SSteve Yin 
1202*9b8096d0SSteve Yin ::com::sun::star::awt::Rectangle SAL_CALL AccessibleTableHeaderShape::getBounds (void) throw (RuntimeException)
1203*9b8096d0SSteve Yin {
1204*9b8096d0SSteve Yin 	return mpTable->getBounds();
1205*9b8096d0SSteve Yin }
1206*9b8096d0SSteve Yin 
1207*9b8096d0SSteve Yin ::com::sun::star::awt::Point SAL_CALL AccessibleTableHeaderShape::getLocation (void) throw (RuntimeException)
1208*9b8096d0SSteve Yin {
1209*9b8096d0SSteve Yin 	return mpTable->getLocation();
1210*9b8096d0SSteve Yin }
1211*9b8096d0SSteve Yin 
1212*9b8096d0SSteve Yin ::com::sun::star::awt::Point SAL_CALL AccessibleTableHeaderShape::getLocationOnScreen (void) throw (RuntimeException)
1213*9b8096d0SSteve Yin {
1214*9b8096d0SSteve Yin 	return mpTable->getLocationOnScreen();
1215*9b8096d0SSteve Yin }
1216*9b8096d0SSteve Yin 
1217*9b8096d0SSteve Yin ::com::sun::star::awt::Size SAL_CALL AccessibleTableHeaderShape::getSize (void) throw (RuntimeException)
1218*9b8096d0SSteve Yin {
1219*9b8096d0SSteve Yin 	return mpTable->getSize();
1220*9b8096d0SSteve Yin }
1221*9b8096d0SSteve Yin 
1222*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleTableHeaderShape::getForeground (void) throw (RuntimeException)
1223*9b8096d0SSteve Yin {
1224*9b8096d0SSteve Yin     return mpTable->getForeground();
1225*9b8096d0SSteve Yin }
1226*9b8096d0SSteve Yin 
1227*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleTableHeaderShape::getBackground (void) throw (RuntimeException)
1228*9b8096d0SSteve Yin {
1229*9b8096d0SSteve Yin     return mpTable->getBackground();
1230*9b8096d0SSteve Yin }
1231*9b8096d0SSteve Yin 
1232*9b8096d0SSteve Yin void SAL_CALL AccessibleTableHeaderShape::grabFocus (void) throw (RuntimeException)
1233*9b8096d0SSteve Yin {
1234*9b8096d0SSteve Yin 	mpTable->grabFocus();
1235*9b8096d0SSteve Yin }
1236*9b8096d0SSteve Yin //=====  XAccessibleTable  ============================================
1237*9b8096d0SSteve Yin 
1238*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleTableHeaderShape::getAccessibleRowCount() throw (RuntimeException)
1239*9b8096d0SSteve Yin {
1240*9b8096d0SSteve Yin 	return mbRow ? 1 : mpTable->getAccessibleRowCount();
1241*9b8096d0SSteve Yin }
1242*9b8096d0SSteve Yin 
1243*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleTableHeaderShape::getAccessibleColumnCount() throw (RuntimeException)
1244*9b8096d0SSteve Yin {
1245*9b8096d0SSteve Yin     return !mbRow ? 1 : mpTable->getAccessibleColumnCount();
1246*9b8096d0SSteve Yin }
1247*9b8096d0SSteve Yin 
1248*9b8096d0SSteve Yin OUString SAL_CALL AccessibleTableHeaderShape::getAccessibleRowDescription( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
1249*9b8096d0SSteve Yin {
1250*9b8096d0SSteve Yin 	return mpTable->getAccessibleRowDescription( nRow );
1251*9b8096d0SSteve Yin }
1252*9b8096d0SSteve Yin 
1253*9b8096d0SSteve Yin OUString SAL_CALL AccessibleTableHeaderShape::getAccessibleColumnDescription( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
1254*9b8096d0SSteve Yin {
1255*9b8096d0SSteve Yin     return mpTable->getAccessibleColumnDescription( nColumn );
1256*9b8096d0SSteve Yin }
1257*9b8096d0SSteve Yin 
1258*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleTableHeaderShape::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
1259*9b8096d0SSteve Yin {
1260*9b8096d0SSteve Yin 	return mpTable->getAccessibleRowExtentAt( nRow, nColumn );
1261*9b8096d0SSteve Yin }
1262*9b8096d0SSteve Yin 
1263*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleTableHeaderShape::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
1264*9b8096d0SSteve Yin {
1265*9b8096d0SSteve Yin 	return mpTable->getAccessibleColumnExtentAt( nRow, nColumn );
1266*9b8096d0SSteve Yin }
1267*9b8096d0SSteve Yin 
1268*9b8096d0SSteve Yin Reference< XAccessibleTable > SAL_CALL AccessibleTableHeaderShape::getAccessibleRowHeaders(  ) throw (RuntimeException)
1269*9b8096d0SSteve Yin {
1270*9b8096d0SSteve Yin 	Reference< XAccessibleTable > xRet;
1271*9b8096d0SSteve Yin 	return xRet;
1272*9b8096d0SSteve Yin }
1273*9b8096d0SSteve Yin 
1274*9b8096d0SSteve Yin Reference< XAccessibleTable > SAL_CALL AccessibleTableHeaderShape::getAccessibleColumnHeaders(  ) throw (RuntimeException)
1275*9b8096d0SSteve Yin {
1276*9b8096d0SSteve Yin 	Reference< XAccessibleTable > xRet;
1277*9b8096d0SSteve Yin 	return xRet;
1278*9b8096d0SSteve Yin }
1279*9b8096d0SSteve Yin 
1280*9b8096d0SSteve Yin Sequence< sal_Int32 > SAL_CALL AccessibleTableHeaderShape::getSelectedAccessibleRows(  ) throw (RuntimeException)
1281*9b8096d0SSteve Yin {
1282*9b8096d0SSteve Yin 	sal_Int32 nRow = getAccessibleRowCount();
1283*9b8096d0SSteve Yin 	::std::vector< sal_Bool > aSelected( nRow, sal_True );
1284*9b8096d0SSteve Yin 	sal_Int32 nCount = nRow;
1285*9b8096d0SSteve Yin 	for( sal_Int32 i = 0; i < nRow; i++ )
1286*9b8096d0SSteve Yin 	{
1287*9b8096d0SSteve Yin 		try
1288*9b8096d0SSteve Yin 		{
1289*9b8096d0SSteve Yin 			aSelected[i] = isAccessibleRowSelected( i );
1290*9b8096d0SSteve Yin 		}
1291*9b8096d0SSteve Yin 		catch( ... )
1292*9b8096d0SSteve Yin 		{
1293*9b8096d0SSteve Yin 			return Sequence< sal_Int32 >();
1294*9b8096d0SSteve Yin 		}
1295*9b8096d0SSteve Yin 
1296*9b8096d0SSteve Yin 		if( !aSelected[i] )
1297*9b8096d0SSteve Yin 			nCount--;
1298*9b8096d0SSteve Yin 	}
1299*9b8096d0SSteve Yin 	Sequence < sal_Int32 > aRet( nCount );
1300*9b8096d0SSteve Yin 	sal_Int32 *pRet = aRet.getArray();
1301*9b8096d0SSteve Yin 	sal_Int32 nPos = 0;
1302*9b8096d0SSteve Yin 	size_t nSize = aSelected.size();
1303*9b8096d0SSteve Yin 	for( size_t i=0; i < nSize && nPos < nCount; i++ )
1304*9b8096d0SSteve Yin 	{
1305*9b8096d0SSteve Yin 		if( aSelected[i] )
1306*9b8096d0SSteve Yin 		{
1307*9b8096d0SSteve Yin 			*pRet++ = i;
1308*9b8096d0SSteve Yin 			nPos++;
1309*9b8096d0SSteve Yin 		}
1310*9b8096d0SSteve Yin 	}
1311*9b8096d0SSteve Yin 
1312*9b8096d0SSteve Yin 	return aRet;
1313*9b8096d0SSteve Yin }
1314*9b8096d0SSteve Yin 
1315*9b8096d0SSteve Yin Sequence< sal_Int32 > SAL_CALL AccessibleTableHeaderShape::getSelectedAccessibleColumns(  ) throw (RuntimeException)
1316*9b8096d0SSteve Yin {
1317*9b8096d0SSteve Yin 	sal_Int32 nColumn = getAccessibleColumnCount();
1318*9b8096d0SSteve Yin 	::std::vector< sal_Bool > aSelected( nColumn, sal_True );
1319*9b8096d0SSteve Yin 	sal_Int32 nCount = nColumn;
1320*9b8096d0SSteve Yin 	for( sal_Int32 i = 0; i < nColumn; i++ )
1321*9b8096d0SSteve Yin 	{
1322*9b8096d0SSteve Yin 		try
1323*9b8096d0SSteve Yin 		{
1324*9b8096d0SSteve Yin 			aSelected[i] = isAccessibleColumnSelected( i );
1325*9b8096d0SSteve Yin 		}
1326*9b8096d0SSteve Yin 		catch( ... )
1327*9b8096d0SSteve Yin 		{
1328*9b8096d0SSteve Yin 			return Sequence< sal_Int32 >();
1329*9b8096d0SSteve Yin 		}
1330*9b8096d0SSteve Yin 
1331*9b8096d0SSteve Yin 		if( !aSelected[i] )
1332*9b8096d0SSteve Yin 			nCount--;
1333*9b8096d0SSteve Yin 	}
1334*9b8096d0SSteve Yin 	Sequence < sal_Int32 > aRet( nCount );
1335*9b8096d0SSteve Yin 	sal_Int32 *pRet = aRet.getArray();
1336*9b8096d0SSteve Yin 	sal_Int32 nPos = 0;
1337*9b8096d0SSteve Yin 	size_t nSize = aSelected.size();
1338*9b8096d0SSteve Yin 	for( size_t i=0; i < nSize && nPos < nCount; i++ )
1339*9b8096d0SSteve Yin 	{
1340*9b8096d0SSteve Yin 		if( aSelected[i] )
1341*9b8096d0SSteve Yin 		{
1342*9b8096d0SSteve Yin 			*pRet++ = i;
1343*9b8096d0SSteve Yin 			nPos++;
1344*9b8096d0SSteve Yin 		}
1345*9b8096d0SSteve Yin 	}
1346*9b8096d0SSteve Yin 
1347*9b8096d0SSteve Yin 	return aRet;
1348*9b8096d0SSteve Yin }
1349*9b8096d0SSteve Yin 
1350*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleTableHeaderShape::isAccessibleRowSelected( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
1351*9b8096d0SSteve Yin {
1352*9b8096d0SSteve Yin 	return mpTable->isAccessibleRowSelected( nRow );
1353*9b8096d0SSteve Yin }
1354*9b8096d0SSteve Yin 
1355*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleTableHeaderShape::isAccessibleColumnSelected( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
1356*9b8096d0SSteve Yin {
1357*9b8096d0SSteve Yin 	return mpTable->isAccessibleColumnSelected( nColumn );
1358*9b8096d0SSteve Yin }
1359*9b8096d0SSteve Yin 
1360*9b8096d0SSteve Yin Reference< XAccessible > SAL_CALL AccessibleTableHeaderShape::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
1361*9b8096d0SSteve Yin {
1362*9b8096d0SSteve Yin 	return mpTable->getAccessibleCellAt( nRow, nColumn );
1363*9b8096d0SSteve Yin }
1364*9b8096d0SSteve Yin 
1365*9b8096d0SSteve Yin Reference< XAccessible > SAL_CALL AccessibleTableHeaderShape::getAccessibleCaption(  ) throw (RuntimeException)
1366*9b8096d0SSteve Yin {
1367*9b8096d0SSteve Yin 	return mpTable->getAccessibleCaption();
1368*9b8096d0SSteve Yin }
1369*9b8096d0SSteve Yin 
1370*9b8096d0SSteve Yin Reference< XAccessible > SAL_CALL AccessibleTableHeaderShape::getAccessibleSummary(  ) throw (RuntimeException)
1371*9b8096d0SSteve Yin {
1372*9b8096d0SSteve Yin 	return mpTable->getAccessibleSummary();
1373*9b8096d0SSteve Yin }
1374*9b8096d0SSteve Yin 
1375*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleTableHeaderShape::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
1376*9b8096d0SSteve Yin {
1377*9b8096d0SSteve Yin 	return mpTable->isAccessibleSelected( nRow, nColumn );
1378*9b8096d0SSteve Yin }
1379*9b8096d0SSteve Yin 
1380*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleTableHeaderShape::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
1381*9b8096d0SSteve Yin {
1382*9b8096d0SSteve Yin 	return mpTable->getAccessibleIndex( nRow, nColumn );
1383*9b8096d0SSteve Yin }
1384*9b8096d0SSteve Yin 
1385*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleTableHeaderShape::getAccessibleRow( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
1386*9b8096d0SSteve Yin {
1387*9b8096d0SSteve Yin 	return mpTable->getAccessibleRow( nChildIndex );
1388*9b8096d0SSteve Yin }
1389*9b8096d0SSteve Yin 
1390*9b8096d0SSteve Yin sal_Int32 SAL_CALL AccessibleTableHeaderShape::getAccessibleColumn( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
1391*9b8096d0SSteve Yin {
1392*9b8096d0SSteve Yin 	return mpTable->getAccessibleColumn( nChildIndex );
1393*9b8096d0SSteve Yin }
1394*9b8096d0SSteve Yin 
1395*9b8096d0SSteve Yin //=====  XAccessibleTableSelection  ============================================
1396*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleTableHeaderShape::selectRow( sal_Int32 row )
1397*9b8096d0SSteve Yin throw (IndexOutOfBoundsException, RuntimeException)
1398*9b8096d0SSteve Yin {
1399*9b8096d0SSteve Yin 	if( mbRow )
1400*9b8096d0SSteve Yin 		return mpTable->selectRow( row );
1401*9b8096d0SSteve Yin 	else
1402*9b8096d0SSteve Yin 	{
1403*9b8096d0SSteve Yin 		mpTable->clearAccessibleSelection();
1404*9b8096d0SSteve Yin 		sal_Int32 nIndex = mpTable->getAccessibleIndex( row, 0 );
1405*9b8096d0SSteve Yin 		mpTable->selectAccessibleChild( nIndex );
1406*9b8096d0SSteve Yin 		return sal_True;
1407*9b8096d0SSteve Yin 	}
1408*9b8096d0SSteve Yin }
1409*9b8096d0SSteve Yin 
1410*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleTableHeaderShape::selectColumn( sal_Int32 column )
1411*9b8096d0SSteve Yin throw (IndexOutOfBoundsException, RuntimeException)
1412*9b8096d0SSteve Yin {
1413*9b8096d0SSteve Yin 	if( !mbRow )
1414*9b8096d0SSteve Yin 		return mpTable->selectColumn( column );
1415*9b8096d0SSteve Yin 	else
1416*9b8096d0SSteve Yin 	{
1417*9b8096d0SSteve Yin 		mpTable->clearAccessibleSelection();
1418*9b8096d0SSteve Yin 		sal_Int32 nIndex = mpTable->getAccessibleIndex( 0, column );
1419*9b8096d0SSteve Yin 		mpTable->selectAccessibleChild( nIndex );
1420*9b8096d0SSteve Yin 		return sal_True;
1421*9b8096d0SSteve Yin 	}
1422*9b8096d0SSteve Yin }
1423*9b8096d0SSteve Yin 
1424*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleTableHeaderShape::unselectRow( sal_Int32 row )
1425*9b8096d0SSteve Yin throw (IndexOutOfBoundsException, RuntimeException)
1426*9b8096d0SSteve Yin {
1427*9b8096d0SSteve Yin 	if( mbRow )
1428*9b8096d0SSteve Yin 		return mpTable->unselectRow( row );
1429*9b8096d0SSteve Yin 	else
1430*9b8096d0SSteve Yin 	{
1431*9b8096d0SSteve Yin 		sal_Int32 nIndex = mpTable->getAccessibleIndex( row, 0 );
1432*9b8096d0SSteve Yin 		mpTable->deselectAccessibleChild( nIndex );
1433*9b8096d0SSteve Yin 		return sal_True;
1434*9b8096d0SSteve Yin 	}
1435*9b8096d0SSteve Yin }
1436*9b8096d0SSteve Yin 
1437*9b8096d0SSteve Yin sal_Bool SAL_CALL AccessibleTableHeaderShape::unselectColumn( sal_Int32 column )
1438*9b8096d0SSteve Yin throw (IndexOutOfBoundsException, RuntimeException)
1439*9b8096d0SSteve Yin {
1440*9b8096d0SSteve Yin 	if( !mbRow )
1441*9b8096d0SSteve Yin 		return mpTable->unselectColumn( column );
1442*9b8096d0SSteve Yin 	else
1443*9b8096d0SSteve Yin 	{
1444*9b8096d0SSteve Yin 		sal_Int32 nIndex = mpTable->getAccessibleIndex( 0, column );
1445*9b8096d0SSteve Yin 		mpTable->deselectAccessibleChild( nIndex );
1446*9b8096d0SSteve Yin 		return sal_True;
1447*9b8096d0SSteve Yin 	}
1448*9b8096d0SSteve Yin }
1449*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009
1450cdf0e10cSrcweir }
1451