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