xref: /trunk/main/accessibility/inc/accessibility/extended/AccessibleBrowseBoxHeaderBar.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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_ACCESSIBLEBROWSEBOXHEADERBAR_HXX
26 #define ACCESSIBILITY_EXT_ACCESSIBLEBROWSEBOXHEADERBAR_HXX
27 
28 #include "accessibility/extended/AccessibleBrowseBoxTableBase.hxx"
29 #include <cppuhelper/implbase1.hxx>
30 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
31 
32 // ============================================================================
33 
34 namespace accessibility {
35 
36 // ============================================================================
37 
38 typedef ::cppu::ImplHelper1<
39             ::com::sun::star::accessibility::XAccessibleSelection >
40         AccessibleBrowseBoxHeaderBarImplHelper;
41 
42 /** This class represents the accessible object of a header bar of a BrowseBox
43     control (row or column header bar). This object supports the
44     XAccessibleSelection interface. Selecting a child of this object selects
45     complete rows or columns of the data table. */
46 class AccessibleBrowseBoxHeaderBar :
47     public AccessibleBrowseBoxTableBase,
48     public AccessibleBrowseBoxHeaderBarImplHelper
49 {
50 public:
51     /** @param eObjType  One of the two allowed types BBTYPE_ROWHEADERBAR or
52                          BBTYPE_COLUMNHEADERBAR. */
53     AccessibleBrowseBoxHeaderBar(
54         const ::com::sun::star::uno::Reference<
55             ::com::sun::star::accessibility::XAccessible >& rxParent,
56         ::svt::IAccessibleTableProvider&                  rBrowseBox,
57         ::svt::AccessibleBrowseBoxObjType  eObjType );
58 
59 protected:
60     virtual ~AccessibleBrowseBoxHeaderBar();
61 
62 public:
63     // XAccessibleContext -----------------------------------------------------
64 
65     /** @return
66         The XAccessible interface of the specified child.
67     */
68     virtual ::com::sun::star::uno::Reference<
69         ::com::sun::star::accessibility::XAccessible > SAL_CALL
70     getAccessibleChild( sal_Int32 nChildIndex );
71 
72     /** @return  The index of this object among the parent's children. */
73     virtual sal_Int32 SAL_CALL getAccessibleIndexInParent();
74 
75     // XAccessibleComponent ---------------------------------------------------
76 
77     /** @return  The accessible child rendered under the given point. */
78     virtual ::com::sun::star::uno::Reference<
79         ::com::sun::star::accessibility::XAccessible > SAL_CALL
80     getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint );
81 
82     /** Grabs the focus to (the current cell of) the data table. */
83     virtual void SAL_CALL grabFocus();
84 
85     /** @return  The key bindings associated with this object. */
86     virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding();
87 
88     // XAccessibleTable -------------------------------------------------------
89 
90     /** @return  The description text of the specified row. */
91     virtual ::rtl::OUString SAL_CALL
92     getAccessibleRowDescription( sal_Int32 nRow );
93 
94     /** @return  The description text of the specified column. */
95     virtual ::rtl::OUString SAL_CALL
96     getAccessibleColumnDescription( sal_Int32 nColumn );
97 
98     /** @return  The XAccessibleTable interface of the row header bar. */
99     virtual ::com::sun::star::uno::Reference<
100         ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
101     getAccessibleRowHeaders();
102 
103     /** @return  The XAccessibleTable interface of the column header bar. */
104     virtual ::com::sun::star::uno::Reference<
105         ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
106     getAccessibleColumnHeaders();
107 
108     /** @return  An index list of completely selected rows. */
109     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
110     getSelectedAccessibleRows();
111 
112     /** @return  An index list of completely selected columns. */
113     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
114     getSelectedAccessibleColumns();
115 
116     /** @return  <TRUE/>, if the specified row is completely selected. */
117     virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow );
118 
119     /** @return  <TRUE/>, if the specified column is completely selected. */
120     virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn );
121 
122     /** @return The XAccessible interface of the cell object at the specified
123                 cell position. */
124     virtual ::com::sun::star::uno::Reference<
125         ::com::sun::star::accessibility::XAccessible > SAL_CALL
126     getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn );
127 
128     /** @return  <TRUE/>, if the specified cell is selected. */
129     virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn );
130 
131     // XAccessibleSelection ---------------------------------------------------
132 
133     /** Selects the specified child (row or column of the table). */
134     virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex );
135 
136     /** @return  <TRUE/>, if the specified child (row/column) is selected. */
137     virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex );
138 
139     /** Clears the complete selection. */
140     virtual void SAL_CALL clearAccessibleSelection();
141 
142     /** Selects all children or first, if multiselection is not supported. */
143     virtual void SAL_CALL selectAllAccessibleChildren();
144 
145     /** @return  The number of selected rows/columns. */
146     virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount();
147 
148     /** @return  The specified selected row/column. */
149     virtual ::com::sun::star::uno::Reference<
150         ::com::sun::star::accessibility::XAccessible > SAL_CALL
151     getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex );
152 
153     /** Removes the specified row/column from the selection. */
154     virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex );
155 
156     // XInterface -------------------------------------------------------------
157 
158     /** Queries for a new interface. */
159     ::com::sun::star::uno::Any SAL_CALL queryInterface(
160             const ::com::sun::star::uno::Type& rType );
161 
162     /** Aquires the object (calls acquire() on base class). */
163     virtual void SAL_CALL acquire() throw ();
164 
165     /** Releases the object (calls release() on base class). */
166     virtual void SAL_CALL release() throw ();
167 
168     // XServiceInfo -----------------------------------------------------------
169 
170     /** @return  The name of this class. */
171     virtual ::rtl::OUString SAL_CALL getImplementationName();
172 
173     /** @return  An unique implementation ID. */
174     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId();
175 
176 protected:
177     // internal virtual methods -----------------------------------------------
178 
179     /** @attention  This method requires locked mutex's and a living object.
180         @return  The bounding box (VCL rect.) relative to the parent window. */
181     virtual Rectangle implGetBoundingBox();
182     /** @attention  This method requires locked mutex's and a living object.
183         @return  The bounding box (VCL rect.) in screen coordinates. */
184     virtual Rectangle implGetBoundingBoxOnScreen();
185 
186     /** @attention  This method requires locked mutex's and a living object.
187         @return  The count of used rows. */
188     virtual sal_Int32 implGetRowCount() const;
189     /** @attention  This method requires locked mutex's and a living object.
190         @return  The count of used columns. */
191     virtual sal_Int32 implGetColumnCount() const;
192 
193     // internal helper methods ------------------------------------------------
194 
195     /** @return  <TRUE/>, if the objects is a header bar for rows. */
196     inline sal_Bool isRowBar() const;
197     /** @return  <TRUE/>, if the objects is a header bar for columns. */
198     inline sal_Bool isColumnBar() const;
199 
200     /** Returns the specified row or column. Uses one of the parameters,
201         depending on object type.
202         @attention  This method requires locked mutex's and a living object.
203         @return  The XAccessible interface of the specified column/row. */
204     ::com::sun::star::uno::Reference<
205         ::com::sun::star::accessibility::XAccessible >
206     implGetChild( sal_Int32 nRow, sal_uInt16 nColumnPos );
207 
208     /** @attention  This method requires locked mutex's and a living object.
209         @return  The absolute child index from the index of selected children.
210         @throws <type>IndexOutOfBoundsException</type>
211         If the specified index is invalid. */
212     sal_Int32 implGetChildIndexFromSelectedIndex( sal_Int32 nSelectedChildIndex );
213 
214     /** @attention  This method requires locked mutex's and a living object.
215         @throws <type>IndexOutOfBoundsException</type>
216         If the specified row/column index (depending on type) is invalid. */
217     void ensureIsValidHeaderIndex( sal_Int32 nIndex );
218 };
219 
220 // inlines --------------------------------------------------------------------
221 
isRowBar() const222 inline sal_Bool AccessibleBrowseBoxHeaderBar::isRowBar() const
223 {
224     return getType() == ::svt::BBTYPE_ROWHEADERBAR;
225 }
226 
isColumnBar() const227 inline sal_Bool AccessibleBrowseBoxHeaderBar::isColumnBar() const
228 {
229     return getType() == ::svt::BBTYPE_COLUMNHEADERBAR;
230 }
231 
232 // ============================================================================
233 
234 } // namespace accessibility
235 
236 // ============================================================================
237 
238 #endif
239