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