1*2bfcd321SSteve Yin /************************************************************************* 2*2bfcd321SSteve Yin * 3*2bfcd321SSteve Yin * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*2bfcd321SSteve Yin * 5*2bfcd321SSteve Yin * Copyright IBM Corporation 2010. 6*2bfcd321SSteve Yin * Copyright 2000, 2010 Oracle and/or its affiliates. 7*2bfcd321SSteve Yin * 8*2bfcd321SSteve Yin * OpenOffice.org - a multi-platform office productivity suite 9*2bfcd321SSteve Yin * 10*2bfcd321SSteve Yin * This file is part of OpenOffice.org. 11*2bfcd321SSteve Yin * 12*2bfcd321SSteve Yin * OpenOffice.org is free software: you can redistribute it and/or modify 13*2bfcd321SSteve Yin * it under the terms of the GNU Lesser General Public License version 3 14*2bfcd321SSteve Yin * only, as published by the Free Software Foundation. 15*2bfcd321SSteve Yin * 16*2bfcd321SSteve Yin * OpenOffice.org is distributed in the hope that it will be useful, 17*2bfcd321SSteve Yin * but WITHOUT ANY WARRANTY; without even the implied warranty of 18*2bfcd321SSteve Yin * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19*2bfcd321SSteve Yin * GNU Lesser General Public License version 3 for more details 20*2bfcd321SSteve Yin * (a copy is included in the LICENSE file that accompanied this code). 21*2bfcd321SSteve Yin * 22*2bfcd321SSteve Yin * You should have received a copy of the GNU Lesser General Public License 23*2bfcd321SSteve Yin * version 3 along with OpenOffice.org. If not, see 24*2bfcd321SSteve Yin * <http://www.openoffice.org/license.html> 25*2bfcd321SSteve Yin * for a copy of the LGPLv3 License. 26*2bfcd321SSteve Yin * 27*2bfcd321SSteve Yin ************************************************************************/ 28*2bfcd321SSteve Yin 29*2bfcd321SSteve Yin // MARKER(update_precomp.py): autogen include statement, do not remove 30*2bfcd321SSteve Yin #include "precompiled_svtools.hxx" 31*2bfcd321SSteve Yin 32*2bfcd321SSteve Yin //add by duan mei hua, 2006/09/04, for issue 174 33*2bfcd321SSteve Yin #ifndef _SVTRULERACCESSIBLE_HXX 34*2bfcd321SSteve Yin #include <svtools/accessibleruler.hxx> 35*2bfcd321SSteve Yin #endif 36*2bfcd321SSteve Yin //end add by duan mei hua, 2006/09/04, for issue 174 37*2bfcd321SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_ 38*2bfcd321SSteve Yin #include <com/sun/star/accessibility/AccessibleRole.hpp> 39*2bfcd321SSteve Yin #endif 40*2bfcd321SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_ 41*2bfcd321SSteve Yin #include <com/sun/star/accessibility/AccessibleEventId.hpp> 42*2bfcd321SSteve Yin #endif 43*2bfcd321SSteve Yin #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_ 44*2bfcd321SSteve Yin #include <unotools/accessiblestatesethelper.hxx> 45*2bfcd321SSteve Yin #endif 46*2bfcd321SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_ 47*2bfcd321SSteve Yin #include <com/sun/star/accessibility/AccessibleStateType.hpp> 48*2bfcd321SSteve Yin #endif 49*2bfcd321SSteve Yin 50*2bfcd321SSteve Yin #ifndef _COM_SUN_STAR_BEANS_PROPERTYCHANGEEVENT_HPP_ 51*2bfcd321SSteve Yin #include <com/sun/star/beans/PropertyChangeEvent.hpp> 52*2bfcd321SSteve Yin #endif 53*2bfcd321SSteve Yin 54*2bfcd321SSteve Yin #ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_ 55*2bfcd321SSteve Yin #include <com/sun/star/awt/XWindow.hpp> 56*2bfcd321SSteve Yin #endif 57*2bfcd321SSteve Yin 58*2bfcd321SSteve Yin #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ 59*2bfcd321SSteve Yin #include <cppuhelper/typeprovider.hxx> 60*2bfcd321SSteve Yin #endif 61*2bfcd321SSteve Yin 62*2bfcd321SSteve Yin #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 63*2bfcd321SSteve Yin #include <toolkit/helper/vclunohelper.hxx> 64*2bfcd321SSteve Yin #endif 65*2bfcd321SSteve Yin #ifndef _TOOLKIT_HELPER_CONVERT_HXX_ 66*2bfcd321SSteve Yin #include <toolkit/helper/convert.hxx> 67*2bfcd321SSteve Yin #endif 68*2bfcd321SSteve Yin 69*2bfcd321SSteve Yin #ifndef _SV_SVAPP_HXX 70*2bfcd321SSteve Yin #include <vcl/svapp.hxx> 71*2bfcd321SSteve Yin #endif 72*2bfcd321SSteve Yin 73*2bfcd321SSteve Yin #ifndef _OSL_MUTEX_HXX_ 74*2bfcd321SSteve Yin #include <osl/mutex.hxx> 75*2bfcd321SSteve Yin #endif 76*2bfcd321SSteve Yin #ifndef _RTL_UUID_H_ 77*2bfcd321SSteve Yin #include <rtl/uuid.h> 78*2bfcd321SSteve Yin #endif 79*2bfcd321SSteve Yin #ifndef _TOOLS_DEBUG_HXX 80*2bfcd321SSteve Yin #include <tools/debug.hxx> 81*2bfcd321SSteve Yin #endif 82*2bfcd321SSteve Yin #ifndef _SV_GEN_HXX 83*2bfcd321SSteve Yin #include <tools/gen.hxx> 84*2bfcd321SSteve Yin #endif 85*2bfcd321SSteve Yin 86*2bfcd321SSteve Yin #include "ruler.hxx" 87*2bfcd321SSteve Yin 88*2bfcd321SSteve Yin #ifndef COMPHELPER_ACCESSIBLE_EVENT_NOTIFIER 89*2bfcd321SSteve Yin #include <comphelper/accessibleeventnotifier.hxx> 90*2bfcd321SSteve Yin #endif 91*2bfcd321SSteve Yin 92*2bfcd321SSteve Yin using namespace ::cppu; 93*2bfcd321SSteve Yin using namespace ::osl; 94*2bfcd321SSteve Yin using namespace ::rtl; 95*2bfcd321SSteve Yin using namespace ::com::sun::star; 96*2bfcd321SSteve Yin using namespace ::com::sun::star::uno; 97*2bfcd321SSteve Yin using namespace ::com::sun::star::accessibility; 98*2bfcd321SSteve Yin 99*2bfcd321SSteve Yin DBG_NAME( SvtRulerAccessible ) 100*2bfcd321SSteve Yin 101*2bfcd321SSteve Yin 102*2bfcd321SSteve Yin //===== internal ============================================================ 103*2bfcd321SSteve Yin 104*2bfcd321SSteve Yin SvtRulerAccessible::SvtRulerAccessible( 105*2bfcd321SSteve Yin const uno::Reference< XAccessible >& rxParent, Ruler& rRepr, const OUString& rName ) : 106*2bfcd321SSteve Yin 107*2bfcd321SSteve Yin SvtRulerAccessible_Base( m_aMutex ), 108*2bfcd321SSteve Yin msName( rName ), 109*2bfcd321SSteve Yin mxParent( rxParent ), 110*2bfcd321SSteve Yin mpRepr( &rRepr ), 111*2bfcd321SSteve Yin mnClientId( 0 ) 112*2bfcd321SSteve Yin { 113*2bfcd321SSteve Yin DBG_CTOR( SvtRulerAccessible, NULL ); 114*2bfcd321SSteve Yin } 115*2bfcd321SSteve Yin 116*2bfcd321SSteve Yin SvtRulerAccessible::~SvtRulerAccessible() 117*2bfcd321SSteve Yin { 118*2bfcd321SSteve Yin DBG_DTOR( SvtRulerAccessible, NULL ); 119*2bfcd321SSteve Yin 120*2bfcd321SSteve Yin if( IsAlive() ) 121*2bfcd321SSteve Yin { 122*2bfcd321SSteve Yin osl_incrementInterlockedCount( &m_refCount ); 123*2bfcd321SSteve Yin dispose(); // set mpRepr = NULL & release all childs 124*2bfcd321SSteve Yin } 125*2bfcd321SSteve Yin } 126*2bfcd321SSteve Yin 127*2bfcd321SSteve Yin //===== XAccessible ========================================================= 128*2bfcd321SSteve Yin 129*2bfcd321SSteve Yin uno::Reference< XAccessibleContext > SAL_CALL SvtRulerAccessible::getAccessibleContext( void ) throw( RuntimeException ) 130*2bfcd321SSteve Yin { 131*2bfcd321SSteve Yin return this; 132*2bfcd321SSteve Yin } 133*2bfcd321SSteve Yin 134*2bfcd321SSteve Yin //===== XAccessibleComponent ================================================ 135*2bfcd321SSteve Yin 136*2bfcd321SSteve Yin sal_Bool SAL_CALL SvtRulerAccessible::containsPoint( const awt::Point& rPoint ) throw( RuntimeException ) 137*2bfcd321SSteve Yin { 138*2bfcd321SSteve Yin // no guard -> done in getBounds() 139*2bfcd321SSteve Yin // return GetBoundingBox().IsInside( VCLPoint( rPoint ) ); 140*2bfcd321SSteve Yin return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) ); 141*2bfcd321SSteve Yin } 142*2bfcd321SSteve Yin 143*2bfcd321SSteve Yin uno::Reference< XAccessible > SAL_CALL SvtRulerAccessible::getAccessibleAtPoint( const awt::Point& ) throw( RuntimeException ) 144*2bfcd321SSteve Yin { 145*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 146*2bfcd321SSteve Yin 147*2bfcd321SSteve Yin ThrowExceptionIfNotAlive(); 148*2bfcd321SSteve Yin 149*2bfcd321SSteve Yin uno::Reference< XAccessible > xRet; 150*2bfcd321SSteve Yin 151*2bfcd321SSteve Yin 152*2bfcd321SSteve Yin return xRet; 153*2bfcd321SSteve Yin } 154*2bfcd321SSteve Yin 155*2bfcd321SSteve Yin awt::Rectangle SAL_CALL SvtRulerAccessible::getBounds() throw( RuntimeException ) 156*2bfcd321SSteve Yin { 157*2bfcd321SSteve Yin // no guard -> done in GetBoundingBox() 158*2bfcd321SSteve Yin return AWTRectangle( GetBoundingBox() ); 159*2bfcd321SSteve Yin } 160*2bfcd321SSteve Yin 161*2bfcd321SSteve Yin awt::Point SAL_CALL SvtRulerAccessible::getLocation() throw( RuntimeException ) 162*2bfcd321SSteve Yin { 163*2bfcd321SSteve Yin // no guard -> done in GetBoundingBox() 164*2bfcd321SSteve Yin return AWTPoint( GetBoundingBox().TopLeft() ); 165*2bfcd321SSteve Yin } 166*2bfcd321SSteve Yin 167*2bfcd321SSteve Yin awt::Point SAL_CALL SvtRulerAccessible::getLocationOnScreen() throw( RuntimeException ) 168*2bfcd321SSteve Yin { 169*2bfcd321SSteve Yin // no guard -> done in GetBoundingBoxOnScreen() 170*2bfcd321SSteve Yin return AWTPoint( GetBoundingBoxOnScreen().TopLeft() ); 171*2bfcd321SSteve Yin } 172*2bfcd321SSteve Yin 173*2bfcd321SSteve Yin awt::Size SAL_CALL SvtRulerAccessible::getSize() throw( RuntimeException ) 174*2bfcd321SSteve Yin { 175*2bfcd321SSteve Yin // no guard -> done in GetBoundingBox() 176*2bfcd321SSteve Yin return AWTSize( GetBoundingBox().GetSize() ); 177*2bfcd321SSteve Yin } 178*2bfcd321SSteve Yin 179*2bfcd321SSteve Yin sal_Bool SAL_CALL SvtRulerAccessible::isShowing() throw( RuntimeException ) 180*2bfcd321SSteve Yin { 181*2bfcd321SSteve Yin return sal_True; 182*2bfcd321SSteve Yin } 183*2bfcd321SSteve Yin 184*2bfcd321SSteve Yin sal_Bool SAL_CALL SvtRulerAccessible::isVisible() throw( RuntimeException ) 185*2bfcd321SSteve Yin { 186*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 187*2bfcd321SSteve Yin 188*2bfcd321SSteve Yin ThrowExceptionIfNotAlive(); 189*2bfcd321SSteve Yin 190*2bfcd321SSteve Yin return mpRepr->IsVisible(); 191*2bfcd321SSteve Yin } 192*2bfcd321SSteve Yin 193*2bfcd321SSteve Yin sal_Bool SAL_CALL SvtRulerAccessible::isFocusTraversable() throw( RuntimeException ) 194*2bfcd321SSteve Yin { 195*2bfcd321SSteve Yin return sal_True; 196*2bfcd321SSteve Yin } 197*2bfcd321SSteve Yin 198*2bfcd321SSteve Yin //===== XAccessibleContext ================================================== 199*2bfcd321SSteve Yin 200*2bfcd321SSteve Yin sal_Int32 SAL_CALL SvtRulerAccessible::getAccessibleChildCount( void ) throw( RuntimeException ) 201*2bfcd321SSteve Yin { 202*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 203*2bfcd321SSteve Yin 204*2bfcd321SSteve Yin ThrowExceptionIfNotAlive(); 205*2bfcd321SSteve Yin 206*2bfcd321SSteve Yin return 0; 207*2bfcd321SSteve Yin } 208*2bfcd321SSteve Yin 209*2bfcd321SSteve Yin uno::Reference< XAccessible > SAL_CALL SvtRulerAccessible::getAccessibleChild( sal_Int32 ) 210*2bfcd321SSteve Yin throw( RuntimeException, lang::IndexOutOfBoundsException ) 211*2bfcd321SSteve Yin { 212*2bfcd321SSteve Yin uno::Reference< XAccessible > xChild ; 213*2bfcd321SSteve Yin 214*2bfcd321SSteve Yin return xChild; 215*2bfcd321SSteve Yin } 216*2bfcd321SSteve Yin 217*2bfcd321SSteve Yin uno::Reference< XAccessible > SAL_CALL SvtRulerAccessible::getAccessibleParent( void ) throw( RuntimeException ) 218*2bfcd321SSteve Yin { 219*2bfcd321SSteve Yin return mxParent; 220*2bfcd321SSteve Yin } 221*2bfcd321SSteve Yin 222*2bfcd321SSteve Yin sal_Int32 SAL_CALL SvtRulerAccessible::getAccessibleIndexInParent( void ) throw( RuntimeException ) 223*2bfcd321SSteve Yin { 224*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 225*2bfcd321SSteve Yin // Use a simple but slow solution for now. Optimize later. 226*2bfcd321SSteve Yin 227*2bfcd321SSteve Yin // Iterate over all the parent's children and search for this object. 228*2bfcd321SSteve Yin if( mxParent.is() ) 229*2bfcd321SSteve Yin { 230*2bfcd321SSteve Yin uno::Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() ); 231*2bfcd321SSteve Yin if( xParentContext.is() ) 232*2bfcd321SSteve Yin { 233*2bfcd321SSteve Yin sal_Int32 nChildCount = xParentContext->getAccessibleChildCount(); 234*2bfcd321SSteve Yin for( sal_Int32 i = 0 ; i < nChildCount ; ++i ) 235*2bfcd321SSteve Yin { 236*2bfcd321SSteve Yin uno::Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) ); 237*2bfcd321SSteve Yin if( xChild.get() == ( XAccessible* ) this ) 238*2bfcd321SSteve Yin return i; 239*2bfcd321SSteve Yin } 240*2bfcd321SSteve Yin } 241*2bfcd321SSteve Yin } 242*2bfcd321SSteve Yin 243*2bfcd321SSteve Yin // Return -1 to indicate that this object's parent does not know about the 244*2bfcd321SSteve Yin // object. 245*2bfcd321SSteve Yin return -1; 246*2bfcd321SSteve Yin } 247*2bfcd321SSteve Yin 248*2bfcd321SSteve Yin sal_Int16 SAL_CALL SvtRulerAccessible::getAccessibleRole( void ) throw( RuntimeException ) 249*2bfcd321SSteve Yin { 250*2bfcd321SSteve Yin return AccessibleRole::RULER; 251*2bfcd321SSteve Yin } 252*2bfcd321SSteve Yin 253*2bfcd321SSteve Yin OUString SAL_CALL SvtRulerAccessible::getAccessibleDescription( void ) throw( RuntimeException ) 254*2bfcd321SSteve Yin { 255*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 256*2bfcd321SSteve Yin return msDescription; 257*2bfcd321SSteve Yin } 258*2bfcd321SSteve Yin 259*2bfcd321SSteve Yin OUString SAL_CALL SvtRulerAccessible::getAccessibleName( void ) throw( RuntimeException ) 260*2bfcd321SSteve Yin { 261*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 262*2bfcd321SSteve Yin return msName; 263*2bfcd321SSteve Yin } 264*2bfcd321SSteve Yin 265*2bfcd321SSteve Yin /** Return empty uno::Reference to indicate that the relation set is not 266*2bfcd321SSteve Yin supported. 267*2bfcd321SSteve Yin */ 268*2bfcd321SSteve Yin uno::Reference< XAccessibleRelationSet > SAL_CALL SvtRulerAccessible::getAccessibleRelationSet( void ) throw( RuntimeException ) 269*2bfcd321SSteve Yin { 270*2bfcd321SSteve Yin return uno::Reference< XAccessibleRelationSet >(); 271*2bfcd321SSteve Yin } 272*2bfcd321SSteve Yin 273*2bfcd321SSteve Yin 274*2bfcd321SSteve Yin uno::Reference< XAccessibleStateSet > SAL_CALL SvtRulerAccessible::getAccessibleStateSet( void ) throw( RuntimeException ) 275*2bfcd321SSteve Yin { 276*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 277*2bfcd321SSteve Yin utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; 278*2bfcd321SSteve Yin 279*2bfcd321SSteve Yin if( IsAlive() ) 280*2bfcd321SSteve Yin { 281*2bfcd321SSteve Yin pStateSetHelper->AddState( AccessibleStateType::ENABLED ); 282*2bfcd321SSteve Yin 283*2bfcd321SSteve Yin if( isShowing() ) 284*2bfcd321SSteve Yin pStateSetHelper->AddState( AccessibleStateType::SHOWING ); 285*2bfcd321SSteve Yin 286*2bfcd321SSteve Yin if( isVisible() ) 287*2bfcd321SSteve Yin pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); 288*2bfcd321SSteve Yin 289*2bfcd321SSteve Yin 290*2bfcd321SSteve Yin if ( mpRepr ) 291*2bfcd321SSteve Yin { 292*2bfcd321SSteve Yin if ( mpRepr->GetStyle() & WB_HORZ ) 293*2bfcd321SSteve Yin pStateSetHelper->AddState( AccessibleStateType::HORIZONTAL ); 294*2bfcd321SSteve Yin else 295*2bfcd321SSteve Yin pStateSetHelper->AddState( AccessibleStateType::VERTICAL ); 296*2bfcd321SSteve Yin } 297*2bfcd321SSteve Yin if(pStateSetHelper->contains(AccessibleStateType::FOCUSABLE)) 298*2bfcd321SSteve Yin { 299*2bfcd321SSteve Yin pStateSetHelper->RemoveState( AccessibleStateType::FOCUSABLE ); 300*2bfcd321SSteve Yin } 301*2bfcd321SSteve Yin 302*2bfcd321SSteve Yin } 303*2bfcd321SSteve Yin 304*2bfcd321SSteve Yin 305*2bfcd321SSteve Yin return pStateSetHelper; 306*2bfcd321SSteve Yin } 307*2bfcd321SSteve Yin 308*2bfcd321SSteve Yin lang::Locale SAL_CALL SvtRulerAccessible::getLocale( void ) throw( IllegalAccessibleComponentStateException, RuntimeException ) 309*2bfcd321SSteve Yin { 310*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 311*2bfcd321SSteve Yin if( mxParent.is() ) 312*2bfcd321SSteve Yin { 313*2bfcd321SSteve Yin uno::Reference< XAccessibleContext > xParentContext( mxParent->getAccessibleContext() ); 314*2bfcd321SSteve Yin if( xParentContext.is() ) 315*2bfcd321SSteve Yin return xParentContext->getLocale(); 316*2bfcd321SSteve Yin } 317*2bfcd321SSteve Yin 318*2bfcd321SSteve Yin // No parent. Therefore throw exception to indicate this cluelessness. 319*2bfcd321SSteve Yin throw IllegalAccessibleComponentStateException(); 320*2bfcd321SSteve Yin } 321*2bfcd321SSteve Yin 322*2bfcd321SSteve Yin void SAL_CALL SvtRulerAccessible::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) 323*2bfcd321SSteve Yin throw( RuntimeException ) 324*2bfcd321SSteve Yin { 325*2bfcd321SSteve Yin if (xListener.is()) 326*2bfcd321SSteve Yin { 327*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 328*2bfcd321SSteve Yin if (!mnClientId) 329*2bfcd321SSteve Yin mnClientId = comphelper::AccessibleEventNotifier::registerClient( ); 330*2bfcd321SSteve Yin comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener ); 331*2bfcd321SSteve Yin } 332*2bfcd321SSteve Yin } 333*2bfcd321SSteve Yin 334*2bfcd321SSteve Yin void SAL_CALL SvtRulerAccessible::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) 335*2bfcd321SSteve Yin throw( RuntimeException ) 336*2bfcd321SSteve Yin { 337*2bfcd321SSteve Yin if (xListener.is()) 338*2bfcd321SSteve Yin { 339*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 340*2bfcd321SSteve Yin 341*2bfcd321SSteve Yin sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ); 342*2bfcd321SSteve Yin if ( !nListenerCount ) 343*2bfcd321SSteve Yin { 344*2bfcd321SSteve Yin // no listeners anymore 345*2bfcd321SSteve Yin // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), 346*2bfcd321SSteve Yin // and at least to us not firing any events anymore, in case somebody calls 347*2bfcd321SSteve Yin // NotifyAccessibleEvent, again 348*2bfcd321SSteve Yin comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); 349*2bfcd321SSteve Yin mnClientId = 0; 350*2bfcd321SSteve Yin } 351*2bfcd321SSteve Yin } 352*2bfcd321SSteve Yin } 353*2bfcd321SSteve Yin 354*2bfcd321SSteve Yin void SAL_CALL SvtRulerAccessible::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) 355*2bfcd321SSteve Yin throw( RuntimeException ) 356*2bfcd321SSteve Yin { 357*2bfcd321SSteve Yin if( xListener.is() ) 358*2bfcd321SSteve Yin { 359*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 360*2bfcd321SSteve Yin 361*2bfcd321SSteve Yin ThrowExceptionIfNotAlive(); 362*2bfcd321SSteve Yin 363*2bfcd321SSteve Yin uno::Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( mpRepr ); 364*2bfcd321SSteve Yin if( xWindow.is() ) 365*2bfcd321SSteve Yin xWindow->addFocusListener( xListener ); 366*2bfcd321SSteve Yin } 367*2bfcd321SSteve Yin } 368*2bfcd321SSteve Yin 369*2bfcd321SSteve Yin void SAL_CALL SvtRulerAccessible::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) 370*2bfcd321SSteve Yin throw (RuntimeException) 371*2bfcd321SSteve Yin { 372*2bfcd321SSteve Yin if( xListener.is() ) 373*2bfcd321SSteve Yin { 374*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 375*2bfcd321SSteve Yin 376*2bfcd321SSteve Yin ThrowExceptionIfNotAlive(); 377*2bfcd321SSteve Yin 378*2bfcd321SSteve Yin uno::Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( mpRepr ); 379*2bfcd321SSteve Yin if( xWindow.is() ) 380*2bfcd321SSteve Yin xWindow->removeFocusListener( xListener ); 381*2bfcd321SSteve Yin } 382*2bfcd321SSteve Yin } 383*2bfcd321SSteve Yin 384*2bfcd321SSteve Yin void SAL_CALL SvtRulerAccessible::grabFocus() throw( RuntimeException ) 385*2bfcd321SSteve Yin { 386*2bfcd321SSteve Yin ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 387*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 388*2bfcd321SSteve Yin 389*2bfcd321SSteve Yin ThrowExceptionIfNotAlive(); 390*2bfcd321SSteve Yin 391*2bfcd321SSteve Yin mpRepr->GrabFocus(); 392*2bfcd321SSteve Yin } 393*2bfcd321SSteve Yin 394*2bfcd321SSteve Yin Any SAL_CALL SvtRulerAccessible::getAccessibleKeyBinding() throw( RuntimeException ) 395*2bfcd321SSteve Yin { 396*2bfcd321SSteve Yin // here is no implementation, because here are no KeyBindings for every object 397*2bfcd321SSteve Yin return Any(); 398*2bfcd321SSteve Yin } 399*2bfcd321SSteve Yin 400*2bfcd321SSteve Yin sal_Int32 SvtRulerAccessible::getForeground( ) 401*2bfcd321SSteve Yin throw (::com::sun::star::uno::RuntimeException) 402*2bfcd321SSteve Yin { 403*2bfcd321SSteve Yin ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 404*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 405*2bfcd321SSteve Yin ThrowExceptionIfNotAlive(); 406*2bfcd321SSteve Yin 407*2bfcd321SSteve Yin return mpRepr->GetControlForeground().GetColor(); 408*2bfcd321SSteve Yin } 409*2bfcd321SSteve Yin sal_Int32 SvtRulerAccessible::getBackground( ) 410*2bfcd321SSteve Yin throw (::com::sun::star::uno::RuntimeException) 411*2bfcd321SSteve Yin { 412*2bfcd321SSteve Yin ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 413*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 414*2bfcd321SSteve Yin ThrowExceptionIfNotAlive(); 415*2bfcd321SSteve Yin 416*2bfcd321SSteve Yin return mpRepr->GetControlBackground().GetColor(); 417*2bfcd321SSteve Yin } 418*2bfcd321SSteve Yin 419*2bfcd321SSteve Yin //===== XServiceInfo ======================================================== 420*2bfcd321SSteve Yin 421*2bfcd321SSteve Yin OUString SAL_CALL SvtRulerAccessible::getImplementationName( void ) throw( RuntimeException ) 422*2bfcd321SSteve Yin { 423*2bfcd321SSteve Yin return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ui.SvtRulerAccessible" ) ); 424*2bfcd321SSteve Yin } 425*2bfcd321SSteve Yin 426*2bfcd321SSteve Yin sal_Bool SAL_CALL SvtRulerAccessible::supportsService( const OUString& sServiceName ) throw( RuntimeException ) 427*2bfcd321SSteve Yin { 428*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 429*2bfcd321SSteve Yin // Iterate over all supported service names and return true if on of them 430*2bfcd321SSteve Yin // matches the given name. 431*2bfcd321SSteve Yin Sequence< OUString > aSupportedServices( getSupportedServiceNames() ); 432*2bfcd321SSteve Yin int nLength = aSupportedServices.getLength(); 433*2bfcd321SSteve Yin const OUString* pStr = aSupportedServices.getConstArray(); 434*2bfcd321SSteve Yin 435*2bfcd321SSteve Yin for( int i = nLength ; i ; --i, ++pStr ) 436*2bfcd321SSteve Yin { 437*2bfcd321SSteve Yin if( sServiceName == *pStr ) 438*2bfcd321SSteve Yin return sal_True; 439*2bfcd321SSteve Yin } 440*2bfcd321SSteve Yin 441*2bfcd321SSteve Yin return sal_False; 442*2bfcd321SSteve Yin } 443*2bfcd321SSteve Yin 444*2bfcd321SSteve Yin Sequence< OUString > SAL_CALL SvtRulerAccessible::getSupportedServiceNames( void ) throw( RuntimeException ) 445*2bfcd321SSteve Yin { 446*2bfcd321SSteve Yin const OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) ); 447*2bfcd321SSteve Yin return Sequence< OUString >( &sServiceName, 1 ); 448*2bfcd321SSteve Yin } 449*2bfcd321SSteve Yin 450*2bfcd321SSteve Yin //===== XTypeProvider ======================================================= 451*2bfcd321SSteve Yin 452*2bfcd321SSteve Yin Sequence< sal_Int8 > SAL_CALL SvtRulerAccessible::getImplementationId( void ) throw( RuntimeException ) 453*2bfcd321SSteve Yin { 454*2bfcd321SSteve Yin return getUniqueId(); 455*2bfcd321SSteve Yin } 456*2bfcd321SSteve Yin 457*2bfcd321SSteve Yin 458*2bfcd321SSteve Yin //===== internals ======================================================== 459*2bfcd321SSteve Yin 460*2bfcd321SSteve Yin void SvtRulerAccessible::setName( const OUString& rName ) 461*2bfcd321SSteve Yin { 462*2bfcd321SSteve Yin msName = rName; 463*2bfcd321SSteve Yin 464*2bfcd321SSteve Yin } 465*2bfcd321SSteve Yin 466*2bfcd321SSteve Yin void SvtRulerAccessible::setDescription( const OUString& rDescr ) 467*2bfcd321SSteve Yin { 468*2bfcd321SSteve Yin 469*2bfcd321SSteve Yin msDescription = rDescr; 470*2bfcd321SSteve Yin 471*2bfcd321SSteve Yin } 472*2bfcd321SSteve Yin 473*2bfcd321SSteve Yin 474*2bfcd321SSteve Yin 475*2bfcd321SSteve Yin void SAL_CALL SvtRulerAccessible::disposing() 476*2bfcd321SSteve Yin { 477*2bfcd321SSteve Yin if( !rBHelper.bDisposed ) 478*2bfcd321SSteve Yin { 479*2bfcd321SSteve Yin { 480*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 481*2bfcd321SSteve Yin mpRepr = NULL; // object dies with representation 482*2bfcd321SSteve Yin 483*2bfcd321SSteve Yin } 484*2bfcd321SSteve Yin 485*2bfcd321SSteve Yin { 486*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 487*2bfcd321SSteve Yin 488*2bfcd321SSteve Yin // Send a disposing to all listeners. 489*2bfcd321SSteve Yin if ( mnClientId ) 490*2bfcd321SSteve Yin { 491*2bfcd321SSteve Yin comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); 492*2bfcd321SSteve Yin mnClientId = 0; 493*2bfcd321SSteve Yin } 494*2bfcd321SSteve Yin mxParent = uno::Reference< XAccessible >(); 495*2bfcd321SSteve Yin } 496*2bfcd321SSteve Yin } 497*2bfcd321SSteve Yin } 498*2bfcd321SSteve Yin 499*2bfcd321SSteve Yin Rectangle SvtRulerAccessible::GetBoundingBoxOnScreen( void ) throw( RuntimeException ) 500*2bfcd321SSteve Yin { 501*2bfcd321SSteve Yin ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 502*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 503*2bfcd321SSteve Yin 504*2bfcd321SSteve Yin ThrowExceptionIfNotAlive(); 505*2bfcd321SSteve Yin //IAccessibility2 Implementation 2009----- 506*2bfcd321SSteve Yin //Modified by Li Xing, 2007/03/26, SODC_7333, the absolute on screen pixel is wrong 507*2bfcd321SSteve Yin //return Rectangle( mpRepr->GetParent()->OutputToScreenPixel( mpRepr->GetPosPixel() ), mpRepr->GetSizePixel() ); 508*2bfcd321SSteve Yin return Rectangle( mpRepr->GetParent()->OutputToAbsoluteScreenPixel( mpRepr->GetPosPixel() ), mpRepr->GetSizePixel() ); 509*2bfcd321SSteve Yin //Ended by Li Xing, 2007/03/26, SODC_7333. 510*2bfcd321SSteve Yin //-----IAccessibility2 Implementation 2009 511*2bfcd321SSteve Yin } 512*2bfcd321SSteve Yin 513*2bfcd321SSteve Yin Rectangle SvtRulerAccessible::GetBoundingBox( void ) throw( RuntimeException ) 514*2bfcd321SSteve Yin { 515*2bfcd321SSteve Yin ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); 516*2bfcd321SSteve Yin ::osl::MutexGuard aGuard( m_aMutex ); 517*2bfcd321SSteve Yin 518*2bfcd321SSteve Yin ThrowExceptionIfNotAlive(); 519*2bfcd321SSteve Yin 520*2bfcd321SSteve Yin return Rectangle( mpRepr->GetPosPixel(), mpRepr->GetSizePixel() ); 521*2bfcd321SSteve Yin } 522*2bfcd321SSteve Yin 523*2bfcd321SSteve Yin Sequence< sal_Int8 > SvtRulerAccessible::getUniqueId( void ) 524*2bfcd321SSteve Yin { 525*2bfcd321SSteve Yin static OImplementationId* pId = 0; 526*2bfcd321SSteve Yin if( !pId ) 527*2bfcd321SSteve Yin { 528*2bfcd321SSteve Yin MutexGuard aGuard( Mutex::getGlobalMutex() ); 529*2bfcd321SSteve Yin if( !pId) 530*2bfcd321SSteve Yin { 531*2bfcd321SSteve Yin static OImplementationId aId; 532*2bfcd321SSteve Yin pId = &aId; 533*2bfcd321SSteve Yin } 534*2bfcd321SSteve Yin } 535*2bfcd321SSteve Yin return pId->getImplementationId(); 536*2bfcd321SSteve Yin } 537*2bfcd321SSteve Yin 538*2bfcd321SSteve Yin void SvtRulerAccessible::ThrowExceptionIfNotAlive( void ) throw( lang::DisposedException ) 539*2bfcd321SSteve Yin { 540*2bfcd321SSteve Yin if( IsNotAlive() ) 541*2bfcd321SSteve Yin throw lang::DisposedException(); 542*2bfcd321SSteve Yin } 543*2bfcd321SSteve Yin 544*2bfcd321SSteve Yin void SvtRulerAccessible::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener )throw( com::sun::star::uno::RuntimeException ) 545*2bfcd321SSteve Yin { 546*2bfcd321SSteve Yin cppu::WeakAggComponentImplHelperBase::addEventListener( xListener ); 547*2bfcd321SSteve Yin } 548*2bfcd321SSteve Yin 549*2bfcd321SSteve Yin void SvtRulerAccessible::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException ) 550*2bfcd321SSteve Yin { 551*2bfcd321SSteve Yin cppu::WeakAggComponentImplHelperBase::removeEventListener( xListener ); 552*2bfcd321SSteve Yin } 553*2bfcd321SSteve Yin 554*2bfcd321SSteve Yin 555*2bfcd321SSteve Yin // ------------------------------------------------------------------------------------------------- 556*2bfcd321SSteve Yin 557