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