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