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