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 #ifndef INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLECSVCONTROL_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLECSVCONTROL_HXX
23 #include <com/sun/star/accessibility/XAccessibleText.hpp>
24 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
25 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
26 #include <tools/gen.hxx>
27 #include <rtl/ustrbuf.hxx>
28 #include <cppuhelper/implbase1.hxx>
29 #include <cppuhelper/implbase2.hxx>
30 #include <editeng/AccessibleStaticTextBase.hxx>
31 #include <comphelper/uno3.hxx>
32 #include <vcl/vclptr.hxx>
33 #include "AccessibleContextBase.hxx"
37 namespace utl
{ class AccessibleStateSetHelper
; }
39 /** Accessible base class used for CSV controls. */
40 class ScAccessibleCsvControl
: public ScAccessibleContextBase
43 VclPtr
<ScCsvControl
> mpControl
; /// Pointer to the VCL control.
46 explicit ScAccessibleCsvControl(
47 const css::uno::Reference
< css::accessibility::XAccessible
>& rxParent
,
48 ScCsvControl
& rControl
,
50 virtual ~ScAccessibleCsvControl();
52 using ScAccessibleContextBase::disposing
;
53 virtual void SAL_CALL
disposing() override
;
55 /** Returns true, if the control is visible. */
56 virtual bool SAL_CALL
isVisible() throw( css::uno::RuntimeException
, std::exception
) override
;
58 // XAccessibleComponent ---------------------------------------------------
60 /** Returns the child at the specified point (cell returns NULL). */
61 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleAtPoint( const css::awt::Point
& rPoint
)
62 throw( css::uno::RuntimeException
, std::exception
) override
;
64 /** Sets the focus to this control. */
65 virtual void SAL_CALL
grabFocus() throw( css::uno::RuntimeException
, std::exception
) override
;
67 // events -----------------------------------------------------------------
69 /** Sends a GetFocus or LoseFocus event to all listeners. */
70 virtual void SendFocusEvent( bool bFocused
);
71 /** Sends a caret changed event to all listeners. */
72 virtual void SendCaretEvent();
73 /** Sends a visible area changed event to all listeners. */
74 void SendVisibleEvent();
75 /** Sends a selection changed event to all listeners. */
76 void SendSelectionEvent();
77 /** Sends a table model changed event for changed cell contents to all listeners. */
78 virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
, bool bAllRows
);
79 /** Sends a table model changed event for an inserted column to all listeners. */
80 virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
);
81 /** Sends a table model changed event for a removed column to all listeners. */
82 virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
);
84 // helpers ----------------------------------------------------------------
86 /** Returns this object's current bounding box relative to the desktop. */
87 virtual Rectangle
GetBoundingBoxOnScreen() const throw( css::uno::RuntimeException
, std::exception
) override
;
88 /** Returns this object's current bounding box relative to the parent object. */
89 virtual Rectangle
GetBoundingBox() const throw( css::uno::RuntimeException
, std::exception
) override
;
91 /** Returns whether the object is alive. Must be called with locked mutex. */
92 inline bool implIsAlive() const { return !rBHelper
.bDisposed
&& !rBHelper
.bInDispose
&& mpControl
; }
93 /** Throws an exception, if the object is disposed/disposing or any pointer
94 is missing. Should be used with locked mutex! */
95 void ensureAlive() const throw( css::lang::DisposedException
);
97 /** Returns the VCL control. Assumes a living object. */
98 ScCsvControl
& implGetControl() const;
100 /** Returns the first child of rxParentObj, which has the role nRole. */
101 static css::uno::Reference
< css::accessibility::XAccessible
> implGetChildByRole( const css::uno::Reference
< css::accessibility::XAccessible
>& rxParentObj
, sal_uInt16 nRole
)
102 throw( css::uno::RuntimeException
);
103 /** Creates a StateSetHelper and fills it with DEFUNC, OPAQUE, ENABLED, SHOWING and VISIBLE. */
104 ::utl::AccessibleStateSetHelper
* implCreateStateSet();
106 /** Disposes the object. This is a helper called from destructors only. */
109 /** Converts the control-relative position to an absolute screen position. */
110 Point
implGetAbsPos( const Point
& rPos
) const;
115 typedef ::cppu::ImplHelper1
< css::accessibility::XAccessibleText
> ScAccessibleCsvRulerImpl
;
117 /** Accessible class representing the CSV ruler control. */
118 class ScAccessibleCsvRuler
: public ScAccessibleCsvControl
, public ScAccessibleCsvRulerImpl
121 OUStringBuffer maBuffer
; /// Contains the text representation of the ruler.
124 explicit ScAccessibleCsvRuler( ScCsvRuler
& rRuler
);
125 virtual ~ScAccessibleCsvRuler();
127 // XAccessibleComponent -----------------------------------------------------
129 virtual sal_Int32 SAL_CALL
getForeground( )
130 throw (css::uno::RuntimeException
, std::exception
) override
;
132 virtual sal_Int32 SAL_CALL
getBackground( )
133 throw (css::uno::RuntimeException
, std::exception
) override
;
135 // XAccessibleContext -----------------------------------------------------
137 /** Returns the child count (the ruler does not have children). */
138 virtual sal_Int32 SAL_CALL
getAccessibleChildCount()
139 throw( css::uno::RuntimeException
, std::exception
) override
;
141 /** Throws an exception (the ruler does not have children). */
142 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int32 nIndex
)
143 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
145 /** Returns the relation to the grid control. */
146 virtual css::uno::Reference
< css::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet()
147 throw( css::uno::RuntimeException
, std::exception
) override
;
149 /** Returns the current set of states. */
150 virtual css::uno::Reference
< css::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet()
151 throw( css::uno::RuntimeException
, std::exception
) override
;
153 // XAccessibleText --------------------------------------------------------
155 /** Return the position of the caret. */
156 virtual sal_Int32 SAL_CALL
getCaretPosition() throw( css::uno::RuntimeException
, std::exception
) override
;
158 /** Sets the position of the caret. */
159 virtual sal_Bool SAL_CALL
setCaretPosition( sal_Int32 nIndex
)
160 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
162 /** Returns the specified character. */
163 virtual sal_Unicode SAL_CALL
getCharacter( sal_Int32 nIndex
)
164 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
166 /** Returns the attributes of the specified character. */
167 virtual css::uno::Sequence
< css::beans::PropertyValue
> SAL_CALL
getCharacterAttributes( sal_Int32 nIndex
, const css::uno::Sequence
< OUString
>& aRequestedAttributes
)
168 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
170 /** Returns the screen coordinates of the specified character. */
171 virtual css::awt::Rectangle SAL_CALL
getCharacterBounds( sal_Int32 nIndex
)
172 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
174 /** Returns the count of characters. */
175 virtual sal_Int32 SAL_CALL
getCharacterCount() throw( css::uno::RuntimeException
, std::exception
) override
;
177 /** Returns the character index at the specified coordinate (object's coordinate system). */
178 virtual sal_Int32 SAL_CALL
getIndexAtPoint( const css::awt::Point
& rPoint
)
179 throw( css::uno::RuntimeException
, std::exception
) override
;
181 /** Returns the selected text (ruler returns empty string). */
182 virtual OUString SAL_CALL
getSelectedText() throw( css::uno::RuntimeException
, std::exception
) override
;
184 /** Returns the start index of the selection (ruler returns -1). */
185 virtual sal_Int32 SAL_CALL
getSelectionStart() throw( css::uno::RuntimeException
, std::exception
) override
;
187 /** Returns the end index of the selection (ruler returns -1). */
188 virtual sal_Int32 SAL_CALL
getSelectionEnd() throw( css::uno::RuntimeException
, std::exception
) override
;
190 /** Selects a part of the text (ruler does nothing). */
191 virtual sal_Bool SAL_CALL
setSelection( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
)
192 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
194 /** Returns the entire text. */
195 virtual OUString SAL_CALL
getText() throw( css::uno::RuntimeException
, std::exception
) override
;
197 /** Returns the specified range [Start,End) of the text. */
198 virtual OUString SAL_CALL
getTextRange( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
)
199 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
201 /** Returns the specified text portion. */
202 virtual css::accessibility::TextSegment SAL_CALL
getTextAtIndex( sal_Int32 nIndex
, sal_Int16 aTextType
) throw (css::lang::IndexOutOfBoundsException
, css::lang::IllegalArgumentException
, css::uno::RuntimeException
, std::exception
) override
;
203 virtual css::accessibility::TextSegment SAL_CALL
getTextBeforeIndex( sal_Int32 nIndex
, sal_Int16 aTextType
) throw (css::lang::IndexOutOfBoundsException
, css::lang::IllegalArgumentException
, css::uno::RuntimeException
, std::exception
) override
;
204 virtual css::accessibility::TextSegment SAL_CALL
getTextBehindIndex( sal_Int32 nIndex
, sal_Int16 aTextType
) throw (css::lang::IndexOutOfBoundsException
, css::lang::IllegalArgumentException
, css::uno::RuntimeException
, std::exception
) override
;
206 /** Copies the specified text range into the clipboard (ruler does nothing). */
207 virtual sal_Bool SAL_CALL
copyText( sal_Int32 nStartIndex
, sal_Int32 nEndIndex
)
208 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
210 // XInterface -------------------------------------------------------------
212 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
)
213 throw( css::uno::RuntimeException
, std::exception
) override
;
215 virtual void SAL_CALL
acquire() throw() override
;
217 virtual void SAL_CALL
release() throw() override
;
219 // XServiceInfo -----------------------------------------------------------
221 /** Returns an identifier for the implementation of this object. */
222 virtual OUString SAL_CALL
getImplementationName()
223 throw( css::uno::RuntimeException
, std::exception
) override
;
225 // XTypeProvider ----------------------------------------------------------
227 /** Returns a sequence with all supported interface types. */
228 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes()
229 throw( css::uno::RuntimeException
, std::exception
) override
;
231 /** Returns an implementation ID. */
232 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
233 throw( css::uno::RuntimeException
, std::exception
) override
;
235 // events -----------------------------------------------------------------
237 /** Sends a caret changed event to all listeners. */
238 virtual void SendCaretEvent() override
;
240 // helpers ----------------------------------------------------------------
242 /** Returns this object's name. */
243 virtual OUString SAL_CALL
createAccessibleName()
244 throw( css::uno::RuntimeException
, std::exception
) override
;
245 /** Returns this object's description. */
246 virtual OUString SAL_CALL
createAccessibleDescription()
247 throw( css::uno::RuntimeException
, std::exception
) override
;
249 /** Throws an exception, if the specified character position is invalid (outside 0..len-1). */
250 void ensureValidIndex( sal_Int32 nIndex
) const
251 throw( css::lang::IndexOutOfBoundsException
);
252 /** Throws an exception, if the specified character position is invalid (outside 0..len). */
253 void ensureValidIndexWithEnd( sal_Int32 nIndex
) const
254 throw( css::lang::IndexOutOfBoundsException
);
255 /** Throws an exception, if the specified character range [Start,End) is invalid.
256 @descr If Start>End, swaps Start and End before checking. */
257 void ensureValidRange( sal_Int32
& rnStartIndex
, sal_Int32
& rnEndIndex
) const
258 throw( css::lang::IndexOutOfBoundsException
);
260 /** Returns the VCL ruler control. Assumes a living object. */
261 ScCsvRuler
& implGetRuler() const;
263 /** Builds the entire string buffer. */
264 void constructStringBuffer() throw( css::uno::RuntimeException
);
265 /** Returns the character count of the text. */
266 sal_Int32
implGetTextLength() const;
268 /** Returns true, if the character at the specified index has a split. */
269 bool implHasSplit( sal_Int32 nApiPos
);
271 /** Returns the first character index with equal formatting as at nApiPos. */
272 sal_Int32
implGetFirstEqualFormatted( sal_Int32 nApiPos
);
273 /** Returns the last character index with equal formatting as at nApiPos. */
274 sal_Int32
implGetLastEqualFormatted( sal_Int32 nApiPos
);
279 typedef ::cppu::ImplHelper2
<
280 css::accessibility::XAccessibleTable
,
281 css::accessibility::XAccessibleSelection
>
282 ScAccessibleCsvGridImpl
;
284 /** Accessible class representing the CSV grid control. */
285 class ScAccessibleCsvGrid
: public ScAccessibleCsvControl
, public ScAccessibleCsvGridImpl
288 typedef css::uno::Reference
< css::accessibility::XAccessibleTable
> XAccessibleTableRef
;
289 typedef std::map
< sal_Int32
, rtl::Reference
<ScAccessibleCsvControl
> > XAccessibleSet
;
292 XAccessibleSet maAccessibleChildren
;
295 explicit ScAccessibleCsvGrid( ScCsvGrid
& rGrid
);
296 virtual ~ScAccessibleCsvGrid();
297 using ScAccessibleContextBase::disposing
;
298 virtual void SAL_CALL
disposing() override
;
300 // XAccessibleComponent ---------------------------------------------------
302 /** Returns the cell at the specified point. */
303 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleAtPoint( const css::awt::Point
& rPoint
)
304 throw( css::uno::RuntimeException
, std::exception
) override
;
306 virtual sal_Int32 SAL_CALL
getForeground( )
307 throw (css::uno::RuntimeException
, std::exception
) override
;
309 virtual sal_Int32 SAL_CALL
getBackground( )
310 throw (css::uno::RuntimeException
, std::exception
) override
;
312 // XAccessibleContext -----------------------------------------------------
314 /** Returns the child count (count of cells in the table). */
315 virtual sal_Int32 SAL_CALL
getAccessibleChildCount()
316 throw( css::uno::RuntimeException
, std::exception
) override
;
318 /** Returns the specified child cell. */
319 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int32 nIndex
)
320 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
322 /** Returns the relation to the ruler control. */
323 virtual css::uno::Reference
< css::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet()
324 throw( css::uno::RuntimeException
, std::exception
) override
;
326 /** Returns the current set of states. */
327 virtual css::uno::Reference
< css::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet()
328 throw( css::uno::RuntimeException
, std::exception
) override
;
330 // XAccessibleTable -------------------------------------------------------
332 /** Returns the number of rows in the table. */
333 virtual sal_Int32 SAL_CALL
getAccessibleRowCount()
334 throw( css::uno::RuntimeException
, std::exception
) override
;
336 /** Returns the number of columns in the table. */
337 virtual sal_Int32 SAL_CALL
getAccessibleColumnCount()
338 throw( css::uno::RuntimeException
, std::exception
) override
;
340 /** Returns the description of the specified row in the table. */
341 virtual OUString SAL_CALL
getAccessibleRowDescription( sal_Int32 nRow
)
342 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
344 /** Returns the description text of the specified column in the table. */
345 virtual OUString SAL_CALL
getAccessibleColumnDescription( sal_Int32 nColumn
)
346 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
348 /** Returns the number of rows occupied at a specified row and column.
349 @descr Returns always 1 (Merged cells not supported). */
350 virtual sal_Int32 SAL_CALL
getAccessibleRowExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
)
351 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
353 /** Returns the number of rows occupied at a specified row and column.
354 @descr Returns always 1 (Merged cells not supported). */
355 virtual sal_Int32 SAL_CALL
getAccessibleColumnExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
)
356 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
358 /** Returns the row headers as an AccessibleTable. */
359 virtual XAccessibleTableRef SAL_CALL
getAccessibleRowHeaders()
360 throw( css::uno::RuntimeException
, std::exception
) override
;
362 /** Returns the column headers as an AccessibleTable. */
363 virtual XAccessibleTableRef SAL_CALL
getAccessibleColumnHeaders()
364 throw( css::uno::RuntimeException
, std::exception
) override
;
366 /** Returns the selected rows as a sequence. */
367 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleRows()
368 throw( css::uno::RuntimeException
, std::exception
) override
;
370 /** Returns the selected columns as a sequence. */
371 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleColumns()
372 throw( css::uno::RuntimeException
, std::exception
) override
;
374 /** Returns true, if the specified row is selected. */
375 virtual sal_Bool SAL_CALL
isAccessibleRowSelected( sal_Int32 nRow
)
376 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
378 /** Returns true, if the specified column is selected. */
379 virtual sal_Bool SAL_CALL
isAccessibleColumnSelected( sal_Int32 nColumn
)
380 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
382 /** Returns the accessible cell object at the specified position. */
383 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleCellAt( sal_Int32 nRow
, sal_Int32 nColumn
)
384 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
386 /** Returns the caption object of the table. */
387 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleCaption()
388 throw( css::uno::RuntimeException
, std::exception
) override
;
390 /** Returns the summary description object of the table. */
391 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleSummary()
392 throw( css::uno::RuntimeException
, std::exception
) override
;
394 /** Returns true, if the cell at a specified position is selected. */
395 virtual sal_Bool SAL_CALL
isAccessibleSelected( sal_Int32 nRow
, sal_Int32 nColumn
)
396 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
398 /** Returns the child index of the cell at the specified position. */
399 virtual sal_Int32 SAL_CALL
getAccessibleIndex( sal_Int32 nRow
, sal_Int32 nColumn
)
400 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
402 /** Returns the row index of the specified child. */
403 virtual sal_Int32 SAL_CALL
getAccessibleRow( sal_Int32 nChildIndex
)
404 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
406 /** Returns the column index of the specified child. */
407 virtual sal_Int32 SAL_CALL
getAccessibleColumn( sal_Int32 nChildIndex
)
408 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
410 // XAccessibleSelection ---------------------------------------------------
412 /** Selects the specified child (selects the entire column or the entire table). */
413 virtual void SAL_CALL
selectAccessibleChild( sal_Int32 nChildIndex
)
414 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
416 /** Returns true, if the specified child is selected. */
417 virtual sal_Bool SAL_CALL
isAccessibleChildSelected( sal_Int32 nChildIndex
)
418 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
420 /** Deselects all cells. */
421 virtual void SAL_CALL
clearAccessibleSelection()
422 throw( css::uno::RuntimeException
, std::exception
) override
;
424 /** Selects all cells. */
425 virtual void SAL_CALL
selectAllAccessibleChildren()
426 throw( css::uno::RuntimeException
, std::exception
) override
;
428 /** Returns the count of selected children. */
429 virtual sal_Int32 SAL_CALL
getSelectedAccessibleChildCount()
430 throw( css::uno::RuntimeException
, std::exception
) override
;
432 /** Returns the child with the specified index in all selected children. */
433 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
434 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
436 /** Deselects the child with the specified index in all selected children. */
437 virtual void SAL_CALL
deselectAccessibleChild( sal_Int32 nSelectedChildIndex
)
438 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
440 // XInterface -------------------------------------------------------------
442 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
)
443 throw( css::uno::RuntimeException
, std::exception
) override
;
445 virtual void SAL_CALL
acquire() throw() override
;
447 virtual void SAL_CALL
release() throw() override
;
449 // XServiceInfo -----------------------------------------------------------
451 /** Returns an identifier for the implementation of this object. */
452 virtual OUString SAL_CALL
getImplementationName()
453 throw( css::uno::RuntimeException
, std::exception
) override
;
455 // XTypeProvider ----------------------------------------------------------
457 /** Returns a sequence with all supported interface types. */
458 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes()
459 throw( css::uno::RuntimeException
, std::exception
) override
;
461 /** Returns an implementation ID. */
462 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
463 throw( css::uno::RuntimeException
, std::exception
) override
;
465 // events -----------------------------------------------------------------
467 /** Sends a GetFocus or LoseFocus event to all listeners. */
468 virtual void SendFocusEvent( bool bFocused
) override
;
469 /** Sends a table model changed event for changed cell contents to all listeners. */
470 virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
, bool bAllRows
) override
;
471 /** Sends a table model changed event for an inserted column to all listeners. */
472 virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
) override
;
473 /** Sends a table model changed event for a removed column to all listeners. */
474 virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn
, sal_uInt32 nLastColumn
) override
;
476 // helpers ----------------------------------------------------------------
478 /** Returns this object's name. */
479 virtual OUString SAL_CALL
createAccessibleName()
480 throw( css::uno::RuntimeException
, std::exception
) override
;
481 /** Returns this object's description. */
482 virtual OUString SAL_CALL
createAccessibleDescription()
483 throw( css::uno::RuntimeException
, std::exception
) override
;
485 /** Throws an exception, if nIndex is not a valid child index. */
486 void ensureValidIndex( sal_Int32 nIndex
) const
487 throw( css::lang::IndexOutOfBoundsException
);
488 /** Throws an exception, if the specified position is invalid. */
489 void ensureValidPosition( sal_Int32 nRow
, sal_Int32 nColumn
) const
490 throw( css::lang::IndexOutOfBoundsException
);
492 /** Returns the VCL grid control. Assumes a living object. */
493 ScCsvGrid
& implGetGrid() const;
495 /** Returns true, if the specified column (including header) is selected. */
496 bool implIsColumnSelected( sal_Int32 nColumn
) const;
497 /** Selects the specified column (including header). */
498 void implSelectColumn( sal_Int32 nColumn
, bool bSelect
);
500 /** Returns the count of visible rows in the table (including header). */
501 sal_Int32
implGetRowCount() const;
502 /** Returns the total column count in the table (including header). */
503 sal_Int32
implGetColumnCount() const;
504 /** Returns the count of selected columns in the table. */
505 sal_Int32
implGetSelColumnCount() const;
506 /** Returns the total cell count in the table (including header). */
507 inline sal_Int32
implGetCellCount() const { return implGetRowCount() * implGetColumnCount(); }
509 /** Returns the row index from cell index (including header). */
510 inline sal_Int32
implGetRow( sal_Int32 nIndex
) const { return nIndex
/ implGetColumnCount(); }
511 /** Returns the column index from cell index (including header). */
512 inline sal_Int32
implGetColumn( sal_Int32 nIndex
) const { return nIndex
% implGetColumnCount(); }
513 /** Returns the absolute column index of the nSelColumn-th selected column. */
514 sal_Int32
implGetSelColumn( sal_Int32 nSelColumn
) const;
515 /** Returns the child index from cell position (including header). */
516 inline sal_Int32
implGetIndex( sal_Int32 nRow
, sal_Int32 nColumn
) const { return nRow
* implGetColumnCount() + nColumn
; }
518 /** Returns the contents of the specified cell (including header). Indexes must be valid. */
519 OUString
implGetCellText( sal_Int32 nRow
, sal_Int32 nColumn
) const;
520 /** Creates a new accessible object of the specified cell. Indexes must be valid. */
521 ScAccessibleCsvControl
* implCreateCellObj( sal_Int32 nRow
, sal_Int32 nColumn
) const;
523 css::uno::Reference
<css::accessibility::XAccessible
> getAccessibleCell(sal_Int32 nRow
, sal_Int32 nColumn
);
526 /** Accessible class representing a cell of the CSV grid control. */
527 class ScAccessibleCsvCell
: public ScAccessibleCsvControl
, public accessibility::AccessibleStaticTextBase
530 typedef ::std::unique_ptr
< SvxEditSource
> SvxEditSourcePtr
;
533 OUString maCellText
; /// The text contents of this cell.
534 sal_Int32 mnLine
; /// The grid line index (core index).
535 sal_uInt32 mnColumn
; /// The grid column index (core index).
536 sal_Int32 mnIndex
; /// The index of the cell in the table.
539 explicit ScAccessibleCsvCell(
541 const OUString
& rCellText
,
542 sal_Int32 nRow
, sal_Int32 nColumn
);
543 virtual ~ScAccessibleCsvCell();
545 using ScAccessibleCsvControl::disposing
;
546 virtual void SAL_CALL
disposing() override
;
548 // XAccessibleComponent ---------------------------------------------------
550 /** Sets the focus to the column of this cell. */
551 virtual void SAL_CALL
grabFocus() throw( css::uno::RuntimeException
, std::exception
) override
;
553 virtual sal_Int32 SAL_CALL
getForeground( )
554 throw (css::uno::RuntimeException
, std::exception
) override
;
556 virtual sal_Int32 SAL_CALL
getBackground( )
557 throw (css::uno::RuntimeException
, std::exception
) override
;
559 // XAccessibleContext -----------------------------------------------------
561 /** Returns the child count. */
562 virtual sal_Int32 SAL_CALL
getAccessibleChildCount()
563 throw( css::uno::RuntimeException
, std::exception
) override
;
565 /** Returns the specified child. */
566 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int32 nIndex
)
567 throw( css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
569 /** Returns the index of this cell in the table. */
570 virtual sal_Int32 SAL_CALL
getAccessibleIndexInParent()
571 throw( css::uno::RuntimeException
, std::exception
) override
;
573 /** Returns the relation to the ruler control. */
574 virtual css::uno::Reference
< css::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet()
575 throw( css::uno::RuntimeException
, std::exception
) override
;
577 /** Returns the current set of states. */
578 virtual css::uno::Reference
< css::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet()
579 throw( css::uno::RuntimeException
, std::exception
) override
;
581 // XInterface -------------------------------------------------------------
585 // XTypeProvider ----------------------------------------------------------
587 DECLARE_XTYPEPROVIDER()
589 // XServiceInfo -----------------------------------------------------------
591 /** Returns an identifier for the implementation of this object. */
592 virtual OUString SAL_CALL
getImplementationName()
593 throw( css::uno::RuntimeException
, std::exception
) override
;
595 // helpers ----------------------------------------------------------------
597 /** Returns this object's current bounding box relative to the desktop. */
598 virtual Rectangle
GetBoundingBoxOnScreen() const throw( css::uno::RuntimeException
, std::exception
) override
;
599 /** Returns this object's current bounding box relative to the parent object. */
600 virtual Rectangle
GetBoundingBox() const throw( css::uno::RuntimeException
, std::exception
) override
;
603 /** Returns this object's name. */
604 virtual OUString SAL_CALL
createAccessibleName()
605 throw( css::uno::RuntimeException
, std::exception
) override
;
606 /** Returns this object's description. */
607 virtual OUString SAL_CALL
createAccessibleDescription()
608 throw( css::uno::RuntimeException
) override
;
610 /** Returns the VCL grid control. Assumes a living object. */
611 ScCsvGrid
& implGetGrid() const;
612 /** Returns the pixel position of the cell (rel. to parent), regardless of visibility. */
613 Point
implGetRealPos() const;
614 /** Returns the width of the character count */
615 sal_uInt32
implCalcPixelWidth(sal_uInt32 nChars
) const;
616 /** Returns the pixel size of the cell, regardless of visibility. */
617 Size
implGetRealSize() const;
618 /** Returns the bounding box of the cell relative in the table. */
619 Rectangle
implGetBoundingBox() const;
621 /** Creates the edit source the text helper needs. */
622 ::std::unique_ptr
< SvxEditSource
> implCreateEditSource();
627 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */