1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_sc.hxx" 30*cdf0e10cSrcweir #include "scitems.hxx" 31*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 32*cdf0e10cSrcweir #include <tools/gen.hxx> 33*cdf0e10cSrcweir #include "AccessibleText.hxx" 34*cdf0e10cSrcweir #include "editsrc.hxx" 35*cdf0e10cSrcweir #include <svx/AccessibleTextHelper.hxx> 36*cdf0e10cSrcweir #include "AccessiblePreviewHeaderCell.hxx" 37*cdf0e10cSrcweir #include "AccessibilityHints.hxx" 38*cdf0e10cSrcweir #include "prevwsh.hxx" 39*cdf0e10cSrcweir #include "unoguard.hxx" 40*cdf0e10cSrcweir #include "miscuno.hxx" 41*cdf0e10cSrcweir #include "prevloc.hxx" 42*cdf0e10cSrcweir #include "scresid.hxx" 43*cdf0e10cSrcweir #ifndef SC_SC_HRC 44*cdf0e10cSrcweir #include "sc.hrc" 45*cdf0e10cSrcweir #endif 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #include <vcl/window.hxx> 51*cdf0e10cSrcweir #include <svl/smplhint.hxx> 52*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 53*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 54*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir using namespace ::com::sun::star; 57*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir //===== internal ============================================================ 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir ScAccessiblePreviewHeaderCell::ScAccessiblePreviewHeaderCell( const ::com::sun::star::uno::Reference< 62*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxParent, 63*cdf0e10cSrcweir ScPreviewShell* pViewShell, 64*cdf0e10cSrcweir const ScAddress& rCellPos, sal_Bool bIsColHdr, sal_Bool bIsRowHdr, 65*cdf0e10cSrcweir sal_Int32 nIndex ) : 66*cdf0e10cSrcweir ScAccessibleContextBase( rxParent, AccessibleRole::TABLE_CELL ), 67*cdf0e10cSrcweir mpViewShell( pViewShell ), 68*cdf0e10cSrcweir mpTextHelper( NULL ), 69*cdf0e10cSrcweir mnIndex( nIndex ), 70*cdf0e10cSrcweir maCellPos( rCellPos ), 71*cdf0e10cSrcweir mbColumnHeader( bIsColHdr ), 72*cdf0e10cSrcweir mbRowHeader( bIsRowHdr ), 73*cdf0e10cSrcweir mpTableInfo( NULL ) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir if (mpViewShell) 76*cdf0e10cSrcweir mpViewShell->AddAccessibilityObject(*this); 77*cdf0e10cSrcweir } 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir ScAccessiblePreviewHeaderCell::~ScAccessiblePreviewHeaderCell() 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir if (mpViewShell) 82*cdf0e10cSrcweir mpViewShell->RemoveAccessibilityObject(*this); 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir void SAL_CALL ScAccessiblePreviewHeaderCell::disposing() 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir ScUnoGuard aGuard; 88*cdf0e10cSrcweir if (mpViewShell) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir mpViewShell->RemoveAccessibilityObject(*this); 91*cdf0e10cSrcweir mpViewShell = NULL; 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir if (mpTableInfo) 95*cdf0e10cSrcweir DELETEZ (mpTableInfo); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir ScAccessibleContextBase::disposing(); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir //===== SfxListener ===================================================== 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir void ScAccessiblePreviewHeaderCell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir if (rHint.ISA( SfxSimpleHint )) 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint; 107*cdf0e10cSrcweir sal_uLong nId = rRef.GetId(); 108*cdf0e10cSrcweir if (nId == SC_HINT_ACC_VISAREACHANGED) 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir if (mpTextHelper) 111*cdf0e10cSrcweir mpTextHelper->UpdateChildren(); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir else if ( nId == SFX_HINT_DATACHANGED ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir // column / row layout may change with any document change, 116*cdf0e10cSrcweir // so it must be invalidated 117*cdf0e10cSrcweir DELETEZ( mpTableInfo ); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir ScAccessibleContextBase::Notify(rBC, rHint); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir //===== XInterface ===================================================== 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::queryInterface( uno::Type const & rType ) 127*cdf0e10cSrcweir throw (uno::RuntimeException) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir uno::Any aAny (ScAccessiblePreviewHeaderCellImpl::queryInterface(rType)); 130*cdf0e10cSrcweir return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir void SAL_CALL ScAccessiblePreviewHeaderCell::acquire() 134*cdf0e10cSrcweir throw () 135*cdf0e10cSrcweir { 136*cdf0e10cSrcweir ScAccessibleContextBase::acquire(); 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir void SAL_CALL ScAccessiblePreviewHeaderCell::release() 140*cdf0e10cSrcweir throw () 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir ScAccessibleContextBase::release(); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir //===== XAccessibleValue ================================================ 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getCurrentValue() throw (uno::RuntimeException) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir ScUnoGuard aGuard; 150*cdf0e10cSrcweir IsObjectValid(); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir double fValue(0.0); 153*cdf0e10cSrcweir if (mbColumnHeader) 154*cdf0e10cSrcweir fValue = maCellPos.Col(); 155*cdf0e10cSrcweir else 156*cdf0e10cSrcweir fValue = maCellPos.Row(); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir uno::Any aAny; 159*cdf0e10cSrcweir aAny <<= fValue; 160*cdf0e10cSrcweir return aAny; 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessiblePreviewHeaderCell::setCurrentValue( const uno::Any& /* aNumber */ ) 164*cdf0e10cSrcweir throw (uno::RuntimeException) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir // it is not possible to set a value 167*cdf0e10cSrcweir return sal_False; 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getMaximumValue() throw (uno::RuntimeException) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir ScUnoGuard aGuard; 173*cdf0e10cSrcweir IsObjectValid(); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir double fValue(0.0); 176*cdf0e10cSrcweir if (mbColumnHeader) 177*cdf0e10cSrcweir fValue = MAXCOL; 178*cdf0e10cSrcweir else 179*cdf0e10cSrcweir fValue = MAXROW; 180*cdf0e10cSrcweir uno::Any aAny; 181*cdf0e10cSrcweir aAny <<= fValue; 182*cdf0e10cSrcweir return aAny; 183*cdf0e10cSrcweir } 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getMinimumValue() throw (uno::RuntimeException) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir double fValue(0.0); 188*cdf0e10cSrcweir uno::Any aAny; 189*cdf0e10cSrcweir aAny <<= fValue; 190*cdf0e10cSrcweir return aAny; 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir //===== XAccessibleComponent ============================================ 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleAtPoint( const awt::Point& rPoint ) 196*cdf0e10cSrcweir throw (uno::RuntimeException) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir uno::Reference<XAccessible> xRet; 199*cdf0e10cSrcweir if (containsPoint(rPoint)) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir ScUnoGuard aGuard; 202*cdf0e10cSrcweir IsObjectValid(); 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir if(!mpTextHelper) 205*cdf0e10cSrcweir CreateTextHelper(); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir xRet = mpTextHelper->GetAt(rPoint); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir return xRet; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir void SAL_CALL ScAccessiblePreviewHeaderCell::grabFocus() throw (uno::RuntimeException) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir ScUnoGuard aGuard; 216*cdf0e10cSrcweir IsObjectValid(); 217*cdf0e10cSrcweir if (getAccessibleParent().is()) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY); 220*cdf0e10cSrcweir if (xAccessibleComponent.is()) 221*cdf0e10cSrcweir xAccessibleComponent->grabFocus(); 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir //===== XAccessibleContext ============================================== 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleChildCount() throw(uno::RuntimeException) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir ScUnoGuard aGuard; 230*cdf0e10cSrcweir IsObjectValid(); 231*cdf0e10cSrcweir if (!mpTextHelper) 232*cdf0e10cSrcweir CreateTextHelper(); 233*cdf0e10cSrcweir return mpTextHelper->GetChildCount(); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleChild(sal_Int32 nIndex) 237*cdf0e10cSrcweir throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir ScUnoGuard aGuard; 240*cdf0e10cSrcweir IsObjectValid(); 241*cdf0e10cSrcweir if (!mpTextHelper) 242*cdf0e10cSrcweir CreateTextHelper(); 243*cdf0e10cSrcweir return mpTextHelper->GetChild(nIndex); 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleIndexInParent() throw (uno::RuntimeException) 247*cdf0e10cSrcweir { 248*cdf0e10cSrcweir return mnIndex; 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleStateSet() 252*cdf0e10cSrcweir throw(uno::RuntimeException) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir ScUnoGuard aGuard; 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> xParentStates; 257*cdf0e10cSrcweir if (getAccessibleParent().is()) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); 260*cdf0e10cSrcweir xParentStates = xParentContext->getAccessibleStateSet(); 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); 263*cdf0e10cSrcweir if (IsDefunc(xParentStates)) 264*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::DEFUNC); 265*cdf0e10cSrcweir else 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::ENABLED); 268*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::MULTI_LINE); 269*cdf0e10cSrcweir if (isShowing()) 270*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::SHOWING); 271*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::TRANSIENT); 272*cdf0e10cSrcweir if (isVisible()) 273*cdf0e10cSrcweir pStateSet->AddState(AccessibleStateType::VISIBLE); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir return pStateSet; 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir //===== XServiceInfo ==================================================== 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir rtl::OUString SAL_CALL ScAccessiblePreviewHeaderCell::getImplementationName() throw(uno::RuntimeException) 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAccessiblePreviewHeaderCell")); 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir uno::Sequence<rtl::OUString> SAL_CALL ScAccessiblePreviewHeaderCell::getSupportedServiceNames() 286*cdf0e10cSrcweir throw(uno::RuntimeException) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames(); 289*cdf0e10cSrcweir sal_Int32 nOldSize(aSequence.getLength()); 290*cdf0e10cSrcweir aSequence.realloc(nOldSize + 1); 291*cdf0e10cSrcweir ::rtl::OUString* pNames = aSequence.getArray(); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.AccessibleCellView")); 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir return aSequence; 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir //===== XTypeProvider ======================================================= 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL ScAccessiblePreviewHeaderCell::getTypes() 301*cdf0e10cSrcweir throw (uno::RuntimeException) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir return comphelper::concatSequences(ScAccessiblePreviewHeaderCellImpl::getTypes(), ScAccessibleContextBase::getTypes()); 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL 307*cdf0e10cSrcweir ScAccessiblePreviewHeaderCell::getImplementationId(void) 308*cdf0e10cSrcweir throw (uno::RuntimeException) 309*cdf0e10cSrcweir { 310*cdf0e10cSrcweir ScUnoGuard aGuard; 311*cdf0e10cSrcweir IsObjectValid(); 312*cdf0e10cSrcweir static uno::Sequence<sal_Int8> aId; 313*cdf0e10cSrcweir if (aId.getLength() == 0) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir aId.realloc (16); 316*cdf0e10cSrcweir rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True); 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir return aId; 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir //==== internal ========================================================= 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir Rectangle ScAccessiblePreviewHeaderCell::GetBoundingBoxOnScreen() const throw (uno::RuntimeException) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir Rectangle aCellRect; 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir FillTableInfo(); 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir if (mpTableInfo) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[maCellPos.Col()]; 332*cdf0e10cSrcweir const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[maCellPos.Row()]; 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir aCellRect = Rectangle( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd ); 335*cdf0e10cSrcweir } 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir if (mpViewShell) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindow(); 340*cdf0e10cSrcweir if (pWindow) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir Rectangle aRect = pWindow->GetWindowExtentsRelative(NULL); 343*cdf0e10cSrcweir aCellRect.setX(aCellRect.getX() + aRect.getX()); 344*cdf0e10cSrcweir aCellRect.setY(aCellRect.getY() + aRect.getY()); 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir return aCellRect; 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir Rectangle ScAccessiblePreviewHeaderCell::GetBoundingBox() const throw (uno::RuntimeException) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir FillTableInfo(); 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir if (mpTableInfo) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[maCellPos.Col()]; 357*cdf0e10cSrcweir const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[maCellPos.Row()]; 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir Rectangle aCellRect( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd ); 360*cdf0e10cSrcweir uno::Reference<XAccessible> xAccParent = const_cast<ScAccessiblePreviewHeaderCell*>(this)->getAccessibleParent(); 361*cdf0e10cSrcweir if (xAccParent.is()) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir uno::Reference<XAccessibleContext> xAccParentContext = xAccParent->getAccessibleContext(); 364*cdf0e10cSrcweir uno::Reference<XAccessibleComponent> xAccParentComp (xAccParentContext, uno::UNO_QUERY); 365*cdf0e10cSrcweir if (xAccParentComp.is()) 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir Rectangle aParentRect (VCLRectangle(xAccParentComp->getBounds())); 368*cdf0e10cSrcweir aCellRect.setX(aCellRect.getX() - aParentRect.getX()); 369*cdf0e10cSrcweir aCellRect.setY(aCellRect.getY() - aParentRect.getY()); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir return aCellRect; 373*cdf0e10cSrcweir } 374*cdf0e10cSrcweir return Rectangle(); 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir rtl::OUString SAL_CALL ScAccessiblePreviewHeaderCell::createAccessibleDescription() throw(uno::RuntimeException) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir rtl::OUString sDescription = String(ScResId(STR_ACC_HEADERCELL_DESCR)); 380*cdf0e10cSrcweir return sDescription; 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir rtl::OUString SAL_CALL ScAccessiblePreviewHeaderCell::createAccessibleName() throw(uno::RuntimeException) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir rtl::OUString sName = String(ScResId(STR_ACC_HEADERCELL_NAME)); 386*cdf0e10cSrcweir 387*cdf0e10cSrcweir if ( mbColumnHeader ) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir if ( mbRowHeader ) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir //! name for corner cell? 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir // sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Column/Row Header")); 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir else 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir // name of column header 398*cdf0e10cSrcweir sName += ScColToAlpha( maCellPos.Col() ); 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir else 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir // name of row header 404*cdf0e10cSrcweir sName += rtl::OUString::valueOf( (sal_Int32) ( maCellPos.Row() + 1 ) ); 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir return sName; 408*cdf0e10cSrcweir } 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir sal_Bool ScAccessiblePreviewHeaderCell::IsDefunc( const uno::Reference<XAccessibleStateSet>& rxParentStates ) 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() || 413*cdf0e10cSrcweir (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC)); 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir void ScAccessiblePreviewHeaderCell::CreateTextHelper() 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir if (!mpTextHelper) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir ::std::auto_ptr < ScAccessibleTextData > pAccessiblePreviewHeaderCellTextData 421*cdf0e10cSrcweir (new ScAccessiblePreviewHeaderCellTextData(mpViewShell, String(getAccessibleName()), maCellPos, mbColumnHeader, mbRowHeader)); 422*cdf0e10cSrcweir ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessiblePreviewHeaderCellTextData)); 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir mpTextHelper = new ::accessibility::AccessibleTextHelper(pEditSource ); 425*cdf0e10cSrcweir mpTextHelper->SetEventSource(this); 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir void ScAccessiblePreviewHeaderCell::FillTableInfo() const 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir if ( mpViewShell && !mpTableInfo ) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir Size aOutputSize; 434*cdf0e10cSrcweir Window* pWindow = mpViewShell->GetWindow(); 435*cdf0e10cSrcweir if ( pWindow ) 436*cdf0e10cSrcweir aOutputSize = pWindow->GetOutputSizePixel(); 437*cdf0e10cSrcweir Point aPoint; 438*cdf0e10cSrcweir Rectangle aVisRect( aPoint, aOutputSize ); 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir mpTableInfo = new ScPreviewTableInfo; 441*cdf0e10cSrcweir mpViewShell->GetLocationData().GetTableInfo( aVisRect, *mpTableInfo ); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir } 444