xref: /trunk/main/sc/source/ui/inc/AccessibleSpreadsheet.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 #ifndef _SC_ACCESSIBLESPREADSHEET_HXX
30 #define _SC_ACCESSIBLESPREADSHEET_HXX
31 
32 #include "AccessibleTableBase.hxx"
33 #include "viewdata.hxx"
34 
35 #include <vector>
36 
37 class ScMyAddress : public ScAddress
38 {
39 public:
40     ScMyAddress() : ScAddress() {}
41     ScMyAddress(SCCOL nColP, SCROW nRowP, SCTAB nTabP) : ScAddress(nColP, nRowP, nTabP) {}
42     ScMyAddress(const ScAddress& rAddress) : ScAddress(rAddress) {}
43 
44     sal_Bool operator< ( const ScMyAddress& rAddress ) const
45     {
46         if( Row() != rAddress.Row() )
47             return (Row() < rAddress.Row());
48         else
49             return (Col() < rAddress.Col());
50     }
51 };
52 
53 class ScTabViewShell;
54 class ScAccessibleDocument;
55 class ScAccessibleCell;
56 
57 /** @descr
58         This base class provides an implementation of the
59         <code>AccessibleTable</code> service.
60 */
61 class ScAccessibleSpreadsheet
62     :   public  ScAccessibleTableBase
63 {
64 public:
65     //=====  internal  ========================================================
66     ScAccessibleSpreadsheet(
67         ScAccessibleDocument* pAccDoc,
68         ScTabViewShell* pViewShell,
69         SCTAB   nTab,
70         ScSplitPos eSplitPos);
71 protected:
72     ScAccessibleSpreadsheet(
73         ScAccessibleSpreadsheet& rParent,
74         const ScRange& rRange );
75 
76     virtual ~ScAccessibleSpreadsheet();
77 
78     void ConstructScAccessibleSpreadsheet(
79         ScAccessibleDocument* pAccDoc,
80         ScTabViewShell* pViewShell,
81         SCTAB nTab,
82         ScSplitPos eSplitPos);
83 
84     using ScAccessibleTableBase::IsDefunc;
85 
86 public:
87     using ScAccessibleTableBase::addEventListener;
88     using ScAccessibleTableBase::disposing;
89 
90     virtual void SAL_CALL disposing();
91 
92     void CompleteSelectionChanged(sal_Bool bNewState);
93 
94     virtual void LostFocus();
95 
96     virtual void GotFocus();
97 
98     void BoundingBoxChanged();
99 
100     void VisAreaChanged();
101 
102     ///=====  SfxListener  =====================================================
103 
104     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
105 
106     ///=====  XAccessibleTable  ================================================
107 
108     /// Returns the row headers as an AccessibleTable.
109     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
110                 getAccessibleRowHeaders(  )
111                     throw (::com::sun::star::uno::RuntimeException);
112 
113     /// Returns the column headers as an AccessibleTable.
114     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
115                 getAccessibleColumnHeaders(  )
116                     throw (::com::sun::star::uno::RuntimeException);
117 
118     /// Returns the selected rows in a table.
119     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
120                 getSelectedAccessibleRows(  )
121                     throw (::com::sun::star::uno::RuntimeException);
122 
123     /// Returns the selected columns in a table.
124     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
125                 getSelectedAccessibleColumns(  )
126                     throw (::com::sun::star::uno::RuntimeException);
127 
128     /// Returns a boolean value indicating whether the specified row is selected.
129     virtual sal_Bool SAL_CALL
130                 isAccessibleRowSelected( sal_Int32 nRow )
131                     throw (::com::sun::star::uno::RuntimeException,
132                     ::com::sun::star::lang::IndexOutOfBoundsException);
133 
134     /// Returns a boolean value indicating whether the specified column is selected.
135     virtual sal_Bool SAL_CALL
136                 isAccessibleColumnSelected( sal_Int32 nColumn )
137                     throw (::com::sun::star::uno::RuntimeException,
138                     ::com::sun::star::lang::IndexOutOfBoundsException);
139 
140     /// Returns the Accessible at a specified row and column in the table.
141     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
142                 getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
143                     throw (::com::sun::star::uno::RuntimeException,
144                             ::com::sun::star::lang::IndexOutOfBoundsException);
145 
146     ScAccessibleCell* GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn);
147 
148     /// Returns a boolean value indicating whether the accessible at a specified row and column is selected.
149     virtual sal_Bool SAL_CALL
150                 isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
151                     throw (::com::sun::star::uno::RuntimeException,
152                     ::com::sun::star::lang::IndexOutOfBoundsException);
153 
154     ///=====  XAccessibleComponent  ============================================
155 
156     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
157         SAL_CALL getAccessibleAtPoint(
158         const ::com::sun::star::awt::Point& rPoint )
159         throw (::com::sun::star::uno::RuntimeException);
160 
161     virtual void SAL_CALL grabFocus(  )
162         throw (::com::sun::star::uno::RuntimeException);
163 
164     virtual sal_Int32 SAL_CALL getForeground(  )
165         throw (::com::sun::star::uno::RuntimeException);
166 
167     virtual sal_Int32 SAL_CALL getBackground(  )
168         throw (::com::sun::star::uno::RuntimeException);
169 
170     ///=====  XAccessibleContext  ==============================================
171 
172     /// Return NULL to indicate that an empty relation set.
173     virtual ::com::sun::star::uno::Reference<
174             ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
175         getAccessibleRelationSet(void)
176         throw (::com::sun::star::uno::RuntimeException);
177 
178     /// Return the set of current states.
179     virtual ::com::sun::star::uno::Reference<
180             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
181         getAccessibleStateSet(void)
182         throw (::com::sun::star::uno::RuntimeException);
183 
184     ///=====  XAccessibleSelection  ===========================================
185 
186     virtual void SAL_CALL
187         selectAccessibleChild( sal_Int32 nChildIndex )
188         throw (::com::sun::star::lang::IndexOutOfBoundsException,
189         ::com::sun::star::uno::RuntimeException);
190 
191     virtual void SAL_CALL
192         clearAccessibleSelection(  )
193         throw (::com::sun::star::uno::RuntimeException);
194 
195     virtual void SAL_CALL
196         selectAllAccessibleChildren(  )
197         throw (::com::sun::star::uno::RuntimeException);
198 
199     virtual sal_Int32 SAL_CALL
200         getSelectedAccessibleChildCount(  )
201         throw (::com::sun::star::uno::RuntimeException);
202 
203     virtual ::com::sun::star::uno::Reference<
204         ::com::sun::star::accessibility::XAccessible > SAL_CALL
205         getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
206         throw (::com::sun::star::lang::IndexOutOfBoundsException,
207         ::com::sun::star::uno::RuntimeException);
208 
209     virtual void SAL_CALL
210         deselectAccessibleChild( sal_Int32 nChildIndex )
211         throw (::com::sun::star::lang::IndexOutOfBoundsException,
212         ::com::sun::star::uno::RuntimeException);
213 
214     ///=====  XServiceInfo  ====================================================
215 
216     /** Returns an identifier for the implementation of this object.
217     */
218     virtual ::rtl::OUString SAL_CALL
219         getImplementationName(void)
220         throw (::com::sun::star::uno::RuntimeException);
221 
222     /** Returns a list of all supported services.
223     */
224     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
225         getSupportedServiceNames(void)
226         throw (::com::sun::star::uno::RuntimeException);
227 
228     ///=====  XTypeProvider  ===================================================
229 
230     /** Returns a implementation id.
231     */
232     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
233         getImplementationId(void)
234         throw (::com::sun::star::uno::RuntimeException);
235 
236     ///=====  XAccessibleEventBroadcaster  =====================================
237 
238     /** Add listener that is informed of future changes of name,
239         description and so on events.
240     */
241     virtual void SAL_CALL
242         addEventListener(
243             const ::com::sun::star::uno::Reference<
244                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
245         throw (com::sun::star::uno::RuntimeException);
246 
247 protected:
248     /// Return the object's current bounding box relative to the desktop.
249     virtual Rectangle GetBoundingBoxOnScreen(void) const
250         throw (::com::sun::star::uno::RuntimeException);
251 
252     /// Return the object's current bounding box relative to the parent object.
253     virtual Rectangle GetBoundingBox(void) const
254         throw (::com::sun::star::uno::RuntimeException);
255 private:
256     ScTabViewShell* mpViewShell;
257     ScRangeList*    mpMarkedRanges;
258     std::vector<ScMyAddress>* mpSortedMarkedCells;
259     ScAccessibleDocument* mpAccDoc;
260     ScAccessibleCell*   mpAccCell;
261     Rectangle       maVisCells;
262     ScSplitPos      meSplitPos;
263     ScAddress       maActiveCell;
264     SCTAB           mnTab;
265     sal_Bool        mbIsSpreadsheet;
266     sal_Bool        mbHasSelection;
267     sal_Bool        mbDelIns;
268     sal_Bool        mbIsFocusSend;
269 
270     sal_Bool IsDefunc(
271         const com::sun::star::uno::Reference<
272         ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
273     sal_Bool IsEditable(
274         const com::sun::star::uno::Reference<
275         ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
276     sal_Bool IsFocused();
277     sal_Bool IsCompleteSheetSelected();
278 
279     void SelectCell(sal_Int32 nRow, sal_Int32 nCol, sal_Bool bDeselect);
280     void CreateSortedMarkedCells();
281     void AddMarkedRange(const ScRange& rRange);
282 
283     ScDocument* GetDocument(ScTabViewShell* pViewShell);
284     Rectangle   GetVisArea(ScTabViewShell* pViewShell, ScSplitPos eSplitPos);
285     Rectangle   GetVisCells(const Rectangle& rVisArea);
286 };
287 
288 
289 #endif
290