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 #ifndef _SVTOOLS_ACCESSIBLETABLEPROVIDER_HXX
25 #define _SVTOOLS_ACCESSIBLETABLEPROVIDER_HXX
26 
27 #include <vcl/window.hxx>
28 #include <unotools/accessiblestatesethelper.hxx>
29 #include <svtools/AccessibleBrowseBoxObjType.hxx>
30 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
31 
32 // ============================================================================
33 
34 namespace svt
35 {
36 
37 // ============================================================================
38 
39 #define OFFSET_DEFAULT  ((sal_Int32)-1)
40 #define OFFSET_NONE     ((sal_Int32)0)
41 
42 // ============================================================================
43 
44 enum AccessibleTableChildIndex
45 {
46     /** Child index of the column header bar (first row). Exists always. */
47     BBINDEX_COLUMNHEADERBAR = 0,
48     /** Child index of the row header bar ("handle column"). Exists always. */
49     BBINDEX_ROWHEADERBAR    = 1,
50     /** Child index of the data table. */
51     BBINDEX_TABLE           = 2,
52     /** Child index of the first additional control. */
53     BBINDEX_FIRSTCONTROL    = 3
54 };
55 
56 // ============================================================================
57 
58 #define	XACC ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
59 
60 /** This abstract class provides methods to implement an accessible table object.
61 */
62 class IAccessibleTableProvider
63 {
64 public:
65     /** @return  The count of the rows. */
66 	virtual	long					GetRowCount() const = 0;
67     /** @return  The count of the columns. */
68 	virtual sal_uInt16				GetColumnCount() const = 0;
69 
70     /** @return  The position of the current row. */
71 	virtual sal_Int32				GetCurrRow() const = 0;
72     /** @return  The position of the current column. */
73 	virtual sal_uInt16				GetCurrColumn() const = 0;
74 
75     /** @return  The description of a row.
76         @param _nRow The row which description is in demand. */
77     virtual ::rtl::OUString			GetRowDescription( sal_Int32 _nRow ) const = 0;
78     /** @return  The description of a column.
79         @param _nColumn The column which description is in demand. */
80 	virtual ::rtl::OUString			GetColumnDescription( sal_uInt16 _nColumnPos ) const = 0;
81 
82     /** @return  <TRUE/>, if the object has a row header. */
83 	virtual sal_Bool				HasRowHeader() const = 0; //GetColumnId
84     /** @return  <TRUE/>, if the object can focus a cell. */
85 	virtual sal_Bool				IsCellFocusable() const = 0;
86 	virtual sal_Bool				GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) = 0;
87 
88 	virtual void					SetNoSelection() = 0;
89 	virtual void					SelectAll() = 0;
90 	virtual void					SelectRow( long _nRow, sal_Bool _bSelect = sal_True, sal_Bool bExpand = sal_True ) = 0;
91 	virtual void					SelectColumn( sal_uInt16 _nColumnPos, sal_Bool _bSelect = sal_True ) = 0;
92 	virtual sal_Int32				GetSelectedRowCount() const = 0;
93 	virtual sal_Int32				GetSelectedColumnCount() const = 0;
94     /** @return  <TRUE/>, if the row is selected. */
95 	virtual bool					IsRowSelected( long _nRow ) const = 0;
96 	virtual sal_Bool				IsColumnSelected( long _nColumnPos ) const = 0;
97 	virtual void					GetAllSelectedRows( ::com::sun::star::uno::Sequence< sal_Int32 >& _rRows ) const = 0;
98 	virtual void					GetAllSelectedColumns( ::com::sun::star::uno::Sequence< sal_Int32 >& _rColumns ) const = 0;
99 
100     /** @return  <TRUE/>, if the cell is visible. */
101 	virtual sal_Bool				IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const = 0;
102 	virtual String					GetAccessibleCellText( long _nRow, sal_uInt16 _nColumnPos ) const = 0;
103 
104 	virtual Rectangle				calcHeaderRect( sal_Bool _bIsColumnBar, sal_Bool _bOnScreen = sal_True ) = 0;
105 	virtual Rectangle				calcTableRect( sal_Bool _bOnScreen = sal_True ) = 0;
106 	virtual Rectangle				GetFieldRectPixelAbs( sal_Int32 _nRow, sal_uInt16 _nColumnPos, sal_Bool _bIsHeader, sal_Bool _bOnScreen = sal_True ) = 0;
107 
108 	virtual XACC					CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) = 0;
109     virtual XACC					CreateAccessibleRowHeader( sal_Int32 _nRow ) = 0;
110     virtual XACC					CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos ) = 0;
111 
112 	virtual sal_Int32				GetAccessibleControlCount() const = 0;
113     virtual XACC					CreateAccessibleControl( sal_Int32 _nIndex ) = 0;
114     virtual sal_Bool				ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint ) = 0;
115 
116 	virtual sal_Bool				ConvertPointToCellAddress( sal_Int32& _rnRow, sal_uInt16& _rnColPos, const Point& _rPoint ) = 0;
117     virtual sal_Bool				ConvertPointToRowHeader( sal_Int32& _rnRow, const Point& _rPoint ) = 0;
118     virtual sal_Bool				ConvertPointToColumnHeader( sal_uInt16& _rnColPos, const Point& _rPoint ) = 0;
119 
120 	virtual ::rtl::OUString			GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const = 0;
121     virtual ::rtl::OUString			GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType _eType, sal_Int32 _nPos = -1 ) const = 0;
122 
123 	virtual void					FillAccessibleStateSet( ::utl::AccessibleStateSetHelper& _rStateSet, ::svt::AccessibleBrowseBoxObjType _eType ) const = 0;
124 	virtual void					FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const = 0;
125     virtual void					GrabTableFocus() = 0;
126 
127 	// OutputDevice
128 	virtual sal_Bool					GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector ) = 0;
129 
130 	// Window
131     virtual Rectangle				GetWindowExtentsRelative( Window *pRelativeWindow ) const = 0;
132     virtual void					GrabFocus() = 0;
133     virtual XACC					GetAccessible( sal_Bool bCreate = sal_True ) = 0;
134     virtual Window*					GetAccessibleParentWindow() const = 0;
135     virtual Window*					GetWindowInstance() = 0;
136 
137 	virtual Rectangle				GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex) = 0;
138 	virtual sal_Int32				GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint) = 0;
139 };
140 
141 // ----------------------------------------------------------------------------
142 
143 /** interface for an implementation of a table control's Accesible component
144 */
145 class IAccessibleTabListBox
146 {
147 public:
148     /** returns the XAccessible object itself
149 
150         The reference returned here can be used to control the life time of the
151         IAccessibleTableImplementation object.
152 
153         The returned reference is guaranteed to not be <NULL/>.
154     */
155 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
156         getMyself() = 0;
157 
158     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
159         SAL_CALL getAccessibleChild( sal_Int32 nChildIndex )
160             throw ( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException ) = 0;
161 
162 	/** returns the accessible object for the row or the column header bar
163 	*/
164     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
165 		getHeaderBar( ::svt::AccessibleBrowseBoxObjType _eObjType ) = 0;
166 };
167 
168 /** interface for an implementation of a browse box's Accesible component
169 */
170 class IAccessibleBrowseBox
171 {
172 public:
173     /** returns the XAccessible object itself
174 
175         The reference returned here can be used to control the life time of the
176         IAccessibleTableImplementation object.
177 
178         The returned reference is guaranteed to not be <NULL/>.
179     */
180 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
181         getMyself() = 0;
182 
183     /** disposes the accessible implementation, so that it becomes defunc
184     */
185     virtual void dispose() = 0;
186 
187     /** checks whether the accessible implementation, and its context, are still alive
188         @return  <TRUE/>, if the object is not disposed or disposing.
189     */
190     virtual sal_Bool isAlive() const = 0;
191 
192 	/** returns the accessible object for the row or the column header bar
193 	*/
194 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
195 		getHeaderBar( ::svt::AccessibleBrowseBoxObjType _eObjType ) = 0;
196 
197     /** returns the accessible object for the table representation
198 	*/
199 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
200 		getTable() = 0;
201 
202     /** commits the event at all listeners of the column/row header bar
203 		@param nEventId
204 			the event id
205 		@param rNewValue
206 			the new value
207 		@param rOldValue
208 			the old value
209 	*/
210 	virtual void commitHeaderBarEvent(
211         sal_Int16 nEventId,
212         const ::com::sun::star::uno::Any& rNewValue,
213         const ::com::sun::star::uno::Any& rOldValue,
214         sal_Bool _bColumnHeaderBar
215     ) = 0;
216 
217     /** commits the event at all listeners of the table
218 		@param nEventId
219 			the event id
220 		@param rNewValue
221 			the new value
222 		@param rOldValue
223 			the old value
224 	*/
225 	virtual void commitTableEvent(
226         sal_Int16 nEventId,
227         const ::com::sun::star::uno::Any& rNewValue,
228         const ::com::sun::star::uno::Any& rOldValue
229     ) = 0;
230 
231 	/** Commits an event to all listeners. */
232     virtual void commitEvent(
233         sal_Int16 nEventId,
234         const ::com::sun::star::uno::Any& rNewValue,
235         const ::com::sun::star::uno::Any& rOldValue
236     ) = 0;
237 };
238 
239 // ----------------------------------------------------------------------------
240 
241 // ============================================================================
242 
243 } // namespace svt
244 
245 // ============================================================================
246 
247 #endif // _SVTOOLS_ACCESSIBLETABLEPROVIDER_HXX
248 
249