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