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_chart2.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "AccessibleBase.hxx" 32*cdf0e10cSrcweir #include "AccessibleChartShape.hxx" 33*cdf0e10cSrcweir #include "ObjectHierarchy.hxx" 34*cdf0e10cSrcweir #include "ObjectIdentifier.hxx" 35*cdf0e10cSrcweir #include "chartview/ExplicitValueProvider.hxx" 36*cdf0e10cSrcweir #include "macros.hxx" 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #include <com/sun/star/awt/XDevice.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventObject.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 43*cdf0e10cSrcweir #include <comphelper/serviceinfohelper.hxx> 44*cdf0e10cSrcweir #include <com/sun/star/drawing/LineStyle.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/drawing/FillStyle.hpp> 46*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 47*cdf0e10cSrcweir // for SolarMutex 48*cdf0e10cSrcweir #include <vcl/svapp.hxx> 49*cdf0e10cSrcweir #include <rtl/uuid.h> 50*cdf0e10cSrcweir #include <cppuhelper/queryinterface.hxx> 51*cdf0e10cSrcweir #include <svl/itemset.hxx> 52*cdf0e10cSrcweir #include <editeng/unofdesc.hxx> 53*cdf0e10cSrcweir #include <editeng/outliner.hxx> 54*cdf0e10cSrcweir #include <svx/svdoutl.hxx> 55*cdf0e10cSrcweir #include <svx/svdetc.hxx> 56*cdf0e10cSrcweir #include <svx/unoshape.hxx> 57*cdf0e10cSrcweir #include <svx/unoprov.hxx> 58*cdf0e10cSrcweir #include <vcl/unohelp.hxx> 59*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx> 60*cdf0e10cSrcweir #include <vcl/window.hxx> 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir #include <algorithm> 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir #include "ChartElementFactory.hxx" 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir using namespace ::com::sun::star; 67*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 70*cdf0e10cSrcweir using ::rtl::OUString; 71*cdf0e10cSrcweir using ::rtl::OUStringBuffer; 72*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 73*cdf0e10cSrcweir using ::osl::MutexGuard; 74*cdf0e10cSrcweir using ::osl::ClearableMutexGuard; 75*cdf0e10cSrcweir using ::osl::ResettableMutexGuard; 76*cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 77*cdf0e10cSrcweir using ::com::sun::star::uno::Any; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir namespace chart 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir /** @param bMayHaveChildren is false per default 83*cdf0e10cSrcweir */ 84*cdf0e10cSrcweir AccessibleBase::AccessibleBase( 85*cdf0e10cSrcweir const AccessibleElementInfo & rAccInfo, 86*cdf0e10cSrcweir bool bMayHaveChildren, 87*cdf0e10cSrcweir bool bAlwaysTransparent /* default: false */ ) : 88*cdf0e10cSrcweir impl::AccessibleBase_Base( m_aMutex ), 89*cdf0e10cSrcweir m_bIsDisposed( false ), 90*cdf0e10cSrcweir m_bMayHaveChildren( bMayHaveChildren ), 91*cdf0e10cSrcweir m_bChildrenInitialized( false ), 92*cdf0e10cSrcweir m_nEventNotifierId(0), 93*cdf0e10cSrcweir m_pStateSetHelper( new ::utl::AccessibleStateSetHelper() ), 94*cdf0e10cSrcweir m_aStateSet( m_pStateSetHelper ), 95*cdf0e10cSrcweir m_aAccInfo( rAccInfo ), 96*cdf0e10cSrcweir m_bAlwaysTransparent( bAlwaysTransparent ), 97*cdf0e10cSrcweir m_bStateSetInitialized( false ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir // initialize some states 100*cdf0e10cSrcweir OSL_ASSERT( m_pStateSetHelper ); 101*cdf0e10cSrcweir m_pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 102*cdf0e10cSrcweir m_pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 103*cdf0e10cSrcweir m_pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); 104*cdf0e10cSrcweir m_pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); 105*cdf0e10cSrcweir m_pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE ); 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir AccessibleBase::~AccessibleBase() 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir OSL_ASSERT( m_bIsDisposed ); 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir // ________ public ________ 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir bool AccessibleBase::CheckDisposeState( bool bThrowException /* default: true */ ) const 116*cdf0e10cSrcweir throw (lang::DisposedException) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir if( bThrowException && 119*cdf0e10cSrcweir m_bIsDisposed ) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir throw lang::DisposedException( 122*cdf0e10cSrcweir C2U("component has state DEFUNC" ), 123*cdf0e10cSrcweir static_cast< uno::XWeak * >( const_cast< AccessibleBase * >( this ))); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir return m_bIsDisposed; 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir bool AccessibleBase::NotifyEvent( EventType eEventType, const AccessibleUniqueId & rId ) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir if( GetId() == rId ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir // event is addressed to this object 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir ::com::sun::star::uno::Any aEmpty; 135*cdf0e10cSrcweir ::com::sun::star::uno::Any aSelected; 136*cdf0e10cSrcweir aSelected <<= AccessibleStateType::SELECTED; 137*cdf0e10cSrcweir switch( eEventType ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir case OBJECT_CHANGE: 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir BroadcastAccEvent( AccessibleEventId::VISIBLE_DATA_CHANGED, aEmpty, aEmpty ); 142*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 143*cdf0e10cSrcweir OSL_TRACE( 144*cdf0e10cSrcweir ::rtl::OUStringToOString( 145*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( 146*cdf0e10cSrcweir "Visible data event sent by: " )) + 147*cdf0e10cSrcweir getAccessibleName(), 148*cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).getStr() ); 149*cdf0e10cSrcweir #endif 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir break; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir case GOT_SELECTION: 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir AddState( AccessibleStateType::SELECTED ); 156*cdf0e10cSrcweir BroadcastAccEvent( AccessibleEventId::STATE_CHANGED, aSelected, aEmpty ); 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir AddState( AccessibleStateType::FOCUSED ); 159*cdf0e10cSrcweir aSelected <<= AccessibleStateType::FOCUSED; 160*cdf0e10cSrcweir BroadcastAccEvent( AccessibleEventId::STATE_CHANGED, aSelected, aEmpty, true ); 161*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 162*cdf0e10cSrcweir OSL_TRACE( 163*cdf0e10cSrcweir ::rtl::OUStringToOString( 164*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( 165*cdf0e10cSrcweir "Selection acquired by: " )) + 166*cdf0e10cSrcweir getAccessibleName(), 167*cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).getStr() ); 168*cdf0e10cSrcweir #endif 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir break; 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir case LOST_SELECTION: 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir RemoveState( AccessibleStateType::SELECTED ); 175*cdf0e10cSrcweir BroadcastAccEvent( AccessibleEventId::STATE_CHANGED, aEmpty, aSelected ); 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir AddState( AccessibleStateType::FOCUSED ); 178*cdf0e10cSrcweir aSelected <<= AccessibleStateType::FOCUSED; 179*cdf0e10cSrcweir BroadcastAccEvent( AccessibleEventId::STATE_CHANGED, aEmpty, aSelected, true ); 180*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 181*cdf0e10cSrcweir OSL_TRACE( 182*cdf0e10cSrcweir ::rtl::OUStringToOString( 183*cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM( 184*cdf0e10cSrcweir "Selection lost by: " )) + 185*cdf0e10cSrcweir getAccessibleName(), 186*cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ).getStr() ); 187*cdf0e10cSrcweir #endif 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir break; 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir case PROPERTY_CHANGE: 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir //not implemented --> rebuild all 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir break; 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir return true; 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir else if( m_bMayHaveChildren ) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir bool bStop = false; 202*cdf0e10cSrcweir // /-- 203*cdf0e10cSrcweir ClearableMutexGuard aGuard( GetMutex() ); 204*cdf0e10cSrcweir // make local copy for notification 205*cdf0e10cSrcweir ChildListVectorType aLocalChildList( m_aChildList ); 206*cdf0e10cSrcweir aGuard.clear(); 207*cdf0e10cSrcweir // \-- 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir ChildListVectorType::iterator aEndIter = aLocalChildList.end(); 210*cdf0e10cSrcweir for( ChildListVectorType::iterator aIter = aLocalChildList.begin() ; 211*cdf0e10cSrcweir ( aIter != aEndIter ) && ( ! bStop ) ; 212*cdf0e10cSrcweir ++aIter ) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir // Note: at this place we must be sure to have an AccessibleBase 215*cdf0e10cSrcweir // object in the UNO reference to XAccessible ! 216*cdf0e10cSrcweir bStop = (*static_cast< AccessibleBase * > 217*cdf0e10cSrcweir ( (*aIter).get() )).NotifyEvent( eEventType, rId ); 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir return bStop; 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir return false; 223*cdf0e10cSrcweir } 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir void AccessibleBase::AddState( sal_Int16 aState ) 226*cdf0e10cSrcweir throw (RuntimeException) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir CheckDisposeState(); 229*cdf0e10cSrcweir OSL_ASSERT( m_pStateSetHelper ); 230*cdf0e10cSrcweir m_pStateSetHelper->AddState( aState ); 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir void AccessibleBase::RemoveState( sal_Int16 aState ) 234*cdf0e10cSrcweir throw (RuntimeException) 235*cdf0e10cSrcweir { 236*cdf0e10cSrcweir CheckDisposeState(); 237*cdf0e10cSrcweir OSL_ASSERT( m_pStateSetHelper ); 238*cdf0e10cSrcweir m_pStateSetHelper->RemoveState( aState ); 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir // ________ protected ________ 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir bool AccessibleBase::UpdateChildren() 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir bool bMustUpdateChildren = false; 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir // /-- 248*cdf0e10cSrcweir MutexGuard aGuard( GetMutex() ); 249*cdf0e10cSrcweir if( ! m_bMayHaveChildren || 250*cdf0e10cSrcweir m_bIsDisposed ) 251*cdf0e10cSrcweir return false; 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir bMustUpdateChildren = ( m_bMayHaveChildren && 254*cdf0e10cSrcweir ! m_bChildrenInitialized ); 255*cdf0e10cSrcweir // \-- 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir // update unguarded 259*cdf0e10cSrcweir if( bMustUpdateChildren ) 260*cdf0e10cSrcweir m_bChildrenInitialized = ImplUpdateChildren(); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir return m_bChildrenInitialized; 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir bool AccessibleBase::ImplUpdateChildren() 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir bool bResult = false; 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir if( m_aAccInfo.m_spObjectHierarchy ) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir ObjectHierarchy::tChildContainer aModelChildren( 272*cdf0e10cSrcweir m_aAccInfo.m_spObjectHierarchy->getChildren( GetId() )); 273*cdf0e10cSrcweir ::std::vector< ChildOIDMap::key_type > aAccChildren; 274*cdf0e10cSrcweir aAccChildren.reserve( aModelChildren.size()); 275*cdf0e10cSrcweir ::std::transform( m_aChildOIDMap.begin(), m_aChildOIDMap.end(), 276*cdf0e10cSrcweir ::std::back_inserter( aAccChildren ), 277*cdf0e10cSrcweir ::std::select1st< ChildOIDMap::value_type >()); 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir ::std::sort( aModelChildren.begin(), aModelChildren.end()); 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir ::std::vector< ObjectHierarchy::tOID > aChildrenToRemove, aChildrenToAdd; 282*cdf0e10cSrcweir ::std::set_difference( aModelChildren.begin(), aModelChildren.end(), 283*cdf0e10cSrcweir aAccChildren.begin(), aAccChildren.end(), 284*cdf0e10cSrcweir ::std::back_inserter( aChildrenToAdd )); 285*cdf0e10cSrcweir ::std::set_difference( aAccChildren.begin(), aAccChildren.end(), 286*cdf0e10cSrcweir aModelChildren.begin(), aModelChildren.end(), 287*cdf0e10cSrcweir ::std::back_inserter( aChildrenToRemove )); 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir ::std::vector< ObjectHierarchy::tOID >::const_iterator aIt( aChildrenToRemove.begin()); 290*cdf0e10cSrcweir for( ; aIt != aChildrenToRemove.end(); ++aIt ) 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir RemoveChildByOId( *aIt ); 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir AccessibleElementInfo aAccInfo( GetInfo()); 296*cdf0e10cSrcweir aAccInfo.m_pParent = this; 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir for( aIt = aChildrenToAdd.begin(); aIt != aChildrenToAdd.end(); ++aIt ) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir aAccInfo.m_aOID = *aIt; 301*cdf0e10cSrcweir if ( aIt->isAutoGeneratedObject() ) 302*cdf0e10cSrcweir { 303*cdf0e10cSrcweir AddChild( ChartElementFactory::CreateChartElement( aAccInfo ) ); 304*cdf0e10cSrcweir } 305*cdf0e10cSrcweir else if ( aIt->isAdditionalShape() ) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir AddChild( new AccessibleChartShape( aAccInfo, true, false ) ); 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir bResult = true; 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir 313*cdf0e10cSrcweir return bResult; 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir void AccessibleBase::AddChild( AccessibleBase * pChild ) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir OSL_ENSURE( pChild != NULL, "Invalid Child" ); 319*cdf0e10cSrcweir if( pChild ) 320*cdf0e10cSrcweir { 321*cdf0e10cSrcweir // /-- 322*cdf0e10cSrcweir ClearableMutexGuard aGuard( GetMutex() ); 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir Reference< XAccessible > xChild( pChild ); 325*cdf0e10cSrcweir m_aChildList.push_back( xChild ); 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir m_aChildOIDMap[ pChild->GetId() ] = xChild; 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir // inform listeners of new child 330*cdf0e10cSrcweir if( m_bChildrenInitialized ) 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir Any aEmpty, aNew; 333*cdf0e10cSrcweir aNew <<= xChild; 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir aGuard.clear(); 336*cdf0e10cSrcweir // \-- (1st) 337*cdf0e10cSrcweir BroadcastAccEvent( AccessibleEventId::CHILD, aNew, aEmpty ); 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir // \-- (2nd) 340*cdf0e10cSrcweir } 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir /** in this method we imply that the Reference< XAccessible > elements in the 344*cdf0e10cSrcweir vector are AccessibleBase objects ! 345*cdf0e10cSrcweir */ 346*cdf0e10cSrcweir void AccessibleBase::RemoveChildByOId( const ObjectIdentifier& rOId ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir // /-- 349*cdf0e10cSrcweir ClearableMutexGuard aGuard( GetMutex() ); 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir ChildOIDMap::iterator aIt( m_aChildOIDMap.find( rOId )); 352*cdf0e10cSrcweir if( aIt != m_aChildOIDMap.end()) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir Reference< XAccessible > xChild( aIt->second ); 355*cdf0e10cSrcweir 356*cdf0e10cSrcweir // remove from map 357*cdf0e10cSrcweir m_aChildOIDMap.erase( aIt ); 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir // search child in vector 360*cdf0e10cSrcweir ChildListVectorType::iterator aVecIter = 361*cdf0e10cSrcweir ::std::find( m_aChildList.begin(), m_aChildList.end(), xChild ); 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir OSL_ENSURE( aVecIter != m_aChildList.end(), 364*cdf0e10cSrcweir "Inconsistent ChildMap" ); 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir // remove child from vector 367*cdf0e10cSrcweir m_aChildList.erase( aVecIter ); 368*cdf0e10cSrcweir bool bInitialized = m_bChildrenInitialized; 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir // call listeners unguarded 371*cdf0e10cSrcweir aGuard.clear(); 372*cdf0e10cSrcweir // \-- (1st) 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir // inform listeners of removed child 375*cdf0e10cSrcweir if( bInitialized ) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir Any aEmpty, aOld; 378*cdf0e10cSrcweir aOld <<= xChild; 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir BroadcastAccEvent( AccessibleEventId::CHILD, aEmpty, aOld ); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir // dispose the child 384*cdf0e10cSrcweir Reference< lang::XComponent > xComp( xChild, UNO_QUERY ); 385*cdf0e10cSrcweir if( xComp.is()) 386*cdf0e10cSrcweir xComp->dispose(); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir awt::Point AccessibleBase::GetUpperLeftOnScreen() const 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir awt::Point aResult; 393*cdf0e10cSrcweir if( m_aAccInfo.m_pParent ) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir // /-- 396*cdf0e10cSrcweir ClearableMutexGuard aGuard( GetMutex() ); 397*cdf0e10cSrcweir AccessibleBase * pParent = m_aAccInfo.m_pParent; 398*cdf0e10cSrcweir aGuard.clear(); 399*cdf0e10cSrcweir // \-- 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir if( pParent ) 402*cdf0e10cSrcweir { 403*cdf0e10cSrcweir aResult = pParent->GetUpperLeftOnScreen(); 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir else 406*cdf0e10cSrcweir OSL_ENSURE( false, "Default position used is probably incorrect." ); 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir return aResult; 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir void AccessibleBase::BroadcastAccEvent( 413*cdf0e10cSrcweir sal_Int16 nId, 414*cdf0e10cSrcweir const Any & rNew, 415*cdf0e10cSrcweir const Any & rOld, 416*cdf0e10cSrcweir bool bSendGlobally ) const 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir // /-- 419*cdf0e10cSrcweir ClearableMutexGuard aGuard( GetMutex() ); 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir if ( !m_nEventNotifierId && !bSendGlobally ) 422*cdf0e10cSrcweir return; 423*cdf0e10cSrcweir // if we don't have a client id for the notifier, then we don't have listeners, then 424*cdf0e10cSrcweir // we don't need to notify anything 425*cdf0e10cSrcweir //except SendGlobally for focus handling? 426*cdf0e10cSrcweir 427*cdf0e10cSrcweir // the const cast is needed, because UNO parameters are never const 428*cdf0e10cSrcweir const AccessibleEventObject aEvent( 429*cdf0e10cSrcweir const_cast< uno::XWeak * >( static_cast< const uno::XWeak * >( this )), 430*cdf0e10cSrcweir nId, rNew, rOld ); 431*cdf0e10cSrcweir 432*cdf0e10cSrcweir if ( m_nEventNotifierId ) // let the notifier handle this event 433*cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::addEvent( m_nEventNotifierId, aEvent ); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir aGuard.clear(); 436*cdf0e10cSrcweir // \-- 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir // send event to global message queue 439*cdf0e10cSrcweir if( bSendGlobally ) 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir ::vcl::unohelper::NotifyAccessibleStateEventGlobally( aEvent ); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir void AccessibleBase::KillAllChildren() 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir // /-- 448*cdf0e10cSrcweir ClearableMutexGuard aGuard( GetMutex() ); 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir // make local copy for notification 451*cdf0e10cSrcweir ChildListVectorType aLocalChildList( m_aChildList ); 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir // remove all children 454*cdf0e10cSrcweir m_aChildList.clear(); 455*cdf0e10cSrcweir m_aChildOIDMap.clear(); 456*cdf0e10cSrcweir 457*cdf0e10cSrcweir aGuard.clear(); 458*cdf0e10cSrcweir // \-- 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir // call dispose for all children 461*cdf0e10cSrcweir // and notify listeners 462*cdf0e10cSrcweir Reference< lang::XComponent > xComp; 463*cdf0e10cSrcweir Any aEmpty, aOld; 464*cdf0e10cSrcweir ChildListVectorType::const_iterator aEndIter = aLocalChildList.end(); 465*cdf0e10cSrcweir for( ChildListVectorType::const_iterator aIter = aLocalChildList.begin(); 466*cdf0e10cSrcweir aIter != aEndIter; ++aIter ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir aOld <<= (*aIter); 469*cdf0e10cSrcweir BroadcastAccEvent( AccessibleEventId::CHILD, aEmpty, aOld ); 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir xComp.set( *aIter, UNO_QUERY ); 472*cdf0e10cSrcweir if( xComp.is()) 473*cdf0e10cSrcweir xComp->dispose(); 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir m_bChildrenInitialized = false; 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir AccessibleElementInfo AccessibleBase::GetInfo() const 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir return m_aAccInfo; 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir void AccessibleBase::SetInfo( const AccessibleElementInfo & rNewInfo ) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir m_aAccInfo = rNewInfo; 486*cdf0e10cSrcweir if( m_bMayHaveChildren ) 487*cdf0e10cSrcweir { 488*cdf0e10cSrcweir KillAllChildren(); 489*cdf0e10cSrcweir } 490*cdf0e10cSrcweir BroadcastAccEvent( AccessibleEventId::INVALIDATE_ALL_CHILDREN, uno::Any(), uno::Any(), 491*cdf0e10cSrcweir true /* global notification */ ); 492*cdf0e10cSrcweir } 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir AccessibleUniqueId AccessibleBase::GetId() const 495*cdf0e10cSrcweir { 496*cdf0e10cSrcweir return m_aAccInfo.m_aOID; 497*cdf0e10cSrcweir } 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir // ____________________________________ 500*cdf0e10cSrcweir // ____________________________________ 501*cdf0e10cSrcweir // 502*cdf0e10cSrcweir // Interfaces 503*cdf0e10cSrcweir // ____________________________________ 504*cdf0e10cSrcweir // ____________________________________ 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir // ________ (XComponent::dispose) ________ 507*cdf0e10cSrcweir void SAL_CALL AccessibleBase::disposing() 508*cdf0e10cSrcweir { 509*cdf0e10cSrcweir // /-- 510*cdf0e10cSrcweir ClearableMutexGuard aGuard( GetMutex() ); 511*cdf0e10cSrcweir OSL_ENSURE( ! m_bIsDisposed, "dispose() called twice" ); 512*cdf0e10cSrcweir 513*cdf0e10cSrcweir // notify disposing to all AccessibleEvent listeners asynchron 514*cdf0e10cSrcweir if ( m_nEventNotifierId ) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( m_nEventNotifierId, *this ); 517*cdf0e10cSrcweir m_nEventNotifierId = 0; 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir // reset pointers 521*cdf0e10cSrcweir m_aAccInfo.m_pParent = NULL; 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir // invalidate implementation for helper, but keep UNO reference to still 524*cdf0e10cSrcweir // allow a tool to query the DEFUNC state. 525*cdf0e10cSrcweir // Note: The object will be deleted when the last reference is released 526*cdf0e10cSrcweir m_pStateSetHelper = NULL; 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir // attach new empty state set helper to member reference 529*cdf0e10cSrcweir ::utl::AccessibleStateSetHelper * pHelper = new ::utl::AccessibleStateSetHelper(); 530*cdf0e10cSrcweir pHelper->AddState( AccessibleStateType::DEFUNC ); 531*cdf0e10cSrcweir // release old helper and attach new one 532*cdf0e10cSrcweir m_aStateSet.set( pHelper ); 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir m_bIsDisposed = true; 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir // call listeners unguarded 537*cdf0e10cSrcweir aGuard.clear(); 538*cdf0e10cSrcweir // \-- 539*cdf0e10cSrcweir 540*cdf0e10cSrcweir if( m_bMayHaveChildren ) 541*cdf0e10cSrcweir { 542*cdf0e10cSrcweir KillAllChildren(); 543*cdf0e10cSrcweir } 544*cdf0e10cSrcweir else 545*cdf0e10cSrcweir OSL_ENSURE( m_aChildList.empty(), "Child list should be empty" ); 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir // ________ XAccessible ________ 549*cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL AccessibleBase::getAccessibleContext() 550*cdf0e10cSrcweir throw (RuntimeException) 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir return this; 553*cdf0e10cSrcweir } 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir // ________ AccessibleBase::XAccessibleContext ________ 556*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleBase::getAccessibleChildCount() 557*cdf0e10cSrcweir throw (RuntimeException) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir // /-- 560*cdf0e10cSrcweir ClearableMutexGuard aGuard( GetMutex() ); 561*cdf0e10cSrcweir if( ! m_bMayHaveChildren || 562*cdf0e10cSrcweir m_bIsDisposed ) 563*cdf0e10cSrcweir return 0; 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir bool bMustUpdateChildren = ( m_bMayHaveChildren && 566*cdf0e10cSrcweir ! m_bChildrenInitialized ); 567*cdf0e10cSrcweir 568*cdf0e10cSrcweir aGuard.clear(); 569*cdf0e10cSrcweir // \-- 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir // update unguarded 572*cdf0e10cSrcweir if( bMustUpdateChildren ) 573*cdf0e10cSrcweir UpdateChildren(); 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir return ImplGetAccessibleChildCount(); 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir sal_Int32 AccessibleBase::ImplGetAccessibleChildCount() const 579*cdf0e10cSrcweir throw (RuntimeException) 580*cdf0e10cSrcweir { 581*cdf0e10cSrcweir return m_aChildList.size(); 582*cdf0e10cSrcweir } 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleChild( sal_Int32 i ) 585*cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, RuntimeException) 586*cdf0e10cSrcweir { 587*cdf0e10cSrcweir CheckDisposeState(); 588*cdf0e10cSrcweir Reference< XAccessible > xResult; 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir // /-- 591*cdf0e10cSrcweir ResettableMutexGuard aGuard( GetMutex() ); 592*cdf0e10cSrcweir bool bMustUpdateChildren = ( m_bMayHaveChildren && 593*cdf0e10cSrcweir ! m_bChildrenInitialized ); 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir aGuard.clear(); 596*cdf0e10cSrcweir // \-- 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir if( bMustUpdateChildren ) 599*cdf0e10cSrcweir UpdateChildren(); 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir xResult.set( ImplGetAccessibleChildById( i )); 602*cdf0e10cSrcweir 603*cdf0e10cSrcweir return xResult; 604*cdf0e10cSrcweir // \-- 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir Reference< XAccessible > AccessibleBase::ImplGetAccessibleChildById( sal_Int32 i ) const 608*cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, RuntimeException) 609*cdf0e10cSrcweir { 610*cdf0e10cSrcweir Reference< XAccessible > xResult; 611*cdf0e10cSrcweir // /-- 612*cdf0e10cSrcweir MutexGuard aGuard( GetMutex()); 613*cdf0e10cSrcweir if( ! m_bMayHaveChildren || 614*cdf0e10cSrcweir i < 0 || 615*cdf0e10cSrcweir static_cast< ChildListVectorType::size_type >( i ) >= m_aChildList.size() ) 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir OUStringBuffer aBuf; 618*cdf0e10cSrcweir aBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Index " )); 619*cdf0e10cSrcweir aBuf.append( i ); 620*cdf0e10cSrcweir aBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " is invalid for range [ 0, " )); 621*cdf0e10cSrcweir aBuf.append( static_cast< sal_Int32 >( m_aChildList.size() - 1 ) ); 622*cdf0e10cSrcweir aBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " ]" ) ); 623*cdf0e10cSrcweir lang::IndexOutOfBoundsException aEx( aBuf.makeStringAndClear(), 624*cdf0e10cSrcweir const_cast< ::cppu::OWeakObject * >( 625*cdf0e10cSrcweir static_cast< const ::cppu::OWeakObject * >( this ))); 626*cdf0e10cSrcweir throw aEx; 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir else 629*cdf0e10cSrcweir xResult.set( m_aChildList[ i ] ); 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir return xResult; 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleParent() 635*cdf0e10cSrcweir throw (RuntimeException) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir CheckDisposeState(); 638*cdf0e10cSrcweir Reference< XAccessible > aResult; 639*cdf0e10cSrcweir if( m_aAccInfo.m_pParent ) 640*cdf0e10cSrcweir aResult.set( m_aAccInfo.m_pParent ); 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir return aResult; 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleBase::getAccessibleIndexInParent() 646*cdf0e10cSrcweir throw (RuntimeException) 647*cdf0e10cSrcweir { 648*cdf0e10cSrcweir CheckDisposeState(); 649*cdf0e10cSrcweir 650*cdf0e10cSrcweir if( m_aAccInfo.m_spObjectHierarchy ) 651*cdf0e10cSrcweir return m_aAccInfo.m_spObjectHierarchy->getIndexInParent( GetId() ); 652*cdf0e10cSrcweir return -1; 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleBase::getAccessibleRole() 656*cdf0e10cSrcweir throw (RuntimeException) 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir return AccessibleRole::LIST_ITEM; // #i73747# role SHAPE seems more appropriate, but is not read 659*cdf0e10cSrcweir } 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL AccessibleBase::getAccessibleRelationSet() 662*cdf0e10cSrcweir throw (RuntimeException) 663*cdf0e10cSrcweir { 664*cdf0e10cSrcweir Reference< XAccessibleRelationSet > aResult; 665*cdf0e10cSrcweir return aResult; 666*cdf0e10cSrcweir } 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir Reference< XAccessibleStateSet > SAL_CALL AccessibleBase::getAccessibleStateSet() 669*cdf0e10cSrcweir throw (RuntimeException) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir if( ! m_bStateSetInitialized ) 672*cdf0e10cSrcweir { 673*cdf0e10cSrcweir Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier ); 674*cdf0e10cSrcweir if ( xSelSupp.is() ) 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir ObjectIdentifier aOID( xSelSupp->getSelection() ); 677*cdf0e10cSrcweir if ( aOID.isValid() && GetId() == aOID ) 678*cdf0e10cSrcweir { 679*cdf0e10cSrcweir AddState( AccessibleStateType::SELECTED ); 680*cdf0e10cSrcweir AddState( AccessibleStateType::FOCUSED ); 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir m_bStateSetInitialized = true; 684*cdf0e10cSrcweir } 685*cdf0e10cSrcweir 686*cdf0e10cSrcweir return m_aStateSet; 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir lang::Locale SAL_CALL AccessibleBase::getLocale() 691*cdf0e10cSrcweir throw (IllegalAccessibleComponentStateException, RuntimeException) 692*cdf0e10cSrcweir { 693*cdf0e10cSrcweir CheckDisposeState(); 694*cdf0e10cSrcweir 695*cdf0e10cSrcweir return Application::GetSettings().GetLocale(); 696*cdf0e10cSrcweir } 697*cdf0e10cSrcweir 698*cdf0e10cSrcweir // ________ AccessibleBase::XAccessibleComponent ________ 699*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleBase::containsPoint( const awt::Point& aPoint ) 700*cdf0e10cSrcweir throw (RuntimeException) 701*cdf0e10cSrcweir { 702*cdf0e10cSrcweir awt::Rectangle aRect( getBounds() ); 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir // contains() works with relative coordinates 705*cdf0e10cSrcweir aRect.X = 0; 706*cdf0e10cSrcweir aRect.Y = 0; 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir return ( aPoint.X >= aRect.X && 709*cdf0e10cSrcweir aPoint.Y >= aRect.Y && 710*cdf0e10cSrcweir aPoint.X < (aRect.X + aRect.Width) && 711*cdf0e10cSrcweir aPoint.Y < (aRect.Y + aRect.Height) ); 712*cdf0e10cSrcweir } 713*cdf0e10cSrcweir 714*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleAtPoint( const awt::Point& aPoint ) 715*cdf0e10cSrcweir throw (RuntimeException) 716*cdf0e10cSrcweir { 717*cdf0e10cSrcweir CheckDisposeState(); 718*cdf0e10cSrcweir Reference< XAccessible > aResult; 719*cdf0e10cSrcweir awt::Rectangle aRect( getBounds()); 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir // children are positioned relative to this object, so translate bound rect 722*cdf0e10cSrcweir aRect.X = 0; 723*cdf0e10cSrcweir aRect.Y = 0; 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir // children must be inside the own bound rect 726*cdf0e10cSrcweir if( ( aRect.X <= aPoint.X && aPoint.X <= (aRect.X + aRect.Width) ) && 727*cdf0e10cSrcweir ( aRect.Y <= aPoint.Y && aPoint.Y <= (aRect.Y + aRect.Height))) 728*cdf0e10cSrcweir { 729*cdf0e10cSrcweir // /-- 730*cdf0e10cSrcweir ClearableMutexGuard aGuard( GetMutex() ); 731*cdf0e10cSrcweir ChildListVectorType aLocalChildList( m_aChildList ); 732*cdf0e10cSrcweir aGuard.clear(); 733*cdf0e10cSrcweir // \-- 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir Reference< XAccessibleComponent > aComp; 736*cdf0e10cSrcweir for( ChildListVectorType::const_iterator aIter = aLocalChildList.begin(); 737*cdf0e10cSrcweir aIter != aLocalChildList.end(); ++aIter ) 738*cdf0e10cSrcweir { 739*cdf0e10cSrcweir aComp.set( *aIter, UNO_QUERY ); 740*cdf0e10cSrcweir if( aComp.is()) 741*cdf0e10cSrcweir { 742*cdf0e10cSrcweir aRect = aComp->getBounds(); 743*cdf0e10cSrcweir if( ( aRect.X <= aPoint.X && aPoint.X <= (aRect.X + aRect.Width) ) && 744*cdf0e10cSrcweir ( aRect.Y <= aPoint.Y && aPoint.Y <= (aRect.Y + aRect.Height))) 745*cdf0e10cSrcweir { 746*cdf0e10cSrcweir aResult = (*aIter); 747*cdf0e10cSrcweir break; 748*cdf0e10cSrcweir } 749*cdf0e10cSrcweir } 750*cdf0e10cSrcweir } 751*cdf0e10cSrcweir } 752*cdf0e10cSrcweir 753*cdf0e10cSrcweir return aResult; 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleBase::getBounds() 757*cdf0e10cSrcweir throw (RuntimeException) 758*cdf0e10cSrcweir { 759*cdf0e10cSrcweir ExplicitValueProvider *pExplicitValueProvider( 760*cdf0e10cSrcweir ExplicitValueProvider::getExplicitValueProvider( m_aAccInfo.m_xView )); 761*cdf0e10cSrcweir if( pExplicitValueProvider ) 762*cdf0e10cSrcweir { 763*cdf0e10cSrcweir Window* pWindow( VCLUnoHelper::GetWindow( m_aAccInfo.m_xWindow )); 764*cdf0e10cSrcweir awt::Rectangle aLogicRect( pExplicitValueProvider->getRectangleOfObject( m_aAccInfo.m_aOID.getObjectCID() )); 765*cdf0e10cSrcweir if( pWindow ) 766*cdf0e10cSrcweir { 767*cdf0e10cSrcweir Rectangle aRect( aLogicRect.X, aLogicRect.Y, 768*cdf0e10cSrcweir aLogicRect.X + aLogicRect.Width, 769*cdf0e10cSrcweir aLogicRect.Y + aLogicRect.Height ); 770*cdf0e10cSrcweir // /-- solar 771*cdf0e10cSrcweir ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 772*cdf0e10cSrcweir aRect = pWindow->LogicToPixel( aRect ); 773*cdf0e10cSrcweir 774*cdf0e10cSrcweir // aLogicRect ist relative to the page, but we need a value relative 775*cdf0e10cSrcweir // to the parent object 776*cdf0e10cSrcweir awt::Point aParentLocOnScreen; 777*cdf0e10cSrcweir uno::Reference< XAccessibleComponent > xParent( getAccessibleParent(), uno::UNO_QUERY ); 778*cdf0e10cSrcweir if( xParent.is() ) 779*cdf0e10cSrcweir aParentLocOnScreen = xParent->getLocationOnScreen(); 780*cdf0e10cSrcweir 781*cdf0e10cSrcweir // aOffset = aParentLocOnScreen - GetUpperLeftOnScreen() 782*cdf0e10cSrcweir awt::Point aULOnScreen = GetUpperLeftOnScreen(); 783*cdf0e10cSrcweir awt::Point aOffset( aParentLocOnScreen.X - aULOnScreen.X, 784*cdf0e10cSrcweir aParentLocOnScreen.Y - aULOnScreen.Y ); 785*cdf0e10cSrcweir 786*cdf0e10cSrcweir return awt::Rectangle( aRect.getX() - aOffset.X, aRect.getY() - aOffset.Y, 787*cdf0e10cSrcweir aRect.getWidth(), aRect.getHeight()); 788*cdf0e10cSrcweir // \-- solar 789*cdf0e10cSrcweir } 790*cdf0e10cSrcweir } 791*cdf0e10cSrcweir 792*cdf0e10cSrcweir return awt::Rectangle(); 793*cdf0e10cSrcweir } 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir awt::Point SAL_CALL AccessibleBase::getLocation() 796*cdf0e10cSrcweir throw (RuntimeException) 797*cdf0e10cSrcweir { 798*cdf0e10cSrcweir CheckDisposeState(); 799*cdf0e10cSrcweir awt::Rectangle aBBox( getBounds() ); 800*cdf0e10cSrcweir return awt::Point( aBBox.X, aBBox.Y ); 801*cdf0e10cSrcweir } 802*cdf0e10cSrcweir 803*cdf0e10cSrcweir awt::Point SAL_CALL AccessibleBase::getLocationOnScreen() 804*cdf0e10cSrcweir throw (RuntimeException) 805*cdf0e10cSrcweir { 806*cdf0e10cSrcweir CheckDisposeState(); 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir if( m_aAccInfo.m_pParent != NULL ) 809*cdf0e10cSrcweir { 810*cdf0e10cSrcweir AccessibleBase * pParent = m_aAccInfo.m_pParent; 811*cdf0e10cSrcweir awt::Point aLocThisRel( getLocation()); 812*cdf0e10cSrcweir awt::Point aUpperLeft; 813*cdf0e10cSrcweir 814*cdf0e10cSrcweir if( pParent != NULL ) 815*cdf0e10cSrcweir aUpperLeft = pParent->getLocationOnScreen(); 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir return awt::Point( aUpperLeft.X + aLocThisRel.X, 818*cdf0e10cSrcweir aUpperLeft.Y + aLocThisRel.Y ); 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir else 821*cdf0e10cSrcweir return getLocation(); 822*cdf0e10cSrcweir } 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir awt::Size SAL_CALL AccessibleBase::getSize() 825*cdf0e10cSrcweir throw (RuntimeException) 826*cdf0e10cSrcweir { 827*cdf0e10cSrcweir CheckDisposeState(); 828*cdf0e10cSrcweir awt::Rectangle aBBox( getBounds() ); 829*cdf0e10cSrcweir return awt::Size( aBBox.Width, aBBox.Height ); 830*cdf0e10cSrcweir } 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir void SAL_CALL AccessibleBase::grabFocus() 833*cdf0e10cSrcweir throw (RuntimeException) 834*cdf0e10cSrcweir { 835*cdf0e10cSrcweir CheckDisposeState(); 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier ); 838*cdf0e10cSrcweir if ( xSelSupp.is() ) 839*cdf0e10cSrcweir { 840*cdf0e10cSrcweir xSelSupp->select( GetId().getAny() ); 841*cdf0e10cSrcweir } 842*cdf0e10cSrcweir } 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleBase::getForeground() 845*cdf0e10cSrcweir throw (RuntimeException) 846*cdf0e10cSrcweir { 847*cdf0e10cSrcweir return getColor( ACC_BASE_FOREGROUND ); 848*cdf0e10cSrcweir } 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleBase::getBackground() 851*cdf0e10cSrcweir throw (RuntimeException) 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir return getColor( ACC_BASE_BACKGROUND ); 854*cdf0e10cSrcweir } 855*cdf0e10cSrcweir 856*cdf0e10cSrcweir sal_Int32 AccessibleBase::getColor( eColorType eColType ) 857*cdf0e10cSrcweir { 858*cdf0e10cSrcweir sal_Int32 nResult = static_cast< sal_Int32 >( Color( COL_TRANSPARENT ).GetColor()); 859*cdf0e10cSrcweir if( m_bAlwaysTransparent ) 860*cdf0e10cSrcweir return nResult; 861*cdf0e10cSrcweir 862*cdf0e10cSrcweir ObjectIdentifier aOID( m_aAccInfo.m_aOID ); 863*cdf0e10cSrcweir ObjectType eType( aOID.getObjectType() ); 864*cdf0e10cSrcweir Reference< beans::XPropertySet > xObjProp; 865*cdf0e10cSrcweir OUString aObjectCID = aOID.getObjectCID(); 866*cdf0e10cSrcweir if( eType == OBJECTTYPE_LEGEND_ENTRY ) 867*cdf0e10cSrcweir { 868*cdf0e10cSrcweir // for colors get the data series/point properties 869*cdf0e10cSrcweir OUString aParentParticle( ObjectIdentifier::getFullParentParticle( aObjectCID )); 870*cdf0e10cSrcweir aObjectCID = ObjectIdentifier::createClassifiedIdentifierForParticle( aParentParticle ); 871*cdf0e10cSrcweir } 872*cdf0e10cSrcweir 873*cdf0e10cSrcweir xObjProp.set( 874*cdf0e10cSrcweir ObjectIdentifier::getObjectPropertySet( 875*cdf0e10cSrcweir aObjectCID, Reference< chart2::XChartDocument >( m_aAccInfo.m_xChartDocument )), uno::UNO_QUERY ); 876*cdf0e10cSrcweir if( xObjProp.is()) 877*cdf0e10cSrcweir { 878*cdf0e10cSrcweir try 879*cdf0e10cSrcweir { 880*cdf0e10cSrcweir OUString aPropName; 881*cdf0e10cSrcweir OUString aStylePropName; 882*cdf0e10cSrcweir 883*cdf0e10cSrcweir switch( eType ) 884*cdf0e10cSrcweir { 885*cdf0e10cSrcweir case OBJECTTYPE_LEGEND_ENTRY: 886*cdf0e10cSrcweir case OBJECTTYPE_DATA_SERIES: 887*cdf0e10cSrcweir case OBJECTTYPE_DATA_POINT: 888*cdf0e10cSrcweir if( eColType == ACC_BASE_FOREGROUND ) 889*cdf0e10cSrcweir { 890*cdf0e10cSrcweir aPropName = C2U("BorderColor"); 891*cdf0e10cSrcweir aStylePropName = C2U("BorderTransparency"); 892*cdf0e10cSrcweir } 893*cdf0e10cSrcweir else 894*cdf0e10cSrcweir { 895*cdf0e10cSrcweir aPropName = C2U("Color"); 896*cdf0e10cSrcweir aStylePropName = C2U("Transparency"); 897*cdf0e10cSrcweir } 898*cdf0e10cSrcweir break; 899*cdf0e10cSrcweir default: 900*cdf0e10cSrcweir if( eColType == ACC_BASE_FOREGROUND ) 901*cdf0e10cSrcweir { 902*cdf0e10cSrcweir aPropName = C2U("LineColor"); 903*cdf0e10cSrcweir aStylePropName = C2U("LineTransparence"); 904*cdf0e10cSrcweir } 905*cdf0e10cSrcweir else 906*cdf0e10cSrcweir { 907*cdf0e10cSrcweir aPropName = C2U("FillColor"); 908*cdf0e10cSrcweir aStylePropName = C2U("FillTransparence"); 909*cdf0e10cSrcweir } 910*cdf0e10cSrcweir break; 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir 913*cdf0e10cSrcweir bool bTransparent = m_bAlwaysTransparent; 914*cdf0e10cSrcweir Reference< beans::XPropertySetInfo > xInfo( xObjProp->getPropertySetInfo(), uno::UNO_QUERY ); 915*cdf0e10cSrcweir if( xInfo.is() && 916*cdf0e10cSrcweir xInfo->hasPropertyByName( aStylePropName )) 917*cdf0e10cSrcweir { 918*cdf0e10cSrcweir if( eColType == ACC_BASE_FOREGROUND ) 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir drawing::LineStyle aLStyle; 921*cdf0e10cSrcweir if( xObjProp->getPropertyValue( aStylePropName ) >>= aLStyle ) 922*cdf0e10cSrcweir bTransparent = (aLStyle == drawing::LineStyle_NONE); 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir else 925*cdf0e10cSrcweir { 926*cdf0e10cSrcweir drawing::FillStyle aFStyle; 927*cdf0e10cSrcweir if( xObjProp->getPropertyValue( aStylePropName ) >>= aFStyle ) 928*cdf0e10cSrcweir bTransparent = (aFStyle == drawing::FillStyle_NONE); 929*cdf0e10cSrcweir } 930*cdf0e10cSrcweir } 931*cdf0e10cSrcweir 932*cdf0e10cSrcweir if( !bTransparent && 933*cdf0e10cSrcweir xInfo.is() && 934*cdf0e10cSrcweir xInfo->hasPropertyByName( aPropName )) 935*cdf0e10cSrcweir { 936*cdf0e10cSrcweir xObjProp->getPropertyValue( aPropName ) >>= nResult; 937*cdf0e10cSrcweir } 938*cdf0e10cSrcweir } 939*cdf0e10cSrcweir catch( const uno::Exception & ex ) 940*cdf0e10cSrcweir { 941*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 942*cdf0e10cSrcweir } 943*cdf0e10cSrcweir } 944*cdf0e10cSrcweir 945*cdf0e10cSrcweir return nResult; 946*cdf0e10cSrcweir } 947*cdf0e10cSrcweir 948*cdf0e10cSrcweir // ________ AccessibleBase::XServiceInfo ________ 949*cdf0e10cSrcweir OUString SAL_CALL AccessibleBase::getImplementationName() 950*cdf0e10cSrcweir throw (RuntimeException) 951*cdf0e10cSrcweir { 952*cdf0e10cSrcweir return OUString( RTL_CONSTASCII_USTRINGPARAM( "AccessibleBase" )); 953*cdf0e10cSrcweir } 954*cdf0e10cSrcweir 955*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleBase::supportsService( const OUString& ServiceName ) 956*cdf0e10cSrcweir throw (RuntimeException) 957*cdf0e10cSrcweir { 958*cdf0e10cSrcweir return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); 959*cdf0e10cSrcweir } 960*cdf0e10cSrcweir 961*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL AccessibleBase::getSupportedServiceNames() 962*cdf0e10cSrcweir throw (RuntimeException) 963*cdf0e10cSrcweir { 964*cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSeq( 2 ); 965*cdf0e10cSrcweir ::rtl::OUString* pStr = aSeq.getArray(); 966*cdf0e10cSrcweir pStr[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.Accessible" )); 967*cdf0e10cSrcweir pStr[ 1 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" )); 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir return aSeq; 970*cdf0e10cSrcweir } 971*cdf0e10cSrcweir 972*cdf0e10cSrcweir // ________ AccessibleBase::XEventListener ________ 973*cdf0e10cSrcweir void SAL_CALL AccessibleBase::disposing( const lang::EventObject& /*Source*/ ) 974*cdf0e10cSrcweir throw (RuntimeException) 975*cdf0e10cSrcweir { 976*cdf0e10cSrcweir } 977*cdf0e10cSrcweir 978*cdf0e10cSrcweir // ________ XAccessibleEventBroadcasters ________ 979*cdf0e10cSrcweir void SAL_CALL AccessibleBase::addEventListener( const Reference< XAccessibleEventListener >& xListener ) 980*cdf0e10cSrcweir throw (RuntimeException) 981*cdf0e10cSrcweir { 982*cdf0e10cSrcweir MutexGuard aGuard( GetMutex() ); 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir if ( xListener.is() ) 985*cdf0e10cSrcweir { 986*cdf0e10cSrcweir if ( !m_nEventNotifierId ) 987*cdf0e10cSrcweir m_nEventNotifierId = ::comphelper::AccessibleEventNotifier::registerClient(); 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::addEventListener( m_nEventNotifierId, xListener ); 990*cdf0e10cSrcweir } 991*cdf0e10cSrcweir } 992*cdf0e10cSrcweir 993*cdf0e10cSrcweir void SAL_CALL AccessibleBase::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) 994*cdf0e10cSrcweir throw (RuntimeException) 995*cdf0e10cSrcweir { 996*cdf0e10cSrcweir MutexGuard aGuard( GetMutex() ); 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir if ( xListener.is() ) 999*cdf0e10cSrcweir { 1000*cdf0e10cSrcweir sal_Int32 nListenerCount = ::comphelper::AccessibleEventNotifier::removeEventListener( m_nEventNotifierId, xListener ); 1001*cdf0e10cSrcweir if ( !nListenerCount ) 1002*cdf0e10cSrcweir { 1003*cdf0e10cSrcweir // no listeners anymore 1004*cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::revokeClient( m_nEventNotifierId ); 1005*cdf0e10cSrcweir m_nEventNotifierId = 0; 1006*cdf0e10cSrcweir } 1007*cdf0e10cSrcweir } 1008*cdf0e10cSrcweir } 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir } // namespace chart 1011