1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 
25 #ifndef _SC_ACCESSIBLETABLEBASE_HXX
26 #define _SC_ACCESSIBLETABLEBASE_HXX
27 
28 #include "AccessibleContextBase.hxx"
29 #include "global.hxx"
30 #include "address.hxx"
31 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
32 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
33 //IAccessibility2 Implementation 2009-----
34 #include <com/sun/star/accessibility/XAccessibleTableSelection.hpp>
35 //-----IAccessibility2 Implementation 2009
36 #include <cppuhelper/implbase2.hxx>
37 
38 class ScTabViewShell;
39 
40 /**	@descr
41         This base class provides an implementation of the
42         <code>AccessibleTable</code> service.
43 */
44 
45 typedef cppu::ImplHelper2< ::com::sun::star::accessibility::XAccessibleTable,
46 					::com::sun::star::accessibility::XAccessibleSelection>
47 					ScAccessibleTableBaseImpl;
48 
49 class ScAccessibleTableBase :
50 			public ScAccessibleContextBase,
51 //IAccessibility2 Implementation 2009-----
52 			public	 ::com::sun::star::accessibility::XAccessibleTableSelection,
53 //-----IAccessibility2 Implementation 2009
54 			public ScAccessibleTableBaseImpl
55 {
56 public:
57 	//=====  internal  ========================================================
58 	ScAccessibleTableBase(
59         const ::com::sun::star::uno::Reference<
60         ::com::sun::star::accessibility::XAccessible>& rxParent,
61 		ScDocument* pDoc,
62 		const ScRange& rRange);
63 protected:
64 	virtual ~ScAccessibleTableBase();
65 public:
66 
67     using ScAccessibleContextBase::disposing;
68  	virtual void SAL_CALL disposing();
69 
70 	///=====  XInterface  =====================================================
71 
72 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
73 		::com::sun::star::uno::Type const & rType )
74 		throw (::com::sun::star::uno::RuntimeException);
75 
76 	virtual void SAL_CALL acquire() throw ();
77 
78 	virtual void SAL_CALL release() throw ();
79 
80 	///=====  XAccessibleTable  ================================================
81 
82     /// Returns the number of rows in the table.
83     virtual sal_Int32 SAL_CALL
84     			getAccessibleRowCount(  )
85     				throw (::com::sun::star::uno::RuntimeException);
86 
87     /// Returns the number of columns in the table.
88     virtual sal_Int32 SAL_CALL
89     			getAccessibleColumnCount(  )
90     				throw (::com::sun::star::uno::RuntimeException);
91 
92     /// Returns the description of the specified row in the table.
93     virtual ::rtl::OUString SAL_CALL
94     			getAccessibleRowDescription( sal_Int32 nRow )
95     				throw (::com::sun::star::uno::RuntimeException,
96                     ::com::sun::star::lang::IndexOutOfBoundsException);
97 
98     /// Returns the description text of the specified column in the table.
99     virtual ::rtl::OUString SAL_CALL
100     			getAccessibleColumnDescription( sal_Int32 nColumn )
101     				throw (::com::sun::star::uno::RuntimeException,
102                     ::com::sun::star::lang::IndexOutOfBoundsException);
103 
104     /** Returns the number of rows occupied by the Accessible at a specified row and column in the table.
105     Returns 1 if it is only a cell and the number of rows the cell is merged if the cell is a merged cell.
106     */
107     virtual sal_Int32 SAL_CALL
108     			getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
109     				throw (::com::sun::star::uno::RuntimeException,
110                     ::com::sun::star::lang::IndexOutOfBoundsException);
111 
112     /** Returns the number of columns occupied by the Accessible at a specified row and column in the table.
113     Returns 1 if it is only a cell and the number of columns the cell is merged if the cell is a merged cell.
114     */
115     virtual sal_Int32 SAL_CALL
116     			getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
117     				throw (::com::sun::star::uno::RuntimeException,
118                     ::com::sun::star::lang::IndexOutOfBoundsException);
119 
120     /// Returns the row headers as an AccessibleTable.
121     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
122     			getAccessibleRowHeaders(  )
123     				throw (::com::sun::star::uno::RuntimeException);
124 
125     /// Returns the column headers as an AccessibleTable.
126     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
127     			getAccessibleColumnHeaders(  )
128     				throw (::com::sun::star::uno::RuntimeException);
129 
130     /// Returns the selected rows in a table.
131     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
132     			getSelectedAccessibleRows(  )
133     				throw (::com::sun::star::uno::RuntimeException);
134 
135     /// Returns the selected columns in a table.
136     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
137     			getSelectedAccessibleColumns(  )
138     				throw (::com::sun::star::uno::RuntimeException);
139 
140     /// Returns a boolean value indicating whether the specified row is selected.
141     virtual sal_Bool SAL_CALL
142     			isAccessibleRowSelected( sal_Int32 nRow )
143     				throw (::com::sun::star::uno::RuntimeException,
144                     ::com::sun::star::lang::IndexOutOfBoundsException);
145 
146     /// Returns a boolean value indicating whether the specified column is selected.
147     virtual sal_Bool SAL_CALL
148     			isAccessibleColumnSelected( sal_Int32 nColumn )
149     				throw (::com::sun::star::uno::RuntimeException,
150                     ::com::sun::star::lang::IndexOutOfBoundsException);
151 
152 	/// Returns the Accessible at a specified row and column in the table.
153     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
154     			getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
155     				throw (::com::sun::star::uno::RuntimeException,
156     				        ::com::sun::star::lang::IndexOutOfBoundsException);
157 
158 	/// Returns the caption for the table.
159     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
160     			getAccessibleCaption(  )
161     				throw (::com::sun::star::uno::RuntimeException);
162 
163     /// Returns the summary description of the table.
164     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
165     			getAccessibleSummary(  )
166     				throw (::com::sun::star::uno::RuntimeException);
167 
168     /// Returns a boolean value indicating whether the accessible at a specified row and column is selected.
169     virtual sal_Bool SAL_CALL
170     			isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
171     				throw (::com::sun::star::uno::RuntimeException,
172                     ::com::sun::star::lang::IndexOutOfBoundsException);
173 
174 	///=====  XAccessibleExtendedTable  ========================================
175 
176     /// Returns the index of the cell on the given position.
177     virtual sal_Int32 SAL_CALL
178     			getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
179     				throw (::com::sun::star::uno::RuntimeException,
180                     ::com::sun::star::lang::IndexOutOfBoundsException);
181 
182     /// Returns the row number of an index in the table.
183     virtual sal_Int32 SAL_CALL
184     			getAccessibleRow( sal_Int32 nChildIndex )
185     				throw (::com::sun::star::uno::RuntimeException,
186                     ::com::sun::star::lang::IndexOutOfBoundsException);
187 
188     /// Returns the column number of an index in the table.
189     virtual sal_Int32 SAL_CALL
190     			getAccessibleColumn( sal_Int32 nChildIndex )
191     				throw (::com::sun::star::uno::RuntimeException,
192                     ::com::sun::star::lang::IndexOutOfBoundsException);
193 
194 	//=====  XAccessibleContext  ==============================================
195 
196     ///	Return the number of currently visible children.
197     // is overloaded to calculate this on demand
198     virtual sal_Int32 SAL_CALL
199     	getAccessibleChildCount(void)
200     				throw (::com::sun::star::uno::RuntimeException);
201 
202     ///	Return the specified child or NULL if index is invalid.
203     // is overloaded to calculate this on demand
204     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
205     	getAccessibleChild(sal_Int32 nIndex)
206         throw (::com::sun::star::uno::RuntimeException,
207 				::com::sun::star::lang::IndexOutOfBoundsException);
208 //IAccessibility2 Implementation 2009-----
209 	virtual sal_Bool SAL_CALL selectRow( sal_Int32 row )
210 		throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ;
211     virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column )
212 		throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ;
213     virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row )
214 		throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ;
215     virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column )
216 		throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ;
217 //-----IAccessibility2 Implementation 2009
218 
219 protected:
220     ///	Return this object's description.
221 	virtual ::rtl::OUString SAL_CALL
222     	createAccessibleDescription(void)
223         throw (::com::sun::star::uno::RuntimeException);
224 
225     ///	Return the object's current name.
226 	virtual ::rtl::OUString SAL_CALL
227     	createAccessibleName(void)
228         throw (::com::sun::star::uno::RuntimeException);
229 
230 public:
231 	///	Return NULL to indicate that an empty relation set.
232 	virtual ::com::sun::star::uno::Reference<
233             ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
234     	getAccessibleRelationSet(void)
235         throw (::com::sun::star::uno::RuntimeException);
236 
237     ///	Return the set of current states.
238     // perhaps sometimes to be implemented
239 	virtual ::com::sun::star::uno::Reference<
240             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
241     	getAccessibleStateSet(void)
242         throw (::com::sun::star::uno::RuntimeException);
243 
244 	///=====  XAccessibleSelection  ===========================================
245 
246     virtual void SAL_CALL
247 		selectAccessibleChild( sal_Int32 nChildIndex )
248 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
249 		::com::sun::star::uno::RuntimeException);
250 
251     virtual sal_Bool SAL_CALL
252 		isAccessibleChildSelected( sal_Int32 nChildIndex )
253 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
254 		::com::sun::star::uno::RuntimeException);
255 
256     virtual void SAL_CALL
257 		clearAccessibleSelection(  )
258 		throw (::com::sun::star::uno::RuntimeException);
259 
260     virtual void SAL_CALL
261 		selectAllAccessibleChildren(  )
262 		throw (::com::sun::star::uno::RuntimeException);
263 
264     virtual sal_Int32 SAL_CALL
265 		getSelectedAccessibleChildCount(  )
266 		throw (::com::sun::star::uno::RuntimeException);
267 
268     virtual ::com::sun::star::uno::Reference<
269 		::com::sun::star::accessibility::XAccessible > SAL_CALL
270 		getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
271 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
272 		::com::sun::star::uno::RuntimeException);
273 
274     virtual void SAL_CALL
275 		deselectAccessibleChild( sal_Int32 nSelectedChildIndex )
276 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
277 		::com::sun::star::uno::RuntimeException);
278 
279 	///=====  XServiceInfo  ===================================================
280 
281     /**	Returns an identifier for the implementation of this object.
282     */
283 	virtual ::rtl::OUString SAL_CALL
284     	getImplementationName(void)
285         throw (::com::sun::star::uno::RuntimeException);
286 
287 	///=====  XTypeProvider  ===================================================
288 
289 	/// returns the possible types
290     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
291 		getTypes()
292 		throw (::com::sun::star::uno::RuntimeException);
293 
294 	/**	Returns a implementation id.
295     */
296     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
297         getImplementationId(void)
298         throw (::com::sun::star::uno::RuntimeException);
299 
300 protected:
301 	/// contains the range of the table, because it could be a subrange of the complete table
302 	ScRange maRange;
303 
304 	ScDocument*	mpDoc;
305 
306 	void CommitTableModelChange(sal_Int32 nStartRow, sal_Int32 nStartCol, sal_Int32 nEndRow, sal_Int32 nEndCol, sal_uInt16 nId);
307 };
308 
309 
310 #endif
311