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 25 #ifndef _SC_ACCESSIBLEDOCUMENT_HXX 26 #define _SC_ACCESSIBLEDOCUMENT_HXX 27 28 #include "AccessibleDocumentBase.hxx" 29 #include "viewdata.hxx" 30 #include <com/sun/star/accessibility/XAccessibleSelection.hpp> 31 #include <com/sun/star/view/XSelectionChangeListener.hpp> 32 #include <cppuhelper/implbase3.hxx> 33 #include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> 34 #include <com/sun/star/accessibility/XAccessibleGetAccFlowTo.hpp> 35 #include <svx/IAccessibleViewForwarder.hxx> 36 37 class ScTabViewShell; 38 class ScAccessibleSpreadsheet; 39 class ScChildrenShapes; 40 class ScAccessibleEditObject; 41 42 namespace accessibility 43 { 44 class AccessibleShape; 45 } 46 namespace utl 47 { 48 class AccessibleRelationSetHelper; 49 } 50 51 /** @descr 52 This base class provides an implementation of the 53 <code>AccessibleContext</code> service. 54 */ 55 56 typedef cppu::ImplHelper3< ::com::sun::star::accessibility::XAccessibleSelection, 57 ::com::sun::star::accessibility::XAccessibleExtendedAttributes, 58 ::com::sun::star::view::XSelectionChangeListener > 59 ScAccessibleDocumentImpl; 60 61 class ScAccessibleDocument 62 : public ScAccessibleDocumentBase, 63 public ScAccessibleDocumentImpl, 64 public com::sun::star::accessibility::XAccessibleGetAccFlowTo, 65 public accessibility::IAccessibleViewForwarder 66 { 67 public: 68 //===== internal ======================================================== 69 ScAccessibleDocument( 70 const ::com::sun::star::uno::Reference< 71 ::com::sun::star::accessibility::XAccessible>& rxParent, 72 ScTabViewShell* pViewShell, 73 ScSplitPos eSplitPos); 74 75 virtual void Init(); 76 77 78 DECL_LINK( WindowChildEventListener, VclSimpleEvent* ); 79 protected: 80 virtual ~ScAccessibleDocument(void); 81 82 using ScAccessibleDocumentBase::IsDefunc; 83 84 public: 85 86 virtual void SAL_CALL disposing(); 87 88 ///===== SfxListener ===================================================== 89 90 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 91 92 ///===== XInterface ===================================================== 93 94 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 95 ::com::sun::star::uno::Type const & rType ) 96 throw (::com::sun::star::uno::RuntimeException); 97 98 virtual void SAL_CALL acquire() throw (); 99 100 virtual void SAL_CALL release() throw (); 101 102 ///===== XAccessibleComponent ============================================ 103 104 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 105 SAL_CALL getAccessibleAtPoint( 106 const ::com::sun::star::awt::Point& rPoint ) 107 throw (::com::sun::star::uno::RuntimeException); 108 109 virtual void SAL_CALL grabFocus( ) 110 throw (::com::sun::star::uno::RuntimeException); 111 112 ///===== XAccessibleContext ============================================== 113 114 /// Return the number of currently visible children. 115 virtual sal_Int32 SAL_CALL 116 getAccessibleChildCount(void) 117 throw (::com::sun::star::uno::RuntimeException); 118 119 /// Return the specified child or NULL if index is invalid. 120 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL 121 getAccessibleChild(sal_Int32 nIndex) 122 throw (::com::sun::star::uno::RuntimeException, 123 ::com::sun::star::lang::IndexOutOfBoundsException); 124 125 /// Return the set of current states. 126 virtual ::com::sun::star::uno::Reference< 127 ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL 128 getAccessibleStateSet(void) 129 throw (::com::sun::star::uno::RuntimeException); 130 131 virtual ::rtl::OUString SAL_CALL 132 getAccessibleName(void) 133 throw (::com::sun::star::uno::RuntimeException); 134 135 virtual ::com::sun::star::uno::Any SAL_CALL getExtendedAttributes() 136 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ; 137 ///===== XAccessibleSelection =========================================== 138 139 virtual void SAL_CALL 140 selectAccessibleChild( sal_Int32 nChildIndex ) 141 throw (::com::sun::star::lang::IndexOutOfBoundsException, 142 ::com::sun::star::uno::RuntimeException); 143 144 virtual sal_Bool SAL_CALL 145 isAccessibleChildSelected( sal_Int32 nChildIndex ) 146 throw (::com::sun::star::lang::IndexOutOfBoundsException, 147 ::com::sun::star::uno::RuntimeException); 148 149 virtual void SAL_CALL 150 clearAccessibleSelection( ) 151 throw (::com::sun::star::uno::RuntimeException); 152 153 virtual void SAL_CALL 154 selectAllAccessibleChildren( ) 155 throw (::com::sun::star::uno::RuntimeException); 156 157 virtual sal_Int32 SAL_CALL 158 getSelectedAccessibleChildCount( ) 159 throw (::com::sun::star::uno::RuntimeException); 160 161 virtual ::com::sun::star::uno::Reference< 162 ::com::sun::star::accessibility::XAccessible > SAL_CALL 163 getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) 164 throw (::com::sun::star::lang::IndexOutOfBoundsException, 165 ::com::sun::star::uno::RuntimeException); 166 167 virtual void SAL_CALL 168 deselectAccessibleChild( sal_Int32 nChildIndex ) 169 throw (::com::sun::star::lang::IndexOutOfBoundsException, 170 ::com::sun::star::uno::RuntimeException); 171 172 ///===== XSelectionListener ============================================= 173 174 virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent ) 175 throw (::com::sun::star::uno::RuntimeException); 176 177 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) 178 throw (::com::sun::star::uno::RuntimeException); 179 180 ///===== XServiceInfo =================================================== 181 182 /** Returns an identifier for the implementation of this object. 183 */ 184 virtual ::rtl::OUString SAL_CALL 185 getImplementationName(void) 186 throw (::com::sun::star::uno::RuntimeException); 187 188 /** Returns a list of all supported services. 189 */ 190 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 191 getSupportedServiceNames(void) 192 throw (::com::sun::star::uno::RuntimeException); 193 194 ///===== XTypeProvider =================================================== 195 196 /// returns the possible types 197 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL 198 getTypes() 199 throw (::com::sun::star::uno::RuntimeException); 200 201 /** Returns a implementation id. 202 */ 203 virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL 204 getImplementationId(void) 205 throw (::com::sun::star::uno::RuntimeException); 206 207 ///===== IAccessibleViewForwarder ======================================== 208 209 /** This method informs you about the state of the forwarder. Do not 210 use it when the returned value is <false/>. 211 212 @return 213 Return <true/> if the view forwarder is valid and <false/> else. 214 */ 215 virtual sal_Bool IsValid (void) const; 216 217 /** Returns the area of the underlying document that is visible in the 218 * corresponding window. 219 220 @return 221 The rectangle of the visible part of the document. The values 222 are, contrary to the base class, in internal coordinates. 223 */ 224 virtual Rectangle GetVisibleArea() const; 225 226 /** Transform the specified point from internal coordinates to an 227 absolute screen position. 228 229 @param rPoint 230 Point in internal coordinates. 231 232 @return 233 The same point but in screen coordinates relative to the upper 234 left corner of the (current) screen. 235 */ 236 virtual Point LogicToPixel (const Point& rPoint) const; 237 238 /** Transform the specified size from internal coordinates to a screen 239 * oriented pixel size. 240 241 @param rSize 242 Size in internal coordinates. 243 244 @return 245 The same size but in screen coordinates. 246 */ 247 virtual Size LogicToPixel (const Size& rSize) const; 248 249 /** Transform the specified point from absolute screen coordinates to 250 internal coordinates. 251 252 @param rPoint 253 Point in screen coordinates relative to the upper left corner of 254 the (current) screen. 255 256 @return 257 The same point but in internal coordinates. 258 */ 259 virtual Point PixelToLogic (const Point& rPoint) const; 260 261 /** Transform the specified size from screen coordinates to internal 262 coordinates. 263 264 @param rSize 265 Size in screen coordinates. 266 267 @return 268 The same size but in internal coordinates. 269 */ 270 virtual Size PixelToLogic (const Size& rSize) const; 271 272 ///======== internal ===================================================== 273 274 utl::AccessibleRelationSetHelper* GetRelationSet(const ScAddress* pAddress) const; 275 276 ::com::sun::star::uno::Reference 277 < ::com::sun::star::accessibility::XAccessible > 278 GetAccessibleSpreadsheet(); 279 280 protected: 281 /// Return this object's description. 282 virtual ::rtl::OUString SAL_CALL 283 createAccessibleDescription(void) 284 throw (::com::sun::star::uno::RuntimeException); 285 286 /// Return the object's current name. 287 virtual ::rtl::OUString SAL_CALL 288 createAccessibleName(void) 289 throw (::com::sun::star::uno::RuntimeException); 290 291 /// Return the object's current bounding box relative to the desktop. 292 virtual Rectangle GetBoundingBoxOnScreen(void) const 293 throw (::com::sun::star::uno::RuntimeException); 294 295 /// Return the object's current bounding box relative to the parent object. 296 virtual Rectangle GetBoundingBox(void) const 297 throw (::com::sun::star::uno::RuntimeException); 298 299 private: 300 ScTabViewShell* mpViewShell; 301 ScSplitPos meSplitPos; 302 ScAccessibleSpreadsheet* mpAccessibleSpreadsheet; 303 ScChildrenShapes* mpChildrenShapes; 304 ScAccessibleEditObject* mpTempAccEdit; 305 com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> mxTempAcc; 306 Rectangle maVisArea; 307 sal_Bool mbCompleteSheetSelected; 308 309 public: 310 SCTAB getVisibleTable() const; // use it in ScChildrenShapes 311 312 private: 313 void FreeAccessibleSpreadsheet(); 314 315 sal_Bool IsTableSelected() const; 316 317 sal_Bool IsDefunc( 318 const com::sun::star::uno::Reference< 319 ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates); 320 sal_Bool IsEditable( 321 const com::sun::star::uno::Reference< 322 ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates); 323 324 void AddChild(const com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>& xAcc, sal_Bool bFireEvent); 325 void RemoveChild(const com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>& xAcc, sal_Bool bFireEvent); 326 327 rtl::OUString GetCurrentCellName() const; 328 rtl::OUString GetCurrentCellDescription() const; 329 330 Rectangle GetVisibleArea_Impl() const; 331 com::sun::star::uno::Sequence< com::sun::star::uno::Any > GetScAccFlowToSequence(); 332 public: 333 ScDocument *GetDocument() const ; 334 ScAddress GetCurCellAddress() const; 335 //===== XAccessibleGetAccFromXShape ============================================ 336 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > 337 SAL_CALL get_AccFlowTo(const ::com::sun::star::uno::Any& rAny, sal_Int32 nType) 338 throw ( ::com::sun::star::uno::RuntimeException ); 339 340 virtual sal_Int32 SAL_CALL getForeground( ) 341 throw (::com::sun::star::uno::RuntimeException); 342 343 virtual sal_Int32 SAL_CALL getBackground( ) 344 throw (::com::sun::star::uno::RuntimeException); 345 protected: 346 void SwitchViewFireFocus(); 347 }; 348 349 350 #endif 351