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