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