1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 
25 #ifndef _SC_ACCESSIBLEEDITOBJECT_HXX
26 #define _SC_ACCESSIBLEEDITOBJECT_HXX
27 
28 #include "AccessibleContextBase.hxx"
29 
30 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
31 #include "global.hxx"
32 namespace accessibility
33 {
34     class AccessibleTextHelper;
35 }
36 class EditView;
37 class Window;
38 
39 enum EditObjectType
40 {
41     CellInEditMode,
42     EditLine,
43     EditControl
44 };
45 
46 /**	@descr
47         This base class provides an implementation of the
48         <code>AccessibleCell</code> service.
49 */
50 class ScAccessibleEditObject
51 	:	public	ScAccessibleContextBase,
52         public ::com::sun::star::accessibility::XAccessibleSelection
53 {
54 public:
55 	//=====  internal  ========================================================
56 	ScAccessibleEditObject(
57         const ::com::sun::star::uno::Reference<
58         ::com::sun::star::accessibility::XAccessible>& rxParent,
59         EditView* pEditView, Window* pWin, const rtl::OUString& rName,
60         const rtl::OUString& rDescription, EditObjectType eObjectType);
61 
62 protected:
63 	virtual ~ScAccessibleEditObject();
64 
65     using ScAccessibleContextBase::IsDefunc;
66 
67 public:
68     using ScAccessibleContextBase::addEventListener;
69     using ScAccessibleContextBase::removeEventListener;
70     using ScAccessibleContextBase::disposing;
71 
72     virtual void SAL_CALL disposing();
73 
74     virtual void LostFocus();
75 
76     virtual void GotFocus();
77 ///=====  XInterface  =====================================================
78 
79 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
80 		::com::sun::star::uno::Type const & rType )
81 		throw (::com::sun::star::uno::RuntimeException);
82 
83 	virtual void SAL_CALL acquire() throw ();
84 
85 	virtual void SAL_CALL release() throw ();
86 	///=====  XAccessibleComponent  ============================================
87 
88     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
89 		SAL_CALL getAccessibleAtPoint(
90 		const ::com::sun::star::awt::Point& rPoint )
91 		throw (::com::sun::star::uno::RuntimeException);
92 
93 protected:
94     ///	Return the object's current bounding box relative to the desktop.
95 	virtual Rectangle GetBoundingBoxOnScreen(void) const
96 		throw (::com::sun::star::uno::RuntimeException);
97 
98 	///	Return the object's current bounding box relative to the parent object.
99 	virtual Rectangle GetBoundingBox(void) const
100 		throw (::com::sun::star::uno::RuntimeException);
101 
102 public:
103 	///=====  XAccessibleContext  ==============================================
104 
105     ///	Return the number of currently visible children.
106     // is overloaded to calculate this on demand
107     virtual sal_Int32 SAL_CALL
108     	getAccessibleChildCount(void)
109     				throw (::com::sun::star::uno::RuntimeException);
110 
111     ///	Return the specified child or NULL if index is invalid.
112     // is overloaded to calculate this on demand
113     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
114     	getAccessibleChild(sal_Int32 nIndex)
115         throw (::com::sun::star::uno::RuntimeException,
116 				::com::sun::star::lang::IndexOutOfBoundsException);
117 
118 	///	Return the set of current states.
119 	virtual ::com::sun::star::uno::Reference<
120             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
121     	getAccessibleStateSet(void)
122         throw (::com::sun::star::uno::RuntimeException);
123 
124 	//=====  XAccessibleSelection  ============================================
125 
126 		virtual void SAL_CALL selectAccessibleChild(
127 			sal_Int32 nChildIndex )
128 			throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
129 			::com::sun::star::uno::RuntimeException );
130 		virtual sal_Bool SAL_CALL isAccessibleChildSelected(
131 			sal_Int32 nChildIndex )
132 			throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
133 			::com::sun::star::uno::RuntimeException );
134 		virtual void SAL_CALL clearAccessibleSelection(  )
135 			throw ( ::com::sun::star::uno::RuntimeException );
136 		virtual void SAL_CALL selectAllAccessibleChildren(  )
137 			throw ( ::com::sun::star::uno::RuntimeException );
138 		virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount(  )
139 			throw ( ::com::sun::star::uno::RuntimeException );
140 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(
141 			sal_Int32 nSelectedChildIndex )
142 			throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
143 			::com::sun::star::uno::RuntimeException);
144 		virtual void SAL_CALL deselectAccessibleChild(
145 			sal_Int32 nSelectedChildIndex )
146 			throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
147 			::com::sun::star::uno::RuntimeException );
148     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) throw (::com::sun::star::uno::RuntimeException);
149 protected:
150     ///	Return this object's description.
151 	virtual ::rtl::OUString SAL_CALL
152     	createAccessibleDescription(void)
153         throw (::com::sun::star::uno::RuntimeException);
154 
155     ///	Return the object's current name.
156 	virtual ::rtl::OUString SAL_CALL
157     	createAccessibleName(void)
158         throw (::com::sun::star::uno::RuntimeException);
159 
160 public:
161 	///=====  XAccessibleEventBroadcaster  =====================================
162 
163     /**	Add listener that is informed of future changes of name,
164       	description and so on events.
165     */
166 	virtual void SAL_CALL
167     	addEventListener(
168         	const ::com::sun::star::uno::Reference<
169                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
170         throw (com::sun::star::uno::RuntimeException);
171 
172     //	Remove an existing event listener.
173 	virtual void SAL_CALL
174     	removeEventListener(
175 			const ::com::sun::star::uno::Reference<
176                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
177         throw (com::sun::star::uno::RuntimeException);
178 
179     ///=====  XServiceInfo  ====================================================
180 
181     /**	Returns an identifier for the implementation of this object.
182     */
183 	virtual ::rtl::OUString SAL_CALL
184     	getImplementationName(void)
185         throw (::com::sun::star::uno::RuntimeException);
186 
187 	///=====  XTypeProvider  ===================================================
188 
189     /**	Returns a implementation id.
190     */
191     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
192         getImplementationId(void)
193         throw (::com::sun::star::uno::RuntimeException);
194 
195 private:
196 	accessibility::AccessibleTextHelper* mpTextHelper;
197     EditView* mpEditView;
198     Window* mpWindow;
199     EditObjectType meObjectType;
200     sal_Bool mbHasFocus;
201 
202 	sal_Bool IsDefunc(
203 		const com::sun::star::uno::Reference<
204 		::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
205 
206 	void CreateTextHelper();
207 	ScDocument *m_pScDoc;
208 	ScAddress m_curCellAddress;
209 
210 
211 	///=====  XAccessibleComponent  ============================================
212     virtual sal_Int32 SAL_CALL getForeground(  )
213         throw (::com::sun::star::uno::RuntimeException);
214 
215     virtual sal_Int32 SAL_CALL getBackground(  )
216         throw (::com::sun::star::uno::RuntimeException);
217 
218 	sal_Int32 GetFgBgColor(  const rtl::OUString &strPropColor) ;
219 };
220 
221 
222 #endif
223