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