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 : :
30 : : #include "scitems.hxx"
31 : : #include "AccessiblePreviewTable.hxx"
32 : : #include "AccessiblePreviewCell.hxx"
33 : : #include "AccessiblePreviewHeaderCell.hxx"
34 : : #include "AccessibilityHints.hxx"
35 : : #include "prevwsh.hxx"
36 : : #include "miscuno.hxx"
37 : : #include "prevloc.hxx"
38 : : #include "attrib.hxx"
39 : : #include "document.hxx"
40 : : #include "scresid.hxx"
41 : : #include "sc.hrc"
42 : :
43 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
44 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
45 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
46 : :
47 : : #include <vcl/window.hxx>
48 : : #include <vcl/svapp.hxx>
49 : : #include <svl/smplhint.hxx>
50 : : #include <unotools/accessiblestatesethelper.hxx>
51 : : #include <comphelper/sequence.hxx>
52 : : #include <comphelper/servicehelper.hxx>
53 : :
54 : : using namespace ::com::sun::star;
55 : : using namespace ::com::sun::star::accessibility;
56 : :
57 : : //===== internal ============================================================
58 : :
59 : 31 : ScAccessiblePreviewTable::ScAccessiblePreviewTable( const ::com::sun::star::uno::Reference<
60 : : ::com::sun::star::accessibility::XAccessible>& rxParent,
61 : : ScPreviewShell* pViewShell, sal_Int32 nIndex ) :
62 : : ScAccessibleContextBase( rxParent, AccessibleRole::TABLE ),
63 : : mpViewShell( pViewShell ),
64 : : mnIndex( nIndex ),
65 : 31 : mpTableInfo( NULL )
66 : : {
67 [ + - ]: 31 : if (mpViewShell)
68 [ + - ]: 31 : mpViewShell->AddAccessibilityObject(*this);
69 : 31 : }
70 : :
71 : 31 : ScAccessiblePreviewTable::~ScAccessiblePreviewTable()
72 : : {
73 [ - + ][ # # ]: 31 : if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
[ - + ]
74 : : {
75 : : // increment refcount to prevent double call off dtor
76 [ # # ]: 0 : osl_incrementInterlockedCount( &m_refCount );
77 [ # # ]: 0 : dispose();
78 : : }
79 [ - + ]: 62 : }
80 : :
81 : 31 : void SAL_CALL ScAccessiblePreviewTable::disposing()
82 : : {
83 [ + - ]: 31 : SolarMutexGuard aGuard;
84 [ + - ]: 31 : if (mpViewShell)
85 : : {
86 [ + - ]: 31 : mpViewShell->RemoveAccessibilityObject(*this);
87 : 31 : mpViewShell = NULL;
88 : : }
89 : :
90 [ + + ]: 31 : if (mpTableInfo)
91 [ + - ][ + - ]: 13 : DELETEZ (mpTableInfo);
92 : :
93 [ + - ][ + - ]: 31 : ScAccessibleContextBase::disposing();
94 : 31 : }
95 : :
96 : : //===== SfxListener =====================================================
97 : :
98 : 38 : void ScAccessiblePreviewTable::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
99 : : {
100 [ + + ]: 38 : if (rHint.ISA( SfxSimpleHint ))
101 : : {
102 : 23 : const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
103 : 23 : sal_uLong nId = rRef.GetId();
104 [ + + ]: 23 : if ( nId == SFX_HINT_DATACHANGED )
105 : : {
106 : : // column / row layout may change with any document change,
107 : : // so it must be invalidated
108 [ + - ]: 18 : DELETEZ( mpTableInfo );
109 : : }
110 [ + - ]: 5 : else if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED)
111 : : {
112 [ + - ]: 5 : AccessibleEventObject aEvent;
113 : 5 : aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
114 [ + - ][ + - ]: 5 : aEvent.Source = uno::Reference< XAccessibleContext >(this);
115 [ + - ][ + - ]: 5 : CommitChange(aEvent);
116 : : }
117 : : }
118 : :
119 : 38 : ScAccessibleContextBase::Notify(rBC, rHint);
120 : 38 : }
121 : :
122 : : //===== XInterface =====================================================
123 : :
124 : 320 : uno::Any SAL_CALL ScAccessiblePreviewTable::queryInterface( uno::Type const & rType )
125 : : throw (uno::RuntimeException)
126 : : {
127 [ + - ]: 320 : uno::Any aAny (ScAccessiblePreviewTableImpl::queryInterface(rType));
128 [ + + ][ + - ]: 320 : return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
129 : : }
130 : :
131 : 1752 : void SAL_CALL ScAccessiblePreviewTable::acquire()
132 : : throw ()
133 : : {
134 : 1752 : ScAccessibleContextBase::acquire();
135 : 1752 : }
136 : :
137 : 1752 : void SAL_CALL ScAccessiblePreviewTable::release()
138 : : throw ()
139 : : {
140 : 1752 : ScAccessibleContextBase::release();
141 : 1752 : }
142 : :
143 : : //===== XAccessibleTable ================================================
144 : :
145 : 1 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowCount() throw (uno::RuntimeException)
146 : : {
147 [ + - ]: 1 : SolarMutexGuard aGuard;
148 [ + - ]: 1 : IsObjectValid();
149 : :
150 [ + - ]: 1 : FillTableInfo();
151 : :
152 : 1 : sal_Int32 nRet = 0;
153 [ + - ]: 1 : if ( mpTableInfo )
154 : 1 : nRet = mpTableInfo->GetRows();
155 [ + - ]: 1 : return nRet;
156 : : }
157 : :
158 : 1 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnCount() throw (uno::RuntimeException)
159 : : {
160 [ + - ]: 1 : SolarMutexGuard aGuard;
161 [ + - ]: 1 : IsObjectValid();
162 : :
163 [ + - ]: 1 : FillTableInfo();
164 : :
165 : 1 : sal_Int32 nRet = 0;
166 [ + - ]: 1 : if ( mpTableInfo )
167 : 1 : nRet = mpTableInfo->GetCols();
168 [ + - ]: 1 : return nRet;
169 : : }
170 : :
171 : 3 : rtl::OUString SAL_CALL ScAccessiblePreviewTable::getAccessibleRowDescription( sal_Int32 nRow )
172 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
173 : : {
174 [ + - ]: 3 : SolarMutexGuard aGuard;
175 [ + - ]: 3 : FillTableInfo();
176 [ + + ][ + - ]: 3 : if ( nRow < 0 || (mpTableInfo && nRow >= mpTableInfo->GetRows()) )
[ + + ][ + + ]
177 [ + - ]: 2 : throw lang::IndexOutOfBoundsException();
178 : :
179 [ + - ]: 3 : return rtl::OUString();
180 : : }
181 : :
182 : 3 : rtl::OUString SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnDescription( sal_Int32 nColumn )
183 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
184 : : {
185 [ + - ]: 3 : SolarMutexGuard aGuard;
186 [ + - ]: 3 : FillTableInfo();
187 [ + + ][ + - ]: 3 : if ( nColumn < 0 || (mpTableInfo && nColumn >= mpTableInfo->GetCols()) )
[ + + ][ + + ]
188 [ + - ]: 2 : throw lang::IndexOutOfBoundsException();
189 : :
190 [ + - ]: 3 : return rtl::OUString();
191 : : }
192 : :
193 : 5 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
194 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
195 : : {
196 [ + - ]: 5 : SolarMutexGuard aGuard;
197 [ + - ]: 5 : IsObjectValid();
198 : :
199 [ + - ]: 5 : FillTableInfo();
200 : :
201 : 5 : sal_Int32 nRows = 1;
202 [ + - ][ + - ]: 10 : if ( mpViewShell && mpTableInfo && nColumn >= 0 && nRow >= 0 &&
[ + + ][ + +
+ + + + ]
[ + + ]
203 : 5 : nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
204 : : {
205 : 1 : const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[nColumn];
206 : 1 : const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[nRow];
207 : :
208 [ + - ][ + - ]: 1 : if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
209 : : {
210 : : // header cells only span a single cell
211 : : }
212 : : else
213 : : {
214 [ + - ]: 1 : ScDocument* pDoc = mpViewShell->GetDocument();
215 : : const ScMergeAttr* pItem = (const ScMergeAttr*)pDoc->GetAttr(
216 [ + - ]: 1 : static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab(), ATTR_MERGE );
217 [ + - ][ - + ]: 1 : if ( pItem && pItem->GetRowMerge() > 0 )
[ - + ]
218 : 0 : nRows = pItem->GetRowMerge();
219 : : }
220 : : }
221 : : else
222 [ + - ]: 4 : throw lang::IndexOutOfBoundsException();
223 : :
224 [ + - ]: 5 : return nRows;
225 : : }
226 : :
227 : 5 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
228 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
229 : : {
230 [ + - ]: 5 : SolarMutexGuard aGuard;
231 [ + - ]: 5 : IsObjectValid();
232 : :
233 [ + - ]: 5 : FillTableInfo();
234 : :
235 : 5 : sal_Int32 nColumns = 1;
236 [ + - ][ + - ]: 10 : if ( mpViewShell && mpTableInfo && nColumn >= 0 && nRow >= 0 &&
[ + + ][ + +
+ + + + ]
[ + + ]
237 : 5 : nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
238 : : {
239 : 1 : const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[nColumn];
240 : 1 : const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[nRow];
241 : :
242 [ + - ][ + - ]: 1 : if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
243 : : {
244 : : // header cells only span a single cell
245 : : }
246 : : else
247 : : {
248 [ + - ]: 1 : ScDocument* pDoc = mpViewShell->GetDocument();
249 : : const ScMergeAttr* pItem = (const ScMergeAttr*)pDoc->GetAttr(
250 [ + - ]: 1 : static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab(), ATTR_MERGE );
251 [ + - ][ - + ]: 1 : if ( pItem && pItem->GetColMerge() > 0 )
[ - + ]
252 : 0 : nColumns = pItem->GetColMerge();
253 : : }
254 : : }
255 : : else
256 [ + - ]: 4 : throw lang::IndexOutOfBoundsException();
257 : :
258 [ + - ]: 5 : return nColumns;
259 : : }
260 : :
261 : 1 : uno::Reference< XAccessibleTable > SAL_CALL ScAccessiblePreviewTable::getAccessibleRowHeaders() throw (uno::RuntimeException)
262 : : {
263 : : //! missing
264 : 1 : return NULL;
265 : : }
266 : :
267 : 1 : uno::Reference< XAccessibleTable > SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnHeaders() throw (uno::RuntimeException)
268 : : {
269 : : //! missing
270 : 1 : return NULL;
271 : : }
272 : :
273 : 1 : uno::Sequence< sal_Int32 > SAL_CALL ScAccessiblePreviewTable::getSelectedAccessibleRows() throw (uno::RuntimeException)
274 : : {
275 : : // in the page preview, there is no selection
276 : 1 : return uno::Sequence<sal_Int32>(0);
277 : : }
278 : :
279 : 1 : uno::Sequence< sal_Int32 > SAL_CALL ScAccessiblePreviewTable::getSelectedAccessibleColumns() throw (uno::RuntimeException)
280 : : {
281 : : // in the page preview, there is no selection
282 : 1 : return uno::Sequence<sal_Int32>(0);
283 : : }
284 : :
285 : 3 : sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleRowSelected( sal_Int32 nRow )
286 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
287 : : {
288 : : // in the page preview, there is no selection
289 : :
290 [ + - ]: 3 : SolarMutexGuard aGuard;
291 [ + - ]: 3 : FillTableInfo();
292 [ + + ][ + - ]: 3 : if ( nRow < 0 || (mpTableInfo && nRow >= mpTableInfo->GetRows()) )
[ + + ][ + + ]
293 [ + - ]: 2 : throw lang::IndexOutOfBoundsException();
294 : :
295 [ + - ]: 3 : return false;
296 : : }
297 : :
298 : 3 : sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleColumnSelected( sal_Int32 nColumn )
299 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
300 : : {
301 : : // in the page preview, there is no selection
302 : :
303 [ + - ]: 3 : SolarMutexGuard aGuard;
304 [ + - ]: 3 : FillTableInfo();
305 [ + + ][ + - ]: 3 : if ( nColumn < 0 || (mpTableInfo && nColumn >= mpTableInfo->GetCols()) )
[ + + ][ + + ]
306 [ + - ]: 2 : throw lang::IndexOutOfBoundsException();
307 : :
308 [ + - ]: 3 : return false;
309 : : }
310 : :
311 : 40 : uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
312 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
313 : : {
314 [ + - ]: 40 : SolarMutexGuard aGuard;
315 [ + - ]: 40 : IsObjectValid();
316 : :
317 [ + - ]: 40 : FillTableInfo();
318 : :
319 : 40 : uno::Reference<XAccessible> xRet;
320 [ + + ][ + + ]: 40 : if ( mpTableInfo && nColumn >= 0 && nRow >= 0 && nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
[ + + ][ + + ]
[ + + ][ + - ]
321 : : {
322 : : // index iterates horizontally
323 : 36 : long nNewIndex = nRow * mpTableInfo->GetCols() + nColumn;
324 : :
325 : 36 : const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[nColumn];
326 : 36 : const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[nRow];
327 : :
328 : 36 : ScAddress aCellPos( static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab() );
329 [ + + ][ + + ]: 36 : if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
330 : : {
331 : : ScAccessiblePreviewHeaderCell* pHeaderCell = new ScAccessiblePreviewHeaderCell( this, mpViewShell, aCellPos,
332 [ + - ][ + - ]: 14 : rRowInfo.bIsHeader, rColInfo.bIsHeader, nNewIndex );
333 [ + - ][ + - ]: 14 : xRet = pHeaderCell;
334 [ + - ]: 14 : pHeaderCell->Init();
335 : : }
336 : : else
337 : : {
338 [ + - ][ + - ]: 22 : ScAccessiblePreviewCell* pCell = new ScAccessiblePreviewCell( this, mpViewShell, aCellPos, nNewIndex );
339 [ + - ][ + - ]: 22 : xRet = pCell;
340 [ + - ]: 36 : pCell->Init();
341 : : }
342 : : }
343 : :
344 [ + + ]: 40 : if ( !xRet.is() )
345 [ + - ]: 4 : throw lang::IndexOutOfBoundsException();
346 : :
347 [ + - ]: 40 : return xRet;
348 : : }
349 : :
350 : 1 : uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleCaption() throw (uno::RuntimeException)
351 : : {
352 : : //! missing
353 : 1 : return NULL;
354 : : }
355 : :
356 : 1 : uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleSummary() throw (uno::RuntimeException)
357 : : {
358 : : //! missing
359 : 1 : return NULL;
360 : : }
361 : :
362 : 5 : sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
363 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
364 : : {
365 : : // in the page preview, there is no selection
366 [ + - ]: 5 : SolarMutexGuard aGuard;
367 [ + - ]: 5 : IsObjectValid();
368 : :
369 [ + - ]: 5 : FillTableInfo();
370 : :
371 [ + - ][ + + ]: 5 : if ( mpTableInfo && nColumn >= 0 && nRow >= 0 && nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
[ + + ][ + + ]
[ + + ][ + + ]
372 : : {
373 : : // index iterates horizontally
374 : : }
375 : : else
376 [ + - ]: 4 : throw lang::IndexOutOfBoundsException();
377 : :
378 [ + - ]: 5 : return false;
379 : : }
380 : :
381 : 5 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
382 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
383 : : {
384 [ + - ]: 5 : SolarMutexGuard aGuard;
385 [ + - ]: 5 : IsObjectValid();
386 : :
387 [ + - ]: 5 : FillTableInfo();
388 : :
389 : 5 : sal_Int32 nRet = 0;
390 [ + - ][ + + ]: 5 : if ( mpTableInfo && nColumn >= 0 && nRow >= 0 && nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
[ + + ][ + + ]
[ + + ][ + + ]
391 : : {
392 : : // index iterates horizontally
393 : 1 : nRet = nRow * mpTableInfo->GetCols() + nColumn;
394 : : }
395 : : else
396 [ + - ]: 5 : throw lang::IndexOutOfBoundsException();
397 : :
398 [ + - ]: 6 : return nRet;
399 : : }
400 : :
401 : 4 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRow( sal_Int32 nChildIndex )
402 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
403 : : {
404 [ + - ]: 4 : SolarMutexGuard aGuard;
405 [ + - ]: 4 : IsObjectValid();
406 : :
407 [ + - ]: 4 : FillTableInfo();
408 : :
409 : 4 : sal_Int32 nRow = 0;
410 [ + - ][ + + ]: 4 : if ( mpTableInfo && nChildIndex >= 0 && nChildIndex < static_cast<sal_Int32>(mpTableInfo->GetRows()) * mpTableInfo->GetCols() )
[ + + ][ + + ]
411 : : {
412 : 2 : nRow = nChildIndex / mpTableInfo->GetCols();
413 : : }
414 : : else
415 [ + - ]: 4 : throw lang::IndexOutOfBoundsException();
416 : :
417 [ + - ]: 6 : return nRow;
418 : : }
419 : :
420 : 4 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumn( sal_Int32 nChildIndex )
421 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
422 : : {
423 [ + - ]: 4 : SolarMutexGuard aGuard;
424 [ + - ]: 4 : IsObjectValid();
425 : :
426 [ + - ]: 4 : FillTableInfo();
427 : :
428 : 4 : sal_Int32 nCol = 0;
429 [ + - ][ + + ]: 4 : if ( mpTableInfo && nChildIndex >= 0 && nChildIndex < static_cast<sal_Int32>(mpTableInfo->GetRows()) * mpTableInfo->GetCols() )
[ + + ][ + + ]
430 : : {
431 : 2 : nCol = nChildIndex % static_cast<sal_Int32>(mpTableInfo->GetCols());
432 : : }
433 : : else
434 [ + - ]: 4 : throw lang::IndexOutOfBoundsException();
435 : :
436 [ + - ]: 6 : return nCol;
437 : : }
438 : :
439 : : //===== XAccessibleComponent ============================================
440 : :
441 : 0 : uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleAtPoint( const awt::Point& aPoint )
442 : : throw (uno::RuntimeException)
443 : : {
444 : 0 : uno::Reference<XAccessible> xRet;
445 [ # # ][ # # ]: 0 : if (containsPoint(aPoint))
446 : : {
447 [ # # ]: 0 : SolarMutexGuard aGuard;
448 [ # # ]: 0 : IsObjectValid();
449 : :
450 [ # # ]: 0 : FillTableInfo();
451 : :
452 [ # # ]: 0 : if ( mpTableInfo )
453 : : {
454 : 0 : SCCOL nCols = mpTableInfo->GetCols();
455 : 0 : SCROW nRows = mpTableInfo->GetRows();
456 : 0 : const ScPreviewColRowInfo* pColInfo = mpTableInfo->GetColInfo();
457 : 0 : const ScPreviewColRowInfo* pRowInfo = mpTableInfo->GetRowInfo();
458 : :
459 [ # # ]: 0 : Rectangle aScreenRect(GetBoundingBox());
460 : :
461 : 0 : awt::Point aMovedPoint = aPoint;
462 : 0 : aMovedPoint.X += aScreenRect.Left();
463 : 0 : aMovedPoint.Y += aScreenRect.Top();
464 : :
465 [ # # ][ # # ]: 0 : if ( nCols > 0 && nRows > 0 && aMovedPoint.X >= pColInfo[0].nPixelStart && aMovedPoint.Y >= pRowInfo[0].nPixelStart )
[ # # ][ # # ]
466 : : {
467 : 0 : SCCOL nColIndex = 0;
468 [ # # ][ # # ]: 0 : while ( nColIndex < nCols && aMovedPoint.X > pColInfo[nColIndex].nPixelEnd )
[ # # ]
469 : 0 : ++nColIndex;
470 : 0 : SCROW nRowIndex = 0;
471 [ # # ][ # # ]: 0 : while ( nRowIndex < nRows && aMovedPoint.Y > pRowInfo[nRowIndex].nPixelEnd )
[ # # ]
472 : 0 : ++nRowIndex;
473 [ # # ][ # # ]: 0 : if ( nColIndex < nCols && nRowIndex < nRows )
474 : : {
475 : : try
476 : : {
477 [ # # ][ # # ]: 0 : xRet = getAccessibleCellAt( nRowIndex, nColIndex );
[ # # ]
478 : : }
479 [ # # ]: 0 : catch (uno::Exception&)
480 : : {
481 : : }
482 : : }
483 : : }
484 [ # # ]: 0 : }
485 : : }
486 : :
487 : 0 : return xRet;
488 : : }
489 : :
490 : 2 : void SAL_CALL ScAccessiblePreviewTable::grabFocus() throw (uno::RuntimeException)
491 : : {
492 [ + - ]: 2 : SolarMutexGuard aGuard;
493 [ + - ]: 2 : IsObjectValid();
494 [ + - ][ + - ]: 2 : if (getAccessibleParent().is())
495 : : {
496 [ + - ][ + - ]: 2 : uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
[ + - ][ + - ]
497 [ + - ]: 2 : if (xAccessibleComponent.is())
498 [ + - ][ + - ]: 2 : xAccessibleComponent->grabFocus();
499 [ + - ]: 2 : }
500 : 2 : }
501 : :
502 : : //===== XAccessibleContext ==============================================
503 : :
504 : 58 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleChildCount() throw (uno::RuntimeException)
505 : : {
506 [ + - ]: 58 : SolarMutexGuard aGuard;
507 [ + - ]: 58 : IsObjectValid();
508 : :
509 [ + - ]: 58 : FillTableInfo();
510 : :
511 : 58 : long nRet = 0;
512 [ + - ]: 58 : if ( mpTableInfo )
513 : 58 : nRet = static_cast<sal_Int32>(mpTableInfo->GetCols()) * mpTableInfo->GetRows();
514 [ + - ]: 58 : return nRet;
515 : : }
516 : :
517 : 35 : uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleChild( sal_Int32 nIndex )
518 : : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
519 : : {
520 [ + - ]: 35 : SolarMutexGuard aGuard;
521 [ + - ]: 35 : IsObjectValid();
522 : :
523 [ + - ]: 35 : FillTableInfo();
524 : :
525 : 35 : uno::Reference<XAccessible> xRet;
526 [ + - ]: 35 : if ( mpTableInfo )
527 : : {
528 : 35 : long nColumns = mpTableInfo->GetCols();
529 [ + - ]: 35 : if ( nColumns > 0 )
530 : : {
531 : : // nCol, nRow are within the visible table, not the document
532 : 35 : long nCol = nIndex % nColumns;
533 : 35 : long nRow = nIndex / nColumns;
534 : :
535 [ + - ][ + - ]: 35 : xRet = getAccessibleCellAt( nRow, nCol );
536 : : }
537 : : }
538 : :
539 [ - + ]: 35 : if ( !xRet.is() )
540 [ # # ]: 0 : throw lang::IndexOutOfBoundsException();
541 : :
542 [ + - ]: 35 : return xRet;
543 : : }
544 : :
545 : 1 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleIndexInParent() throw (uno::RuntimeException)
546 : : {
547 : 1 : return mnIndex;
548 : : }
549 : :
550 : 42 : uno::Reference< XAccessibleStateSet > SAL_CALL ScAccessiblePreviewTable::getAccessibleStateSet()
551 : : throw (uno::RuntimeException)
552 : : {
553 [ + - ]: 42 : SolarMutexGuard aGuard;
554 : 42 : uno::Reference<XAccessibleStateSet> xParentStates;
555 [ + - ][ + - ]: 42 : if (getAccessibleParent().is())
556 : : {
557 [ + - ][ + - ]: 42 : uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
[ + - ]
558 [ + - ][ + - ]: 42 : xParentStates = xParentContext->getAccessibleStateSet();
[ + - ]
559 : : }
560 [ + - ]: 42 : utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
561 [ + - ][ - + ]: 42 : if (IsDefunc(xParentStates))
562 [ # # ]: 0 : pStateSet->AddState(AccessibleStateType::DEFUNC);
563 : : else
564 : : {
565 [ + - ]: 42 : pStateSet->AddState(AccessibleStateType::MANAGES_DESCENDANTS);
566 [ + - ]: 42 : pStateSet->AddState(AccessibleStateType::ENABLED);
567 [ + - ]: 42 : pStateSet->AddState(AccessibleStateType::OPAQUE);
568 [ + - ][ + - ]: 42 : if (isShowing())
569 [ + - ]: 42 : pStateSet->AddState(AccessibleStateType::SHOWING);
570 [ + - ][ + - ]: 42 : if (isVisible())
571 [ + - ]: 42 : pStateSet->AddState(AccessibleStateType::VISIBLE);
572 : : }
573 [ + - ][ + - ]: 42 : return pStateSet;
[ + - ]
574 : : }
575 : :
576 : : //===== XServiceInfo ====================================================
577 : :
578 : 1 : rtl::OUString SAL_CALL ScAccessiblePreviewTable::getImplementationName() throw(uno::RuntimeException)
579 : : {
580 : 1 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAccessiblePreviewTable"));
581 : : }
582 : :
583 : 0 : uno::Sequence<rtl::OUString> SAL_CALL ScAccessiblePreviewTable::getSupportedServiceNames()
584 : : throw(uno::RuntimeException)
585 : : {
586 : 0 : uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
587 : 0 : sal_Int32 nOldSize(aSequence.getLength());
588 [ # # ]: 0 : aSequence.realloc(nOldSize + 1);
589 [ # # ]: 0 : ::rtl::OUString* pNames = aSequence.getArray();
590 : :
591 [ # # ]: 0 : pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.AccessibleTableView"));
592 : :
593 : 0 : return aSequence;
594 : : }
595 : :
596 : : //===== XTypeProvider ===================================================
597 : :
598 : 0 : uno::Sequence< uno::Type > SAL_CALL ScAccessiblePreviewTable::getTypes()
599 : : throw (uno::RuntimeException)
600 : : {
601 [ # # ][ # # ]: 0 : return comphelper::concatSequences(ScAccessiblePreviewTableImpl::getTypes(), ScAccessibleContextBase::getTypes());
[ # # ]
602 : : }
603 : :
604 : : namespace
605 : : {
606 : : class theScAccessiblePreviewTableImplementationId : public rtl::Static< UnoTunnelIdInit, theScAccessiblePreviewTableImplementationId > {};
607 : : }
608 : :
609 : 0 : uno::Sequence<sal_Int8> SAL_CALL ScAccessiblePreviewTable::getImplementationId()
610 : : throw(uno::RuntimeException)
611 : : {
612 : 0 : return theScAccessiblePreviewTableImplementationId::get().getSeq();
613 : : }
614 : :
615 : : //==== internal =========================================================
616 : :
617 : 54 : ::rtl::OUString SAL_CALL ScAccessiblePreviewTable::createAccessibleDescription(void)
618 : : throw (uno::RuntimeException)
619 : : {
620 [ + - ][ + - ]: 54 : String sDesc(ScResId(STR_ACC_TABLE_DESCR));
621 [ + - ][ + - ]: 54 : return rtl::OUString(sDesc);
622 : : }
623 : :
624 : 31 : ::rtl::OUString SAL_CALL ScAccessiblePreviewTable::createAccessibleName(void)
625 : : throw (uno::RuntimeException)
626 : : {
627 [ + - ][ + - ]: 31 : String sName(ScResId(STR_ACC_TABLE_NAME));
628 : :
629 [ + - ][ + - ]: 31 : if (mpViewShell && mpViewShell->GetDocument())
[ + - ][ + - ]
630 : : {
631 [ + - ]: 31 : FillTableInfo();
632 : :
633 [ + - ]: 31 : if ( mpTableInfo )
634 : : {
635 : 31 : rtl::OUString sCoreName;
636 [ + - ][ + - ]: 31 : if (mpViewShell->GetDocument()->GetName( mpTableInfo->GetTab(), sCoreName ))
[ + - ]
637 [ + - ][ + - ]: 31 : sName.SearchAndReplaceAscii("%1", sCoreName);
[ + - ]
638 : : }
639 : : }
640 : :
641 [ + - ][ + - ]: 31 : return rtl::OUString(sName);
642 : : }
643 : :
644 : 2 : Rectangle ScAccessiblePreviewTable::GetBoundingBoxOnScreen() const throw (uno::RuntimeException)
645 : : {
646 : 2 : Rectangle aCellRect(GetBoundingBox());
647 [ + - ]: 2 : if (mpViewShell)
648 : : {
649 : 2 : Window* pWindow = mpViewShell->GetWindow();
650 [ + - ]: 2 : if (pWindow)
651 : : {
652 [ + - ]: 2 : Rectangle aRect = pWindow->GetWindowExtentsRelative(NULL);
653 : 2 : aCellRect.setX(aCellRect.getX() + aRect.getX());
654 : 2 : aCellRect.setY(aCellRect.getY() + aRect.getY());
655 : : }
656 : : }
657 : 2 : return aCellRect;
658 : : }
659 : :
660 : 269 : Rectangle ScAccessiblePreviewTable::GetBoundingBox() const throw (uno::RuntimeException)
661 : : {
662 : 269 : FillTableInfo();
663 : :
664 : 269 : Rectangle aRect;
665 [ + - ]: 269 : if ( mpTableInfo )
666 : : {
667 : 269 : SCCOL nColumns = mpTableInfo->GetCols();
668 : 269 : SCROW nRows = mpTableInfo->GetRows();
669 [ + - ][ + - ]: 269 : if ( nColumns > 0 && nRows > 0 )
670 : : {
671 : 269 : const ScPreviewColRowInfo* pColInfo = mpTableInfo->GetColInfo();
672 : 269 : const ScPreviewColRowInfo* pRowInfo = mpTableInfo->GetRowInfo();
673 : :
674 : : aRect = Rectangle( pColInfo[0].nPixelStart,
675 : : pRowInfo[0].nPixelStart,
676 : 269 : pColInfo[nColumns-1].nPixelEnd,
677 : 269 : pRowInfo[nRows-1].nPixelEnd );
678 : : }
679 : : }
680 : 269 : return aRect;
681 : : }
682 : :
683 : 42 : sal_Bool ScAccessiblePreviewTable::IsDefunc( const uno::Reference<XAccessibleStateSet>& rxParentStates )
684 : : {
685 [ + - ][ + - ]: 126 : return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() ||
[ # # ]
686 [ + - + - ]: 126 : (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
[ + - ][ + - ]
[ + - ][ - + ]
[ + - ]
687 : : }
688 : :
689 : 475 : void ScAccessiblePreviewTable::FillTableInfo() const
690 : : {
691 [ + - ][ + + ]: 475 : if ( mpViewShell && !mpTableInfo )
692 : : {
693 : 31 : Size aOutputSize;
694 : 31 : Window* pWindow = mpViewShell->GetWindow();
695 [ + - ]: 31 : if ( pWindow )
696 : 31 : aOutputSize = pWindow->GetOutputSizePixel();
697 : 31 : Point aPoint;
698 [ + - ]: 31 : Rectangle aVisRect( aPoint, aOutputSize );
699 : :
700 [ + - ][ + - ]: 31 : mpTableInfo = new ScPreviewTableInfo;
701 [ + - ][ + - ]: 31 : mpViewShell->GetLocationData().GetTableInfo( aVisRect, *mpTableInfo );
702 : : }
703 : 475 : }
704 : :
705 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|