xref: /AOO41X/main/svx/source/table/accessibletableshape.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svx.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/table/XMergeableCell.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <comphelper/accessiblewrapper.hxx>
36*cdf0e10cSrcweir #include <vos/mutex.hxx>
37*cdf0e10cSrcweir #include <tools/debug.hxx>
38*cdf0e10cSrcweir #include <vcl/svapp.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <svx/AccessibleTableShape.hxx>
41*cdf0e10cSrcweir #include "tablecontroller.hxx"
42*cdf0e10cSrcweir #include "accessiblecell.hxx"
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #include <algorithm>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir using ::rtl::OUString;
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir using namespace ::accessibility;
51*cdf0e10cSrcweir using namespace ::sdr::table;
52*cdf0e10cSrcweir using namespace	::com::sun::star::accessibility;
53*cdf0e10cSrcweir using namespace	::com::sun::star::uno;
54*cdf0e10cSrcweir using namespace	::com::sun::star::beans;
55*cdf0e10cSrcweir using namespace	::com::sun::star::util;
56*cdf0e10cSrcweir using namespace	::com::sun::star::lang;
57*cdf0e10cSrcweir using namespace	::com::sun::star::drawing;
58*cdf0e10cSrcweir using namespace	::com::sun::star::table;
59*cdf0e10cSrcweir using namespace	::com::sun::star::container;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir #define C2U(x) OUString(RTL_CONSTASCII_USTRINGPARAM(x))
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir namespace accessibility
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir struct hash
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir 	std::size_t operator()( const Reference< XCell >& xCell ) const
69*cdf0e10cSrcweir 	{
70*cdf0e10cSrcweir 		return std::size_t( xCell.get() );
71*cdf0e10cSrcweir 	}
72*cdf0e10cSrcweir };
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir typedef std::hash_map< Reference< XCell >, rtl::Reference< AccessibleCell >, hash > AccessibleCellMap;
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir //-----------------------------------------------------------------------------
77*cdf0e10cSrcweir // AccessibleTableShapeImpl
78*cdf0e10cSrcweir //-----------------------------------------------------------------------------
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir class AccessibleTableShapeImpl : public cppu::WeakImplHelper1< XModifyListener >
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir public:
83*cdf0e10cSrcweir 	AccessibleTableShapeImpl( AccessibleShapeTreeInfo& rShapeTreeInfo );
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir 	void init( const Reference< XAccessible>& xAccessible, const Reference< XTable >& xTable );
86*cdf0e10cSrcweir 	void dispose();
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	Reference< XAccessible > getAccessibleChild( sal_Int32 i ) throw(IndexOutOfBoundsException);
89*cdf0e10cSrcweir 	void getColumnAndRow( sal_Int32 nChildIndex, sal_Int32& rnColumn, sal_Int32& rnRow ) throw (IndexOutOfBoundsException );
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     // XModifyListener
92*cdf0e10cSrcweir     virtual void SAL_CALL modified( const EventObject& aEvent ) throw (RuntimeException);
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     // XEventListener
95*cdf0e10cSrcweir     virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 	AccessibleShapeTreeInfo& mrShapeTreeInfo;
98*cdf0e10cSrcweir 	Reference< XTable > mxTable;
99*cdf0e10cSrcweir 	AccessibleCellMap maChildMap;
100*cdf0e10cSrcweir 	Reference< XAccessible> mxAccessible;
101*cdf0e10cSrcweir };
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir //-----------------------------------------------------------------------------
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir AccessibleTableShapeImpl::AccessibleTableShapeImpl( AccessibleShapeTreeInfo& rShapeTreeInfo )
106*cdf0e10cSrcweir : mrShapeTreeInfo( rShapeTreeInfo )
107*cdf0e10cSrcweir {
108*cdf0e10cSrcweir }
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir //-----------------------------------------------------------------------------
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir void AccessibleTableShapeImpl::init( const Reference< XAccessible>& xAccessible, const Reference< XTable >& xTable )
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir 	mxAccessible = xAccessible;
115*cdf0e10cSrcweir 	mxTable = xTable;
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	if( mxTable.is() )
118*cdf0e10cSrcweir 	{
119*cdf0e10cSrcweir 		Reference< XModifyListener > xListener( this );
120*cdf0e10cSrcweir 		mxTable->addModifyListener( xListener );
121*cdf0e10cSrcweir 	}
122*cdf0e10cSrcweir }
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir //-----------------------------------------------------------------------------
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir void AccessibleTableShapeImpl::dispose()
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir 	if( mxTable.is() )
129*cdf0e10cSrcweir 	{
130*cdf0e10cSrcweir 		Reference< XModifyListener > xListener( this );
131*cdf0e10cSrcweir 		mxTable->removeModifyListener( xListener );
132*cdf0e10cSrcweir 		mxTable.clear();
133*cdf0e10cSrcweir 	}
134*cdf0e10cSrcweir 	mxAccessible.clear();
135*cdf0e10cSrcweir }
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir //-----------------------------------------------------------------------------
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir Reference< XAccessible > AccessibleTableShapeImpl::getAccessibleChild( sal_Int32 nChildIndex ) throw(IndexOutOfBoundsException)
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir 	sal_Int32 nColumn = 0, nRow = 0;
142*cdf0e10cSrcweir 	getColumnAndRow( nChildIndex, nColumn, nRow );
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir 	Reference< XCell > xCell( mxTable->getCellByPosition( nColumn, nRow ) );
145*cdf0e10cSrcweir 	AccessibleCellMap::iterator iter( maChildMap.find( xCell ) );
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir 	if( iter != maChildMap.end() )
148*cdf0e10cSrcweir 	{
149*cdf0e10cSrcweir 		Reference< XAccessible > xChild( (*iter).second.get() );
150*cdf0e10cSrcweir 		return xChild;
151*cdf0e10cSrcweir 	}
152*cdf0e10cSrcweir 	else
153*cdf0e10cSrcweir 	{
154*cdf0e10cSrcweir 		CellRef xCellRef( dynamic_cast< Cell* >( xCell.get() ) );
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 		rtl::Reference< AccessibleCell > xAccessibleCell( new AccessibleCell( mxAccessible, xCellRef, nChildIndex, mrShapeTreeInfo ) );
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 		maChildMap[xCell] = xAccessibleCell;
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir         xAccessibleCell->Init();
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 		Reference< XAccessible > xChild( xAccessibleCell.get() );
163*cdf0e10cSrcweir 		return xChild;
164*cdf0e10cSrcweir 	}
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir //-----------------------------------------------------------------------------
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir void AccessibleTableShapeImpl::getColumnAndRow( sal_Int32 nChildIndex, sal_Int32& rnColumn, sal_Int32& rnRow ) throw (IndexOutOfBoundsException )
170*cdf0e10cSrcweir {
171*cdf0e10cSrcweir 	rnRow = 0;
172*cdf0e10cSrcweir 	rnColumn = nChildIndex;
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir 	if( mxTable.is() )
175*cdf0e10cSrcweir 	{
176*cdf0e10cSrcweir 		const sal_Int32 nColumnCount = mxTable->getColumnCount();
177*cdf0e10cSrcweir 		while( rnColumn >= nColumnCount )
178*cdf0e10cSrcweir 		{
179*cdf0e10cSrcweir 			rnRow++;
180*cdf0e10cSrcweir 			rnColumn -= nColumnCount;
181*cdf0e10cSrcweir 		}
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir 		if( rnRow < mxTable->getRowCount() )
184*cdf0e10cSrcweir 			return;
185*cdf0e10cSrcweir 	}
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
188*cdf0e10cSrcweir }
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir // XModifyListener
191*cdf0e10cSrcweir void SAL_CALL AccessibleTableShapeImpl::modified( const EventObject& /*aEvent*/ ) throw (RuntimeException)
192*cdf0e10cSrcweir {
193*cdf0e10cSrcweir 	if( mxTable.is() ) try
194*cdf0e10cSrcweir 	{
195*cdf0e10cSrcweir 		// structural changes may have happened to the table, validate all accessible cell instances
196*cdf0e10cSrcweir 		AccessibleCellMap aTempChildMap;
197*cdf0e10cSrcweir 		aTempChildMap.swap( maChildMap );
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir 		// first move all still existing cells to maChildMap again and update their index
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 		const sal_Int32 nRowCount = mxTable->getRowCount();
202*cdf0e10cSrcweir 		const sal_Int32 nColCount = mxTable->getColumnCount();
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 		sal_Int32 nChildIndex = 0;
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 		for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow )
207*cdf0e10cSrcweir 		{
208*cdf0e10cSrcweir 			for( sal_Int32 nCol = 0; nCol < nColCount; ++nCol )
209*cdf0e10cSrcweir 			{
210*cdf0e10cSrcweir 				Reference< XCell > xCell( mxTable->getCellByPosition( nCol, nRow ) );
211*cdf0e10cSrcweir 				AccessibleCellMap::iterator iter( aTempChildMap.find( xCell ) );
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 				if( iter != aTempChildMap.end() )
214*cdf0e10cSrcweir 				{
215*cdf0e10cSrcweir 					rtl::Reference< AccessibleCell > xAccessibleCell( (*iter).second );
216*cdf0e10cSrcweir 					xAccessibleCell->setIndexInParent( nChildIndex );
217*cdf0e10cSrcweir 					xAccessibleCell->CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, Any(), Any());
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 					// move still existing cell from temporary child map to our child map
220*cdf0e10cSrcweir 					maChildMap[xCell] = xAccessibleCell;
221*cdf0e10cSrcweir 					aTempChildMap.erase( iter );
222*cdf0e10cSrcweir 				}
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir 				++nChildIndex;
225*cdf0e10cSrcweir 			}
226*cdf0e10cSrcweir 		}
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 		// all accessible cell instances still left in aTempChildMap must be disposed
229*cdf0e10cSrcweir 		// as they are no longer part of the table
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir 		for( AccessibleCellMap::iterator iter( aTempChildMap.begin() ); iter != aTempChildMap.end(); iter++ )
232*cdf0e10cSrcweir 		{
233*cdf0e10cSrcweir 			(*iter).second->dispose();
234*cdf0e10cSrcweir 		}
235*cdf0e10cSrcweir 	}
236*cdf0e10cSrcweir 	catch( Exception& )
237*cdf0e10cSrcweir 	{
238*cdf0e10cSrcweir 		DBG_ERROR("svx::AccessibleTableShape::modified(), exception caught!");
239*cdf0e10cSrcweir 	}
240*cdf0e10cSrcweir }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir // XEventListener
243*cdf0e10cSrcweir void SAL_CALL AccessibleTableShapeImpl::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir }
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir //-----------------------------------------------------------------------------
248*cdf0e10cSrcweir // AccessibleTableShape
249*cdf0e10cSrcweir //-----------------------------------------------------------------------------
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir //-----------------------------------------------------------------------------
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir AccessibleTableShape::AccessibleTableShape( const AccessibleShapeInfo& rShapeInfo, const AccessibleShapeTreeInfo& rShapeTreeInfo)
254*cdf0e10cSrcweir : AccessibleTableShape_Base(rShapeInfo, rShapeTreeInfo)
255*cdf0e10cSrcweir , mxImpl( new AccessibleTableShapeImpl( maShapeTreeInfo ) )
256*cdf0e10cSrcweir {
257*cdf0e10cSrcweir }
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir //-----------------------------------------------------------------------------
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir AccessibleTableShape::~AccessibleTableShape (void)
262*cdf0e10cSrcweir {
263*cdf0e10cSrcweir }
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir //-----------------------------------------------------------------------------
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir void AccessibleTableShape::Init()
268*cdf0e10cSrcweir {
269*cdf0e10cSrcweir 	try
270*cdf0e10cSrcweir 	{
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir 		Reference< XPropertySet > xSet( mxShape, UNO_QUERY_THROW );
273*cdf0e10cSrcweir 		Reference< XTable > xTable( xSet->getPropertyValue(C2U("Model")), UNO_QUERY_THROW );
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir 		mxImpl->init( this, xTable );
276*cdf0e10cSrcweir 	}
277*cdf0e10cSrcweir 	catch( Exception& )
278*cdf0e10cSrcweir 	{
279*cdf0e10cSrcweir 		DBG_ERROR("AccessibleTableShape::init(), exception caught?");
280*cdf0e10cSrcweir 	}
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir 	AccessibleTableShape_Base::Init();
283*cdf0e10cSrcweir }
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir //-----------------------------------------------------------------------------
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir SvxTableController* AccessibleTableShape::getTableController()
288*cdf0e10cSrcweir {
289*cdf0e10cSrcweir 	SdrView* pView = maShapeTreeInfo.GetSdrView ();
290*cdf0e10cSrcweir 	if( pView )
291*cdf0e10cSrcweir 		return dynamic_cast< SvxTableController* >( pView->getSelectionController().get() );
292*cdf0e10cSrcweir 	else
293*cdf0e10cSrcweir 		return 0;
294*cdf0e10cSrcweir }
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir //-----------------------------------------------------------------------------
297*cdf0e10cSrcweir // XInterface
298*cdf0e10cSrcweir //-----------------------------------------------------------------------------
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir Any SAL_CALL AccessibleTableShape::queryInterface( const Type& aType ) throw (RuntimeException)
301*cdf0e10cSrcweir {
302*cdf0e10cSrcweir 	return AccessibleTableShape_Base::queryInterface( aType );
303*cdf0e10cSrcweir }
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir //-----------------------------------------------------------------------------
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::acquire(  ) throw ()
308*cdf0e10cSrcweir {
309*cdf0e10cSrcweir 	AccessibleTableShape_Base::acquire();
310*cdf0e10cSrcweir }
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir //-----------------------------------------------------------------------------
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::release(  ) throw ()
315*cdf0e10cSrcweir {
316*cdf0e10cSrcweir 	AccessibleTableShape_Base::release();
317*cdf0e10cSrcweir }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir //-----------------------------------------------------------------------------
320*cdf0e10cSrcweir // XAccessible
321*cdf0e10cSrcweir //-----------------------------------------------------------------------------
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL AccessibleTableShape::getAccessibleContext(void) throw (RuntimeException)
324*cdf0e10cSrcweir {
325*cdf0e10cSrcweir 	return AccessibleShape::getAccessibleContext ();
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir //-----------------------------------------------------------------------------
329*cdf0e10cSrcweir OUString SAL_CALL AccessibleTableShape::getImplementationName(void) throw (RuntimeException)
330*cdf0e10cSrcweir {
331*cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.accessibility.AccessibleTableShape" ) );
332*cdf0e10cSrcweir }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir //-----------------------------------------------------------------------------
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir OUString AccessibleTableShape::CreateAccessibleBaseName(void) throw (RuntimeException)
337*cdf0e10cSrcweir {
338*cdf0e10cSrcweir     return OUString (RTL_CONSTASCII_USTRINGPARAM("TableShape"));;
339*cdf0e10cSrcweir }
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir //--------------------------------------------------------------------
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleChildCount( ) throw(RuntimeException)
344*cdf0e10cSrcweir {
345*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard(::Application::GetSolarMutex());
346*cdf0e10cSrcweir 	return mxImpl->mxTable.is() ? mxImpl->mxTable->getRowCount() * mxImpl->mxTable->getColumnCount() : 0;
347*cdf0e10cSrcweir }
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir //--------------------------------------------------------------------
350*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleTableShape::getAccessibleChild( sal_Int32 i ) throw(IndexOutOfBoundsException, RuntimeException)
351*cdf0e10cSrcweir {
352*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
353*cdf0e10cSrcweir 	ThrowIfDisposed();
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir 	return mxImpl->getAccessibleChild( i );
356*cdf0e10cSrcweir }
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir //--------------------------------------------------------------------
359*cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL AccessibleTableShape::getAccessibleRelationSet(  ) throw (RuntimeException)
360*cdf0e10cSrcweir {
361*cdf0e10cSrcweir 	return AccessibleShape::getAccessibleRelationSet( );
362*cdf0e10cSrcweir }
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir //--------------------------------------------------------------------
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleTableShape::getAccessibleRole (void) throw (RuntimeException)
367*cdf0e10cSrcweir {
368*cdf0e10cSrcweir 	return AccessibleRole::TABLE;
369*cdf0e10cSrcweir }
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir //--------------------------------------------------------------------
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::disposing (void)
374*cdf0e10cSrcweir {
375*cdf0e10cSrcweir 	mxImpl->dispose();
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir 	// let the base do it's stuff
378*cdf0e10cSrcweir 	AccessibleShape::disposing();
379*cdf0e10cSrcweir }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir //--------------------------------------------------------------------
382*cdf0e10cSrcweir // XAccessibleTable
383*cdf0e10cSrcweir //--------------------------------------------------------------------
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleRowCount() throw (RuntimeException)
386*cdf0e10cSrcweir {
387*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
388*cdf0e10cSrcweir 	return mxImpl->mxTable.is() ? mxImpl->mxTable->getRowCount() : 0;
389*cdf0e10cSrcweir }
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir //--------------------------------------------------------------------
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleColumnCount(  ) throw (RuntimeException)
394*cdf0e10cSrcweir {
395*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
396*cdf0e10cSrcweir 	return mxImpl->mxTable.is() ? mxImpl->mxTable->getColumnCount() : 0;
397*cdf0e10cSrcweir }
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir //--------------------------------------------------------------------
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir OUString SAL_CALL AccessibleTableShape::getAccessibleRowDescription( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir 	checkCellPosition( 0, nRow );
404*cdf0e10cSrcweir 	return OUString();
405*cdf0e10cSrcweir }
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir //--------------------------------------------------------------------
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir OUString SAL_CALL AccessibleTableShape::getAccessibleColumnDescription( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
410*cdf0e10cSrcweir {
411*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
412*cdf0e10cSrcweir 	checkCellPosition( nColumn, 0 );
413*cdf0e10cSrcweir 	return OUString();
414*cdf0e10cSrcweir }
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir //--------------------------------------------------------------------
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
419*cdf0e10cSrcweir {
420*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
421*cdf0e10cSrcweir 	checkCellPosition( nColumn, nRow );
422*cdf0e10cSrcweir 	if( mxImpl->mxTable.is() )
423*cdf0e10cSrcweir 	{
424*cdf0e10cSrcweir 		Reference< XMergeableCell > xCell( mxImpl->mxTable->getCellByPosition( nColumn, nRow ), UNO_QUERY );
425*cdf0e10cSrcweir 		if( xCell.is() )
426*cdf0e10cSrcweir 			return xCell->getRowSpan();
427*cdf0e10cSrcweir 	}
428*cdf0e10cSrcweir 	return 1;
429*cdf0e10cSrcweir }
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir //--------------------------------------------------------------------
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
434*cdf0e10cSrcweir {
435*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
436*cdf0e10cSrcweir 	checkCellPosition( nColumn, nRow );
437*cdf0e10cSrcweir 	if( mxImpl->mxTable.is() )
438*cdf0e10cSrcweir 	{
439*cdf0e10cSrcweir 		Reference< XMergeableCell > xCell( mxImpl->mxTable->getCellByPosition( nColumn, nRow ), UNO_QUERY );
440*cdf0e10cSrcweir 		if( xCell.is() )
441*cdf0e10cSrcweir 			return xCell->getColumnSpan();
442*cdf0e10cSrcweir 	}
443*cdf0e10cSrcweir 	return 1;
444*cdf0e10cSrcweir }
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir //--------------------------------------------------------------------
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir Reference< XAccessibleTable > SAL_CALL AccessibleTableShape::getAccessibleRowHeaders(  ) throw (RuntimeException)
449*cdf0e10cSrcweir {
450*cdf0e10cSrcweir 	Reference< XAccessibleTable > xRet( this ); // todo
451*cdf0e10cSrcweir 	return xRet;
452*cdf0e10cSrcweir }
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir //--------------------------------------------------------------------
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir Reference< XAccessibleTable > SAL_CALL AccessibleTableShape::getAccessibleColumnHeaders(  ) throw (RuntimeException)
457*cdf0e10cSrcweir {
458*cdf0e10cSrcweir 	Reference< XAccessibleTable > xRet( this ); // todo
459*cdf0e10cSrcweir 	return xRet;
460*cdf0e10cSrcweir }
461*cdf0e10cSrcweir 
462*cdf0e10cSrcweir //--------------------------------------------------------------------
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL AccessibleTableShape::getSelectedAccessibleRows(  ) throw (RuntimeException)
465*cdf0e10cSrcweir {
466*cdf0e10cSrcweir 	Sequence< sal_Int32 > aRet;
467*cdf0e10cSrcweir 	return aRet;
468*cdf0e10cSrcweir }
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir //--------------------------------------------------------------------
471*cdf0e10cSrcweir 
472*cdf0e10cSrcweir Sequence< sal_Int32 > SAL_CALL AccessibleTableShape::getSelectedAccessibleColumns(  ) throw (RuntimeException)
473*cdf0e10cSrcweir {
474*cdf0e10cSrcweir 	Sequence< sal_Int32 > aRet;
475*cdf0e10cSrcweir 	return aRet;
476*cdf0e10cSrcweir }
477*cdf0e10cSrcweir 
478*cdf0e10cSrcweir //--------------------------------------------------------------------
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleTableShape::isAccessibleRowSelected( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
481*cdf0e10cSrcweir {
482*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
483*cdf0e10cSrcweir 	checkCellPosition( 0, nRow );
484*cdf0e10cSrcweir 	return sal_False;
485*cdf0e10cSrcweir }
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir //--------------------------------------------------------------------
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleTableShape::isAccessibleColumnSelected( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
490*cdf0e10cSrcweir {
491*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
492*cdf0e10cSrcweir 	checkCellPosition( nColumn, 0 );
493*cdf0e10cSrcweir 	return sal_False;
494*cdf0e10cSrcweir }
495*cdf0e10cSrcweir 
496*cdf0e10cSrcweir //--------------------------------------------------------------------
497*cdf0e10cSrcweir 
498*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleTableShape::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
499*cdf0e10cSrcweir {
500*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
501*cdf0e10cSrcweir 	checkCellPosition( nColumn, nRow );
502*cdf0e10cSrcweir 
503*cdf0e10cSrcweir     sal_Int32 nChildIndex = 0;
504*cdf0e10cSrcweir 	if( mxImpl->mxTable.is() )
505*cdf0e10cSrcweir 		nChildIndex = mxImpl->mxTable->getColumnCount() * nRow + nColumn;
506*cdf0e10cSrcweir 
507*cdf0e10cSrcweir     return getAccessibleChild( nChildIndex );
508*cdf0e10cSrcweir }
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir //--------------------------------------------------------------------
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleTableShape::getAccessibleCaption(  ) throw (RuntimeException)
513*cdf0e10cSrcweir {
514*cdf0e10cSrcweir 	Reference< XAccessible > xRet;
515*cdf0e10cSrcweir 	return xRet;
516*cdf0e10cSrcweir }
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir //--------------------------------------------------------------------
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleTableShape::getAccessibleSummary(  ) throw (RuntimeException)
521*cdf0e10cSrcweir {
522*cdf0e10cSrcweir 	Reference< XAccessible > xRet;
523*cdf0e10cSrcweir 	return xRet;
524*cdf0e10cSrcweir }
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir //--------------------------------------------------------------------
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleTableShape::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
529*cdf0e10cSrcweir {
530*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
531*cdf0e10cSrcweir 	checkCellPosition( nColumn, nRow );
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
534*cdf0e10cSrcweir 	if( pController && pController->hasSelectedCells() )
535*cdf0e10cSrcweir 	{
536*cdf0e10cSrcweir 		CellPos aFirstPos, aLastPos;
537*cdf0e10cSrcweir 		pController->getSelectedCells( aFirstPos, aLastPos );
538*cdf0e10cSrcweir 		if( (aFirstPos.mnRow <= nRow) && (aFirstPos.mnCol <= nColumn) && (nRow <= aLastPos.mnRow) && (nColumn <= aLastPos.mnCol) )
539*cdf0e10cSrcweir 			return sal_True;
540*cdf0e10cSrcweir 	}
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir 	return sal_False;
543*cdf0e10cSrcweir }
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir //--------------------------------------------------------------------
546*cdf0e10cSrcweir 
547*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
548*cdf0e10cSrcweir {
549*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
550*cdf0e10cSrcweir 	checkCellPosition( nColumn, nRow );
551*cdf0e10cSrcweir 	return  mxImpl->mxTable.is() ? (nRow * mxImpl->mxTable->getColumnCount() + nColumn) : 0;
552*cdf0e10cSrcweir }
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir //--------------------------------------------------------------------
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleRow( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
557*cdf0e10cSrcweir {
558*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
559*cdf0e10cSrcweir 	sal_Int32 nColumn = 0, nRow = 0;
560*cdf0e10cSrcweir 	mxImpl->getColumnAndRow( nChildIndex, nColumn, nRow );
561*cdf0e10cSrcweir 	return nRow;
562*cdf0e10cSrcweir }
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir //--------------------------------------------------------------------
565*cdf0e10cSrcweir 
566*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getAccessibleColumn( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
567*cdf0e10cSrcweir {
568*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
569*cdf0e10cSrcweir 	sal_Int32 nColumn = 0, nRow = 0;
570*cdf0e10cSrcweir 	mxImpl->getColumnAndRow( nChildIndex, nColumn, nRow );
571*cdf0e10cSrcweir 	return nChildIndex;
572*cdf0e10cSrcweir }
573*cdf0e10cSrcweir 
574*cdf0e10cSrcweir //--------------------------------------------------------------------
575*cdf0e10cSrcweir // XAccessibleSelection
576*cdf0e10cSrcweir //--------------------------------------------------------------------
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::selectAccessibleChild( sal_Int32 nChildIndex ) throw ( IndexOutOfBoundsException, RuntimeException )
579*cdf0e10cSrcweir {
580*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
581*cdf0e10cSrcweir 	CellPos aPos;
582*cdf0e10cSrcweir 	mxImpl->getColumnAndRow( nChildIndex, aPos.mnCol, aPos.mnRow );
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir 	// todo, select table shape?!?
585*cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
586*cdf0e10cSrcweir 	if( pController )
587*cdf0e10cSrcweir 	{
588*cdf0e10cSrcweir 		CellPos aFirstPos( aPos ), aLastPos( aPos );
589*cdf0e10cSrcweir 		if( pController->hasSelectedCells() )
590*cdf0e10cSrcweir 		{
591*cdf0e10cSrcweir 			pController->getSelectedCells( aFirstPos, aLastPos );
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir 			aFirstPos.mnRow = std::min( aFirstPos.mnRow, aPos.mnRow );
594*cdf0e10cSrcweir 			aFirstPos.mnCol = std::min( aFirstPos.mnCol, aPos.mnCol );
595*cdf0e10cSrcweir 			aLastPos.mnRow = std::max( aLastPos.mnRow, aPos.mnRow );
596*cdf0e10cSrcweir 			aLastPos.mnCol = std::max( aLastPos.mnCol, aPos.mnCol );
597*cdf0e10cSrcweir 		}
598*cdf0e10cSrcweir 		pController->setSelectedCells( aFirstPos, aLastPos );
599*cdf0e10cSrcweir 	}
600*cdf0e10cSrcweir }
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir //--------------------------------------------------------------------
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleTableShape::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw ( IndexOutOfBoundsException, RuntimeException )
605*cdf0e10cSrcweir {
606*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
607*cdf0e10cSrcweir 	CellPos aPos;
608*cdf0e10cSrcweir 	mxImpl->getColumnAndRow( nChildIndex, aPos.mnCol, aPos.mnRow );
609*cdf0e10cSrcweir 
610*cdf0e10cSrcweir 	return isAccessibleSelected(aPos.mnCol, aPos.mnRow);
611*cdf0e10cSrcweir }
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir //--------------------------------------------------------------------
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::clearAccessibleSelection() throw ( RuntimeException )
616*cdf0e10cSrcweir {
617*cdf0e10cSrcweir    ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
620*cdf0e10cSrcweir 	if( pController )
621*cdf0e10cSrcweir 		pController->clearSelection();
622*cdf0e10cSrcweir }
623*cdf0e10cSrcweir //--------------------------------------------------------------------
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::selectAllAccessibleChildren() throw ( RuntimeException )
626*cdf0e10cSrcweir {
627*cdf0e10cSrcweir    ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir    // todo: force selection of shape?
630*cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
631*cdf0e10cSrcweir 	if( pController )
632*cdf0e10cSrcweir 		pController->selectAll();
633*cdf0e10cSrcweir }
634*cdf0e10cSrcweir 
635*cdf0e10cSrcweir //--------------------------------------------------------------------
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleTableShape::getSelectedAccessibleChildCount() throw ( RuntimeException )
638*cdf0e10cSrcweir {
639*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
642*cdf0e10cSrcweir 	if( pController && pController->hasSelectedCells() )
643*cdf0e10cSrcweir 	{
644*cdf0e10cSrcweir 		CellPos aFirstPos, aLastPos;
645*cdf0e10cSrcweir 		pController->getSelectedCells( aFirstPos, aLastPos );
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir 		const sal_Int32 nSelectedColumns = std::max( (sal_Int32)0, aLastPos.mnCol - aFirstPos.mnCol ) + 1;
648*cdf0e10cSrcweir 		const sal_Int32 nSelectedRows = std::max( (sal_Int32)0, aLastPos.mnRow - aFirstPos.mnRow ) + 1;
649*cdf0e10cSrcweir 		return nSelectedRows * nSelectedColumns;
650*cdf0e10cSrcweir 	}
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir 	return 0;
653*cdf0e10cSrcweir }
654*cdf0e10cSrcweir 
655*cdf0e10cSrcweir //--------------------------------------------------------------------
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleTableShape::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw ( IndexOutOfBoundsException, RuntimeException)
658*cdf0e10cSrcweir {
659*cdf0e10cSrcweir     ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
662*cdf0e10cSrcweir 	if( pController && pController->hasSelectedCells() )
663*cdf0e10cSrcweir 	{
664*cdf0e10cSrcweir 		CellPos aFirstPos, aLastPos;
665*cdf0e10cSrcweir 		pController->getSelectedCells( aFirstPos, aLastPos );
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir 		const sal_Int32 nSelectedColumns = std::max( (sal_Int32)0, aLastPos.mnCol - aFirstPos.mnCol ) + 1;
668*cdf0e10cSrcweir 		const sal_Int32 nSelectedRows = std::max( (sal_Int32)0, aLastPos.mnRow - aFirstPos.mnRow ) + 1;
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir 		if( nSelectedChildIndex < (nSelectedRows * nSelectedColumns) )
671*cdf0e10cSrcweir 		{
672*cdf0e10cSrcweir 			while( nSelectedChildIndex >= nSelectedColumns )
673*cdf0e10cSrcweir 			{
674*cdf0e10cSrcweir 				aFirstPos.mnRow++;
675*cdf0e10cSrcweir 				nSelectedChildIndex -= nSelectedColumns;
676*cdf0e10cSrcweir 			}
677*cdf0e10cSrcweir 			return getAccessibleCellAt( nSelectedColumns, aFirstPos.mnRow );
678*cdf0e10cSrcweir 		}
679*cdf0e10cSrcweir 	}
680*cdf0e10cSrcweir 
681*cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
682*cdf0e10cSrcweir }
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir //--------------------------------------------------------------------
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir void SAL_CALL AccessibleTableShape::deselectAccessibleChild( sal_Int32 nChildIndex )  throw ( IndexOutOfBoundsException, RuntimeException )
687*cdf0e10cSrcweir {
688*cdf0e10cSrcweir    ::vos::OGuard aSolarGuard (::Application::GetSolarMutex());
689*cdf0e10cSrcweir 	CellPos aPos;
690*cdf0e10cSrcweir 	mxImpl->getColumnAndRow( nChildIndex, aPos.mnCol, aPos.mnRow );
691*cdf0e10cSrcweir 
692*cdf0e10cSrcweir 	// todo, select table shape?!?
693*cdf0e10cSrcweir 	SvxTableController* pController = getTableController();
694*cdf0e10cSrcweir 	if( pController && pController->hasSelectedCells() )
695*cdf0e10cSrcweir 	{
696*cdf0e10cSrcweir 		CellPos aFirstPos, aLastPos;
697*cdf0e10cSrcweir 		pController->getSelectedCells( aFirstPos, aLastPos );
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir 		// create a selection where aPos is not part of anymore
700*cdf0e10cSrcweir 		aFirstPos.mnRow = std::min( aFirstPos.mnRow, aPos.mnRow+1 );
701*cdf0e10cSrcweir 		aFirstPos.mnCol = std::min( aFirstPos.mnCol, aPos.mnCol+1 );
702*cdf0e10cSrcweir 		aLastPos.mnRow = std::max( aLastPos.mnRow, aPos.mnRow-1 );
703*cdf0e10cSrcweir 		aLastPos.mnCol = std::max( aLastPos.mnCol, aPos.mnCol-1 );
704*cdf0e10cSrcweir 
705*cdf0e10cSrcweir 		// new selection may be invalid (child to deselect is not at a border of the selection but in between)
706*cdf0e10cSrcweir 		if( (aFirstPos.mnRow > aLastPos.mnRow) || (aFirstPos.mnCol > aLastPos.mnCol) )
707*cdf0e10cSrcweir 			pController->clearSelection(); // if selection is invalid, clear all
708*cdf0e10cSrcweir 		else
709*cdf0e10cSrcweir 			pController->setSelectedCells( aFirstPos, aLastPos );
710*cdf0e10cSrcweir 	}
711*cdf0e10cSrcweir }
712*cdf0e10cSrcweir 
713*cdf0e10cSrcweir //--------------------------------------------------------------------
714*cdf0e10cSrcweir 
715*cdf0e10cSrcweir void AccessibleTableShape::checkCellPosition( sal_Int32 nCol, sal_Int32 nRow ) throw ( IndexOutOfBoundsException )
716*cdf0e10cSrcweir {
717*cdf0e10cSrcweir 	if( (nCol >= 0) && (nRow >= 0) && mxImpl->mxTable.is() && (nCol < mxImpl->mxTable->getColumnCount()) && (nRow < mxImpl->mxTable->getRowCount()) )
718*cdf0e10cSrcweir 		return;
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
721*cdf0e10cSrcweir }
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir }
724