xref: /aoo41x/main/sw/source/core/access/acctable.hxx (revision cdf0e10c)
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 #ifndef _ACCTABLE_HXX
28 #define _ACCTABLE_HXX
29 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
30 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
31 
32 #include <acccontext.hxx>
33 
34 class SwTabFrm;
35 class SwAccessibleTableData_Impl;
36 class SwTableBox;
37 class SwSelBoxes;
38 
39 namespace sw { namespace access {
40     class SwAccessibleChild;
41 } }
42 
43 class SwAccessibleTable :
44 		public SwAccessibleContext,
45 		public ::com::sun::star::accessibility::XAccessibleTable,
46         public ::com::sun::star::accessibility::XAccessibleSelection,
47 		public SwClient
48 {
49 	SwAccessibleTableData_Impl *mpTableData;	// the table's data, prot by Sol-Mutex
50 	::rtl::OUString	sDesc;
51 	const SwSelBoxes *GetSelBoxes() const;
52 
53 	void FireTableChangeEvent( const SwAccessibleTableData_Impl& rTableData );
54 
55     /** get the SwTableBox* for the given child */
56     const SwTableBox* GetTableBox( sal_Int32 ) const;
57 
58 	sal_Bool IsChildSelected( sal_Int32 nChildIndex ) const;
59 
60 	sal_Int32 GetIndexOfSelectedChild( sal_Int32 nSelectedChildIndex ) const;
61 
62 protected:
63 
64 	// Set states for getAccessibleStateSet.
65 	// This drived class additinaly sets MULTISELECTABLE(+)
66 	virtual void GetStates( ::utl::AccessibleStateSetHelper& rStateSet );
67 
68 	virtual ~SwAccessibleTable();
69 
70     // --> OD 2007-06-27 #i77106#
71     inline void SetDesc( ::rtl::OUString sNewDesc )
72     {
73         sDesc = sNewDesc;
74     }
75 
76     // --> OD 2007-06-28 #i77106#
77     virtual SwAccessibleTableData_Impl* CreateNewTableData();
78     // <--
79 
80 	// force update of table data
81     void UpdateTableData();
82 
83 	// remove the current table data
84 	void ClearTableData();
85 
86 	// get table data, update if necessary
87 	inline SwAccessibleTableData_Impl& GetTableData();
88 
89 	// Is table data evailable?
90     sal_Bool HasTableData() const { return (mpTableData != 0); }
91 
92 	virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
93 
94 public:
95 
96     SwAccessibleTable( SwAccessibleMap* pInitMap, const SwTabFrm* pTableFrm );
97 
98 	//=====  XInterface  ======================================================
99 
100     // (XInterface methods need to be implemented to disambigouate
101     // between those inherited through SwAcessibleContext and
102     // XAccessibleTable).
103 
104     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
105         const ::com::sun::star::uno::Type& aType )
106         throw (::com::sun::star::uno::RuntimeException);
107 
108     virtual void SAL_CALL acquire(  ) throw ()
109         { SwAccessibleContext::acquire(); };
110 
111     virtual void SAL_CALL release(  ) throw ()
112         { SwAccessibleContext::release(); };
113 
114 	//====== XTypeProvider ====================================================
115 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);
116     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId(  ) throw(::com::sun::star::uno::RuntimeException);
117 
118 	//=====  XAccessibleContext  ==============================================
119 
120     ///	Return this object's description.
121 	virtual ::rtl::OUString SAL_CALL
122     	getAccessibleDescription (void)
123         throw (com::sun::star::uno::RuntimeException);
124 
125 	//=====  XAccessibleTable  ================================================
126 
127     virtual sal_Int32 SAL_CALL getAccessibleRowCount()
128 		throw (::com::sun::star::uno::RuntimeException);
129     virtual sal_Int32 SAL_CALL getAccessibleColumnCount(  )
130 		throw (::com::sun::star::uno::RuntimeException);
131     virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription(
132 			sal_Int32 nRow )
133 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
134 				::com::sun::star::uno::RuntimeException);
135     virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription(
136 			sal_Int32 nColumn )
137 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
138 				::com::sun::star::uno::RuntimeException);
139     virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(
140 			sal_Int32 nRow, sal_Int32 nColumn )
141 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
142 				::com::sun::star::uno::RuntimeException);
143     virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(
144 		   	sal_Int32 nRow, sal_Int32 nColumn )
145 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
146 				::com::sun::star::uno::RuntimeException);
147     virtual ::com::sun::star::uno::Reference<
148 				::com::sun::star::accessibility::XAccessibleTable >
149 		SAL_CALL getAccessibleRowHeaders(  )
150 	   	throw (::com::sun::star::uno::RuntimeException);
151     virtual ::com::sun::star::uno::Reference<
152 				::com::sun::star::accessibility::XAccessibleTable >
153 		SAL_CALL getAccessibleColumnHeaders(  )
154 		throw (::com::sun::star::uno::RuntimeException);
155     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
156 		getSelectedAccessibleRows(  )
157 		throw (::com::sun::star::uno::RuntimeException);
158     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
159 		getSelectedAccessibleColumns(  )
160 		throw (::com::sun::star::uno::RuntimeException);
161     virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow )
162 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
163 				::com::sun::star::uno::RuntimeException);
164     virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn )
165 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
166 				::com::sun::star::uno::RuntimeException);
167     virtual ::com::sun::star::uno::Reference<
168 		::com::sun::star::accessibility::XAccessible > SAL_CALL
169 		getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
170 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
171 				::com::sun::star::uno::RuntimeException);
172     virtual ::com::sun::star::uno::Reference<
173 		::com::sun::star::accessibility::XAccessible > SAL_CALL
174 		getAccessibleCaption(  )
175 		throw (::com::sun::star::uno::RuntimeException);
176     virtual ::com::sun::star::uno::Reference<
177 		::com::sun::star::accessibility::XAccessible > SAL_CALL
178 		getAccessibleSummary(  )
179 		throw (::com::sun::star::uno::RuntimeException);
180     virtual sal_Bool SAL_CALL isAccessibleSelected(
181 			sal_Int32 nRow, sal_Int32 nColumn )
182 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
183 				::com::sun::star::uno::RuntimeException);
184     virtual sal_Int32 SAL_CALL getAccessibleIndex(
185 			sal_Int32 nRow, sal_Int32 nColumn )
186 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
187 				::com::sun::star::uno::RuntimeException);
188     virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex )
189 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
190 				::com::sun::star::uno::RuntimeException);
191     virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex )
192 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
193 				::com::sun::star::uno::RuntimeException);
194 
195 	//=====  XServiceInfo  ====================================================
196 
197     /**	Returns an identifier for the implementation of this object.
198     */
199 	virtual ::rtl::OUString SAL_CALL
200     	getImplementationName (void)
201         throw (::com::sun::star::uno::RuntimeException);
202 
203     /**	Return whether the specified service is supported by this class.
204     */
205     virtual sal_Bool SAL_CALL
206     	supportsService (const ::rtl::OUString& sServiceName)
207         throw (::com::sun::star::uno::RuntimeException);
208 
209     /** Returns a list of all supported services.  In this case that is just
210     	the AccessibleContext service.
211     */
212 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
213     	getSupportedServiceNames (void)
214         throw (::com::sun::star::uno::RuntimeException);
215 
216 	//===== C++ interface ======================================================
217 
218 	// The object has been moved by the layout
219 	virtual void InvalidatePosOrSize( const SwRect& rOldBox );
220 
221 	// The object is not visible an longer and should be destroyed
222 	virtual void Dispose( sal_Bool bRecursive = sal_False );
223 
224     virtual void DisposeChild( const sw::access::SwAccessibleChild& rFrmOrObj,
225                                sal_Bool bRecursive );
226     virtual void InvalidateChildPosOrSize( const sw::access::SwAccessibleChild& rFrmOrObj,
227                                            const SwRect& rFrm );
228 
229 	//=====  XAccessibleSelection  ============================================
230 
231     virtual void SAL_CALL selectAccessibleChild(
232         sal_Int32 nChildIndex )
233         throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
234                 ::com::sun::star::uno::RuntimeException );
235 
236     virtual sal_Bool SAL_CALL isAccessibleChildSelected(
237         sal_Int32 nChildIndex )
238         throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
239                 ::com::sun::star::uno::RuntimeException );
240 
241     virtual void SAL_CALL clearAccessibleSelection(  )
242         throw ( ::com::sun::star::uno::RuntimeException );
243 
244     virtual void SAL_CALL selectAllAccessibleChildren(  )
245         throw ( ::com::sun::star::uno::RuntimeException );
246 
247     virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount(  )
248         throw ( ::com::sun::star::uno::RuntimeException );
249 
250     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(
251         sal_Int32 nSelectedChildIndex )
252         throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
253                 ::com::sun::star::uno::RuntimeException);
254 
255     // --> OD 2004-11-16 #111714# - index has to be treated as global child index.
256     virtual void SAL_CALL deselectAccessibleChild(
257         sal_Int32 nChildIndex )
258         throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
259                 ::com::sun::star::uno::RuntimeException );
260 
261 };
262 
263 inline SwAccessibleTableData_Impl& SwAccessibleTable::GetTableData()
264 {
265 	if( !mpTableData )
266 		UpdateTableData();
267 	return *mpTableData;
268 }
269 
270 // --> OD 2007-06-28 #i77106#
271 // subclass to represent table column headers
272 class SwAccessibleTableColHeaders : public SwAccessibleTable
273 {
274 protected:
275 
276     virtual ~SwAccessibleTableColHeaders()
277     {}
278 
279     virtual SwAccessibleTableData_Impl* CreateNewTableData();
280     virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew);
281 
282 public:
283 
284     SwAccessibleTableColHeaders( SwAccessibleMap *pMap, const SwTabFrm *pTabFrm );
285 
286     //=====  XInterface  ======================================================
287 
288     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
289         const ::com::sun::star::uno::Type& aType )
290         throw (::com::sun::star::uno::RuntimeException);
291 
292     virtual void SAL_CALL acquire(  ) throw ()
293         { SwAccessibleContext::acquire(); };
294 
295     virtual void SAL_CALL release(  ) throw ()
296         { SwAccessibleContext::release(); };
297 
298     //=====  XAccessibleContext  ==============================================
299 
300     /// Return the number of currently visible children.
301     virtual sal_Int32 SAL_CALL getAccessibleChildCount (void)
302         throw (::com::sun::star::uno::RuntimeException);
303 
304     /// Return the specified child or NULL if index is invalid.
305     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
306         getAccessibleChild (sal_Int32 nIndex)
307         throw (::com::sun::star::uno::RuntimeException,
308                 ::com::sun::star::lang::IndexOutOfBoundsException);
309 
310     //=====  XAccessibleTable  ================================================
311 
312     virtual ::com::sun::star::uno::Reference<
313                 ::com::sun::star::accessibility::XAccessibleTable >
314         SAL_CALL getAccessibleRowHeaders(  )
315         throw (::com::sun::star::uno::RuntimeException);
316     virtual ::com::sun::star::uno::Reference<
317                 ::com::sun::star::accessibility::XAccessibleTable >
318         SAL_CALL getAccessibleColumnHeaders(  )
319         throw (::com::sun::star::uno::RuntimeException);
320 
321     //=====  XServiceInfo  ====================================================
322 
323     /** Returns an identifier for the implementation of this object.
324     */
325     virtual ::rtl::OUString SAL_CALL
326         getImplementationName (void)
327         throw (::com::sun::star::uno::RuntimeException);
328 
329 };
330 // <--
331 #endif
332