Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROL_HXX
21 : #define ACCESSIBILITY_EXT_ACCESSIBLEGRIDCONTROL_HXX
22 :
23 : #include <accessibility/extended/AccessibleGridControlBase.hxx>
24 : #include <accessibility/extended/AccessibleGridControlTable.hxx>
25 : #include <cppuhelper/weakref.hxx>
26 : #include <svtools/accessibletable.hxx>
27 :
28 : #include <memory>
29 :
30 : // ============================================================================
31 :
32 : namespace accessibility {
33 :
34 : class AccessibleGridControl_Impl;
35 :
36 : // ============================================================================
37 :
38 : /** This class represents the complete accessible Grid Control object. */
39 : class AccessibleGridControl : public AccessibleGridControlBase
40 : {
41 : friend class AccessibleGridControlAccess;
42 :
43 : protected:
44 : AccessibleGridControl(
45 : const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent,
46 : const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxCreator,
47 : ::svt::table::IAccessibleTable& _rTable
48 : );
49 :
50 : virtual ~AccessibleGridControl();
51 :
52 : /** Cleans up members. */
53 : using AccessibleGridControlBase::disposing;
54 : virtual void SAL_CALL disposing();
55 :
56 : protected:
57 : // XAccessibleContext -----------------------------------------------------
58 :
59 : /** @return The count of visible children. */
60 : virtual sal_Int32 SAL_CALL getAccessibleChildCount()
61 : throw ( ::com::sun::star::uno::RuntimeException );
62 :
63 : /** @return The XAccessible interface of the specified child. */
64 : virtual ::com::sun::star::uno::Reference<
65 : ::com::sun::star::accessibility::XAccessible > SAL_CALL
66 : getAccessibleChild( sal_Int32 nChildIndex )
67 : throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
68 : ::com::sun::star::uno::RuntimeException );
69 :
70 : /** @return The role of this object (a table). */
71 : virtual sal_Int16 SAL_CALL getAccessibleRole()
72 : throw ( ::com::sun::star::uno::RuntimeException );
73 :
74 : // XAccessibleComponent ---------------------------------------------------
75 :
76 : /** @return
77 : The accessible child rendered under the given point.
78 : */
79 : virtual ::com::sun::star::uno::Reference<
80 : ::com::sun::star::accessibility::XAccessible > SAL_CALL
81 : getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint )
82 : throw ( ::com::sun::star::uno::RuntimeException );
83 :
84 : /** Grabs the focus to the Grid Control. */
85 : virtual void SAL_CALL grabFocus()
86 : throw ( ::com::sun::star::uno::RuntimeException );
87 :
88 : /** @return The key bindings associated with this object. */
89 : virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding()
90 : throw ( ::com::sun::star::uno::RuntimeException );
91 :
92 : // XServiceInfo -----------------------------------------------------------
93 :
94 : /** @return
95 : The name of this class.
96 : */
97 : virtual OUString SAL_CALL getImplementationName()
98 : throw ( ::com::sun::star::uno::RuntimeException );
99 :
100 : public:
101 : // helper functions
102 :
103 : /** commitCellEvent commit the event at all listeners of the table
104 : @param nEventId
105 : the event id
106 : @param rNewValue
107 : the new value
108 : @param rOldValue
109 : the old value
110 : */
111 : void commitCellEvent(sal_Int16 nEventId, const ::com::sun::star::uno::Any& rNewValue,
112 : const ::com::sun::star::uno::Any& rOldValue);
113 :
114 : /** commitTableEvent commit the event at all listeners of the table
115 : @param nEventId
116 : the event id
117 : @param rNewValue
118 : the new value
119 : @param rOldValue
120 : the old value
121 : */
122 : void commitTableEvent(sal_Int16 nEventId, const ::com::sun::star::uno::Any& rNewValue,
123 : const ::com::sun::star::uno::Any& rOldValue);
124 : /** returns the accessible object for the row or the column header bar
125 : */
126 : inline ::com::sun::star::uno::Reference<
127 : ::com::sun::star::accessibility::XAccessible >
128 0 : getHeaderBar( ::svt::table::AccessibleTableControlObjType _eObjType )
129 : {
130 0 : return implGetHeaderBar(_eObjType);
131 : }
132 :
133 : /** returns the accessible object for the table representation
134 : */
135 : inline ::com::sun::star::uno::Reference<
136 : ::com::sun::star::accessibility::XAccessible >
137 0 : getTable( )
138 : {
139 0 : return implGetTable();
140 : }
141 :
142 : protected:
143 : // internal virtual methods -----------------------------------------------
144 :
145 : /** @attention This method requires locked mutex's and a living object.
146 : @return The bounding box (VCL rect.) relative to the parent window. */
147 : virtual Rectangle implGetBoundingBox();
148 : /** @attention This method requires locked mutex's and a living object.
149 : @return The bounding box (VCL rect.) in screen coordinates. */
150 : virtual Rectangle implGetBoundingBoxOnScreen();
151 :
152 : // internal helper methods ------------------------------------------------
153 :
154 : /** This method creates (once) and returns the accessible data table child.
155 : @attention This method requires locked mutex's and a living object.
156 : @return The XAccessible interface of the data table. */
157 : virtual ::com::sun::star::uno::Reference<
158 : ::com::sun::star::accessibility::XAccessible > implGetTable();
159 :
160 : /** This method creates (once) and returns the specified header bar.
161 : @attention This method requires locked mutex's and a living object.
162 : @return The XAccessible interface of the header bar. */
163 : ::com::sun::star::uno::Reference<
164 : ::com::sun::star::accessibility::XAccessible >
165 : implGetHeaderBar( ::svt::table::AccessibleTableControlObjType eObjType );
166 :
167 : /** This method returns one of the children that are always present:
168 : Data table, row and column header bar or corner control.
169 : @attention This method requires locked mutex's and a living object.
170 : @return The XAccessible interface of the specified child. */
171 : ::com::sun::star::uno::Reference<
172 : ::com::sun::star::accessibility::XAccessible >
173 : implGetFixedChild( sal_Int32 nChildIndex );
174 :
175 : /** This method creates and returns an accessible table.
176 : @return An AccessibleGridControlTable. */
177 : virtual AccessibleGridControlTable* createAccessibleTable();
178 :
179 : private:
180 : // members ----------------------------------------------------------------
181 : ::std::auto_ptr< AccessibleGridControl_Impl > m_pImpl;
182 : };
183 :
184 : // ============================================================================
185 : /** the XAccessible which creates/returns an AccessibleGridControl
186 :
187 : <p>The instance holds it's XAccessibleContext with a hard reference, while
188 : the contxt holds this instance weak.</p>
189 : */
190 : typedef ::cppu::WeakImplHelper1 < ::com::sun::star::accessibility::XAccessible > AccessibleGridControlAccess_Base;
191 :
192 : class AccessibleGridControlAccess :public AccessibleGridControlAccess_Base
193 : ,public ::svt::table::IAccessibleTableControl
194 : {
195 : private:
196 : ::osl::Mutex m_aMutex;
197 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
198 : m_xParent;
199 : ::svt::table::IAccessibleTable& m_rTable;
200 :
201 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
202 : m_xContext;
203 : AccessibleGridControl* m_pContext;
204 : // note that this pointer is valid as long as m_xContext is valid!
205 :
206 : public:
207 : AccessibleGridControlAccess(
208 : const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent,
209 : ::svt::table::IAccessibleTable& _rTable
210 : );
211 :
212 : /// checks whether the accessible context is still alive
213 : bool isContextAlive() const;
214 :
215 : /// returns the AccessibleContext belonging to this Accessible
216 0 : inline AccessibleGridControl* getContext() { return m_pContext; }
217 : inline const AccessibleGridControl* getContext() const { return m_pContext; }
218 :
219 : protected:
220 : virtual ~AccessibleGridControlAccess();
221 :
222 : // XAccessible
223 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
224 : SAL_CALL getAccessibleContext() throw ( ::com::sun::star::uno::RuntimeException );
225 :
226 : // IAccessibleTable
227 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
228 0 : getMyself()
229 : {
230 0 : return this;
231 : }
232 : void dispose();
233 0 : virtual sal_Bool isAlive() const
234 : {
235 0 : return isContextAlive();
236 : }
237 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
238 0 : getTableHeader( ::svt::table::AccessibleTableControlObjType _eObjType )
239 : {
240 0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible;
241 0 : AccessibleGridControl* pContext( getContext() );
242 0 : if ( pContext )
243 0 : xAccessible = pContext->getHeaderBar( _eObjType );
244 0 : return xAccessible;
245 : }
246 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
247 0 : getTable()
248 : {
249 0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible;
250 0 : AccessibleGridControl* pContext( getContext() );
251 0 : if ( pContext )
252 0 : xAccessible = pContext->getTable();
253 0 : return xAccessible;
254 : }
255 0 : virtual void commitCellEvent( sal_Int16 nEventId,
256 : const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue )
257 : {
258 0 : AccessibleGridControl* pContext( getContext() );
259 0 : if ( pContext )
260 0 : pContext->commitCellEvent( nEventId, rNewValue, rOldValue );
261 0 : }
262 0 : virtual void commitTableEvent( sal_Int16 nEventId,
263 : const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue )
264 : {
265 0 : AccessibleGridControl* pContext( getContext() );
266 0 : if ( pContext )
267 0 : pContext->commitTableEvent( nEventId, rNewValue, rOldValue );
268 0 : }
269 0 : virtual void commitEvent( sal_Int16 nEventId,
270 : const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue )
271 : {
272 0 : AccessibleGridControl* pContext( getContext() );
273 0 : if ( pContext )
274 0 : pContext->commitEvent( nEventId, rNewValue, rOldValue );
275 0 : }
276 :
277 : private:
278 : AccessibleGridControlAccess(); // never implemented
279 : AccessibleGridControlAccess( const AccessibleGridControlAccess& ); // never implemented
280 : AccessibleGridControlAccess& operator=( const AccessibleGridControlAccess& ); // never implemented
281 : };
282 :
283 : // ============================================================================
284 : } // namespace accessibility
285 :
286 : // ============================================================================
287 :
288 : #endif
289 :
290 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|