1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SD_ACCESSIBILITY_ACCESSIBLE_SLIDE_VIEW_HXX 25 #define SD_ACCESSIBILITY_ACCESSIBLE_SLIDE_VIEW_HXX 26 27 #include <cppuhelper/implbase6.hxx> 28 //IAccessibility2 Implementation 2009----- 29 #include <cppuhelper/implbase9.hxx> 30 //#include <cppuhelper/implbase7.hxx> 31 //-----IAccessibility2 Implementation 2009 32 #include "SlideView.hxx" 33 #include <com/sun/star/lang/XUnoTunnel.hpp> 34 #include <com/sun/star/accessibility/XAccessible.hpp> 35 #include <com/sun/star/accessibility/XAccessibleContext.hpp> 36 #include <com/sun/star/accessibility/XAccessibleComponent.hpp> 37 #include <com/sun/star/accessibility/XAccessibleSelection.hpp> 38 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> 39 #include <com/sun/star/lang/XServiceInfo.hpp> 40 41 //IAccessibility2 Implementation 2009----- 42 #include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> 43 //-----IAccessibility2 Implementation 2009 44 #include <vector> 45 46 class SdDrawDocument; 47 class AccessibleSlideView; 48 49 namespace sd { 50 class SlideView; 51 class Window; 52 } 53 54 // ----------------------------- 55 // - AccessibleSlideViewObject - 56 // ----------------------------- 57 58 class AccessibleSlideViewObject : public ::cppu::WeakImplHelper6< 59 ::com::sun::star::lang::XUnoTunnel, 60 ::com::sun::star::accessibility::XAccessible, 61 ::com::sun::star::accessibility::XAccessibleEventBroadcaster, 62 ::com::sun::star::accessibility::XAccessibleContext, 63 ::com::sun::star::accessibility::XAccessibleComponent, 64 ::com::sun::star::lang::XServiceInfo > 65 { 66 private: 67 68 ::osl::Mutex maMutex; 69 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxParent; 70 AccessibleSlideView* mpManager; 71 /// client id in the AccessibleEventNotifier queue 72 sal_uInt32 mnClientId; 73 sal_uInt16 mnPage; 74 sal_Bool mbVisible; 75 sal_Bool mbValid; 76 77 private: 78 79 // Misc 80 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); 81 82 // XUnoTunnel 83 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException ); 84 85 // XAccessible 86 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException); 87 88 // XAccessibleEventBroadcaster 89 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 90 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 91 92 // XAccessibleContext 93 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); 94 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 95 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException); 96 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException); 97 virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException); 98 virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException); 99 virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException); 100 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException); 101 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException); 102 virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException); 103 104 // XAccessibleComponent 105 virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); 106 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); 107 virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException); 108 virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException); 109 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException); 110 virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException); 111 virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException); 112 113 virtual sal_Int32 SAL_CALL getForeground (void) 114 throw (::com::sun::star::uno::RuntimeException); 115 116 virtual sal_Int32 SAL_CALL getBackground (void) 117 throw (::com::sun::star::uno::RuntimeException); 118 119 //===== XServiceInfo ==================================================== 120 121 /** Returns an identifier for the implementation of this object. 122 */ 123 virtual ::rtl::OUString SAL_CALL 124 getImplementationName (void) 125 throw (::com::sun::star::uno::RuntimeException); 126 127 /** Return whether the specified service is supported by this class. 128 */ 129 virtual sal_Bool SAL_CALL 130 supportsService (const ::rtl::OUString& sServiceName) 131 throw (::com::sun::star::uno::RuntimeException); 132 133 /** Returns a list of all supported services. 134 */ 135 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 136 getSupportedServiceNames (void) 137 throw (::com::sun::star::uno::RuntimeException); 138 139 public: 140 141 static AccessibleSlideViewObject* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw(); 142 143 public: 144 145 AccessibleSlideViewObject( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxParent, sal_uInt16 nPage, sal_Bool bVisible ); 146 ~AccessibleSlideViewObject(); 147 148 void FireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue ); 149 150 /** This method acts like a dispose call. It sends a disposing to all 151 of its listeners. It may be called twice. 152 */ 153 void Destroyed (void); 154 155 sal_uInt16 GetPageNum() const { return mnPage; } 156 157 void SetVisible( sal_Bool bVisible ); 158 sal_Bool IsVisible() const; 159 }; 160 161 // ----------------------- 162 // - AccessibleSlideView - 163 // ----------------------- 164 165 class AccessibleSlideView : public ::cppu::WeakImplHelper9< 166 ::com::sun::star::lang::XUnoTunnel, 167 ::com::sun::star::accessibility::XAccessible, 168 ::com::sun::star::accessibility::XAccessibleEventBroadcaster, 169 ::com::sun::star::accessibility::XAccessibleContext, 170 ::com::sun::star::accessibility::XAccessibleComponent, 171 ::com::sun::star::accessibility::XAccessibleSelection, 172 ::com::sun::star::lang::XServiceInfo 173 //IAccessibility2 Implementation 2009----- 174 ,::com::sun::star::accessibility::XAccessibleExtendedAttributes 175 ,::com::sun::star::awt::XFocusListener > 176 //-----IAccessibility2 Implementation 2009 177 { 178 public: 179 180 static AccessibleSlideView* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw(); 181 182 AccessibleSlideView( 183 SdDrawDocument& rDoc, 184 ::sd::SlideView& rView, 185 ::sd::Window& rParentWindow); 186 virtual ~AccessibleSlideView (void); 187 188 void FireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue ); 189 190 /** This method acts like a dispose call. It sends a disposing to all 191 of its listeners. It may be called twice. 192 */ 193 void Destroyed (void); 194 195 SdDrawDocument* GetDrawDocument() const { return mpDoc; } 196 ::sd::SlideView* GetSlideView() const { return mpView; } 197 ::sd::Window* GetParentWindow() const { return mpParentWindow; } 198 199 void SetPageVisible( sal_uInt16 nPage, sal_Bool bVisible ); 200 void Reset(); 201 void FocusHasChanged( sal_uInt16 nOldFocusPage, sal_uInt16 nNewFocusPage ); 202 //IAccessibility2 Implementation 2009----- 203 void SelectionHasChanged (sal_uInt16 nPage, sal_Bool bSelect ); 204 //===== XFocusListener ================================================= 205 virtual void SAL_CALL focusGained (const ::com::sun::star::awt::FocusEvent& e) 206 throw (::com::sun::star::uno::RuntimeException); 207 virtual void SAL_CALL focusLost (const ::com::sun::star::awt::FocusEvent& e) 208 throw (::com::sun::star::uno::RuntimeException); 209 //===== lang::XEventListener ============================================ 210 virtual void SAL_CALL disposing (const struct com::sun::star::lang::EventObject &) throw (::com::sun::star::uno::RuntimeException); 211 // This method is called from the component helper base class while disposing. 212 virtual void SAL_CALL disposing (void); 213 //-----IAccessibility2 Implementation 2009 214 private: 215 ::osl::Mutex maMutex; 216 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > > maSlidePageObjects; 217 SdDrawDocument* mpDoc; 218 ::sd::SlideView* mpView; 219 ::sd::Window* mpParentWindow; 220 /// client id in the AccessibleEventNotifier queue 221 sal_uInt32 mnClientId; 222 //IAccessibility2 Implementation 2009----- 223 sal_uInt32 nFocusPageIndex; 224 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> mxWindow; 225 //-----IAccessibility2 Implementation 2009 226 227 // internal 228 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); 229 sal_Int32 ImplGetVisibleChildCount() const; 230 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ImplGetVisibleChild( sal_Int32 nVisibleChild ) const; 231 232 // XUnoTunnel 233 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException ); 234 235 // XAccessible 236 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException); 237 238 // XAccessibleEventBroadcaster 239 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 240 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 241 242 // XAccessibleContext 243 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); 244 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 245 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException); 246 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException); 247 virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException); 248 virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException); 249 virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException); 250 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException); 251 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException); 252 virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException); 253 254 // XAccessibleComponent 255 virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); 256 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); 257 virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException); 258 virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException); 259 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException); 260 virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException); 261 virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException); 262 263 virtual sal_Int32 SAL_CALL getForeground (void) 264 throw (::com::sun::star::uno::RuntimeException); 265 266 virtual sal_Int32 SAL_CALL getBackground (void) 267 throw (::com::sun::star::uno::RuntimeException); 268 269 // XAccessibleSelection 270 virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 271 virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 272 virtual void SAL_CALL clearAccessibleSelection( ) throw (::com::sun::star::uno::RuntimeException); 273 virtual void SAL_CALL selectAllAccessibleChildren( ) throw (::com::sun::star::uno::RuntimeException); 274 virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); 275 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 276 virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 277 278 //===== XServiceInfo ==================================================== 279 280 //IAccessibility2 Implementation 2009----- 281 //----------------------------xAttribute---------------------------- 282 virtual com::sun::star::uno::Any SAL_CALL getExtendedAttributes() 283 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; 284 //-----IAccessibility2 Implementation 2009 285 /** Returns an identifier for the implementation of this object. 286 */ 287 virtual ::rtl::OUString SAL_CALL 288 getImplementationName (void) 289 throw (::com::sun::star::uno::RuntimeException); 290 291 /** Return whether the specified service is supported by this class. 292 */ 293 virtual sal_Bool SAL_CALL 294 supportsService (const ::rtl::OUString& sServiceName) 295 throw (::com::sun::star::uno::RuntimeException); 296 297 /** Returns a list of all supported services. 298 */ 299 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 300 getSupportedServiceNames (void) 301 throw (::com::sun::star::uno::RuntimeException); 302 303 }; 304 305 #endif 306