Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "accessibility/extended/AccessibleBrowseBoxHeaderBar.hxx"
30 : : #include <svtools/accessibletableprovider.hxx>
31 : : #include <comphelper/servicehelper.hxx>
32 : :
33 : : // ============================================================================
34 : :
35 : : using ::rtl::OUString;
36 : :
37 : : using ::com::sun::star::uno::Reference;
38 : : using ::com::sun::star::uno::Sequence;
39 : : using ::com::sun::star::uno::Any;
40 : :
41 : : using namespace ::com::sun::star;
42 : : using namespace ::com::sun::star::accessibility;
43 : : using namespace ::svt;
44 : :
45 : : // ============================================================================
46 : :
47 : : namespace accessibility {
48 : :
49 : : // ============================================================================
50 : :
51 : : // Ctor/Dtor/disposing --------------------------------------------------------
52 : :
53 : 0 : AccessibleBrowseBoxHeaderBar::AccessibleBrowseBoxHeaderBar(
54 : : const Reference< XAccessible >& rxParent,
55 : : IAccessibleTableProvider& rBrowseBox,
56 : : AccessibleBrowseBoxObjType eObjType ) :
57 : 0 : AccessibleBrowseBoxTableBase( rxParent, rBrowseBox,eObjType )
58 : : {
59 : : OSL_ENSURE( isRowBar() || isColumnBar(),
60 : : "accessibility/extended/AccessibleBrowseBoxHeaderBar - invalid object type" );
61 : 0 : }
62 : :
63 : 0 : AccessibleBrowseBoxHeaderBar::~AccessibleBrowseBoxHeaderBar()
64 : : {
65 [ # # ]: 0 : }
66 : :
67 : : // XAccessibleContext ---------------------------------------------------------
68 : :
69 : : Reference< XAccessible > SAL_CALL
70 : 0 : AccessibleBrowseBoxHeaderBar::getAccessibleChild( sal_Int32 nChildIndex )
71 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
72 : : {
73 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
74 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
75 [ # # ]: 0 : ensureIsAlive();
76 [ # # ]: 0 : ensureIsValidHeaderIndex( nChildIndex );
77 [ # # ][ # # ]: 0 : return implGetChild( nChildIndex, implToVCLColumnPos( nChildIndex ) );
[ # # ][ # # ]
78 : : }
79 : :
80 : 0 : sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleIndexInParent()
81 : : throw ( uno::RuntimeException )
82 : : {
83 [ # # ]: 0 : return isRowBar() ? BBINDEX_ROWHEADERBAR : BBINDEX_COLUMNHEADERBAR;
84 : : }
85 : :
86 : : // XAccessibleComponent -------------------------------------------------------
87 : :
88 : : Reference< XAccessible > SAL_CALL
89 : 0 : AccessibleBrowseBoxHeaderBar::getAccessibleAtPoint( const awt::Point& rPoint )
90 : : throw ( uno::RuntimeException )
91 : : {
92 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
93 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
94 [ # # ]: 0 : ensureIsAlive();
95 : :
96 : 0 : sal_Int32 nRow = 0;
97 : 0 : sal_uInt16 nColumnPos = 0;
98 : 0 : sal_Bool bConverted = isRowBar() ?
99 [ # # ][ # # ]: 0 : mpBrowseBox->ConvertPointToRowHeader( nRow, VCLPoint( rPoint ) ) :
100 [ # # ][ # # ]: 0 : mpBrowseBox->ConvertPointToColumnHeader( nColumnPos, VCLPoint( rPoint ) );
[ # # ]
[ # # # # ]
101 : :
102 [ # # ][ # # ]: 0 : return bConverted ? implGetChild( nRow, nColumnPos ) : Reference< XAccessible >();
[ # # ][ # # ]
103 : : }
104 : :
105 : 0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::grabFocus()
106 : : throw ( uno::RuntimeException )
107 : : {
108 : 0 : ensureIsAlive();
109 : : // focus on header not supported
110 : 0 : }
111 : :
112 : 0 : Any SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleKeyBinding()
113 : : throw ( uno::RuntimeException )
114 : : {
115 : 0 : ensureIsAlive();
116 : 0 : return Any(); // no special key bindings for header
117 : : }
118 : :
119 : : // XAccessibleTable -----------------------------------------------------------
120 : :
121 : 0 : OUString SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleRowDescription( sal_Int32 nRow )
122 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
123 : : {
124 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
125 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
126 [ # # ]: 0 : ensureIsAlive();
127 [ # # ]: 0 : ensureIsValidRow( nRow );
128 [ # # ][ # # ]: 0 : return OUString(); // no headers in headers
129 : : }
130 : :
131 : 0 : OUString SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleColumnDescription( sal_Int32 nColumn )
132 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
133 : : {
134 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
135 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
136 [ # # ]: 0 : ensureIsAlive();
137 [ # # ]: 0 : ensureIsValidColumn( nColumn );
138 [ # # ][ # # ]: 0 : return OUString(); // no headers in headers
139 : : }
140 : :
141 : 0 : Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleRowHeaders()
142 : : throw ( uno::RuntimeException )
143 : : {
144 : 0 : ensureIsAlive();
145 : 0 : return NULL; // no headers in headers
146 : : }
147 : :
148 : 0 : Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleColumnHeaders()
149 : : throw ( uno::RuntimeException )
150 : : {
151 : 0 : ensureIsAlive();
152 : 0 : return NULL; // no headers in headers
153 : : }
154 : :
155 : 0 : Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxHeaderBar::getSelectedAccessibleRows()
156 : : throw ( uno::RuntimeException )
157 : : {
158 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
159 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
160 [ # # ]: 0 : ensureIsAlive();
161 : :
162 [ # # ]: 0 : Sequence< sal_Int32 > aSelSeq;
163 : : // row of column header bar not selectable
164 [ # # ]: 0 : if( isRowBar() )
165 [ # # ]: 0 : implGetSelectedRows( aSelSeq );
166 [ # # ][ # # ]: 0 : return aSelSeq;
167 : : }
168 : :
169 : 0 : Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxHeaderBar::getSelectedAccessibleColumns()
170 : : throw ( uno::RuntimeException )
171 : : {
172 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
173 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
174 [ # # ]: 0 : ensureIsAlive();
175 : :
176 [ # # ]: 0 : Sequence< sal_Int32 > aSelSeq;
177 : : // column of row header bar ("handle column") not selectable
178 [ # # ]: 0 : if( isColumnBar() )
179 [ # # ]: 0 : implGetSelectedColumns( aSelSeq );
180 [ # # ][ # # ]: 0 : return aSelSeq;
181 : : }
182 : :
183 : 0 : sal_Bool SAL_CALL AccessibleBrowseBoxHeaderBar::isAccessibleRowSelected( sal_Int32 nRow )
184 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
185 : : {
186 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
187 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
188 [ # # ]: 0 : ensureIsAlive();
189 [ # # ]: 0 : ensureIsValidRow( nRow );
190 [ # # ][ # # ]: 0 : return isRowBar() ? implIsRowSelected( nRow ) : sal_False;
[ # # ][ # # ]
191 : : }
192 : :
193 : 0 : sal_Bool SAL_CALL AccessibleBrowseBoxHeaderBar::isAccessibleColumnSelected( sal_Int32 nColumn )
194 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
195 : : {
196 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
197 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
198 [ # # ]: 0 : ensureIsAlive();
199 [ # # ]: 0 : ensureIsValidColumn( nColumn );
200 [ # # ][ # # ]: 0 : return isColumnBar() ? implIsColumnSelected( nColumn ) : sal_False;
[ # # ][ # # ]
201 : : }
202 : :
203 : 0 : Reference< XAccessible > SAL_CALL AccessibleBrowseBoxHeaderBar::getAccessibleCellAt(
204 : : sal_Int32 nRow, sal_Int32 nColumn )
205 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
206 : : {
207 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
208 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
209 [ # # ]: 0 : ensureIsAlive();
210 [ # # ]: 0 : ensureIsValidAddress( nRow, nColumn );
211 [ # # ][ # # ]: 0 : return implGetChild( nRow, implToVCLColumnPos( nColumn ) );
[ # # ][ # # ]
212 : : }
213 : :
214 : 0 : sal_Bool SAL_CALL AccessibleBrowseBoxHeaderBar::isAccessibleSelected(
215 : : sal_Int32 nRow, sal_Int32 nColumn )
216 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
217 : : {
218 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
219 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
220 [ # # ]: 0 : ensureIsAlive();
221 [ # # ]: 0 : ensureIsValidAddress( nRow, nColumn );
222 [ # # ][ # # ]: 0 : return isRowBar() ? implIsRowSelected( nRow ) : implIsColumnSelected( nColumn );
[ # # ][ # # ]
[ # # ]
223 : : }
224 : :
225 : : // XAccessibleSelection -------------------------------------------------------
226 : :
227 : 0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::selectAccessibleChild( sal_Int32 nChildIndex )
228 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
229 : : {
230 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
231 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
232 [ # # ]: 0 : ensureIsAlive();
233 [ # # ]: 0 : ensureIsValidHeaderIndex( nChildIndex );
234 [ # # ]: 0 : if( isRowBar() )
235 [ # # ]: 0 : implSelectRow( nChildIndex, sal_True );
236 : : else
237 [ # # ][ # # ]: 0 : implSelectColumn( implToVCLColumnPos( nChildIndex ), sal_True );
[ # # ][ # # ]
238 : 0 : }
239 : :
240 : 0 : sal_Bool SAL_CALL AccessibleBrowseBoxHeaderBar::isAccessibleChildSelected( sal_Int32 nChildIndex )
241 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
242 : : {
243 : : // using interface methods - no mutex
244 : 0 : return isRowBar() ?
245 : 0 : isAccessibleRowSelected( nChildIndex ) :
246 [ # # ]: 0 : isAccessibleColumnSelected( nChildIndex );
247 : : }
248 : :
249 : 0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::clearAccessibleSelection()
250 : : throw ( uno::RuntimeException )
251 : : {
252 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
253 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
254 [ # # ]: 0 : ensureIsAlive();
255 [ # # ][ # # ]: 0 : mpBrowseBox->SetNoSelection();
[ # # ]
256 : 0 : }
257 : :
258 : 0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::selectAllAccessibleChildren()
259 : : throw ( uno::RuntimeException )
260 : : {
261 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
262 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
263 [ # # ]: 0 : ensureIsAlive();
264 : : // no multiselection of columns possible
265 [ # # ]: 0 : if( isRowBar() )
266 [ # # ]: 0 : mpBrowseBox->SelectAll();
267 : : else
268 [ # # ][ # # ]: 0 : implSelectColumn( implToVCLColumnPos( 0 ), sal_True );
[ # # ][ # # ]
269 : 0 : }
270 : :
271 : 0 : sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderBar::getSelectedAccessibleChildCount()
272 : : throw ( uno::RuntimeException )
273 : : {
274 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
275 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
276 [ # # ]: 0 : ensureIsAlive();
277 [ # # ][ # # ]: 0 : return isRowBar() ? implGetSelectedRowCount() : implGetSelectedColumnCount();
[ # # ][ # # ]
[ # # ]
278 : : }
279 : :
280 : : Reference< XAccessible > SAL_CALL
281 : 0 : AccessibleBrowseBoxHeaderBar::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
282 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
283 : : {
284 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
285 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
286 [ # # ]: 0 : ensureIsAlive();
287 : :
288 : : // method may throw lang::IndexOutOfBoundsException
289 [ # # ]: 0 : sal_Int32 nIndex = implGetChildIndexFromSelectedIndex( nSelectedChildIndex );
290 [ # # ][ # # ]: 0 : return implGetChild( nIndex, implToVCLColumnPos( nIndex ) );
[ # # ][ # # ]
291 : : }
292 : :
293 : 0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::deselectAccessibleChild(
294 : : sal_Int32 nSelectedChildIndex )
295 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
296 : : {
297 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
298 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
299 [ # # ]: 0 : ensureIsAlive();
300 : :
301 : : // method may throw lang::IndexOutOfBoundsException
302 [ # # ][ # # ]: 0 : if ( isAccessibleChildSelected(nSelectedChildIndex) )
303 : : {
304 [ # # ]: 0 : if( isRowBar() )
305 [ # # ]: 0 : implSelectRow( nSelectedChildIndex, sal_False );
306 : : else
307 [ # # ][ # # ]: 0 : implSelectColumn( implToVCLColumnPos( nSelectedChildIndex ), sal_False );
308 [ # # ][ # # ]: 0 : }
309 : 0 : }
310 : :
311 : : // XInterface -----------------------------------------------------------------
312 : :
313 : 0 : Any SAL_CALL AccessibleBrowseBoxHeaderBar::queryInterface( const uno::Type& rType )
314 : : throw ( uno::RuntimeException )
315 : : {
316 [ # # ]: 0 : Any aAny( AccessibleBrowseBoxTableBase::queryInterface( rType ) );
317 : 0 : return aAny.hasValue() ?
318 [ # # ][ # # ]: 0 : aAny : AccessibleBrowseBoxHeaderBarImplHelper::queryInterface( rType );
319 : : }
320 : :
321 : 0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::acquire() throw ()
322 : : {
323 : 0 : AccessibleBrowseBoxTableBase::acquire();
324 : 0 : }
325 : :
326 : 0 : void SAL_CALL AccessibleBrowseBoxHeaderBar::release() throw ()
327 : : {
328 : 0 : AccessibleBrowseBoxTableBase::release();
329 : 0 : }
330 : :
331 : : // XServiceInfo ---------------------------------------------------------------
332 : :
333 : 0 : OUString SAL_CALL AccessibleBrowseBoxHeaderBar::getImplementationName()
334 : : throw ( uno::RuntimeException )
335 : : {
336 : 0 : return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderBar" ) );
337 : : }
338 : :
339 : : namespace
340 : : {
341 : : class theAccessibleBrowseBoxHeaderBarImplementationId : public rtl::Static< UnoTunnelIdInit, theAccessibleBrowseBoxHeaderBarImplementationId > {};
342 : : }
343 : :
344 : 0 : Sequence< sal_Int8 > SAL_CALL AccessibleBrowseBoxHeaderBar::getImplementationId()
345 : : throw ( uno::RuntimeException )
346 : : {
347 : 0 : return theAccessibleBrowseBoxHeaderBarImplementationId::get().getSeq();
348 : : }
349 : :
350 : : // internal virtual methods ---------------------------------------------------
351 : :
352 : 0 : Rectangle AccessibleBrowseBoxHeaderBar::implGetBoundingBox()
353 : : {
354 : 0 : return mpBrowseBox->calcHeaderRect(isColumnBar(),sal_False);
355 : : }
356 : :
357 : 0 : Rectangle AccessibleBrowseBoxHeaderBar::implGetBoundingBoxOnScreen()
358 : : {
359 : 0 : return mpBrowseBox->calcHeaderRect(isColumnBar(),sal_True);
360 : : }
361 : :
362 : 0 : sal_Int32 AccessibleBrowseBoxHeaderBar::implGetRowCount() const
363 : : {
364 : : // column header bar: only 1 row
365 [ # # ]: 0 : return isRowBar() ? AccessibleBrowseBoxTableBase::implGetRowCount() : 1;
366 : : }
367 : :
368 : 0 : sal_Int32 AccessibleBrowseBoxHeaderBar::implGetColumnCount() const
369 : : {
370 : : // row header bar ("handle column"): only 1 column
371 [ # # ]: 0 : return isColumnBar() ? AccessibleBrowseBoxTableBase::implGetColumnCount() : 1;
372 : : }
373 : :
374 : : // internal helper methods ----------------------------------------------------
375 : :
376 : 0 : Reference< XAccessible > AccessibleBrowseBoxHeaderBar::implGetChild(
377 : : sal_Int32 nRow, sal_uInt16 nColumnPos )
378 : : {
379 : 0 : return isRowBar() ?
380 : 0 : mpBrowseBox->CreateAccessibleRowHeader( nRow ) :
381 [ # # ]: 0 : mpBrowseBox->CreateAccessibleColumnHeader( nColumnPos );
382 : : }
383 : :
384 : 0 : sal_Int32 AccessibleBrowseBoxHeaderBar::implGetChildIndexFromSelectedIndex(
385 : : sal_Int32 nSelectedChildIndex )
386 : : throw ( lang::IndexOutOfBoundsException )
387 : : {
388 [ # # ]: 0 : Sequence< sal_Int32 > aSelSeq;
389 [ # # ]: 0 : if( isRowBar() )
390 [ # # ]: 0 : implGetSelectedRows( aSelSeq );
391 : : else
392 [ # # ]: 0 : implGetSelectedColumns( aSelSeq );
393 : :
394 [ # # ][ # # ]: 0 : if( (nSelectedChildIndex < 0) || (nSelectedChildIndex >= aSelSeq.getLength()) )
[ # # ]
395 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
396 : :
397 [ # # ][ # # ]: 0 : return aSelSeq[ nSelectedChildIndex ];
398 : : }
399 : :
400 : 0 : void AccessibleBrowseBoxHeaderBar::ensureIsValidHeaderIndex( sal_Int32 nIndex )
401 : : throw ( lang::IndexOutOfBoundsException )
402 : : {
403 [ # # ]: 0 : if( isRowBar() )
404 : 0 : ensureIsValidRow( nIndex );
405 : : else
406 : 0 : ensureIsValidColumn( nIndex );
407 : 0 : }
408 : :
409 : : // ============================================================================
410 : :
411 : : } // namespace accessibility
412 : :
413 : : // ============================================================================
414 : :
415 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|