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_ACCESSIBLESPREADSHEET_HXX
30*cdf0e10cSrcweir #define _SC_ACCESSIBLESPREADSHEET_HXX
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include "AccessibleTableBase.hxx"
33*cdf0e10cSrcweir #include "viewdata.hxx"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <vector>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir class ScMyAddress : public ScAddress
38*cdf0e10cSrcweir {
39*cdf0e10cSrcweir public:
40*cdf0e10cSrcweir 	ScMyAddress() : ScAddress() {}
41*cdf0e10cSrcweir     ScMyAddress(SCCOL nColP, SCROW nRowP, SCTAB nTabP) : ScAddress(nColP, nRowP, nTabP) {}
42*cdf0e10cSrcweir 	ScMyAddress(const ScAddress& rAddress) : ScAddress(rAddress) {}
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 	sal_Bool operator< ( const ScMyAddress& rAddress ) const
45*cdf0e10cSrcweir     {
46*cdf0e10cSrcweir 		if( Row() != rAddress.Row() )
47*cdf0e10cSrcweir 			return (Row() < rAddress.Row());
48*cdf0e10cSrcweir 		else
49*cdf0e10cSrcweir 			return (Col() < rAddress.Col());
50*cdf0e10cSrcweir     }
51*cdf0e10cSrcweir };
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir class ScTabViewShell;
54*cdf0e10cSrcweir class ScAccessibleDocument;
55*cdf0e10cSrcweir class ScAccessibleCell;
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir /**	@descr
58*cdf0e10cSrcweir         This base class provides an implementation of the
59*cdf0e10cSrcweir         <code>AccessibleTable</code> service.
60*cdf0e10cSrcweir */
61*cdf0e10cSrcweir class ScAccessibleSpreadsheet
62*cdf0e10cSrcweir 	:	public	ScAccessibleTableBase
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir public:
65*cdf0e10cSrcweir 	//=====  internal  ========================================================
66*cdf0e10cSrcweir 	ScAccessibleSpreadsheet(
67*cdf0e10cSrcweir         ScAccessibleDocument* pAccDoc,
68*cdf0e10cSrcweir 		ScTabViewShell* pViewShell,
69*cdf0e10cSrcweir 		SCTAB	nTab,
70*cdf0e10cSrcweir 		ScSplitPos eSplitPos);
71*cdf0e10cSrcweir protected:
72*cdf0e10cSrcweir     ScAccessibleSpreadsheet(
73*cdf0e10cSrcweir         ScAccessibleSpreadsheet& rParent,
74*cdf0e10cSrcweir         const ScRange& rRange );
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	virtual ~ScAccessibleSpreadsheet();
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir     void ConstructScAccessibleSpreadsheet(
79*cdf0e10cSrcweir         ScAccessibleDocument* pAccDoc,
80*cdf0e10cSrcweir         ScTabViewShell* pViewShell,
81*cdf0e10cSrcweir         SCTAB nTab,
82*cdf0e10cSrcweir         ScSplitPos eSplitPos);
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir     using ScAccessibleTableBase::IsDefunc;
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir public:
87*cdf0e10cSrcweir     using ScAccessibleTableBase::addEventListener;
88*cdf0e10cSrcweir     using ScAccessibleTableBase::disposing;
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir  	virtual void SAL_CALL disposing();
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir 	void CompleteSelectionChanged(sal_Bool bNewState);
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     virtual void LostFocus();
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     virtual void GotFocus();
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir     void BoundingBoxChanged();
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir     void VisAreaChanged();
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir 	///=====  SfxListener  =====================================================
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 	virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir 	///=====  XAccessibleTable  ================================================
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir     /// Returns the row headers as an AccessibleTable.
109*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
110*cdf0e10cSrcweir                 getAccessibleRowHeaders(  )
111*cdf0e10cSrcweir                     throw (::com::sun::star::uno::RuntimeException);
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir     /// Returns the column headers as an AccessibleTable.
114*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
115*cdf0e10cSrcweir                 getAccessibleColumnHeaders(  )
116*cdf0e10cSrcweir                     throw (::com::sun::star::uno::RuntimeException);
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     /// Returns the selected rows in a table.
119*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
120*cdf0e10cSrcweir     			getSelectedAccessibleRows(  )
121*cdf0e10cSrcweir     				throw (::com::sun::star::uno::RuntimeException);
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir     /// Returns the selected columns in a table.
124*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
125*cdf0e10cSrcweir     			getSelectedAccessibleColumns(  )
126*cdf0e10cSrcweir     				throw (::com::sun::star::uno::RuntimeException);
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     /// Returns a boolean value indicating whether the specified row is selected.
129*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
130*cdf0e10cSrcweir     			isAccessibleRowSelected( sal_Int32 nRow )
131*cdf0e10cSrcweir     				throw (::com::sun::star::uno::RuntimeException,
132*cdf0e10cSrcweir 				    ::com::sun::star::lang::IndexOutOfBoundsException);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     /// Returns a boolean value indicating whether the specified column is selected.
135*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
136*cdf0e10cSrcweir     			isAccessibleColumnSelected( sal_Int32 nColumn )
137*cdf0e10cSrcweir     				throw (::com::sun::star::uno::RuntimeException,
138*cdf0e10cSrcweir 				    ::com::sun::star::lang::IndexOutOfBoundsException);
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 	/// Returns the Accessible at a specified row and column in the table.
141*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
142*cdf0e10cSrcweir     			getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
143*cdf0e10cSrcweir     				throw (::com::sun::star::uno::RuntimeException,
144*cdf0e10cSrcweir     				        ::com::sun::star::lang::IndexOutOfBoundsException);
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir     ScAccessibleCell* GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn);
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 	/// Returns a boolean value indicating whether the accessible at a specified row and column is selected.
149*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL
150*cdf0e10cSrcweir     			isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
151*cdf0e10cSrcweir     				throw (::com::sun::star::uno::RuntimeException,
152*cdf0e10cSrcweir 				    ::com::sun::star::lang::IndexOutOfBoundsException);
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	///=====  XAccessibleComponent  ============================================
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
157*cdf0e10cSrcweir 		SAL_CALL getAccessibleAtPoint(
158*cdf0e10cSrcweir 		const ::com::sun::star::awt::Point& rPoint )
159*cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     virtual void SAL_CALL grabFocus(  )
162*cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getForeground(  )
165*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getBackground(  )
168*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     ///=====  XAccessibleContext  ==============================================
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 	///	Return NULL to indicate that an empty relation set.
173*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference<
174*cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
175*cdf0e10cSrcweir     	getAccessibleRelationSet(void)
176*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir     ///	Return the set of current states.
179*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference<
180*cdf0e10cSrcweir             ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
181*cdf0e10cSrcweir     	getAccessibleStateSet(void)
182*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 	///=====  XAccessibleSelection  ===========================================
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     virtual void SAL_CALL
187*cdf0e10cSrcweir 		selectAccessibleChild( sal_Int32 nChildIndex )
188*cdf0e10cSrcweir 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
189*cdf0e10cSrcweir 		::com::sun::star::uno::RuntimeException);
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir     virtual void SAL_CALL
192*cdf0e10cSrcweir 		clearAccessibleSelection(  )
193*cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir     virtual void SAL_CALL
196*cdf0e10cSrcweir 		selectAllAccessibleChildren(  )
197*cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL
200*cdf0e10cSrcweir 		getSelectedAccessibleChildCount(  )
201*cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference<
204*cdf0e10cSrcweir 		::com::sun::star::accessibility::XAccessible > SAL_CALL
205*cdf0e10cSrcweir 		getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
206*cdf0e10cSrcweir 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
207*cdf0e10cSrcweir 		::com::sun::star::uno::RuntimeException);
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir     virtual void SAL_CALL
210*cdf0e10cSrcweir 		deselectAccessibleChild( sal_Int32 nChildIndex )
211*cdf0e10cSrcweir 		throw (::com::sun::star::lang::IndexOutOfBoundsException,
212*cdf0e10cSrcweir 		::com::sun::star::uno::RuntimeException);
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir 	///=====  XServiceInfo  ====================================================
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir     /**	Returns an identifier for the implementation of this object.
217*cdf0e10cSrcweir     */
218*cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL
219*cdf0e10cSrcweir     	getImplementationName(void)
220*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir     /** Returns a list of all supported services.
223*cdf0e10cSrcweir     */
224*cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
225*cdf0e10cSrcweir     	getSupportedServiceNames(void)
226*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	///=====  XTypeProvider  ===================================================
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     /**	Returns a implementation id.
231*cdf0e10cSrcweir     */
232*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
233*cdf0e10cSrcweir         getImplementationId(void)
234*cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 	///=====  XAccessibleEventBroadcaster  =====================================
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir     /**	Add listener that is informed of future changes of name,
239*cdf0e10cSrcweir       	description and so on events.
240*cdf0e10cSrcweir     */
241*cdf0e10cSrcweir 	virtual void SAL_CALL
242*cdf0e10cSrcweir     	addEventListener(
243*cdf0e10cSrcweir         	const ::com::sun::star::uno::Reference<
244*cdf0e10cSrcweir                 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
245*cdf0e10cSrcweir         throw (com::sun::star::uno::RuntimeException);
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir protected:
248*cdf0e10cSrcweir     ///	Return the object's current bounding box relative to the desktop.
249*cdf0e10cSrcweir 	virtual Rectangle GetBoundingBoxOnScreen(void) const
250*cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 	///	Return the object's current bounding box relative to the parent object.
253*cdf0e10cSrcweir 	virtual Rectangle GetBoundingBox(void) const
254*cdf0e10cSrcweir 		throw (::com::sun::star::uno::RuntimeException);
255*cdf0e10cSrcweir private:
256*cdf0e10cSrcweir 	ScTabViewShell* mpViewShell;
257*cdf0e10cSrcweir 	ScRangeList*	mpMarkedRanges;
258*cdf0e10cSrcweir 	std::vector<ScMyAddress>* mpSortedMarkedCells;
259*cdf0e10cSrcweir     ScAccessibleDocument* mpAccDoc;
260*cdf0e10cSrcweir     ScAccessibleCell*   mpAccCell;
261*cdf0e10cSrcweir 	Rectangle		maVisCells;
262*cdf0e10cSrcweir 	ScSplitPos 		meSplitPos;
263*cdf0e10cSrcweir 	ScAddress		maActiveCell;
264*cdf0e10cSrcweir     SCTAB           mnTab;
265*cdf0e10cSrcweir     sal_Bool        mbIsSpreadsheet;
266*cdf0e10cSrcweir 	sal_Bool		mbHasSelection;
267*cdf0e10cSrcweir 	sal_Bool		mbDelIns;
268*cdf0e10cSrcweir     sal_Bool        mbIsFocusSend;
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir 	sal_Bool IsDefunc(
271*cdf0e10cSrcweir 		const com::sun::star::uno::Reference<
272*cdf0e10cSrcweir 		::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
273*cdf0e10cSrcweir 	sal_Bool IsEditable(
274*cdf0e10cSrcweir 		const com::sun::star::uno::Reference<
275*cdf0e10cSrcweir 		::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
276*cdf0e10cSrcweir     sal_Bool IsFocused();
277*cdf0e10cSrcweir 	sal_Bool IsCompleteSheetSelected();
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir 	void SelectCell(sal_Int32 nRow, sal_Int32 nCol, sal_Bool bDeselect);
280*cdf0e10cSrcweir 	void CreateSortedMarkedCells();
281*cdf0e10cSrcweir 	void AddMarkedRange(const ScRange& rRange);
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir 	ScDocument* GetDocument(ScTabViewShell* pViewShell);
284*cdf0e10cSrcweir 	Rectangle	GetVisArea(ScTabViewShell* pViewShell, ScSplitPos eSplitPos);
285*cdf0e10cSrcweir 	Rectangle	GetVisCells(const Rectangle& rVisArea);
286*cdf0e10cSrcweir };
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir #endif
290