Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxTable.cxx
blob77dd2d4ba7daaebe8a5d9b5d3c5a5eb21c8d28cb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "accessibility/extended/AccessibleBrowseBoxTable.hxx"
21 #include <svtools/accessibletableprovider.hxx>
23 // ============================================================================
25 using ::com::sun::star::uno::Reference;
26 using ::com::sun::star::uno::Sequence;
27 using ::com::sun::star::uno::Any;
29 using namespace ::com::sun::star;
30 using namespace ::com::sun::star::accessibility;
31 using namespace ::svt;
33 // ============================================================================
35 namespace accessibility {
37 // ============================================================================
39 // Ctor/Dtor/disposing --------------------------------------------------------
41 AccessibleBrowseBoxTable::AccessibleBrowseBoxTable(
42 const Reference< XAccessible >& rxParent,
43 IAccessibleTableProvider& rBrowseBox ) :
44 AccessibleBrowseBoxTableBase( rxParent, rBrowseBox, BBTYPE_TABLE )
48 AccessibleBrowseBoxTable::~AccessibleBrowseBoxTable()
52 // XAccessibleContext ---------------------------------------------------------
54 Reference< XAccessible > SAL_CALL
55 AccessibleBrowseBoxTable::getAccessibleChild( sal_Int32 nChildIndex )
56 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
58 SolarMutexGuard aSolarGuard;
59 ::osl::MutexGuard aGuard( getOslMutex() );
60 ensureIsAlive();
61 ensureIsValidIndex( nChildIndex );
62 return mpBrowseBox->CreateAccessibleCell(
63 implGetRow( nChildIndex ), (sal_Int16)implGetColumn( nChildIndex ) );
66 sal_Int32 SAL_CALL AccessibleBrowseBoxTable::getAccessibleIndexInParent()
67 throw ( uno::RuntimeException )
69 ensureIsAlive();
70 return BBINDEX_TABLE;
73 // XAccessibleComponent -------------------------------------------------------
75 Reference< XAccessible > SAL_CALL
76 AccessibleBrowseBoxTable::getAccessibleAtPoint( const awt::Point& rPoint )
77 throw ( uno::RuntimeException )
79 SolarMutexGuard aSolarGuard;
80 ::osl::MutexGuard aGuard( getOslMutex() );
81 ensureIsAlive();
83 Reference< XAccessible > xChild;
84 sal_Int32 nRow = 0;
85 sal_uInt16 nColumnPos = 0;
86 if( mpBrowseBox->ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) )
87 xChild = mpBrowseBox->CreateAccessibleCell( nRow, nColumnPos );
89 return xChild;
92 void SAL_CALL AccessibleBrowseBoxTable::grabFocus()
93 throw ( uno::RuntimeException )
95 SolarMutexGuard aSolarGuard;
96 ::osl::MutexGuard aGuard( getOslMutex() );
97 ensureIsAlive();
98 mpBrowseBox->GrabTableFocus();
101 Any SAL_CALL AccessibleBrowseBoxTable::getAccessibleKeyBinding()
102 throw ( uno::RuntimeException )
104 ensureIsAlive();
105 return Any(); // no special key bindings for data table
108 // XAccessibleTable -----------------------------------------------------------
110 OUString SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowDescription( sal_Int32 nRow )
111 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
113 SolarMutexGuard aSolarGuard;
114 ::osl::MutexGuard aGuard( getOslMutex() );
115 ensureIsAlive();
116 ensureIsValidRow( nRow );
117 return mpBrowseBox->GetRowDescription( nRow );
120 OUString SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnDescription( sal_Int32 nColumn )
121 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
123 SolarMutexGuard aSolarGuard;
124 ::osl::MutexGuard aGuard( getOslMutex() );
125 ensureIsAlive();
126 ensureIsValidColumn( nColumn );
127 return mpBrowseBox->GetColumnDescription( (sal_uInt16)nColumn );
130 Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowHeaders()
131 throw ( uno::RuntimeException )
133 ::osl::MutexGuard aGuard( getOslMutex() );
134 ensureIsAlive();
135 return implGetHeaderBar( BBINDEX_ROWHEADERBAR );
138 Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnHeaders()
139 throw ( uno::RuntimeException )
141 ::osl::MutexGuard aGuard( getOslMutex() );
142 ensureIsAlive();
143 return implGetHeaderBar( BBINDEX_COLUMNHEADERBAR );
146 Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleRows()
147 throw ( uno::RuntimeException )
149 SolarMutexGuard aSolarGuard;
150 ::osl::MutexGuard aGuard( getOslMutex() );
151 ensureIsAlive();
153 Sequence< sal_Int32 > aSelSeq;
154 implGetSelectedRows( aSelSeq );
155 return aSelSeq;
158 Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleColumns()
159 throw ( uno::RuntimeException )
161 SolarMutexGuard aSolarGuard;
162 ::osl::MutexGuard aGuard( getOslMutex() );
163 ensureIsAlive();
165 Sequence< sal_Int32 > aSelSeq;
166 implGetSelectedColumns( aSelSeq );
167 return aSelSeq;
170 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleRowSelected( sal_Int32 nRow )
171 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
173 SolarMutexGuard aSolarGuard;
174 ::osl::MutexGuard aGuard( getOslMutex() );
175 ensureIsAlive();
176 ensureIsValidRow( nRow );
177 return implIsRowSelected( nRow );
180 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleColumnSelected( sal_Int32 nColumn )
181 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
183 SolarMutexGuard aSolarGuard;
184 ::osl::MutexGuard aGuard( getOslMutex() );
185 ensureIsAlive();
186 ensureIsValidColumn( nColumn );
187 return implIsColumnSelected( nColumn );
190 Reference< XAccessible > SAL_CALL AccessibleBrowseBoxTable::getAccessibleCellAt(
191 sal_Int32 nRow, sal_Int32 nColumn )
192 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
194 SolarMutexGuard aSolarGuard;
195 ::osl::MutexGuard aGuard( getOslMutex() );
196 ensureIsAlive();
197 ensureIsValidAddress( nRow, nColumn );
198 return mpBrowseBox->CreateAccessibleCell( nRow, (sal_Int16)nColumn );
201 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleSelected(
202 sal_Int32 nRow, sal_Int32 nColumn )
203 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
205 SolarMutexGuard aSolarGuard;
206 ::osl::MutexGuard aGuard( getOslMutex() );
207 ensureIsAlive();
208 ensureIsValidAddress( nRow, nColumn );
209 return implIsRowSelected( nRow ) || implIsColumnSelected( nColumn );
212 // XServiceInfo ---------------------------------------------------------------
214 OUString SAL_CALL AccessibleBrowseBoxTable::getImplementationName()
215 throw ( uno::RuntimeException )
217 return OUString( "com.sun.star.comp.svtools.AccessibleBrowseBoxTable" );
220 // internal virtual methods ---------------------------------------------------
222 Rectangle AccessibleBrowseBoxTable::implGetBoundingBox()
224 return mpBrowseBox->calcTableRect(sal_False);
227 Rectangle AccessibleBrowseBoxTable::implGetBoundingBoxOnScreen()
229 return mpBrowseBox->calcTableRect();
232 // internal helper methods ----------------------------------------------------
234 Reference< XAccessibleTable > AccessibleBrowseBoxTable::implGetHeaderBar(
235 sal_Int32 nChildIndex )
236 throw ( uno::RuntimeException )
238 Reference< XAccessible > xRet;
239 Reference< XAccessibleContext > xContext( mxParent, uno::UNO_QUERY );
240 if( xContext.is() )
244 xRet = xContext->getAccessibleChild( nChildIndex );
246 catch (const lang::IndexOutOfBoundsException&)
248 OSL_FAIL( "implGetHeaderBar - wrong child index" );
250 // RuntimeException goes to caller
252 return Reference< XAccessibleTable >( xRet, uno::UNO_QUERY );
255 // ============================================================================
257 } // namespace accessibility
259 // ============================================================================
261 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */