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 <boost/scoped_ptr.hpp>
26 : #include <cppuhelper/weakref.hxx>
27 : #include <svtools/accessibletable.hxx>
28 :
29 :
30 :
31 : namespace accessibility {
32 :
33 : class AccessibleGridControl_Impl;
34 :
35 :
36 :
37 : /** This class represents the complete accessible Grid Control object. */
38 : class AccessibleGridControl : public AccessibleGridControlBase
39 : {
40 : friend class AccessibleGridControlAccess;
41 :
42 : protected:
43 : AccessibleGridControl(
44 : const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent,
45 : const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxCreator,
46 : ::svt::table::IAccessibleTable& _rTable
47 : );
48 :
49 : virtual ~AccessibleGridControl();
50 :
51 : /** Cleans up members. */
52 : using AccessibleGridControlBase::disposing;
53 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
54 :
55 : protected:
56 : // XAccessibleContext -----------------------------------------------------
57 :
58 : /** @return The count of visible children. */
59 : virtual sal_Int32 SAL_CALL getAccessibleChildCount()
60 : throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
61 :
62 : /** @return The XAccessible interface of the specified child. */
63 : virtual ::com::sun::star::uno::Reference<
64 : ::com::sun::star::accessibility::XAccessible > SAL_CALL
65 : getAccessibleChild( sal_Int32 nChildIndex )
66 : throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
67 : ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
68 :
69 : /** @return The role of this object (a table). */
70 : virtual sal_Int16 SAL_CALL getAccessibleRole()
71 : throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
72 :
73 : // XAccessibleComponent ---------------------------------------------------
74 :
75 : /** @return
76 : The accessible child rendered under the given point.
77 : */
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 : throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
82 :
83 : /** Grabs the focus to the Grid Control. */
84 : virtual void SAL_CALL grabFocus()
85 : throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
86 :
87 : // XServiceInfo -----------------------------------------------------------
88 :
89 : /** @return
90 : The name of this class.
91 : */
92 : virtual OUString SAL_CALL getImplementationName()
93 : throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
94 :
95 : public:
96 : // helper functions
97 :
98 : /** commitCellEvent commit the event at all listeners of the table
99 : @param nEventId
100 : the event id
101 : @param rNewValue
102 : the new value
103 : @param rOldValue
104 : the old value
105 : */
106 : void commitCellEvent(sal_Int16 nEventId, const ::com::sun::star::uno::Any& rNewValue,
107 : const ::com::sun::star::uno::Any& rOldValue);
108 :
109 : /** commitTableEvent commit the event at all listeners of the table
110 : @param nEventId
111 : the event id
112 : @param rNewValue
113 : the new value
114 : @param rOldValue
115 : the old value
116 : */
117 : void commitTableEvent(sal_Int16 nEventId, const ::com::sun::star::uno::Any& rNewValue,
118 : const ::com::sun::star::uno::Any& rOldValue);
119 : /** returns the accessible object for the row or the column header bar
120 : */
121 : inline ::com::sun::star::uno::Reference<
122 : ::com::sun::star::accessibility::XAccessible >
123 0 : getHeaderBar( ::svt::table::AccessibleTableControlObjType _eObjType )
124 : {
125 0 : return implGetHeaderBar(_eObjType);
126 : }
127 :
128 : /** returns the accessible object for the table representation
129 : */
130 : inline ::com::sun::star::uno::Reference<
131 : ::com::sun::star::accessibility::XAccessible >
132 0 : getTable( )
133 : {
134 0 : return implGetTable();
135 : }
136 :
137 : protected:
138 : // internal virtual methods -----------------------------------------------
139 :
140 : /** @attention This method requires locked mutex's and a living object.
141 : @return The bounding box (VCL rect.) relative to the parent window. */
142 : virtual Rectangle implGetBoundingBox() SAL_OVERRIDE;
143 : /** @attention This method requires locked mutex's and a living object.
144 : @return The bounding box (VCL rect.) in screen coordinates. */
145 : virtual Rectangle implGetBoundingBoxOnScreen() SAL_OVERRIDE;
146 :
147 : // internal helper methods ------------------------------------------------
148 :
149 : /** This method creates (once) and returns the accessible data table child.
150 : @attention This method requires locked mutex's and a living object.
151 : @return The XAccessible interface of the data table. */
152 : virtual ::com::sun::star::uno::Reference<
153 : ::com::sun::star::accessibility::XAccessible > implGetTable();
154 :
155 : /** This method creates (once) and returns the specified header bar.
156 : @attention This method requires locked mutex's and a living object.
157 : @return The XAccessible interface of the header bar. */
158 : ::com::sun::star::uno::Reference<
159 : ::com::sun::star::accessibility::XAccessible >
160 : implGetHeaderBar( ::svt::table::AccessibleTableControlObjType eObjType );
161 :
162 : /** This method returns one of the children that are always present:
163 : Data table, row and column header bar or corner control.
164 : @attention This method requires locked mutex's and a living object.
165 : @return The XAccessible interface of the specified child. */
166 : ::com::sun::star::uno::Reference<
167 : ::com::sun::star::accessibility::XAccessible >
168 : implGetFixedChild( sal_Int32 nChildIndex );
169 :
170 : /** This method creates and returns an accessible table.
171 : @return An AccessibleGridControlTable. */
172 : virtual AccessibleGridControlTable* createAccessibleTable();
173 :
174 : private:
175 : // members ----------------------------------------------------------------
176 : boost::scoped_ptr< AccessibleGridControl_Impl > m_pImpl;
177 : };
178 :
179 :
180 : /** the XAccessible which creates/returns an AccessibleGridControl
181 :
182 : <p>The instance holds its XAccessibleContext with a hard reference, while
183 : the contxt holds this instance weak.</p>
184 : */
185 : typedef ::cppu::WeakImplHelper1 < ::com::sun::star::accessibility::XAccessible > AccessibleGridControlAccess_Base;
186 :
187 : class AccessibleGridControlAccess :public AccessibleGridControlAccess_Base
188 : ,public ::svt::table::IAccessibleTableControl
189 : {
190 : private:
191 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
192 : m_xParent;
193 : ::svt::table::IAccessibleTable * m_pTable;
194 :
195 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
196 : m_xContext;
197 : AccessibleGridControl* m_pContext;
198 : // note that this pointer is valid as long as m_xContext is valid!
199 :
200 : public:
201 : AccessibleGridControlAccess(
202 : const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent,
203 : ::svt::table::IAccessibleTable& _rTable
204 : );
205 :
206 : /// checks whether the accessible context is still alive
207 : bool isContextAlive() const;
208 :
209 : /// returns the AccessibleContext belonging to this Accessible
210 0 : inline AccessibleGridControl* getContext() { return m_pContext; }
211 : inline const AccessibleGridControl* getContext() const { return m_pContext; }
212 :
213 : protected:
214 : virtual ~AccessibleGridControlAccess();
215 :
216 : // XAccessible
217 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext >
218 : SAL_CALL getAccessibleContext() throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
219 :
220 : // IAccessibleTable
221 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
222 0 : getMyself() SAL_OVERRIDE
223 : {
224 0 : return this;
225 : }
226 : void DisposeAccessImpl() SAL_OVERRIDE;
227 0 : virtual bool isAlive() const SAL_OVERRIDE
228 : {
229 0 : return isContextAlive();
230 : }
231 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
232 0 : getTableHeader( ::svt::table::AccessibleTableControlObjType _eObjType ) SAL_OVERRIDE
233 : {
234 0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible;
235 0 : AccessibleGridControl* pContext( getContext() );
236 0 : if ( pContext )
237 0 : xAccessible = pContext->getHeaderBar( _eObjType );
238 0 : return xAccessible;
239 : }
240 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
241 0 : getTable() SAL_OVERRIDE
242 : {
243 0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible;
244 0 : AccessibleGridControl* pContext( getContext() );
245 0 : if ( pContext )
246 0 : xAccessible = pContext->getTable();
247 0 : return xAccessible;
248 : }
249 0 : virtual void commitCellEvent( sal_Int16 nEventId,
250 : const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue ) SAL_OVERRIDE
251 : {
252 0 : AccessibleGridControl* pContext( getContext() );
253 0 : if ( pContext )
254 0 : pContext->commitCellEvent( nEventId, rNewValue, rOldValue );
255 0 : }
256 0 : virtual void commitTableEvent( sal_Int16 nEventId,
257 : const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue ) SAL_OVERRIDE
258 : {
259 0 : AccessibleGridControl* pContext( getContext() );
260 0 : if ( pContext )
261 0 : pContext->commitTableEvent( nEventId, rNewValue, rOldValue );
262 0 : }
263 0 : virtual void commitEvent( sal_Int16 nEventId,
264 : const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue ) SAL_OVERRIDE
265 : {
266 0 : AccessibleGridControl* pContext( getContext() );
267 0 : if ( pContext )
268 0 : pContext->commitEvent( nEventId, rNewValue, rOldValue );
269 0 : }
270 :
271 : private:
272 : AccessibleGridControlAccess(); // never implemented
273 : AccessibleGridControlAccess( const AccessibleGridControlAccess& ); // never implemented
274 : AccessibleGridControlAccess& operator=( const AccessibleGridControlAccess& ); // never implemented
275 : };
276 :
277 :
278 : } // namespace accessibility
279 :
280 :
281 :
282 : #endif
283 :
284 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|