1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleBrowseBoxHeaderBar.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_accessibility.hxx"
35 #include "accessibility/extended/AccessibleBrowseBoxHeaderBar.hxx"
36 #include <svtools/accessibletableprovider.hxx>
38 // ============================================================================
40 using ::rtl::OUString
;
42 using ::com::sun::star::uno::Reference
;
43 using ::com::sun::star::uno::Sequence
;
44 using ::com::sun::star::uno::Any
;
46 using namespace ::com::sun::star
;
47 using namespace ::com::sun::star::accessibility
;
48 using namespace ::svt
;
50 // ============================================================================
52 namespace accessibility
{
54 // ============================================================================
56 // Ctor/Dtor/disposing --------------------------------------------------------
58 DBG_NAME( AccessibleBrowseBoxHeaderBar
)
60 AccessibleBrowseBoxHeaderBar::AccessibleBrowseBoxHeaderBar(
61 const Reference
< XAccessible
>& rxParent
,
62 IAccessibleTableProvider
& rBrowseBox
,
63 AccessibleBrowseBoxObjType eObjType
) :
64 AccessibleBrowseBoxTableBase( rxParent
, rBrowseBox
,eObjType
)
66 DBG_CTOR( AccessibleBrowseBoxHeaderBar
, NULL
);
68 DBG_ASSERT( isRowBar() || isColumnBar(),
69 "accessibility/extended/AccessibleBrowseBoxHeaderBar - invalid object type" );
72 AccessibleBrowseBoxHeaderBar::~AccessibleBrowseBoxHeaderBar()
74 DBG_DTOR( AccessibleBrowseBoxHeaderBar
, NULL
);
77 // XAccessibleContext ---------------------------------------------------------
79 Reference
< XAccessible
> SAL_CALL
80 AccessibleBrowseBoxHeaderBar::getAccessibleChild( sal_Int32 nChildIndex
)
81 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
83 BBSolarGuard aSolarGuard
;
84 ::osl::MutexGuard
aGuard( getOslMutex() );
86 ensureIsValidHeaderIndex( nChildIndex
);
87 return implGetChild( nChildIndex
, implToVCLColumnPos( nChildIndex
) );
90 sal_Int32 SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleIndexInParent()
91 throw ( uno::RuntimeException
)
93 return isRowBar() ? BBINDEX_ROWHEADERBAR
: BBINDEX_COLUMNHEADERBAR
;
96 // XAccessibleComponent -------------------------------------------------------
98 Reference
< XAccessible
> SAL_CALL
99 AccessibleBrowseBoxHeaderBar::getAccessibleAtPoint( const awt::Point
& rPoint
)
100 throw ( uno::RuntimeException
)
102 BBSolarGuard aSolarGuard
;
103 ::osl::MutexGuard
aGuard( getOslMutex() );
107 sal_uInt16 nColumnPos
= 0;
108 sal_Bool bConverted
= isRowBar() ?
109 mpBrowseBox
->ConvertPointToRowHeader( nRow
, VCLPoint( rPoint
) ) :
110 mpBrowseBox
->ConvertPointToColumnHeader( nColumnPos
, VCLPoint( rPoint
) );
112 return bConverted
? implGetChild( nRow
, nColumnPos
) : Reference
< XAccessible
>();
115 void SAL_CALL
AccessibleBrowseBoxHeaderBar::grabFocus()
116 throw ( uno::RuntimeException
)
119 // focus on header not supported
122 Any SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleKeyBinding()
123 throw ( uno::RuntimeException
)
126 return Any(); // no special key bindings for header
129 // XAccessibleTable -----------------------------------------------------------
131 OUString SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleRowDescription( sal_Int32 nRow
)
132 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
134 BBSolarGuard aSolarGuard
;
135 ::osl::MutexGuard
aGuard( getOslMutex() );
137 ensureIsValidRow( nRow
);
138 return OUString(); // no headers in headers
141 OUString SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleColumnDescription( sal_Int32 nColumn
)
142 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
144 BBSolarGuard aSolarGuard
;
145 ::osl::MutexGuard
aGuard( getOslMutex() );
147 ensureIsValidColumn( nColumn
);
148 return OUString(); // no headers in headers
151 Reference
< XAccessibleTable
> SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleRowHeaders()
152 throw ( uno::RuntimeException
)
155 return NULL
; // no headers in headers
158 Reference
< XAccessibleTable
> SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleColumnHeaders()
159 throw ( uno::RuntimeException
)
162 return NULL
; // no headers in headers
165 Sequence
< sal_Int32
> SAL_CALL
AccessibleBrowseBoxHeaderBar::getSelectedAccessibleRows()
166 throw ( uno::RuntimeException
)
168 BBSolarGuard aSolarGuard
;
169 ::osl::MutexGuard
aGuard( getOslMutex() );
172 Sequence
< sal_Int32
> aSelSeq
;
173 // row of column header bar not selectable
175 implGetSelectedRows( aSelSeq
);
179 Sequence
< sal_Int32
> SAL_CALL
AccessibleBrowseBoxHeaderBar::getSelectedAccessibleColumns()
180 throw ( uno::RuntimeException
)
182 BBSolarGuard aSolarGuard
;
183 ::osl::MutexGuard
aGuard( getOslMutex() );
186 Sequence
< sal_Int32
> aSelSeq
;
187 // column of row header bar ("handle column") not selectable
189 implGetSelectedColumns( aSelSeq
);
193 sal_Bool SAL_CALL
AccessibleBrowseBoxHeaderBar::isAccessibleRowSelected( sal_Int32 nRow
)
194 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
196 BBSolarGuard aSolarGuard
;
197 ::osl::MutexGuard
aGuard( getOslMutex() );
199 ensureIsValidRow( nRow
);
200 return isRowBar() ? implIsRowSelected( nRow
) : sal_False
;
203 sal_Bool SAL_CALL
AccessibleBrowseBoxHeaderBar::isAccessibleColumnSelected( sal_Int32 nColumn
)
204 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
206 BBSolarGuard aSolarGuard
;
207 ::osl::MutexGuard
aGuard( getOslMutex() );
209 ensureIsValidColumn( nColumn
);
210 return isColumnBar() ? implIsColumnSelected( nColumn
) : sal_False
;
213 Reference
< XAccessible
> SAL_CALL
AccessibleBrowseBoxHeaderBar::getAccessibleCellAt(
214 sal_Int32 nRow
, sal_Int32 nColumn
)
215 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
217 BBSolarGuard aSolarGuard
;
218 ::osl::MutexGuard
aGuard( getOslMutex() );
220 ensureIsValidAddress( nRow
, nColumn
);
221 return implGetChild( nRow
, implToVCLColumnPos( nColumn
) );
224 sal_Bool SAL_CALL
AccessibleBrowseBoxHeaderBar::isAccessibleSelected(
225 sal_Int32 nRow
, sal_Int32 nColumn
)
226 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
228 BBSolarGuard aSolarGuard
;
229 ::osl::MutexGuard
aGuard( getOslMutex() );
231 ensureIsValidAddress( nRow
, nColumn
);
232 return isRowBar() ? implIsRowSelected( nRow
) : implIsColumnSelected( nColumn
);
235 // XAccessibleSelection -------------------------------------------------------
237 void SAL_CALL
AccessibleBrowseBoxHeaderBar::selectAccessibleChild( sal_Int32 nChildIndex
)
238 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
240 BBSolarGuard aSolarGuard
;
241 ::osl::MutexGuard
aGuard( getOslMutex() );
243 ensureIsValidHeaderIndex( nChildIndex
);
245 implSelectRow( nChildIndex
, sal_True
);
247 implSelectColumn( implToVCLColumnPos( nChildIndex
), sal_True
);
250 sal_Bool SAL_CALL
AccessibleBrowseBoxHeaderBar::isAccessibleChildSelected( sal_Int32 nChildIndex
)
251 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
253 // using interface methods - no mutex
255 isAccessibleRowSelected( nChildIndex
) :
256 isAccessibleColumnSelected( nChildIndex
);
259 void SAL_CALL
AccessibleBrowseBoxHeaderBar::clearAccessibleSelection()
260 throw ( uno::RuntimeException
)
262 BBSolarGuard aSolarGuard
;
263 ::osl::MutexGuard
aGuard( getOslMutex() );
265 mpBrowseBox
->SetNoSelection();
268 void SAL_CALL
AccessibleBrowseBoxHeaderBar::selectAllAccessibleChildren()
269 throw ( uno::RuntimeException
)
271 BBSolarGuard aSolarGuard
;
272 ::osl::MutexGuard
aGuard( getOslMutex() );
274 // no multiselection of columns possible
276 mpBrowseBox
->SelectAll();
278 implSelectColumn( implToVCLColumnPos( 0 ), sal_True
);
281 sal_Int32 SAL_CALL
AccessibleBrowseBoxHeaderBar::getSelectedAccessibleChildCount()
282 throw ( uno::RuntimeException
)
284 BBSolarGuard aSolarGuard
;
285 ::osl::MutexGuard
aGuard( getOslMutex() );
287 return isRowBar() ? implGetSelectedRowCount() : implGetSelectedColumnCount();
290 Reference
< XAccessible
> SAL_CALL
291 AccessibleBrowseBoxHeaderBar::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
292 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
294 BBSolarGuard aSolarGuard
;
295 ::osl::MutexGuard
aGuard( getOslMutex() );
298 // method may throw lang::IndexOutOfBoundsException
299 sal_Int32 nIndex
= implGetChildIndexFromSelectedIndex( nSelectedChildIndex
);
300 return implGetChild( nIndex
, implToVCLColumnPos( nIndex
) );
303 void SAL_CALL
AccessibleBrowseBoxHeaderBar::deselectAccessibleChild(
304 sal_Int32 nSelectedChildIndex
)
305 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
307 BBSolarGuard aSolarGuard
;
308 ::osl::MutexGuard
aGuard( getOslMutex() );
311 // method may throw lang::IndexOutOfBoundsException
312 if ( isAccessibleChildSelected(nSelectedChildIndex
) )
315 implSelectRow( nSelectedChildIndex
, sal_False
);
317 implSelectColumn( implToVCLColumnPos( nSelectedChildIndex
), sal_False
);
321 // XInterface -----------------------------------------------------------------
323 Any SAL_CALL
AccessibleBrowseBoxHeaderBar::queryInterface( const uno::Type
& rType
)
324 throw ( uno::RuntimeException
)
326 Any
aAny( AccessibleBrowseBoxTableBase::queryInterface( rType
) );
327 return aAny
.hasValue() ?
328 aAny
: AccessibleBrowseBoxHeaderBarImplHelper::queryInterface( rType
);
331 void SAL_CALL
AccessibleBrowseBoxHeaderBar::acquire() throw ()
333 AccessibleBrowseBoxTableBase::acquire();
336 void SAL_CALL
AccessibleBrowseBoxHeaderBar::release() throw ()
338 AccessibleBrowseBoxTableBase::release();
341 // XServiceInfo ---------------------------------------------------------------
343 OUString SAL_CALL
AccessibleBrowseBoxHeaderBar::getImplementationName()
344 throw ( uno::RuntimeException
)
346 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderBar" ) );
349 Sequence
< sal_Int8
> SAL_CALL
AccessibleBrowseBoxHeaderBar::getImplementationId()
350 throw ( uno::RuntimeException
)
352 ::osl::MutexGuard
aGuard( getOslGlobalMutex() );
353 static Sequence
< sal_Int8
> aId
;
354 implCreateUuid( aId
);
358 // internal virtual methods ---------------------------------------------------
360 Rectangle
AccessibleBrowseBoxHeaderBar::implGetBoundingBox()
362 return mpBrowseBox
->calcHeaderRect(isColumnBar(),FALSE
);
365 Rectangle
AccessibleBrowseBoxHeaderBar::implGetBoundingBoxOnScreen()
367 return mpBrowseBox
->calcHeaderRect(isColumnBar(),TRUE
);
370 sal_Int32
AccessibleBrowseBoxHeaderBar::implGetRowCount() const
372 // column header bar: only 1 row
373 return isRowBar() ? AccessibleBrowseBoxTableBase::implGetRowCount() : 1;
376 sal_Int32
AccessibleBrowseBoxHeaderBar::implGetColumnCount() const
378 // row header bar ("handle column"): only 1 column
379 return isColumnBar() ? AccessibleBrowseBoxTableBase::implGetColumnCount() : 1;
382 // internal helper methods ----------------------------------------------------
384 Reference
< XAccessible
> AccessibleBrowseBoxHeaderBar::implGetChild(
385 sal_Int32 nRow
, sal_uInt16 nColumnPos
)
388 mpBrowseBox
->CreateAccessibleRowHeader( nRow
) :
389 mpBrowseBox
->CreateAccessibleColumnHeader( nColumnPos
);
392 sal_Int32
AccessibleBrowseBoxHeaderBar::implGetChildIndexFromSelectedIndex(
393 sal_Int32 nSelectedChildIndex
)
394 throw ( lang::IndexOutOfBoundsException
)
396 Sequence
< sal_Int32
> aSelSeq
;
398 implGetSelectedRows( aSelSeq
);
400 implGetSelectedColumns( aSelSeq
);
402 if( (nSelectedChildIndex
< 0) || (nSelectedChildIndex
>= aSelSeq
.getLength()) )
403 throw lang::IndexOutOfBoundsException();
405 return aSelSeq
[ nSelectedChildIndex
];
408 void AccessibleBrowseBoxHeaderBar::ensureIsValidHeaderIndex( sal_Int32 nIndex
)
409 throw ( lang::IndexOutOfBoundsException
)
412 ensureIsValidRow( nIndex
);
414 ensureIsValidColumn( nIndex
);
417 // ============================================================================
419 } // namespace accessibility
421 // ============================================================================