Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <osl/mutex.hxx>
21 : #include <rtl/ustrbuf.hxx>
22 :
23 : #include <algorithm>
24 : #include <list>
25 : #include <set>
26 : #include <com/sun/star/accessibility/AccessibleRole.hpp>
27 : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
28 : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
29 : #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
30 : #include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
31 : #include <unotools/accessiblestatesethelper.hxx>
32 : #include <vcl/svapp.hxx>
33 : #include <frmfmt.hxx>
34 : #include <tabfrm.hxx>
35 : #include <rowfrm.hxx>
36 : #include <cellfrm.hxx>
37 : #include <swtable.hxx>
38 : #include <crsrsh.hxx>
39 : #include <viscrs.hxx>
40 : #include <hints.hxx>
41 : #include <fesh.hxx>
42 : #include <accfrmobjslist.hxx>
43 : #include <accmap.hxx>
44 : #include <access.hrc>
45 : #include <acctable.hxx>
46 :
47 : #include <com/sun/star/accessibility/XAccessibleText.hpp>
48 : #include <comphelper/servicehelper.hxx>
49 :
50 : using namespace ::com::sun::star;
51 : using namespace ::com::sun::star::accessibility;
52 : using ::rtl::OUString;
53 : using ::rtl::OUStringBuffer;
54 : using namespace ::sw::access;
55 :
56 : const sal_Char sServiceName[] = "com.sun.star.table.AccessibleTableView";
57 : const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleTableView";
58 :
59 : typedef ::std::less < sal_Int32 > Int32Less_Impl;
60 : typedef ::std::set < sal_Int32, Int32Less_Impl > Int32Set_Impl;
61 :
62 : typedef ::std::pair < sal_Int32, sal_Int32 > Int32Pair_Impl;
63 : typedef ::std::list < Int32Pair_Impl > Int32PairList_Impl;
64 :
65 0 : class SwAccTableSelHander_Impl
66 : {
67 : public:
68 : virtual void Unselect( sal_Int32 nRowOrCol, sal_Int32 nExt ) = 0;
69 :
70 : protected:
71 0 : ~SwAccTableSelHander_Impl() {}
72 : };
73 :
74 :
75 : //------------------------------------------------------------------------------
76 :
77 0 : class SwAccessibleTableData_Impl
78 : {
79 : SwAccessibleMap& mrAccMap;
80 : Int32Set_Impl maRows;
81 : Int32Set_Impl maColumns;
82 : Int32PairList_Impl maExtents; // cell extends for event processing only
83 : Point maTabFrmPos;
84 : const SwTabFrm *mpTabFrm;
85 : sal_Bool mbIsInPagePreview;
86 : bool mbOnlyTableColumnHeader;
87 :
88 : void CollectData( const SwFrm *pFrm );
89 : void CollectExtents( const SwFrm *pFrm );
90 :
91 : sal_Bool FindCell( const Point& rPos, const SwFrm *pFrm ,
92 : sal_Bool bExact, const SwFrm *& rFrm ) const;
93 :
94 : void GetSelection( const Point& rTabPos, const SwRect& rArea,
95 : const SwSelBoxes& rSelBoxes, const SwFrm *pFrm,
96 : SwAccTableSelHander_Impl& rSelHdl,
97 : sal_Bool bColumns ) const;
98 :
99 : // #i77106#
100 0 : inline bool IncludeRow( const SwFrm& rFrm ) const
101 : {
102 0 : return !mbOnlyTableColumnHeader ||
103 0 : mpTabFrm->IsInHeadline( rFrm );
104 : }
105 : public:
106 : // #i77106# - add third optional parameter <bOnlyTableColumnHeader>, default value <false>
107 : SwAccessibleTableData_Impl( SwAccessibleMap& rAccMap,
108 : const SwTabFrm *pTabFrm,
109 : sal_Bool bIsInPagePreview,
110 : bool bOnlyTableColumnHeader = false );
111 :
112 0 : const Int32Set_Impl& GetRows() const { return maRows; }
113 0 : const Int32Set_Impl& GetColumns() const { return maColumns; }
114 :
115 : inline Int32Set_Impl::const_iterator GetRowIter( sal_Int32 nRow ) const;
116 : inline Int32Set_Impl::const_iterator GetColumnIter( sal_Int32 nCol ) const;
117 :
118 : const SwFrm *GetCell( sal_Int32 nRow, sal_Int32 nColumn, sal_Bool bExact,
119 : SwAccessibleTable *pThis ) const
120 : throw(lang::IndexOutOfBoundsException );
121 : const SwFrm *GetCellAtPos( sal_Int32 nLeft, sal_Int32 nTop,
122 : sal_Bool bExact ) const;
123 : inline sal_Int32 GetRowCount() const;
124 : inline sal_Int32 GetColumnCount() const;
125 : sal_Bool CompareExtents( const SwAccessibleTableData_Impl& r ) const;
126 :
127 : void GetSelection( sal_Int32 nStart, sal_Int32 nEnd,
128 : const SwSelBoxes& rSelBoxes,
129 : SwAccTableSelHander_Impl& rSelHdl,
130 : sal_Bool bColumns ) const;
131 :
132 : void CheckRowAndCol( sal_Int32 nRow, sal_Int32 nCol,
133 : SwAccessibleTable *pThis ) const
134 : throw(lang::IndexOutOfBoundsException );
135 :
136 : void GetRowColumnAndExtent( const SwRect& rBox,
137 : sal_Int32& rRow, sal_Int32& rColumn,
138 : sal_Int32& rRowExtent,
139 : sal_Int32& rColumnExtent ) const;
140 :
141 : const Point& GetTablePos() const { return maTabFrmPos; }
142 0 : void SetTablePos( const Point& rPos ) { maTabFrmPos = rPos; }
143 : };
144 :
145 0 : void SwAccessibleTableData_Impl::CollectData( const SwFrm *pFrm )
146 : {
147 0 : const SwAccessibleChildSList aList( *pFrm, mrAccMap );
148 0 : SwAccessibleChildSList::const_iterator aIter( aList.begin() );
149 0 : SwAccessibleChildSList::const_iterator aEndIter( aList.end() );
150 0 : while( aIter != aEndIter )
151 : {
152 0 : const SwAccessibleChild& rLower = *aIter;
153 0 : const SwFrm *pLower = rLower.GetSwFrm();
154 0 : if( pLower )
155 : {
156 0 : if( pLower->IsRowFrm() )
157 : {
158 : // #i77106#
159 0 : if ( IncludeRow( *pLower ) )
160 : {
161 0 : maRows.insert( pLower->Frm().Top() - maTabFrmPos.Y() );
162 0 : CollectData( pLower );
163 : }
164 : }
165 0 : else if( pLower->IsCellFrm() &&
166 0 : rLower.IsAccessible( mbIsInPagePreview ) )
167 : {
168 0 : maColumns.insert( pLower->Frm().Left() - maTabFrmPos.X() );
169 : }
170 : else
171 : {
172 0 : CollectData( pLower );
173 : }
174 : }
175 0 : ++aIter;
176 : }
177 0 : }
178 :
179 0 : void SwAccessibleTableData_Impl::CollectExtents( const SwFrm *pFrm )
180 : {
181 0 : const SwAccessibleChildSList aList( *pFrm, mrAccMap );
182 0 : SwAccessibleChildSList::const_iterator aIter( aList.begin() );
183 0 : SwAccessibleChildSList::const_iterator aEndIter( aList.end() );
184 0 : while( aIter != aEndIter )
185 : {
186 0 : const SwAccessibleChild& rLower = *aIter;
187 0 : const SwFrm *pLower = rLower.GetSwFrm();
188 0 : if( pLower )
189 : {
190 0 : if( pLower->IsCellFrm() &&
191 0 : rLower.IsAccessible( mbIsInPagePreview ) )
192 : {
193 : sal_Int32 nRow, nCol;
194 0 : Int32Pair_Impl aCellExtents;
195 0 : GetRowColumnAndExtent( pLower->Frm(), nRow, nCol,
196 : aCellExtents.first,
197 0 : aCellExtents.second );
198 :
199 0 : maExtents.push_back( aCellExtents );
200 : }
201 : else
202 : {
203 : // #i77106#
204 0 : if ( !pLower->IsRowFrm() ||
205 0 : IncludeRow( *pLower ) )
206 : {
207 0 : CollectExtents( pLower );
208 : }
209 : }
210 : }
211 0 : ++aIter;
212 : }
213 0 : }
214 :
215 0 : sal_Bool SwAccessibleTableData_Impl::FindCell(
216 : const Point& rPos, const SwFrm *pFrm, sal_Bool bExact,
217 : const SwFrm *& rRet ) const
218 : {
219 0 : sal_Bool bFound = sal_False;
220 :
221 0 : const SwAccessibleChildSList aList( *pFrm, mrAccMap );
222 0 : SwAccessibleChildSList::const_iterator aIter( aList.begin() );
223 0 : SwAccessibleChildSList::const_iterator aEndIter( aList.end() );
224 0 : while( !bFound && aIter != aEndIter )
225 : {
226 0 : const SwAccessibleChild& rLower = *aIter;
227 0 : const SwFrm *pLower = rLower.GetSwFrm();
228 : OSL_ENSURE( pLower, "child should be a frame" );
229 0 : if( pLower )
230 : {
231 0 : if( rLower.IsAccessible( mbIsInPagePreview ) )
232 : {
233 : OSL_ENSURE( pLower->IsCellFrm(), "lower is not a cell frame" );
234 0 : const SwRect& rFrm = pLower->Frm();
235 0 : if( rFrm.Right() >= rPos.X() && rFrm.Bottom() >= rPos.Y() )
236 : {
237 : // We have found the cell
238 : OSL_ENSURE( rFrm.Left() <= rPos.X() && rFrm.Top() <= rPos.Y(),
239 : "find frame moved to far!" );
240 0 : bFound = sal_True;
241 0 : if( !bExact ||
242 0 : (rFrm.Top() == rPos.Y() && rFrm.Left() == rPos.Y() ) )
243 : {
244 0 : rRet = pLower;
245 : }
246 : }
247 : }
248 : else
249 : {
250 : // #i77106#
251 0 : if ( !pLower->IsRowFrm() ||
252 0 : IncludeRow( *pLower ) )
253 : {
254 0 : bFound = FindCell( rPos, pLower, bExact, rRet );
255 : }
256 : }
257 : }
258 0 : ++aIter;
259 : }
260 :
261 0 : return bFound;
262 : }
263 :
264 0 : void SwAccessibleTableData_Impl::GetSelection(
265 : const Point& rTabPos,
266 : const SwRect& rArea,
267 : const SwSelBoxes& rSelBoxes,
268 : const SwFrm *pFrm,
269 : SwAccTableSelHander_Impl& rSelHdl,
270 : sal_Bool bColumns ) const
271 : {
272 0 : const SwAccessibleChildSList aList( *pFrm, mrAccMap );
273 0 : SwAccessibleChildSList::const_iterator aIter( aList.begin() );
274 0 : SwAccessibleChildSList::const_iterator aEndIter( aList.end() );
275 0 : while( aIter != aEndIter )
276 : {
277 0 : const SwAccessibleChild& rLower = *aIter;
278 0 : const SwFrm *pLower = rLower.GetSwFrm();
279 : OSL_ENSURE( pLower, "child should be a frame" );
280 0 : const SwRect& rBox = rLower.GetBox( mrAccMap );
281 0 : if( pLower && rBox.IsOver( rArea ) )
282 : {
283 0 : if( rLower.IsAccessible( mbIsInPagePreview ) )
284 : {
285 : OSL_ENSURE( pLower->IsCellFrm(), "lower is not a cell frame" );
286 : const SwCellFrm *pCFrm =
287 0 : static_cast < const SwCellFrm * >( pLower );
288 : SwTableBox *pBox =
289 0 : const_cast< SwTableBox *>( pCFrm->GetTabBox() );
290 0 : if( rSelBoxes.find( pBox ) == rSelBoxes.end() )
291 : {
292 : const Int32Set_Impl rRowsOrCols =
293 0 : bColumns ? maColumns : maRows;
294 :
295 0 : sal_Int32 nPos = bColumns ? (rBox.Left() - rTabPos.X())
296 0 : : (rBox.Top() - rTabPos.Y());
297 : Int32Set_Impl::const_iterator aSttRowOrCol(
298 0 : rRowsOrCols.lower_bound( nPos ) );
299 : sal_Int32 nRowOrCol =
300 : static_cast< sal_Int32 >( ::std::distance(
301 0 : rRowsOrCols.begin(), aSttRowOrCol ) );
302 :
303 0 : nPos = bColumns ? (rBox.Right() - rTabPos.X())
304 0 : : (rBox.Bottom() - rTabPos.Y());
305 : Int32Set_Impl::const_iterator aEndRowOrCol(
306 0 : rRowsOrCols.upper_bound( nPos ) );
307 : sal_Int32 nExt =
308 : static_cast< sal_Int32 >( ::std::distance(
309 0 : aSttRowOrCol, aEndRowOrCol ) );
310 :
311 0 : rSelHdl.Unselect( nRowOrCol, nExt );
312 : }
313 : }
314 : else
315 : {
316 : // #i77106#
317 0 : if ( !pLower->IsRowFrm() ||
318 0 : IncludeRow( *pLower ) )
319 : {
320 : GetSelection( rTabPos, rArea, rSelBoxes, pLower, rSelHdl,
321 0 : bColumns );
322 : }
323 : }
324 : }
325 0 : ++aIter;
326 : }
327 0 : }
328 :
329 0 : const SwFrm *SwAccessibleTableData_Impl::GetCell(
330 : sal_Int32 nRow, sal_Int32 nColumn, sal_Bool,
331 : SwAccessibleTable *pThis ) const
332 : throw(lang::IndexOutOfBoundsException )
333 : {
334 0 : CheckRowAndCol( nRow, nColumn, pThis );
335 :
336 0 : Int32Set_Impl::const_iterator aSttCol( GetColumnIter( nColumn ) );
337 0 : Int32Set_Impl::const_iterator aSttRow( GetRowIter( nRow ) );
338 0 : const SwFrm *pCellFrm = GetCellAtPos( *aSttCol, *aSttRow, sal_False );
339 :
340 0 : return pCellFrm;
341 : }
342 :
343 0 : void SwAccessibleTableData_Impl::GetSelection(
344 : sal_Int32 nStart, sal_Int32 nEnd,
345 : const SwSelBoxes& rSelBoxes,
346 : SwAccTableSelHander_Impl& rSelHdl,
347 : sal_Bool bColumns ) const
348 : {
349 0 : SwRect aArea( mpTabFrm->Frm() );
350 0 : Point aPos( aArea.Pos() );
351 :
352 0 : const Int32Set_Impl& rRowsOrColumns = bColumns ? maColumns : maRows;
353 0 : if( nStart > 0 )
354 : {
355 0 : Int32Set_Impl::const_iterator aStt( rRowsOrColumns.begin() );
356 : ::std::advance( aStt,
357 0 : static_cast< Int32Set_Impl::difference_type >( nStart ) );
358 0 : if( bColumns )
359 0 : aArea.Left( *aStt + aPos.X() );
360 : else
361 0 : aArea.Top( *aStt + aPos.Y() );
362 : }
363 0 : if( nEnd < static_cast< sal_Int32 >( rRowsOrColumns.size() ) )
364 : {
365 0 : Int32Set_Impl::const_iterator aEnd( rRowsOrColumns.begin() );
366 : ::std::advance( aEnd,
367 0 : static_cast< Int32Set_Impl::difference_type >( nEnd ) );
368 0 : if( bColumns )
369 0 : aArea.Right( *aEnd + aPos.X() - 1 );
370 : else
371 0 : aArea.Bottom( *aEnd + aPos.Y() - 1 );
372 : }
373 :
374 0 : GetSelection( aPos, aArea, rSelBoxes, mpTabFrm, rSelHdl, bColumns );
375 0 : }
376 :
377 0 : const SwFrm *SwAccessibleTableData_Impl::GetCellAtPos(
378 : sal_Int32 nLeft, sal_Int32 nTop, sal_Bool bExact ) const
379 : {
380 0 : Point aPos( mpTabFrm->Frm().Pos() );
381 0 : aPos.Move( nLeft, nTop );
382 0 : const SwFrm *pRet = 0;
383 0 : FindCell( aPos, mpTabFrm, bExact, pRet );
384 :
385 0 : return pRet;
386 : }
387 :
388 0 : inline sal_Int32 SwAccessibleTableData_Impl::GetRowCount() const
389 : {
390 0 : return static_cast< sal_Int32 >( maRows.size() );
391 : }
392 :
393 0 : inline sal_Int32 SwAccessibleTableData_Impl::GetColumnCount() const
394 : {
395 0 : return static_cast< sal_Int32 >( maColumns.size() );
396 : }
397 :
398 0 : sal_Bool SwAccessibleTableData_Impl::CompareExtents(
399 : const SwAccessibleTableData_Impl& rCmp ) const
400 : {
401 0 : if( maExtents.size() != rCmp.maExtents.size() )
402 0 : return sal_False;
403 :
404 0 : return ::std::equal(maExtents.begin(), maExtents.end(), rCmp.maExtents.begin()) ? sal_True : sal_False;
405 : }
406 :
407 0 : SwAccessibleTableData_Impl::SwAccessibleTableData_Impl( SwAccessibleMap& rAccMap,
408 : const SwTabFrm *pTabFrm,
409 : sal_Bool bIsInPagePreview,
410 : bool bOnlyTableColumnHeader )
411 : : mrAccMap( rAccMap )
412 0 : , maTabFrmPos( pTabFrm->Frm().Pos() )
413 : , mpTabFrm( pTabFrm )
414 : , mbIsInPagePreview( bIsInPagePreview )
415 0 : , mbOnlyTableColumnHeader( bOnlyTableColumnHeader )
416 : {
417 0 : CollectData( mpTabFrm );
418 0 : CollectExtents( mpTabFrm );
419 0 : }
420 :
421 0 : inline Int32Set_Impl::const_iterator SwAccessibleTableData_Impl::GetRowIter(
422 : sal_Int32 nRow ) const
423 : {
424 0 : Int32Set_Impl::const_iterator aCol( GetRows().begin() );
425 0 : if( nRow > 0 )
426 : {
427 : ::std::advance( aCol,
428 0 : static_cast< Int32Set_Impl::difference_type >( nRow ) );
429 : }
430 0 : return aCol;
431 : }
432 :
433 0 : inline Int32Set_Impl::const_iterator SwAccessibleTableData_Impl::GetColumnIter(
434 : sal_Int32 nColumn ) const
435 : {
436 0 : Int32Set_Impl::const_iterator aCol = GetColumns().begin();
437 0 : if( nColumn > 0 )
438 : {
439 : ::std::advance( aCol,
440 0 : static_cast< Int32Set_Impl::difference_type >( nColumn ) );
441 : }
442 0 : return aCol;
443 : }
444 :
445 0 : void SwAccessibleTableData_Impl::CheckRowAndCol(
446 : sal_Int32 nRow, sal_Int32 nCol, SwAccessibleTable *pThis ) const
447 : throw(lang::IndexOutOfBoundsException )
448 : {
449 0 : if( ( nRow < 0 || nRow >= static_cast< sal_Int32 >( maRows.size() ) ) ||
450 0 : ( nCol < 0 || nCol >= static_cast< sal_Int32 >( maColumns.size() ) ) )
451 : {
452 0 : uno::Reference < XAccessibleTable > xThis( pThis );
453 : lang::IndexOutOfBoundsException aExcept(
454 : OUString( RTL_CONSTASCII_USTRINGPARAM(
455 : "row or column index out of range") ),
456 0 : xThis );
457 0 : throw aExcept;
458 : }
459 0 : }
460 :
461 0 : void SwAccessibleTableData_Impl::GetRowColumnAndExtent(
462 : const SwRect& rBox,
463 : sal_Int32& rRow, sal_Int32& rColumn,
464 : sal_Int32& rRowExtent, sal_Int32& rColumnExtent ) const
465 : {
466 : Int32Set_Impl::const_iterator aStt(
467 0 : maRows.lower_bound( rBox.Top() - maTabFrmPos.Y() ) );
468 : Int32Set_Impl::const_iterator aEnd(
469 0 : maRows.upper_bound( rBox.Bottom() - maTabFrmPos.Y() ) );
470 : rRow =
471 0 : static_cast< sal_Int32 >( ::std::distance( maRows.begin(), aStt ) );
472 : rRowExtent =
473 0 : static_cast< sal_Int32 >( ::std::distance( aStt, aEnd ) );
474 :
475 0 : aStt = maColumns.lower_bound( rBox.Left() - maTabFrmPos.X() );
476 0 : aEnd = maColumns.upper_bound( rBox.Right() - maTabFrmPos.X() );
477 : rColumn =
478 0 : static_cast< sal_Int32 >( ::std::distance( maColumns.begin(), aStt ) );
479 : rColumnExtent =
480 0 : static_cast< sal_Int32 >( ::std::distance( aStt, aEnd ) );
481 0 : }
482 :
483 : //------------------------------------------------------------------------------
484 :
485 : class SwAccSingleTableSelHander_Impl : public SwAccTableSelHander_Impl
486 : {
487 : sal_Bool bSelected;
488 :
489 : public:
490 :
491 : inline SwAccSingleTableSelHander_Impl();
492 :
493 0 : virtual ~SwAccSingleTableSelHander_Impl() {}
494 :
495 0 : inline sal_Bool IsSelected() const { return bSelected; }
496 :
497 : virtual void Unselect( sal_Int32, sal_Int32 );
498 : };
499 :
500 0 : inline SwAccSingleTableSelHander_Impl::SwAccSingleTableSelHander_Impl() :
501 0 : bSelected( sal_True )
502 : {
503 0 : }
504 :
505 0 : void SwAccSingleTableSelHander_Impl::Unselect( sal_Int32, sal_Int32 )
506 : {
507 0 : bSelected = sal_False;
508 0 : }
509 :
510 : //------------------------------------------------------------------------------
511 :
512 : class SwAccAllTableSelHander_Impl : public SwAccTableSelHander_Impl
513 :
514 : {
515 : ::std::vector< sal_Bool > aSelected;
516 : sal_Int32 nCount;
517 :
518 : public:
519 :
520 : inline SwAccAllTableSelHander_Impl( sal_Int32 nSize );
521 :
522 : uno::Sequence < sal_Int32 > GetSelSequence();
523 :
524 : virtual void Unselect( sal_Int32 nRowOrCol, sal_Int32 nExt );
525 : virtual ~SwAccAllTableSelHander_Impl();
526 : };
527 :
528 0 : SwAccAllTableSelHander_Impl::~SwAccAllTableSelHander_Impl()
529 : {
530 0 : }
531 :
532 0 : inline SwAccAllTableSelHander_Impl::SwAccAllTableSelHander_Impl( sal_Int32 nSize ) :
533 : aSelected( nSize, sal_True ),
534 0 : nCount( nSize )
535 : {
536 0 : }
537 :
538 0 : uno::Sequence < sal_Int32 > SwAccAllTableSelHander_Impl::GetSelSequence()
539 : {
540 : OSL_ENSURE( nCount >= 0, "underflow" );
541 0 : uno::Sequence < sal_Int32 > aRet( nCount );
542 0 : sal_Int32 *pRet = aRet.getArray();
543 0 : sal_Int32 nPos = 0;
544 0 : size_t nSize = aSelected.size();
545 0 : for( size_t i=0; i < nSize && nPos < nCount; i++ )
546 : {
547 0 : if( aSelected[i] )
548 : {
549 0 : *pRet++ = i;
550 0 : nPos++;
551 : }
552 : }
553 :
554 : OSL_ENSURE( nPos == nCount, "count is wrong" );
555 :
556 0 : return aRet;
557 : }
558 :
559 0 : void SwAccAllTableSelHander_Impl::Unselect( sal_Int32 nRowOrCol,
560 : sal_Int32 nExt )
561 : {
562 : OSL_ENSURE( static_cast< size_t >( nRowOrCol ) < aSelected.size(),
563 : "index to large" );
564 : OSL_ENSURE( static_cast< size_t >( nRowOrCol+nExt ) <= aSelected.size(),
565 : "extent to large" );
566 0 : while( nExt )
567 : {
568 0 : if( aSelected[static_cast< size_t >( nRowOrCol )] )
569 : {
570 0 : aSelected[static_cast< size_t >( nRowOrCol )] = sal_False;
571 0 : nCount--;
572 : }
573 0 : nExt--;
574 0 : nRowOrCol++;
575 : }
576 0 : }
577 :
578 : //------------------------------------------------------------------------------
579 :
580 0 : const SwSelBoxes *SwAccessibleTable::GetSelBoxes() const
581 : {
582 0 : const SwSelBoxes *pSelBoxes = 0;
583 0 : const SwCrsrShell *pCSh = GetCrsrShell();
584 0 : if( (pCSh != NULL) && pCSh->IsTableMode() )
585 : {
586 0 : pSelBoxes = &pCSh->GetTableCrsr()->GetSelectedBoxes();
587 : }
588 :
589 0 : return pSelBoxes;
590 : }
591 :
592 0 : void SwAccessibleTable::FireTableChangeEvent(
593 : const SwAccessibleTableData_Impl& rTableData )
594 : {
595 0 : AccessibleTableModelChange aModelChange;
596 0 : aModelChange.Type = AccessibleTableModelChangeType::UPDATE;
597 0 : aModelChange.FirstRow = 0;
598 0 : aModelChange.LastRow = rTableData.GetRowCount() - 1;
599 0 : aModelChange.FirstColumn = 0;
600 0 : aModelChange.LastColumn = rTableData.GetColumnCount() - 1;
601 :
602 0 : AccessibleEventObject aEvent;
603 0 : aEvent.EventId = AccessibleEventId::TABLE_MODEL_CHANGED;
604 0 : aEvent.NewValue <<= aModelChange;
605 :
606 0 : FireAccessibleEvent( aEvent );
607 0 : }
608 :
609 :
610 0 : const SwTableBox* SwAccessibleTable::GetTableBox( sal_Int32 nChildIndex ) const
611 : {
612 : OSL_ENSURE( nChildIndex >= 0, "Illegal child index." );
613 : OSL_ENSURE( nChildIndex < const_cast<SwAccessibleTable*>(this)->getAccessibleChildCount(), "Illegal child index." ); // #i77106#
614 :
615 0 : const SwTableBox* pBox = NULL;
616 :
617 : // get table box for 'our' table cell
618 0 : SwAccessibleChild aCell( GetChild( *(const_cast<SwAccessibleMap*>(GetMap())), nChildIndex ) );
619 0 : if( aCell.GetSwFrm() )
620 : {
621 0 : const SwFrm* pChildFrm = aCell.GetSwFrm();
622 0 : if( (pChildFrm != NULL) && pChildFrm->IsCellFrm() )
623 : {
624 : const SwCellFrm* pCellFrm =
625 0 : static_cast<const SwCellFrm*>( pChildFrm );
626 0 : pBox = pCellFrm->GetTabBox();
627 : }
628 : }
629 :
630 : OSL_ENSURE( pBox != NULL, "We need the table box." );
631 0 : return pBox;
632 : }
633 :
634 0 : sal_Bool SwAccessibleTable::IsChildSelected( sal_Int32 nChildIndex ) const
635 : {
636 0 : sal_Bool bRet = sal_False;
637 0 : const SwSelBoxes* pSelBoxes = GetSelBoxes();
638 0 : if( pSelBoxes )
639 : {
640 0 : const SwTableBox* pBox = GetTableBox( nChildIndex );
641 : OSL_ENSURE( pBox != NULL, "We need the table box." );
642 0 : bRet = pSelBoxes->find( const_cast<SwTableBox*>( pBox ) ) != pSelBoxes->end();
643 : }
644 :
645 0 : return bRet;
646 : }
647 :
648 0 : sal_Int32 SwAccessibleTable::GetIndexOfSelectedChild(
649 : sal_Int32 nSelectedChildIndex ) const
650 : {
651 : // iterate over all children to n-th isAccessibleChildSelected()
652 0 : sal_Int32 nChildren = const_cast<SwAccessibleTable*>(this)->getAccessibleChildCount(); // #i77106#
653 0 : if( nSelectedChildIndex >= nChildren )
654 0 : return -1L;
655 :
656 0 : sal_Int32 n = 0;
657 0 : while( n < nChildren )
658 : {
659 0 : if( IsChildSelected( n ) )
660 : {
661 0 : if( 0 == nSelectedChildIndex )
662 0 : break;
663 : else
664 0 : --nSelectedChildIndex;
665 : }
666 0 : ++n;
667 : }
668 :
669 0 : return n < nChildren ? n : -1L;
670 : }
671 :
672 0 : void SwAccessibleTable::GetStates(
673 : ::utl::AccessibleStateSetHelper& rStateSet )
674 : {
675 0 : SwAccessibleContext::GetStates( rStateSet );
676 :
677 : // MULTISELECTABLE
678 0 : SwCrsrShell* pCrsrShell = GetCrsrShell();
679 0 : if( pCrsrShell )
680 0 : rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE );
681 0 : }
682 :
683 0 : SwAccessibleTable::SwAccessibleTable(
684 : SwAccessibleMap* pInitMap,
685 : const SwTabFrm* pTabFrm ) :
686 : SwAccessibleContext( pInitMap, AccessibleRole::TABLE, pTabFrm ),
687 0 : mpTableData( 0 )
688 : {
689 0 : SolarMutexGuard aGuard;
690 :
691 0 : const SwFrmFmt *pFrmFmt = pTabFrm->GetFmt();
692 0 : const_cast< SwFrmFmt * >( pFrmFmt )->Add( this );
693 0 : const String& rName = pFrmFmt->GetName();
694 :
695 0 : OUStringBuffer aBuffer( rName.Len() + 4 );
696 0 : aBuffer.append( OUString(rName) );
697 0 : aBuffer.append( static_cast<sal_Unicode>( '-' ) );
698 0 : aBuffer.append( static_cast<sal_Int32>( pTabFrm->GetPhyPageNum() ) );
699 :
700 0 : SetName( aBuffer.makeStringAndClear() );
701 :
702 0 : OUString sArg1( static_cast< const SwTabFrm * >( GetFrm() )
703 0 : ->GetFmt()->GetName() );
704 0 : OUString sArg2( GetFormattedPageNumber() );
705 :
706 0 : sDesc = GetResource( STR_ACCESS_TABLE_DESC, &sArg1, &sArg2 );
707 0 : }
708 :
709 0 : SwAccessibleTable::~SwAccessibleTable()
710 : {
711 0 : SolarMutexGuard aGuard;
712 :
713 0 : delete mpTableData;
714 0 : }
715 :
716 0 : void SwAccessibleTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
717 : {
718 0 : sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ;
719 0 : const SwTabFrm *pTabFrm = static_cast< const SwTabFrm * >( GetFrm() );
720 0 : switch( nWhich )
721 : {
722 : case RES_NAME_CHANGED:
723 0 : if( pTabFrm )
724 : {
725 0 : const SwFrmFmt *pFrmFmt = pTabFrm->GetFmt();
726 : OSL_ENSURE( pFrmFmt == GetRegisteredIn(), "invalid frame" );
727 :
728 0 : OUString sOldName( GetName() );
729 :
730 0 : const String& rNewTabName = pFrmFmt->GetName();
731 0 : OUStringBuffer aBuffer( rNewTabName.Len() + 4 );
732 0 : aBuffer.append( OUString(rNewTabName) );
733 0 : aBuffer.append( static_cast<sal_Unicode>( '-' ) );
734 0 : aBuffer.append( static_cast<sal_Int32>( pTabFrm->GetPhyPageNum() ) );
735 :
736 0 : SetName( aBuffer.makeStringAndClear() );
737 0 : if( sOldName != GetName() )
738 : {
739 0 : AccessibleEventObject aEvent;
740 0 : aEvent.EventId = AccessibleEventId::NAME_CHANGED;
741 0 : aEvent.OldValue <<= sOldName;
742 0 : aEvent.NewValue <<= GetName();
743 0 : FireAccessibleEvent( aEvent );
744 : }
745 :
746 0 : OUString sOldDesc( sDesc );
747 0 : OUString sArg1( rNewTabName );
748 0 : OUString sArg2( GetFormattedPageNumber() );
749 :
750 0 : sDesc = GetResource( STR_ACCESS_TABLE_DESC, &sArg1, &sArg2 );
751 0 : if( sDesc != sOldDesc )
752 : {
753 0 : AccessibleEventObject aEvent;
754 0 : aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED;
755 0 : aEvent.OldValue <<= sOldDesc;
756 0 : aEvent.NewValue <<= sDesc;
757 0 : FireAccessibleEvent( aEvent );
758 0 : }
759 : }
760 0 : break;
761 :
762 : case RES_OBJECTDYING:
763 : // mba: it seems that this class intentionally does not call code in base class SwClient
764 0 : if( GetRegisteredIn() ==
765 : static_cast< SwModify *>( static_cast< const SwPtrMsgPoolItem * >( pOld )->pObject ) )
766 0 : GetRegisteredInNonConst()->Remove( this );
767 0 : break;
768 :
769 : default:
770 : // mba: former call to base class method removed as it is meant to handle only RES_OBJECTDYING
771 0 : break;
772 : }
773 0 : }
774 :
775 0 : uno::Any SwAccessibleTable::queryInterface( const uno::Type& rType )
776 : throw (uno::RuntimeException)
777 : {
778 0 : uno::Any aRet;
779 0 : if ( rType == ::getCppuType( static_cast< uno::Reference< XAccessibleTable > * >( 0 ) ) )
780 : {
781 0 : uno::Reference<XAccessibleTable> xThis( this );
782 0 : aRet <<= xThis;
783 : }
784 0 : else if ( rType == ::getCppuType( static_cast< uno::Reference< XAccessibleSelection > * >( 0 ) ) )
785 : {
786 0 : uno::Reference<XAccessibleSelection> xSelection( this );
787 0 : aRet <<= xSelection;
788 : }
789 : else
790 : {
791 0 : aRet = SwAccessibleContext::queryInterface(rType);
792 : }
793 :
794 0 : return aRet;
795 : }
796 :
797 : //====== XTypeProvider ====================================================
798 0 : uno::Sequence< uno::Type > SAL_CALL SwAccessibleTable::getTypes()
799 : throw(uno::RuntimeException)
800 : {
801 0 : uno::Sequence< uno::Type > aTypes( SwAccessibleContext::getTypes() );
802 :
803 0 : sal_Int32 nIndex = aTypes.getLength();
804 0 : aTypes.realloc( nIndex + 2 );
805 :
806 0 : uno::Type* pTypes = aTypes.getArray();
807 0 : pTypes[nIndex++] = ::getCppuType( static_cast< uno::Reference< XAccessibleSelection > * >( 0 ) );
808 0 : pTypes[nIndex++] = ::getCppuType( static_cast< uno::Reference< XAccessibleTable > * >( 0 ) );
809 :
810 0 : return aTypes;
811 : }
812 :
813 : namespace
814 : {
815 : class theSwAccessibleTableImplementationId : public rtl::Static< UnoTunnelIdInit, theSwAccessibleTableImplementationId > {};
816 : }
817 :
818 0 : uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleTable::getImplementationId()
819 : throw(uno::RuntimeException)
820 : {
821 0 : return theSwAccessibleTableImplementationId::get().getSeq();
822 : }
823 :
824 : // #i77106#
825 0 : SwAccessibleTableData_Impl* SwAccessibleTable::CreateNewTableData()
826 : {
827 0 : const SwTabFrm* pTabFrm = static_cast<const SwTabFrm*>( GetFrm() );
828 0 : return new SwAccessibleTableData_Impl( *GetMap(), pTabFrm, IsInPagePreview() );
829 : }
830 :
831 0 : void SwAccessibleTable::UpdateTableData()
832 : {
833 : // #i77106# - usage of new method <CreateNewTableData()>
834 0 : delete mpTableData;
835 0 : mpTableData = CreateNewTableData();
836 0 : }
837 :
838 0 : void SwAccessibleTable::ClearTableData()
839 : {
840 0 : delete mpTableData;
841 0 : mpTableData = 0;
842 0 : }
843 :
844 0 : OUString SAL_CALL SwAccessibleTable::getAccessibleDescription (void)
845 : throw (uno::RuntimeException)
846 : {
847 0 : SolarMutexGuard aGuard;
848 :
849 0 : CHECK_FOR_DEFUNC( XAccessibleContext )
850 :
851 0 : return sDesc;
852 : }
853 :
854 0 : sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleRowCount()
855 : throw (uno::RuntimeException)
856 : {
857 0 : SolarMutexGuard aGuard;
858 :
859 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
860 :
861 0 : return GetTableData().GetRowCount();
862 : }
863 :
864 0 : sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleColumnCount( )
865 : throw (uno::RuntimeException)
866 : {
867 0 : SolarMutexGuard aGuard;
868 :
869 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
870 :
871 0 : return GetTableData().GetColumnCount();
872 : }
873 :
874 0 : OUString SAL_CALL SwAccessibleTable::getAccessibleRowDescription(
875 : sal_Int32 nRow )
876 : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
877 : {
878 : // #i87532# - determine table cell in <nRow>th row and
879 : // in first column of row header table and return its text content.
880 0 : OUString sRowDesc;
881 :
882 0 : GetTableData().CheckRowAndCol(nRow, 0, this);
883 :
884 0 : uno::Reference< XAccessibleTable > xTableRowHeader = getAccessibleRowHeaders();
885 0 : if ( xTableRowHeader.is() )
886 : {
887 : uno::Reference< XAccessible > xRowHeaderCell =
888 0 : xTableRowHeader->getAccessibleCellAt( nRow, 0 );
889 : OSL_ENSURE( xRowHeaderCell.is(),
890 : "<SwAccessibleTable::getAccessibleRowDescription(..)> - missing row header cell -> serious issue." );
891 : uno::Reference< XAccessibleContext > xRowHeaderCellContext =
892 0 : xRowHeaderCell->getAccessibleContext();
893 0 : const sal_Int32 nCellChildCount( xRowHeaderCellContext->getAccessibleChildCount() );
894 0 : for ( sal_Int32 nChildIndex = 0; nChildIndex < nCellChildCount; ++nChildIndex )
895 : {
896 0 : uno::Reference< XAccessible > xChild = xRowHeaderCellContext->getAccessibleChild( nChildIndex );
897 0 : uno::Reference< XAccessibleText > xChildText( xChild, uno::UNO_QUERY );
898 0 : if ( xChildText.is() )
899 : {
900 0 : sRowDesc = sRowDesc + xChildText->getText();
901 : }
902 0 : }
903 : }
904 :
905 0 : return sRowDesc;
906 : }
907 :
908 0 : OUString SAL_CALL SwAccessibleTable::getAccessibleColumnDescription(
909 : sal_Int32 nColumn )
910 : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
911 : {
912 : // #i87532# - determine table cell in first row and
913 : // in <nColumn>th column of column header table and return its text content.
914 0 : OUString sColumnDesc;
915 :
916 0 : GetTableData().CheckRowAndCol(0, nColumn, this);
917 :
918 0 : uno::Reference< XAccessibleTable > xTableColumnHeader = getAccessibleColumnHeaders();
919 0 : if ( xTableColumnHeader.is() )
920 : {
921 : uno::Reference< XAccessible > xColumnHeaderCell =
922 0 : xTableColumnHeader->getAccessibleCellAt( 0, nColumn );
923 : OSL_ENSURE( xColumnHeaderCell.is(),
924 : "<SwAccessibleTable::getAccessibleColumnDescription(..)> - missing column header cell -> serious issue." );
925 : uno::Reference< XAccessibleContext > xColumnHeaderCellContext =
926 0 : xColumnHeaderCell->getAccessibleContext();
927 0 : const sal_Int32 nCellChildCount( xColumnHeaderCellContext->getAccessibleChildCount() );
928 0 : for ( sal_Int32 nChildIndex = 0; nChildIndex < nCellChildCount; ++nChildIndex )
929 : {
930 0 : uno::Reference< XAccessible > xChild = xColumnHeaderCellContext->getAccessibleChild( nChildIndex );
931 0 : uno::Reference< XAccessibleText > xChildText( xChild, uno::UNO_QUERY );
932 0 : if ( xChildText.is() )
933 : {
934 0 : sColumnDesc = sColumnDesc + xChildText->getText();
935 : }
936 0 : }
937 : }
938 :
939 0 : return sColumnDesc;
940 : }
941 :
942 0 : sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleRowExtentAt(
943 : sal_Int32 nRow, sal_Int32 nColumn )
944 : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
945 : {
946 0 : sal_Int32 nExtend = -1;
947 :
948 0 : SolarMutexGuard aGuard;
949 :
950 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
951 :
952 0 : GetTableData().CheckRowAndCol( nRow, nColumn, this );
953 :
954 : Int32Set_Impl::const_iterator aSttCol(
955 0 : GetTableData().GetColumnIter( nColumn ) );
956 : Int32Set_Impl::const_iterator aSttRow(
957 0 : GetTableData().GetRowIter( nRow ) );
958 0 : const SwFrm *pCellFrm = GetTableData().GetCellAtPos( *aSttCol, *aSttRow,
959 0 : sal_False );
960 0 : if( pCellFrm )
961 : {
962 0 : sal_Int32 nBottom = pCellFrm->Frm().Bottom();
963 0 : nBottom -= GetFrm()->Frm().Top();
964 : Int32Set_Impl::const_iterator aEndRow(
965 0 : GetTableData().GetRows().upper_bound( nBottom ) );
966 : nExtend =
967 0 : static_cast< sal_Int32 >( ::std::distance( aSttRow, aEndRow ) );
968 : }
969 :
970 0 : return nExtend;
971 : }
972 :
973 0 : sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleColumnExtentAt(
974 : sal_Int32 nRow, sal_Int32 nColumn )
975 : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
976 : {
977 0 : sal_Int32 nExtend = -1;
978 :
979 0 : SolarMutexGuard aGuard;
980 :
981 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
982 :
983 0 : GetTableData().CheckRowAndCol( nRow, nColumn, this );
984 :
985 : Int32Set_Impl::const_iterator aSttCol(
986 0 : GetTableData().GetColumnIter( nColumn ) );
987 : Int32Set_Impl::const_iterator aSttRow(
988 0 : GetTableData().GetRowIter( nRow ) );
989 0 : const SwFrm *pCellFrm = GetTableData().GetCellAtPos( *aSttCol, *aSttRow,
990 0 : sal_False );
991 0 : if( pCellFrm )
992 : {
993 0 : sal_Int32 nRight = pCellFrm->Frm().Right();
994 0 : nRight -= GetFrm()->Frm().Left();
995 : Int32Set_Impl::const_iterator aEndCol(
996 0 : GetTableData().GetColumns().upper_bound( nRight ) );
997 : nExtend =
998 0 : static_cast< sal_Int32 >( ::std::distance( aSttCol, aEndCol ) );
999 : }
1000 :
1001 0 : return nExtend;
1002 : }
1003 :
1004 : uno::Reference< XAccessibleTable > SAL_CALL
1005 0 : SwAccessibleTable::getAccessibleRowHeaders( )
1006 : throw (uno::RuntimeException)
1007 : {
1008 : // Row headers aren't supported
1009 0 : return uno::Reference< XAccessibleTable >();
1010 : }
1011 :
1012 : uno::Reference< XAccessibleTable > SAL_CALL
1013 0 : SwAccessibleTable::getAccessibleColumnHeaders( )
1014 : throw (uno::RuntimeException)
1015 : {
1016 : // #i87532# - assure that return accesible object is empty,
1017 : // if no column header exists.
1018 : SwAccessibleTableColHeaders* pTableColHeaders =
1019 0 : new SwAccessibleTableColHeaders( GetMap(), static_cast< const SwTabFrm *>( GetFrm() ) );
1020 0 : uno::Reference< XAccessibleTable > xTableColumnHeaders( pTableColHeaders );
1021 0 : if ( pTableColHeaders->getAccessibleChildCount() <= 0 )
1022 : {
1023 0 : return uno::Reference< XAccessibleTable >();
1024 : }
1025 :
1026 0 : return xTableColumnHeaders;
1027 : }
1028 :
1029 0 : uno::Sequence< sal_Int32 > SAL_CALL SwAccessibleTable::getSelectedAccessibleRows()
1030 : throw (uno::RuntimeException)
1031 : {
1032 0 : SolarMutexGuard aGuard;
1033 :
1034 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
1035 :
1036 0 : const SwSelBoxes *pSelBoxes = GetSelBoxes();
1037 0 : if( pSelBoxes )
1038 : {
1039 0 : sal_Int32 nRows = GetTableData().GetRowCount();
1040 0 : SwAccAllTableSelHander_Impl aSelRows( nRows );
1041 :
1042 0 : GetTableData().GetSelection( 0, nRows, *pSelBoxes, aSelRows,
1043 0 : sal_False );
1044 :
1045 0 : return aSelRows.GetSelSequence();
1046 : }
1047 : else
1048 : {
1049 0 : return uno::Sequence< sal_Int32 >( 0 );
1050 0 : }
1051 : }
1052 :
1053 0 : uno::Sequence< sal_Int32 > SAL_CALL SwAccessibleTable::getSelectedAccessibleColumns()
1054 : throw (uno::RuntimeException)
1055 : {
1056 0 : SolarMutexGuard aGuard;
1057 :
1058 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
1059 :
1060 0 : const SwSelBoxes *pSelBoxes = GetSelBoxes();
1061 0 : if( pSelBoxes )
1062 : {
1063 0 : sal_Int32 nCols = GetTableData().GetColumnCount();
1064 0 : SwAccAllTableSelHander_Impl aSelCols( nCols );
1065 :
1066 0 : GetTableData().GetSelection( 0, nCols, *pSelBoxes, aSelCols, sal_True );
1067 :
1068 0 : return aSelCols.GetSelSequence();
1069 : }
1070 : else
1071 : {
1072 0 : return uno::Sequence< sal_Int32 >( 0 );
1073 0 : }
1074 : }
1075 :
1076 0 : sal_Bool SAL_CALL SwAccessibleTable::isAccessibleRowSelected( sal_Int32 nRow )
1077 : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1078 : {
1079 0 : SolarMutexGuard aGuard;
1080 :
1081 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
1082 :
1083 0 : GetTableData().CheckRowAndCol( nRow, 0, this );
1084 :
1085 : sal_Bool bRet;
1086 0 : const SwSelBoxes *pSelBoxes = GetSelBoxes();
1087 0 : if( pSelBoxes )
1088 : {
1089 0 : SwAccSingleTableSelHander_Impl aSelRow;
1090 0 : GetTableData().GetSelection( nRow, nRow+1, *pSelBoxes, aSelRow,
1091 0 : sal_False );
1092 0 : bRet = aSelRow.IsSelected();
1093 : }
1094 : else
1095 : {
1096 0 : bRet = sal_False;
1097 : }
1098 :
1099 0 : return bRet;
1100 : }
1101 :
1102 0 : sal_Bool SAL_CALL SwAccessibleTable::isAccessibleColumnSelected(
1103 : sal_Int32 nColumn )
1104 : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1105 : {
1106 0 : SolarMutexGuard aGuard;
1107 :
1108 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
1109 :
1110 0 : GetTableData().CheckRowAndCol( 0, nColumn, this );
1111 :
1112 : sal_Bool bRet;
1113 0 : const SwSelBoxes *pSelBoxes = GetSelBoxes();
1114 0 : if( pSelBoxes )
1115 : {
1116 0 : SwAccSingleTableSelHander_Impl aSelCol;
1117 :
1118 0 : GetTableData().GetSelection( nColumn, nColumn+1, *pSelBoxes, aSelCol,
1119 0 : sal_True );
1120 0 : bRet = aSelCol.IsSelected();
1121 : }
1122 : else
1123 : {
1124 0 : bRet = sal_False;
1125 : }
1126 :
1127 0 : return bRet;
1128 : }
1129 :
1130 0 : uno::Reference< XAccessible > SAL_CALL SwAccessibleTable::getAccessibleCellAt(
1131 : sal_Int32 nRow, sal_Int32 nColumn )
1132 : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1133 : {
1134 0 : uno::Reference< XAccessible > xRet;
1135 :
1136 0 : SolarMutexGuard aGuard;
1137 :
1138 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
1139 :
1140 : const SwFrm *pCellFrm =
1141 0 : GetTableData().GetCell( nRow, nColumn, sal_False, this );
1142 0 : if( pCellFrm )
1143 0 : xRet = GetMap()->GetContext( pCellFrm, sal_True );
1144 :
1145 0 : return xRet;
1146 : }
1147 :
1148 0 : uno::Reference< XAccessible > SAL_CALL SwAccessibleTable::getAccessibleCaption()
1149 : throw (uno::RuntimeException)
1150 : {
1151 : // captions aren't supported
1152 0 : return uno::Reference< XAccessible >();
1153 : }
1154 :
1155 0 : uno::Reference< XAccessible > SAL_CALL SwAccessibleTable::getAccessibleSummary()
1156 : throw (uno::RuntimeException)
1157 : {
1158 : // summaries aren't supported
1159 0 : return uno::Reference< XAccessible >();
1160 : }
1161 :
1162 0 : sal_Bool SAL_CALL SwAccessibleTable::isAccessibleSelected(
1163 : sal_Int32 nRow, sal_Int32 nColumn )
1164 : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1165 : {
1166 0 : sal_Bool bRet = sal_False;
1167 :
1168 0 : SolarMutexGuard aGuard;
1169 :
1170 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
1171 :
1172 : const SwFrm *pFrm =
1173 0 : GetTableData().GetCell( nRow, nColumn, sal_False, this );
1174 0 : if( pFrm && pFrm->IsCellFrm() )
1175 : {
1176 0 : const SwSelBoxes *pSelBoxes = GetSelBoxes();
1177 0 : if( pSelBoxes )
1178 : {
1179 0 : const SwCellFrm *pCFrm = static_cast < const SwCellFrm * >( pFrm );
1180 : SwTableBox *pBox =
1181 0 : const_cast< SwTableBox *>( pCFrm->GetTabBox() );
1182 0 : bRet = pSelBoxes->find( pBox ) != pSelBoxes->end();
1183 : }
1184 : }
1185 :
1186 0 : return bRet;
1187 : }
1188 :
1189 0 : sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleIndex(
1190 : sal_Int32 nRow, sal_Int32 nColumn )
1191 : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1192 : {
1193 0 : sal_Int32 nRet = -1;
1194 :
1195 0 : SolarMutexGuard aGuard;
1196 :
1197 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
1198 :
1199 0 : SwAccessibleChild aCell( GetTableData().GetCell( nRow, nColumn, sal_False, this ));
1200 0 : if ( aCell.IsValid() )
1201 : {
1202 0 : nRet = GetChildIndex( *(GetMap()), aCell );
1203 : }
1204 :
1205 0 : return nRet;
1206 : }
1207 :
1208 0 : sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleRow( sal_Int32 nChildIndex )
1209 : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1210 : {
1211 0 : sal_Int32 nRet = -1;
1212 :
1213 0 : SolarMutexGuard aGuard;
1214 :
1215 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
1216 :
1217 : // #i77106#
1218 0 : if ( ( nChildIndex < 0 ) ||
1219 0 : ( nChildIndex >= getAccessibleChildCount() ) )
1220 : {
1221 0 : throw lang::IndexOutOfBoundsException();
1222 : }
1223 :
1224 0 : SwAccessibleChild aCell( GetChild( *(GetMap()), nChildIndex ) );
1225 0 : if ( aCell.GetSwFrm() )
1226 : {
1227 0 : sal_Int32 nTop = aCell.GetSwFrm()->Frm().Top();
1228 0 : nTop -= GetFrm()->Frm().Top();
1229 : Int32Set_Impl::const_iterator aRow(
1230 0 : GetTableData().GetRows().lower_bound( nTop ) );
1231 : nRet = static_cast< sal_Int32 >( ::std::distance(
1232 0 : GetTableData().GetRows().begin(), aRow ) );
1233 : }
1234 : else
1235 : {
1236 : OSL_ENSURE( !aCell.IsValid(), "SwAccessibleTable::getAccessibleColumn:"
1237 : "aCell not expected to be valid.");
1238 :
1239 0 : throw lang::IndexOutOfBoundsException();
1240 : }
1241 :
1242 0 : return nRet;
1243 : }
1244 :
1245 0 : sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleColumn(
1246 : sal_Int32 nChildIndex )
1247 : throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1248 : {
1249 0 : sal_Int32 nRet = -1;
1250 :
1251 0 : SolarMutexGuard aGuard;
1252 :
1253 0 : CHECK_FOR_DEFUNC( XAccessibleTable )
1254 :
1255 : // #i77106#
1256 0 : if ( ( nChildIndex < 0 ) ||
1257 0 : ( nChildIndex >= getAccessibleChildCount() ) )
1258 : {
1259 0 : throw lang::IndexOutOfBoundsException();
1260 : }
1261 :
1262 0 : SwAccessibleChild aCell( GetChild( *(GetMap()), nChildIndex ) );
1263 0 : if ( aCell.GetSwFrm() )
1264 : {
1265 0 : sal_Int32 nLeft = aCell.GetSwFrm()->Frm().Left();
1266 0 : nLeft -= GetFrm()->Frm().Left();
1267 : Int32Set_Impl::const_iterator aCol(
1268 0 : GetTableData().GetColumns().lower_bound( nLeft ) );
1269 : nRet = static_cast< sal_Int32 >( ::std::distance(
1270 0 : GetTableData().GetColumns().begin(), aCol ) );
1271 : }
1272 : else
1273 : {
1274 : OSL_ENSURE( !aCell.IsValid(), "SwAccessibleTable::getAccessibleColumn:"
1275 : "aCell not expected to be valid.");
1276 :
1277 0 : throw lang::IndexOutOfBoundsException();
1278 : }
1279 :
1280 0 : return nRet;
1281 : }
1282 :
1283 :
1284 0 : OUString SAL_CALL SwAccessibleTable::getImplementationName()
1285 : throw( uno::RuntimeException )
1286 : {
1287 0 : return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationName));
1288 : }
1289 :
1290 0 : sal_Bool SAL_CALL SwAccessibleTable::supportsService(
1291 : const OUString& sTestServiceName)
1292 : throw (uno::RuntimeException)
1293 : {
1294 : return sTestServiceName.equalsAsciiL( sServiceName,
1295 0 : sizeof(sServiceName)-1 ) ||
1296 : sTestServiceName.equalsAsciiL( sAccessibleServiceName,
1297 0 : sizeof(sAccessibleServiceName)-1 );
1298 : }
1299 :
1300 0 : uno::Sequence< OUString > SAL_CALL SwAccessibleTable::getSupportedServiceNames()
1301 : throw( uno::RuntimeException )
1302 : {
1303 0 : uno::Sequence< OUString > aRet(2);
1304 0 : OUString* pArray = aRet.getArray();
1305 0 : pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceName) );
1306 0 : pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) );
1307 0 : return aRet;
1308 : }
1309 :
1310 0 : void SwAccessibleTable::InvalidatePosOrSize( const SwRect& rOldBox )
1311 : {
1312 0 : SolarMutexGuard aGuard;
1313 :
1314 0 : if( HasTableData() )
1315 0 : GetTableData().SetTablePos( GetFrm()->Frm().Pos() );
1316 :
1317 0 : SwAccessibleContext::InvalidatePosOrSize( rOldBox );
1318 0 : }
1319 :
1320 0 : void SwAccessibleTable::Dispose( sal_Bool bRecursive )
1321 : {
1322 0 : SolarMutexGuard aGuard;
1323 :
1324 0 : if( GetRegisteredIn() )
1325 0 : GetRegisteredInNonConst()->Remove( this );
1326 :
1327 0 : SwAccessibleContext::Dispose( bRecursive );
1328 0 : }
1329 :
1330 0 : void SwAccessibleTable::DisposeChild( const SwAccessibleChild& rChildFrmOrObj,
1331 : sal_Bool bRecursive )
1332 : {
1333 0 : SolarMutexGuard aGuard;
1334 :
1335 0 : const SwFrm *pFrm = rChildFrmOrObj.GetSwFrm();
1336 : OSL_ENSURE( pFrm, "frame expected" );
1337 0 : if( HasTableData() )
1338 : {
1339 0 : FireTableChangeEvent( GetTableData() );
1340 0 : ClearTableData();
1341 : }
1342 :
1343 : // There are two reason why this method has been called. The first one
1344 : // is there is no context for pFrm. The method is them called by
1345 : // the map, and we have to call our superclass.
1346 : // The other situation is that we have been call by a call to get notified
1347 : // about its change. We then must not call the superclass
1348 0 : uno::Reference< XAccessible > xAcc( GetMap()->GetContext( pFrm, sal_False ) );
1349 0 : if( !xAcc.is() )
1350 0 : SwAccessibleContext::DisposeChild( rChildFrmOrObj, bRecursive );
1351 0 : }
1352 :
1353 0 : void SwAccessibleTable::InvalidateChildPosOrSize( const SwAccessibleChild& rChildFrmOrObj,
1354 : const SwRect& rOldBox )
1355 : {
1356 0 : SolarMutexGuard aGuard;
1357 :
1358 0 : if( HasTableData() )
1359 : {
1360 : OSL_ENSURE( !HasTableData() ||
1361 : GetFrm()->Frm().Pos() == GetTableData().GetTablePos(),
1362 : "table has invalid position" );
1363 0 : if( HasTableData() )
1364 : {
1365 0 : SwAccessibleTableData_Impl *pNewTableData = CreateNewTableData(); // #i77106#
1366 0 : if( !pNewTableData->CompareExtents( GetTableData() ) )
1367 : {
1368 0 : FireTableChangeEvent( GetTableData() );
1369 0 : ClearTableData();
1370 0 : mpTableData = pNewTableData;
1371 : }
1372 : else
1373 : {
1374 0 : delete pNewTableData;
1375 : }
1376 : }
1377 : }
1378 :
1379 : // #i013961# - always call super class method
1380 0 : SwAccessibleContext::InvalidateChildPosOrSize( rChildFrmOrObj, rOldBox );
1381 0 : }
1382 :
1383 :
1384 : //
1385 : // XAccessibleSelection
1386 : //
1387 :
1388 0 : void SAL_CALL SwAccessibleTable::selectAccessibleChild(
1389 : sal_Int32 nChildIndex )
1390 : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
1391 : {
1392 0 : SolarMutexGuard aGuard;
1393 0 : CHECK_FOR_DEFUNC( XAccessibleTable );
1394 :
1395 0 : if( (nChildIndex < 0) || (nChildIndex >= getAccessibleChildCount()) ) // #i77106#
1396 0 : throw lang::IndexOutOfBoundsException();
1397 :
1398 : // preliminaries: get 'our' table box, and get the cursor shell
1399 0 : const SwTableBox* pBox = GetTableBox( nChildIndex );
1400 : OSL_ENSURE( pBox != NULL, "We need the table box." );
1401 :
1402 0 : SwCrsrShell* pCrsrShell = GetCrsrShell();
1403 0 : if( pCrsrShell == NULL )
1404 : return;
1405 :
1406 : // assure, that child, indentified by the given index, isn't already selected.
1407 0 : if ( IsChildSelected( nChildIndex ) )
1408 : {
1409 : return;
1410 : }
1411 :
1412 : // now we can start to do the work: check whether we already have
1413 : // a table selection (in 'our' table). If so, extend the
1414 : // selection, else select the current cell.
1415 :
1416 : // if we have a selection in a table, check if it's in the
1417 : // same table that we're trying to select in
1418 0 : const SwTableNode* pSelectedTable = pCrsrShell->IsCrsrInTbl();
1419 0 : if( pSelectedTable != NULL )
1420 : {
1421 : // get top-most table line
1422 0 : const SwTableLine* pUpper = pBox->GetUpper();
1423 0 : while( pUpper->GetUpper() != NULL )
1424 0 : pUpper = pUpper->GetUpper()->GetUpper();
1425 : sal_uInt16 nPos =
1426 0 : pSelectedTable->GetTable().GetTabLines().GetPos( pUpper );
1427 0 : if( nPos == USHRT_MAX )
1428 0 : pSelectedTable = NULL;
1429 : }
1430 :
1431 : // create the new selection
1432 0 : const SwStartNode* pStartNode = pBox->GetSttNd();
1433 0 : if( pSelectedTable == NULL || !pCrsrShell->GetTblCrs() )
1434 : {
1435 0 : pCrsrShell->StartAction();
1436 : // Set cursor into current cell. This deletes any table cursor.
1437 0 : SwPaM aPaM( *pStartNode );
1438 0 : aPaM.Move( fnMoveForward, fnGoNode );
1439 0 : Select( aPaM );
1440 : // Move cursor to the end of the table creating a selection and a table
1441 : // cursor.
1442 0 : pCrsrShell->SetMark();
1443 0 : pCrsrShell->MoveTable( fnTableCurr, fnTableEnd );
1444 : // now set the cursor into the cell again.
1445 0 : SwPaM *pPaM = pCrsrShell->GetTblCrs() ? pCrsrShell->GetTblCrs()
1446 0 : : pCrsrShell->GetCrsr();
1447 0 : *pPaM->GetPoint() = *pPaM->GetMark();
1448 0 : pCrsrShell->EndAction();
1449 : // we now have one cell selected!
1450 : }
1451 : else
1452 : {
1453 : // if the cursor is already in this table,
1454 : // expand the current selection (i.e., set
1455 : // point to new position; keep mark)
1456 0 : SwPaM aPaM( *pStartNode );
1457 0 : aPaM.Move( fnMoveForward, fnGoNode );
1458 0 : aPaM.SetMark();
1459 0 : const SwPaM *pPaM = pCrsrShell->GetTblCrs() ? pCrsrShell->GetTblCrs()
1460 0 : : pCrsrShell->GetCrsr();
1461 0 : *(aPaM.GetMark()) = *pPaM->GetMark();
1462 0 : Select( aPaM );
1463 :
1464 0 : }
1465 : }
1466 :
1467 :
1468 0 : sal_Bool SAL_CALL SwAccessibleTable::isAccessibleChildSelected(
1469 : sal_Int32 nChildIndex )
1470 : throw ( lang::IndexOutOfBoundsException,
1471 : uno::RuntimeException )
1472 : {
1473 0 : SolarMutexGuard aGuard;
1474 0 : CHECK_FOR_DEFUNC( XAccessibleTable );
1475 :
1476 0 : if( (nChildIndex < 0) || (nChildIndex >= getAccessibleChildCount()) ) // #i77106#
1477 0 : throw lang::IndexOutOfBoundsException();
1478 :
1479 0 : return IsChildSelected( nChildIndex );
1480 : }
1481 :
1482 0 : void SAL_CALL SwAccessibleTable::clearAccessibleSelection( )
1483 : throw ( uno::RuntimeException )
1484 : {
1485 0 : SolarMutexGuard aGuard;
1486 :
1487 0 : CHECK_FOR_DEFUNC( XAccessibleTable );
1488 :
1489 0 : SwCrsrShell* pCrsrShell = GetCrsrShell();
1490 0 : if( pCrsrShell != NULL )
1491 : {
1492 0 : pCrsrShell->StartAction();
1493 0 : pCrsrShell->ClearMark();
1494 0 : pCrsrShell->EndAction();
1495 0 : }
1496 0 : }
1497 :
1498 0 : void SAL_CALL SwAccessibleTable::selectAllAccessibleChildren( )
1499 : throw ( uno::RuntimeException )
1500 : {
1501 : // first clear selection, then select first and last child
1502 0 : clearAccessibleSelection();
1503 0 : selectAccessibleChild( 0 );
1504 0 : selectAccessibleChild( getAccessibleChildCount()-1 ); // #i77106#
1505 0 : }
1506 :
1507 0 : sal_Int32 SAL_CALL SwAccessibleTable::getSelectedAccessibleChildCount( )
1508 : throw ( uno::RuntimeException )
1509 : {
1510 0 : SolarMutexGuard aGuard;
1511 0 : CHECK_FOR_DEFUNC( XAccessibleTable );
1512 :
1513 : // iterate over all children and count isAccessibleChildSelected()
1514 0 : sal_Int32 nCount = 0;
1515 :
1516 0 : sal_Int32 nChildren = getAccessibleChildCount(); // #i71106#
1517 0 : for( sal_Int32 n = 0; n < nChildren; n++ )
1518 0 : if( IsChildSelected( n ) )
1519 0 : nCount++;
1520 :
1521 0 : return nCount;
1522 : }
1523 :
1524 0 : uno::Reference<XAccessible> SAL_CALL SwAccessibleTable::getSelectedAccessibleChild(
1525 : sal_Int32 nSelectedChildIndex )
1526 : throw ( lang::IndexOutOfBoundsException,
1527 : uno::RuntimeException)
1528 : {
1529 0 : SolarMutexGuard aGuard;
1530 0 : CHECK_FOR_DEFUNC( XAccessibleTable );
1531 :
1532 : // paremter checking (part 1): index lower 0
1533 0 : if( nSelectedChildIndex < 0 )
1534 0 : throw lang::IndexOutOfBoundsException();
1535 :
1536 0 : sal_Int32 nChildIndex = GetIndexOfSelectedChild( nSelectedChildIndex );
1537 :
1538 : // parameter checking (part 2): index higher than selected children?
1539 0 : if( nChildIndex < 0 )
1540 0 : throw lang::IndexOutOfBoundsException();
1541 :
1542 : // #i77106#
1543 0 : if ( nChildIndex >= getAccessibleChildCount() )
1544 : {
1545 0 : throw lang::IndexOutOfBoundsException();
1546 : }
1547 :
1548 0 : return getAccessibleChild( nChildIndex );
1549 : }
1550 :
1551 : // index has to be treated as global child index.
1552 0 : void SAL_CALL SwAccessibleTable::deselectAccessibleChild(
1553 : sal_Int32 nChildIndex )
1554 : throw ( lang::IndexOutOfBoundsException,
1555 : uno::RuntimeException )
1556 : {
1557 0 : SolarMutexGuard aGuard;
1558 0 : CHECK_FOR_DEFUNC( XAccessibleTable );
1559 :
1560 0 : SwCrsrShell* pCrsrShell = GetCrsrShell();
1561 :
1562 : // index has to be treated as global child index
1563 0 : if ( !pCrsrShell )
1564 0 : throw lang::IndexOutOfBoundsException();
1565 :
1566 : // assure, that given child index is in bounds.
1567 0 : if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() ) // #i77106#
1568 0 : throw lang::IndexOutOfBoundsException();
1569 :
1570 : // assure, that child, identified by the given index, is selected.
1571 0 : if ( !IsChildSelected( nChildIndex ) )
1572 0 : return;
1573 :
1574 0 : const SwTableBox* pBox = GetTableBox( nChildIndex );
1575 : OSL_ENSURE( pBox != NULL, "We need the table box." );
1576 :
1577 : // If we unselect point, then set cursor to mark. If we clear another
1578 : // selected box, then set cursor to point.
1579 : // reduce selection to mark.
1580 0 : SwPaM *pPaM = pCrsrShell->GetTblCrs() ? pCrsrShell->GetTblCrs()
1581 0 : : pCrsrShell->GetCrsr();
1582 : sal_Bool bDeselectPoint =
1583 0 : pBox->GetSttNd() ==
1584 0 : pPaM->GetPoint()->nNode.GetNode().FindTableBoxStartNode();
1585 :
1586 0 : SwPaM aPaM( bDeselectPoint ? *pPaM->GetMark() : *pPaM->GetPoint() );
1587 :
1588 0 : pCrsrShell->StartAction();
1589 :
1590 : // Set cursor into either point or mark
1591 0 : Select( aPaM );
1592 : // Move cursor to the end of the table creating a selection and a table
1593 : // cursor.
1594 0 : pCrsrShell->SetMark();
1595 0 : pCrsrShell->MoveTable( fnTableCurr, fnTableEnd );
1596 : // now set the cursor into the cell again.
1597 0 : pPaM = pCrsrShell->GetTblCrs() ? pCrsrShell->GetTblCrs()
1598 0 : : pCrsrShell->GetCrsr();
1599 0 : *pPaM->GetPoint() = *pPaM->GetMark();
1600 0 : pCrsrShell->EndAction();
1601 : }
1602 :
1603 : // #i77106# - implementation of class <SwAccessibleTableColHeaders>
1604 0 : SwAccessibleTableColHeaders::SwAccessibleTableColHeaders( SwAccessibleMap *pMap2,
1605 : const SwTabFrm *pTabFrm )
1606 0 : : SwAccessibleTable( pMap2, pTabFrm )
1607 : {
1608 0 : SolarMutexGuard aGuard;
1609 :
1610 0 : const SwFrmFmt *pFrmFmt = pTabFrm->GetFmt();
1611 0 : const_cast< SwFrmFmt * >( pFrmFmt )->Add( this );
1612 0 : const String& rName = pFrmFmt->GetName();
1613 :
1614 0 : OUStringBuffer aBuffer( rName.Len() + 15 + 6 );
1615 0 : aBuffer.append( OUString(rName) );
1616 0 : aBuffer.append( rtl::OUString("-ColumnHeaders-") );
1617 0 : aBuffer.append( static_cast<sal_Int32>( pTabFrm->GetPhyPageNum() ) );
1618 :
1619 0 : SetName( aBuffer.makeStringAndClear() );
1620 :
1621 0 : OUStringBuffer aBuffer2( rName.Len() + 14 );
1622 0 : aBuffer2.append( OUString(rName) );
1623 0 : aBuffer2.append( rtl::OUString("-ColumnHeaders") );
1624 0 : OUString sArg1( aBuffer2.makeStringAndClear() );
1625 0 : OUString sArg2( GetFormattedPageNumber() );
1626 :
1627 0 : OUString sDesc2 = GetResource( STR_ACCESS_TABLE_DESC, &sArg1, &sArg2 );
1628 0 : SetDesc( sDesc2 );
1629 :
1630 0 : NotRegisteredAtAccessibleMap(); // #i85634#
1631 0 : }
1632 :
1633 0 : SwAccessibleTableData_Impl* SwAccessibleTableColHeaders::CreateNewTableData()
1634 : {
1635 0 : const SwTabFrm* pTabFrm = static_cast<const SwTabFrm*>( GetFrm() );
1636 0 : return new SwAccessibleTableData_Impl( *(GetMap()), pTabFrm, IsInPagePreview(), true );
1637 : }
1638 :
1639 :
1640 0 : void SwAccessibleTableColHeaders::Modify( const SfxPoolItem * /*pOld*/, const SfxPoolItem * /*pNew*/ )
1641 : {
1642 0 : }
1643 :
1644 : //===== XInterface ======================================================
1645 0 : uno::Any SAL_CALL SwAccessibleTableColHeaders::queryInterface( const uno::Type& aType )
1646 : throw (uno::RuntimeException)
1647 : {
1648 0 : return SwAccessibleTable::queryInterface( aType );
1649 : }
1650 :
1651 : //===== XAccessibleContext ==============================================
1652 0 : sal_Int32 SAL_CALL SwAccessibleTableColHeaders::getAccessibleChildCount(void)
1653 : throw (uno::RuntimeException)
1654 : {
1655 0 : SolarMutexGuard aGuard;
1656 :
1657 0 : CHECK_FOR_DEFUNC( XAccessibleContext )
1658 :
1659 0 : sal_Int32 nCount = 0;
1660 :
1661 0 : const SwTabFrm* pTabFrm = static_cast<const SwTabFrm*>( GetFrm() );
1662 0 : const SwAccessibleChildSList aVisList( GetVisArea(), *pTabFrm, *(GetMap()) );
1663 0 : SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
1664 0 : while( aIter != aVisList.end() )
1665 : {
1666 0 : const SwAccessibleChild& rLower = *aIter;
1667 0 : if( rLower.IsAccessible( IsInPagePreview() ) )
1668 : {
1669 0 : nCount++;
1670 : }
1671 0 : else if( rLower.GetSwFrm() )
1672 : {
1673 : // There are no unaccessible SdrObjects that count
1674 0 : if ( !rLower.GetSwFrm()->IsRowFrm() ||
1675 0 : pTabFrm->IsInHeadline( *(rLower.GetSwFrm()) ) )
1676 : {
1677 0 : nCount += SwAccessibleFrame::GetChildCount( *(GetMap()),
1678 0 : GetVisArea(),
1679 : rLower.GetSwFrm(),
1680 0 : IsInPagePreview() );
1681 : }
1682 : }
1683 0 : ++aIter;
1684 : }
1685 :
1686 0 : return nCount;
1687 : }
1688 :
1689 : uno::Reference< XAccessible> SAL_CALL
1690 0 : SwAccessibleTableColHeaders::getAccessibleChild (sal_Int32 nIndex)
1691 : throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
1692 : {
1693 0 : if ( nIndex < 0 || nIndex >= getAccessibleChildCount() )
1694 : {
1695 0 : throw lang::IndexOutOfBoundsException();
1696 : }
1697 :
1698 0 : return SwAccessibleTable::getAccessibleChild( nIndex );
1699 : }
1700 :
1701 : //===== XAccessibleTable ================================================
1702 : uno::Reference< XAccessibleTable >
1703 0 : SAL_CALL SwAccessibleTableColHeaders::getAccessibleRowHeaders()
1704 : throw (uno::RuntimeException)
1705 : {
1706 0 : return uno::Reference< XAccessibleTable >();
1707 : }
1708 :
1709 : uno::Reference< XAccessibleTable >
1710 0 : SAL_CALL SwAccessibleTableColHeaders::getAccessibleColumnHeaders()
1711 : throw (uno::RuntimeException)
1712 : {
1713 0 : return uno::Reference< XAccessibleTable >();
1714 : }
1715 :
1716 : //===== XServiceInfo ====================================================
1717 :
1718 0 : ::rtl::OUString SAL_CALL SwAccessibleTableColHeaders::getImplementationName (void)
1719 : throw (uno::RuntimeException)
1720 : {
1721 : static const sal_Char sImplName[] = "com.sun.star.comp.Writer.SwAccessibleTableColumnHeadersView";
1722 0 : return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplName));
1723 : }
1724 :
1725 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|