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 29*cdf0e10cSrcweir #ifndef _SC_ACCESSIBLECONTEXTBASE_HXX 30*cdf0e10cSrcweir #define _SC_ACCESSIBLECONTEXTBASE_HXX 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleComponent.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleContext.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> 36*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_IllegalAccessibleComponentStateException_HPP_ 37*cdf0e10cSrcweir #include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp> 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx> 41*cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 42*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> 46*cdf0e10cSrcweir #include <vos/mutex.hxx> 47*cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h> 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir #include <svl/lstner.hxx> 51*cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx> 52*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 53*cdf0e10cSrcweir #include <comphelper/servicehelper.hxx> 54*cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir class Rectangle; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir /** @descr 59*cdf0e10cSrcweir This base class provides an implementation of the 60*cdf0e10cSrcweir <code>AccessibleContext</code> service. 61*cdf0e10cSrcweir */ 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir typedef cppu::WeakAggComponentImplHelper5< 64*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible, 65*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleComponent, 66*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleContext, 67*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleEventBroadcaster, 68*cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo 69*cdf0e10cSrcweir > ScAccessibleContextBaseWeakImpl; 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir typedef cppu::ImplHelper1< 72*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleEventListener 73*cdf0e10cSrcweir > ScAccessibleContextBaseImplEvent; 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir class ScAccessibleContextBase 76*cdf0e10cSrcweir : public comphelper::OBaseMutex, 77*cdf0e10cSrcweir public ScAccessibleContextBaseWeakImpl, 78*cdf0e10cSrcweir public ScAccessibleContextBaseImplEvent, 79*cdf0e10cSrcweir public SfxListener 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir public: 82*cdf0e10cSrcweir //===== internal ======================================================== 83*cdf0e10cSrcweir ScAccessibleContextBase( 84*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 85*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible>& rxParent, 86*cdf0e10cSrcweir const sal_Int16 aRole); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir virtual void Init(); 89*cdf0e10cSrcweir virtual void SAL_CALL disposing(); 90*cdf0e10cSrcweir protected: 91*cdf0e10cSrcweir virtual ~ScAccessibleContextBase(void); 92*cdf0e10cSrcweir public: 93*cdf0e10cSrcweir using WeakAggComponentImplHelperBase::addEventListener; 94*cdf0e10cSrcweir using WeakAggComponentImplHelperBase::removeEventListener; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir ///===== SfxListener ===================================================== 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir ///===== XInterface ===================================================== 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 103*cdf0e10cSrcweir ::com::sun::star::uno::Type const & rType ) 104*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir virtual void SAL_CALL acquire() throw (); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir virtual void SAL_CALL release() throw (); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir ///===== XAccessible ===================================================== 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir /// Return the XAccessibleContext. 113*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL 114*cdf0e10cSrcweir getAccessibleContext(void) throw (::com::sun::star::uno::RuntimeException); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir ///===== XAccessibleComponent ============================================ 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir virtual sal_Bool SAL_CALL containsPoint( 119*cdf0e10cSrcweir const ::com::sun::star::awt::Point& rPoint ) 120*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 123*cdf0e10cSrcweir SAL_CALL getAccessibleAtPoint( 124*cdf0e10cSrcweir const ::com::sun::star::awt::Point& rPoint ) 125*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) 128*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) 131*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) 134*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) 137*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir virtual sal_Bool SAL_CALL isShowing( ) 140*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir virtual sal_Bool SAL_CALL isVisible( ) 143*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir virtual void SAL_CALL grabFocus( ) 146*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getForeground( ) 149*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getBackground( ) 152*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir ///===== XAccessibleContext ============================================== 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir /// Return the number of currently visible children. 157*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 158*cdf0e10cSrcweir getAccessibleChildCount(void) throw (::com::sun::star::uno::RuntimeException); 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir /// Return the specified child or NULL if index is invalid. 161*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL 162*cdf0e10cSrcweir getAccessibleChild(sal_Int32 nIndex) 163*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException, 164*cdf0e10cSrcweir ::com::sun::star::lang::IndexOutOfBoundsException); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir /// Return a reference to the parent. 167*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL 168*cdf0e10cSrcweir getAccessibleParent(void) 169*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir /// Return this objects index among the parents children. 172*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 173*cdf0e10cSrcweir getAccessibleIndexInParent(void) 174*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 175*cdf0e10cSrcweir 176*cdf0e10cSrcweir /// Return this object's role. 177*cdf0e10cSrcweir virtual sal_Int16 SAL_CALL 178*cdf0e10cSrcweir getAccessibleRole(void) 179*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir /// Return this object's description. 182*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 183*cdf0e10cSrcweir getAccessibleDescription(void) 184*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir /// Return the object's current name. 187*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 188*cdf0e10cSrcweir getAccessibleName(void) 189*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir /// Return NULL to indicate that an empty relation set. 192*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 193*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL 194*cdf0e10cSrcweir getAccessibleRelationSet(void) 195*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir /// Return the set of current states. 198*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 199*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL 200*cdf0e10cSrcweir getAccessibleStateSet(void) 201*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir /** Return the parents locale or throw exception if this object has no 204*cdf0e10cSrcweir parent yet/anymore. 205*cdf0e10cSrcweir */ 206*cdf0e10cSrcweir virtual ::com::sun::star::lang::Locale SAL_CALL 207*cdf0e10cSrcweir getLocale(void) 208*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException, 209*cdf0e10cSrcweir ::com::sun::star::accessibility::IllegalAccessibleComponentStateException); 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir ///===== XAccessibleEventBroadcaster ===================================== 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir /** Add listener that is informed of future changes of name, 214*cdf0e10cSrcweir description and so on events. 215*cdf0e10cSrcweir */ 216*cdf0e10cSrcweir virtual void SAL_CALL 217*cdf0e10cSrcweir addEventListener( 218*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 219*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleEventListener>& xListener) 220*cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException); 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir // Remove an existing event listener. 223*cdf0e10cSrcweir virtual void SAL_CALL 224*cdf0e10cSrcweir removeEventListener( 225*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 226*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleEventListener>& xListener) 227*cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir ///===== XAccessibleEventListener ======================================== 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir virtual void SAL_CALL 232*cdf0e10cSrcweir disposing( const ::com::sun::star::lang::EventObject& Source ) 233*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir virtual void SAL_CALL 236*cdf0e10cSrcweir notifyEvent( 237*cdf0e10cSrcweir const ::com::sun::star::accessibility::AccessibleEventObject& aEvent ) 238*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir ///===== XServiceInfo ==================================================== 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir /** Returns an identifier for the implementation of this object. 243*cdf0e10cSrcweir */ 244*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 245*cdf0e10cSrcweir getImplementationName(void) 246*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir /** Return whether the specified service is supported by this class. 249*cdf0e10cSrcweir */ 250*cdf0e10cSrcweir virtual sal_Bool SAL_CALL 251*cdf0e10cSrcweir supportsService(const ::rtl::OUString& sServiceName) 252*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir /** Returns a list of all supported services. In this case that is just 255*cdf0e10cSrcweir the AccessibleContext and Accessible service. 256*cdf0e10cSrcweir */ 257*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 258*cdf0e10cSrcweir getSupportedServiceNames(void) 259*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir ///===== XTypeProvider =================================================== 262*cdf0e10cSrcweir 263*cdf0e10cSrcweir /// returns the possible types 264*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL 265*cdf0e10cSrcweir getTypes() 266*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 267*cdf0e10cSrcweir 268*cdf0e10cSrcweir /** Returns a implementation id. 269*cdf0e10cSrcweir */ 270*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL 271*cdf0e10cSrcweir getImplementationId(void) 272*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir protected: 275*cdf0e10cSrcweir /// Return this object's description. 276*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 277*cdf0e10cSrcweir createAccessibleDescription(void) 278*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir /// Return the object's current name. 281*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 282*cdf0e10cSrcweir createAccessibleName(void) 283*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir /// Return the object's current bounding box relative to the desktop. 286*cdf0e10cSrcweir virtual Rectangle GetBoundingBoxOnScreen(void) const 287*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 288*cdf0e10cSrcweir 289*cdf0e10cSrcweir /// Return the object's current bounding box relative to the parent object. 290*cdf0e10cSrcweir virtual Rectangle GetBoundingBox(void) const 291*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir public: 294*cdf0e10cSrcweir /// Calls all Listener to tell they the change. 295*cdf0e10cSrcweir void 296*cdf0e10cSrcweir CommitChange(const com::sun::star::accessibility::AccessibleEventObject& rEvent) const; 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir /// change the name and call the listener to tell they the change 299*cdf0e10cSrcweir void 300*cdf0e10cSrcweir ChangeName(); 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir protected: 303*cdf0e10cSrcweir /// Calls all FocusListener to tell they that the focus is gained. 304*cdf0e10cSrcweir void CommitFocusGained() const; 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir /// Calls all FocusListener to tell they that the focus is lost. 307*cdf0e10cSrcweir void CommitFocusLost() const; 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir sal_Bool IsDefunc() const { return rBHelper.bDisposed; } 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir virtual void IsObjectValid() const 312*cdf0e10cSrcweir throw (::com::sun::star::lang::DisposedException); 313*cdf0e10cSrcweir 314*cdf0e10cSrcweir /// Use this method to set initial Name without notification 315*cdf0e10cSrcweir void SetName(const rtl::OUString& rName) { msName = rName; } 316*cdf0e10cSrcweir /// Use this method to set initial Description without notification 317*cdf0e10cSrcweir void SetDescription(const rtl::OUString& rDesc) { msDescription = rDesc; } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir /// Reference to the parent object. 320*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 321*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> mxParent; 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir private: 324*cdf0e10cSrcweir /** Description of this object. This is not a constant because it can 325*cdf0e10cSrcweir be set from the outside. Furthermore, it changes according the the 326*cdf0e10cSrcweir draw page's display mode. 327*cdf0e10cSrcweir */ 328*cdf0e10cSrcweir ::rtl::OUString msDescription; 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir /** Name of this object. It changes according the the draw page's 331*cdf0e10cSrcweir display mode. 332*cdf0e10cSrcweir */ 333*cdf0e10cSrcweir ::rtl::OUString msName; 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir /// client id in the AccessibleEventNotifier queue 336*cdf0e10cSrcweir sal_uInt32 mnClientId; 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir /** This is the role of this object. 339*cdf0e10cSrcweir */ 340*cdf0e10cSrcweir sal_Int16 maRole; 341*cdf0e10cSrcweir }; 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir #endif 345