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_ACCESSIBLEEDITOBJECT_HXX
30 #define _SC_ACCESSIBLEEDITOBJECT_HXX
31 
32 #include "AccessibleContextBase.hxx"
33 
34 namespace accessibility
35 {
36     class AccessibleTextHelper;
37 }
38 class EditView;
39 class Window;
40 
41 enum EditObjectType
42 {
43     CellInEditMode,
44     EditLine,
45     EditControl
46 };
47 
48 /**	@descr
49         This base class provides an implementation of the
50         <code>AccessibleCell</code> service.
51 */
52 class ScAccessibleEditObject
53 	:	public	ScAccessibleContextBase
54 {
55 public:
56 	//=====  internal  ========================================================
57 	ScAccessibleEditObject(
58         const ::com::sun::star::uno::Reference<
59         ::com::sun::star::accessibility::XAccessible>& rxParent,
60         EditView* pEditView, Window* pWin, const rtl::OUString& rName,
61         const rtl::OUString& rDescription, EditObjectType eObjectType);
62 
63 protected:
64 	virtual ~ScAccessibleEditObject();
65 
66     using ScAccessibleContextBase::IsDefunc;
67 
68 public:
69     using ScAccessibleContextBase::addEventListener;
70     using ScAccessibleContextBase::removeEventListener;
71     using ScAccessibleContextBase::disposing;
72 
73     virtual void SAL_CALL disposing();
74 
75     virtual void LostFocus();
76 
77     virtual void GotFocus();
78 
79 	///=====  XAccessibleComponent  ============================================
80 
81     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
82 		SAL_CALL getAccessibleAtPoint(
83 		const ::com::sun::star::awt::Point& rPoint )
84 		throw (::com::sun::star::uno::RuntimeException);
85 
86 protected:
87     ///	Return the object's current bounding box relative to the desktop.
88 	virtual Rectangle GetBoundingBoxOnScreen(void) const
89 		throw (::com::sun::star::uno::RuntimeException);
90 
91 	///	Return the object's current bounding box relative to the parent object.
92 	virtual Rectangle GetBoundingBox(void) const
93 		throw (::com::sun::star::uno::RuntimeException);
94 
95 public:
96 	///=====  XAccessibleContext  ==============================================
97 
98     ///	Return the number of currently visible children.
99     // is overloaded to calculate this on demand
100     virtual sal_Int32 SAL_CALL
101     	getAccessibleChildCount(void)
102     				throw (::com::sun::star::uno::RuntimeException);
103 
104     ///	Return the specified child or NULL if index is invalid.
105     // is overloaded to calculate this on demand
106     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
107     	getAccessibleChild(sal_Int32 nIndex)
108         throw (::com::sun::star::uno::RuntimeException,
109 				::com::sun::star::lang::IndexOutOfBoundsException);
110 
111 	///	Return the set of current states.
112 	virtual ::com::sun::star::uno::Reference<
113             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
114     	getAccessibleStateSet(void)
115         throw (::com::sun::star::uno::RuntimeException);
116 
117 protected:
118     ///	Return this object's description.
119 	virtual ::rtl::OUString SAL_CALL
120     	createAccessibleDescription(void)
121         throw (::com::sun::star::uno::RuntimeException);
122 
123     ///	Return the object's current name.
124 	virtual ::rtl::OUString SAL_CALL
125     	createAccessibleName(void)
126         throw (::com::sun::star::uno::RuntimeException);
127 
128 public:
129 	///=====  XAccessibleEventBroadcaster  =====================================
130 
131     /**	Add listener that is informed of future changes of name,
132       	description and so on events.
133     */
134 	virtual void SAL_CALL
135     	addEventListener(
136         	const ::com::sun::star::uno::Reference<
137                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
138         throw (com::sun::star::uno::RuntimeException);
139 
140     //	Remove an existing event listener.
141 	virtual void SAL_CALL
142     	removeEventListener(
143 			const ::com::sun::star::uno::Reference<
144                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
145         throw (com::sun::star::uno::RuntimeException);
146 
147     ///=====  XServiceInfo  ====================================================
148 
149     /**	Returns an identifier for the implementation of this object.
150     */
151 	virtual ::rtl::OUString SAL_CALL
152     	getImplementationName(void)
153         throw (::com::sun::star::uno::RuntimeException);
154 
155 	///=====  XTypeProvider  ===================================================
156 
157     /**	Returns a implementation id.
158     */
159     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
160         getImplementationId(void)
161         throw (::com::sun::star::uno::RuntimeException);
162 
163 private:
164 	accessibility::AccessibleTextHelper* mpTextHelper;
165     EditView* mpEditView;
166     Window* mpWindow;
167     EditObjectType meObjectType;
168     sal_Bool mbHasFocus;
169 
170 	sal_Bool IsDefunc(
171 		const com::sun::star::uno::Reference<
172 		::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
173 
174 	void CreateTextHelper();
175 };
176 
177 
178 #endif
179