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 #include <cppuhelper/implbase9.hxx> 29 //#include <cppuhelper/implbase7.hxx> 30 #include "SlideView.hxx" 31 #include <com/sun/star/lang/XUnoTunnel.hpp> 32 #include <com/sun/star/accessibility/XAccessible.hpp> 33 #include <com/sun/star/accessibility/XAccessibleContext.hpp> 34 #include <com/sun/star/accessibility/XAccessibleComponent.hpp> 35 #include <com/sun/star/accessibility/XAccessibleSelection.hpp> 36 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> 37 #include <com/sun/star/lang/XServiceInfo.hpp> 38 39 #include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> 40 #include <vector> 41 42 class SdDrawDocument; 43 class AccessibleSlideView; 44 45 namespace sd { 46 class SlideView; 47 class Window; 48 } 49 50 // ----------------------------- 51 // - AccessibleSlideViewObject - 52 // ----------------------------- 53 54 class AccessibleSlideViewObject : public ::cppu::WeakImplHelper6< 55 ::com::sun::star::lang::XUnoTunnel, 56 ::com::sun::star::accessibility::XAccessible, 57 ::com::sun::star::accessibility::XAccessibleEventBroadcaster, 58 ::com::sun::star::accessibility::XAccessibleContext, 59 ::com::sun::star::accessibility::XAccessibleComponent, 60 ::com::sun::star::lang::XServiceInfo > 61 { 62 private: 63 64 ::osl::Mutex maMutex; 65 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > mxParent; 66 AccessibleSlideView* mpManager; 67 /// client id in the AccessibleEventNotifier queue 68 sal_uInt32 mnClientId; 69 sal_uInt16 mnPage; 70 sal_Bool mbVisible; 71 sal_Bool mbValid; 72 73 private: 74 75 // Misc 76 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); 77 78 // XUnoTunnel 79 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException ); 80 81 // XAccessible 82 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException); 83 84 // XAccessibleEventBroadcaster 85 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 86 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 87 88 // XAccessibleContext 89 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); 90 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); 91 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException); 92 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException); 93 virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException); 94 virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException); 95 virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException); 96 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException); 97 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException); 98 virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException); 99 100 // XAccessibleComponent 101 virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); 102 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); 103 virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException); 104 virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException); 105 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException); 106 virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException); 107 virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException); 108 109 virtual sal_Int32 SAL_CALL getForeground (void) 110 throw (::com::sun::star::uno::RuntimeException); 111 112 virtual sal_Int32 SAL_CALL getBackground (void) 113 throw (::com::sun::star::uno::RuntimeException); 114 115 //===== XServiceInfo ==================================================== 116 117 /** Returns an identifier for the implementation of this object. 118 */ 119 virtual ::rtl::OUString SAL_CALL 120 getImplementationName (void) 121 throw (::com::sun::star::uno::RuntimeException); 122 123 /** Return whether the specified service is supported by this class. 124 */ 125 virtual sal_Bool SAL_CALL 126 supportsService (const ::rtl::OUString& sServiceName) 127 throw (::com::sun::star::uno::RuntimeException); 128 129 /** Returns a list of all supported services. 130 */ 131 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 132 getSupportedServiceNames (void) 133 throw (::com::sun::star::uno::RuntimeException); 134 135 public: 136 137 static AccessibleSlideViewObject* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw(); 138 139 public: 140 141 AccessibleSlideViewObject( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxParent, sal_uInt16 nPage, sal_Bool bVisible ); 142 ~AccessibleSlideViewObject(); 143 144 void FireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue ); 145 146 /** This method acts like a dispose call. It sends a disposing to all 147 of its listeners. It may be called twice. 148 */ 149 void Destroyed (void); 150 GetPageNum() const151 sal_uInt16 GetPageNum() const { return mnPage; } 152 153 void SetVisible( sal_Bool bVisible ); 154 sal_Bool IsVisible() const; 155 }; 156 157 // ----------------------- 158 // - AccessibleSlideView - 159 // ----------------------- 160 161 class AccessibleSlideView : public ::cppu::WeakImplHelper9< 162 ::com::sun::star::lang::XUnoTunnel, 163 ::com::sun::star::accessibility::XAccessible, 164 ::com::sun::star::accessibility::XAccessibleEventBroadcaster, 165 ::com::sun::star::accessibility::XAccessibleContext, 166 ::com::sun::star::accessibility::XAccessibleComponent, 167 ::com::sun::star::accessibility::XAccessibleSelection, 168 ::com::sun::star::lang::XServiceInfo 169 ,::com::sun::star::accessibility::XAccessibleExtendedAttributes 170 ,::com::sun::star::awt::XFocusListener > 171 { 172 public: 173 174 static AccessibleSlideView* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw(); 175 176 AccessibleSlideView( 177 SdDrawDocument& rDoc, 178 ::sd::SlideView& rView, 179 ::sd::Window& rParentWindow); 180 virtual ~AccessibleSlideView (void); 181 182 void FireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue ); 183 184 /** This method acts like a dispose call. It sends a disposing to all 185 of its listeners. It may be called twice. 186 */ 187 void Destroyed (void); 188 GetDrawDocument() const189 SdDrawDocument* GetDrawDocument() const { return mpDoc; } GetSlideView() const190 ::sd::SlideView* GetSlideView() const { return mpView; } GetParentWindow() const191 ::sd::Window* GetParentWindow() const { return mpParentWindow; } 192 193 void SetPageVisible( sal_uInt16 nPage, sal_Bool bVisible ); 194 void Reset(); 195 void FocusHasChanged( sal_uInt16 nOldFocusPage, sal_uInt16 nNewFocusPage ); 196 void SelectionHasChanged (sal_uInt16 nPage, sal_Bool bSelect ); 197 //===== XFocusListener ================================================= 198 virtual void SAL_CALL focusGained (const ::com::sun::star::awt::FocusEvent& e) 199 throw (::com::sun::star::uno::RuntimeException); 200 virtual void SAL_CALL focusLost (const ::com::sun::star::awt::FocusEvent& e) 201 throw (::com::sun::star::uno::RuntimeException); 202 //===== lang::XEventListener ============================================ 203 virtual void SAL_CALL disposing (const struct com::sun::star::lang::EventObject &) throw (::com::sun::star::uno::RuntimeException); 204 // This method is called from the component helper base class while disposing. 205 virtual void SAL_CALL disposing (void); 206 private: 207 ::osl::Mutex maMutex; 208 ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > > maSlidePageObjects; 209 SdDrawDocument* mpDoc; 210 ::sd::SlideView* mpView; 211 ::sd::Window* mpParentWindow; 212 /// client id in the AccessibleEventNotifier queue 213 sal_uInt32 mnClientId; 214 sal_uInt32 nFocusPageIndex; 215 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> mxWindow; 216 217 // internal 218 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId(); 219 sal_Int32 ImplGetVisibleChildCount() const; 220 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ImplGetVisibleChild( sal_Int32 nVisibleChild ) const; 221 222 // XUnoTunnel 223 virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException ); 224 225 // XAccessible 226 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException); 227 228 // XAccessibleEventBroadcaster 229 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 230 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 231 232 // XAccessibleContext 233 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); 234 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); 235 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) throw (::com::sun::star::uno::RuntimeException); 236 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) throw (::com::sun::star::uno::RuntimeException); 237 virtual sal_Int16 SAL_CALL getAccessibleRole( ) throw (::com::sun::star::uno::RuntimeException); 238 virtual ::rtl::OUString SAL_CALL getAccessibleDescription( ) throw (::com::sun::star::uno::RuntimeException); 239 virtual ::rtl::OUString SAL_CALL getAccessibleName( ) throw (::com::sun::star::uno::RuntimeException); 240 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException); 241 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) throw (::com::sun::star::uno::RuntimeException); 242 virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException); 243 244 // XAccessibleComponent 245 virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); 246 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); 247 virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( ) throw (::com::sun::star::uno::RuntimeException); 248 virtual ::com::sun::star::awt::Point SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException); 249 virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( ) throw (::com::sun::star::uno::RuntimeException); 250 virtual ::com::sun::star::awt::Size SAL_CALL getSize( ) throw (::com::sun::star::uno::RuntimeException); 251 virtual void SAL_CALL grabFocus( ) throw (::com::sun::star::uno::RuntimeException); 252 253 virtual sal_Int32 SAL_CALL getForeground (void) 254 throw (::com::sun::star::uno::RuntimeException); 255 256 virtual sal_Int32 SAL_CALL getBackground (void) 257 throw (::com::sun::star::uno::RuntimeException); 258 259 // XAccessibleSelection 260 virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 261 virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 262 virtual void SAL_CALL clearAccessibleSelection( ) throw (::com::sun::star::uno::RuntimeException); 263 virtual void SAL_CALL selectAllAccessibleChildren( ) throw (::com::sun::star::uno::RuntimeException); 264 virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) throw (::com::sun::star::uno::RuntimeException); 265 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); 266 virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); 267 268 //===== XServiceInfo ==================================================== 269 270 //----------------------------xAttribute---------------------------- 271 virtual com::sun::star::uno::Any SAL_CALL getExtendedAttributes() 272 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; 273 /** Returns an identifier for the implementation of this object. 274 */ 275 virtual ::rtl::OUString SAL_CALL 276 getImplementationName (void) 277 throw (::com::sun::star::uno::RuntimeException); 278 279 /** Return whether the specified service is supported by this class. 280 */ 281 virtual sal_Bool SAL_CALL 282 supportsService (const ::rtl::OUString& sServiceName) 283 throw (::com::sun::star::uno::RuntimeException); 284 285 /** Returns a list of all supported services. 286 */ 287 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 288 getSupportedServiceNames (void) 289 throw (::com::sun::star::uno::RuntimeException); 290 291 }; 292 293 #endif 294