merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / Accessibility / AccessiblePreviewTable.cxx
blob70de804c00421592e9a6ed6af17b51186a9124ab
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessiblePreviewTable.cxx,v $
10 * $Revision: 1.28 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include "scitems.hxx"
35 #include "AccessiblePreviewTable.hxx"
36 #include "AccessiblePreviewCell.hxx"
37 #include "AccessiblePreviewHeaderCell.hxx"
38 #include "AccessibilityHints.hxx"
39 #include "prevwsh.hxx"
40 #include "unoguard.hxx"
41 #include "miscuno.hxx"
42 #include "prevloc.hxx"
43 #include "attrib.hxx"
44 #include "document.hxx"
45 #include "scresid.hxx"
46 #ifndef SC_SC_HRC
47 #include "sc.hrc"
48 #endif
50 #include <com/sun/star/accessibility/AccessibleRole.hpp>
51 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
52 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
54 #include <vcl/window.hxx>
55 #include <svtools/smplhint.hxx>
56 #include <unotools/accessiblestatesethelper.hxx>
57 #include <comphelper/sequence.hxx>
59 using namespace ::com::sun::star;
60 using namespace ::com::sun::star::accessibility;
62 //===== internal ============================================================
64 ScAccessiblePreviewTable::ScAccessiblePreviewTable( const ::com::sun::star::uno::Reference<
65 ::com::sun::star::accessibility::XAccessible>& rxParent,
66 ScPreviewShell* pViewShell, sal_Int32 nIndex ) :
67 ScAccessibleContextBase( rxParent, AccessibleRole::TABLE ),
68 mpViewShell( pViewShell ),
69 mnIndex( nIndex ),
70 mpTableInfo( NULL )
72 if (mpViewShell)
73 mpViewShell->AddAccessibilityObject(*this);
76 ScAccessiblePreviewTable::~ScAccessiblePreviewTable()
78 if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
80 // increment refcount to prevent double call off dtor
81 osl_incrementInterlockedCount( &m_refCount );
82 dispose();
86 void SAL_CALL ScAccessiblePreviewTable::disposing()
88 ScUnoGuard aGuard;
89 if (mpViewShell)
91 mpViewShell->RemoveAccessibilityObject(*this);
92 mpViewShell = NULL;
95 if (mpTableInfo)
96 DELETEZ (mpTableInfo);
98 ScAccessibleContextBase::disposing();
101 //===== SfxListener =====================================================
103 void ScAccessiblePreviewTable::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
105 if (rHint.ISA( SfxSimpleHint ))
107 const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
108 ULONG nId = rRef.GetId();
109 if ( nId == SFX_HINT_DATACHANGED )
111 // column / row layout may change with any document change,
112 // so it must be invalidated
113 DELETEZ( mpTableInfo );
115 else if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED)
117 AccessibleEventObject aEvent;
118 aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
119 aEvent.Source = uno::Reference< XAccessibleContext >(this);
120 CommitChange(aEvent);
124 ScAccessibleContextBase::Notify(rBC, rHint);
127 //===== XInterface =====================================================
129 uno::Any SAL_CALL ScAccessiblePreviewTable::queryInterface( uno::Type const & rType )
130 throw (uno::RuntimeException)
132 uno::Any aAny (ScAccessiblePreviewTableImpl::queryInterface(rType));
133 return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
136 void SAL_CALL ScAccessiblePreviewTable::acquire()
137 throw ()
139 ScAccessibleContextBase::acquire();
142 void SAL_CALL ScAccessiblePreviewTable::release()
143 throw ()
145 ScAccessibleContextBase::release();
148 //===== XAccessibleTable ================================================
150 sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowCount() throw (uno::RuntimeException)
152 ScUnoGuard aGuard;
153 IsObjectValid();
155 FillTableInfo();
157 sal_Int32 nRet = 0;
158 if ( mpTableInfo )
159 nRet = mpTableInfo->GetRows();
160 return nRet;
163 sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnCount() throw (uno::RuntimeException)
165 ScUnoGuard aGuard;
166 IsObjectValid();
168 FillTableInfo();
170 sal_Int32 nRet = 0;
171 if ( mpTableInfo )
172 nRet = mpTableInfo->GetCols();
173 return nRet;
176 rtl::OUString SAL_CALL ScAccessiblePreviewTable::getAccessibleRowDescription( sal_Int32 nRow )
177 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
179 // is not supported or specified so not implemented
180 /* ScUnoGuard aGuard;
181 IsObjectValid();
183 FillTableInfo();
185 rtl::OUString sName;
186 if ( mpTableInfo && nRow >= 0 && nRow < mpTableInfo->GetRows() )
188 const ScPreviewColRowInfo& rInfo = mpTableInfo->GetRowInfo()[nRow];
189 if ( rInfo.bIsHeader )
191 //! name of column headers row?
193 sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Column Headers"));
195 else
197 // normal row name
198 sName = rtl::OUString::valueOf( (sal_Int32) ( rInfo.nDocIndex + 1 ) );
201 else
202 throw lang::IndexOutOfBoundsException();*/
204 ScUnoGuard aGuard;
205 FillTableInfo();
206 if ( nRow < 0 || (mpTableInfo && nRow >= mpTableInfo->GetRows()) )
207 throw lang::IndexOutOfBoundsException();
209 return rtl::OUString();
212 rtl::OUString SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnDescription( sal_Int32 nColumn )
213 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
215 // is not supported or specified so not implemented
216 /* ScUnoGuard aGuard;
217 IsObjectValid();
219 FillTableInfo();
221 rtl::OUString sName;
222 if ( mpTableInfo && nColumn >= 0 && nColumn < mpTableInfo->GetCols() )
224 const ScPreviewColRowInfo& rInfo = mpTableInfo->GetColInfo()[nColumn];
225 if ( rInfo.bIsHeader )
227 //! name of row headers column?
229 sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Row Headers"));
231 else
233 // normal column name
234 sName = ScColToAlpha( rInfo.nDocIndex );
237 else
238 throw lang::IndexOutOfBoundsException();*/
240 ScUnoGuard aGuard;
241 FillTableInfo();
242 if ( nColumn < 0 || (mpTableInfo && nColumn >= mpTableInfo->GetCols()) )
243 throw lang::IndexOutOfBoundsException();
245 return rtl::OUString();
248 sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
249 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
251 ScUnoGuard aGuard;
252 IsObjectValid();
254 FillTableInfo();
256 sal_Int32 nRows = 1;
257 if ( mpViewShell && mpTableInfo && nColumn >= 0 && nRow >= 0 &&
258 nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
260 const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[nColumn];
261 const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[nRow];
263 if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
265 // header cells only span a single cell
267 else
269 ScDocument* pDoc = mpViewShell->GetDocument();
270 const ScMergeAttr* pItem = (const ScMergeAttr*)pDoc->GetAttr(
271 static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab(), ATTR_MERGE );
272 if ( pItem && pItem->GetRowMerge() > 0 )
273 nRows = pItem->GetRowMerge();
276 else
277 throw lang::IndexOutOfBoundsException();
279 return nRows;
282 sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
283 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
285 ScUnoGuard aGuard;
286 IsObjectValid();
288 FillTableInfo();
290 sal_Int32 nColumns = 1;
291 if ( mpViewShell && mpTableInfo && nColumn >= 0 && nRow >= 0 &&
292 nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
294 const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[nColumn];
295 const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[nRow];
297 if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
299 // header cells only span a single cell
301 else
303 ScDocument* pDoc = mpViewShell->GetDocument();
304 const ScMergeAttr* pItem = (const ScMergeAttr*)pDoc->GetAttr(
305 static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab(), ATTR_MERGE );
306 if ( pItem && pItem->GetColMerge() > 0 )
307 nColumns = pItem->GetColMerge();
310 else
311 throw lang::IndexOutOfBoundsException();
313 return nColumns;
316 uno::Reference< XAccessibleTable > SAL_CALL ScAccessiblePreviewTable::getAccessibleRowHeaders() throw (uno::RuntimeException)
318 //! missing
319 return NULL;
322 uno::Reference< XAccessibleTable > SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnHeaders() throw (uno::RuntimeException)
324 //! missing
325 return NULL;
328 uno::Sequence< sal_Int32 > SAL_CALL ScAccessiblePreviewTable::getSelectedAccessibleRows() throw (uno::RuntimeException)
330 // in the page preview, there is no selection
331 return uno::Sequence<sal_Int32>(0);
334 uno::Sequence< sal_Int32 > SAL_CALL ScAccessiblePreviewTable::getSelectedAccessibleColumns() throw (uno::RuntimeException)
336 // in the page preview, there is no selection
337 return uno::Sequence<sal_Int32>(0);
340 sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleRowSelected( sal_Int32 nRow )
341 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
343 // in the page preview, there is no selection
345 ScUnoGuard aGuard;
346 FillTableInfo();
347 if ( nRow < 0 || (mpTableInfo && nRow >= mpTableInfo->GetRows()) )
348 throw lang::IndexOutOfBoundsException();
350 return sal_False;
353 sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleColumnSelected( sal_Int32 nColumn )
354 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
356 // in the page preview, there is no selection
358 ScUnoGuard aGuard;
359 FillTableInfo();
360 if ( nColumn < 0 || (mpTableInfo && nColumn >= mpTableInfo->GetCols()) )
361 throw lang::IndexOutOfBoundsException();
363 return sal_False;
366 uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
367 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
369 ScUnoGuard aGuard;
370 IsObjectValid();
372 FillTableInfo();
374 uno::Reference<XAccessible> xRet;
375 if ( mpTableInfo && nColumn >= 0 && nRow >= 0 && nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
377 // index iterates horizontally
378 long nNewIndex = nRow * mpTableInfo->GetCols() + nColumn;
380 const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[nColumn];
381 const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[nRow];
383 ScAddress aCellPos( static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab() );
384 if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
386 ScAccessiblePreviewHeaderCell* pHeaderCell = new ScAccessiblePreviewHeaderCell( this, mpViewShell, aCellPos,
387 rRowInfo.bIsHeader, rColInfo.bIsHeader, nNewIndex );
388 xRet = pHeaderCell;
389 pHeaderCell->Init();
391 else
393 ScAccessiblePreviewCell* pCell = new ScAccessiblePreviewCell( this, mpViewShell, aCellPos, nNewIndex );
394 xRet = pCell;
395 pCell->Init();
399 if ( !xRet.is() )
400 throw lang::IndexOutOfBoundsException();
402 return xRet;
405 uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleCaption() throw (uno::RuntimeException)
407 //! missing
408 return NULL;
411 uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleSummary() throw (uno::RuntimeException)
413 //! missing
414 return NULL;
417 sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
418 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
420 // in the page preview, there is no selection
421 ScUnoGuard aGuard;
422 IsObjectValid();
424 FillTableInfo();
426 if ( mpTableInfo && nColumn >= 0 && nRow >= 0 && nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
428 // index iterates horizontally
430 else
431 throw lang::IndexOutOfBoundsException();
433 return sal_False;
436 sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
437 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
439 ScUnoGuard aGuard;
440 IsObjectValid();
442 FillTableInfo();
444 sal_Int32 nRet = 0;
445 if ( mpTableInfo && nColumn >= 0 && nRow >= 0 && nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
447 // index iterates horizontally
448 nRet = nRow * mpTableInfo->GetCols() + nColumn;
450 else
451 throw lang::IndexOutOfBoundsException();
453 return nRet;
456 sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRow( sal_Int32 nChildIndex )
457 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
459 ScUnoGuard aGuard;
460 IsObjectValid();
462 FillTableInfo();
464 sal_Int32 nRow = 0;
465 if ( mpTableInfo && nChildIndex >= 0 && nChildIndex < static_cast<sal_Int32>(mpTableInfo->GetRows()) * mpTableInfo->GetCols() )
467 nRow = nChildIndex / mpTableInfo->GetCols();
469 else
470 throw lang::IndexOutOfBoundsException();
472 return nRow;
475 sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumn( sal_Int32 nChildIndex )
476 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
478 ScUnoGuard aGuard;
479 IsObjectValid();
481 FillTableInfo();
483 sal_Int32 nCol = 0;
484 if ( mpTableInfo && nChildIndex >= 0 && nChildIndex < static_cast<sal_Int32>(mpTableInfo->GetRows()) * mpTableInfo->GetCols() )
486 nCol = nChildIndex % static_cast<sal_Int32>(mpTableInfo->GetCols());
488 else
489 throw lang::IndexOutOfBoundsException();
491 return nCol;
494 //===== XAccessibleComponent ============================================
496 uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleAtPoint( const awt::Point& aPoint )
497 throw (uno::RuntimeException)
499 uno::Reference<XAccessible> xRet;
500 if (containsPoint(aPoint))
502 ScUnoGuard aGuard;
503 IsObjectValid();
505 FillTableInfo();
507 if ( mpTableInfo )
509 SCCOL nCols = mpTableInfo->GetCols();
510 SCROW nRows = mpTableInfo->GetRows();
511 const ScPreviewColRowInfo* pColInfo = mpTableInfo->GetColInfo();
512 const ScPreviewColRowInfo* pRowInfo = mpTableInfo->GetRowInfo();
514 Rectangle aScreenRect(GetBoundingBox());
516 awt::Point aMovedPoint = aPoint;
517 aMovedPoint.X += aScreenRect.Left();
518 aMovedPoint.Y += aScreenRect.Top();
520 if ( nCols > 0 && nRows > 0 && aMovedPoint.X >= pColInfo[0].nPixelStart && aMovedPoint.Y >= pRowInfo[0].nPixelStart )
522 SCCOL nColIndex = 0;
523 while ( nColIndex < nCols && aMovedPoint.X > pColInfo[nColIndex].nPixelEnd )
524 ++nColIndex;
525 SCROW nRowIndex = 0;
526 while ( nRowIndex < nRows && aMovedPoint.Y > pRowInfo[nRowIndex].nPixelEnd )
527 ++nRowIndex;
528 if ( nColIndex < nCols && nRowIndex < nRows )
532 xRet = getAccessibleCellAt( nRowIndex, nColIndex );
534 catch (uno::Exception&)
542 return xRet;
545 void SAL_CALL ScAccessiblePreviewTable::grabFocus() throw (uno::RuntimeException)
547 ScUnoGuard aGuard;
548 IsObjectValid();
549 if (getAccessibleParent().is())
551 uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
552 if (xAccessibleComponent.is())
553 xAccessibleComponent->grabFocus();
557 //===== XAccessibleContext ==============================================
559 sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleChildCount() throw (uno::RuntimeException)
561 ScUnoGuard aGuard;
562 IsObjectValid();
564 FillTableInfo();
566 long nRet = 0;
567 if ( mpTableInfo )
568 nRet = static_cast<sal_Int32>(mpTableInfo->GetCols()) * mpTableInfo->GetRows();
569 return nRet;
572 uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleChild( sal_Int32 nIndex )
573 throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
575 ScUnoGuard aGuard;
576 IsObjectValid();
578 FillTableInfo();
580 uno::Reference<XAccessible> xRet;
581 if ( mpTableInfo )
583 long nColumns = mpTableInfo->GetCols();
584 if ( nColumns > 0 )
586 // nCol, nRow are within the visible table, not the document
587 long nCol = nIndex % nColumns;
588 long nRow = nIndex / nColumns;
590 xRet = getAccessibleCellAt( nRow, nCol );
594 if ( !xRet.is() )
595 throw lang::IndexOutOfBoundsException();
597 return xRet;
600 sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleIndexInParent() throw (uno::RuntimeException)
602 return mnIndex;
605 uno::Reference< XAccessibleStateSet > SAL_CALL ScAccessiblePreviewTable::getAccessibleStateSet()
606 throw (uno::RuntimeException)
608 ScUnoGuard aGuard;
609 uno::Reference<XAccessibleStateSet> xParentStates;
610 if (getAccessibleParent().is())
612 uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
613 xParentStates = xParentContext->getAccessibleStateSet();
615 utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
616 if (IsDefunc(xParentStates))
617 pStateSet->AddState(AccessibleStateType::DEFUNC);
618 else
620 pStateSet->AddState(AccessibleStateType::MANAGES_DESCENDANTS);
621 pStateSet->AddState(AccessibleStateType::ENABLED);
622 pStateSet->AddState(AccessibleStateType::OPAQUE);
623 if (isShowing())
624 pStateSet->AddState(AccessibleStateType::SHOWING);
625 if (isVisible())
626 pStateSet->AddState(AccessibleStateType::VISIBLE);
628 return pStateSet;
631 //===== XServiceInfo ====================================================
633 rtl::OUString SAL_CALL ScAccessiblePreviewTable::getImplementationName() throw(uno::RuntimeException)
635 return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAccessiblePreviewTable"));
638 uno::Sequence<rtl::OUString> SAL_CALL ScAccessiblePreviewTable::getSupportedServiceNames()
639 throw(uno::RuntimeException)
641 uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
642 sal_Int32 nOldSize(aSequence.getLength());
643 aSequence.realloc(nOldSize + 1);
644 ::rtl::OUString* pNames = aSequence.getArray();
646 pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.AccessibleTableView"));
648 return aSequence;
651 //===== XTypeProvider ===================================================
653 uno::Sequence< uno::Type > SAL_CALL ScAccessiblePreviewTable::getTypes()
654 throw (uno::RuntimeException)
656 return comphelper::concatSequences(ScAccessiblePreviewTableImpl::getTypes(), ScAccessibleContextBase::getTypes());
659 uno::Sequence<sal_Int8> SAL_CALL ScAccessiblePreviewTable::getImplementationId()
660 throw(uno::RuntimeException)
662 static uno::Sequence< sal_Int8 > aId;
663 if( aId.getLength() == 0 )
665 aId.realloc( 16 );
666 rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
668 return aId;
671 //==== internal =========================================================
673 ::rtl::OUString SAL_CALL ScAccessiblePreviewTable::createAccessibleDescription(void)
674 throw (uno::RuntimeException)
676 String sDesc(ScResId(STR_ACC_TABLE_DESCR));
677 /* if (mpViewShell && mpViewShell->GetDocument())
679 FillTableInfo();
681 if ( mpTableInfo )
683 String sCoreName;
684 if (mpViewShell->GetDocument()->GetName( mpTableInfo->GetTab(), sCoreName ))
685 sDesc.SearchAndReplaceAscii("%1", sCoreName);
688 sDesc.SearchAndReplaceAscii("%2", String(ScResId(SCSTR_UNKNOWN)));*/
689 return rtl::OUString(sDesc);
692 ::rtl::OUString SAL_CALL ScAccessiblePreviewTable::createAccessibleName(void)
693 throw (uno::RuntimeException)
695 String sName(ScResId(STR_ACC_TABLE_NAME));
697 if (mpViewShell && mpViewShell->GetDocument())
699 FillTableInfo();
701 if ( mpTableInfo )
703 String sCoreName;
704 if (mpViewShell->GetDocument()->GetName( mpTableInfo->GetTab(), sCoreName ))
705 sName.SearchAndReplaceAscii("%1", sCoreName);
709 return rtl::OUString(sName);
712 Rectangle ScAccessiblePreviewTable::GetBoundingBoxOnScreen() const throw (uno::RuntimeException)
714 Rectangle aCellRect(GetBoundingBox());
715 if (mpViewShell)
717 Window* pWindow = mpViewShell->GetWindow();
718 if (pWindow)
720 Rectangle aRect = pWindow->GetWindowExtentsRelative(NULL);
721 aCellRect.setX(aCellRect.getX() + aRect.getX());
722 aCellRect.setY(aCellRect.getY() + aRect.getY());
725 return aCellRect;
728 Rectangle ScAccessiblePreviewTable::GetBoundingBox() const throw (uno::RuntimeException)
730 FillTableInfo();
732 Rectangle aRect;
733 if ( mpTableInfo )
735 SCCOL nColumns = mpTableInfo->GetCols();
736 SCROW nRows = mpTableInfo->GetRows();
737 if ( nColumns > 0 && nRows > 0 )
739 const ScPreviewColRowInfo* pColInfo = mpTableInfo->GetColInfo();
740 const ScPreviewColRowInfo* pRowInfo = mpTableInfo->GetRowInfo();
742 aRect = Rectangle( pColInfo[0].nPixelStart,
743 pRowInfo[0].nPixelStart,
744 pColInfo[nColumns-1].nPixelEnd,
745 pRowInfo[nRows-1].nPixelEnd );
748 return aRect;
751 sal_Bool ScAccessiblePreviewTable::IsDefunc( const uno::Reference<XAccessibleStateSet>& rxParentStates )
753 return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() ||
754 (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
757 void ScAccessiblePreviewTable::FillTableInfo() const
759 if ( mpViewShell && !mpTableInfo )
761 Size aOutputSize;
762 Window* pWindow = mpViewShell->GetWindow();
763 if ( pWindow )
764 aOutputSize = pWindow->GetOutputSizePixel();
765 Point aPoint;
766 Rectangle aVisRect( aPoint, aOutputSize );
768 mpTableInfo = new ScPreviewTableInfo;
769 mpViewShell->GetLocationData().GetTableInfo( aVisRect, *mpTableInfo );