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