xref: /AOO41X/main/accessibility/source/extended/AccessibleGridControl.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_accessibility.hxx"
30*cdf0e10cSrcweir #include "accessibility/extended/AccessibleGridControl.hxx"
31*cdf0e10cSrcweir #include "accessibility/extended/AccessibleGridControlTable.hxx"
32*cdf0e10cSrcweir #include "accessibility/extended/AccessibleGridControlHeader.hxx"
33*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
36*cdf0e10cSrcweir #include <svtools/accessibletable.hxx>
37*cdf0e10cSrcweir #include <comphelper/types.hxx>
38*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir // ============================================================================
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir namespace accessibility
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir // ============================================================================
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir using ::rtl::OUString;
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
50*cdf0e10cSrcweir using namespace ::com::sun::star;
51*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
52*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
53*cdf0e10cSrcweir using namespace ::svt;
54*cdf0e10cSrcweir using namespace ::svt::table;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir // ============================================================================
57*cdf0e10cSrcweir class AccessibleGridControl_Impl
58*cdf0e10cSrcweir {
59*cdf0e10cSrcweir public:
60*cdf0e10cSrcweir     /// the XAccessible which created the AccessibleGridControl
61*cdf0e10cSrcweir     WeakReference< XAccessible >                                m_aCreator;
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir 	/** The data table child. */
64*cdf0e10cSrcweir     Reference<
65*cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible >          m_xTable;
66*cdf0e10cSrcweir 	AccessibleGridControlTable*				m_pTable;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     /** The header bar for rows. */
69*cdf0e10cSrcweir     Reference<
70*cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible >	        m_xRowHeaderBar;
71*cdf0e10cSrcweir 	AccessibleGridControlHeader*				m_pRowHeaderBar;
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir     /** The header bar for columns (first row of the table). */
74*cdf0e10cSrcweir     Reference<
75*cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible >	        m_xColumnHeaderBar;
76*cdf0e10cSrcweir 	AccessibleGridControlHeader*				m_pColumnHeaderBar;
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 	/** The table cell child. */
79*cdf0e10cSrcweir     Reference<
80*cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible >          m_xCell;
81*cdf0e10cSrcweir 	AccessibleGridControlTableCell*				m_pCell;
82*cdf0e10cSrcweir };
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir DBG_NAME( AccessibleGridControl )
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir AccessibleGridControl::AccessibleGridControl(
87*cdf0e10cSrcweir             const Reference< XAccessible >& _rxParent, const Reference< XAccessible >& _rxCreator,
88*cdf0e10cSrcweir             IAccessibleTable& _rTable )
89*cdf0e10cSrcweir     : AccessibleGridControlBase( _rxParent, _rTable, TCTYPE_GRIDCONTROL )
90*cdf0e10cSrcweir {
91*cdf0e10cSrcweir 	m_pImpl.reset( new AccessibleGridControl_Impl() );
92*cdf0e10cSrcweir 	m_pImpl->m_aCreator = _rxCreator;
93*cdf0e10cSrcweir }
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir // -----------------------------------------------------------------------------
96*cdf0e10cSrcweir AccessibleGridControl::~AccessibleGridControl()
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir // -----------------------------------------------------------------------------
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir void SAL_CALL AccessibleGridControl::disposing()
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getOslMutex() );
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	m_pImpl->m_pTable		= NULL;
106*cdf0e10cSrcweir 	m_pImpl->m_pColumnHeaderBar	= NULL;
107*cdf0e10cSrcweir 	m_pImpl->m_pRowHeaderBar	= NULL;
108*cdf0e10cSrcweir 	m_pImpl->m_pCell			= NULL;
109*cdf0e10cSrcweir 	m_pImpl->m_aCreator         = Reference< XAccessible >();
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	Reference< XAccessible >  xTable = m_pImpl->m_xTable;
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	Reference< XComponent > xComp( m_pImpl->m_xTable, UNO_QUERY );
114*cdf0e10cSrcweir 	if ( xComp.is() )
115*cdf0e10cSrcweir 	{
116*cdf0e10cSrcweir 		xComp->dispose();
117*cdf0e10cSrcweir 	}
118*cdf0e10cSrcweir 	Reference< XAccessible >  xCell = m_pImpl->m_xCell;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	Reference< XComponent > xCellComp( m_pImpl->m_xCell, UNO_QUERY );
121*cdf0e10cSrcweir 	if ( xCellComp.is() )
122*cdf0e10cSrcweir 	{
123*cdf0e10cSrcweir 		xCellComp->dispose();
124*cdf0e10cSrcweir 	}
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir 	::comphelper::disposeComponent(m_pImpl->m_xRowHeaderBar);
127*cdf0e10cSrcweir     ::comphelper::disposeComponent(m_pImpl->m_xColumnHeaderBar);
128*cdf0e10cSrcweir 	AccessibleGridControlBase::disposing();
129*cdf0e10cSrcweir }
130*cdf0e10cSrcweir // -----------------------------------------------------------------------------
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir // XAccessibleContext ---------------------------------------------------------
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGridControl::getAccessibleChildCount()
135*cdf0e10cSrcweir     throw ( uno::RuntimeException )
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir 	TCSolarGuard aSolarGuard;
138*cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getOslMutex() );
139*cdf0e10cSrcweir 	ensureIsAlive();
140*cdf0e10cSrcweir 	return m_aTable.GetAccessibleControlCount();
141*cdf0e10cSrcweir }
142*cdf0e10cSrcweir // -----------------------------------------------------------------------------
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL
145*cdf0e10cSrcweir AccessibleGridControl::getAccessibleChild( sal_Int32 nChildIndex )
146*cdf0e10cSrcweir     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
147*cdf0e10cSrcweir {
148*cdf0e10cSrcweir 	TCSolarGuard aSolarGuard;
149*cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getOslMutex() );
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 	if (nChildIndex<0 || nChildIndex>=getAccessibleChildCount())
152*cdf0e10cSrcweir 		throw IndexOutOfBoundsException();
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	Reference< XAccessible > xChild;
155*cdf0e10cSrcweir 	if (isAlive())
156*cdf0e10cSrcweir 	{
157*cdf0e10cSrcweir 		if(nChildIndex == 0 && m_aTable.HasColHeader())
158*cdf0e10cSrcweir 		{
159*cdf0e10cSrcweir 			if(!m_pImpl->m_xColumnHeaderBar.is())
160*cdf0e10cSrcweir 			{
161*cdf0e10cSrcweir 				AccessibleGridControlHeader* pColHeaderBar = new AccessibleGridControlHeader(m_pImpl->m_aCreator, m_aTable, svt::table::TCTYPE_COLUMNHEADERBAR);
162*cdf0e10cSrcweir 				m_pImpl->m_xColumnHeaderBar = pColHeaderBar;
163*cdf0e10cSrcweir 			}
164*cdf0e10cSrcweir 			xChild = m_pImpl->m_xColumnHeaderBar;
165*cdf0e10cSrcweir 		}
166*cdf0e10cSrcweir 		else if(m_aTable.HasRowHeader() && (nChildIndex == 1 || nChildIndex == 0))
167*cdf0e10cSrcweir 		{
168*cdf0e10cSrcweir 			if(!m_pImpl->m_xRowHeaderBar.is())
169*cdf0e10cSrcweir 			{
170*cdf0e10cSrcweir 				AccessibleGridControlHeader* pRowHeaderBar = new AccessibleGridControlHeader(m_pImpl->m_aCreator, m_aTable, svt::table::TCTYPE_ROWHEADERBAR);
171*cdf0e10cSrcweir 				m_pImpl->m_xRowHeaderBar = pRowHeaderBar;
172*cdf0e10cSrcweir 			}
173*cdf0e10cSrcweir 			xChild = m_pImpl->m_xRowHeaderBar;
174*cdf0e10cSrcweir 		}
175*cdf0e10cSrcweir 		else
176*cdf0e10cSrcweir 		{
177*cdf0e10cSrcweir 			if(!m_pImpl->m_xTable.is())
178*cdf0e10cSrcweir 			{
179*cdf0e10cSrcweir 			AccessibleGridControlTable* pTable = new AccessibleGridControlTable(m_pImpl->m_aCreator, m_aTable, svt::table::TCTYPE_TABLE);
180*cdf0e10cSrcweir 			m_pImpl->m_xTable = pTable;
181*cdf0e10cSrcweir 				m_pImpl->m_pTable = pTable;
182*cdf0e10cSrcweir 			}
183*cdf0e10cSrcweir 			xChild = m_pImpl->m_xTable;
184*cdf0e10cSrcweir 		}
185*cdf0e10cSrcweir 	}
186*cdf0e10cSrcweir 	return xChild;
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir // -----------------------------------------------------------------------------
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleGridControl::getAccessibleRole()
191*cdf0e10cSrcweir     throw ( uno::RuntimeException )
192*cdf0e10cSrcweir {
193*cdf0e10cSrcweir 	ensureIsAlive();
194*cdf0e10cSrcweir 	return AccessibleRole::PANEL;
195*cdf0e10cSrcweir }
196*cdf0e10cSrcweir // -----------------------------------------------------------------------------
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir // XAccessibleComponent -------------------------------------------------------
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL
201*cdf0e10cSrcweir AccessibleGridControl::getAccessibleAtPoint( const awt::Point& rPoint )
202*cdf0e10cSrcweir     throw ( uno::RuntimeException )
203*cdf0e10cSrcweir {
204*cdf0e10cSrcweir 	TCSolarGuard aSolarGuard;
205*cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getOslMutex() );
206*cdf0e10cSrcweir 	ensureIsAlive();
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir 	Reference< XAccessible > xChild;
209*cdf0e10cSrcweir 	sal_Int32 nIndex = 0;
210*cdf0e10cSrcweir 	if( m_aTable.ConvertPointToControlIndex( nIndex, VCLPoint( rPoint ) ) )
211*cdf0e10cSrcweir 		xChild = m_aTable.CreateAccessibleControl( nIndex );
212*cdf0e10cSrcweir 	else
213*cdf0e10cSrcweir 	{
214*cdf0e10cSrcweir 		// try whether point is in one of the fixed children
215*cdf0e10cSrcweir 		// (table, header bars, corner control)
216*cdf0e10cSrcweir 		Point aPoint( VCLPoint( rPoint ) );
217*cdf0e10cSrcweir 		for( nIndex = 0; (nIndex < 3) && !xChild.is(); ++nIndex )
218*cdf0e10cSrcweir 		{
219*cdf0e10cSrcweir 			Reference< XAccessible > xCurrChild( implGetFixedChild( nIndex ) );
220*cdf0e10cSrcweir 			Reference< XAccessibleComponent >
221*cdf0e10cSrcweir 			xCurrChildComp( xCurrChild, uno::UNO_QUERY );
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 			if( xCurrChildComp.is() &&
224*cdf0e10cSrcweir 				VCLRectangle( xCurrChildComp->getBounds() ).IsInside( aPoint ) )
225*cdf0e10cSrcweir 			xChild = xCurrChild;
226*cdf0e10cSrcweir 		}
227*cdf0e10cSrcweir 	}
228*cdf0e10cSrcweir 	return xChild;
229*cdf0e10cSrcweir }
230*cdf0e10cSrcweir // -----------------------------------------------------------------------------
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir void SAL_CALL AccessibleGridControl::grabFocus()
233*cdf0e10cSrcweir     throw ( uno::RuntimeException )
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir 	TCSolarGuard aSolarGuard;
236*cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getOslMutex() );
237*cdf0e10cSrcweir 	ensureIsAlive();
238*cdf0e10cSrcweir     	m_aTable.GrabFocus();
239*cdf0e10cSrcweir }
240*cdf0e10cSrcweir // -----------------------------------------------------------------------------
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir Any SAL_CALL AccessibleGridControl::getAccessibleKeyBinding()
243*cdf0e10cSrcweir     throw ( uno::RuntimeException )
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir 	ensureIsAlive();
246*cdf0e10cSrcweir 	return Any();
247*cdf0e10cSrcweir }
248*cdf0e10cSrcweir // -----------------------------------------------------------------------------
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir // XServiceInfo ---------------------------------------------------------------
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir OUString SAL_CALL AccessibleGridControl::getImplementationName()
253*cdf0e10cSrcweir     throw ( uno::RuntimeException )
254*cdf0e10cSrcweir {
255*cdf0e10cSrcweir 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControl" ) );
256*cdf0e10cSrcweir }
257*cdf0e10cSrcweir // -----------------------------------------------------------------------------
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir // internal virtual methods ---------------------------------------------------
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir Rectangle AccessibleGridControl::implGetBoundingBox()
262*cdf0e10cSrcweir {
263*cdf0e10cSrcweir 	Window* pParent = m_aTable.GetAccessibleParentWindow();
264*cdf0e10cSrcweir 	DBG_ASSERT( pParent, "implGetBoundingBox - missing parent window" );
265*cdf0e10cSrcweir 	return m_aTable.GetWindowExtentsRelative( pParent );
266*cdf0e10cSrcweir }
267*cdf0e10cSrcweir // -----------------------------------------------------------------------------
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir Rectangle AccessibleGridControl::implGetBoundingBoxOnScreen()
270*cdf0e10cSrcweir {
271*cdf0e10cSrcweir 	return m_aTable.GetWindowExtentsRelative( NULL );
272*cdf0e10cSrcweir }
273*cdf0e10cSrcweir // internal helper methods ----------------------------------------------------
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir Reference< XAccessible > AccessibleGridControl::implGetTable()
276*cdf0e10cSrcweir {
277*cdf0e10cSrcweir 	if( !m_pImpl->m_xTable.is() )
278*cdf0e10cSrcweir 	{
279*cdf0e10cSrcweir 		m_pImpl->m_pTable = createAccessibleTable();
280*cdf0e10cSrcweir 		m_pImpl->m_xTable  = m_pImpl->m_pTable;
281*cdf0e10cSrcweir 	}
282*cdf0e10cSrcweir 	return m_pImpl->m_xTable;
283*cdf0e10cSrcweir }
284*cdf0e10cSrcweir // -----------------------------------------------------------------------------
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir Reference< XAccessible >
287*cdf0e10cSrcweir AccessibleGridControl::implGetHeaderBar( AccessibleTableControlObjType eObjType )
288*cdf0e10cSrcweir {
289*cdf0e10cSrcweir 	Reference< XAccessible > xRet;
290*cdf0e10cSrcweir 	Reference< XAccessible >* pxMember = NULL;
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir 	if( eObjType == TCTYPE_ROWHEADERBAR )
293*cdf0e10cSrcweir 		pxMember = &m_pImpl->m_xRowHeaderBar;
294*cdf0e10cSrcweir 	else if( eObjType ==  TCTYPE_COLUMNHEADERBAR )
295*cdf0e10cSrcweir 		pxMember = &m_pImpl->m_xColumnHeaderBar;
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir 	if( pxMember )
298*cdf0e10cSrcweir 	{
299*cdf0e10cSrcweir 		if( !pxMember->is() )
300*cdf0e10cSrcweir 		{
301*cdf0e10cSrcweir 			AccessibleGridControlHeader* pHeaderBar = new AccessibleGridControlHeader(
302*cdf0e10cSrcweir 				(Reference< XAccessible >)m_pImpl->m_aCreator, m_aTable, eObjType );
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir 			if ( TCTYPE_COLUMNHEADERBAR == eObjType)
305*cdf0e10cSrcweir 				m_pImpl->m_pColumnHeaderBar = pHeaderBar;
306*cdf0e10cSrcweir 			else
307*cdf0e10cSrcweir 				m_pImpl->m_pRowHeaderBar	= pHeaderBar;
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir 			*pxMember = pHeaderBar;
310*cdf0e10cSrcweir 		}
311*cdf0e10cSrcweir 		xRet = *pxMember;
312*cdf0e10cSrcweir 	}
313*cdf0e10cSrcweir 	return xRet;
314*cdf0e10cSrcweir }
315*cdf0e10cSrcweir // -----------------------------------------------------------------------------
316*cdf0e10cSrcweir Reference< XAccessible >
317*cdf0e10cSrcweir AccessibleGridControl::implGetFixedChild( sal_Int32 nChildIndex )
318*cdf0e10cSrcweir {
319*cdf0e10cSrcweir 	Reference< XAccessible > xRet;
320*cdf0e10cSrcweir 	switch( nChildIndex )
321*cdf0e10cSrcweir 	{
322*cdf0e10cSrcweir       	case TCINDEX_COLUMNHEADERBAR:
323*cdf0e10cSrcweir             xRet = implGetHeaderBar( TCTYPE_COLUMNHEADERBAR );
324*cdf0e10cSrcweir 	    break;
325*cdf0e10cSrcweir         case TCINDEX_ROWHEADERBAR:
326*cdf0e10cSrcweir             xRet = implGetHeaderBar( TCTYPE_ROWHEADERBAR );
327*cdf0e10cSrcweir 	    break;
328*cdf0e10cSrcweir         case TCINDEX_TABLE:
329*cdf0e10cSrcweir             xRet = implGetTable();
330*cdf0e10cSrcweir 	    break;
331*cdf0e10cSrcweir 	}
332*cdf0e10cSrcweir 	return xRet;
333*cdf0e10cSrcweir }
334*cdf0e10cSrcweir // -----------------------------------------------------------------------------
335*cdf0e10cSrcweir AccessibleGridControlTable* AccessibleGridControl::createAccessibleTable()
336*cdf0e10cSrcweir {
337*cdf0e10cSrcweir 	Reference< XAccessible > xCreator = (Reference< XAccessible >)m_pImpl->m_aCreator;
338*cdf0e10cSrcweir     	DBG_ASSERT( xCreator.is(), "accessibility/extended/AccessibleGirdControl::createAccessibleTable: my creator died - how this?" );
339*cdf0e10cSrcweir 	return new AccessibleGridControlTable( xCreator, m_aTable, TCTYPE_TABLE );
340*cdf0e10cSrcweir }
341*cdf0e10cSrcweir // -----------------------------------------------------------------------------
342*cdf0e10cSrcweir void AccessibleGridControl::commitCellEvent(sal_Int16 _nEventId,const Any& _rNewValue,const Any& _rOldValue)
343*cdf0e10cSrcweir {
344*cdf0e10cSrcweir 	sal_Int32 nChildCount = getAccessibleChildCount();
345*cdf0e10cSrcweir     if(nChildCount != 0)
346*cdf0e10cSrcweir 	{
347*cdf0e10cSrcweir 		for(sal_Int32 i=0;i<nChildCount;i++)
348*cdf0e10cSrcweir 		{
349*cdf0e10cSrcweir 			Reference< XAccessible > xAccessible = getAccessibleChild(i);
350*cdf0e10cSrcweir 			com::sun::star::uno::Reference< com::sun::star::accessibility::XAccessibleContext > xAccessibleChild = xAccessible->getAccessibleContext();
351*cdf0e10cSrcweir 			if(m_pImpl->m_xTable == xAccessible)
352*cdf0e10cSrcweir 			{
353*cdf0e10cSrcweir 				std::vector< AccessibleGridControlTableCell* > xCellCont = m_pImpl->m_pTable->getCellVector();
354*cdf0e10cSrcweir 				int nIndex = m_aTable.GetCurrentRow()*m_aTable.GetColumnCount()+m_aTable.GetCurrentColumn();
355*cdf0e10cSrcweir 				if(!xCellCont.empty() && xCellCont[nIndex])
356*cdf0e10cSrcweir 				{
357*cdf0e10cSrcweir 					m_pImpl->m_pCell = xCellCont[nIndex];
358*cdf0e10cSrcweir 					m_pImpl->m_pCell->commitEvent( _nEventId, _rNewValue, _rOldValue );
359*cdf0e10cSrcweir 				}
360*cdf0e10cSrcweir 			}
361*cdf0e10cSrcweir 		}
362*cdf0e10cSrcweir 	}
363*cdf0e10cSrcweir 	else
364*cdf0e10cSrcweir 	{
365*cdf0e10cSrcweir 		if ( m_pImpl->m_xTable.is() )
366*cdf0e10cSrcweir 			m_pImpl->m_pTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
367*cdf0e10cSrcweir 	}
368*cdf0e10cSrcweir }
369*cdf0e10cSrcweir void AccessibleGridControl::commitTableEvent(sal_Int16 _nEventId,const Any& _rNewValue,const Any& _rOldValue)
370*cdf0e10cSrcweir {
371*cdf0e10cSrcweir 	if ( m_pImpl->m_xTable.is() )
372*cdf0e10cSrcweir 	{
373*cdf0e10cSrcweir 		if(_nEventId == AccessibleEventId::ACTIVE_DESCENDANT_CHANGED)
374*cdf0e10cSrcweir 		{
375*cdf0e10cSrcweir 			Reference< XAccessible > xChild = m_pImpl->m_pTable->getAccessibleChild(m_aTable.GetCurrentRow()*m_aTable.GetColumnCount()+m_aTable.GetCurrentColumn());
376*cdf0e10cSrcweir 			m_pImpl->m_pTable->commitEvent(_nEventId, makeAny(xChild),_rOldValue);
377*cdf0e10cSrcweir 		}
378*cdf0e10cSrcweir 		else if(_nEventId == AccessibleEventId::TABLE_MODEL_CHANGED)
379*cdf0e10cSrcweir 		{
380*cdf0e10cSrcweir 			AccessibleTableModelChange aChange;
381*cdf0e10cSrcweir 			if(_rNewValue >>= aChange)
382*cdf0e10cSrcweir 			{
383*cdf0e10cSrcweir 				if(aChange.Type == AccessibleTableModelChangeType::DELETE)
384*cdf0e10cSrcweir 				{
385*cdf0e10cSrcweir 					std::vector< AccessibleGridControlTableCell* >::iterator m_pCell = m_pImpl->m_pTable->getCellVector().begin();
386*cdf0e10cSrcweir 					std::vector< Reference< XAccessible > >::iterator m_xAccessibleVector = m_pImpl->m_pTable->getAccessibleCellVector().begin();
387*cdf0e10cSrcweir 					int nColCount = m_aTable.GetColumnCount();
388*cdf0e10cSrcweir 					m_pImpl->m_pTable->getCellVector().erase(m_pCell+nColCount*aChange.FirstRow, m_pCell+nColCount*aChange.LastRow );
389*cdf0e10cSrcweir 					m_pImpl->m_pTable->getAccessibleCellVector().erase(m_xAccessibleVector+nColCount*aChange.FirstRow, m_xAccessibleVector+nColCount*aChange.LastRow);
390*cdf0e10cSrcweir 					m_pImpl->m_pTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
391*cdf0e10cSrcweir 				}
392*cdf0e10cSrcweir 				else
393*cdf0e10cSrcweir 					m_pImpl->m_pTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
394*cdf0e10cSrcweir 			}
395*cdf0e10cSrcweir 		}
396*cdf0e10cSrcweir 		else
397*cdf0e10cSrcweir 			m_pImpl->m_pTable->commitEvent(_nEventId,_rNewValue,_rOldValue);
398*cdf0e10cSrcweir 	}
399*cdf0e10cSrcweir }
400*cdf0e10cSrcweir // ============================================================================
401*cdf0e10cSrcweir // = AccessibleGridControlAccess
402*cdf0e10cSrcweir // ============================================================================
403*cdf0e10cSrcweir DBG_NAME( AccessibleGridControlAccess )
404*cdf0e10cSrcweir // -----------------------------------------------------------------------------
405*cdf0e10cSrcweir AccessibleGridControlAccess::AccessibleGridControlAccess( const Reference< XAccessible >& _rxParent, IAccessibleTable& _rTable )
406*cdf0e10cSrcweir         :m_xParent( _rxParent )
407*cdf0e10cSrcweir         ,m_rTable( _rTable )
408*cdf0e10cSrcweir         ,m_pContext( NULL )
409*cdf0e10cSrcweir {
410*cdf0e10cSrcweir }
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir // -----------------------------------------------------------------------------
413*cdf0e10cSrcweir AccessibleGridControlAccess::~AccessibleGridControlAccess()
414*cdf0e10cSrcweir {
415*cdf0e10cSrcweir }
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir // -----------------------------------------------------------------------------
418*cdf0e10cSrcweir void AccessibleGridControlAccess::dispose()
419*cdf0e10cSrcweir {
420*cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir 	m_pContext = NULL;
423*cdf0e10cSrcweir 	::comphelper::disposeComponent( m_xContext );
424*cdf0e10cSrcweir }
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir // -----------------------------------------------------------------------------
427*cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL AccessibleGridControlAccess::getAccessibleContext() throw ( RuntimeException )
428*cdf0e10cSrcweir {
429*cdf0e10cSrcweir 	::osl::MutexGuard aGuard( m_aMutex );
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir 	DBG_ASSERT( ( m_pContext && m_xContext.is() ) || ( !m_pContext && !m_xContext.is() ),
432*cdf0e10cSrcweir         "accessibility/extended/AccessibleGridControlAccess::getAccessibleContext: inconsistency!" );
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir 	// if the context died meanwhile (we're no listener, so it won't tell us explicitily when this happens),
435*cdf0e10cSrcweir 	// then reset an re-create.
436*cdf0e10cSrcweir 	if ( m_pContext && !m_pContext->isAlive() )
437*cdf0e10cSrcweir 		m_xContext = m_pContext = NULL;
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir 	if ( !m_xContext.is() )
440*cdf0e10cSrcweir 		m_xContext = m_pContext = new AccessibleGridControl( m_xParent, this, m_rTable );
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 	return m_xContext;
443*cdf0e10cSrcweir }
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir // -----------------------------------------------------------------------------
446*cdf0e10cSrcweir bool AccessibleGridControlAccess::isContextAlive() const
447*cdf0e10cSrcweir {
448*cdf0e10cSrcweir 	return  ( NULL != m_pContext ) && m_pContext->isAlive();
449*cdf0e10cSrcweir }
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir // ============================================================================
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir }   // namespace accessibility
454