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 #include <com/sun/star/accessibility/AccessibleRole.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyChangeEvent.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp> 36*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 37*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 38*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 39*cdf0e10cSrcweir #include <vcl/svapp.hxx> 40*cdf0e10cSrcweir #include <osl/mutex.hxx> 41*cdf0e10cSrcweir #include <rtl/uuid.h> 42*cdf0e10cSrcweir #include <tools/debug.hxx> 43*cdf0e10cSrcweir #include <tools/gen.hxx> 44*cdf0e10cSrcweir #include <svl/smplhint.hxx> 45*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 46*cdf0e10cSrcweir #include <svtools/colorcfg.hxx> 47*cdf0e10cSrcweir #include <comphelper/accessibleeventnotifier.hxx> 48*cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx> 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir //===== local includes ======================================================== 51*cdf0e10cSrcweir #include <svx/ShapeTypeHandler.hxx> 52*cdf0e10cSrcweir #include <svx/AccessibleShapeInfo.hxx> 53*cdf0e10cSrcweir #include "GraphCtlAccessibleContext.hxx" 54*cdf0e10cSrcweir #include <svx/graphctl.hxx> 55*cdf0e10cSrcweir #ifndef _SVX_DIALOGS_HRC 56*cdf0e10cSrcweir #include <svx/dialogs.hrc> 57*cdf0e10cSrcweir #endif 58*cdf0e10cSrcweir #ifndef _SVX_ACCESSIBILITY_HRC 59*cdf0e10cSrcweir #include "accessibility.hrc" 60*cdf0e10cSrcweir #endif 61*cdf0e10cSrcweir #include <svx/svdpage.hxx> 62*cdf0e10cSrcweir #include <svx/unomod.hxx> 63*cdf0e10cSrcweir #include <svx/dialmgr.hxx> 64*cdf0e10cSrcweir #include <svx/svdetc.hxx> 65*cdf0e10cSrcweir #include <svx/sdrhittesthelper.hxx> 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir //===== namespaces =========================================================== 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir using namespace ::vos; 70*cdf0e10cSrcweir using namespace ::cppu; 71*cdf0e10cSrcweir using namespace ::osl; 72*cdf0e10cSrcweir using ::rtl::OUString; 73*cdf0e10cSrcweir using namespace ::accessibility; 74*cdf0e10cSrcweir using namespace ::com::sun::star; 75*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 76*cdf0e10cSrcweir using namespace ::com::sun::star::drawing; 77*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 78*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir //===== internal ============================================================ 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir /** initialize this component and set default values */ 83*cdf0e10cSrcweir SvxGraphCtrlAccessibleContext::SvxGraphCtrlAccessibleContext( 84*cdf0e10cSrcweir const Reference< XAccessible >& rxParent, 85*cdf0e10cSrcweir GraphCtrl& rRepr, 86*cdf0e10cSrcweir const OUString* pName, 87*cdf0e10cSrcweir const OUString* pDesc ) : 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir SvxGraphCtrlAccessibleContext_Base( m_aMutex ), 90*cdf0e10cSrcweir mxParent( rxParent ), 91*cdf0e10cSrcweir mpControl( &rRepr ), 92*cdf0e10cSrcweir mpModel (NULL), 93*cdf0e10cSrcweir mpPage (NULL), 94*cdf0e10cSrcweir mpView (NULL), 95*cdf0e10cSrcweir mnClientId( 0 ), 96*cdf0e10cSrcweir mbDisposed( sal_False ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir if (mpControl != NULL) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir mpModel = mpControl->GetSdrModel(); 101*cdf0e10cSrcweir if (mpModel != NULL) 102*cdf0e10cSrcweir mpPage = (SdrPage*)mpModel->GetPage( 0 ); 103*cdf0e10cSrcweir mpView = mpControl->GetSdrView(); 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir if( mpModel == NULL || mpPage == NULL || mpView == NULL ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir mbDisposed = true; 108*cdf0e10cSrcweir // Set all the pointers to NULL just in case they are used as 109*cdf0e10cSrcweir // a disposed flag. 110*cdf0e10cSrcweir mpModel = NULL; 111*cdf0e10cSrcweir mpPage = NULL; 112*cdf0e10cSrcweir mpView = NULL; 113*cdf0e10cSrcweir } 114*cdf0e10cSrcweir } 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir if( pName ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir msName = *pName; 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir else 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 123*cdf0e10cSrcweir msName = SVX_RESSTR( RID_SVXSTR_GRAPHCTRL_ACC_NAME ); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir if( pDesc ) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir msDescription = *pDesc; 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir else 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 133*cdf0e10cSrcweir msDescription = SVX_RESSTR( RID_SVXSTR_GRAPHCTRL_ACC_DESCRIPTION ); 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir maTreeInfo.SetSdrView( mpView ); 137*cdf0e10cSrcweir maTreeInfo.SetWindow( mpControl ); 138*cdf0e10cSrcweir maTreeInfo.SetViewForwarder( const_cast<SvxGraphCtrlAccessibleContext*>(this) ); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir //----------------------------------------------------------------------------- 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir /** on destruction, this component is disposed and all dispose listeners 144*cdf0e10cSrcweir are called, except if this component was already disposed */ 145*cdf0e10cSrcweir SvxGraphCtrlAccessibleContext::~SvxGraphCtrlAccessibleContext() 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir disposing(); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir //----------------------------------------------------------------------------- 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir /** returns the XAccessible interface for a given SdrObject. 153*cdf0e10cSrcweir Multiple calls for the same SdrObject return the same XAccessible. 154*cdf0e10cSrcweir */ 155*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessible( const SdrObject* pObj ) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir Reference<XAccessible> xAccessibleShape; 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir if( pObj ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir // see if we already created an XAccessible for the given SdrObject 162*cdf0e10cSrcweir ShapesMapType::iterator iter = mxShapes.find( pObj ); 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir if( iter != mxShapes.end() ) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir // if we already have one, return it 167*cdf0e10cSrcweir xAccessibleShape = (*iter).second; 168*cdf0e10cSrcweir } 169*cdf0e10cSrcweir else 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir // create a new one and remember in our internal map 172*cdf0e10cSrcweir Reference< XShape > xShape( Reference< XShape >::query( (const_cast<SdrObject*>(pObj))->getUnoShape() ) ); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir AccessibleShapeInfo aShapeInfo (xShape,mxParent); 175*cdf0e10cSrcweir // Create accessible object that corresponds to the descriptor's shape. 176*cdf0e10cSrcweir AccessibleShape* pAcc = ShapeTypeHandler::Instance().CreateAccessibleObject( 177*cdf0e10cSrcweir aShapeInfo, maTreeInfo); 178*cdf0e10cSrcweir xAccessibleShape = pAcc; 179*cdf0e10cSrcweir if (pAcc != NULL) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir pAcc->acquire(); 182*cdf0e10cSrcweir // Now that we acquired the new accessible shape we can 183*cdf0e10cSrcweir // safely call its Init() method. 184*cdf0e10cSrcweir pAcc->Init (); 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir mxShapes[pObj] = pAcc; 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir // Create event and inform listeners of the object creation. 189*cdf0e10cSrcweir CommitChange( AccessibleEventId::CHILD, makeAny( xAccessibleShape ), makeAny( Reference<XAccessible>() ) ); 190*cdf0e10cSrcweir } 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir return xAccessibleShape; 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir //===== XAccessible ========================================================= 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleContext( void ) throw( RuntimeException ) 199*cdf0e10cSrcweir { 200*cdf0e10cSrcweir return this; 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir //===== XAccessibleComponent ================================================ 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir sal_Bool SAL_CALL SvxGraphCtrlAccessibleContext::containsPoint( const awt::Point& rPoint ) throw( RuntimeException ) 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir // no guard -> done in getSize() 208*cdf0e10cSrcweir awt::Size aSize (getSize()); 209*cdf0e10cSrcweir return (rPoint.X >= 0) 210*cdf0e10cSrcweir && (rPoint.X < aSize.Width) 211*cdf0e10cSrcweir && (rPoint.Y >= 0) 212*cdf0e10cSrcweir && (rPoint.Y < aSize.Height); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir //----------------------------------------------------------------------------- 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleAtPoint( const awt::Point& rPoint ) throw( RuntimeException ) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir Reference< XAccessible > xAccessible; 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir if( mpControl ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir Point aPnt( rPoint.X, rPoint.Y ); 226*cdf0e10cSrcweir mpControl->PixelToLogic( aPnt ); 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir SdrObject* pObj = 0; 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir if(mpView && mpView->GetSdrPageView()) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir pObj = SdrObjListPrimitiveHit(*mpPage, aPnt, 1, *mpView->GetSdrPageView(), 0, false); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir if( pObj ) 236*cdf0e10cSrcweir xAccessible = getAccessible( pObj ); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir else 239*cdf0e10cSrcweir { 240*cdf0e10cSrcweir throw DisposedException(); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir return xAccessible; 244*cdf0e10cSrcweir } 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir //----------------------------------------------------------------------------- 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir awt::Rectangle SAL_CALL SvxGraphCtrlAccessibleContext::getBounds() throw( RuntimeException ) 249*cdf0e10cSrcweir { 250*cdf0e10cSrcweir // no guard -> done in GetBoundingBox() 251*cdf0e10cSrcweir Rectangle aCoreBounds( GetBoundingBox() ); 252*cdf0e10cSrcweir awt::Rectangle aBounds; 253*cdf0e10cSrcweir aBounds.X = aCoreBounds.getX(); 254*cdf0e10cSrcweir aBounds.Y = aCoreBounds.getY(); 255*cdf0e10cSrcweir aBounds.Width = aCoreBounds.getWidth(); 256*cdf0e10cSrcweir aBounds.Height = aCoreBounds.getHeight(); 257*cdf0e10cSrcweir return aBounds; 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir //----------------------------------------------------------------------------- 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir awt::Point SAL_CALL SvxGraphCtrlAccessibleContext::getLocation() throw( RuntimeException ) 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir // no guard -> done in GetBoundingBox() 265*cdf0e10cSrcweir Rectangle aRect( GetBoundingBox() ); 266*cdf0e10cSrcweir return awt::Point( aRect.getX(), aRect.getY() ); 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir //----------------------------------------------------------------------------- 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir awt::Point SAL_CALL SvxGraphCtrlAccessibleContext::getLocationOnScreen() throw( RuntimeException ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir // no guard -> done in GetBoundingBoxOnScreen() 274*cdf0e10cSrcweir Rectangle aRect( GetBoundingBoxOnScreen() ); 275*cdf0e10cSrcweir return awt::Point( aRect.getX(), aRect.getY() ); 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir //----------------------------------------------------------------------------- 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir awt::Size SAL_CALL SvxGraphCtrlAccessibleContext::getSize() throw( RuntimeException ) 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir // no guard -> done in GetBoundingBox() 283*cdf0e10cSrcweir Rectangle aRect( GetBoundingBox() ); 284*cdf0e10cSrcweir return awt::Size( aRect.getWidth(), aRect.getHeight() ); 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir //===== XAccessibleContext ================================================== 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleChildCount( void ) throw( RuntimeException ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir if( NULL == mpPage ) 295*cdf0e10cSrcweir throw DisposedException(); 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir return mpPage->GetObjCount(); 298*cdf0e10cSrcweir } 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir //----------------------------------------------------------------------------- 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir /** returns the SdrObject at index nIndex from the model of this graph */ 303*cdf0e10cSrcweir SdrObject* SvxGraphCtrlAccessibleContext::getSdrObject( sal_Int32 nIndex ) 304*cdf0e10cSrcweir throw( RuntimeException, lang::IndexOutOfBoundsException ) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir if( NULL == mpPage ) 309*cdf0e10cSrcweir throw DisposedException(); 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir if( (nIndex < 0) || ( static_cast<sal_uInt32>(nIndex) >= mpPage->GetObjCount() ) ) 312*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir return mpPage->GetObj( nIndex ); 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir //----------------------------------------------------------------------------- 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir /** sends an AccessibleEventObject to all added XAccessibleEventListeners */ 320*cdf0e10cSrcweir void SvxGraphCtrlAccessibleContext::CommitChange ( 321*cdf0e10cSrcweir sal_Int16 nEventId, 322*cdf0e10cSrcweir const uno::Any& rNewValue, 323*cdf0e10cSrcweir const uno::Any& rOldValue) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir AccessibleEventObject aEvent ( 326*cdf0e10cSrcweir static_cast<uno::XWeak*>(this), 327*cdf0e10cSrcweir nEventId, 328*cdf0e10cSrcweir rNewValue, 329*cdf0e10cSrcweir rOldValue); 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir FireEvent (aEvent); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir /** sends an AccessibleEventObject to all added XAccessibleEventListeners */ 335*cdf0e10cSrcweir void SvxGraphCtrlAccessibleContext::FireEvent (const AccessibleEventObject& aEvent) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir if (mnClientId) 338*cdf0e10cSrcweir comphelper::AccessibleEventNotifier::addEvent( mnClientId, aEvent ); 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir //----------------------------------------------------------------------------- 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleChild( sal_Int32 nIndex ) 344*cdf0e10cSrcweir throw( RuntimeException, lang::IndexOutOfBoundsException ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir return getAccessible( getSdrObject( nIndex ) ); 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir //----------------------------------------------------------------------------- 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleParent( void ) throw( RuntimeException ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir return mxParent; 356*cdf0e10cSrcweir } 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir //----------------------------------------------------------------------------- 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleIndexInParent( void ) throw( RuntimeException ) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 363*cdf0e10cSrcweir // Use a simple but slow solution for now. Optimize later. 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir // Iterate over all the parent's children and search for this object. 366*cdf0e10cSrcweir if( mxParent.is() ) 367*cdf0e10cSrcweir { 368*cdf0e10cSrcweir Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() ); 369*cdf0e10cSrcweir if( xParentContext.is() ) 370*cdf0e10cSrcweir { 371*cdf0e10cSrcweir sal_Int32 nChildCount = xParentContext->getAccessibleChildCount(); 372*cdf0e10cSrcweir for( sal_Int32 i = 0 ; i < nChildCount ; ++i ) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) ); 375*cdf0e10cSrcweir if( xChild.is() ) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir Reference< XAccessibleContext > xChildContext = xChild->getAccessibleContext(); 378*cdf0e10cSrcweir if( xChildContext == ( XAccessibleContext* ) this ) 379*cdf0e10cSrcweir return i; 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir // Return -1 to indicate that this object's parent does not know about the 386*cdf0e10cSrcweir // object. 387*cdf0e10cSrcweir return -1; 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir //----------------------------------------------------------------------------- 391*cdf0e10cSrcweir 392*cdf0e10cSrcweir sal_Int16 SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleRole( void ) throw( RuntimeException ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir return AccessibleRole::PANEL; 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir //----------------------------------------------------------------------------- 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir OUString SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleDescription( void ) throw( RuntimeException ) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 402*cdf0e10cSrcweir return msDescription; 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir 405*cdf0e10cSrcweir //----------------------------------------------------------------------------- 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir OUString SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleName( void ) throw( RuntimeException ) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 410*cdf0e10cSrcweir return msName; 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir //----------------------------------------------------------------------------- 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir /** Return empty reference to indicate that the relation set is not 416*cdf0e10cSrcweir supported. 417*cdf0e10cSrcweir */ 418*cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleRelationSet( void ) throw( RuntimeException ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir return Reference< XAccessibleRelationSet >(); 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir //----------------------------------------------------------------------------- 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleStateSet( void ) throw( RuntimeException ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; 430*cdf0e10cSrcweir 431*cdf0e10cSrcweir if ( rBHelper.bDisposed || mbDisposed ) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir else 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir // pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 438*cdf0e10cSrcweir // pStateSetHelper->AddState( AccessibleStateType::SENSITIVE ); 439*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE ); 440*cdf0e10cSrcweir if( mpControl->HasFocus() ) 441*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::FOCUSED ); 442*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::OPAQUE ); 443*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 444*cdf0e10cSrcweir pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir return pStateSetHelper; 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir //----------------------------------------------------------------------------- 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir lang::Locale SAL_CALL SvxGraphCtrlAccessibleContext::getLocale( void ) throw( IllegalAccessibleComponentStateException, RuntimeException ) 453*cdf0e10cSrcweir { 454*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir if( mxParent.is() ) 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() ); 459*cdf0e10cSrcweir if( xParentContext.is() ) 460*cdf0e10cSrcweir return xParentContext->getLocale(); 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir // No parent. Therefore throw exception to indicate this cluelessness. 464*cdf0e10cSrcweir throw IllegalAccessibleComponentStateException(); 465*cdf0e10cSrcweir } 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir //===== XAccessibleEventListener ============================================ 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir void SAL_CALL SvxGraphCtrlAccessibleContext::addEventListener( const Reference< XAccessibleEventListener >& xListener ) 470*cdf0e10cSrcweir throw( RuntimeException ) 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir if (xListener.is()) 473*cdf0e10cSrcweir { 474*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 475*cdf0e10cSrcweir if (!mnClientId) 476*cdf0e10cSrcweir mnClientId = comphelper::AccessibleEventNotifier::registerClient( ); 477*cdf0e10cSrcweir comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener ); 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir } 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir //----------------------------------------------------------------------------- 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir void SAL_CALL SvxGraphCtrlAccessibleContext::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) 484*cdf0e10cSrcweir throw( RuntimeException ) 485*cdf0e10cSrcweir { 486*cdf0e10cSrcweir if (xListener.is()) 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); 491*cdf0e10cSrcweir if ( !nListenerCount ) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir // no listeners anymore 494*cdf0e10cSrcweir // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), 495*cdf0e10cSrcweir // and at least to us not firing any events anymore, in case somebody calls 496*cdf0e10cSrcweir // NotifyAccessibleEvent, again 497*cdf0e10cSrcweir comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); 498*cdf0e10cSrcweir mnClientId = 0; 499*cdf0e10cSrcweir } 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir //----------------------------------------------------------------------------- 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir void SAL_CALL SvxGraphCtrlAccessibleContext::addFocusListener( const Reference< awt::XFocusListener >& xListener ) 506*cdf0e10cSrcweir throw( RuntimeException ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir if( xListener.is() ) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir Reference< ::com::sun::star::awt::XWindow > xWindow( VCLUnoHelper::GetInterface( mpControl ) ); 513*cdf0e10cSrcweir if( xWindow.is() ) 514*cdf0e10cSrcweir xWindow->addFocusListener( xListener ); 515*cdf0e10cSrcweir } 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir 518*cdf0e10cSrcweir //----------------------------------------------------------------------------- 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir void SAL_CALL SvxGraphCtrlAccessibleContext::removeFocusListener( const Reference< awt::XFocusListener >& xListener ) 521*cdf0e10cSrcweir throw (RuntimeException) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir if( xListener.is() ) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir Reference< ::com::sun::star::awt::XWindow > xWindow = VCLUnoHelper::GetInterface( mpControl ); 528*cdf0e10cSrcweir if( xWindow.is() ) 529*cdf0e10cSrcweir xWindow->removeFocusListener( xListener ); 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir 533*cdf0e10cSrcweir //----------------------------------------------------------------------------- 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir void SAL_CALL SvxGraphCtrlAccessibleContext::grabFocus() throw( RuntimeException ) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir if( NULL == mpControl ) 540*cdf0e10cSrcweir throw DisposedException(); 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir mpControl->GrabFocus(); 543*cdf0e10cSrcweir } 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir //----------------------------------------------------------------------------- 546*cdf0e10cSrcweir 547*cdf0e10cSrcweir Any SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleKeyBinding() throw( RuntimeException ) 548*cdf0e10cSrcweir { 549*cdf0e10cSrcweir // here is no implementation, because here are no KeyBindings for every object 550*cdf0e10cSrcweir return Any(); 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getForeground (void) 558*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir svtools::ColorConfig aColorConfig; 561*cdf0e10cSrcweir sal_uInt32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor; 562*cdf0e10cSrcweir return static_cast<sal_Int32>(nColor); 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getBackground (void) 569*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor(); 572*cdf0e10cSrcweir return static_cast<sal_Int32>(nColor); 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir 576*cdf0e10cSrcweir //===== XServiceInfo ======================================================== 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir OUString SAL_CALL SvxGraphCtrlAccessibleContext::getImplementationName( void ) throw( RuntimeException ) 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ui.SvxGraphCtrlAccessibleContext" ) ); 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir //----------------------------------------------------------------------------- 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir sal_Bool SAL_CALL SvxGraphCtrlAccessibleContext::supportsService( const OUString& sServiceName ) throw( RuntimeException ) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 588*cdf0e10cSrcweir // Iterate over all supported service names and return true if on of them 589*cdf0e10cSrcweir // matches the given name. 590*cdf0e10cSrcweir Sequence< OUString > aSupportedServices( getSupportedServiceNames() ); 591*cdf0e10cSrcweir int nLenght = aSupportedServices.getLength(); 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir for( int i = 0 ; i < nLenght ; ++i ) 594*cdf0e10cSrcweir { 595*cdf0e10cSrcweir if( sServiceName == aSupportedServices[ i ] ) 596*cdf0e10cSrcweir return sal_True; 597*cdf0e10cSrcweir } 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir return sal_False; 600*cdf0e10cSrcweir } 601*cdf0e10cSrcweir 602*cdf0e10cSrcweir //----------------------------------------------------------------------------- 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir Sequence< OUString > SAL_CALL SvxGraphCtrlAccessibleContext::getSupportedServiceNames( void ) throw( RuntimeException ) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir Sequence< OUString > aSNs( 3 ); 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir aSNs[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.Accessible" ) ); 609*cdf0e10cSrcweir aSNs[1] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) ); 610*cdf0e10cSrcweir aSNs[2] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.AccessibleGraphControl" ) ); 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir return aSNs; 613*cdf0e10cSrcweir } 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir //===== XTypeProvider ======================================================= 616*cdf0e10cSrcweir 617*cdf0e10cSrcweir Sequence<sal_Int8> SAL_CALL SvxGraphCtrlAccessibleContext::getImplementationId( void ) throw( RuntimeException ) 618*cdf0e10cSrcweir { 619*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 620*cdf0e10cSrcweir return getUniqueId(); 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir //===== XServiceName ======================================================== 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir OUString SvxGraphCtrlAccessibleContext::getServiceName( void ) throw( RuntimeException ) 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) ); 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir //===== XAccessibleSelection ============================================= 631*cdf0e10cSrcweir 632*cdf0e10cSrcweir void SAL_CALL SvxGraphCtrlAccessibleContext::selectAccessibleChild( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException ) 633*cdf0e10cSrcweir { 634*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir if( NULL == mpView ) 637*cdf0e10cSrcweir throw DisposedException(); 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir SdrObject* pObj = getSdrObject( nIndex ); 640*cdf0e10cSrcweir 641*cdf0e10cSrcweir if( pObj ) 642*cdf0e10cSrcweir mpView->MarkObj( pObj, mpView->GetSdrPageView()); 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir //----------------------------------------------------------------------------- 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir sal_Bool SAL_CALL SvxGraphCtrlAccessibleContext::isAccessibleChildSelected( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException ) 648*cdf0e10cSrcweir { 649*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 650*cdf0e10cSrcweir 651*cdf0e10cSrcweir if( NULL == mpView ) 652*cdf0e10cSrcweir throw DisposedException(); 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir return mpView->IsObjMarked( getSdrObject( nIndex ) ); 655*cdf0e10cSrcweir } 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir //----------------------------------------------------------------------------- 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir void SAL_CALL SvxGraphCtrlAccessibleContext::clearAccessibleSelection() throw( RuntimeException ) 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 662*cdf0e10cSrcweir 663*cdf0e10cSrcweir if( NULL == mpView ) 664*cdf0e10cSrcweir throw DisposedException(); 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir mpView->UnmarkAllObj(); 667*cdf0e10cSrcweir } 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir //----------------------------------------------------------------------------- 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir void SAL_CALL SvxGraphCtrlAccessibleContext::selectAllAccessibleChildren() throw( RuntimeException ) 672*cdf0e10cSrcweir { 673*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir if( NULL == mpView ) 676*cdf0e10cSrcweir throw DisposedException(); 677*cdf0e10cSrcweir 678*cdf0e10cSrcweir mpView->MarkAllObj(); 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir //----------------------------------------------------------------------------- 682*cdf0e10cSrcweir 683*cdf0e10cSrcweir sal_Int32 SAL_CALL SvxGraphCtrlAccessibleContext::getSelectedAccessibleChildCount() throw( RuntimeException ) 684*cdf0e10cSrcweir { 685*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir if( NULL == mpView ) 688*cdf0e10cSrcweir throw DisposedException(); 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir const SdrMarkList& rList = mpView->GetMarkedObjectList(); 691*cdf0e10cSrcweir return rList.GetMarkCount(); 692*cdf0e10cSrcweir } 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir //----------------------------------------------------------------------------- 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getSelectedAccessibleChild( sal_Int32 nIndex ) 697*cdf0e10cSrcweir throw( lang::IndexOutOfBoundsException, RuntimeException ) 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir checkChildIndexOnSelection( nIndex ); 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir Reference< XAccessible > xAccessible; 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir const SdrMarkList& rList = mpView->GetMarkedObjectList(); 706*cdf0e10cSrcweir SdrObject* pObj = rList.GetMark(nIndex)->GetMarkedSdrObj(); 707*cdf0e10cSrcweir if( pObj ) 708*cdf0e10cSrcweir xAccessible = getAccessible( pObj ); 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir return xAccessible; 711*cdf0e10cSrcweir } 712*cdf0e10cSrcweir 713*cdf0e10cSrcweir //----------------------------------------------------------------------------- 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir void SAL_CALL SvxGraphCtrlAccessibleContext::deselectAccessibleChild( sal_Int32 nIndex ) throw( lang::IndexOutOfBoundsException, RuntimeException ) 716*cdf0e10cSrcweir { 717*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir checkChildIndexOnSelection( nIndex ); 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir if( mpView ) 722*cdf0e10cSrcweir { 723*cdf0e10cSrcweir const SdrMarkList& rList = mpView->GetMarkedObjectList(); 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir SdrObject* pObj = getSdrObject( nIndex ); 726*cdf0e10cSrcweir if( pObj ) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir SdrMarkList aRefList( rList ); 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir SdrPageView* pPV = mpView->GetSdrPageView(); 731*cdf0e10cSrcweir mpView->UnmarkAllObj( pPV ); 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir sal_uInt32 nCount = aRefList.GetMarkCount(); 734*cdf0e10cSrcweir sal_uInt32 nMark; 735*cdf0e10cSrcweir for( nMark = 0; nMark < nCount; nMark++ ) 736*cdf0e10cSrcweir { 737*cdf0e10cSrcweir if( aRefList.GetMark(nMark)->GetMarkedSdrObj() != pObj ) 738*cdf0e10cSrcweir mpView->MarkObj( aRefList.GetMark(nMark)->GetMarkedSdrObj(), pPV ); 739*cdf0e10cSrcweir } 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir } 742*cdf0e10cSrcweir } 743*cdf0e10cSrcweir 744*cdf0e10cSrcweir //===== internals ======================================================== 745*cdf0e10cSrcweir 746*cdf0e10cSrcweir void SvxGraphCtrlAccessibleContext::checkChildIndex( long nIndex ) throw( lang::IndexOutOfBoundsException ) 747*cdf0e10cSrcweir { 748*cdf0e10cSrcweir if( nIndex < 0 || nIndex >= getAccessibleChildCount() ) 749*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 750*cdf0e10cSrcweir } 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir //----------------------------------------------------------------------------- 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir void SvxGraphCtrlAccessibleContext::checkChildIndexOnSelection( long nIndex ) throw( lang::IndexOutOfBoundsException ) 755*cdf0e10cSrcweir { 756*cdf0e10cSrcweir if( nIndex < 0 || nIndex >= getSelectedAccessibleChildCount() ) 757*cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 758*cdf0e10cSrcweir } 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir //----------------------------------------------------------------------------- 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir void SvxGraphCtrlAccessibleContext::setName( const OUString& rName ) 763*cdf0e10cSrcweir { 764*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir msName = rName; 767*cdf0e10cSrcweir } 768*cdf0e10cSrcweir 769*cdf0e10cSrcweir //----------------------------------------------------------------------------- 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir void SvxGraphCtrlAccessibleContext::setDescription( const OUString& rDescr ) 772*cdf0e10cSrcweir { 773*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 774*cdf0e10cSrcweir 775*cdf0e10cSrcweir msDescription = rDescr; 776*cdf0e10cSrcweir } 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir /** Replace the model, page, and view pointers by the ones provided 782*cdf0e10cSrcweir (explicitly and implicitly). 783*cdf0e10cSrcweir */ 784*cdf0e10cSrcweir void SvxGraphCtrlAccessibleContext::setModelAndView ( 785*cdf0e10cSrcweir SdrModel* pModel, 786*cdf0e10cSrcweir SdrView* pView) 787*cdf0e10cSrcweir { 788*cdf0e10cSrcweir OGuard aGuard (Application::GetSolarMutex()); 789*cdf0e10cSrcweir 790*cdf0e10cSrcweir mpModel = pModel; 791*cdf0e10cSrcweir if (mpModel != NULL) 792*cdf0e10cSrcweir mpPage = (SdrPage*)mpModel->GetPage( 0 ); 793*cdf0e10cSrcweir mpView = pView; 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir if (mpModel == NULL || mpPage == NULL || mpView == NULL) 796*cdf0e10cSrcweir { 797*cdf0e10cSrcweir mbDisposed = true; 798*cdf0e10cSrcweir 799*cdf0e10cSrcweir // Set all the pointers to NULL just in case they are used as 800*cdf0e10cSrcweir // a disposed flag. 801*cdf0e10cSrcweir mpModel = NULL; 802*cdf0e10cSrcweir mpPage = NULL; 803*cdf0e10cSrcweir mpView = NULL; 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir maTreeInfo.SetSdrView (mpView); 807*cdf0e10cSrcweir } 808*cdf0e10cSrcweir 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir 811*cdf0e10cSrcweir //----------------------------------------------------------------------------- 812*cdf0e10cSrcweir 813*cdf0e10cSrcweir void SAL_CALL SvxGraphCtrlAccessibleContext::disposing() 814*cdf0e10cSrcweir { 815*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir if( mbDisposed ) 818*cdf0e10cSrcweir return; 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir mbDisposed = sal_True; 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir mpControl = NULL; // object dies with representation 823*cdf0e10cSrcweir mpView = NULL; 824*cdf0e10cSrcweir mpPage = NULL; 825*cdf0e10cSrcweir 826*cdf0e10cSrcweir { 827*cdf0e10cSrcweir ShapesMapType::iterator I; 828*cdf0e10cSrcweir 829*cdf0e10cSrcweir for (I=mxShapes.begin(); I!=mxShapes.end(); I++) 830*cdf0e10cSrcweir { 831*cdf0e10cSrcweir XAccessible* pAcc = (*I).second; 832*cdf0e10cSrcweir Reference< XComponent > xComp( pAcc, UNO_QUERY ); 833*cdf0e10cSrcweir if( xComp.is() ) 834*cdf0e10cSrcweir xComp->dispose(); 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir (*I).second->release(); 837*cdf0e10cSrcweir } 838*cdf0e10cSrcweir 839*cdf0e10cSrcweir mxShapes.clear(); 840*cdf0e10cSrcweir } 841*cdf0e10cSrcweir 842*cdf0e10cSrcweir // Send a disposing to all listeners. 843*cdf0e10cSrcweir if ( mnClientId ) 844*cdf0e10cSrcweir { 845*cdf0e10cSrcweir comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); 846*cdf0e10cSrcweir mnClientId = 0; 847*cdf0e10cSrcweir } 848*cdf0e10cSrcweir } 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir //----------------------------------------------------------------------------- 851*cdf0e10cSrcweir 852*cdf0e10cSrcweir Rectangle SvxGraphCtrlAccessibleContext::GetBoundingBoxOnScreen( void ) throw( RuntimeException ) 853*cdf0e10cSrcweir { 854*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 855*cdf0e10cSrcweir 856*cdf0e10cSrcweir if( NULL == mpControl ) 857*cdf0e10cSrcweir throw DisposedException(); 858*cdf0e10cSrcweir 859*cdf0e10cSrcweir return Rectangle( 860*cdf0e10cSrcweir mpControl->GetAccessibleParentWindow()->OutputToAbsoluteScreenPixel( 861*cdf0e10cSrcweir mpControl->GetPosPixel() ), 862*cdf0e10cSrcweir mpControl->GetSizePixel() ); 863*cdf0e10cSrcweir } 864*cdf0e10cSrcweir 865*cdf0e10cSrcweir //----------------------------------------------------------------------------- 866*cdf0e10cSrcweir 867*cdf0e10cSrcweir /** Calculate the relative coordinates of the bounding box as difference 868*cdf0e10cSrcweir between the absolute coordinates of the bounding boxes of this control 869*cdf0e10cSrcweir and its parent in the accessibility tree. 870*cdf0e10cSrcweir */ 871*cdf0e10cSrcweir Rectangle SvxGraphCtrlAccessibleContext::GetBoundingBox( void ) throw( RuntimeException ) 872*cdf0e10cSrcweir { 873*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 874*cdf0e10cSrcweir 875*cdf0e10cSrcweir Rectangle aBounds ( 0, 0, 0, 0 ); 876*cdf0e10cSrcweir 877*cdf0e10cSrcweir Window* pWindow = mpControl; 878*cdf0e10cSrcweir if (pWindow != NULL) 879*cdf0e10cSrcweir { 880*cdf0e10cSrcweir aBounds = pWindow->GetWindowExtentsRelative (NULL); 881*cdf0e10cSrcweir Window* pParent = pWindow->GetAccessibleParentWindow(); 882*cdf0e10cSrcweir if (pParent != NULL) 883*cdf0e10cSrcweir { 884*cdf0e10cSrcweir Rectangle aParentRect = pParent->GetWindowExtentsRelative (NULL); 885*cdf0e10cSrcweir aBounds -= aParentRect.TopLeft(); 886*cdf0e10cSrcweir } 887*cdf0e10cSrcweir } 888*cdf0e10cSrcweir else 889*cdf0e10cSrcweir throw DisposedException(); 890*cdf0e10cSrcweir 891*cdf0e10cSrcweir return aBounds; 892*cdf0e10cSrcweir } 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir //----------------------------------------------------------------------------- 895*cdf0e10cSrcweir 896*cdf0e10cSrcweir Sequence< sal_Int8 > SvxGraphCtrlAccessibleContext::getUniqueId( void ) 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir // no guard because it's private -> has to guarded when using it! 899*cdf0e10cSrcweir static OImplementationId* pId = 0; 900*cdf0e10cSrcweir if( !pId ) 901*cdf0e10cSrcweir { 902*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 903*cdf0e10cSrcweir if( !pId) 904*cdf0e10cSrcweir { 905*cdf0e10cSrcweir static OImplementationId aId; 906*cdf0e10cSrcweir pId = &aId; 907*cdf0e10cSrcweir } 908*cdf0e10cSrcweir } 909*cdf0e10cSrcweir return pId->getImplementationId(); 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir //----------------------------------------------------------------------------- 913*cdf0e10cSrcweir 914*cdf0e10cSrcweir void SvxGraphCtrlAccessibleContext::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) 915*cdf0e10cSrcweir { 916*cdf0e10cSrcweir const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir if( pSdrHint ) 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir switch( pSdrHint->GetKind() ) 921*cdf0e10cSrcweir { 922*cdf0e10cSrcweir case HINT_OBJCHG: 923*cdf0e10cSrcweir { 924*cdf0e10cSrcweir ShapesMapType::iterator iter = mxShapes.find( pSdrHint->GetObject() ); 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir if( iter != mxShapes.end() ) 927*cdf0e10cSrcweir { 928*cdf0e10cSrcweir // if we already have one, return it 929*cdf0e10cSrcweir AccessibleShape* pShape = (*iter).second; 930*cdf0e10cSrcweir 931*cdf0e10cSrcweir if( NULL != pShape ) 932*cdf0e10cSrcweir pShape->CommitChange( AccessibleEventId::VISIBLE_DATA_CHANGED, uno::Any(), uno::Any() ); 933*cdf0e10cSrcweir } 934*cdf0e10cSrcweir } 935*cdf0e10cSrcweir break; 936*cdf0e10cSrcweir 937*cdf0e10cSrcweir case HINT_OBJINSERTED: 938*cdf0e10cSrcweir CommitChange( AccessibleEventId::CHILD, makeAny( getAccessible( pSdrHint->GetObject() ) ) , uno::Any()); 939*cdf0e10cSrcweir break; 940*cdf0e10cSrcweir case HINT_OBJREMOVED: 941*cdf0e10cSrcweir CommitChange( AccessibleEventId::CHILD, uno::Any(), makeAny( getAccessible( pSdrHint->GetObject() ) ) ); 942*cdf0e10cSrcweir break; 943*cdf0e10cSrcweir case HINT_MODELCLEARED: 944*cdf0e10cSrcweir dispose(); 945*cdf0e10cSrcweir break; 946*cdf0e10cSrcweir default: 947*cdf0e10cSrcweir break; 948*cdf0e10cSrcweir } 949*cdf0e10cSrcweir } 950*cdf0e10cSrcweir else 951*cdf0e10cSrcweir { 952*cdf0e10cSrcweir const SfxSimpleHint* pSfxHint = PTR_CAST(SfxSimpleHint, &rHint ); 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir // ist unser SdDrawDocument gerade gestorben? 955*cdf0e10cSrcweir if(pSfxHint && pSfxHint->GetId() == SFX_HINT_DYING) 956*cdf0e10cSrcweir { 957*cdf0e10cSrcweir dispose(); 958*cdf0e10cSrcweir } 959*cdf0e10cSrcweir } 960*cdf0e10cSrcweir } 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir //===== IAccessibleViewforwarder ======================================== 963*cdf0e10cSrcweir 964*cdf0e10cSrcweir sal_Bool SvxGraphCtrlAccessibleContext::IsValid (void) const 965*cdf0e10cSrcweir { 966*cdf0e10cSrcweir return sal_True; 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir //----------------------------------------------------------------------------- 970*cdf0e10cSrcweir 971*cdf0e10cSrcweir Rectangle SvxGraphCtrlAccessibleContext::GetVisibleArea (void) const 972*cdf0e10cSrcweir { 973*cdf0e10cSrcweir Rectangle aVisArea; 974*cdf0e10cSrcweir 975*cdf0e10cSrcweir if( mpView && mpView->PaintWindowCount()) 976*cdf0e10cSrcweir { 977*cdf0e10cSrcweir SdrPaintWindow* pPaintWindow = mpView->GetPaintWindow(0L); 978*cdf0e10cSrcweir aVisArea = pPaintWindow->GetVisibleArea(); 979*cdf0e10cSrcweir } 980*cdf0e10cSrcweir 981*cdf0e10cSrcweir return aVisArea; 982*cdf0e10cSrcweir } 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir //----------------------------------------------------------------------------- 985*cdf0e10cSrcweir 986*cdf0e10cSrcweir Point SvxGraphCtrlAccessibleContext::LogicToPixel (const Point& rPoint) const 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir if( mpControl ) 989*cdf0e10cSrcweir { 990*cdf0e10cSrcweir Rectangle aBBox(mpControl->GetWindowExtentsRelative(NULL)); 991*cdf0e10cSrcweir return mpControl->LogicToPixel (rPoint) + aBBox.TopLeft(); 992*cdf0e10cSrcweir } 993*cdf0e10cSrcweir else 994*cdf0e10cSrcweir { 995*cdf0e10cSrcweir return rPoint; 996*cdf0e10cSrcweir } 997*cdf0e10cSrcweir } 998*cdf0e10cSrcweir 999*cdf0e10cSrcweir //----------------------------------------------------------------------------- 1000*cdf0e10cSrcweir 1001*cdf0e10cSrcweir Size SvxGraphCtrlAccessibleContext::LogicToPixel (const Size& rSize) const 1002*cdf0e10cSrcweir { 1003*cdf0e10cSrcweir if( mpControl ) 1004*cdf0e10cSrcweir return mpControl->LogicToPixel (rSize); 1005*cdf0e10cSrcweir else 1006*cdf0e10cSrcweir return rSize; 1007*cdf0e10cSrcweir } 1008*cdf0e10cSrcweir 1009*cdf0e10cSrcweir //----------------------------------------------------------------------------- 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir Point SvxGraphCtrlAccessibleContext::PixelToLogic (const Point& rPoint) const 1012*cdf0e10cSrcweir { 1013*cdf0e10cSrcweir if( mpControl ) 1014*cdf0e10cSrcweir return mpControl->PixelToLogic (rPoint); 1015*cdf0e10cSrcweir else 1016*cdf0e10cSrcweir return rPoint; 1017*cdf0e10cSrcweir } 1018*cdf0e10cSrcweir 1019*cdf0e10cSrcweir //----------------------------------------------------------------------------- 1020*cdf0e10cSrcweir 1021*cdf0e10cSrcweir Size SvxGraphCtrlAccessibleContext::PixelToLogic (const Size& rSize) const 1022*cdf0e10cSrcweir { 1023*cdf0e10cSrcweir if( mpControl ) 1024*cdf0e10cSrcweir return mpControl->PixelToLogic (rSize); 1025*cdf0e10cSrcweir else 1026*cdf0e10cSrcweir return rSize; 1027*cdf0e10cSrcweir } 1028