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_svx.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <accessiblecell.hxx> 32*cdf0e10cSrcweir 33*cdf0e10cSrcweir #include "svx/DescriptionGenerator.hxx" 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <vcl/svapp.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <editeng/outlobj.hxx> 43*cdf0e10cSrcweir #include <svx/unoshtxt.hxx> 44*cdf0e10cSrcweir #include <svx/svdotext.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir using ::rtl::OUString; 47*cdf0e10cSrcweir using namespace ::sdr::table; 48*cdf0e10cSrcweir using namespace ::com::sun::star; 49*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 50*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 51*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 52*cdf0e10cSrcweir using namespace ::com::sun::star::container; 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir namespace accessibility { 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir // -------------------------------------------------------------------- 57*cdf0e10cSrcweir // AccessibleCell 58*cdf0e10cSrcweir // -------------------------------------------------------------------- 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir AccessibleCell::AccessibleCell( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent, const sdr::table::CellRef& rCell, sal_Int32 nIndex, const AccessibleShapeTreeInfo& rShapeTreeInfo ) 61*cdf0e10cSrcweir : AccessibleCellBase( rxParent, AccessibleRole::TABLE_CELL ) 62*cdf0e10cSrcweir , maShapeTreeInfo( rShapeTreeInfo ) 63*cdf0e10cSrcweir , mnIndexInParent( nIndex ) 64*cdf0e10cSrcweir , mpText( NULL ) 65*cdf0e10cSrcweir , mxCell( rCell ) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir } 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir // -------------------------------------------------------------------- 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir AccessibleCell::~AccessibleCell (void) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir DBG_ASSERT( mpText == 0, "svx::AccessibleCell::~AccessibleCell(), not disposed!?" ); 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir // -------------------------------------------------------------------- 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir void AccessibleCell::Init (void) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir SdrView* pView = maShapeTreeInfo.GetSdrView(); 81*cdf0e10cSrcweir const Window* pWindow = maShapeTreeInfo.GetWindow (); 82*cdf0e10cSrcweir if( (pView != NULL) && (pWindow != NULL) && mxCell.is()) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir OutlinerParaObject* pOutlinerParaObject = mxCell->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir bool bOwnParaObject = pOutlinerParaObject != 0; 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir if( !pOutlinerParaObject ) 89*cdf0e10cSrcweir pOutlinerParaObject = mxCell->GetOutlinerParaObject(); 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir // create AccessibleTextHelper to handle this shape's text 92*cdf0e10cSrcweir if( pOutlinerParaObject ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir // non-empty text -> use full-fledged edit source right away 95*cdf0e10cSrcweir ::std::auto_ptr<SvxEditSource> pEditSource( new SvxTextEditSource( mxCell->GetObject(), mxCell.get(), *pView, *pWindow) ); 96*cdf0e10cSrcweir mpText = new AccessibleTextHelper( pEditSource ); 97*cdf0e10cSrcweir mpText->SetEventSource(this); 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir if( bOwnParaObject) 101*cdf0e10cSrcweir delete pOutlinerParaObject; 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir // -------------------------------------------------------------------- 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir sal_Bool AccessibleCell::SetState (sal_Int16 aState) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir sal_Bool bStateHasChanged = sal_False; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir if (aState == AccessibleStateType::FOCUSED && mpText != NULL) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir // Offer FOCUSED state to edit engine and detect whether the state 114*cdf0e10cSrcweir // changes. 115*cdf0e10cSrcweir sal_Bool bIsFocused = mpText->HaveFocus (); 116*cdf0e10cSrcweir mpText->SetFocus (sal_True); 117*cdf0e10cSrcweir bStateHasChanged = (bIsFocused != mpText->HaveFocus ()); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir else 120*cdf0e10cSrcweir bStateHasChanged = AccessibleContextBase::SetState (aState); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir return bStateHasChanged; 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir // -------------------------------------------------------------------- 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir sal_Bool AccessibleCell::ResetState (sal_Int16 aState) 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir sal_Bool bStateHasChanged = sal_False; 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir if (aState == AccessibleStateType::FOCUSED && mpText != NULL) 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir // Try to remove FOCUSED state from the edit engine and detect 134*cdf0e10cSrcweir // whether the state changes. 135*cdf0e10cSrcweir sal_Bool bIsFocused = mpText->HaveFocus (); 136*cdf0e10cSrcweir mpText->SetFocus (sal_False); 137*cdf0e10cSrcweir bStateHasChanged = (bIsFocused != mpText->HaveFocus ()); 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir else 140*cdf0e10cSrcweir bStateHasChanged = AccessibleContextBase::ResetState (aState); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir return bStateHasChanged; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir // -------------------------------------------------------------------- 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir sal_Bool AccessibleCell::GetState (sal_Int16 aState) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir if (aState == AccessibleStateType::FOCUSED && mpText != NULL) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir // Just delegate the call to the edit engine. The state is not 152*cdf0e10cSrcweir // merged into the state set. 153*cdf0e10cSrcweir return mpText->HaveFocus(); 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir else 156*cdf0e10cSrcweir return AccessibleContextBase::GetState (aState); 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir //----------------------------------------------------------------------------- 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir bool AccessibleCell::operator== (const AccessibleCell& rAccessibleCell) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir return this == &rAccessibleCell; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir //----------------------------------------------------------------------------- 167*cdf0e10cSrcweir // XInterface 168*cdf0e10cSrcweir //----------------------------------------------------------------------------- 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir Any SAL_CALL AccessibleCell::queryInterface( const Type& aType ) throw (RuntimeException) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir return AccessibleCellBase::queryInterface( aType ); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir //----------------------------------------------------------------------------- 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir void SAL_CALL AccessibleCell::acquire( ) throw () 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir AccessibleCellBase::acquire(); 180*cdf0e10cSrcweir } 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir //----------------------------------------------------------------------------- 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir void SAL_CALL AccessibleCell::release( ) throw () 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir AccessibleCellBase::release(); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir // -------------------------------------------------------------------- 190*cdf0e10cSrcweir // XAccessibleContext 191*cdf0e10cSrcweir // -------------------------------------------------------------------- 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir /** The children of this cell come from the paragraphs of text. 194*cdf0e10cSrcweir */ 195*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleCell::getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir ::vos::OGuard aSolarGuard (::Application::GetSolarMutex()); 198*cdf0e10cSrcweir ThrowIfDisposed (); 199*cdf0e10cSrcweir return mpText != NULL ? mpText->GetChildCount () : 0; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir // -------------------------------------------------------------------- 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir /** Forward the request to the shape. Return the requested shape or throw 205*cdf0e10cSrcweir an exception for a wrong index. 206*cdf0e10cSrcweir */ 207*cdf0e10cSrcweir Reference<XAccessible> SAL_CALL AccessibleCell::getAccessibleChild (sal_Int32 nIndex) throw (IndexOutOfBoundsException, RuntimeException) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir ::vos::OGuard aSolarGuard (::Application::GetSolarMutex()); 210*cdf0e10cSrcweir ThrowIfDisposed (); 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir // todo: does GetChild throw IndexOutOfBoundsException? 213*cdf0e10cSrcweir return mpText->GetChild (nIndex); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir // -------------------------------------------------------------------- 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir /** Return a copy of the state set. 219*cdf0e10cSrcweir Possible states are: 220*cdf0e10cSrcweir ENABLED 221*cdf0e10cSrcweir SHOWING 222*cdf0e10cSrcweir VISIBLE 223*cdf0e10cSrcweir */ 224*cdf0e10cSrcweir Reference<XAccessibleStateSet> SAL_CALL AccessibleCell::getAccessibleStateSet (void) throw (RuntimeException) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir ::vos::OGuard aSolarGuard (::Application::GetSolarMutex()); 227*cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex); 228*cdf0e10cSrcweir Reference<XAccessibleStateSet> xStateSet; 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir if (rBHelper.bDisposed || mpText == NULL) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir // Return a minimal state set that only contains the DEFUNC state. 233*cdf0e10cSrcweir xStateSet = AccessibleContextBase::getAccessibleStateSet (); 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir else 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir if(pStateSet) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir // Merge current FOCUSED state from edit engine. 242*cdf0e10cSrcweir if (mpText != NULL) 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir if (mpText->HaveFocus()) 245*cdf0e10cSrcweir pStateSet->AddState (AccessibleStateType::FOCUSED); 246*cdf0e10cSrcweir else 247*cdf0e10cSrcweir pStateSet->RemoveState (AccessibleStateType::FOCUSED); 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir // Create a copy of the state set that may be modified by the 251*cdf0e10cSrcweir // caller without affecting the current state set. 252*cdf0e10cSrcweir xStateSet = Reference<XAccessibleStateSet>(new ::utl::AccessibleStateSetHelper (*pStateSet)); 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir return xStateSet; 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir // -------------------------------------------------------------------- 260*cdf0e10cSrcweir // XAccessibleComponent 261*cdf0e10cSrcweir // -------------------------------------------------------------------- 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleCell::containsPoint( const ::com::sun::star::awt::Point& aPoint) throw (::com::sun::star::uno::RuntimeException) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir return AccessibleComponentBase::containsPoint( aPoint ); 266*cdf0e10cSrcweir } 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir /** The implementation below is at the moment straightforward. It iterates 269*cdf0e10cSrcweir over all children (and thereby instances all children which have not 270*cdf0e10cSrcweir been already instatiated) until a child covering the specifed point is 271*cdf0e10cSrcweir found. 272*cdf0e10cSrcweir This leaves room for improvement. For instance, first iterate only over 273*cdf0e10cSrcweir the already instantiated children and only if no match is found 274*cdf0e10cSrcweir instantiate the remaining ones. 275*cdf0e10cSrcweir */ 276*cdf0e10cSrcweir Reference<XAccessible > SAL_CALL AccessibleCell::getAccessibleAtPoint ( const ::com::sun::star::awt::Point& aPoint) throw(RuntimeException) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir ::vos::OGuard aSolarGuard (::Application::GetSolarMutex()); 279*cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir sal_Int32 nChildCount = getAccessibleChildCount (); 282*cdf0e10cSrcweir for (sal_Int32 i=0; i<nChildCount; ++i) 283*cdf0e10cSrcweir { 284*cdf0e10cSrcweir Reference<XAccessible> xChild (getAccessibleChild (i)); 285*cdf0e10cSrcweir if (xChild.is()) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir Reference<XAccessibleComponent> xChildComponent (xChild->getAccessibleContext(), uno::UNO_QUERY); 288*cdf0e10cSrcweir if (xChildComponent.is()) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir awt::Rectangle aBBox (xChildComponent->getBounds()); 291*cdf0e10cSrcweir if ( (aPoint.X >= aBBox.X) 292*cdf0e10cSrcweir && (aPoint.Y >= aBBox.Y) 293*cdf0e10cSrcweir && (aPoint.X < aBBox.X+aBBox.Width) 294*cdf0e10cSrcweir && (aPoint.Y < aBBox.Y+aBBox.Height) ) 295*cdf0e10cSrcweir return xChild; 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir // Have not found a child under the given point. Returning empty 301*cdf0e10cSrcweir // reference to indicate this. 302*cdf0e10cSrcweir return uno::Reference<XAccessible>(); 303*cdf0e10cSrcweir } 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir // -------------------------------------------------------------------- 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir ::com::sun::star::awt::Rectangle SAL_CALL AccessibleCell::getBounds(void) throw(RuntimeException) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir ::vos::OGuard aSolarGuard (::Application::GetSolarMutex()); 310*cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex); 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir ThrowIfDisposed (); 313*cdf0e10cSrcweir ::com::sun::star::awt::Rectangle aBoundingBox; 314*cdf0e10cSrcweir if( mxCell.is() ) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir // Get the cell's bounding box in internal coordinates (in 100th of mm) 317*cdf0e10cSrcweir const ::Rectangle aCellRect( mxCell->getCellRect() ); 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir // Transform coordinates from internal to pixel. 320*cdf0e10cSrcweir if (maShapeTreeInfo.GetViewForwarder() == NULL) 321*cdf0e10cSrcweir throw uno::RuntimeException (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleCell has no valid view forwarder")),static_cast<uno::XWeak*>(this)); 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir ::Size aPixelSize( maShapeTreeInfo.GetViewForwarder()->LogicToPixel(::Size(aCellRect.GetWidth(), aCellRect.GetHeight())) ); 324*cdf0e10cSrcweir ::Point aPixelPosition( maShapeTreeInfo.GetViewForwarder()->LogicToPixel( aCellRect.TopLeft() )); 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir // Clip the shape's bounding box with the bounding box of its parent. 327*cdf0e10cSrcweir Reference<XAccessibleComponent> xParentComponent ( getAccessibleParent(), uno::UNO_QUERY); 328*cdf0e10cSrcweir if (xParentComponent.is()) 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir // Make the coordinates relative to the parent. 331*cdf0e10cSrcweir awt::Point aParentLocation (xParentComponent->getLocationOnScreen()); 332*cdf0e10cSrcweir int x = aPixelPosition.getX() - aParentLocation.X; 333*cdf0e10cSrcweir int y = aPixelPosition.getY() - aParentLocation.Y; 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir // Clip with parent (with coordinates relative to itself). 336*cdf0e10cSrcweir ::Rectangle aBBox ( x, y, x + aPixelSize.getWidth(), y + aPixelSize.getHeight()); 337*cdf0e10cSrcweir awt::Size aParentSize (xParentComponent->getSize()); 338*cdf0e10cSrcweir ::Rectangle aParentBBox (0,0, aParentSize.Width, aParentSize.Height); 339*cdf0e10cSrcweir aBBox = aBBox.GetIntersection (aParentBBox); 340*cdf0e10cSrcweir aBoundingBox = awt::Rectangle ( aBBox.getX(), aBBox.getY(), aBBox.getWidth(), aBBox.getHeight()); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir else 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir OSL_TRACE ("parent does not support component"); 345*cdf0e10cSrcweir aBoundingBox = awt::Rectangle (aPixelPosition.getX(), aPixelPosition.getY(),aPixelSize.getWidth(), aPixelSize.getHeight()); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir return aBoundingBox; 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir // -------------------------------------------------------------------- 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir ::com::sun::star::awt::Point SAL_CALL AccessibleCell::getLocation(void) throw (RuntimeException) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir ThrowIfDisposed (); 357*cdf0e10cSrcweir ::com::sun::star::awt::Rectangle aBoundingBox(getBounds()); 358*cdf0e10cSrcweir return ::com::sun::star::awt::Point(aBoundingBox.X, aBoundingBox.Y); 359*cdf0e10cSrcweir } 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir // -------------------------------------------------------------------- 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir ::com::sun::star::awt::Point SAL_CALL AccessibleCell::getLocationOnScreen(void) throw(RuntimeException) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir ThrowIfDisposed (); 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir // Get relative position... 368*cdf0e10cSrcweir ::com::sun::star::awt::Point aLocation(getLocation ()); 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir // ... and add absolute position of the parent. 371*cdf0e10cSrcweir Reference<XAccessibleComponent> xParentComponent( getAccessibleParent(), uno::UNO_QUERY); 372*cdf0e10cSrcweir if(xParentComponent.is()) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir ::com::sun::star::awt::Point aParentLocation(xParentComponent->getLocationOnScreen()); 375*cdf0e10cSrcweir aLocation.X += aParentLocation.X; 376*cdf0e10cSrcweir aLocation.Y += aParentLocation.Y; 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir else 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir OSL_TRACE ("getLocation: parent does not support XAccessibleComponent"); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir return aLocation; 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir // -------------------------------------------------------------------- 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir awt::Size SAL_CALL AccessibleCell::getSize (void) throw (RuntimeException) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir ThrowIfDisposed (); 391*cdf0e10cSrcweir awt::Rectangle aBoundingBox (getBounds()); 392*cdf0e10cSrcweir return awt::Size (aBoundingBox.Width, aBoundingBox.Height); 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir // -------------------------------------------------------------------- 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir void SAL_CALL AccessibleCell::addFocusListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener) throw (::com::sun::star::uno::RuntimeException) 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir AccessibleComponentBase::addFocusListener( xListener ); 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir // -------------------------------------------------------------------- 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir void SAL_CALL AccessibleCell::removeFocusListener (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException) 405*cdf0e10cSrcweir { 406*cdf0e10cSrcweir AccessibleComponentBase::removeFocusListener( xListener ); 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir // -------------------------------------------------------------------- 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir void SAL_CALL AccessibleCell::grabFocus (void) throw (::com::sun::star::uno::RuntimeException) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir AccessibleComponentBase::grabFocus(); 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir // -------------------------------------------------------------------- 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleCell::getForeground(void) throw (RuntimeException) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir ThrowIfDisposed (); 421*cdf0e10cSrcweir sal_Int32 nColor (0x0ffffffL); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir // todo 424*cdf0e10cSrcweir return nColor; 425*cdf0e10cSrcweir } 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir // -------------------------------------------------------------------- 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleCell::getBackground (void) throw (RuntimeException) 430*cdf0e10cSrcweir { 431*cdf0e10cSrcweir ThrowIfDisposed (); 432*cdf0e10cSrcweir sal_Int32 nColor (0L); 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir // todo 435*cdf0e10cSrcweir return nColor; 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir // -------------------------------------------------------------------- 439*cdf0e10cSrcweir // XAccessibleExtendedComponent 440*cdf0e10cSrcweir // -------------------------------------------------------------------- 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL AccessibleCell::getFont (void) throw (::com::sun::star::uno::RuntimeException) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir //todo 445*cdf0e10cSrcweir return AccessibleComponentBase::getFont(); 446*cdf0e10cSrcweir } 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir // -------------------------------------------------------------------- 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleCell::getTitledBorderText (void) throw (::com::sun::star::uno::RuntimeException) 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir return AccessibleComponentBase::getTitledBorderText(); 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir // -------------------------------------------------------------------- 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleCell::getToolTipText (void) throw (::com::sun::star::uno::RuntimeException) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir return AccessibleComponentBase::getToolTipText(); 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir // -------------------------------------------------------------------- 463*cdf0e10cSrcweir // XAccessibleEventBroadcaster 464*cdf0e10cSrcweir // -------------------------------------------------------------------- 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir void SAL_CALL AccessibleCell::addEventListener( const Reference<XAccessibleEventListener >& rxListener) throw (RuntimeException) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir ::vos::OGuard aSolarGuard (::Application::GetSolarMutex()); 469*cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex); 470*cdf0e10cSrcweir if (rBHelper.bDisposed || rBHelper.bInDispose) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir Reference<XInterface> xSource( static_cast<XComponent *>(this) ); 473*cdf0e10cSrcweir lang::EventObject aEventObj(xSource); 474*cdf0e10cSrcweir rxListener->disposing(aEventObj); 475*cdf0e10cSrcweir } 476*cdf0e10cSrcweir else 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir AccessibleContextBase::addEventListener (rxListener); 479*cdf0e10cSrcweir if (mpText != NULL) 480*cdf0e10cSrcweir mpText->AddEventListener (rxListener); 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir // -------------------------------------------------------------------- 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir void SAL_CALL AccessibleCell::removeEventListener( const Reference<XAccessibleEventListener >& rxListener) throw (RuntimeException) 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir ::vos::OGuard aSolarGuard (::Application::GetSolarMutex()); 489*cdf0e10cSrcweir AccessibleContextBase::removeEventListener(rxListener); 490*cdf0e10cSrcweir if (mpText != NULL) 491*cdf0e10cSrcweir mpText->RemoveEventListener (rxListener); 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir // -------------------------------------------------------------------- 495*cdf0e10cSrcweir // XServiceInfo 496*cdf0e10cSrcweir // -------------------------------------------------------------------- 497*cdf0e10cSrcweir 498*cdf0e10cSrcweir OUString SAL_CALL AccessibleCell::getImplementationName(void) throw (RuntimeException) 499*cdf0e10cSrcweir { 500*cdf0e10cSrcweir return OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleCell")); 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir // -------------------------------------------------------------------- 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir Sequence<OUString> SAL_CALL AccessibleCell::getSupportedServiceNames(void) throw (RuntimeException) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir ThrowIfDisposed (); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir // Get list of supported service names from base class... 510*cdf0e10cSrcweir uno::Sequence<OUString> aServiceNames = AccessibleContextBase::getSupportedServiceNames(); 511*cdf0e10cSrcweir sal_Int32 nCount (aServiceNames.getLength()); 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir // ...and add additional names. 514*cdf0e10cSrcweir aServiceNames.realloc (nCount + 1); 515*cdf0e10cSrcweir static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.AccessibleCell")); 516*cdf0e10cSrcweir aServiceNames[nCount] = sAdditionalServiceName; 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir return aServiceNames; 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir // -------------------------------------------------------------------- 522*cdf0e10cSrcweir // IAccessibleViewForwarderListener 523*cdf0e10cSrcweir // -------------------------------------------------------------------- 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir void AccessibleCell::ViewForwarderChanged (ChangeType /*aChangeType*/, const IAccessibleViewForwarder* /*pViewForwarder*/) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir // Inform all listeners that the graphical representation (i.e. size 528*cdf0e10cSrcweir // and/or position) of the shape has changed. 529*cdf0e10cSrcweir CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, Any(), Any()); 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir // update our children that our screen position might have changed 532*cdf0e10cSrcweir if( mpText ) 533*cdf0e10cSrcweir mpText->UpdateChildren(); 534*cdf0e10cSrcweir } 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir // -------------------------------------------------------------------- 537*cdf0e10cSrcweir // protected 538*cdf0e10cSrcweir // -------------------------------------------------------------------- 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir void AccessibleCell::disposing (void) 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir ::vos::OGuard aSolarGuard (::Application::GetSolarMutex()); 543*cdf0e10cSrcweir ::osl::MutexGuard aGuard (maMutex); 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir // Make sure to send an event that this object looses the focus in the 546*cdf0e10cSrcweir // case that it has the focus. 547*cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 548*cdf0e10cSrcweir if (pStateSet != NULL) 549*cdf0e10cSrcweir pStateSet->RemoveState(AccessibleStateType::FOCUSED); 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir if (mpText != NULL) 552*cdf0e10cSrcweir { 553*cdf0e10cSrcweir mpText->Dispose(); 554*cdf0e10cSrcweir delete mpText; 555*cdf0e10cSrcweir mpText = NULL; 556*cdf0e10cSrcweir } 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir // Cleanup. Remove references to objects to allow them to be 559*cdf0e10cSrcweir // destroyed. 560*cdf0e10cSrcweir mxCell.clear(); 561*cdf0e10cSrcweir maShapeTreeInfo = AccessibleShapeTreeInfo(); 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir // Call base classes. 564*cdf0e10cSrcweir AccessibleContextBase::dispose (); 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleCell::getAccessibleIndexInParent (void) throw (RuntimeException) 568*cdf0e10cSrcweir { 569*cdf0e10cSrcweir ThrowIfDisposed (); 570*cdf0e10cSrcweir return mnIndexInParent; 571*cdf0e10cSrcweir } 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleCell::getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException) 574*cdf0e10cSrcweir { 575*cdf0e10cSrcweir ThrowIfDisposed (); 576*cdf0e10cSrcweir ::vos::OGuard aSolarGuard (::Application::GetSolarMutex()); 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir if( mxCell.is() ) 579*cdf0e10cSrcweir return mxCell->getName(); 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir return AccessibleCellBase::getAccessibleName(); 582*cdf0e10cSrcweir } 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir } // end of namespace accessibility 585