xref: /trunk/main/svtools/inc/svtools/accessibletableprovider.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 #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 ) = 0;
160 
161     /** returns the accessible object for the row or the column header bar
162     */
163     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
164         getHeaderBar( ::svt::AccessibleBrowseBoxObjType _eObjType ) = 0;
165 };
166 
167 /** interface for an implementation of a browse box's Accesible component
168 */
169 class IAccessibleBrowseBox
170 {
171 public:
172     /** returns the XAccessible object itself
173 
174         The reference returned here can be used to control the life time of the
175         IAccessibleTableImplementation object.
176 
177         The returned reference is guaranteed to not be <NULL/>.
178     */
179     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
180         getMyself() = 0;
181 
182     /** disposes the accessible implementation, so that it becomes defunc
183     */
184     virtual void dispose() = 0;
185 
186     /** checks whether the accessible implementation, and its context, are still alive
187         @return  <TRUE/>, if the object is not disposed or disposing.
188     */
189     virtual sal_Bool isAlive() const = 0;
190 
191     /** returns the accessible object for the row or the column header bar
192     */
193     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
194         getHeaderBar( ::svt::AccessibleBrowseBoxObjType _eObjType ) = 0;
195 
196     /** returns the accessible object for the table representation
197     */
198     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
199         getTable() = 0;
200 
201     /** commits the event at all listeners of the column/row header bar
202         @param nEventId
203             the event id
204         @param rNewValue
205             the new value
206         @param rOldValue
207             the old value
208     */
209     virtual void commitHeaderBarEvent(
210         sal_Int16 nEventId,
211         const ::com::sun::star::uno::Any& rNewValue,
212         const ::com::sun::star::uno::Any& rOldValue,
213         sal_Bool _bColumnHeaderBar
214     ) = 0;
215 
216     /** commits the event at all listeners of the table
217         @param nEventId
218             the event id
219         @param rNewValue
220             the new value
221         @param rOldValue
222             the old value
223     */
224     virtual void commitTableEvent(
225         sal_Int16 nEventId,
226         const ::com::sun::star::uno::Any& rNewValue,
227         const ::com::sun::star::uno::Any& rOldValue
228     ) = 0;
229 
230     /** Commits an event to all listeners. */
231     virtual void commitEvent(
232         sal_Int16 nEventId,
233         const ::com::sun::star::uno::Any& rNewValue,
234         const ::com::sun::star::uno::Any& rOldValue
235     ) = 0;
236 };
237 
238 // ----------------------------------------------------------------------------
239 
240 // ============================================================================
241 
242 } // namespace svt
243 
244 // ============================================================================
245 
246 #endif // _SVTOOLS_ACCESSIBLETABLEPROVIDER_HXX
247