138d50f7bSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
338d50f7bSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
438d50f7bSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
538d50f7bSAndrew Rist  * distributed with this work for additional information
638d50f7bSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
738d50f7bSAndrew Rist  * to you under the Apache License, Version 2.0 (the
838d50f7bSAndrew Rist  * "License"); you may not use this file except in compliance
938d50f7bSAndrew Rist  * with the License.  You may obtain a copy of the License at
1038d50f7bSAndrew Rist  *
1138d50f7bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1238d50f7bSAndrew Rist  *
1338d50f7bSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1438d50f7bSAndrew Rist  * software distributed under the License is distributed on an
1538d50f7bSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1638d50f7bSAndrew Rist  * KIND, either express or implied.  See the License for the
1738d50f7bSAndrew Rist  * specific language governing permissions and limitations
1838d50f7bSAndrew Rist  * under the License.
1938d50f7bSAndrew Rist  *
2038d50f7bSAndrew Rist  *************************************************************/
2138d50f7bSAndrew Rist 
2238d50f7bSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir #ifndef _SC_ACCESSIBLEDOCUMENT_HXX
26cdf0e10cSrcweir #define _SC_ACCESSIBLEDOCUMENT_HXX
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "AccessibleDocumentBase.hxx"
29cdf0e10cSrcweir #include "viewdata.hxx"
30cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
31cdf0e10cSrcweir #include <com/sun/star/view/XSelectionChangeListener.hpp>
32*0deba7fbSSteve Yin #include <cppuhelper/implbase3.hxx>
33*0deba7fbSSteve Yin #include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp>
34*0deba7fbSSteve Yin #include <com/sun/star/accessibility/XAccessibleGetAccFlowTo.hpp>
35cdf0e10cSrcweir #include <svx/IAccessibleViewForwarder.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir class ScTabViewShell;
38cdf0e10cSrcweir class ScAccessibleSpreadsheet;
39cdf0e10cSrcweir class ScChildrenShapes;
40cdf0e10cSrcweir class ScAccessibleEditObject;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace accessibility
43cdf0e10cSrcweir {
44cdf0e10cSrcweir 	class AccessibleShape;
45cdf0e10cSrcweir }
46cdf0e10cSrcweir namespace utl
47cdf0e10cSrcweir {
48cdf0e10cSrcweir     class AccessibleRelationSetHelper;
49cdf0e10cSrcweir }
50cdf0e10cSrcweir 
51cdf0e10cSrcweir /**	@descr
52cdf0e10cSrcweir         This base class provides an implementation of the
53cdf0e10cSrcweir         <code>AccessibleContext</code> service.
54cdf0e10cSrcweir */
55cdf0e10cSrcweir 
56*0deba7fbSSteve Yin typedef cppu::ImplHelper3< ::com::sun::star::accessibility::XAccessibleSelection,
57*0deba7fbSSteve Yin 							::com::sun::star::accessibility::XAccessibleExtendedAttributes,
58cdf0e10cSrcweir 							::com::sun::star::view::XSelectionChangeListener >
59cdf0e10cSrcweir 					ScAccessibleDocumentImpl;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir class ScAccessibleDocument
62cdf0e10cSrcweir 	:	public ScAccessibleDocumentBase,
63cdf0e10cSrcweir 		public ScAccessibleDocumentImpl,
64*0deba7fbSSteve Yin 	       public com::sun::star::accessibility::XAccessibleGetAccFlowTo,
65cdf0e10cSrcweir         public accessibility::IAccessibleViewForwarder
66cdf0e10cSrcweir {
67cdf0e10cSrcweir public:
68cdf0e10cSrcweir 	//=====  internal  ========================================================
69cdf0e10cSrcweir 	ScAccessibleDocument(
70cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
71cdf0e10cSrcweir         ::com::sun::star::accessibility::XAccessible>& rxParent,
72cdf0e10cSrcweir 		ScTabViewShell* pViewShell,
73cdf0e10cSrcweir 		ScSplitPos eSplitPos);
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	virtual void Init();
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	DECL_LINK( WindowChildEventListener, VclSimpleEvent* );
79cdf0e10cSrcweir protected:
80cdf0e10cSrcweir 	virtual ~ScAccessibleDocument(void);
81cdf0e10cSrcweir 
82cdf0e10cSrcweir     using ScAccessibleDocumentBase::IsDefunc;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir public:
85cdf0e10cSrcweir 
86cdf0e10cSrcweir  	virtual void SAL_CALL disposing();
87cdf0e10cSrcweir 
88cdf0e10cSrcweir    ///=====  SfxListener  =====================================================
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	///=====  XInterface  =====================================================
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
95cdf0e10cSrcweir 		::com::sun::star::uno::Type const & rType )
96cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	virtual void SAL_CALL acquire() throw ();
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	virtual void SAL_CALL release() throw ();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	///=====  XAccessibleComponent  ============================================
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
105cdf0e10cSrcweir 		SAL_CALL getAccessibleAtPoint(
106cdf0e10cSrcweir 		const ::com::sun::star::awt::Point& rPoint )
107cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     virtual void SAL_CALL grabFocus(  )
110cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	///=====  XAccessibleContext  ==============================================
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     ///	Return the number of currently visible children.
115cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL
116cdf0e10cSrcweir     	getAccessibleChildCount(void)
117cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     ///	Return the specified child or NULL if index is invalid.
120cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
121cdf0e10cSrcweir     	getAccessibleChild(sal_Int32 nIndex)
122cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException,
123cdf0e10cSrcweir 				::com::sun::star::lang::IndexOutOfBoundsException);
124cdf0e10cSrcweir 
125cdf0e10cSrcweir     ///	Return the set of current states.
126cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference<
127cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
128cdf0e10cSrcweir     	getAccessibleStateSet(void)
129cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
130cdf0e10cSrcweir 
131*0deba7fbSSteve Yin 	virtual ::rtl::OUString SAL_CALL
132*0deba7fbSSteve Yin 		getAccessibleName(void)
133*0deba7fbSSteve Yin 		throw (::com::sun::star::uno::RuntimeException);
134*0deba7fbSSteve Yin 
135*0deba7fbSSteve Yin 	virtual ::com::sun::star::uno::Any SAL_CALL getExtendedAttributes()
136*0deba7fbSSteve Yin 		throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) ;
137cdf0e10cSrcweir 	///=====  XAccessibleSelection  ===========================================
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     virtual void SAL_CALL
140cdf0e10cSrcweir 		selectAccessibleChild( sal_Int32 nChildIndex )
141cdf0e10cSrcweir 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
142cdf0e10cSrcweir 		::com::sun::star::uno::RuntimeException);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
145cdf0e10cSrcweir 		isAccessibleChildSelected( sal_Int32 nChildIndex )
146cdf0e10cSrcweir 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
147cdf0e10cSrcweir 		::com::sun::star::uno::RuntimeException);
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     virtual void SAL_CALL
150cdf0e10cSrcweir 		clearAccessibleSelection(  )
151cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     virtual void SAL_CALL
154cdf0e10cSrcweir 		selectAllAccessibleChildren(  )
155cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL
158cdf0e10cSrcweir 		getSelectedAccessibleChildCount(  )
159cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
160cdf0e10cSrcweir 
161cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
162cdf0e10cSrcweir 		::com::sun::star::accessibility::XAccessible > SAL_CALL
163cdf0e10cSrcweir 		getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
164cdf0e10cSrcweir 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
165cdf0e10cSrcweir 		::com::sun::star::uno::RuntimeException);
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     virtual void SAL_CALL
168cdf0e10cSrcweir 		deselectAccessibleChild( sal_Int32 nChildIndex )
169cdf0e10cSrcweir 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
170cdf0e10cSrcweir 		::com::sun::star::uno::RuntimeException);
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 	///=====  XSelectionListener  =============================================
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent )
175cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
178cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	///=====  XServiceInfo  ===================================================
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     /**	Returns an identifier for the implementation of this object.
183cdf0e10cSrcweir     */
184cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL
185cdf0e10cSrcweir     	getImplementationName(void)
186cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
187cdf0e10cSrcweir 
188cdf0e10cSrcweir     /** Returns a list of all supported services.
189cdf0e10cSrcweir     */
190cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
191cdf0e10cSrcweir     	getSupportedServiceNames(void)
192cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 	///=====  XTypeProvider  ===================================================
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 	/// returns the possible types
197cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
198cdf0e10cSrcweir 		getTypes()
199cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 	/**	Returns a implementation id.
202cdf0e10cSrcweir     */
203cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
204cdf0e10cSrcweir         getImplementationId(void)
205cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	///=====  IAccessibleViewForwarder  ========================================
208cdf0e10cSrcweir 
209cdf0e10cSrcweir     /** This method informs you about the state of the forwarder.  Do not
210cdf0e10cSrcweir         use it when the returned value is <false/>.
211cdf0e10cSrcweir 
212cdf0e10cSrcweir     	@return
213cdf0e10cSrcweir             Return <true/> if the view forwarder is valid and <false/> else.
214cdf0e10cSrcweir      */
215cdf0e10cSrcweir 	virtual sal_Bool IsValid (void) const;
216cdf0e10cSrcweir 
217cdf0e10cSrcweir     /** Returns the area of the underlying document that is visible in the
218cdf0e10cSrcweir     * corresponding window.
219cdf0e10cSrcweir 
220cdf0e10cSrcweir     	@return
221cdf0e10cSrcweir             The rectangle of the visible part of the document. The values
222cdf0e10cSrcweir             are, contrary to the base class, in internal coordinates.
223cdf0e10cSrcweir      */
224cdf0e10cSrcweir     virtual Rectangle GetVisibleArea() const;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     /** Transform the specified point from internal coordinates to an
227cdf0e10cSrcweir         absolute screen position.
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     	@param rPoint
230cdf0e10cSrcweir             Point in internal coordinates.
231cdf0e10cSrcweir 
232cdf0e10cSrcweir         @return
233cdf0e10cSrcweir             The same point but in screen coordinates relative to the upper
234cdf0e10cSrcweir             left corner of the (current) screen.
235cdf0e10cSrcweir      */
236cdf0e10cSrcweir     virtual Point LogicToPixel (const Point& rPoint) const;
237cdf0e10cSrcweir 
238cdf0e10cSrcweir     /** Transform the specified size from internal coordinates to a screen
239cdf0e10cSrcweir     * oriented pixel size.
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     	@param rSize
242cdf0e10cSrcweir             Size in internal coordinates.
243cdf0e10cSrcweir 
244cdf0e10cSrcweir         @return
245cdf0e10cSrcweir             The same size but in screen coordinates.
246cdf0e10cSrcweir      */
247cdf0e10cSrcweir     virtual Size LogicToPixel (const Size& rSize) const;
248cdf0e10cSrcweir 
249cdf0e10cSrcweir     /** Transform the specified point from absolute screen coordinates to
250cdf0e10cSrcweir         internal coordinates.
251cdf0e10cSrcweir 
252cdf0e10cSrcweir     	@param rPoint
253cdf0e10cSrcweir             Point in screen coordinates relative to the upper left corner of
254cdf0e10cSrcweir             the (current) screen.
255cdf0e10cSrcweir 
256cdf0e10cSrcweir         @return
257cdf0e10cSrcweir             The same point but in internal coordinates.
258cdf0e10cSrcweir      */
259cdf0e10cSrcweir     virtual Point PixelToLogic (const Point& rPoint) const;
260cdf0e10cSrcweir 
261cdf0e10cSrcweir     /** Transform the specified size from screen coordinates to internal
262cdf0e10cSrcweir         coordinates.
263cdf0e10cSrcweir 
264cdf0e10cSrcweir     	@param rSize
265cdf0e10cSrcweir             Size in screen coordinates.
266cdf0e10cSrcweir 
267cdf0e10cSrcweir         @return
268cdf0e10cSrcweir             The same size but in internal coordinates.
269cdf0e10cSrcweir      */
270cdf0e10cSrcweir     virtual Size PixelToLogic (const Size& rSize) const;
271cdf0e10cSrcweir 
272cdf0e10cSrcweir     ///======== internal =====================================================
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     utl::AccessibleRelationSetHelper* GetRelationSet(const ScAddress* pAddress) const;
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 	::com::sun::star::uno::Reference
277cdf0e10cSrcweir 		< ::com::sun::star::accessibility::XAccessible >
278cdf0e10cSrcweir 		GetAccessibleSpreadsheet();
279cdf0e10cSrcweir 
280cdf0e10cSrcweir protected:
281cdf0e10cSrcweir     ///	Return this object's description.
282cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL
283cdf0e10cSrcweir     	createAccessibleDescription(void)
284cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
285cdf0e10cSrcweir 
286cdf0e10cSrcweir     ///	Return the object's current name.
287cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL
288cdf0e10cSrcweir     	createAccessibleName(void)
289cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
290cdf0e10cSrcweir 
291cdf0e10cSrcweir     ///	Return the object's current bounding box relative to the desktop.
292cdf0e10cSrcweir 	virtual Rectangle GetBoundingBoxOnScreen(void) const
293cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	///	Return the object's current bounding box relative to the parent object.
296cdf0e10cSrcweir 	virtual Rectangle GetBoundingBox(void) const
297cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
298cdf0e10cSrcweir 
299cdf0e10cSrcweir private:
300cdf0e10cSrcweir 	ScTabViewShell*	mpViewShell;
301cdf0e10cSrcweir 	ScSplitPos		meSplitPos;
302cdf0e10cSrcweir 	ScAccessibleSpreadsheet* mpAccessibleSpreadsheet;
303cdf0e10cSrcweir     ScChildrenShapes* mpChildrenShapes;
304cdf0e10cSrcweir     ScAccessibleEditObject* mpTempAccEdit;
305cdf0e10cSrcweir     com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> mxTempAcc;
306cdf0e10cSrcweir     Rectangle maVisArea;
307cdf0e10cSrcweir 	sal_Bool mbCompleteSheetSelected;
308cdf0e10cSrcweir 
309cdf0e10cSrcweir public:
310cdf0e10cSrcweir     SCTAB getVisibleTable() const; // use it in ScChildrenShapes
311cdf0e10cSrcweir 
312cdf0e10cSrcweir private:
313cdf0e10cSrcweir 	void FreeAccessibleSpreadsheet();
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 	sal_Bool IsTableSelected() const;
316cdf0e10cSrcweir 
317cdf0e10cSrcweir     sal_Bool IsDefunc(
318cdf0e10cSrcweir 		const com::sun::star::uno::Reference<
319cdf0e10cSrcweir 		::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
320cdf0e10cSrcweir 	sal_Bool IsEditable(
321cdf0e10cSrcweir 		const com::sun::star::uno::Reference<
322cdf0e10cSrcweir 		::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
323cdf0e10cSrcweir 
324cdf0e10cSrcweir     void AddChild(const com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>& xAcc, sal_Bool bFireEvent);
325cdf0e10cSrcweir     void RemoveChild(const com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>& xAcc, sal_Bool bFireEvent);
326cdf0e10cSrcweir 
327cdf0e10cSrcweir     rtl::OUString GetCurrentCellName() const;
328cdf0e10cSrcweir     rtl::OUString GetCurrentCellDescription() const;
329cdf0e10cSrcweir 
330cdf0e10cSrcweir     Rectangle GetVisibleArea_Impl() const;
331*0deba7fbSSteve Yin     com::sun::star::uno::Sequence< com::sun::star::uno::Any > GetScAccFlowToSequence();
332*0deba7fbSSteve Yin public:
333*0deba7fbSSteve Yin 	ScDocument *GetDocument() const ;
334*0deba7fbSSteve Yin 	ScAddress   GetCurCellAddress() const;
335*0deba7fbSSteve Yin 	//=====  XAccessibleGetAccFromXShape  ============================================
336*0deba7fbSSteve Yin 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
337*0deba7fbSSteve Yin 		SAL_CALL get_AccFlowTo(const ::com::sun::star::uno::Any& rAny, sal_Int32 nType)
338*0deba7fbSSteve Yin 		throw ( ::com::sun::star::uno::RuntimeException );
339*0deba7fbSSteve Yin 
340*0deba7fbSSteve Yin 	 virtual sal_Int32 SAL_CALL getForeground(  )
341*0deba7fbSSteve Yin         throw (::com::sun::star::uno::RuntimeException);
342*0deba7fbSSteve Yin 
343*0deba7fbSSteve Yin     virtual sal_Int32 SAL_CALL getBackground(  )
344*0deba7fbSSteve Yin         throw (::com::sun::star::uno::RuntimeException);
345*0deba7fbSSteve Yin protected:
346*0deba7fbSSteve Yin 	void SwitchViewFireFocus();
347cdf0e10cSrcweir };
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 
350cdf0e10cSrcweir #endif
351