xref: /AOO41X/main/svtools/source/control/accessibleruler.cxx (revision 0deba7fbda3d9908785c25a443701a293b6f4e71)
12bfcd321SSteve Yin /*************************************************************************
22bfcd321SSteve Yin  *
32bfcd321SSteve Yin  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
42bfcd321SSteve Yin  *
52bfcd321SSteve Yin  * Copyright IBM Corporation 2010.
62bfcd321SSteve Yin  * Copyright 2000, 2010 Oracle and/or its affiliates.
72bfcd321SSteve Yin  *
82bfcd321SSteve Yin  * OpenOffice.org - a multi-platform office productivity suite
92bfcd321SSteve Yin  *
102bfcd321SSteve Yin  * This file is part of OpenOffice.org.
112bfcd321SSteve Yin  *
122bfcd321SSteve Yin  * OpenOffice.org is free software: you can redistribute it and/or modify
132bfcd321SSteve Yin  * it under the terms of the GNU Lesser General Public License version 3
142bfcd321SSteve Yin  * only, as published by the Free Software Foundation.
152bfcd321SSteve Yin  *
162bfcd321SSteve Yin  * OpenOffice.org is distributed in the hope that it will be useful,
172bfcd321SSteve Yin  * but WITHOUT ANY WARRANTY; without even the implied warranty of
182bfcd321SSteve Yin  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
192bfcd321SSteve Yin  * GNU Lesser General Public License version 3 for more details
202bfcd321SSteve Yin  * (a copy is included in the LICENSE file that accompanied this code).
212bfcd321SSteve Yin  *
222bfcd321SSteve Yin  * You should have received a copy of the GNU Lesser General Public License
232bfcd321SSteve Yin  * version 3 along with OpenOffice.org.  If not, see
242bfcd321SSteve Yin  * <http://www.openoffice.org/license.html>
252bfcd321SSteve Yin  * for a copy of the LGPLv3 License.
262bfcd321SSteve Yin  *
272bfcd321SSteve Yin  ************************************************************************/
282bfcd321SSteve Yin 
292bfcd321SSteve Yin // MARKER(update_precomp.py): autogen include statement, do not remove
302bfcd321SSteve Yin #include "precompiled_svtools.hxx"
312bfcd321SSteve Yin 
322bfcd321SSteve Yin #ifndef _SVTRULERACCESSIBLE_HXX
332bfcd321SSteve Yin #include <svtools/accessibleruler.hxx>
342bfcd321SSteve Yin #endif
35*0deba7fbSSteve Yin 
362bfcd321SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
372bfcd321SSteve Yin #include <com/sun/star/accessibility/AccessibleRole.hpp>
382bfcd321SSteve Yin #endif
392bfcd321SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
402bfcd321SSteve Yin #include <com/sun/star/accessibility/AccessibleEventId.hpp>
412bfcd321SSteve Yin #endif
422bfcd321SSteve Yin #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_
432bfcd321SSteve Yin #include <unotools/accessiblestatesethelper.hxx>
442bfcd321SSteve Yin #endif
452bfcd321SSteve Yin #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_
462bfcd321SSteve Yin #include <com/sun/star/accessibility/AccessibleStateType.hpp>
472bfcd321SSteve Yin #endif
482bfcd321SSteve Yin 
492bfcd321SSteve Yin #ifndef	_COM_SUN_STAR_BEANS_PROPERTYCHANGEEVENT_HPP_
502bfcd321SSteve Yin #include <com/sun/star/beans/PropertyChangeEvent.hpp>
512bfcd321SSteve Yin #endif
522bfcd321SSteve Yin 
532bfcd321SSteve Yin #ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
542bfcd321SSteve Yin #include <com/sun/star/awt/XWindow.hpp>
552bfcd321SSteve Yin #endif
562bfcd321SSteve Yin 
572bfcd321SSteve Yin #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
582bfcd321SSteve Yin #include <cppuhelper/typeprovider.hxx>
592bfcd321SSteve Yin #endif
602bfcd321SSteve Yin 
612bfcd321SSteve Yin #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
622bfcd321SSteve Yin #include <toolkit/helper/vclunohelper.hxx>
632bfcd321SSteve Yin #endif
642bfcd321SSteve Yin #ifndef _TOOLKIT_HELPER_CONVERT_HXX_
652bfcd321SSteve Yin #include <toolkit/helper/convert.hxx>
662bfcd321SSteve Yin #endif
672bfcd321SSteve Yin 
682bfcd321SSteve Yin #ifndef _SV_SVAPP_HXX
692bfcd321SSteve Yin #include <vcl/svapp.hxx>
702bfcd321SSteve Yin #endif
712bfcd321SSteve Yin 
722bfcd321SSteve Yin #ifndef _OSL_MUTEX_HXX_
732bfcd321SSteve Yin #include <osl/mutex.hxx>
742bfcd321SSteve Yin #endif
752bfcd321SSteve Yin #ifndef _RTL_UUID_H_
762bfcd321SSteve Yin #include <rtl/uuid.h>
772bfcd321SSteve Yin #endif
782bfcd321SSteve Yin #ifndef _TOOLS_DEBUG_HXX
792bfcd321SSteve Yin #include <tools/debug.hxx>
802bfcd321SSteve Yin #endif
812bfcd321SSteve Yin #ifndef _SV_GEN_HXX
822bfcd321SSteve Yin #include <tools/gen.hxx>
832bfcd321SSteve Yin #endif
842bfcd321SSteve Yin 
852bfcd321SSteve Yin #include "ruler.hxx"
862bfcd321SSteve Yin 
872bfcd321SSteve Yin #ifndef COMPHELPER_ACCESSIBLE_EVENT_NOTIFIER
882bfcd321SSteve Yin #include <comphelper/accessibleeventnotifier.hxx>
892bfcd321SSteve Yin #endif
902bfcd321SSteve Yin 
912bfcd321SSteve Yin using namespace ::cppu;
922bfcd321SSteve Yin using namespace ::osl;
932bfcd321SSteve Yin using namespace	::rtl;
942bfcd321SSteve Yin using namespace	::com::sun::star;
952bfcd321SSteve Yin using namespace	::com::sun::star::uno;
962bfcd321SSteve Yin using namespace	::com::sun::star::accessibility;
972bfcd321SSteve Yin 
982bfcd321SSteve Yin DBG_NAME( SvtRulerAccessible )
992bfcd321SSteve Yin 
1002bfcd321SSteve Yin 
1012bfcd321SSteve Yin //=====  internal  ============================================================
1022bfcd321SSteve Yin 
1032bfcd321SSteve Yin SvtRulerAccessible::SvtRulerAccessible(
1042bfcd321SSteve Yin 	const uno::Reference< XAccessible >& rxParent, Ruler& rRepr, const OUString& rName ) :
1052bfcd321SSteve Yin 
1062bfcd321SSteve Yin 	SvtRulerAccessible_Base( m_aMutex ),
1072bfcd321SSteve Yin 	msName( rName ),
1082bfcd321SSteve Yin 	mxParent( rxParent ),
1092bfcd321SSteve Yin 	mpRepr( &rRepr ),
1102bfcd321SSteve Yin     mnClientId( 0 )
1112bfcd321SSteve Yin {
1122bfcd321SSteve Yin 	DBG_CTOR( SvtRulerAccessible, NULL );
1132bfcd321SSteve Yin }
1142bfcd321SSteve Yin 
1152bfcd321SSteve Yin SvtRulerAccessible::~SvtRulerAccessible()
1162bfcd321SSteve Yin {
1172bfcd321SSteve Yin 	DBG_DTOR( SvtRulerAccessible, NULL );
1182bfcd321SSteve Yin 
1192bfcd321SSteve Yin 	if( IsAlive() )
1202bfcd321SSteve Yin 	{
1212bfcd321SSteve Yin 		osl_incrementInterlockedCount( &m_refCount );
1222bfcd321SSteve Yin 		dispose();		// set mpRepr = NULL & release all childs
1232bfcd321SSteve Yin 	}
1242bfcd321SSteve Yin }
1252bfcd321SSteve Yin 
1262bfcd321SSteve Yin //=====  XAccessible  =========================================================
1272bfcd321SSteve Yin 
1282bfcd321SSteve Yin uno::Reference< XAccessibleContext > SAL_CALL SvtRulerAccessible::getAccessibleContext( void ) throw( RuntimeException )
1292bfcd321SSteve Yin {
1302bfcd321SSteve Yin 	return this;
1312bfcd321SSteve Yin }
1322bfcd321SSteve Yin 
1332bfcd321SSteve Yin //=====  XAccessibleComponent  ================================================
1342bfcd321SSteve Yin 
1352bfcd321SSteve Yin sal_Bool SAL_CALL SvtRulerAccessible::containsPoint( const awt::Point& rPoint ) throw( RuntimeException )
1362bfcd321SSteve Yin {
1372bfcd321SSteve Yin 	// no guard -> done in getBounds()
1382bfcd321SSteve Yin //	return GetBoundingBox().IsInside( VCLPoint( rPoint ) );
1392bfcd321SSteve Yin 	return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint ) );
1402bfcd321SSteve Yin }
1412bfcd321SSteve Yin 
1422bfcd321SSteve Yin uno::Reference< XAccessible > SAL_CALL SvtRulerAccessible::getAccessibleAtPoint( const awt::Point& ) throw( RuntimeException )
1432bfcd321SSteve Yin {
1442bfcd321SSteve Yin 	::osl::MutexGuard			aGuard( m_aMutex );
1452bfcd321SSteve Yin 
1462bfcd321SSteve Yin 	ThrowExceptionIfNotAlive();
1472bfcd321SSteve Yin 
1482bfcd321SSteve Yin 	uno::Reference< XAccessible >	xRet;
1492bfcd321SSteve Yin 
1502bfcd321SSteve Yin 
1512bfcd321SSteve Yin 	return xRet;
1522bfcd321SSteve Yin }
1532bfcd321SSteve Yin 
1542bfcd321SSteve Yin awt::Rectangle SAL_CALL SvtRulerAccessible::getBounds() throw( RuntimeException )
1552bfcd321SSteve Yin {
1562bfcd321SSteve Yin 	// no guard -> done in GetBoundingBox()
1572bfcd321SSteve Yin 	return AWTRectangle( GetBoundingBox() );
1582bfcd321SSteve Yin }
1592bfcd321SSteve Yin 
1602bfcd321SSteve Yin awt::Point SAL_CALL SvtRulerAccessible::getLocation() throw( RuntimeException )
1612bfcd321SSteve Yin {
1622bfcd321SSteve Yin 	// no guard -> done in GetBoundingBox()
1632bfcd321SSteve Yin 	return AWTPoint( GetBoundingBox().TopLeft() );
1642bfcd321SSteve Yin }
1652bfcd321SSteve Yin 
1662bfcd321SSteve Yin awt::Point SAL_CALL SvtRulerAccessible::getLocationOnScreen() throw( RuntimeException )
1672bfcd321SSteve Yin {
1682bfcd321SSteve Yin 	// no guard -> done in GetBoundingBoxOnScreen()
1692bfcd321SSteve Yin 	return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
1702bfcd321SSteve Yin }
1712bfcd321SSteve Yin 
1722bfcd321SSteve Yin awt::Size SAL_CALL SvtRulerAccessible::getSize() throw( RuntimeException )
1732bfcd321SSteve Yin {
1742bfcd321SSteve Yin 	// no guard -> done in GetBoundingBox()
1752bfcd321SSteve Yin 	return AWTSize( GetBoundingBox().GetSize() );
1762bfcd321SSteve Yin }
1772bfcd321SSteve Yin 
1782bfcd321SSteve Yin sal_Bool SAL_CALL SvtRulerAccessible::isShowing() throw( RuntimeException )
1792bfcd321SSteve Yin {
1802bfcd321SSteve Yin 	return sal_True;
1812bfcd321SSteve Yin }
1822bfcd321SSteve Yin 
1832bfcd321SSteve Yin sal_Bool SAL_CALL SvtRulerAccessible::isVisible() throw( RuntimeException )
1842bfcd321SSteve Yin {
1852bfcd321SSteve Yin 	::osl::MutexGuard			aGuard( m_aMutex );
1862bfcd321SSteve Yin 
1872bfcd321SSteve Yin 	ThrowExceptionIfNotAlive();
1882bfcd321SSteve Yin 
1892bfcd321SSteve Yin 	return mpRepr->IsVisible();
1902bfcd321SSteve Yin }
1912bfcd321SSteve Yin 
1922bfcd321SSteve Yin sal_Bool SAL_CALL SvtRulerAccessible::isFocusTraversable() throw( RuntimeException )
1932bfcd321SSteve Yin {
1942bfcd321SSteve Yin 	return sal_True;
1952bfcd321SSteve Yin }
1962bfcd321SSteve Yin 
1972bfcd321SSteve Yin //=====  XAccessibleContext  ==================================================
1982bfcd321SSteve Yin 
1992bfcd321SSteve Yin sal_Int32 SAL_CALL SvtRulerAccessible::getAccessibleChildCount( void ) throw( RuntimeException )
2002bfcd321SSteve Yin {
2012bfcd321SSteve Yin 	::osl::MutexGuard	aGuard( m_aMutex );
2022bfcd321SSteve Yin 
2032bfcd321SSteve Yin 	ThrowExceptionIfNotAlive();
2042bfcd321SSteve Yin 
2052bfcd321SSteve Yin 	return 0;
2062bfcd321SSteve Yin }
2072bfcd321SSteve Yin 
2082bfcd321SSteve Yin uno::Reference< XAccessible > SAL_CALL SvtRulerAccessible::getAccessibleChild( sal_Int32 )
2092bfcd321SSteve Yin 	throw( RuntimeException, lang::IndexOutOfBoundsException )
2102bfcd321SSteve Yin {
2112bfcd321SSteve Yin 	uno::Reference< XAccessible >	xChild ;
2122bfcd321SSteve Yin 
2132bfcd321SSteve Yin 	return xChild;
2142bfcd321SSteve Yin }
2152bfcd321SSteve Yin 
2162bfcd321SSteve Yin uno::Reference< XAccessible > SAL_CALL SvtRulerAccessible::getAccessibleParent( void ) throw( RuntimeException )
2172bfcd321SSteve Yin {
2182bfcd321SSteve Yin 	return mxParent;
2192bfcd321SSteve Yin }
2202bfcd321SSteve Yin 
2212bfcd321SSteve Yin sal_Int32 SAL_CALL SvtRulerAccessible::getAccessibleIndexInParent( void ) throw( RuntimeException )
2222bfcd321SSteve Yin {
2232bfcd321SSteve Yin 	::osl::MutexGuard	aGuard( m_aMutex );
2242bfcd321SSteve Yin 	//	Use a simple but slow solution for now.  Optimize later.
2252bfcd321SSteve Yin 
2262bfcd321SSteve Yin     //	Iterate over all the parent's children and search for this object.
2272bfcd321SSteve Yin     if( mxParent.is() )
2282bfcd321SSteve Yin     {
2292bfcd321SSteve Yin     	uno::Reference< XAccessibleContext >		xParentContext( mxParent->getAccessibleContext() );
2302bfcd321SSteve Yin         if( xParentContext.is() )
2312bfcd321SSteve Yin         {
2322bfcd321SSteve Yin         	sal_Int32						nChildCount = xParentContext->getAccessibleChildCount();
2332bfcd321SSteve Yin             for( sal_Int32 i = 0 ; i < nChildCount ; ++i )
2342bfcd321SSteve Yin             {
2352bfcd321SSteve Yin             	uno::Reference< XAccessible >	xChild( xParentContext->getAccessibleChild( i ) );
2362bfcd321SSteve Yin 				if( xChild.get() == ( XAccessible* ) this )
2372bfcd321SSteve Yin                     return i;
2382bfcd321SSteve Yin             }
2392bfcd321SSteve Yin         }
2402bfcd321SSteve Yin    }
2412bfcd321SSteve Yin 
2422bfcd321SSteve Yin    //	Return -1 to indicate that this object's parent does not know about the
2432bfcd321SSteve Yin    //	object.
2442bfcd321SSteve Yin    return -1;
2452bfcd321SSteve Yin }
2462bfcd321SSteve Yin 
2472bfcd321SSteve Yin sal_Int16 SAL_CALL SvtRulerAccessible::getAccessibleRole( void ) throw( RuntimeException )
2482bfcd321SSteve Yin {
2492bfcd321SSteve Yin 	return AccessibleRole::RULER;
2502bfcd321SSteve Yin }
2512bfcd321SSteve Yin 
2522bfcd321SSteve Yin OUString SAL_CALL SvtRulerAccessible::getAccessibleDescription( void ) throw( RuntimeException )
2532bfcd321SSteve Yin {
2542bfcd321SSteve Yin 	::osl::MutexGuard	aGuard( m_aMutex );
2552bfcd321SSteve Yin 	return msDescription;
2562bfcd321SSteve Yin }
2572bfcd321SSteve Yin 
2582bfcd321SSteve Yin OUString SAL_CALL SvtRulerAccessible::getAccessibleName( void ) throw( RuntimeException )
2592bfcd321SSteve Yin {
2602bfcd321SSteve Yin 	::osl::MutexGuard	aGuard( m_aMutex );
2612bfcd321SSteve Yin 	return msName;
2622bfcd321SSteve Yin }
2632bfcd321SSteve Yin 
2642bfcd321SSteve Yin /**	Return empty uno::Reference to indicate that the relation set is not
2652bfcd321SSteve Yin 	supported.
2662bfcd321SSteve Yin */
2672bfcd321SSteve Yin uno::Reference< XAccessibleRelationSet > SAL_CALL SvtRulerAccessible::getAccessibleRelationSet( void ) throw( RuntimeException )
2682bfcd321SSteve Yin {
2692bfcd321SSteve Yin 	return uno::Reference< XAccessibleRelationSet >();
2702bfcd321SSteve Yin }
2712bfcd321SSteve Yin 
2722bfcd321SSteve Yin 
2732bfcd321SSteve Yin uno::Reference< XAccessibleStateSet > SAL_CALL SvtRulerAccessible::getAccessibleStateSet( void ) throw( RuntimeException )
2742bfcd321SSteve Yin {
2752bfcd321SSteve Yin 	::osl::MutexGuard						aGuard( m_aMutex );
2762bfcd321SSteve Yin 	utl::AccessibleStateSetHelper*			pStateSetHelper = new utl::AccessibleStateSetHelper;
2772bfcd321SSteve Yin 
2782bfcd321SSteve Yin 	if( IsAlive() )
2792bfcd321SSteve Yin 	{
2802bfcd321SSteve Yin 		pStateSetHelper->AddState( AccessibleStateType::ENABLED );
2812bfcd321SSteve Yin 
2822bfcd321SSteve Yin 		if( isShowing() )
2832bfcd321SSteve Yin 			pStateSetHelper->AddState( AccessibleStateType::SHOWING );
2842bfcd321SSteve Yin 
2852bfcd321SSteve Yin 		if( isVisible() )
2862bfcd321SSteve Yin 			pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
2872bfcd321SSteve Yin 
2882bfcd321SSteve Yin 
2892bfcd321SSteve Yin 		if ( mpRepr )
2902bfcd321SSteve Yin 		{
2912bfcd321SSteve Yin 			if ( mpRepr->GetStyle() & WB_HORZ )
2922bfcd321SSteve Yin 				pStateSetHelper->AddState( AccessibleStateType::HORIZONTAL );
2932bfcd321SSteve Yin 			else
2942bfcd321SSteve Yin 				pStateSetHelper->AddState( AccessibleStateType::VERTICAL );
2952bfcd321SSteve Yin 		}
2962bfcd321SSteve Yin 		if(pStateSetHelper->contains(AccessibleStateType::FOCUSABLE))
2972bfcd321SSteve Yin 		{
2982bfcd321SSteve Yin 			pStateSetHelper->RemoveState( AccessibleStateType::FOCUSABLE );
2992bfcd321SSteve Yin 		}
3002bfcd321SSteve Yin 
3012bfcd321SSteve Yin 	}
3022bfcd321SSteve Yin 
3032bfcd321SSteve Yin 
3042bfcd321SSteve Yin 	return pStateSetHelper;
3052bfcd321SSteve Yin }
3062bfcd321SSteve Yin 
3072bfcd321SSteve Yin lang::Locale SAL_CALL SvtRulerAccessible::getLocale( void ) throw( IllegalAccessibleComponentStateException, RuntimeException )
3082bfcd321SSteve Yin {
3092bfcd321SSteve Yin 	::osl::MutexGuard							aGuard( m_aMutex );
3102bfcd321SSteve Yin 	if( mxParent.is() )
3112bfcd321SSteve Yin     {
3122bfcd321SSteve Yin     	uno::Reference< XAccessibleContext >	xParentContext( mxParent->getAccessibleContext() );
3132bfcd321SSteve Yin         if( xParentContext.is() )
3142bfcd321SSteve Yin 	    	return xParentContext->getLocale();
3152bfcd321SSteve Yin     }
3162bfcd321SSteve Yin 
3172bfcd321SSteve Yin     //	No parent.  Therefore throw exception to indicate this cluelessness.
3182bfcd321SSteve Yin     throw IllegalAccessibleComponentStateException();
3192bfcd321SSteve Yin }
3202bfcd321SSteve Yin 
3212bfcd321SSteve Yin void SAL_CALL SvtRulerAccessible::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
3222bfcd321SSteve Yin     throw( RuntimeException )
3232bfcd321SSteve Yin {
3242bfcd321SSteve Yin 	if (xListener.is())
3252bfcd321SSteve Yin     {
3262bfcd321SSteve Yin 		::osl::MutexGuard	aGuard( m_aMutex );
3272bfcd321SSteve Yin 		if (!mnClientId)
3282bfcd321SSteve Yin             mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
3292bfcd321SSteve Yin 		comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
3302bfcd321SSteve Yin     }
3312bfcd321SSteve Yin }
3322bfcd321SSteve Yin 
3332bfcd321SSteve Yin void SAL_CALL SvtRulerAccessible::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener )
3342bfcd321SSteve Yin     throw( RuntimeException )
3352bfcd321SSteve Yin {
3362bfcd321SSteve Yin 	if (xListener.is())
3372bfcd321SSteve Yin 	{
3382bfcd321SSteve Yin     	::osl::MutexGuard	aGuard( m_aMutex );
3392bfcd321SSteve Yin 
3402bfcd321SSteve Yin         sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener );
3412bfcd321SSteve Yin 		if ( !nListenerCount )
3422bfcd321SSteve Yin 		{
3432bfcd321SSteve Yin 			// no listeners anymore
3442bfcd321SSteve Yin 			// -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
3452bfcd321SSteve Yin 			// and at least to us not firing any events anymore, in case somebody calls
3462bfcd321SSteve Yin 			// NotifyAccessibleEvent, again
3472bfcd321SSteve Yin 			comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
3482bfcd321SSteve Yin 			mnClientId = 0;
3492bfcd321SSteve Yin 		}
3502bfcd321SSteve Yin 	}
3512bfcd321SSteve Yin }
3522bfcd321SSteve Yin 
3532bfcd321SSteve Yin void SAL_CALL SvtRulerAccessible::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
3542bfcd321SSteve Yin 	throw( RuntimeException )
3552bfcd321SSteve Yin {
3562bfcd321SSteve Yin 	if( xListener.is() )
3572bfcd321SSteve Yin     {
3582bfcd321SSteve Yin 		::osl::MutexGuard	aGuard( m_aMutex );
3592bfcd321SSteve Yin 
3602bfcd321SSteve Yin 		ThrowExceptionIfNotAlive();
3612bfcd321SSteve Yin 
3622bfcd321SSteve Yin 		uno::Reference< awt::XWindow >	xWindow = VCLUnoHelper::GetInterface( mpRepr );
3632bfcd321SSteve Yin 		if( xWindow.is() )
3642bfcd321SSteve Yin 			xWindow->addFocusListener( xListener );
3652bfcd321SSteve Yin     }
3662bfcd321SSteve Yin }
3672bfcd321SSteve Yin 
3682bfcd321SSteve Yin void SAL_CALL SvtRulerAccessible::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener )
3692bfcd321SSteve Yin 	throw (RuntimeException)
3702bfcd321SSteve Yin {
3712bfcd321SSteve Yin 	if( xListener.is() )
3722bfcd321SSteve Yin     {
3732bfcd321SSteve Yin 		::osl::MutexGuard	aGuard( m_aMutex );
3742bfcd321SSteve Yin 
3752bfcd321SSteve Yin 		ThrowExceptionIfNotAlive();
3762bfcd321SSteve Yin 
3772bfcd321SSteve Yin 		uno::Reference< awt::XWindow >	xWindow = VCLUnoHelper::GetInterface( mpRepr );
3782bfcd321SSteve Yin 		if( xWindow.is() )
3792bfcd321SSteve Yin 			xWindow->removeFocusListener( xListener );
3802bfcd321SSteve Yin     }
3812bfcd321SSteve Yin }
3822bfcd321SSteve Yin 
3832bfcd321SSteve Yin void SAL_CALL SvtRulerAccessible::grabFocus() throw( RuntimeException )
3842bfcd321SSteve Yin {
3852bfcd321SSteve Yin 	::vos::OGuard		aSolarGuard( Application::GetSolarMutex() );
3862bfcd321SSteve Yin 	::osl::MutexGuard	aGuard( m_aMutex );
3872bfcd321SSteve Yin 
3882bfcd321SSteve Yin 	ThrowExceptionIfNotAlive();
3892bfcd321SSteve Yin 
3902bfcd321SSteve Yin 	mpRepr->GrabFocus();
3912bfcd321SSteve Yin }
3922bfcd321SSteve Yin 
3932bfcd321SSteve Yin Any SAL_CALL SvtRulerAccessible::getAccessibleKeyBinding() throw( RuntimeException )
3942bfcd321SSteve Yin {
3952bfcd321SSteve Yin 	// here is no implementation, because here are no KeyBindings for every object
3962bfcd321SSteve Yin 	return Any();
3972bfcd321SSteve Yin }
3982bfcd321SSteve Yin 
3992bfcd321SSteve Yin sal_Int32 SvtRulerAccessible::getForeground(  )
4002bfcd321SSteve Yin         throw (::com::sun::star::uno::RuntimeException)
4012bfcd321SSteve Yin {
4022bfcd321SSteve Yin     ::vos::OGuard       aSolarGuard( Application::GetSolarMutex() );
4032bfcd321SSteve Yin     ::osl::MutexGuard   aGuard( m_aMutex );
4042bfcd321SSteve Yin     ThrowExceptionIfNotAlive();
4052bfcd321SSteve Yin 
4062bfcd321SSteve Yin     return mpRepr->GetControlForeground().GetColor();
4072bfcd321SSteve Yin }
4082bfcd321SSteve Yin sal_Int32 SvtRulerAccessible::getBackground(  )
4092bfcd321SSteve Yin         throw (::com::sun::star::uno::RuntimeException)
4102bfcd321SSteve Yin {
4112bfcd321SSteve Yin     ::vos::OGuard       aSolarGuard( Application::GetSolarMutex() );
4122bfcd321SSteve Yin     ::osl::MutexGuard   aGuard( m_aMutex );
4132bfcd321SSteve Yin     ThrowExceptionIfNotAlive();
4142bfcd321SSteve Yin 
4152bfcd321SSteve Yin     return mpRepr->GetControlBackground().GetColor();
4162bfcd321SSteve Yin }
4172bfcd321SSteve Yin 
4182bfcd321SSteve Yin //=====  XServiceInfo  ========================================================
4192bfcd321SSteve Yin 
4202bfcd321SSteve Yin OUString SAL_CALL SvtRulerAccessible::getImplementationName( void ) throw( RuntimeException )
4212bfcd321SSteve Yin {
4222bfcd321SSteve Yin 	return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ui.SvtRulerAccessible" ) );
4232bfcd321SSteve Yin }
4242bfcd321SSteve Yin 
4252bfcd321SSteve Yin sal_Bool SAL_CALL SvtRulerAccessible::supportsService( const OUString& sServiceName ) throw( RuntimeException )
4262bfcd321SSteve Yin {
4272bfcd321SSteve Yin 	::osl::MutexGuard	aGuard( m_aMutex );
4282bfcd321SSteve Yin     //  Iterate over all supported service names and return true if on of them
4292bfcd321SSteve Yin     //  matches the given name.
4302bfcd321SSteve Yin     Sequence< OUString >	aSupportedServices( getSupportedServiceNames() );
4312bfcd321SSteve Yin 	int						nLength = aSupportedServices.getLength();
4322bfcd321SSteve Yin 	const OUString*			pStr = aSupportedServices.getConstArray();
4332bfcd321SSteve Yin 
4342bfcd321SSteve Yin     for( int i = nLength ; i ; --i, ++pStr )
4352bfcd321SSteve Yin 	{
4362bfcd321SSteve Yin         if( sServiceName == *pStr )
4372bfcd321SSteve Yin             return sal_True;
4382bfcd321SSteve Yin 	}
4392bfcd321SSteve Yin 
4402bfcd321SSteve Yin     return sal_False;
4412bfcd321SSteve Yin }
4422bfcd321SSteve Yin 
4432bfcd321SSteve Yin Sequence< OUString > SAL_CALL SvtRulerAccessible::getSupportedServiceNames( void ) throw( RuntimeException )
4442bfcd321SSteve Yin {
4452bfcd321SSteve Yin 	const OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" ) );
4462bfcd321SSteve Yin 	return Sequence< OUString >( &sServiceName, 1 );
4472bfcd321SSteve Yin }
4482bfcd321SSteve Yin 
4492bfcd321SSteve Yin //=====  XTypeProvider  =======================================================
4502bfcd321SSteve Yin 
4512bfcd321SSteve Yin Sequence< sal_Int8 > SAL_CALL SvtRulerAccessible::getImplementationId( void ) throw( RuntimeException )
4522bfcd321SSteve Yin {
4532bfcd321SSteve Yin 	return getUniqueId();
4542bfcd321SSteve Yin }
4552bfcd321SSteve Yin 
4562bfcd321SSteve Yin 
4572bfcd321SSteve Yin //=====  internals ========================================================
4582bfcd321SSteve Yin 
4592bfcd321SSteve Yin void SvtRulerAccessible::setName( const OUString& rName )
4602bfcd321SSteve Yin {
4612bfcd321SSteve Yin 		msName = rName;
4622bfcd321SSteve Yin 
4632bfcd321SSteve Yin }
4642bfcd321SSteve Yin 
4652bfcd321SSteve Yin void SvtRulerAccessible::setDescription( const OUString& rDescr )
4662bfcd321SSteve Yin {
4672bfcd321SSteve Yin 
4682bfcd321SSteve Yin 		msDescription = rDescr;
4692bfcd321SSteve Yin 
4702bfcd321SSteve Yin }
4712bfcd321SSteve Yin 
4722bfcd321SSteve Yin 
4732bfcd321SSteve Yin 
4742bfcd321SSteve Yin void SAL_CALL SvtRulerAccessible::disposing()
4752bfcd321SSteve Yin {
4762bfcd321SSteve Yin 	if( !rBHelper.bDisposed )
4772bfcd321SSteve Yin 	{
4782bfcd321SSteve Yin 		{
4792bfcd321SSteve Yin 			::osl::MutexGuard	aGuard( m_aMutex );
4802bfcd321SSteve Yin 			mpRepr = NULL;		// object dies with representation
4812bfcd321SSteve Yin 
4822bfcd321SSteve Yin 		}
4832bfcd321SSteve Yin 
4842bfcd321SSteve Yin 		{
4852bfcd321SSteve Yin 			::osl::MutexGuard	aGuard( m_aMutex );
4862bfcd321SSteve Yin 
4872bfcd321SSteve Yin             // Send a disposing to all listeners.
4882bfcd321SSteve Yin 	        if ( mnClientId )
4892bfcd321SSteve Yin 	        {
4902bfcd321SSteve Yin                 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
4912bfcd321SSteve Yin 		        mnClientId =  0;
4922bfcd321SSteve Yin 	        }
4932bfcd321SSteve Yin 			mxParent = uno::Reference< XAccessible >();
4942bfcd321SSteve Yin 		}
4952bfcd321SSteve Yin 	}
4962bfcd321SSteve Yin }
4972bfcd321SSteve Yin 
4982bfcd321SSteve Yin Rectangle SvtRulerAccessible::GetBoundingBoxOnScreen( void ) throw( RuntimeException )
4992bfcd321SSteve Yin {
5002bfcd321SSteve Yin 	::vos::OGuard		aSolarGuard( Application::GetSolarMutex() );
5012bfcd321SSteve Yin 	::osl::MutexGuard	aGuard( m_aMutex );
5022bfcd321SSteve Yin 
5032bfcd321SSteve Yin 	ThrowExceptionIfNotAlive();
5042bfcd321SSteve Yin //IAccessibility2 Implementation 2009-----
505*0deba7fbSSteve Yin 	//the absolute on screen pixel is wrong
5062bfcd321SSteve Yin 	//return Rectangle( mpRepr->GetParent()->OutputToScreenPixel( mpRepr->GetPosPixel() ), mpRepr->GetSizePixel() );
5072bfcd321SSteve Yin 	return Rectangle( mpRepr->GetParent()->OutputToAbsoluteScreenPixel( mpRepr->GetPosPixel() ), mpRepr->GetSizePixel() );
5082bfcd321SSteve Yin //-----IAccessibility2 Implementation 2009
5092bfcd321SSteve Yin }
5102bfcd321SSteve Yin 
5112bfcd321SSteve Yin Rectangle SvtRulerAccessible::GetBoundingBox( void ) throw( RuntimeException )
5122bfcd321SSteve Yin {
5132bfcd321SSteve Yin 	::vos::OGuard		aSolarGuard( Application::GetSolarMutex() );
5142bfcd321SSteve Yin 	::osl::MutexGuard	aGuard( m_aMutex );
5152bfcd321SSteve Yin 
5162bfcd321SSteve Yin 	ThrowExceptionIfNotAlive();
5172bfcd321SSteve Yin 
5182bfcd321SSteve Yin 	return Rectangle( mpRepr->GetPosPixel(), mpRepr->GetSizePixel() );
5192bfcd321SSteve Yin }
5202bfcd321SSteve Yin 
5212bfcd321SSteve Yin Sequence< sal_Int8 > SvtRulerAccessible::getUniqueId( void )
5222bfcd321SSteve Yin {
5232bfcd321SSteve Yin 	static OImplementationId*	pId = 0;
5242bfcd321SSteve Yin 	if( !pId )
5252bfcd321SSteve Yin 	{
5262bfcd321SSteve Yin 		MutexGuard						aGuard( Mutex::getGlobalMutex() );
5272bfcd321SSteve Yin 		if( !pId)
5282bfcd321SSteve Yin 		{
5292bfcd321SSteve Yin 			static OImplementationId	aId;
5302bfcd321SSteve Yin 			pId = &aId;
5312bfcd321SSteve Yin 		}
5322bfcd321SSteve Yin 	}
5332bfcd321SSteve Yin 	return pId->getImplementationId();
5342bfcd321SSteve Yin }
5352bfcd321SSteve Yin 
5362bfcd321SSteve Yin void SvtRulerAccessible::ThrowExceptionIfNotAlive( void ) throw( lang::DisposedException )
5372bfcd321SSteve Yin {
5382bfcd321SSteve Yin 	if( IsNotAlive() )
5392bfcd321SSteve Yin 		throw lang::DisposedException();
5402bfcd321SSteve Yin }
5412bfcd321SSteve Yin 
5422bfcd321SSteve Yin void SvtRulerAccessible::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener )throw( com::sun::star::uno::RuntimeException )
5432bfcd321SSteve Yin {
5442bfcd321SSteve Yin 	cppu::WeakAggComponentImplHelperBase::addEventListener( xListener );
5452bfcd321SSteve Yin }
5462bfcd321SSteve Yin 
5472bfcd321SSteve Yin void SvtRulerAccessible::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException )
5482bfcd321SSteve Yin {
5492bfcd321SSteve Yin 	cppu::WeakAggComponentImplHelperBase::removeEventListener( xListener );
5502bfcd321SSteve Yin }
5512bfcd321SSteve Yin 
5522bfcd321SSteve Yin 
5532bfcd321SSteve Yin // -------------------------------------------------------------------------------------------------
5542bfcd321SSteve Yin 
555