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 ACCESSIBILITY_EXT_ACCESSIBLEBROWSEBOXTABLEBASE_HXX
26 #define ACCESSIBILITY_EXT_ACCESSIBLEBROWSEBOXTABLEBASE_HXX
27 
28 #include "accessibility/extended/AccessibleBrowseBoxBase.hxx"
29 #include <cppuhelper/implbase1.hxx>
30 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
31 
32 // ============================================================================
33 
34 namespace accessibility {
35 
36 typedef ::cppu::ImplHelper1<
37             ::com::sun::star::accessibility::XAccessibleTable >
38         AccessibleBrowseBoxTableImplHelper;
39 
40 /** The BrowseBox accessible table objects inherit from this base class. It
41     implements basic functionality for the XAccessibleTable interface.
42     BrowseBox table objects are: the data table, the column header bar and the
43     row header bar. */
44 class AccessibleBrowseBoxTableBase :
45     public BrowseBoxAccessibleElement,
46     public AccessibleBrowseBoxTableImplHelper
47 {
48 public:
49     /** Constructor sets specified name and description. If the constant of a
50         text is BBTEXT_NONE, the derived class has to set the text via
51         implSetName() and implSetDescription() (in Ctor) or later via
52         setAccessibleName() and setAccessibleDescription() (these methods
53         notify the listeners about the change).
54         @param rxParent  XAccessible interface of the parent object.
55         @param rBrowseBox  The BrowseBox control.
56         @param eNameText  The constant for the name text.
57         @param eDescrText  The constant for the description text. */
58     AccessibleBrowseBoxTableBase(
59         const ::com::sun::star::uno::Reference<
60             ::com::sun::star::accessibility::XAccessible >& rxParent,
61         ::svt::IAccessibleTableProvider&                  rBrowseBox,
62         ::svt::AccessibleBrowseBoxObjType  eObjType );
63 
64 protected:
65     virtual ~AccessibleBrowseBoxTableBase();
66 
67 public:
68     // XAccessibleContext -----------------------------------------------------
69 
70     /** @return  The count of visible children. */
71     virtual sal_Int32 SAL_CALL getAccessibleChildCount()
72         throw ( ::com::sun::star::uno::RuntimeException );
73 
74     /** @return  The role of this object (a table). */
75     virtual sal_Int16 SAL_CALL getAccessibleRole()
76         throw ( ::com::sun::star::uno::RuntimeException );
77 
78     /*  Derived classes have to implement:
79         -   getAccessibleChild,
80         -   getAccessibleIndexInParent. */
81 
82     // XAccessibleComponent ---------------------------------------------------
83 
84     /*  Derived classes have to implement:
85         -   getAccessibleAt,
86         -   grabFocus,
87         -   getAccessibleKeyBinding. */
88 
89     // XAccessibleTable -------------------------------------------------------
90 
91     /** @return  The number of used rows in the table (0 = empty table). */
92     virtual sal_Int32 SAL_CALL getAccessibleRowCount()
93         throw ( ::com::sun::star::uno::RuntimeException );
94 
95     /** @return  The number of used columns in the table (0 = empty table). */
96     virtual sal_Int32 SAL_CALL getAccessibleColumnCount()
97         throw ( ::com::sun::star::uno::RuntimeException );
98 
99     /** @return  The row extent of the specified cell (always 1). */
100     virtual sal_Int32 SAL_CALL
101     getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
102         throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
103                 ::com::sun::star::uno::RuntimeException );
104 
105     /** @return  The column extent of the specified cell (always 1). */
106     virtual sal_Int32 SAL_CALL
107     getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
108         throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
109                 ::com::sun::star::uno::RuntimeException );
110 
111     /** @return  The caption cell of the table (not supported). */
112     virtual ::com::sun::star::uno::Reference<
113         ::com::sun::star::accessibility::XAccessible > SAL_CALL
114     getAccessibleCaption()
115         throw ( ::com::sun::star::uno::RuntimeException );
116 
117     /** @return  The summary object of the table (not supported). */
118     virtual ::com::sun::star::uno::Reference<
119         ::com::sun::star::accessibility::XAccessible > SAL_CALL
120     getAccessibleSummary()
121         throw ( ::com::sun::star::uno::RuntimeException );
122 
123     /** @return  The child index of the specified cell. */
124     virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
125         throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
126                 ::com::sun::star::uno::RuntimeException );
127 
128     /** @return  The row index of the specified child cell. */
129     virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex )
130         throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
131                 ::com::sun::star::uno::RuntimeException );
132 
133     /** @return  The column index of the specified child cell. */
134     virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex )
135         throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
136                 ::com::sun::star::uno::RuntimeException );
137 
138     /*  Derived classes have to implement:
139         -   getAccessibleRowDescription,
140         -   getAccessibleColumnDescription,
141         -   getAccessibleRowHeaders,
142         -   getAccessibleColumnHeaders,
143         -   getSelectedAccessibleRows,
144         -   getSelectedAccessibleColumns,
145         -   isAccessibleRowSelected,
146         -   isAccessibleColumnSelected,
147         -   getAccessibleCellAt,
148         -   isAccessibleSelected. */
149 
150     // XInterface -------------------------------------------------------------
151 
152     /** Queries for a new interface. */
153     ::com::sun::star::uno::Any SAL_CALL queryInterface(
154             const ::com::sun::star::uno::Type& rType )
155         throw ( ::com::sun::star::uno::RuntimeException );
156 
157     /** Aquires the object (calls acquire() on base class). */
158     virtual void SAL_CALL acquire() throw ();
159 
160     /** Releases the object (calls release() on base class). */
161     virtual void SAL_CALL release() throw ();
162 
163     // XTypeProvider ----------------------------------------------------------
164 
165     /** @return  A sequence of possible types (received from base classes). */
166     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
167         throw ( ::com::sun::star::uno::RuntimeException );
168 
169     /** @return  An unique implementation ID. */
170     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
171         throw ( ::com::sun::star::uno::RuntimeException );
172 
173     // XServiceInfo -----------------------------------------------------------
174 
175     /*  Derived classes have to implement:
176         -   getImplementationName */
177 
178 protected:
179     // internal virtual methods -----------------------------------------------
180 
181     /** @attention  This method requires locked mutex's and a living object.
182         @return  The count of data rows without header bar. */
183     virtual sal_Int32 implGetRowCount() const;
184     /** @attention  This method requires locked mutex's and a living object.
185         @return  The count of data columns without "handle column". */
186     virtual sal_Int32 implGetColumnCount() const;
187 
188     // internal helper methods ------------------------------------------------
189 
190     /** @return  <TRUE/>, if first BrowseBox column is the "handle column". */
191     sal_Bool implHasHandleColumn() const;
192 
193     /** @attention  This method requires locked mutex's and a living object.
194         @param nColumn
195             the position of the column in the Accessible world
196         @return
197             the position of the column in VCL the Accessible world
198     */
199     sal_uInt16 implToVCLColumnPos( sal_Int32 nColumn ) const;
200 
201     /** @attention  This method requires locked mutex's and a living object.
202         @return  The number of cells of the table. */
203     sal_Int32 implGetChildCount() const;
204 
205     /** @attention  This method requires locked mutex's and a living object.
206         @return  The row index of the specified cell index. */
207     sal_Int32 implGetRow( sal_Int32 nChildIndex ) const;
208     /** @attention  This method requires locked mutex's and a living object.
209         @return  The column index of the specified cell index. */
210     sal_Int32 implGetColumn( sal_Int32 nChildIndex ) const;
211     /** @attention  This method requires locked mutex's and a living object.
212         @return  The child index of the specified cell address. */
213     sal_Int32 implGetChildIndex( sal_Int32 nRow, sal_Int32 nColumn ) const;
214 
215     /** @attention  This method requires locked mutex's and a living object.
216         @return  <TRUE/>, if the specified row is selected. */
217     sal_Bool implIsRowSelected( sal_Int32 nRow ) const;
218     /** @attention  This method requires locked mutex's and a living object.
219         @return  <TRUE/>, if the specified column is selected. */
220     sal_Bool implIsColumnSelected( sal_Int32 nColumn ) const;
221 
222     /** Selects/deselects a row (tries to expand selection).
223         @attention  This method requires locked mutex's and a living object.
224         @param bSelect  <TRUE/> = select, <FALSE/> = deselect */
225     void implSelectRow( sal_Int32 nRow, sal_Bool bSelect );
226     /** Selects/deselects a column (tries to expand selection).
227         @attention  This method requires locked mutex's and a living object.
228         @param bSelect  <TRUE/> = select, <FALSE/> = deselect */
229     void implSelectColumn( sal_Int32 nColumnPos, sal_Bool bSelect );
230 
231     /** @attention  This method requires locked mutex's and a living object.
232         @return  The count of selected rows. */
233     sal_Int32 implGetSelectedRowCount() const;
234     /** @attention  This method requires locked mutex's and a living object.
235         @return  The count of selected columns. */
236     sal_Int32 implGetSelectedColumnCount() const;
237 
238     /** Fills a sequence with sorted indexes of completely selected rows.
239         @attention  This method requires locked mutex's and a living object.
240         @param rSeq  Out-parameter that takes the sorted row index list. */
241     void implGetSelectedRows( ::com::sun::star::uno::Sequence< sal_Int32 >& rSeq );
242     /** Fills a sequence with sorted indexes of completely selected columns.
243         @attention  This method requires locked mutex's and a living object.
244         @param rSeq  Out-parameter that takes the sorted column index list. */
245     void implGetSelectedColumns( ::com::sun::star::uno::Sequence< sal_Int32 >& rSeq );
246 
247     /** @attention  This method requires locked mutex's and a living object.
248         @throws <type>IndexOutOfBoundsException</type>
249         If the specified row index is invalid. */
250     void ensureIsValidRow( sal_Int32 nRow )
251         throw ( ::com::sun::star::lang::IndexOutOfBoundsException );
252     /** @attention  This method requires locked mutex's and a living object.
253         @throws <type>IndexOutOfBoundsException</type>
254         If the specified column index is invalid. */
255     void ensureIsValidColumn( sal_Int32 nColumn )
256         throw ( ::com::sun::star::lang::IndexOutOfBoundsException );
257     /** @attention  This method requires locked mutex's and a living object.
258         @throws <type>IndexOutOfBoundsException</type>
259         If the specified cell address is invalid. */
260     void ensureIsValidAddress( sal_Int32 nRow, sal_Int32 nColumn )
261         throw ( ::com::sun::star::lang::IndexOutOfBoundsException );
262     /** @attention  This method requires locked mutex's and a living object.
263         @throws <type>IndexOutOfBoundsException</type>
264         If the specified child index is invalid. */
265     void ensureIsValidIndex( sal_Int32 nChildIndex )
266         throw ( ::com::sun::star::lang::IndexOutOfBoundsException );
267 };
268 
269 // ============================================================================
270 
271 } // namespace accessibility
272 
273 // ============================================================================
274 
275 #endif
276 
277