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/AccessibleBrowseBoxTable.hxx"
30 : : #include <svtools/accessibletableprovider.hxx>
31 : :
32 : : // ============================================================================
33 : :
34 : : using ::rtl::OUString;
35 : :
36 : : using ::com::sun::star::uno::Reference;
37 : : using ::com::sun::star::uno::Sequence;
38 : : using ::com::sun::star::uno::Any;
39 : :
40 : : using namespace ::com::sun::star;
41 : : using namespace ::com::sun::star::accessibility;
42 : : using namespace ::svt;
43 : :
44 : : // ============================================================================
45 : :
46 : : namespace accessibility {
47 : :
48 : : // ============================================================================
49 : :
50 : : // Ctor/Dtor/disposing --------------------------------------------------------
51 : :
52 : 0 : AccessibleBrowseBoxTable::AccessibleBrowseBoxTable(
53 : : const Reference< XAccessible >& rxParent,
54 : : IAccessibleTableProvider& rBrowseBox ) :
55 : 0 : AccessibleBrowseBoxTableBase( rxParent, rBrowseBox, BBTYPE_TABLE )
56 : : {
57 : 0 : }
58 : :
59 : 0 : AccessibleBrowseBoxTable::~AccessibleBrowseBoxTable()
60 : : {
61 [ # # ]: 0 : }
62 : :
63 : : // XAccessibleContext ---------------------------------------------------------
64 : :
65 : : Reference< XAccessible > SAL_CALL
66 : 0 : AccessibleBrowseBoxTable::getAccessibleChild( sal_Int32 nChildIndex )
67 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
68 : : {
69 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
70 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
71 [ # # ]: 0 : ensureIsAlive();
72 [ # # ]: 0 : ensureIsValidIndex( nChildIndex );
73 : : return mpBrowseBox->CreateAccessibleCell(
74 [ # # ][ # # ]: 0 : implGetRow( nChildIndex ), (sal_Int16)implGetColumn( nChildIndex ) );
[ # # ][ # # ]
[ # # ]
75 : : }
76 : :
77 : 0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTable::getAccessibleIndexInParent()
78 : : throw ( uno::RuntimeException )
79 : : {
80 : 0 : ensureIsAlive();
81 : 0 : return BBINDEX_TABLE;
82 : : }
83 : :
84 : : // XAccessibleComponent -------------------------------------------------------
85 : :
86 : : Reference< XAccessible > SAL_CALL
87 : 0 : AccessibleBrowseBoxTable::getAccessibleAtPoint( const awt::Point& rPoint )
88 : : throw ( uno::RuntimeException )
89 : : {
90 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
91 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
92 [ # # ]: 0 : ensureIsAlive();
93 : :
94 : 0 : Reference< XAccessible > xChild;
95 : 0 : sal_Int32 nRow = 0;
96 : 0 : sal_uInt16 nColumnPos = 0;
97 [ # # ][ # # ]: 0 : if( mpBrowseBox->ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) )
98 [ # # ][ # # ]: 0 : xChild = mpBrowseBox->CreateAccessibleCell( nRow, nColumnPos );
99 : :
100 [ # # ][ # # ]: 0 : return xChild;
101 : : }
102 : :
103 : 0 : void SAL_CALL AccessibleBrowseBoxTable::grabFocus()
104 : : throw ( uno::RuntimeException )
105 : : {
106 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
107 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
108 [ # # ]: 0 : ensureIsAlive();
109 [ # # ][ # # ]: 0 : mpBrowseBox->GrabTableFocus();
[ # # ]
110 : 0 : }
111 : :
112 : 0 : Any SAL_CALL AccessibleBrowseBoxTable::getAccessibleKeyBinding()
113 : : throw ( uno::RuntimeException )
114 : : {
115 : 0 : ensureIsAlive();
116 : 0 : return Any(); // no special key bindings for data table
117 : : }
118 : :
119 : : // XAccessibleTable -----------------------------------------------------------
120 : :
121 : 0 : OUString SAL_CALL AccessibleBrowseBoxTable::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 mpBrowseBox->GetRowDescription( nRow );
[ # # ]
129 : : }
130 : :
131 : 0 : OUString SAL_CALL AccessibleBrowseBoxTable::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 mpBrowseBox->GetColumnDescription( (sal_uInt16)nColumn );
[ # # ]
139 : : }
140 : :
141 : 0 : Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowHeaders()
142 : : throw ( uno::RuntimeException )
143 : : {
144 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
145 [ # # ]: 0 : ensureIsAlive();
146 [ # # ][ # # ]: 0 : return implGetHeaderBar( BBINDEX_ROWHEADERBAR );
147 : : }
148 : :
149 : 0 : Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnHeaders()
150 : : throw ( uno::RuntimeException )
151 : : {
152 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
153 [ # # ]: 0 : ensureIsAlive();
154 [ # # ][ # # ]: 0 : return implGetHeaderBar( BBINDEX_COLUMNHEADERBAR );
155 : : }
156 : :
157 : 0 : Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleRows()
158 : : throw ( uno::RuntimeException )
159 : : {
160 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
161 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
162 [ # # ]: 0 : ensureIsAlive();
163 : :
164 [ # # ]: 0 : Sequence< sal_Int32 > aSelSeq;
165 [ # # ]: 0 : implGetSelectedRows( aSelSeq );
166 [ # # ][ # # ]: 0 : return aSelSeq;
167 : : }
168 : :
169 : 0 : Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::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 [ # # ]: 0 : implGetSelectedColumns( aSelSeq );
178 [ # # ][ # # ]: 0 : return aSelSeq;
179 : : }
180 : :
181 : 0 : sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleRowSelected( sal_Int32 nRow )
182 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
183 : : {
184 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
185 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
186 [ # # ]: 0 : ensureIsAlive();
187 [ # # ]: 0 : ensureIsValidRow( nRow );
188 [ # # ][ # # ]: 0 : return implIsRowSelected( nRow );
[ # # ]
189 : : }
190 : :
191 : 0 : sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleColumnSelected( sal_Int32 nColumn )
192 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
193 : : {
194 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
195 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
196 [ # # ]: 0 : ensureIsAlive();
197 [ # # ]: 0 : ensureIsValidColumn( nColumn );
198 [ # # ][ # # ]: 0 : return implIsColumnSelected( nColumn );
[ # # ]
199 : : }
200 : :
201 : 0 : Reference< XAccessible > SAL_CALL AccessibleBrowseBoxTable::getAccessibleCellAt(
202 : : sal_Int32 nRow, sal_Int32 nColumn )
203 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
204 : : {
205 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
206 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
207 [ # # ]: 0 : ensureIsAlive();
208 [ # # ]: 0 : ensureIsValidAddress( nRow, nColumn );
209 [ # # ][ # # ]: 0 : return mpBrowseBox->CreateAccessibleCell( nRow, (sal_Int16)nColumn );
[ # # ]
210 : : }
211 : :
212 : 0 : sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleSelected(
213 : : sal_Int32 nRow, sal_Int32 nColumn )
214 : : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
215 : : {
216 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
217 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
218 [ # # ]: 0 : ensureIsAlive();
219 [ # # ]: 0 : ensureIsValidAddress( nRow, nColumn );
220 [ # # ][ # # ]: 0 : return implIsRowSelected( nRow ) || implIsColumnSelected( nColumn );
[ # # ][ # # ]
[ # # ][ # # ]
221 : : }
222 : :
223 : : // XServiceInfo ---------------------------------------------------------------
224 : :
225 : 0 : OUString SAL_CALL AccessibleBrowseBoxTable::getImplementationName()
226 : : throw ( uno::RuntimeException )
227 : : {
228 : 0 : return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.AccessibleBrowseBoxTable" ) );
229 : : }
230 : :
231 : : // internal virtual methods ---------------------------------------------------
232 : :
233 : 0 : Rectangle AccessibleBrowseBoxTable::implGetBoundingBox()
234 : : {
235 : 0 : return mpBrowseBox->calcTableRect(sal_False);
236 : : }
237 : :
238 : 0 : Rectangle AccessibleBrowseBoxTable::implGetBoundingBoxOnScreen()
239 : : {
240 : 0 : return mpBrowseBox->calcTableRect();
241 : : }
242 : :
243 : : // internal helper methods ----------------------------------------------------
244 : :
245 : 0 : Reference< XAccessibleTable > AccessibleBrowseBoxTable::implGetHeaderBar(
246 : : sal_Int32 nChildIndex )
247 : : throw ( uno::RuntimeException )
248 : : {
249 : 0 : Reference< XAccessible > xRet;
250 [ # # ]: 0 : Reference< XAccessibleContext > xContext( mxParent, uno::UNO_QUERY );
251 [ # # ]: 0 : if( xContext.is() )
252 : : {
253 : : try
254 : : {
255 [ # # ][ # # ]: 0 : xRet = xContext->getAccessibleChild( nChildIndex );
[ # # ][ # # ]
256 : : }
257 [ # # ]: 0 : catch (const lang::IndexOutOfBoundsException&)
258 : : {
259 : : OSL_FAIL( "implGetHeaderBar - wrong child index" );
260 : : }
261 : : // RuntimeException goes to caller
262 : : }
263 [ # # ]: 0 : return Reference< XAccessibleTable >( xRet, uno::UNO_QUERY );
264 : : }
265 : :
266 : : // ============================================================================
267 : :
268 : : } // namespace accessibility
269 : :
270 : : // ============================================================================
271 : :
272 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|