1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 #ifndef _SC_ACCESSIBLEDOCUMENT_HXX
30 #define _SC_ACCESSIBLEDOCUMENT_HXX
31 
32 #include "AccessibleDocumentBase.hxx"
33 #include "viewdata.hxx"
34 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
35 #include <com/sun/star/view/XSelectionChangeListener.hpp>
36 #include <cppuhelper/implbase2.hxx>
37 #include <svx/IAccessibleViewForwarder.hxx>
38 
39 class ScTabViewShell;
40 class ScAccessibleSpreadsheet;
41 class ScChildrenShapes;
42 class ScAccessibleEditObject;
43 
44 namespace accessibility
45 {
46 	class AccessibleShape;
47 }
48 namespace utl
49 {
50     class AccessibleRelationSetHelper;
51 }
52 
53 /**	@descr
54         This base class provides an implementation of the
55         <code>AccessibleContext</code> service.
56 */
57 
58 typedef cppu::ImplHelper2< ::com::sun::star::accessibility::XAccessibleSelection,
59 							::com::sun::star::view::XSelectionChangeListener >
60 					ScAccessibleDocumentImpl;
61 
62 class ScAccessibleDocument
63 	:	public ScAccessibleDocumentBase,
64 		public ScAccessibleDocumentImpl,
65         public accessibility::IAccessibleViewForwarder
66 {
67 public:
68 	//=====  internal  ========================================================
69 	ScAccessibleDocument(
70         const ::com::sun::star::uno::Reference<
71         ::com::sun::star::accessibility::XAccessible>& rxParent,
72 		ScTabViewShell* pViewShell,
73 		ScSplitPos eSplitPos);
74 
75 	virtual void Init();
76 
77 
78 	DECL_LINK( WindowChildEventListener, VclSimpleEvent* );
79 protected:
80 	virtual ~ScAccessibleDocument(void);
81 
82     using ScAccessibleDocumentBase::IsDefunc;
83 
84 public:
85 
86  	virtual void SAL_CALL disposing();
87 
88    ///=====  SfxListener  =====================================================
89 
90 	virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
91 
92 	///=====  XInterface  =====================================================
93 
94 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
95 		::com::sun::star::uno::Type const & rType )
96 		throw (::com::sun::star::uno::RuntimeException);
97 
98 	virtual void SAL_CALL acquire() throw ();
99 
100 	virtual void SAL_CALL release() throw ();
101 
102 	///=====  XAccessibleComponent  ============================================
103 
104     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
105 		SAL_CALL getAccessibleAtPoint(
106 		const ::com::sun::star::awt::Point& rPoint )
107 		throw (::com::sun::star::uno::RuntimeException);
108 
109     virtual void SAL_CALL grabFocus(  )
110 		throw (::com::sun::star::uno::RuntimeException);
111 
112 	///=====  XAccessibleContext  ==============================================
113 
114     ///	Return the number of currently visible children.
115     virtual sal_Int32 SAL_CALL
116     	getAccessibleChildCount(void)
117         throw (::com::sun::star::uno::RuntimeException);
118 
119     ///	Return the specified child or NULL if index is invalid.
120     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
121     	getAccessibleChild(sal_Int32 nIndex)
122         throw (::com::sun::star::uno::RuntimeException,
123 				::com::sun::star::lang::IndexOutOfBoundsException);
124 
125     ///	Return the set of current states.
126 	virtual ::com::sun::star::uno::Reference<
127             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
128     	getAccessibleStateSet(void)
129         throw (::com::sun::star::uno::RuntimeException);
130 
131 	///=====  XAccessibleSelection  ===========================================
132 
133     virtual void SAL_CALL
134 		selectAccessibleChild( sal_Int32 nChildIndex )
135 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
136 		::com::sun::star::uno::RuntimeException);
137 
138     virtual sal_Bool SAL_CALL
139 		isAccessibleChildSelected( sal_Int32 nChildIndex )
140 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
141 		::com::sun::star::uno::RuntimeException);
142 
143     virtual void SAL_CALL
144 		clearAccessibleSelection(  )
145 		throw (::com::sun::star::uno::RuntimeException);
146 
147     virtual void SAL_CALL
148 		selectAllAccessibleChildren(  )
149 		throw (::com::sun::star::uno::RuntimeException);
150 
151     virtual sal_Int32 SAL_CALL
152 		getSelectedAccessibleChildCount(  )
153 		throw (::com::sun::star::uno::RuntimeException);
154 
155     virtual ::com::sun::star::uno::Reference<
156 		::com::sun::star::accessibility::XAccessible > SAL_CALL
157 		getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
158 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
159 		::com::sun::star::uno::RuntimeException);
160 
161     virtual void SAL_CALL
162 		deselectAccessibleChild( sal_Int32 nChildIndex )
163 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
164 		::com::sun::star::uno::RuntimeException);
165 
166 	///=====  XSelectionListener  =============================================
167 
168     virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent )
169 		throw (::com::sun::star::uno::RuntimeException);
170 
171     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
172 		throw (::com::sun::star::uno::RuntimeException);
173 
174 	///=====  XServiceInfo  ===================================================
175 
176     /**	Returns an identifier for the implementation of this object.
177     */
178 	virtual ::rtl::OUString SAL_CALL
179     	getImplementationName(void)
180         throw (::com::sun::star::uno::RuntimeException);
181 
182     /** Returns a list of all supported services.
183     */
184 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
185     	getSupportedServiceNames(void)
186         throw (::com::sun::star::uno::RuntimeException);
187 
188 	///=====  XTypeProvider  ===================================================
189 
190 	/// returns the possible types
191     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
192 		getTypes()
193 		throw (::com::sun::star::uno::RuntimeException);
194 
195 	/**	Returns a implementation id.
196     */
197     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
198         getImplementationId(void)
199         throw (::com::sun::star::uno::RuntimeException);
200 
201 	///=====  IAccessibleViewForwarder  ========================================
202 
203     /** This method informs you about the state of the forwarder.  Do not
204         use it when the returned value is <false/>.
205 
206     	@return
207             Return <true/> if the view forwarder is valid and <false/> else.
208      */
209 	virtual sal_Bool IsValid (void) const;
210 
211     /** Returns the area of the underlying document that is visible in the
212     * corresponding window.
213 
214     	@return
215             The rectangle of the visible part of the document. The values
216             are, contrary to the base class, in internal coordinates.
217      */
218     virtual Rectangle GetVisibleArea() const;
219 
220     /** Transform the specified point from internal coordinates to an
221         absolute screen position.
222 
223     	@param rPoint
224             Point in internal coordinates.
225 
226         @return
227             The same point but in screen coordinates relative to the upper
228             left corner of the (current) screen.
229      */
230     virtual Point LogicToPixel (const Point& rPoint) const;
231 
232     /** Transform the specified size from internal coordinates to a screen
233     * oriented pixel size.
234 
235     	@param rSize
236             Size in internal coordinates.
237 
238         @return
239             The same size but in screen coordinates.
240      */
241     virtual Size LogicToPixel (const Size& rSize) const;
242 
243     /** Transform the specified point from absolute screen coordinates to
244         internal coordinates.
245 
246     	@param rPoint
247             Point in screen coordinates relative to the upper left corner of
248             the (current) screen.
249 
250         @return
251             The same point but in internal coordinates.
252      */
253     virtual Point PixelToLogic (const Point& rPoint) const;
254 
255     /** Transform the specified size from screen coordinates to internal
256         coordinates.
257 
258     	@param rSize
259             Size in screen coordinates.
260 
261         @return
262             The same size but in internal coordinates.
263      */
264     virtual Size PixelToLogic (const Size& rSize) const;
265 
266     ///======== internal =====================================================
267 
268     utl::AccessibleRelationSetHelper* GetRelationSet(const ScAddress* pAddress) const;
269 
270 	::com::sun::star::uno::Reference
271 		< ::com::sun::star::accessibility::XAccessible >
272 		GetAccessibleSpreadsheet();
273 
274 protected:
275     ///	Return this object's description.
276 	virtual ::rtl::OUString SAL_CALL
277     	createAccessibleDescription(void)
278         throw (::com::sun::star::uno::RuntimeException);
279 
280     ///	Return the object's current name.
281 	virtual ::rtl::OUString SAL_CALL
282     	createAccessibleName(void)
283         throw (::com::sun::star::uno::RuntimeException);
284 
285     ///	Return the object's current bounding box relative to the desktop.
286 	virtual Rectangle GetBoundingBoxOnScreen(void) const
287 		throw (::com::sun::star::uno::RuntimeException);
288 
289 	///	Return the object's current bounding box relative to the parent object.
290 	virtual Rectangle GetBoundingBox(void) const
291 		throw (::com::sun::star::uno::RuntimeException);
292 
293 private:
294 	ScTabViewShell*	mpViewShell;
295 	ScSplitPos		meSplitPos;
296 	ScAccessibleSpreadsheet* mpAccessibleSpreadsheet;
297     ScChildrenShapes* mpChildrenShapes;
298     ScAccessibleEditObject* mpTempAccEdit;
299     com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> mxTempAcc;
300     Rectangle maVisArea;
301 	sal_Bool mbCompleteSheetSelected;
302 
303 public:
304     SCTAB getVisibleTable() const; // use it in ScChildrenShapes
305 
306 private:
307 	void FreeAccessibleSpreadsheet();
308 
309 	sal_Bool IsTableSelected() const;
310 
311     sal_Bool IsDefunc(
312 		const com::sun::star::uno::Reference<
313 		::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
314 	sal_Bool IsEditable(
315 		const com::sun::star::uno::Reference<
316 		::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
317 
318     void AddChild(const com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>& xAcc, sal_Bool bFireEvent);
319     void RemoveChild(const com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>& xAcc, sal_Bool bFireEvent);
320 
321     rtl::OUString GetCurrentCellName() const;
322     rtl::OUString GetCurrentCellDescription() const;
323 
324     Rectangle GetVisibleArea_Impl() const;
325 };
326 
327 
328 #endif
329