1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // ============================================================================ 29 30 #ifndef _SC_ACCESSIBLECSVCONTROL_HXX 31 #define _SC_ACCESSIBLECSVCONTROL_HXX 32 33 #include <com/sun/star/accessibility/XAccessibleText.hpp> 34 #include <com/sun/star/accessibility/XAccessibleTable.hpp> 35 #include <com/sun/star/accessibility/XAccessibleSelection.hpp> 36 #include <tools/gen.hxx> 37 #include <tools/string.hxx> 38 #include <rtl/ustrbuf.hxx> 39 #include <cppuhelper/implbase1.hxx> 40 #include <cppuhelper/implbase2.hxx> 41 #include <editeng/AccessibleStaticTextBase.hxx> 42 #include <comphelper/uno3.hxx> 43 #include "AccessibleContextBase.hxx" 44 45 46 // ============================================================================ 47 48 class ScCsvControl; 49 namespace utl { class AccessibleStateSetHelper; } 50 51 /** Accessible base class used for CSV controls. */ 52 class ScAccessibleCsvControl : public ScAccessibleContextBase 53 { 54 protected: 55 typedef ::com::sun::star::uno::Reference< 56 ::com::sun::star::accessibility::XAccessible > XAccessibleRef; 57 typedef ::com::sun::star::uno::Reference< 58 ::com::sun::star::accessibility::XAccessibleRelationSet > XAccessibleRelationSetRef; 59 typedef ::com::sun::star::uno::Reference< 60 ::com::sun::star::accessibility::XAccessibleStateSet > XAccessibleStateSetRef; 61 62 typedef ::com::sun::star::awt::Point AwtPoint; 63 typedef ::com::sun::star::awt::Size AwtSize; 64 typedef ::com::sun::star::awt::Rectangle AwtRectangle; 65 66 private: 67 ScCsvControl* mpControl; /// Pointer to the VCL control. 68 69 public: 70 explicit ScAccessibleCsvControl( 71 const XAccessibleRef& rxParent, 72 ScCsvControl& rControl, 73 sal_uInt16 nRole ); 74 virtual ~ScAccessibleCsvControl(); 75 76 using ScAccessibleContextBase::disposing; 77 virtual void SAL_CALL disposing(); 78 79 // XAccessibleComponent --------------------------------------------------- 80 81 /** Returns the child at the specified point (cell returns NULL). */ 82 virtual XAccessibleRef SAL_CALL getAccessibleAtPoint( const AwtPoint& rPoint ) 83 throw( ::com::sun::star::uno::RuntimeException ); 84 85 /** Returns true, if the control is visible. */ 86 virtual sal_Bool SAL_CALL isVisible() throw( ::com::sun::star::uno::RuntimeException ); 87 88 /** Sets the focus to this control. */ 89 virtual void SAL_CALL grabFocus() throw( ::com::sun::star::uno::RuntimeException ); 90 91 // events ----------------------------------------------------------------- 92 public: 93 /** Sends a GetFocus or LoseFocus event to all listeners. */ 94 virtual void SendFocusEvent( bool bFocused ); 95 /** Sends a caret changed event to all listeners. */ 96 virtual void SendCaretEvent(); 97 /** Sends a visible area changed event to all listeners. */ 98 virtual void SendVisibleEvent(); 99 /** Sends a selection changed event to all listeners. */ 100 virtual void SendSelectionEvent(); 101 /** Sends a table model changed event for changed cell contents to all listeners. */ 102 virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows ); 103 /** Sends a table model changed event for an inserted column to all listeners. */ 104 virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn ); 105 /** Sends a table model changed event for a removed column to all listeners. */ 106 virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn ); 107 108 // helpers ---------------------------------------------------------------- 109 protected: 110 /** Returns this object's current bounding box relative to the desktop. */ 111 virtual Rectangle GetBoundingBoxOnScreen() const throw( ::com::sun::star::uno::RuntimeException ); 112 /** Returns this object's current bounding box relative to the parent object. */ 113 virtual Rectangle GetBoundingBox() const throw( ::com::sun::star::uno::RuntimeException ); 114 115 /** Creates a new UUID in rSeq, if it is empty. Locks mutex internally. */ 116 void getUuid( ::com::sun::star::uno::Sequence< sal_Int8 >& rSeq ); 117 118 /** Returns whether the object is alive. Must be called with locked mutex. */ 119 inline bool implIsAlive() const { return !rBHelper.bDisposed && !rBHelper.bInDispose && mpControl; } 120 /** Throws an exception, if the object is disposed/disposing or any pointer 121 is missing. Should be used with locked mutex! */ 122 void ensureAlive() const throw( ::com::sun::star::lang::DisposedException ); 123 124 /** Returns the VCL control. Assumes a living object. */ 125 ScCsvControl& implGetControl() const; 126 127 /** Returns the first child of rxParentObj, which has the role nRole. */ 128 XAccessibleRef implGetChildByRole( const XAccessibleRef& rxParentObj, sal_uInt16 nRole ) 129 throw( ::com::sun::star::uno::RuntimeException ); 130 /** Creates a StateSetHelper and fills it with DEFUNC, OPAQUE, ENABLED, SHOWING and VISIBLE. */ 131 ::utl::AccessibleStateSetHelper* implCreateStateSet(); 132 133 /** Disposes the object. This is a helper called from destructors only. */ 134 void implDispose(); 135 136 /** Converts the control-relative position to an absolute screen position. */ 137 Point implGetAbsPos( const Point& rPos ) const; 138 }; 139 140 141 // ============================================================================ 142 143 class ScCsvRuler; 144 145 typedef ::cppu::ImplHelper1< 146 ::com::sun::star::accessibility::XAccessibleText > 147 ScAccessibleCsvRulerImpl; 148 149 /** Accessible class representing the CSV ruler control. */ 150 class ScAccessibleCsvRuler : public ScAccessibleCsvControl, public ScAccessibleCsvRulerImpl 151 { 152 protected: 153 typedef ::com::sun::star::uno::Sequence< 154 ::com::sun::star::beans::PropertyValue > PropertyValueSeq; 155 156 private: 157 ::rtl::OUStringBuffer maBuffer; /// Contains the text representation of the ruler. 158 159 public: 160 explicit ScAccessibleCsvRuler( ScCsvRuler& rRuler ); 161 virtual ~ScAccessibleCsvRuler(); 162 163 // XAccessibleComponent ----------------------------------------------------- 164 165 virtual sal_Int32 SAL_CALL getForeground( ) 166 throw (::com::sun::star::uno::RuntimeException); 167 168 virtual sal_Int32 SAL_CALL getBackground( ) 169 throw (::com::sun::star::uno::RuntimeException); 170 171 // XAccessibleContext ----------------------------------------------------- 172 173 /** Returns the child count (the ruler does not have children). */ 174 virtual sal_Int32 SAL_CALL getAccessibleChildCount() 175 throw( ::com::sun::star::uno::RuntimeException ); 176 177 /** Throws an exception (the ruler does not have childern). */ 178 virtual XAccessibleRef SAL_CALL getAccessibleChild( sal_Int32 nIndex ) 179 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 180 181 /** Returns the relation to the grid control. */ 182 virtual XAccessibleRelationSetRef SAL_CALL getAccessibleRelationSet() 183 throw( ::com::sun::star::uno::RuntimeException ); 184 185 /** Returns the current set of states. */ 186 virtual XAccessibleStateSetRef SAL_CALL getAccessibleStateSet() 187 throw( ::com::sun::star::uno::RuntimeException ); 188 189 // XAccessibleText -------------------------------------------------------- 190 191 /** Return the position of the caret. */ 192 virtual sal_Int32 SAL_CALL getCaretPosition() throw( ::com::sun::star::uno::RuntimeException ); 193 194 /** Sets the position of the caret. */ 195 virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) 196 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 197 198 /** Returns the specified character. */ 199 virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) 200 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 201 202 /** Returns the attributes of the specified character. */ 203 virtual PropertyValueSeq SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRequestedAttributes ) 204 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 205 206 /** Returns the screen coordinates of the specified character. */ 207 virtual AwtRectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) 208 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 209 210 /** Returns the count of characters. */ 211 virtual sal_Int32 SAL_CALL getCharacterCount() throw( ::com::sun::star::uno::RuntimeException ); 212 213 /** Returns the character index at the specified coordinate (object's coordinate system). */ 214 virtual sal_Int32 SAL_CALL getIndexAtPoint( const AwtPoint& rPoint ) 215 throw( ::com::sun::star::uno::RuntimeException ); 216 217 /** Returns the selected text (ruler returns empty string). */ 218 virtual ::rtl::OUString SAL_CALL getSelectedText() throw( ::com::sun::star::uno::RuntimeException ); 219 220 /** Returns the start index of the selection (ruler returns -1). */ 221 virtual sal_Int32 SAL_CALL getSelectionStart() throw( ::com::sun::star::uno::RuntimeException ); 222 223 /** Returns the end index of the selection (ruler returns -1). */ 224 virtual sal_Int32 SAL_CALL getSelectionEnd() throw( ::com::sun::star::uno::RuntimeException ); 225 226 /** Selects a part of the text (ruler does nothing). */ 227 virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) 228 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 229 230 /** Returns the entire text. */ 231 virtual ::rtl::OUString SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException ); 232 233 /** Returns the specified range [Start,End) of the text. */ 234 virtual ::rtl::OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) 235 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 236 237 /** Returns the specified text portion. */ 238 virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 239 virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 240 virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); 241 242 /** Copies the specified text range into the clipboard (ruler does nothing). */ 243 virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) 244 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 245 246 // XInterface ------------------------------------------------------------- 247 248 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType ) 249 throw( ::com::sun::star::uno::RuntimeException ); 250 251 virtual void SAL_CALL acquire() throw(); 252 253 virtual void SAL_CALL release() throw(); 254 255 // XServiceInfo ----------------------------------------------------------- 256 257 /** Returns an identifier for the implementation of this object. */ 258 virtual ::rtl::OUString SAL_CALL getImplementationName() 259 throw( ::com::sun::star::uno::RuntimeException ); 260 261 // XTypeProvider ---------------------------------------------------------- 262 263 /** Returns a sequence with all supported interface types. */ 264 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() 265 throw( ::com::sun::star::uno::RuntimeException ); 266 267 /** Returns an implementation ID. */ 268 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() 269 throw( ::com::sun::star::uno::RuntimeException ); 270 271 // events ----------------------------------------------------------------- 272 public: 273 /** Sends a caret changed event to all listeners. */ 274 virtual void SendCaretEvent(); 275 276 // helpers ---------------------------------------------------------------- 277 private: 278 /** Returns this object's name. */ 279 virtual ::rtl::OUString SAL_CALL createAccessibleName() 280 throw( ::com::sun::star::uno::RuntimeException ); 281 /** Returns this object's description. */ 282 virtual ::rtl::OUString SAL_CALL createAccessibleDescription() 283 throw( ::com::sun::star::uno::RuntimeException ); 284 285 /** Throws an exception, if the specified character position is invalid (outside 0..len-1). */ 286 void ensureValidIndex( sal_Int32 nIndex ) const 287 throw( ::com::sun::star::lang::IndexOutOfBoundsException ); 288 /** Throws an exception, if the specified character position is invalid (outside 0..len). */ 289 void ensureValidIndexWithEnd( sal_Int32 nIndex ) const 290 throw( ::com::sun::star::lang::IndexOutOfBoundsException ); 291 /** Throws an exception, if the specified character range [Start,End) is invalid. 292 @descr If Start>End, swaps Start and End before checking. */ 293 void ensureValidRange( sal_Int32& rnStartIndex, sal_Int32& rnEndIndex ) const 294 throw( ::com::sun::star::lang::IndexOutOfBoundsException ); 295 296 /** Returns the VCL ruler control. Assumes a living object. */ 297 ScCsvRuler& implGetRuler() const; 298 299 /** Builds the entire string buffer. */ 300 void constructStringBuffer() throw( ::com::sun::star::uno::RuntimeException ); 301 /** Returns the character count of the text. */ 302 sal_Int32 implGetTextLength() const; 303 304 /** Returns true, if the character at the specified index has a split. */ 305 bool implHasSplit( sal_Int32 nApiPos ); 306 307 /** Returns the first character index with equal formatting as at nApiPos. */ 308 sal_Int32 implGetFirstEqualFormatted( sal_Int32 nApiPos ); 309 /** Returns the last character index with equal formatting as at nApiPos. */ 310 sal_Int32 implGetLastEqualFormatted( sal_Int32 nApiPos ); 311 }; 312 313 314 // ============================================================================ 315 316 class ScCsvGrid; 317 318 typedef ::cppu::ImplHelper2< 319 ::com::sun::star::accessibility::XAccessibleTable, 320 ::com::sun::star::accessibility::XAccessibleSelection > 321 ScAccessibleCsvGridImpl; 322 323 /** Accessible class representing the CSV grid control. */ 324 class ScAccessibleCsvGrid : public ScAccessibleCsvControl, public ScAccessibleCsvGridImpl 325 { 326 protected: 327 typedef ::com::sun::star::uno::Reference< 328 ::com::sun::star::accessibility::XAccessibleTable > XAccessibleTableRef; 329 330 public: 331 explicit ScAccessibleCsvGrid( ScCsvGrid& rGrid ); 332 virtual ~ScAccessibleCsvGrid(); 333 334 // XAccessibleComponent --------------------------------------------------- 335 336 /** Returns the cell at the specified point. */ 337 virtual XAccessibleRef SAL_CALL getAccessibleAtPoint( const AwtPoint& rPoint ) 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 346 // XAccessibleContext ----------------------------------------------------- 347 348 /** Returns the child count (count of cells in the table). */ 349 virtual sal_Int32 SAL_CALL getAccessibleChildCount() 350 throw( ::com::sun::star::uno::RuntimeException ); 351 352 /** Returns the specified child cell. */ 353 virtual XAccessibleRef SAL_CALL getAccessibleChild( sal_Int32 nIndex ) 354 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 355 356 /** Returns the relation to the ruler control. */ 357 virtual XAccessibleRelationSetRef SAL_CALL getAccessibleRelationSet() 358 throw( ::com::sun::star::uno::RuntimeException ); 359 360 /** Returns the current set of states. */ 361 virtual XAccessibleStateSetRef SAL_CALL getAccessibleStateSet() 362 throw( ::com::sun::star::uno::RuntimeException ); 363 364 // XAccessibleTable ------------------------------------------------------- 365 366 /** Returns the number of rows in the table. */ 367 virtual sal_Int32 SAL_CALL getAccessibleRowCount() 368 throw( ::com::sun::star::uno::RuntimeException ); 369 370 /** Returns the number of columns in the table. */ 371 virtual sal_Int32 SAL_CALL getAccessibleColumnCount() 372 throw( ::com::sun::star::uno::RuntimeException ); 373 374 /** Returns the description of the specified row in the table. */ 375 virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) 376 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 377 378 /** Returns the description text of the specified column in the table. */ 379 virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) 380 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 381 382 /** Returns the number of rows occupied at a specified row and column. 383 @descr Returns always 1 (Merged cells not supported). */ 384 virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) 385 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 386 387 /** Returns the number of rows occupied at a specified row and column. 388 @descr Returns always 1 (Merged cells not supported). */ 389 virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) 390 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 391 392 /** Returns the row headers as an AccessibleTable. */ 393 virtual XAccessibleTableRef SAL_CALL getAccessibleRowHeaders() 394 throw( ::com::sun::star::uno::RuntimeException ); 395 396 /** Returns the column headers as an AccessibleTable. */ 397 virtual XAccessibleTableRef SAL_CALL getAccessibleColumnHeaders() 398 throw( ::com::sun::star::uno::RuntimeException ); 399 400 /** Returns the selected rows as a sequence. */ 401 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows() 402 throw( ::com::sun::star::uno::RuntimeException ); 403 404 /** Returns the selected columns as a sequence. */ 405 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns() 406 throw( ::com::sun::star::uno::RuntimeException ); 407 408 /** Returns true, if the specified row is selected. */ 409 virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) 410 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 411 412 /** Returns true, if the specified column is selected. */ 413 virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) 414 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 415 416 /** Returns the accessible cell object at the specified position. */ 417 virtual XAccessibleRef SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) 418 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 419 420 /** Returns the caption object of the table. */ 421 virtual XAccessibleRef SAL_CALL getAccessibleCaption() 422 throw( ::com::sun::star::uno::RuntimeException ); 423 424 /** Returns the summary description object of the table. */ 425 virtual XAccessibleRef SAL_CALL getAccessibleSummary() 426 throw( ::com::sun::star::uno::RuntimeException ); 427 428 /** Returns true, if the cell at a specified position is selected. */ 429 virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) 430 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 431 432 /** Returns the child index of the cell at the specified position. */ 433 virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) 434 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 435 436 /** Returns the row index of the specified child. */ 437 virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) 438 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 439 440 /** Returns the column index of the specified child. */ 441 virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) 442 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 443 444 // XAccessibleSelection --------------------------------------------------- 445 446 /** Selects the specified child (selects the entire column or the entire table). */ 447 virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) 448 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 449 450 /** Returns true, if the specified child is selected. */ 451 virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) 452 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 453 454 /** Deselects all cells. */ 455 virtual void SAL_CALL clearAccessibleSelection() 456 throw( ::com::sun::star::uno::RuntimeException ); 457 458 /** Selects all cells. */ 459 virtual void SAL_CALL selectAllAccessibleChildren() 460 throw( ::com::sun::star::uno::RuntimeException ); 461 462 /** Returns the count of selected children. */ 463 virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() 464 throw( ::com::sun::star::uno::RuntimeException ); 465 466 /** Returns the child with the specified index in all selected children. */ 467 virtual XAccessibleRef SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) 468 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 469 470 /** Deselects the child with the specified index in all selected children. */ 471 virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) 472 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 473 474 // XInterface ------------------------------------------------------------- 475 476 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType ) 477 throw( ::com::sun::star::uno::RuntimeException ); 478 479 virtual void SAL_CALL acquire() throw(); 480 481 virtual void SAL_CALL release() throw(); 482 483 // XServiceInfo ----------------------------------------------------------- 484 485 /** Returns an identifier for the implementation of this object. */ 486 virtual ::rtl::OUString SAL_CALL getImplementationName() 487 throw( ::com::sun::star::uno::RuntimeException ); 488 489 // XTypeProvider ---------------------------------------------------------- 490 491 /** Returns a sequence with all supported interface types. */ 492 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() 493 throw( ::com::sun::star::uno::RuntimeException ); 494 495 /** Returns an implementation ID. */ 496 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() 497 throw( ::com::sun::star::uno::RuntimeException ); 498 499 // events ----------------------------------------------------------------- 500 public: 501 /** Sends a GetFocus or LoseFocus event to all listeners. */ 502 virtual void SendFocusEvent( bool bFocused ); 503 /** Sends a table model changed event for changed cell contents to all listeners. */ 504 virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows ); 505 /** Sends a table model changed event for an inserted column to all listeners. */ 506 virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn ); 507 /** Sends a table model changed event for a removed column to all listeners. */ 508 virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn ); 509 510 // helpers ---------------------------------------------------------------- 511 private: 512 /** Returns this object's name. */ 513 virtual ::rtl::OUString SAL_CALL createAccessibleName() 514 throw( ::com::sun::star::uno::RuntimeException ); 515 /** Returns this object's description. */ 516 virtual ::rtl::OUString SAL_CALL createAccessibleDescription() 517 throw( ::com::sun::star::uno::RuntimeException ); 518 519 /** Throws an exception, if nIndex is not a valid child index. */ 520 void ensureValidIndex( sal_Int32 nIndex ) const 521 throw( ::com::sun::star::lang::IndexOutOfBoundsException ); 522 /** Throws an exception, if the specified position is invalid. */ 523 void ensureValidPosition( sal_Int32 nRow, sal_Int32 nColumn ) const 524 throw( ::com::sun::star::lang::IndexOutOfBoundsException ); 525 526 /** Returns the VCL grid control. Assumes a living object. */ 527 ScCsvGrid& implGetGrid() const; 528 529 /** Returns true, if the specified column (including header) is selected. */ 530 bool implIsColumnSelected( sal_Int32 nColumn ) const; 531 /** Selects the specified column (including header). */ 532 void implSelectColumn( sal_Int32 nColumn, bool bSelect ); 533 534 /** Returns the count of visible rows in the table (including header). */ 535 sal_Int32 implGetRowCount() const; 536 /** Returns the total column count in the table (including header). */ 537 sal_Int32 implGetColumnCount() const; 538 /** Returns the count of selected columns in the table. */ 539 sal_Int32 implGetSelColumnCount() const; 540 /** Returns the total cell count in the table (including header). */ 541 inline sal_Int32 implGetCellCount() const { return implGetRowCount() * implGetColumnCount(); } 542 543 /** Returns the row index from cell index (including header). */ 544 inline sal_Int32 implGetRow( sal_Int32 nIndex ) const { return nIndex / implGetColumnCount(); } 545 /** Returns the column index from cell index (including header). */ 546 inline sal_Int32 implGetColumn( sal_Int32 nIndex ) const { return nIndex % implGetColumnCount(); } 547 /** Returns the absolute column index of the nSelColumn-th selected column. */ 548 sal_Int32 implGetSelColumn( sal_Int32 nSelColumn ) const; 549 /** Returns the child index from cell position (including header). */ 550 inline sal_Int32 implGetIndex( sal_Int32 nRow, sal_Int32 nColumn ) const { return nRow * implGetColumnCount() + nColumn; } 551 552 /** Returns the contents of the specified cell (including header). Indexes must be valid. */ 553 String implGetCellText( sal_Int32 nRow, sal_Int32 nColumn ) const; 554 /** Creates a new accessible object of the specified cell. Indexes must be valid. */ 555 ScAccessibleCsvControl* implCreateCellObj( sal_Int32 nRow, sal_Int32 nColumn ) const; 556 }; 557 558 559 // ============================================================================ 560 561 /** Accessible class representing a cell of the CSV grid control. */ 562 class ScAccessibleCsvCell : public ScAccessibleCsvControl, public accessibility::AccessibleStaticTextBase 563 { 564 protected: 565 typedef ::com::sun::star::uno::Sequence< 566 ::com::sun::star::beans::PropertyValue > PropertyValueSeq; 567 typedef ::std::auto_ptr< SvxEditSource > SvxEditSourcePtr; 568 569 private: 570 String maCellText; /// The text contents of this cell. 571 sal_Int32 mnLine; /// The grid line index (core index). 572 sal_uInt32 mnColumn; /// The grid column index (core index). 573 sal_Int32 mnIndex; /// The index of the cell in the table. 574 575 public: 576 explicit ScAccessibleCsvCell( 577 ScCsvGrid& rGrid, 578 const String& rCellText, 579 sal_Int32 nRow, sal_Int32 nColumn ); 580 virtual ~ScAccessibleCsvCell(); 581 582 using ScAccessibleCsvControl::disposing; 583 virtual void SAL_CALL disposing(); 584 585 // XAccessibleComponent --------------------------------------------------- 586 587 /** Sets the focus to the column of this cell. */ 588 virtual void SAL_CALL grabFocus() throw( ::com::sun::star::uno::RuntimeException ); 589 590 virtual sal_Int32 SAL_CALL getForeground( ) 591 throw (::com::sun::star::uno::RuntimeException); 592 593 virtual sal_Int32 SAL_CALL getBackground( ) 594 throw (::com::sun::star::uno::RuntimeException); 595 596 // XAccessibleContext ----------------------------------------------------- 597 598 /** Returns the child count. */ 599 virtual sal_Int32 SAL_CALL getAccessibleChildCount() 600 throw( ::com::sun::star::uno::RuntimeException ); 601 602 /** Returns the specified child. */ 603 virtual XAccessibleRef SAL_CALL getAccessibleChild( sal_Int32 nIndex ) 604 throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ); 605 606 /** Returns the index of this cell in the table. */ 607 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() 608 throw( ::com::sun::star::uno::RuntimeException ); 609 610 /** Returns the relation to the ruler control. */ 611 virtual XAccessibleRelationSetRef SAL_CALL getAccessibleRelationSet() 612 throw( ::com::sun::star::uno::RuntimeException ); 613 614 /** Returns the current set of states. */ 615 virtual XAccessibleStateSetRef SAL_CALL getAccessibleStateSet() 616 throw( ::com::sun::star::uno::RuntimeException ); 617 618 // XInterface ------------------------------------------------------------- 619 620 DECLARE_XINTERFACE() 621 622 // XTypeProvider ---------------------------------------------------------- 623 624 DECLARE_XTYPEPROVIDER() 625 626 // XServiceInfo ----------------------------------------------------------- 627 628 /** Returns an identifier for the implementation of this object. */ 629 virtual ::rtl::OUString SAL_CALL getImplementationName() 630 throw( ::com::sun::star::uno::RuntimeException ); 631 632 // helpers ---------------------------------------------------------------- 633 protected: 634 /** Returns this object's current bounding box relative to the desktop. */ 635 virtual Rectangle GetBoundingBoxOnScreen() const throw( ::com::sun::star::uno::RuntimeException ); 636 /** Returns this object's current bounding box relative to the parent object. */ 637 virtual Rectangle GetBoundingBox() const throw( ::com::sun::star::uno::RuntimeException ); 638 639 private: 640 /** Returns this object's name. */ 641 virtual ::rtl::OUString SAL_CALL createAccessibleName() 642 throw( ::com::sun::star::uno::RuntimeException ); 643 /** Returns this object's description. */ 644 virtual ::rtl::OUString SAL_CALL createAccessibleDescription() 645 throw( ::com::sun::star::uno::RuntimeException ); 646 647 /** Returns the VCL grid control. Assumes a living object. */ 648 ScCsvGrid& implGetGrid() const; 649 /** Returns the pixel position of the cell (rel. to parent), regardless of visibility. */ 650 Point implGetRealPos() const; 651 /** Returns the width of the character count */ 652 sal_uInt32 implCalcPixelWidth(sal_uInt32 nChars) const; 653 /** Returns the pixel size of the cell, regardless of visibility. */ 654 Size implGetRealSize() const; 655 /** Returns the bounding box of the cell relative in the table. */ 656 Rectangle implGetBoundingBox() const; 657 658 /** Creates the edit source the text helper needs. */ 659 ::std::auto_ptr< SvxEditSource > implCreateEditSource(); 660 }; 661 662 663 // ============================================================================ 664 665 #endif 666 667