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