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: AccessibleBrowseBoxTable.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/AccessibleBrowseBoxTable.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( AccessibleBrowseBoxTable
)
60 AccessibleBrowseBoxTable::AccessibleBrowseBoxTable(
61 const Reference
< XAccessible
>& rxParent
,
62 IAccessibleTableProvider
& rBrowseBox
) :
63 AccessibleBrowseBoxTableBase( rxParent
, rBrowseBox
, BBTYPE_TABLE
)
65 DBG_CTOR( AccessibleBrowseBoxTable
, NULL
);
68 AccessibleBrowseBoxTable::~AccessibleBrowseBoxTable()
70 DBG_DTOR( AccessibleBrowseBoxTable
, NULL
);
73 // XAccessibleContext ---------------------------------------------------------
75 Reference
< XAccessible
> SAL_CALL
76 AccessibleBrowseBoxTable::getAccessibleChild( sal_Int32 nChildIndex
)
77 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
79 BBSolarGuard aSolarGuard
;
80 ::osl::MutexGuard
aGuard( getOslMutex() );
82 ensureIsValidIndex( nChildIndex
);
83 return mpBrowseBox
->CreateAccessibleCell(
84 implGetRow( nChildIndex
), (sal_Int16
)implGetColumn( nChildIndex
) );
87 sal_Int32 SAL_CALL
AccessibleBrowseBoxTable::getAccessibleIndexInParent()
88 throw ( uno::RuntimeException
)
94 // XAccessibleComponent -------------------------------------------------------
96 Reference
< XAccessible
> SAL_CALL
97 AccessibleBrowseBoxTable::getAccessibleAtPoint( const awt::Point
& rPoint
)
98 throw ( uno::RuntimeException
)
100 BBSolarGuard aSolarGuard
;
101 ::osl::MutexGuard
aGuard( getOslMutex() );
104 Reference
< XAccessible
> xChild
;
106 sal_uInt16 nColumnPos
= 0;
107 if( mpBrowseBox
->ConvertPointToCellAddress( nRow
, nColumnPos
, VCLPoint( rPoint
) ) )
108 xChild
= mpBrowseBox
->CreateAccessibleCell( nRow
, nColumnPos
);
113 void SAL_CALL
AccessibleBrowseBoxTable::grabFocus()
114 throw ( uno::RuntimeException
)
116 BBSolarGuard aSolarGuard
;
117 ::osl::MutexGuard
aGuard( getOslMutex() );
119 mpBrowseBox
->GrabTableFocus();
122 Any SAL_CALL
AccessibleBrowseBoxTable::getAccessibleKeyBinding()
123 throw ( uno::RuntimeException
)
126 return Any(); // no special key bindings for data table
129 // XAccessibleTable -----------------------------------------------------------
131 OUString SAL_CALL
AccessibleBrowseBoxTable::getAccessibleRowDescription( sal_Int32 nRow
)
132 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
134 BBSolarGuard aSolarGuard
;
135 ::osl::MutexGuard
aGuard( getOslMutex() );
137 ensureIsValidRow( nRow
);
138 return mpBrowseBox
->GetRowDescription( nRow
);
141 OUString SAL_CALL
AccessibleBrowseBoxTable::getAccessibleColumnDescription( sal_Int32 nColumn
)
142 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
144 BBSolarGuard aSolarGuard
;
145 ::osl::MutexGuard
aGuard( getOslMutex() );
147 ensureIsValidColumn( nColumn
);
148 return mpBrowseBox
->GetColumnDescription( (sal_uInt16
)nColumn
);
151 Reference
< XAccessibleTable
> SAL_CALL
AccessibleBrowseBoxTable::getAccessibleRowHeaders()
152 throw ( uno::RuntimeException
)
154 ::osl::MutexGuard
aGuard( getOslMutex() );
156 return implGetHeaderBar( BBINDEX_ROWHEADERBAR
);
159 Reference
< XAccessibleTable
> SAL_CALL
AccessibleBrowseBoxTable::getAccessibleColumnHeaders()
160 throw ( uno::RuntimeException
)
162 ::osl::MutexGuard
aGuard( getOslMutex() );
164 return implGetHeaderBar( BBINDEX_COLUMNHEADERBAR
);
167 Sequence
< sal_Int32
> SAL_CALL
AccessibleBrowseBoxTable::getSelectedAccessibleRows()
168 throw ( uno::RuntimeException
)
170 BBSolarGuard aSolarGuard
;
171 ::osl::MutexGuard
aGuard( getOslMutex() );
174 Sequence
< sal_Int32
> aSelSeq
;
175 implGetSelectedRows( aSelSeq
);
179 Sequence
< sal_Int32
> SAL_CALL
AccessibleBrowseBoxTable::getSelectedAccessibleColumns()
180 throw ( uno::RuntimeException
)
182 BBSolarGuard aSolarGuard
;
183 ::osl::MutexGuard
aGuard( getOslMutex() );
186 Sequence
< sal_Int32
> aSelSeq
;
187 implGetSelectedColumns( aSelSeq
);
191 sal_Bool SAL_CALL
AccessibleBrowseBoxTable::isAccessibleRowSelected( sal_Int32 nRow
)
192 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
194 BBSolarGuard aSolarGuard
;
195 ::osl::MutexGuard
aGuard( getOslMutex() );
197 ensureIsValidRow( nRow
);
198 return implIsRowSelected( nRow
);
201 sal_Bool SAL_CALL
AccessibleBrowseBoxTable::isAccessibleColumnSelected( sal_Int32 nColumn
)
202 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
204 BBSolarGuard aSolarGuard
;
205 ::osl::MutexGuard
aGuard( getOslMutex() );
207 ensureIsValidColumn( nColumn
);
208 return implIsColumnSelected( nColumn
);
211 Reference
< XAccessible
> SAL_CALL
AccessibleBrowseBoxTable::getAccessibleCellAt(
212 sal_Int32 nRow
, sal_Int32 nColumn
)
213 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
215 BBSolarGuard aSolarGuard
;
216 ::osl::MutexGuard
aGuard( getOslMutex() );
218 ensureIsValidAddress( nRow
, nColumn
);
219 return mpBrowseBox
->CreateAccessibleCell( nRow
, (sal_Int16
)nColumn
);
222 sal_Bool SAL_CALL
AccessibleBrowseBoxTable::isAccessibleSelected(
223 sal_Int32 nRow
, sal_Int32 nColumn
)
224 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
226 BBSolarGuard aSolarGuard
;
227 ::osl::MutexGuard
aGuard( getOslMutex() );
229 ensureIsValidAddress( nRow
, nColumn
);
230 return implIsRowSelected( nRow
) || implIsColumnSelected( nColumn
);
233 // XServiceInfo ---------------------------------------------------------------
235 OUString SAL_CALL
AccessibleBrowseBoxTable::getImplementationName()
236 throw ( uno::RuntimeException
)
238 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.AccessibleBrowseBoxTable" ) );
241 // internal virtual methods ---------------------------------------------------
243 Rectangle
AccessibleBrowseBoxTable::implGetBoundingBox()
245 return mpBrowseBox
->calcTableRect(FALSE
);
248 Rectangle
AccessibleBrowseBoxTable::implGetBoundingBoxOnScreen()
250 return mpBrowseBox
->calcTableRect();
253 // internal helper methods ----------------------------------------------------
255 Reference
< XAccessibleTable
> AccessibleBrowseBoxTable::implGetHeaderBar(
256 sal_Int32 nChildIndex
)
257 throw ( uno::RuntimeException
)
259 Reference
< XAccessible
> xRet
;
260 Reference
< XAccessibleContext
> xContext( mxParent
, uno::UNO_QUERY
);
265 xRet
= xContext
->getAccessibleChild( nChildIndex
);
267 catch( lang::IndexOutOfBoundsException
& )
269 DBG_ERROR( "implGetHeaderBar - wrong child index" );
271 // RuntimeException goes to caller
273 return Reference
< XAccessibleTable
>( xRet
, uno::UNO_QUERY
);
276 // ============================================================================
278 } // namespace accessibility
280 // ============================================================================