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 <tools/string.hxx>
30 #include <rtl/ustrbuf.hxx>
31 #include <cppuhelper/implbase1.hxx>
32 #include <cppuhelper/implbase2.hxx>
33 #include <editeng/AccessibleStaticTextBase.hxx>
34 #include <comphelper/uno3.hxx>
35 #include "AccessibleContextBase.hxx"
38 // ============================================================================
41 namespace utl
{ class AccessibleStateSetHelper
; }
43 /** Accessible base class used for CSV controls. */
44 class ScAccessibleCsvControl
: public ScAccessibleContextBase
47 typedef ::com::sun::star::uno::Reference
<
48 ::com::sun::star::accessibility::XAccessible
> XAccessibleRef
;
49 typedef ::com::sun::star::uno::Reference
<
50 ::com::sun::star::accessibility::XAccessibleRelationSet
> XAccessibleRelationSetRef
;
51 typedef ::com::sun::star::uno::Reference
<
52 ::com::sun::star::accessibility::XAccessibleStateSet
> XAccessibleStateSetRef
;
54 typedef ::com::sun::star::awt::Point AwtPoint
;
55 typedef ::com::sun::star::awt::Size AwtSize
;
56 typedef ::com::sun::star::awt::Rectangle AwtRectangle
;
59 ScCsvControl
* mpControl
; /// Pointer to the VCL control.
62 explicit ScAccessibleCsvControl(
63 const XAccessibleRef
& rxParent
,
64 ScCsvControl
& rControl
,
66 virtual ~ScAccessibleCsvControl();
68 using ScAccessibleContextBase::disposing
;
69 virtual void SAL_CALL
disposing();
71 // XAccessibleComponent ---------------------------------------------------
73 /** Returns the child at the specified point (cell returns NULL). */
74 virtual XAccessibleRef SAL_CALL
getAccessibleAtPoint( const AwtPoint
& rPoint
)
75 throw( ::com::sun::star::uno::RuntimeException
);
77 /** Returns true, if the control is visible. */
78 virtual sal_Bool SAL_CALL
isVisible() throw( ::com::sun::star::uno::RuntimeException
);
80 /** Sets the focus to this control. */
81 virtual void SAL_CALL
grabFocus() throw( ::com::sun::star::uno::RuntimeException
);
83 // events -----------------------------------------------------------------
85 /** Sends a GetFocus or LoseFocus event to all listeners. */
86 virtual void SendFocusEvent( bool bFocused
);
87 /** Sends a caret changed event to all listeners. */
88 virtual void SendCaretEvent();
89 /** Sends a visible area changed event to all listeners. */
90 virtual void SendVisibleEvent();
91 /** Sends a selection changed event to all listeners. */
92 virtual void SendSelectionEvent();
93 /** Sends a table model changed event for changed cell contents to all listeners. */
94 virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
, bool bAllRows
);
95 /** Sends a table model changed event for an inserted column to all listeners. */
96 virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
);
97 /** Sends a table model changed event for a removed column to all listeners. */
98 virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
);
100 // helpers ----------------------------------------------------------------
102 /** Returns this object's current bounding box relative to the desktop. */
103 virtual Rectangle
GetBoundingBoxOnScreen() const throw( ::com::sun::star::uno::RuntimeException
);
104 /** Returns this object's current bounding box relative to the parent object. */
105 virtual Rectangle
GetBoundingBox() const throw( ::com::sun::star::uno::RuntimeException
);
107 /** Returns whether the object is alive. Must be called with locked mutex. */
108 inline bool implIsAlive() const { return !rBHelper
.bDisposed
&& !rBHelper
.bInDispose
&& mpControl
; }
109 /** Throws an exception, if the object is disposed/disposing or any pointer
110 is missing. Should be used with locked mutex! */
111 void ensureAlive() const throw( ::com::sun::star::lang::DisposedException
);
113 /** Returns the VCL control. Assumes a living object. */
114 ScCsvControl
& implGetControl() const;
116 /** Returns the first child of rxParentObj, which has the role nRole. */
117 XAccessibleRef
implGetChildByRole( const XAccessibleRef
& rxParentObj
, sal_uInt16 nRole
)
118 throw( ::com::sun::star::uno::RuntimeException
);
119 /** Creates a StateSetHelper and fills it with DEFUNC, OPAQUE, ENABLED, SHOWING and VISIBLE. */
120 ::utl::AccessibleStateSetHelper
* implCreateStateSet();
122 /** Disposes the object. This is a helper called from destructors only. */
125 /** Converts the control-relative position to an absolute screen position. */
126 Point
implGetAbsPos( const Point
& rPos
) const;
130 // ============================================================================
134 typedef ::cppu::ImplHelper1
<
135 ::com::sun::star::accessibility::XAccessibleText
>
136 ScAccessibleCsvRulerImpl
;
138 /** Accessible class representing the CSV ruler control. */
139 class ScAccessibleCsvRuler
: public ScAccessibleCsvControl
, public ScAccessibleCsvRulerImpl
142 typedef ::com::sun::star::uno::Sequence
<
143 ::com::sun::star::beans::PropertyValue
> PropertyValueSeq
;
146 OUStringBuffer maBuffer
; /// Contains the text representation of the ruler.
149 explicit ScAccessibleCsvRuler( ScCsvRuler
& rRuler
);
150 virtual ~ScAccessibleCsvRuler();
152 // XAccessibleComponent -----------------------------------------------------
154 virtual sal_Int32 SAL_CALL
getForeground( )
155 throw (::com::sun::star::uno::RuntimeException
);
157 virtual sal_Int32 SAL_CALL
getBackground( )
158 throw (::com::sun::star::uno::RuntimeException
);
160 // XAccessibleContext -----------------------------------------------------
162 /** Returns the child count (the ruler does not have children). */
163 virtual sal_Int32 SAL_CALL
getAccessibleChildCount()
164 throw( ::com::sun::star::uno::RuntimeException
);
166 /** Throws an exception (the ruler does not have children). */
167 virtual XAccessibleRef SAL_CALL
getAccessibleChild( sal_Int32 nIndex
)
168 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
170 /** Returns the relation to the grid control. */
171 virtual XAccessibleRelationSetRef SAL_CALL
getAccessibleRelationSet()
172 throw( ::com::sun::star::uno::RuntimeException
);
174 /** Returns the current set of states. */
175 virtual XAccessibleStateSetRef SAL_CALL
getAccessibleStateSet()
176 throw( ::com::sun::star::uno::RuntimeException
);
178 // XAccessibleText --------------------------------------------------------
180 /** Return the position of the caret. */
181 virtual sal_Int32 SAL_CALL
getCaretPosition() throw( ::com::sun::star::uno::RuntimeException
);
183 /** Sets the position of the caret. */
184 virtual sal_Bool SAL_CALL
setCaretPosition( sal_Int32 nIndex
)
185 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
187 /** Returns the specified character. */
188 virtual sal_Unicode SAL_CALL
getCharacter( sal_Int32 nIndex
)
189 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
191 /** Returns the attributes of the specified character. */
192 virtual PropertyValueSeq SAL_CALL
getCharacterAttributes( sal_Int32 nIndex
, const ::com::sun::star::uno::Sequence
< OUString
>& aRequestedAttributes
)
193 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
195 /** Returns the screen coordinates of the specified character. */
196 virtual AwtRectangle SAL_CALL
getCharacterBounds( sal_Int32 nIndex
)
197 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
199 /** Returns the count of characters. */
200 virtual sal_Int32 SAL_CALL
getCharacterCount() throw( ::com::sun::star::uno::RuntimeException
);
202 /** Returns the character index at the specified coordinate (object's coordinate system). */
203 virtual sal_Int32 SAL_CALL
getIndexAtPoint( const AwtPoint
& rPoint
)
204 throw( ::com::sun::star::uno::RuntimeException
);
206 /** Returns the selected text (ruler returns empty string). */
207 virtual OUString SAL_CALL
getSelectedText() throw( ::com::sun::star::uno::RuntimeException
);
209 /** Returns the start index of the selection (ruler returns -1). */
210 virtual sal_Int32 SAL_CALL
getSelectionStart() throw( ::com::sun::star::uno::RuntimeException
);
212 /** Returns the end index of the selection (ruler returns -1). */
213 virtual sal_Int32 SAL_CALL
getSelectionEnd() throw( ::com::sun::star::uno::RuntimeException
);
215 /** Selects a part of the text (ruler does nothing). */
216 virtual sal_Bool SAL_CALL
setSelection( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
)
217 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
219 /** Returns the entire text. */
220 virtual OUString SAL_CALL
getText() throw( ::com::sun::star::uno::RuntimeException
);
222 /** Returns the specified range [Start,End) of the text. */
223 virtual OUString SAL_CALL
getTextRange( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
)
224 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
226 /** Returns the specified text portion. */
227 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
);
228 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
);
229 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
);
231 /** Copies the specified text range into the clipboard (ruler does nothing). */
232 virtual sal_Bool SAL_CALL
copyText( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
)
233 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
235 // XInterface -------------------------------------------------------------
237 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
)
238 throw( ::com::sun::star::uno::RuntimeException
);
240 virtual void SAL_CALL
acquire() throw();
242 virtual void SAL_CALL
release() throw();
244 // XServiceInfo -----------------------------------------------------------
246 /** Returns an identifier for the implementation of this object. */
247 virtual OUString SAL_CALL
getImplementationName()
248 throw( ::com::sun::star::uno::RuntimeException
);
250 // XTypeProvider ----------------------------------------------------------
252 /** Returns a sequence with all supported interface types. */
253 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes()
254 throw( ::com::sun::star::uno::RuntimeException
);
256 /** Returns an implementation ID. */
257 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
258 throw( ::com::sun::star::uno::RuntimeException
);
260 // events -----------------------------------------------------------------
262 /** Sends a caret changed event to all listeners. */
263 virtual void SendCaretEvent();
265 // helpers ----------------------------------------------------------------
267 /** Returns this object's name. */
268 virtual OUString SAL_CALL
createAccessibleName()
269 throw( ::com::sun::star::uno::RuntimeException
);
270 /** Returns this object's description. */
271 virtual OUString SAL_CALL
createAccessibleDescription()
272 throw( ::com::sun::star::uno::RuntimeException
);
274 /** Throws an exception, if the specified character position is invalid (outside 0..len-1). */
275 void ensureValidIndex( sal_Int32 nIndex
) const
276 throw( ::com::sun::star::lang::IndexOutOfBoundsException
);
277 /** Throws an exception, if the specified character position is invalid (outside 0..len). */
278 void ensureValidIndexWithEnd( sal_Int32 nIndex
) const
279 throw( ::com::sun::star::lang::IndexOutOfBoundsException
);
280 /** Throws an exception, if the specified character range [Start,End) is invalid.
281 @descr If Start>End, swaps Start and End before checking. */
282 void ensureValidRange( sal_Int32
& rnStartIndex
, sal_Int32
& rnEndIndex
) const
283 throw( ::com::sun::star::lang::IndexOutOfBoundsException
);
285 /** Returns the VCL ruler control. Assumes a living object. */
286 ScCsvRuler
& implGetRuler() const;
288 /** Builds the entire string buffer. */
289 void constructStringBuffer() throw( ::com::sun::star::uno::RuntimeException
);
290 /** Returns the character count of the text. */
291 sal_Int32
implGetTextLength() const;
293 /** Returns true, if the character at the specified index has a split. */
294 bool implHasSplit( sal_Int32 nApiPos
);
296 /** Returns the first character index with equal formatting as at nApiPos. */
297 sal_Int32
implGetFirstEqualFormatted( sal_Int32 nApiPos
);
298 /** Returns the last character index with equal formatting as at nApiPos. */
299 sal_Int32
implGetLastEqualFormatted( sal_Int32 nApiPos
);
303 // ============================================================================
307 typedef ::cppu::ImplHelper2
<
308 ::com::sun::star::accessibility::XAccessibleTable
,
309 ::com::sun::star::accessibility::XAccessibleSelection
>
310 ScAccessibleCsvGridImpl
;
312 /** Accessible class representing the CSV grid control. */
313 class ScAccessibleCsvGrid
: public ScAccessibleCsvControl
, public ScAccessibleCsvGridImpl
316 typedef ::com::sun::star::uno::Reference
<
317 ::com::sun::star::accessibility::XAccessibleTable
> XAccessibleTableRef
;
320 explicit ScAccessibleCsvGrid( ScCsvGrid
& rGrid
);
321 virtual ~ScAccessibleCsvGrid();
323 // XAccessibleComponent ---------------------------------------------------
325 /** Returns the cell at the specified point. */
326 virtual XAccessibleRef SAL_CALL
getAccessibleAtPoint( const AwtPoint
& rPoint
)
327 throw( ::com::sun::star::uno::RuntimeException
);
329 virtual sal_Int32 SAL_CALL
getForeground( )
330 throw (::com::sun::star::uno::RuntimeException
);
332 virtual sal_Int32 SAL_CALL
getBackground( )
333 throw (::com::sun::star::uno::RuntimeException
);
335 // XAccessibleContext -----------------------------------------------------
337 /** Returns the child count (count of cells in the table). */
338 virtual sal_Int32 SAL_CALL
getAccessibleChildCount()
339 throw( ::com::sun::star::uno::RuntimeException
);
341 /** Returns the specified child cell. */
342 virtual XAccessibleRef SAL_CALL
getAccessibleChild( sal_Int32 nIndex
)
343 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
345 /** Returns the relation to the ruler control. */
346 virtual XAccessibleRelationSetRef SAL_CALL
getAccessibleRelationSet()
347 throw( ::com::sun::star::uno::RuntimeException
);
349 /** Returns the current set of states. */
350 virtual XAccessibleStateSetRef SAL_CALL
getAccessibleStateSet()
351 throw( ::com::sun::star::uno::RuntimeException
);
353 // XAccessibleTable -------------------------------------------------------
355 /** Returns the number of rows in the table. */
356 virtual sal_Int32 SAL_CALL
getAccessibleRowCount()
357 throw( ::com::sun::star::uno::RuntimeException
);
359 /** Returns the number of columns in the table. */
360 virtual sal_Int32 SAL_CALL
getAccessibleColumnCount()
361 throw( ::com::sun::star::uno::RuntimeException
);
363 /** Returns the description of the specified row in the table. */
364 virtual OUString SAL_CALL
getAccessibleRowDescription( sal_Int32 nRow
)
365 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
367 /** Returns the description text of the specified column in the table. */
368 virtual OUString SAL_CALL
getAccessibleColumnDescription( sal_Int32 nColumn
)
369 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
371 /** Returns the number of rows occupied at a specified row and column.
372 @descr Returns always 1 (Merged cells not supported). */
373 virtual sal_Int32 SAL_CALL
getAccessibleRowExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
)
374 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
376 /** Returns the number of rows occupied at a specified row and column.
377 @descr Returns always 1 (Merged cells not supported). */
378 virtual sal_Int32 SAL_CALL
getAccessibleColumnExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
)
379 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
381 /** Returns the row headers as an AccessibleTable. */
382 virtual XAccessibleTableRef SAL_CALL
getAccessibleRowHeaders()
383 throw( ::com::sun::star::uno::RuntimeException
);
385 /** Returns the column headers as an AccessibleTable. */
386 virtual XAccessibleTableRef SAL_CALL
getAccessibleColumnHeaders()
387 throw( ::com::sun::star::uno::RuntimeException
);
389 /** Returns the selected rows as a sequence. */
390 virtual ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleRows()
391 throw( ::com::sun::star::uno::RuntimeException
);
393 /** Returns the selected columns as a sequence. */
394 virtual ::com::sun::star::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleColumns()
395 throw( ::com::sun::star::uno::RuntimeException
);
397 /** Returns true, if the specified row is selected. */
398 virtual sal_Bool SAL_CALL
isAccessibleRowSelected( sal_Int32 nRow
)
399 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
401 /** Returns true, if the specified column is selected. */
402 virtual sal_Bool SAL_CALL
isAccessibleColumnSelected( sal_Int32 nColumn
)
403 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
405 /** Returns the accessible cell object at the specified position. */
406 virtual XAccessibleRef SAL_CALL
getAccessibleCellAt( sal_Int32 nRow
, sal_Int32 nColumn
)
407 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
409 /** Returns the caption object of the table. */
410 virtual XAccessibleRef SAL_CALL
getAccessibleCaption()
411 throw( ::com::sun::star::uno::RuntimeException
);
413 /** Returns the summary description object of the table. */
414 virtual XAccessibleRef SAL_CALL
getAccessibleSummary()
415 throw( ::com::sun::star::uno::RuntimeException
);
417 /** Returns true, if the cell at a specified position is selected. */
418 virtual sal_Bool SAL_CALL
isAccessibleSelected( sal_Int32 nRow
, sal_Int32 nColumn
)
419 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
421 /** Returns the child index of the cell at the specified position. */
422 virtual sal_Int32 SAL_CALL
getAccessibleIndex( sal_Int32 nRow
, sal_Int32 nColumn
)
423 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
425 /** Returns the row index of the specified child. */
426 virtual sal_Int32 SAL_CALL
getAccessibleRow( sal_Int32 nChildIndex
)
427 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
429 /** Returns the column index of the specified child. */
430 virtual sal_Int32 SAL_CALL
getAccessibleColumn( sal_Int32 nChildIndex
)
431 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
433 // XAccessibleSelection ---------------------------------------------------
435 /** Selects the specified child (selects the entire column or the entire table). */
436 virtual void SAL_CALL
selectAccessibleChild( sal_Int32 nChildIndex
)
437 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
439 /** Returns true, if the specified child is selected. */
440 virtual sal_Bool SAL_CALL
isAccessibleChildSelected( sal_Int32 nChildIndex
)
441 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
443 /** Deselects all cells. */
444 virtual void SAL_CALL
clearAccessibleSelection()
445 throw( ::com::sun::star::uno::RuntimeException
);
447 /** Selects all cells. */
448 virtual void SAL_CALL
selectAllAccessibleChildren()
449 throw( ::com::sun::star::uno::RuntimeException
);
451 /** Returns the count of selected children. */
452 virtual sal_Int32 SAL_CALL
getSelectedAccessibleChildCount()
453 throw( ::com::sun::star::uno::RuntimeException
);
455 /** Returns the child with the specified index in all selected children. */
456 virtual XAccessibleRef SAL_CALL
getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
457 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
459 /** Deselects the child with the specified index in all selected children. */
460 virtual void SAL_CALL
deselectAccessibleChild( sal_Int32 nSelectedChildIndex
)
461 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
463 // XInterface -------------------------------------------------------------
465 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
)
466 throw( ::com::sun::star::uno::RuntimeException
);
468 virtual void SAL_CALL
acquire() throw();
470 virtual void SAL_CALL
release() throw();
472 // XServiceInfo -----------------------------------------------------------
474 /** Returns an identifier for the implementation of this object. */
475 virtual OUString SAL_CALL
getImplementationName()
476 throw( ::com::sun::star::uno::RuntimeException
);
478 // XTypeProvider ----------------------------------------------------------
480 /** Returns a sequence with all supported interface types. */
481 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes()
482 throw( ::com::sun::star::uno::RuntimeException
);
484 /** Returns an implementation ID. */
485 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
486 throw( ::com::sun::star::uno::RuntimeException
);
488 // events -----------------------------------------------------------------
490 /** Sends a GetFocus or LoseFocus event to all listeners. */
491 virtual void SendFocusEvent( bool bFocused
);
492 /** Sends a table model changed event for changed cell contents to all listeners. */
493 virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
, bool bAllRows
);
494 /** Sends a table model changed event for an inserted column to all listeners. */
495 virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
);
496 /** Sends a table model changed event for a removed column to all listeners. */
497 virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
);
499 // helpers ----------------------------------------------------------------
501 /** Returns this object's name. */
502 virtual OUString SAL_CALL
createAccessibleName()
503 throw( ::com::sun::star::uno::RuntimeException
);
504 /** Returns this object's description. */
505 virtual OUString SAL_CALL
createAccessibleDescription()
506 throw( ::com::sun::star::uno::RuntimeException
);
508 /** Throws an exception, if nIndex is not a valid child index. */
509 void ensureValidIndex( sal_Int32 nIndex
) const
510 throw( ::com::sun::star::lang::IndexOutOfBoundsException
);
511 /** Throws an exception, if the specified position is invalid. */
512 void ensureValidPosition( sal_Int32 nRow
, sal_Int32 nColumn
) const
513 throw( ::com::sun::star::lang::IndexOutOfBoundsException
);
515 /** Returns the VCL grid control. Assumes a living object. */
516 ScCsvGrid
& implGetGrid() const;
518 /** Returns true, if the specified column (including header) is selected. */
519 bool implIsColumnSelected( sal_Int32 nColumn
) const;
520 /** Selects the specified column (including header). */
521 void implSelectColumn( sal_Int32 nColumn
, bool bSelect
);
523 /** Returns the count of visible rows in the table (including header). */
524 sal_Int32
implGetRowCount() const;
525 /** Returns the total column count in the table (including header). */
526 sal_Int32
implGetColumnCount() const;
527 /** Returns the count of selected columns in the table. */
528 sal_Int32
implGetSelColumnCount() const;
529 /** Returns the total cell count in the table (including header). */
530 inline sal_Int32
implGetCellCount() const { return implGetRowCount() * implGetColumnCount(); }
532 /** Returns the row index from cell index (including header). */
533 inline sal_Int32
implGetRow( sal_Int32 nIndex
) const { return nIndex
/ implGetColumnCount(); }
534 /** Returns the column index from cell index (including header). */
535 inline sal_Int32
implGetColumn( sal_Int32 nIndex
) const { return nIndex
% implGetColumnCount(); }
536 /** Returns the absolute column index of the nSelColumn-th selected column. */
537 sal_Int32
implGetSelColumn( sal_Int32 nSelColumn
) const;
538 /** Returns the child index from cell position (including header). */
539 inline sal_Int32
implGetIndex( sal_Int32 nRow
, sal_Int32 nColumn
) const { return nRow
* implGetColumnCount() + nColumn
; }
541 /** Returns the contents of the specified cell (including header). Indexes must be valid. */
542 String
implGetCellText( sal_Int32 nRow
, sal_Int32 nColumn
) const;
543 /** Creates a new accessible object of the specified cell. Indexes must be valid. */
544 ScAccessibleCsvControl
* implCreateCellObj( sal_Int32 nRow
, sal_Int32 nColumn
) const;
548 // ============================================================================
550 /** Accessible class representing a cell of the CSV grid control. */
551 class ScAccessibleCsvCell
: public ScAccessibleCsvControl
, public accessibility::AccessibleStaticTextBase
554 typedef ::com::sun::star::uno::Sequence
<
555 ::com::sun::star::beans::PropertyValue
> PropertyValueSeq
;
556 typedef ::std::auto_ptr
< SvxEditSource
> SvxEditSourcePtr
;
559 String maCellText
; /// The text contents of this cell.
560 sal_Int32 mnLine
; /// The grid line index (core index).
561 sal_uInt32 mnColumn
; /// The grid column index (core index).
562 sal_Int32 mnIndex
; /// The index of the cell in the table.
565 explicit ScAccessibleCsvCell(
567 const String
& rCellText
,
568 sal_Int32 nRow
, sal_Int32 nColumn
);
569 virtual ~ScAccessibleCsvCell();
571 using ScAccessibleCsvControl::disposing
;
572 virtual void SAL_CALL
disposing();
574 // XAccessibleComponent ---------------------------------------------------
576 /** Sets the focus to the column of this cell. */
577 virtual void SAL_CALL
grabFocus() throw( ::com::sun::star::uno::RuntimeException
);
579 virtual sal_Int32 SAL_CALL
getForeground( )
580 throw (::com::sun::star::uno::RuntimeException
);
582 virtual sal_Int32 SAL_CALL
getBackground( )
583 throw (::com::sun::star::uno::RuntimeException
);
585 // XAccessibleContext -----------------------------------------------------
587 /** Returns the child count. */
588 virtual sal_Int32 SAL_CALL
getAccessibleChildCount()
589 throw( ::com::sun::star::uno::RuntimeException
);
591 /** Returns the specified child. */
592 virtual XAccessibleRef SAL_CALL
getAccessibleChild( sal_Int32 nIndex
)
593 throw( ::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
595 /** Returns the index of this cell in the table. */
596 virtual sal_Int32 SAL_CALL
getAccessibleIndexInParent()
597 throw( ::com::sun::star::uno::RuntimeException
);
599 /** Returns the relation to the ruler control. */
600 virtual XAccessibleRelationSetRef SAL_CALL
getAccessibleRelationSet()
601 throw( ::com::sun::star::uno::RuntimeException
);
603 /** Returns the current set of states. */
604 virtual XAccessibleStateSetRef SAL_CALL
getAccessibleStateSet()
605 throw( ::com::sun::star::uno::RuntimeException
);
607 // XInterface -------------------------------------------------------------
611 // XTypeProvider ----------------------------------------------------------
613 DECLARE_XTYPEPROVIDER()
615 // XServiceInfo -----------------------------------------------------------
617 /** Returns an identifier for the implementation of this object. */
618 virtual OUString SAL_CALL
getImplementationName()
619 throw( ::com::sun::star::uno::RuntimeException
);
621 // helpers ----------------------------------------------------------------
623 /** Returns this object's current bounding box relative to the desktop. */
624 virtual Rectangle
GetBoundingBoxOnScreen() const throw( ::com::sun::star::uno::RuntimeException
);
625 /** Returns this object's current bounding box relative to the parent object. */
626 virtual Rectangle
GetBoundingBox() const throw( ::com::sun::star::uno::RuntimeException
);
629 /** Returns this object's name. */
630 virtual OUString SAL_CALL
createAccessibleName()
631 throw( ::com::sun::star::uno::RuntimeException
);
632 /** Returns this object's description. */
633 virtual OUString SAL_CALL
createAccessibleDescription()
634 throw( ::com::sun::star::uno::RuntimeException
);
636 /** Returns the VCL grid control. Assumes a living object. */
637 ScCsvGrid
& implGetGrid() const;
638 /** Returns the pixel position of the cell (rel. to parent), regardless of visibility. */
639 Point
implGetRealPos() const;
640 /** Returns the width of the character count */
641 sal_uInt32
implCalcPixelWidth(sal_uInt32 nChars
) const;
642 /** Returns the pixel size of the cell, regardless of visibility. */
643 Size
implGetRealSize() const;
644 /** Returns the bounding box of the cell relative in the table. */
645 Rectangle
implGetBoundingBox() const;
647 /** Creates the edit source the text helper needs. */
648 ::std::auto_ptr
< SvxEditSource
> implCreateEditSource();
652 // ============================================================================
656 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */