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 #ifndef SD_ACCESSIBILITY_ACCESSIBLE_BASE_HXX 29*cdf0e10cSrcweir #define SD_ACCESSIBILITY_ACCESSIBLE_BASE_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "MutexOwner.hxx" 32*cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx> 33*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleContext.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleComponent.hpp> 36*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> 37*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/awt/XFocusListener.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/document/XEventListener.hpp> 43*cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 44*cdf0e10cSrcweir #include <tools/link.hxx> 45*cdf0e10cSrcweir #include <rtl/ref.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir class VclWindowEvent; 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir namespace sd { namespace toolpanel { 50*cdf0e10cSrcweir class TreeNode; 51*cdf0e10cSrcweir class TreeNodeStateChangeEvent; 52*cdf0e10cSrcweir } } 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir namespace utl { 56*cdf0e10cSrcweir class AccessibleStateSetHelper; 57*cdf0e10cSrcweir } 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir namespace accessibility { 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir class AccessibleSlideSorterObject; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper5< 65*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible, 66*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleEventBroadcaster, 67*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleContext, 68*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleComponent, 69*cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo 70*cdf0e10cSrcweir > AccessibleTreeNodeBase; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir /** This class makes objects based on the sd::toolpanel::TreeNode 73*cdf0e10cSrcweir accessible. 74*cdf0e10cSrcweir */ 75*cdf0e10cSrcweir class AccessibleTreeNode 76*cdf0e10cSrcweir : public ::sd::MutexOwner, 77*cdf0e10cSrcweir public AccessibleTreeNodeBase 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir public: 80*cdf0e10cSrcweir /** Create a new object for the given tree node. The accessible parent 81*cdf0e10cSrcweir is taken from the window returned by GetAccessibleParent() when 82*cdf0e10cSrcweir called at the window of the node. 83*cdf0e10cSrcweir @param rNode 84*cdf0e10cSrcweir The TreeNode to make accessible. 85*cdf0e10cSrcweir @param rsName 86*cdf0e10cSrcweir The accessible name that will be returned by getAccessibleName(). 87*cdf0e10cSrcweir @param rsDescription 88*cdf0e10cSrcweir The accessible description that will be returned by 89*cdf0e10cSrcweir getAccessibleDescription(). 90*cdf0e10cSrcweir @param eRole 91*cdf0e10cSrcweir The role that will be returned by getAccessibleRole(). 92*cdf0e10cSrcweir */ 93*cdf0e10cSrcweir AccessibleTreeNode( 94*cdf0e10cSrcweir ::sd::toolpanel::TreeNode& rNode, 95*cdf0e10cSrcweir const ::rtl::OUString& rsName, 96*cdf0e10cSrcweir const ::rtl::OUString& rsDescription, 97*cdf0e10cSrcweir sal_Int16 eRole); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir void FireAccessibleEvent ( 100*cdf0e10cSrcweir short nEventId, 101*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rOldValue, 102*cdf0e10cSrcweir const ::com::sun::star::uno::Any& rNewValue); 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir virtual void SAL_CALL disposing (void); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir //===== XAccessible ======================================================= 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 109*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL 110*cdf0e10cSrcweir getAccessibleContext (void) 111*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir //===== XAccessibleEventBroadcaster ======================================= 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir virtual void SAL_CALL 117*cdf0e10cSrcweir addEventListener( 118*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 119*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener) 120*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir virtual void SAL_CALL 123*cdf0e10cSrcweir removeEventListener( 124*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 125*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleEventListener >& rxListener ) 126*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir using cppu::WeakComponentImplHelperBase::addEventListener; 129*cdf0e10cSrcweir using cppu::WeakComponentImplHelperBase::removeEventListener; 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir //===== XAccessibleContext ============================================== 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir /// Return the number of currently visible children. 134*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 135*cdf0e10cSrcweir getAccessibleChildCount (void) throw (::com::sun::star::uno::RuntimeException); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir /// Return the specified child or throw exception. 138*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL 139*cdf0e10cSrcweir getAccessibleChild (sal_Int32 nIndex) 140*cdf0e10cSrcweir throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir /// Return a reference to the parent. 143*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL 144*cdf0e10cSrcweir getAccessibleParent (void) 145*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir /// Return this objects index among the parents children. 148*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 149*cdf0e10cSrcweir getAccessibleIndexInParent (void) 150*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir /// Return this object's role. 153*cdf0e10cSrcweir virtual sal_Int16 SAL_CALL 154*cdf0e10cSrcweir getAccessibleRole (void) 155*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir /// Return this object's description. 158*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 159*cdf0e10cSrcweir getAccessibleDescription (void) 160*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir /// Return the object's current name. 163*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 164*cdf0e10cSrcweir getAccessibleName (void) 165*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir /// Return NULL to indicate that an empty relation set. 168*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 169*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL 170*cdf0e10cSrcweir getAccessibleRelationSet (void) 171*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir /// Return the set of current states. 174*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 175*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL 176*cdf0e10cSrcweir getAccessibleStateSet (void) 177*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir /** Return the parents locale or throw exception if this object has no 180*cdf0e10cSrcweir parent yet/anymore. 181*cdf0e10cSrcweir */ 182*cdf0e10cSrcweir virtual ::com::sun::star::lang::Locale SAL_CALL 183*cdf0e10cSrcweir getLocale (void) 184*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException, 185*cdf0e10cSrcweir ::com::sun::star::accessibility::IllegalAccessibleComponentStateException); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir //===== XAccessibleComponent ================================================ 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir virtual sal_Bool SAL_CALL containsPoint ( 190*cdf0e10cSrcweir const ::com::sun::star::awt::Point& aPoint) 191*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< 194*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible > SAL_CALL 195*cdf0e10cSrcweir getAccessibleAtPoint ( 196*cdf0e10cSrcweir const ::com::sun::star::awt::Point& aPoint) 197*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds (void) 200*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir virtual ::com::sun::star::awt::Point SAL_CALL getLocation (void) 203*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen (void) 206*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir virtual ::com::sun::star::awt::Size SAL_CALL getSize (void) 209*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir virtual void SAL_CALL grabFocus (void) 212*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getForeground (void) 215*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getBackground (void) 218*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir //===== XServiceInfo ==================================================== 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir /** Returns an identifier for the implementation of this object. 224*cdf0e10cSrcweir */ 225*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL 226*cdf0e10cSrcweir getImplementationName (void) 227*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir /** Return whether the specified service is supported by this class. 230*cdf0e10cSrcweir */ 231*cdf0e10cSrcweir virtual sal_Bool SAL_CALL 232*cdf0e10cSrcweir supportsService (const ::rtl::OUString& sServiceName) 233*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir /** Returns a list of all supported services. 236*cdf0e10cSrcweir */ 237*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 238*cdf0e10cSrcweir getSupportedServiceNames (void) 239*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir 242*cdf0e10cSrcweir protected: 243*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 244*cdf0e10cSrcweir ::com::sun::star::accessibility::XAccessible> mxParent; 245*cdf0e10cSrcweir ::sd::toolpanel::TreeNode& mrTreeNode; 246*cdf0e10cSrcweir ::rtl::Reference< ::utl::AccessibleStateSetHelper> mrStateSet; 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir const ::rtl::OUString msName; 249*cdf0e10cSrcweir const ::rtl::OUString msDescription; 250*cdf0e10cSrcweir const sal_Int16 meRole; 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir virtual ~AccessibleTreeNode (void); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir /** Check whether or not the object has been disposed (or is in the 255*cdf0e10cSrcweir state of beeing disposed). If that is the case then 256*cdf0e10cSrcweir DisposedException is thrown to inform the (indirect) caller of the 257*cdf0e10cSrcweir foul deed. 258*cdf0e10cSrcweir */ 259*cdf0e10cSrcweir void ThrowIfDisposed (void) 260*cdf0e10cSrcweir throw (::com::sun::star::lang::DisposedException); 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir /** Check whether or not the object has been disposed (or is in the 263*cdf0e10cSrcweir state of beeing disposed). 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir @return sal_True, if the object is disposed or in the course 266*cdf0e10cSrcweir of being disposed. Otherwise, sal_False is returned. 267*cdf0e10cSrcweir */ 268*cdf0e10cSrcweir sal_Bool IsDisposed (void); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir /** Update the mpStateSet member to reflect the current state of the 271*cdf0e10cSrcweir TreeNode. When one of the states has changed since the last call 272*cdf0e10cSrcweir then an appropriate event is sent. 273*cdf0e10cSrcweir */ 274*cdf0e10cSrcweir virtual void UpdateStateSet (void); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir /** Update a single state and sent an event if its value changes. 277*cdf0e10cSrcweir */ 278*cdf0e10cSrcweir void UpdateState( 279*cdf0e10cSrcweir sal_Int16 aState, 280*cdf0e10cSrcweir bool bValue); 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir DECL_LINK(StateChangeListener, ::sd::toolpanel::TreeNodeStateChangeEvent*); 283*cdf0e10cSrcweir DECL_LINK(WindowEventListener, VclWindowEvent*); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir private: 286*cdf0e10cSrcweir sal_uInt32 mnClientId; 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir /// The common part of the constructor. 289*cdf0e10cSrcweir void CommonConstructor (void); 290*cdf0e10cSrcweir }; 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir } // end of namespace ::accessibility 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir #endif 295