1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 // ============================================================================
22 #ifndef _SC_ACCESSIBLECSVCONTROL_HXX
23 #define _SC_ACCESSIBLECSVCONTROL_HXX
25 #include <com/sun/star/accessibility/XAccessibleText.hpp>
26 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
27 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
28 #include <tools/gen.hxx>
29 #include <rtl/ustrbuf.hxx>
30 #include <cppuhelper/implbase1.hxx>
31 #include <cppuhelper/implbase2.hxx>
32 #include <editeng/AccessibleStaticTextBase.hxx>
33 #include <comphelper/uno3.hxx>
34 #include "AccessibleContextBase.hxx"
37 // ============================================================================
40 namespace utl
{ class AccessibleStateSetHelper
; }
42 /** Accessible base class used for CSV controls. */
43 class ScAccessibleCsvControl
: public ScAccessibleContextBase
46 typedef ::com::sun::star::uno::Reference
<
47 ::com::sun::star::accessibility::XAccessible
> XAccessibleRef
;
48 typedef ::com::sun::star::uno::Reference
<
49 ::com::sun::star::accessibility::XAccessibleRelationSet
> XAccessibleRelationSetRef
;
50 typedef ::com::sun::star::uno::Reference
<
51 ::com::sun::star::accessibility::XAccessibleStateSet
> XAccessibleStateSetRef
;
53 typedef ::com::sun::star::awt::Point AwtPoint
;
54 typedef ::com::sun::star::awt::Size AwtSize
;
55 typedef ::com::sun::star::awt::Rectangle AwtRectangle
;
58 ScCsvControl
* mpControl
; /// Pointer to the VCL control.
61 explicit ScAccessibleCsvControl(
62 const XAccessibleRef
& rxParent
,
63 ScCsvControl
& rControl
,
65 virtual ~ScAccessibleCsvControl();
67 using ScAccessibleContextBase::disposing
;
68 virtual void SAL_CALL
disposing();
70 // XAccessibleComponent ---------------------------------------------------
72 /** Returns the child at the specified point (cell returns NULL). */
73 virtual XAccessibleRef SAL_CALL
getAccessibleAtPoint( const AwtPoint
& rPoint
)
74 throw( ::com::sun::star::uno::RuntimeException
);
76 /** Returns true, if the control is visible. */
77 virtual sal_Bool SAL_CALL
isVisible() throw( ::com::sun::star::uno::RuntimeException
);
79 /** Sets the focus to this control. */
80 virtual void SAL_CALL
grabFocus() throw( ::com::sun::star::uno::RuntimeException
);
82 // events -----------------------------------------------------------------
84 /** Sends a GetFocus or LoseFocus event to all listeners. */
85 virtual void SendFocusEvent( bool bFocused
);
86 /** Sends a caret changed event to all listeners. */
87 virtual void SendCaretEvent();
88 /** Sends a visible area changed event to all listeners. */
89 virtual void SendVisibleEvent();
90 /** Sends a selection changed event to all listeners. */
91 virtual void SendSelectionEvent();
92 /** Sends a table model changed event for changed cell contents to all listeners. */
93 virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
, bool bAllRows
);
94 /** Sends a table model changed event for an inserted column to all listeners. */
95 virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
);
96 /** Sends a table model changed event for a removed column to all listeners. */
97 virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
);
99 // helpers ----------------------------------------------------------------
101 /** Returns this object's current bounding box relative to the desktop. */
102 virtual Rectangle
GetBoundingBoxOnScreen() const throw( ::com::sun::star::uno::RuntimeException
);
103 /** Returns this object's current bounding box relative to the parent object. */
104 virtual Rectangle
GetBoundingBox() const throw( ::com::sun::star::uno::RuntimeException
);
106 /** Returns whether the object is alive. Must be called with locked mutex. */
107 inline bool implIsAlive() const { return !rBHelper
.bDisposed
&& !rBHelper
.bInDispose
&& mpControl
; }
108 /** Throws an exception, if the object is disposed/disposing or any pointer
109 is missing. Should be used with locked mutex! */
110 void ensureAlive() const throw( ::com::sun::star::lang::DisposedException
);
112 /** Returns the VCL control. Assumes a living object. */
113 ScCsvControl
& implGetControl() const;
115 /** Returns the first child of rxParentObj, which has the role nRole. */
116 XAccessibleRef
implGetChildByRole( const XAccessibleRef
& rxParentObj
, sal_uInt16 nRole
)
117 throw( ::com::sun::star::uno::RuntimeException
);
118 /** Creates a StateSetHelper and fills it with DEFUNC, OPAQUE, ENABLED, SHOWING and VISIBLE. */
119 ::utl::AccessibleStateSetHelper
* implCreateStateSet();
121 /** Disposes the object. This is a helper called from destructors only. */
124 /** Converts the control-relative position to an absolute screen position. */
125 Point
implGetAbsPos( const Point
& rPos
) const;
129 // ============================================================================
133 typedef ::cppu::ImplHelper1
<
134 ::com::sun::star::accessibility::XAccessibleText
>
135 ScAccessibleCsvRulerImpl
;
137 /** Accessible class representing the CSV ruler control. */
138 class ScAccessibleCsvRuler
: public ScAccessibleCsvControl
, public ScAccessibleCsvRulerImpl
141 typedef ::com::sun::star::uno::Sequence
<
142 ::com::sun::star::beans::PropertyValue
> PropertyValueSeq
;
145 OUStringBuffer maBuffer
; /// Contains the text representation of the ruler.
148 explicit ScAccessibleCsvRuler( ScCsvRuler
& rRuler
);
149 virtual ~ScAccessibleCsvRuler();
151 // XAccessibleComponent -----------------------------------------------------
153 virtual sal_Int32 SAL_CALL
getForeground( )
154 throw (::com::sun::star::uno::RuntimeException
);
156 virtual sal_Int32 SAL_CALL
getBackground( )
157 throw (::com::sun::star::uno::RuntimeException
);
159 // XAccessibleContext -----------------------------------------------------
161 /** Returns the child count (the ruler does not have children). */
162 virtual sal_Int32 SAL_CALL
getAccessibleChildCount()
163 throw( ::com::sun::star::uno::RuntimeException
);
165 /** Throws an exception (the ruler does not have children). */
166 virtual XAccessibleRef SAL_CALL
getAccessibleChild( sal_Int32 nIndex
)
167 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
169 /** Returns the relation to the grid control. */
170 virtual XAccessibleRelationSetRef SAL_CALL
getAccessibleRelationSet()
171 throw( ::com::sun::star::uno::RuntimeException
);
173 /** Returns the current set of states. */
174 virtual XAccessibleStateSetRef SAL_CALL
getAccessibleStateSet()
175 throw( ::com::sun::star::uno::RuntimeException
);
177 // XAccessibleText --------------------------------------------------------
179 /** Return the position of the caret. */
180 virtual sal_Int32 SAL_CALL
getCaretPosition() throw( ::com::sun::star::uno::RuntimeException
);
182 /** Sets the position of the caret. */
183 virtual sal_Bool SAL_CALL
setCaretPosition( sal_Int32 nIndex
)
184 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
186 /** Returns the specified character. */
187 virtual sal_Unicode SAL_CALL
getCharacter( sal_Int32 nIndex
)
188 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
190 /** Returns the attributes of the specified character. */
191 virtual PropertyValueSeq SAL_CALL
getCharacterAttributes( sal_Int32 nIndex
, const ::com::sun::star::uno::Sequence
< OUString
>& aRequestedAttributes
)
192 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
194 /** Returns the screen coordinates of the specified character. */
195 virtual AwtRectangle SAL_CALL
getCharacterBounds( sal_Int32 nIndex
)
196 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
198 /** Returns the count of characters. */
199 virtual sal_Int32 SAL_CALL
getCharacterCount() throw( ::com::sun::star::uno::RuntimeException
);
201 /** Returns the character index at the specified coordinate (object's coordinate system). */
202 virtual sal_Int32 SAL_CALL
getIndexAtPoint( const AwtPoint
& rPoint
)
203 throw( ::com::sun::star::uno::RuntimeException
);
205 /** Returns the selected text (ruler returns empty string). */
206 virtual OUString SAL_CALL
getSelectedText() throw( ::com::sun::star::uno::RuntimeException
);
208 /** Returns the start index of the selection (ruler returns -1). */
209 virtual sal_Int32 SAL_CALL
getSelectionStart() throw( ::com::sun::star::uno::RuntimeException
);
211 /** Returns the end index of the selection (ruler returns -1). */
212 virtual sal_Int32 SAL_CALL
getSelectionEnd() throw( ::com::sun::star::uno::RuntimeException
);
214 /** Selects a part of the text (ruler does nothing). */
215 virtual sal_Bool SAL_CALL
setSelection( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
)
216 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
218 /** Returns the entire text. */
219 virtual OUString SAL_CALL
getText() throw( ::com::sun::star::uno::RuntimeException
);
221 /** Returns the specified range [Start,End) of the text. */
222 virtual OUString SAL_CALL
getTextRange( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
)
223 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
225 /** Returns the specified text portion. */
226 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
);
227 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
);
228 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
);
230 /** Copies the specified text range into the clipboard (ruler does nothing). */
231 virtual sal_Bool SAL_CALL
copyText( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
)
232 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
234 // XInterface -------------------------------------------------------------
236 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
)
237 throw( ::com::sun::star::uno::RuntimeException
);
239 virtual void SAL_CALL
acquire() throw();
241 virtual void SAL_CALL
release() throw();
243 // XServiceInfo -----------------------------------------------------------
245 /** Returns an identifier for the implementation of this object. */
246 virtual OUString SAL_CALL
getImplementationName()
247 throw( ::com::sun::star::uno::RuntimeException
);
249 // XTypeProvider ----------------------------------------------------------
251 /** Returns a sequence with all supported interface types. */
252 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes()
253 throw( ::com::sun::star::uno::RuntimeException
);
255 /** Returns an implementation ID. */
256 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
257 throw( ::com::sun::star::uno::RuntimeException
);
259 // events -----------------------------------------------------------------
261 /** Sends a caret changed event to all listeners. */
262 virtual void SendCaretEvent();
264 // helpers ----------------------------------------------------------------
266 /** Returns this object's name. */
267 virtual OUString SAL_CALL
createAccessibleName()
268 throw( ::com::sun::star::uno::RuntimeException
);
269 /** Returns this object's description. */
270 virtual OUString SAL_CALL
createAccessibleDescription()
271 throw( ::com::sun::star::uno::RuntimeException
);
273 /** Throws an exception, if the specified character position is invalid (outside 0..len-1). */
274 void ensureValidIndex( sal_Int32 nIndex
) const
275 throw( ::com::sun::star::lang::IndexOutOfBoundsException
);
276 /** Throws an exception, if the specified character position is invalid (outside 0..len). */
277 void ensureValidIndexWithEnd( sal_Int32 nIndex
) const
278 throw( ::com::sun::star::lang::IndexOutOfBoundsException
);
279 /** Throws an exception, if the specified character range [Start,End) is invalid.
280 @descr If Start>End, swaps Start and End before checking. */
281 void ensureValidRange( sal_Int32
& rnStartIndex
, sal_Int32
& rnEndIndex
) const
282 throw( ::com::sun::star::lang::IndexOutOfBoundsException
);
284 /** Returns the VCL ruler control. Assumes a living object. */
285 ScCsvRuler
& implGetRuler() const;
287 /** Builds the entire string buffer. */
288 void constructStringBuffer() throw( ::com::sun::star::uno::RuntimeException
);
289 /** Returns the character count of the text. */
290 sal_Int32
implGetTextLength() const;
292 /** Returns true, if the character at the specified index has a split. */
293 bool implHasSplit( sal_Int32 nApiPos
);
295 /** Returns the first character index with equal formatting as at nApiPos. */
296 sal_Int32
implGetFirstEqualFormatted( sal_Int32 nApiPos
);
297 /** Returns the last character index with equal formatting as at nApiPos. */
298 sal_Int32
implGetLastEqualFormatted( sal_Int32 nApiPos
);
302 // ============================================================================
306 typedef ::cppu::ImplHelper2
<
307 ::com::sun::star::accessibility::XAccessibleTable
,
308 ::com::sun::star::accessibility::XAccessibleSelection
>
309 ScAccessibleCsvGridImpl
;
311 /** Accessible class representing the CSV grid control. */
312 class ScAccessibleCsvGrid
: public ScAccessibleCsvControl
, public ScAccessibleCsvGridImpl
315 typedef ::com::sun::star::uno::Reference
<
316 ::com::sun::star::accessibility::XAccessibleTable
> XAccessibleTableRef
;
319 explicit ScAccessibleCsvGrid( ScCsvGrid
& rGrid
);
320 virtual ~ScAccessibleCsvGrid();
322 // XAccessibleComponent ---------------------------------------------------
324 /** Returns the cell at the specified point. */
325 virtual XAccessibleRef SAL_CALL
getAccessibleAtPoint( const AwtPoint
& rPoint
)
326 throw( ::com::sun::star::uno::RuntimeException
);
328 virtual sal_Int32 SAL_CALL
getForeground( )
329 throw (::com::sun::star::uno::RuntimeException
);
331 virtual sal_Int32 SAL_CALL
getBackground( )
332 throw (::com::sun::star::uno::RuntimeException
);
334 // XAccessibleContext -----------------------------------------------------
336 /** Returns the child count (count of cells in the table). */
337 virtual sal_Int32 SAL_CALL
getAccessibleChildCount()
338 throw( ::com::sun::star::uno::RuntimeException
);
340 /** Returns the specified child cell. */
341 virtual XAccessibleRef SAL_CALL
getAccessibleChild( sal_Int32 nIndex
)
342 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
344 /** Returns the relation to the ruler control. */
345 virtual XAccessibleRelationSetRef SAL_CALL
getAccessibleRelationSet()
346 throw( ::com::sun::star::uno::RuntimeException
);
348 /** Returns the current set of states. */
349 virtual XAccessibleStateSetRef SAL_CALL
getAccessibleStateSet()
350 throw( ::com::sun::star::uno::RuntimeException
);
352 // XAccessibleTable -------------------------------------------------------
354 /** Returns the number of rows in the table. */
355 virtual sal_Int32 SAL_CALL
getAccessibleRowCount()
356 throw( ::com::sun::star::uno::RuntimeException
);
358 /** Returns the number of columns in the table. */
359 virtual sal_Int32 SAL_CALL
getAccessibleColumnCount()
360 throw( ::com::sun::star::uno::RuntimeException
);
362 /** Returns the description of the specified row in the table. */
363 virtual OUString SAL_CALL
getAccessibleRowDescription( sal_Int32 nRow
)
364 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
366 /** Returns the description text of the specified column in the table. */
367 virtual OUString SAL_CALL
getAccessibleColumnDescription( sal_Int32 nColumn
)
368 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
370 /** Returns the number of rows occupied at a specified row and column.
371 @descr Returns always 1 (Merged cells not supported). */
372 virtual sal_Int32 SAL_CALL
getAccessibleRowExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
)
373 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
375 /** Returns the number of rows occupied at a specified row and column.
376 @descr Returns always 1 (Merged cells not supported). */
377 virtual sal_Int32 SAL_CALL
getAccessibleColumnExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
)
378 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
380 /** Returns the row headers as an AccessibleTable. */
381 virtual XAccessibleTableRef SAL_CALL
getAccessibleRowHeaders()
382 throw( ::com::sun::star::uno::RuntimeException
);
384 /** Returns the column headers as an AccessibleTable. */
385 virtual XAccessibleTableRef SAL_CALL
getAccessibleColumnHeaders()
386 throw( ::com::sun::star::uno::RuntimeException
);
388 /** Returns the selected rows as a sequence. */
389 virtual ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleRows()
390 throw( ::com::sun::star::uno::RuntimeException
);
392 /** Returns the selected columns as a sequence. */
393 virtual ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleColumns()
394 throw( ::com::sun::star::uno::RuntimeException
);
396 /** Returns true, if the specified row is selected. */
397 virtual sal_Bool SAL_CALL
isAccessibleRowSelected( sal_Int32 nRow
)
398 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
400 /** Returns true, if the specified column is selected. */
401 virtual sal_Bool SAL_CALL
isAccessibleColumnSelected( sal_Int32 nColumn
)
402 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
404 /** Returns the accessible cell object at the specified position. */
405 virtual XAccessibleRef SAL_CALL
getAccessibleCellAt( sal_Int32 nRow
, sal_Int32 nColumn
)
406 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
408 /** Returns the caption object of the table. */
409 virtual XAccessibleRef SAL_CALL
getAccessibleCaption()
410 throw( ::com::sun::star::uno::RuntimeException
);
412 /** Returns the summary description object of the table. */
413 virtual XAccessibleRef SAL_CALL
getAccessibleSummary()
414 throw( ::com::sun::star::uno::RuntimeException
);
416 /** Returns true, if the cell at a specified position is selected. */
417 virtual sal_Bool SAL_CALL
isAccessibleSelected( sal_Int32 nRow
, sal_Int32 nColumn
)
418 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
420 /** Returns the child index of the cell at the specified position. */
421 virtual sal_Int32 SAL_CALL
getAccessibleIndex( sal_Int32 nRow
, sal_Int32 nColumn
)
422 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
424 /** Returns the row index of the specified child. */
425 virtual sal_Int32 SAL_CALL
getAccessibleRow( sal_Int32 nChildIndex
)
426 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
428 /** Returns the column index of the specified child. */
429 virtual sal_Int32 SAL_CALL
getAccessibleColumn( sal_Int32 nChildIndex
)
430 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
432 // XAccessibleSelection ---------------------------------------------------
434 /** Selects the specified child (selects the entire column or the entire table). */
435 virtual void SAL_CALL
selectAccessibleChild( sal_Int32 nChildIndex
)
436 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
438 /** Returns true, if the specified child is selected. */
439 virtual sal_Bool SAL_CALL
isAccessibleChildSelected( sal_Int32 nChildIndex
)
440 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
442 /** Deselects all cells. */
443 virtual void SAL_CALL
clearAccessibleSelection()
444 throw( ::com::sun::star::uno::RuntimeException
);
446 /** Selects all cells. */
447 virtual void SAL_CALL
selectAllAccessibleChildren()
448 throw( ::com::sun::star::uno::RuntimeException
);
450 /** Returns the count of selected children. */
451 virtual sal_Int32 SAL_CALL
getSelectedAccessibleChildCount()
452 throw( ::com::sun::star::uno::RuntimeException
);
454 /** Returns the child with the specified index in all selected children. */
455 virtual XAccessibleRef SAL_CALL
getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
456 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
458 /** Deselects the child with the specified index in all selected children. */
459 virtual void SAL_CALL
deselectAccessibleChild( sal_Int32 nSelectedChildIndex
)
460 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
462 // XInterface -------------------------------------------------------------
464 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
)
465 throw( ::com::sun::star::uno::RuntimeException
);
467 virtual void SAL_CALL
acquire() throw();
469 virtual void SAL_CALL
release() throw();
471 // XServiceInfo -----------------------------------------------------------
473 /** Returns an identifier for the implementation of this object. */
474 virtual OUString SAL_CALL
getImplementationName()
475 throw( ::com::sun::star::uno::RuntimeException
);
477 // XTypeProvider ----------------------------------------------------------
479 /** Returns a sequence with all supported interface types. */
480 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes()
481 throw( ::com::sun::star::uno::RuntimeException
);
483 /** Returns an implementation ID. */
484 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
485 throw( ::com::sun::star::uno::RuntimeException
);
487 // events -----------------------------------------------------------------
489 /** Sends a GetFocus or LoseFocus event to all listeners. */
490 virtual void SendFocusEvent( bool bFocused
);
491 /** Sends a table model changed event for changed cell contents to all listeners. */
492 virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
, bool bAllRows
);
493 /** Sends a table model changed event for an inserted column to all listeners. */
494 virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
);
495 /** Sends a table model changed event for a removed column to all listeners. */
496 virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
);
498 // helpers ----------------------------------------------------------------
500 /** Returns this object's name. */
501 virtual OUString SAL_CALL
createAccessibleName()
502 throw( ::com::sun::star::uno::RuntimeException
);
503 /** Returns this object's description. */
504 virtual OUString SAL_CALL
createAccessibleDescription()
505 throw( ::com::sun::star::uno::RuntimeException
);
507 /** Throws an exception, if nIndex is not a valid child index. */
508 void ensureValidIndex( sal_Int32 nIndex
) const
509 throw( ::com::sun::star::lang::IndexOutOfBoundsException
);
510 /** Throws an exception, if the specified position is invalid. */
511 void ensureValidPosition( sal_Int32 nRow
, sal_Int32 nColumn
) const
512 throw( ::com::sun::star::lang::IndexOutOfBoundsException
);
514 /** Returns the VCL grid control. Assumes a living object. */
515 ScCsvGrid
& implGetGrid() const;
517 /** Returns true, if the specified column (including header) is selected. */
518 bool implIsColumnSelected( sal_Int32 nColumn
) const;
519 /** Selects the specified column (including header). */
520 void implSelectColumn( sal_Int32 nColumn
, bool bSelect
);
522 /** Returns the count of visible rows in the table (including header). */
523 sal_Int32
implGetRowCount() const;
524 /** Returns the total column count in the table (including header). */
525 sal_Int32
implGetColumnCount() const;
526 /** Returns the count of selected columns in the table. */
527 sal_Int32
implGetSelColumnCount() const;
528 /** Returns the total cell count in the table (including header). */
529 inline sal_Int32
implGetCellCount() const { return implGetRowCount() * implGetColumnCount(); }
531 /** Returns the row index from cell index (including header). */
532 inline sal_Int32
implGetRow( sal_Int32 nIndex
) const { return nIndex
/ implGetColumnCount(); }
533 /** Returns the column index from cell index (including header). */
534 inline sal_Int32
implGetColumn( sal_Int32 nIndex
) const { return nIndex
% implGetColumnCount(); }
535 /** Returns the absolute column index of the nSelColumn-th selected column. */
536 sal_Int32
implGetSelColumn( sal_Int32 nSelColumn
) const;
537 /** Returns the child index from cell position (including header). */
538 inline sal_Int32
implGetIndex( sal_Int32 nRow
, sal_Int32 nColumn
) const { return nRow
* implGetColumnCount() + nColumn
; }
540 /** Returns the contents of the specified cell (including header). Indexes must be valid. */
541 OUString
implGetCellText( sal_Int32 nRow
, sal_Int32 nColumn
) const;
542 /** Creates a new accessible object of the specified cell. Indexes must be valid. */
543 ScAccessibleCsvControl
* implCreateCellObj( sal_Int32 nRow
, sal_Int32 nColumn
) const;
547 // ============================================================================
549 /** Accessible class representing a cell of the CSV grid control. */
550 class ScAccessibleCsvCell
: public ScAccessibleCsvControl
, public accessibility::AccessibleStaticTextBase
553 typedef ::com::sun::star::uno::Sequence
<
554 ::com::sun::star::beans::PropertyValue
> PropertyValueSeq
;
555 typedef ::std::auto_ptr
< SvxEditSource
> SvxEditSourcePtr
;
558 OUString maCellText
; /// The text contents of this cell.
559 sal_Int32 mnLine
; /// The grid line index (core index).
560 sal_uInt32 mnColumn
; /// The grid column index (core index).
561 sal_Int32 mnIndex
; /// The index of the cell in the table.
564 explicit ScAccessibleCsvCell(
566 const OUString
& rCellText
,
567 sal_Int32 nRow
, sal_Int32 nColumn
);
568 virtual ~ScAccessibleCsvCell();
570 using ScAccessibleCsvControl::disposing
;
571 virtual void SAL_CALL
disposing();
573 // XAccessibleComponent ---------------------------------------------------
575 /** Sets the focus to the column of this cell. */
576 virtual void SAL_CALL
grabFocus() throw( ::com::sun::star::uno::RuntimeException
);
578 virtual sal_Int32 SAL_CALL
getForeground( )
579 throw (::com::sun::star::uno::RuntimeException
);
581 virtual sal_Int32 SAL_CALL
getBackground( )
582 throw (::com::sun::star::uno::RuntimeException
);
584 // XAccessibleContext -----------------------------------------------------
586 /** Returns the child count. */
587 virtual sal_Int32 SAL_CALL
getAccessibleChildCount()
588 throw( ::com::sun::star::uno::RuntimeException
);
590 /** Returns the specified child. */
591 virtual XAccessibleRef SAL_CALL
getAccessibleChild( sal_Int32 nIndex
)
592 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
594 /** Returns the index of this cell in the table. */
595 virtual sal_Int32 SAL_CALL
getAccessibleIndexInParent()
596 throw( ::com::sun::star::uno::RuntimeException
);
598 /** Returns the relation to the ruler control. */
599 virtual XAccessibleRelationSetRef SAL_CALL
getAccessibleRelationSet()
600 throw( ::com::sun::star::uno::RuntimeException
);
602 /** Returns the current set of states. */
603 virtual XAccessibleStateSetRef SAL_CALL
getAccessibleStateSet()
604 throw( ::com::sun::star::uno::RuntimeException
);
606 // XInterface -------------------------------------------------------------
610 // XTypeProvider ----------------------------------------------------------
612 DECLARE_XTYPEPROVIDER()
614 // XServiceInfo -----------------------------------------------------------
616 /** Returns an identifier for the implementation of this object. */
617 virtual OUString SAL_CALL
getImplementationName()
618 throw( ::com::sun::star::uno::RuntimeException
);
620 // helpers ----------------------------------------------------------------
622 /** Returns this object's current bounding box relative to the desktop. */
623 virtual Rectangle
GetBoundingBoxOnScreen() const throw( ::com::sun::star::uno::RuntimeException
);
624 /** Returns this object's current bounding box relative to the parent object. */
625 virtual Rectangle
GetBoundingBox() const throw( ::com::sun::star::uno::RuntimeException
);
628 /** Returns this object's name. */
629 virtual OUString SAL_CALL
createAccessibleName()
630 throw( ::com::sun::star::uno::RuntimeException
);
631 /** Returns this object's description. */
632 virtual OUString SAL_CALL
createAccessibleDescription()
633 throw( ::com::sun::star::uno::RuntimeException
);
635 /** Returns the VCL grid control. Assumes a living object. */
636 ScCsvGrid
& implGetGrid() const;
637 /** Returns the pixel position of the cell (rel. to parent), regardless of visibility. */
638 Point
implGetRealPos() const;
639 /** Returns the width of the character count */
640 sal_uInt32
implCalcPixelWidth(sal_uInt32 nChars
) const;
641 /** Returns the pixel size of the cell, regardless of visibility. */
642 Size
implGetRealSize() const;
643 /** Returns the bounding box of the cell relative in the table. */
644 Rectangle
implGetBoundingBox() const;
646 /** Creates the edit source the text helper needs. */
647 ::std::auto_ptr
< SvxEditSource
> implCreateEditSource();
651 // ============================================================================
655 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */