10841af79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
30841af79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
40841af79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
50841af79SAndrew Rist  * distributed with this work for additional information
60841af79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
70841af79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
80841af79SAndrew Rist  * "License"); you may not use this file except in compliance
90841af79SAndrew Rist  * with the License.  You may obtain a copy of the License at
100841af79SAndrew Rist  *
110841af79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
120841af79SAndrew Rist  *
130841af79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
140841af79SAndrew Rist  * software distributed under the License is distributed on an
150841af79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
160841af79SAndrew Rist  * KIND, either express or implied.  See the License for the
170841af79SAndrew Rist  * specific language governing permissions and limitations
180841af79SAndrew Rist  * under the License.
190841af79SAndrew Rist  *
200841af79SAndrew Rist  *************************************************************/
210841af79SAndrew Rist 
220841af79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef ACCESSIBILITY_EXT_ACCESSIBLETABLISTBOXTABLE_HXX_
28cdf0e10cSrcweir #include "accessibility/extended/accessibletablistboxtable.hxx"
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include "accessibility/extended/AccessibleBrowseBoxTableCell.hxx"
31cdf0e10cSrcweir #include "accessibility/extended/AccessibleBrowseBoxCheckBoxCell.hxx"
32cdf0e10cSrcweir #include <svtools/svtabbx.hxx>
33cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
34cdf0e10cSrcweir 
3521075d77SSteve Yin #ifndef _SVTOOLS_ACCESSIBILEBROWSEBOXTABLECELL_HXX
3621075d77SSteve Yin #include "accessibility/extended/AccessibleBrowseBoxTableCell.hxx"
3721075d77SSteve Yin #endif
38cdf0e10cSrcweir //........................................................................
39cdf0e10cSrcweir namespace accessibility
40cdf0e10cSrcweir {
41cdf0e10cSrcweir //........................................................................
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 	// class TLBSolarGuard ---------------------------------------------------------
44cdf0e10cSrcweir 
45*07a3d7f1SPedro Giffuni 	/** Acquire the solar mutex. */
46cdf0e10cSrcweir 	class TLBSolarGuard : public ::vos::OGuard
47cdf0e10cSrcweir 	{
48cdf0e10cSrcweir 	public:
TLBSolarGuard()49cdf0e10cSrcweir     	inline TLBSolarGuard() : ::vos::OGuard( Application::GetSolarMutex() ) {}
50cdf0e10cSrcweir 	};
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 	// class AccessibleTabListBoxTable ---------------------------------------------
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	using namespace ::com::sun::star::accessibility;
55cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
56cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
57cdf0e10cSrcweir 	using namespace ::com::sun::star;
58cdf0e10cSrcweir 
DBG_NAME(AccessibleTabListBoxTable)59cdf0e10cSrcweir 	DBG_NAME(AccessibleTabListBoxTable)
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
62cdf0e10cSrcweir 	// Ctor() and Dtor()
63cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
64cdf0e10cSrcweir 	AccessibleTabListBoxTable::AccessibleTabListBoxTable( const Reference< XAccessible >& rxParent, SvHeaderTabListBox& rBox ) :
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 		AccessibleBrowseBoxTable( rxParent, rBox ),
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 		m_pTabListBox	( &rBox )
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	{
71cdf0e10cSrcweir 		DBG_CTOR( AccessibleTabListBoxTable, NULL );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 		m_pTabListBox->AddEventListener( LINK( this, AccessibleTabListBoxTable, WindowEventListener ) );
74cdf0e10cSrcweir 	}
75cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
~AccessibleTabListBoxTable()76cdf0e10cSrcweir 	AccessibleTabListBoxTable::~AccessibleTabListBoxTable()
77cdf0e10cSrcweir 	{
78cdf0e10cSrcweir 		DBG_DTOR( AccessibleTabListBoxTable, NULL );
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 		if ( isAlive() )
81cdf0e10cSrcweir 		{
82cdf0e10cSrcweir 			m_pTabListBox = NULL;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 			// increment ref count to prevent double call of Dtor
85cdf0e10cSrcweir         	osl_incrementInterlockedCount( &m_refCount );
86cdf0e10cSrcweir         	dispose();
87cdf0e10cSrcweir 		}
88cdf0e10cSrcweir 	}
89cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)90cdf0e10cSrcweir 	void AccessibleTabListBoxTable::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
91cdf0e10cSrcweir 	{
92cdf0e10cSrcweir     	if ( isAlive() )
93cdf0e10cSrcweir 		{
94cdf0e10cSrcweir             sal_uLong nEventId = rVclWindowEvent.GetId();
95cdf0e10cSrcweir             switch ( nEventId )
96cdf0e10cSrcweir             {
97cdf0e10cSrcweir 				case  VCLEVENT_OBJECT_DYING :
98cdf0e10cSrcweir 				{
99cdf0e10cSrcweir 					m_pTabListBox->RemoveEventListener( LINK( this, AccessibleTabListBoxTable, WindowEventListener ) );
100cdf0e10cSrcweir 					m_pTabListBox = NULL;
101cdf0e10cSrcweir 					break;
102cdf0e10cSrcweir 				}
103cdf0e10cSrcweir 
104cdf0e10cSrcweir                 case VCLEVENT_CONTROL_GETFOCUS :
105cdf0e10cSrcweir                 case VCLEVENT_CONTROL_LOSEFOCUS :
106cdf0e10cSrcweir                 {
107cdf0e10cSrcweir                     uno::Any aOldValue, aNewValue;
108cdf0e10cSrcweir                     if ( VCLEVENT_CONTROL_GETFOCUS == nEventId )
109cdf0e10cSrcweir                         aNewValue <<= AccessibleStateType::FOCUSED;
110cdf0e10cSrcweir                     else
111cdf0e10cSrcweir                         aOldValue <<= AccessibleStateType::FOCUSED;
112cdf0e10cSrcweir                     commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue );
113cdf0e10cSrcweir                     break;
114cdf0e10cSrcweir                 }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir                 case VCLEVENT_LISTBOX_SELECT :
117cdf0e10cSrcweir 				{
118cdf0e10cSrcweir                     // First send an event that tells the listeners of a
119cdf0e10cSrcweir                     // modified selection.  The active descendant event is
120cdf0e10cSrcweir                     // send after that so that the receiving AT has time to
121cdf0e10cSrcweir                     // read the text or name of the active child.
122cdf0e10cSrcweir 					commitEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
123cdf0e10cSrcweir 					if ( m_pTabListBox && m_pTabListBox->HasFocus() )
124cdf0e10cSrcweir 					{
125cdf0e10cSrcweir                         SvLBoxEntry* pEntry = static_cast< SvLBoxEntry* >( rVclWindowEvent.GetData() );
126cdf0e10cSrcweir 						if ( pEntry )
127cdf0e10cSrcweir 						{
128cdf0e10cSrcweir 							sal_Int32 nRow = m_pTabListBox->GetEntryPos( pEntry );
129cdf0e10cSrcweir                             sal_uInt16 nCol = m_pTabListBox->GetCurrColumn();
130cdf0e10cSrcweir                             Reference< XAccessible > xChild =
131cdf0e10cSrcweir                                 m_pTabListBox->CreateAccessibleCell( nRow, nCol );
132cdf0e10cSrcweir 							uno::Any aOldValue, aNewValue;
133cdf0e10cSrcweir 
134cdf0e10cSrcweir                             if ( m_pTabListBox->IsTransientChildrenDisabled() )
135cdf0e10cSrcweir                             {
136cdf0e10cSrcweir                                 aNewValue <<= AccessibleStateType::FOCUSED;
137cdf0e10cSrcweir                                 TriState eState = STATE_DONTKNOW;
138cdf0e10cSrcweir                                 if ( m_pTabListBox->IsCellCheckBox( nRow, nCol, eState ) )
139cdf0e10cSrcweir                                 {
140cdf0e10cSrcweir                                     AccessibleCheckBoxCell* pCell =
141cdf0e10cSrcweir                                         static_cast< AccessibleCheckBoxCell* >( xChild.get() );
142cdf0e10cSrcweir                                     pCell->commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue );
143cdf0e10cSrcweir                                 }
144cdf0e10cSrcweir                                 else
145cdf0e10cSrcweir                                 {
146cdf0e10cSrcweir                                     AccessibleBrowseBoxTableCell* pCell =
147cdf0e10cSrcweir                                         static_cast< AccessibleBrowseBoxTableCell* >( xChild.get() );
148cdf0e10cSrcweir                                     pCell->commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue );
149cdf0e10cSrcweir                                 }
150cdf0e10cSrcweir                             }
151cdf0e10cSrcweir                             else
152cdf0e10cSrcweir                             {
153cdf0e10cSrcweir                                 aNewValue <<= xChild;
154cdf0e10cSrcweir                                 commitEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aNewValue, aOldValue );
155cdf0e10cSrcweir                             }
156cdf0e10cSrcweir 						}
157cdf0e10cSrcweir 					}
158cdf0e10cSrcweir 					break;
159cdf0e10cSrcweir 				}
16021075d77SSteve Yin 				case VCLEVENT_WINDOW_GETFOCUS :
16121075d77SSteve Yin 				{
16221075d77SSteve Yin 					uno::Any aOldValue, aNewValue;
16321075d77SSteve Yin 					aNewValue <<= AccessibleStateType::FOCUSED;
16421075d77SSteve Yin 					commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue );
16521075d77SSteve Yin 					break;
16621075d77SSteve Yin 
16721075d77SSteve Yin 				}
16821075d77SSteve Yin 				case VCLEVENT_WINDOW_LOSEFOCUS :
16921075d77SSteve Yin 				{
17021075d77SSteve Yin 					uno::Any aOldValue, aNewValue;
17121075d77SSteve Yin 					aOldValue <<= AccessibleStateType::FOCUSED;
17221075d77SSteve Yin 					commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue, aOldValue );
17321075d77SSteve Yin 					break;
17421075d77SSteve Yin 				}
17521075d77SSteve Yin 				case VCLEVENT_LISTBOX_TREESELECT:
17621075d77SSteve Yin 					{
17721075d77SSteve Yin 						SvLBoxEntry* pEntry = static_cast< SvLBoxEntry* >( rVclWindowEvent.GetData() );
17821075d77SSteve Yin 						if (pEntry)
17921075d77SSteve Yin 						{
18021075d77SSteve Yin 							sal_Int32 nRow = m_pTabListBox->GetEntryPos( pEntry );
18121075d77SSteve Yin 							Reference< XAccessible > xChild = m_pTabListBox->CreateAccessibleCell( nRow, m_pTabListBox->GetCurrColumn() );
18221075d77SSteve Yin 							TriState eState = STATE_DONTKNOW;
18321075d77SSteve Yin 							if ( m_pTabListBox->IsCellCheckBox( nRow, m_pTabListBox->GetCurrColumn(), eState ) )
18421075d77SSteve Yin                             {
18521075d77SSteve Yin                                 AccessibleCheckBoxCell* pCell = static_cast< AccessibleCheckBoxCell* >( xChild.get() );
18621075d77SSteve Yin                                 pCell->commitEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
18721075d77SSteve Yin                             }
18821075d77SSteve Yin                             else
18921075d77SSteve Yin                             {
19021075d77SSteve Yin                                 AccessibleBrowseBoxTableCell* pCell = static_cast< AccessibleBrowseBoxTableCell* >( xChild.get() );
19121075d77SSteve Yin                                 pCell->commitEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
19221075d77SSteve Yin                             }
19321075d77SSteve Yin 						}
19421075d77SSteve Yin 					}
19521075d77SSteve Yin 					break;
19621075d77SSteve Yin 				case VCLEVENT_LISTBOX_TREEFOCUS:
19721075d77SSteve Yin 					{
19821075d77SSteve Yin 						if ( m_pTabListBox && m_pTabListBox->HasFocus() )
19921075d77SSteve Yin 						{
20021075d77SSteve Yin 							uno::Any aOldValue, aNewValue;
20121075d77SSteve Yin 							SvLBoxEntry* pEntry = static_cast< SvLBoxEntry* >( rVclWindowEvent.GetData() );
20221075d77SSteve Yin 							if ( pEntry )
20321075d77SSteve Yin 							{
20421075d77SSteve Yin 								sal_Int32 nRow = m_pTabListBox->GetEntryPos( pEntry );
20521075d77SSteve Yin 								m_xCurChild = m_pTabListBox->CreateAccessibleCell( nRow, m_pTabListBox->GetCurrColumn() );
20621075d77SSteve Yin 								aNewValue <<= m_xCurChild;
20721075d77SSteve Yin 								commitEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aNewValue ,aOldValue);
20821075d77SSteve Yin 							}
20921075d77SSteve Yin 							else
21021075d77SSteve Yin 							{
21121075d77SSteve Yin 								aNewValue <<= AccessibleStateType::FOCUSED;
21221075d77SSteve Yin 								commitEvent( AccessibleEventId::STATE_CHANGED, aNewValue ,aOldValue);
21321075d77SSteve Yin 							}
21421075d77SSteve Yin 						}
21521075d77SSteve Yin 					}
21621075d77SSteve Yin 					break;
217cdf0e10cSrcweir 
218cdf0e10cSrcweir                 case VCLEVENT_CHECKBOX_TOGGLE :
219cdf0e10cSrcweir                 {
220cdf0e10cSrcweir                     if ( m_pTabListBox && m_pTabListBox->HasFocus() )
221cdf0e10cSrcweir                     {
222cdf0e10cSrcweir                         SvLBoxEntry* pEntry = static_cast< SvLBoxEntry* >( rVclWindowEvent.GetData() );
223cdf0e10cSrcweir                         if ( pEntry )
224cdf0e10cSrcweir                         {
225cdf0e10cSrcweir                             sal_Int32 nRow = m_pTabListBox->GetEntryPos( pEntry );
226cdf0e10cSrcweir                             sal_uInt16 nCol = m_pTabListBox->GetCurrColumn();
227cdf0e10cSrcweir                             TriState eState = STATE_DONTKNOW;
228cdf0e10cSrcweir                             if ( m_pTabListBox->IsCellCheckBox( nRow, nCol, eState ) )
229cdf0e10cSrcweir                             {
230cdf0e10cSrcweir                                 Reference< XAccessible > xChild =
231cdf0e10cSrcweir                                     m_pTabListBox->CreateAccessibleCell( nRow, nCol );
232cdf0e10cSrcweir                                 AccessibleCheckBoxCell* pCell =
233cdf0e10cSrcweir                                     static_cast< AccessibleCheckBoxCell* >( xChild.get() );
234cdf0e10cSrcweir                                 pCell->SetChecked( m_pTabListBox->IsItemChecked( pEntry, nCol ) );
235cdf0e10cSrcweir                             }
236cdf0e10cSrcweir                         }
237cdf0e10cSrcweir                     }
238cdf0e10cSrcweir                     break;
239cdf0e10cSrcweir                 }
240cdf0e10cSrcweir 
241cdf0e10cSrcweir                 case VCLEVENT_TABLECELL_NAMECHANGED :
242cdf0e10cSrcweir                 {
243cdf0e10cSrcweir                     if ( m_pTabListBox->IsTransientChildrenDisabled() )
244cdf0e10cSrcweir                     {
245cdf0e10cSrcweir                         commitEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
246cdf0e10cSrcweir                         TabListBoxEventData* pData = static_cast< TabListBoxEventData* >( rVclWindowEvent.GetData() );
247cdf0e10cSrcweir                         SvLBoxEntry* pEntry = pData != NULL ? pData->m_pEntry : NULL;
248cdf0e10cSrcweir                         if ( pEntry )
249cdf0e10cSrcweir                         {
250cdf0e10cSrcweir                             sal_Int32 nRow = m_pTabListBox->GetEntryPos( pEntry );
251cdf0e10cSrcweir                             sal_uInt16 nCol = pData->m_nColumn;
252cdf0e10cSrcweir                             Reference< XAccessible > xChild =
253cdf0e10cSrcweir                                 m_pTabListBox->CreateAccessibleCell( nRow, nCol );
254cdf0e10cSrcweir                             uno::Any aOldValue, aNewValue;
255cdf0e10cSrcweir                             aOldValue <<= ::rtl::OUString( pData->m_sOldText );
256cdf0e10cSrcweir                             ::rtl::OUString sNewText( m_pTabListBox->GetCellText( nRow, nCol ) );
257cdf0e10cSrcweir                             aNewValue <<= sNewText;
258cdf0e10cSrcweir                             TriState eState = STATE_DONTKNOW;
259cdf0e10cSrcweir 
260cdf0e10cSrcweir                             if ( m_pTabListBox->IsCellCheckBox( nRow, nCol, eState ) )
261cdf0e10cSrcweir                             {
262cdf0e10cSrcweir                                 AccessibleCheckBoxCell* pCell =
263cdf0e10cSrcweir                                     static_cast< AccessibleCheckBoxCell* >( xChild.get() );
264cdf0e10cSrcweir                                 pCell->commitEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
265cdf0e10cSrcweir                             }
266cdf0e10cSrcweir                             else
267cdf0e10cSrcweir                             {
268cdf0e10cSrcweir                                 AccessibleBrowseBoxTableCell* pCell =
269cdf0e10cSrcweir                                     static_cast< AccessibleBrowseBoxTableCell* >( xChild.get() );
270cdf0e10cSrcweir                                 pCell->nameChanged( sNewText, pData->m_sOldText );
271cdf0e10cSrcweir                             }
272cdf0e10cSrcweir                         }
273cdf0e10cSrcweir                     }
274cdf0e10cSrcweir                     break;
275cdf0e10cSrcweir                 }
276cdf0e10cSrcweir 			}
277cdf0e10cSrcweir 		}
278cdf0e10cSrcweir 	}
279cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
IMPL_LINK(AccessibleTabListBoxTable,WindowEventListener,VclSimpleEvent *,pEvent)280cdf0e10cSrcweir 	IMPL_LINK( AccessibleTabListBoxTable, WindowEventListener, VclSimpleEvent*, pEvent )
281cdf0e10cSrcweir 	{
282cdf0e10cSrcweir     	DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
283cdf0e10cSrcweir     	if ( pEvent && pEvent->ISA( VclWindowEvent ) )
284cdf0e10cSrcweir     	{
285cdf0e10cSrcweir         	DBG_ASSERT( ( (VclWindowEvent*)pEvent )->GetWindow() && m_pTabListBox, "no event window" );
286cdf0e10cSrcweir         	ProcessWindowEvent( *(VclWindowEvent*)pEvent );
287cdf0e10cSrcweir     	}
288cdf0e10cSrcweir     	return 0;
289cdf0e10cSrcweir 	}
290cdf0e10cSrcweir 	// helpers --------------------------------------------------------------------
291cdf0e10cSrcweir 
ensureValidIndex(sal_Int32 _nIndex) const292cdf0e10cSrcweir 	void AccessibleTabListBoxTable::ensureValidIndex( sal_Int32 _nIndex ) const
293cdf0e10cSrcweir 	        SAL_THROW( ( IndexOutOfBoundsException ) )
294cdf0e10cSrcweir 	{
295cdf0e10cSrcweir 	    if ( ( _nIndex < 0 ) || ( _nIndex >= implGetCellCount() ) )
296cdf0e10cSrcweir 	        throw IndexOutOfBoundsException();
297cdf0e10cSrcweir 	}
298cdf0e10cSrcweir 
implIsRowSelected(sal_Int32 _nRow) const299cdf0e10cSrcweir 	sal_Bool AccessibleTabListBoxTable::implIsRowSelected( sal_Int32 _nRow ) const
300cdf0e10cSrcweir 	{
301cdf0e10cSrcweir 	    return m_pTabListBox ? m_pTabListBox->IsSelected( m_pTabListBox->GetEntry( _nRow ) ) : sal_False;
302cdf0e10cSrcweir 	}
303cdf0e10cSrcweir 
implSelectRow(sal_Int32 _nRow,sal_Bool _bSelect)304cdf0e10cSrcweir 	void AccessibleTabListBoxTable::implSelectRow( sal_Int32 _nRow, sal_Bool _bSelect )
305cdf0e10cSrcweir 	{
306cdf0e10cSrcweir 		if ( m_pTabListBox )
307cdf0e10cSrcweir 		    m_pTabListBox->Select( m_pTabListBox->GetEntry( _nRow ), _bSelect );
308cdf0e10cSrcweir 	}
309cdf0e10cSrcweir 
implGetRowCount() const310cdf0e10cSrcweir 	sal_Int32 AccessibleTabListBoxTable::implGetRowCount() const
311cdf0e10cSrcweir 	{
312cdf0e10cSrcweir 	    return m_pTabListBox ? m_pTabListBox->GetEntryCount() : 0;
313cdf0e10cSrcweir 	}
314cdf0e10cSrcweir 
implGetColumnCount() const315cdf0e10cSrcweir 	sal_Int32 AccessibleTabListBoxTable::implGetColumnCount() const
316cdf0e10cSrcweir 	{
317cdf0e10cSrcweir 	    return m_pTabListBox ? m_pTabListBox->GetColumnCount() : 0;
318cdf0e10cSrcweir 	}
319cdf0e10cSrcweir 
implGetSelRowCount() const320cdf0e10cSrcweir 	sal_Int32 AccessibleTabListBoxTable::implGetSelRowCount() const
321cdf0e10cSrcweir 	{
322cdf0e10cSrcweir 	    return m_pTabListBox ? m_pTabListBox->GetSelectionCount() : 0;
323cdf0e10cSrcweir 	}
324cdf0e10cSrcweir 
implGetSelRow(sal_Int32 nSelRow) const325cdf0e10cSrcweir 	sal_Int32 AccessibleTabListBoxTable::implGetSelRow( sal_Int32 nSelRow ) const
326cdf0e10cSrcweir 	{
327cdf0e10cSrcweir 		if ( m_pTabListBox )
328cdf0e10cSrcweir 		{
329cdf0e10cSrcweir 		    sal_Int32 nRow = 0;
330cdf0e10cSrcweir 			SvLBoxEntry* pEntry = m_pTabListBox->FirstSelected();
331cdf0e10cSrcweir 			while ( pEntry )
332cdf0e10cSrcweir 			{
333cdf0e10cSrcweir 				++nRow;
334cdf0e10cSrcweir 				if ( nRow == nSelRow )
335cdf0e10cSrcweir 					return m_pTabListBox->GetEntryPos( pEntry );
336cdf0e10cSrcweir 				pEntry = m_pTabListBox->NextSelected( pEntry );
337cdf0e10cSrcweir 			}
338cdf0e10cSrcweir 		}
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 		return 0;
341cdf0e10cSrcweir 	}
342cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
343cdf0e10cSrcweir 	// XInterface & XTypeProvider
344cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
IMPLEMENT_FORWARD_XINTERFACE2(AccessibleTabListBoxTable,AccessibleBrowseBoxTable,AccessibleTabListBoxTableImplHelper)345cdf0e10cSrcweir 	IMPLEMENT_FORWARD_XINTERFACE2(AccessibleTabListBoxTable, AccessibleBrowseBoxTable, AccessibleTabListBoxTableImplHelper)
346cdf0e10cSrcweir 	IMPLEMENT_FORWARD_XTYPEPROVIDER2(AccessibleTabListBoxTable, AccessibleBrowseBoxTable, AccessibleTabListBoxTableImplHelper)
347cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
348cdf0e10cSrcweir 	// XServiceInfo
349cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
350cdf0e10cSrcweir 	::rtl::OUString AccessibleTabListBoxTable::getImplementationName (void) throw (RuntimeException)
351cdf0e10cSrcweir 	{
352cdf0e10cSrcweir 		return ::rtl::OUString::createFromAscii("com.sun.star.comp.svtools.AccessibleTabListBoxTable");
353cdf0e10cSrcweir 	}
354cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
355cdf0e10cSrcweir 	// XAccessibleSelection
356cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
selectAccessibleChild(sal_Int32 nChildIndex)357cdf0e10cSrcweir 	void SAL_CALL AccessibleTabListBoxTable::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
358cdf0e10cSrcweir 	{
359cdf0e10cSrcweir     	TLBSolarGuard aSolarGuard;
360cdf0e10cSrcweir 		::osl::MutexGuard aGuard( getOslMutex() );
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 		ensureIsAlive();
363cdf0e10cSrcweir 	    ensureValidIndex( nChildIndex );
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 		implSelectRow( implGetRow( nChildIndex ), sal_True );
366cdf0e10cSrcweir 	}
367cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
isAccessibleChildSelected(sal_Int32 nChildIndex)368cdf0e10cSrcweir 	sal_Bool SAL_CALL AccessibleTabListBoxTable::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
369cdf0e10cSrcweir 	{
370cdf0e10cSrcweir     	TLBSolarGuard aSolarGuard;
371cdf0e10cSrcweir 		::osl::MutexGuard aGuard( getOslMutex() );
372cdf0e10cSrcweir 
373cdf0e10cSrcweir 		ensureIsAlive();
374cdf0e10cSrcweir 	    ensureValidIndex( nChildIndex );
375cdf0e10cSrcweir 
376cdf0e10cSrcweir 	    return implIsRowSelected( implGetRow( nChildIndex ) );
377cdf0e10cSrcweir 	}
378cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
clearAccessibleSelection()379cdf0e10cSrcweir 	void SAL_CALL AccessibleTabListBoxTable::clearAccessibleSelection(  ) throw (RuntimeException)
380cdf0e10cSrcweir 	{
381cdf0e10cSrcweir     	TLBSolarGuard aSolarGuard;
382cdf0e10cSrcweir 		::osl::MutexGuard aGuard( getOslMutex() );
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 		ensureIsAlive();
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 		m_pTabListBox->SetNoSelection();
387cdf0e10cSrcweir 	}
388cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
selectAllAccessibleChildren()389cdf0e10cSrcweir 	void SAL_CALL AccessibleTabListBoxTable::selectAllAccessibleChildren(  ) throw (RuntimeException)
390cdf0e10cSrcweir 	{
391cdf0e10cSrcweir     	TLBSolarGuard aSolarGuard;
392cdf0e10cSrcweir 		::osl::MutexGuard aGuard( getOslMutex() );
393cdf0e10cSrcweir 
394cdf0e10cSrcweir 		ensureIsAlive();
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 		m_pTabListBox->SelectAll();
397cdf0e10cSrcweir 	}
398cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
getSelectedAccessibleChildCount()399cdf0e10cSrcweir 	sal_Int32 SAL_CALL AccessibleTabListBoxTable::getSelectedAccessibleChildCount(  ) throw (RuntimeException)
400cdf0e10cSrcweir 	{
401cdf0e10cSrcweir     	TLBSolarGuard aSolarGuard;
402cdf0e10cSrcweir 		::osl::MutexGuard aGuard( getOslMutex() );
403cdf0e10cSrcweir 
404cdf0e10cSrcweir 		ensureIsAlive();
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	    return implGetColumnCount() * implGetSelRowCount();
407cdf0e10cSrcweir 	}
408cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)409cdf0e10cSrcweir 	Reference< XAccessible > SAL_CALL AccessibleTabListBoxTable::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
410cdf0e10cSrcweir 	{
411cdf0e10cSrcweir     	TLBSolarGuard aSolarGuard;
412cdf0e10cSrcweir 		::osl::MutexGuard aGuard( getOslMutex() );
413cdf0e10cSrcweir 
414cdf0e10cSrcweir 		ensureIsAlive();
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 	    sal_Int32 nRows = implGetSelRowCount();
417cdf0e10cSrcweir 	    if ( nRows == 0 )
418cdf0e10cSrcweir 	        throw IndexOutOfBoundsException();
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 	    sal_Int32 nRow = implGetSelRow( nSelectedChildIndex % nRows );
421cdf0e10cSrcweir 	    sal_Int32 nColumn = nSelectedChildIndex / nRows;
422cdf0e10cSrcweir 	    return getAccessibleCellAt( nRow, nColumn );
423cdf0e10cSrcweir 	}
424cdf0e10cSrcweir 	// -----------------------------------------------------------------------------
deselectAccessibleChild(sal_Int32 nSelectedChildIndex)425cdf0e10cSrcweir 	void SAL_CALL AccessibleTabListBoxTable::deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
426cdf0e10cSrcweir 	{
427cdf0e10cSrcweir     	TLBSolarGuard aSolarGuard;
428cdf0e10cSrcweir 		::osl::MutexGuard aGuard( getOslMutex() );
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 		ensureIsAlive();
431cdf0e10cSrcweir 	    ensureValidIndex( nSelectedChildIndex );
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 		implSelectRow( implGetRow( nSelectedChildIndex ), sal_False );
434cdf0e10cSrcweir 	}
435cdf0e10cSrcweir 
436cdf0e10cSrcweir //........................................................................
437cdf0e10cSrcweir }// namespace accessibility
438cdf0e10cSrcweir //........................................................................
439cdf0e10cSrcweir 
440