1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b3f79822SAndrew Rist  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19b3f79822SAndrew Rist  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "AccessibleTableBase.hxx"
29cdf0e10cSrcweir #include "miscuno.hxx"
30cdf0e10cSrcweir #include "document.hxx"
31cdf0e10cSrcweir #include "unoguard.hxx"
32cdf0e10cSrcweir #include "scresid.hxx"
33cdf0e10cSrcweir #ifndef SC_SC_HRC
34cdf0e10cSrcweir #include "sc.hrc"
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir 
37cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEROLE_HPP_
38cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
41cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
42cdf0e10cSrcweir #include <rtl/uuid.h>
43cdf0e10cSrcweir #include <tools/debug.hxx>
44cdf0e10cSrcweir #include <comphelper/sequence.hxx>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir using namespace	::com::sun::star;
48cdf0e10cSrcweir using namespace	::com::sun::star::accessibility;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir //=====  internal  ============================================================
51cdf0e10cSrcweir 
52cdf0e10cSrcweir ScAccessibleTableBase::ScAccessibleTableBase(
53cdf0e10cSrcweir         const uno::Reference<XAccessible>& rxParent,
54cdf0e10cSrcweir 		ScDocument* pDoc,
55cdf0e10cSrcweir 		const ScRange& rRange)
56cdf0e10cSrcweir 	:
57cdf0e10cSrcweir 	ScAccessibleContextBase (rxParent, AccessibleRole::TABLE),
58cdf0e10cSrcweir 	maRange(rRange),
59cdf0e10cSrcweir 	mpDoc(pDoc)
60cdf0e10cSrcweir {
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir ScAccessibleTableBase::~ScAccessibleTableBase()
64cdf0e10cSrcweir {
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir void SAL_CALL ScAccessibleTableBase::disposing()
68cdf0e10cSrcweir {
69cdf0e10cSrcweir     ScUnoGuard aGuard;
70cdf0e10cSrcweir 	mpDoc = NULL;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	ScAccessibleContextBase::disposing();
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	//=====  XInterface  =====================================================
76cdf0e10cSrcweir 
77cdf0e10cSrcweir uno::Any SAL_CALL ScAccessibleTableBase::queryInterface( uno::Type const & rType )
78cdf0e10cSrcweir 	throw (uno::RuntimeException)
79cdf0e10cSrcweir {
80*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
81*0deba7fbSSteve Yin 	//uno::Any aAny (ScAccessibleTableBaseImpl::queryInterface(rType));
82*0deba7fbSSteve Yin 	//return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
83*0deba7fbSSteve Yin 	uno::Any aRet;
84*0deba7fbSSteve Yin 	if ( rType == ::getCppuType((uno::Reference<XAccessibleTableSelection> *)0) )
85*0deba7fbSSteve Yin     {
86*0deba7fbSSteve Yin 		uno::Reference<XAccessibleTableSelection> xThis( this );
87*0deba7fbSSteve Yin        	aRet <<= xThis;
88*0deba7fbSSteve Yin 		return aRet;
89*0deba7fbSSteve Yin     }
90*0deba7fbSSteve Yin 	else
91*0deba7fbSSteve Yin 	{
92*0deba7fbSSteve Yin 		uno::Any aAny (ScAccessibleTableBaseImpl::queryInterface(rType));
93*0deba7fbSSteve Yin 		return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
94*0deba7fbSSteve Yin 	}
95*0deba7fbSSteve Yin 	return aRet;
96*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir void SAL_CALL ScAccessibleTableBase::acquire()
100cdf0e10cSrcweir 	throw ()
101cdf0e10cSrcweir {
102cdf0e10cSrcweir 	ScAccessibleContextBase::acquire();
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir void SAL_CALL ScAccessibleTableBase::release()
106cdf0e10cSrcweir 	throw ()
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	ScAccessibleContextBase::release();
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	//=====  XAccessibleTable  ================================================
112cdf0e10cSrcweir 
113cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRowCount(  )
114cdf0e10cSrcweir     				throw (uno::RuntimeException)
115cdf0e10cSrcweir {
116cdf0e10cSrcweir 	ScUnoGuard aGuard;
117cdf0e10cSrcweir     IsObjectValid();
118cdf0e10cSrcweir 	return maRange.aEnd.Row() - maRange.aStart.Row() + 1;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumnCount(  )
122cdf0e10cSrcweir     				throw (uno::RuntimeException)
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	ScUnoGuard aGuard;
125cdf0e10cSrcweir     IsObjectValid();
126cdf0e10cSrcweir 	return maRange.aEnd.Col() - maRange.aStart.Col() + 1;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleTableBase::getAccessibleRowDescription( sal_Int32 nRow )
130cdf0e10cSrcweir     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
131cdf0e10cSrcweir {
132cdf0e10cSrcweir 	DBG_ERROR("Here should be a implementation to fill the description");
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     if ((nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
135cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     //setAccessibleRowDescription(nRow, xAccessible); // to remember the created Description
138cdf0e10cSrcweir 	return rtl::OUString();
139cdf0e10cSrcweir }
140cdf0e10cSrcweir 
141cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleTableBase::getAccessibleColumnDescription( sal_Int32 nColumn )
142cdf0e10cSrcweir     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
143cdf0e10cSrcweir {
144cdf0e10cSrcweir 	DBG_ERROR("Here should be a implementation to fill the description");
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0))
147cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     //setAccessibleColumnDescription(nColumn, xAccessible); // to remember the created Description
150cdf0e10cSrcweir 	return rtl::OUString();
151cdf0e10cSrcweir }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
154cdf0e10cSrcweir     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
155cdf0e10cSrcweir {
156cdf0e10cSrcweir 	ScUnoGuard aGuard;
157cdf0e10cSrcweir     IsObjectValid();
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0) ||
160cdf0e10cSrcweir         (nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
161cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     sal_Int32 nCount(1); // the same cell
164cdf0e10cSrcweir 	nRow += maRange.aStart.Row();
165cdf0e10cSrcweir 	nColumn += maRange.aStart.Col();
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	if (mpDoc)
168cdf0e10cSrcweir 	{
169cdf0e10cSrcweir 		SCROW nEndRow(0);
170cdf0e10cSrcweir         SCCOL nEndCol(0);
171*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
172*0deba7fbSSteve Yin 		mpDoc->GetTableByIndex(maRange.aStart.Tab())->GetColumnByIndex(nColumn)->
173*0deba7fbSSteve Yin 			ExtendMerge( static_cast<SCCOL>(nColumn), static_cast<SCROW>(nRow), nRow, nEndCol, nEndRow, sal_False, sal_False );
174*0deba7fbSSteve Yin 		if (nEndRow > nRow)
175*0deba7fbSSteve Yin 			   nCount = nEndRow - nRow + 1;
176*0deba7fbSSteve Yin 	//	if (mpDoc->ExtendMerge(static_cast<SCCOL>(nColumn), static_cast<SCROW>(nRow),
177*0deba7fbSSteve Yin 	//		nEndCol, nEndRow, maRange.aStart.Tab()))
178*0deba7fbSSteve Yin         //{
179*0deba7fbSSteve Yin 	//	    if (nEndRow > nRow)
180*0deba7fbSSteve Yin 	//		    nCount = nEndRow - nRow + 1;
181*0deba7fbSSteve Yin         //}
182*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
183cdf0e10cSrcweir 	}
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	return nCount;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
189cdf0e10cSrcweir     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
190cdf0e10cSrcweir {
191cdf0e10cSrcweir 	ScUnoGuard aGuard;
192cdf0e10cSrcweir     IsObjectValid();
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0) ||
195cdf0e10cSrcweir         (nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
196cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     sal_Int32 nCount(1); // the same cell
199cdf0e10cSrcweir 	nRow += maRange.aStart.Row();
200cdf0e10cSrcweir 	nColumn += maRange.aStart.Col();
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 	if (mpDoc)
203cdf0e10cSrcweir 	{
204cdf0e10cSrcweir 		SCROW nEndRow(0);
205cdf0e10cSrcweir         SCCOL nEndCol(0);
206*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
207*0deba7fbSSteve Yin 		mpDoc->GetTableByIndex(maRange.aStart.Tab())->GetColumnByIndex(nColumn)->
208*0deba7fbSSteve Yin 			ExtendMerge( static_cast<SCCOL>(nColumn), static_cast<SCROW>(nRow), nRow, nEndCol, nEndRow, sal_False, sal_False );
209*0deba7fbSSteve Yin 		if (nEndCol > nColumn)
210cdf0e10cSrcweir 			    nCount = nEndCol - nColumn + 1;
211*0deba7fbSSteve Yin 	//	if (mpDoc->ExtendMerge(static_cast<SCCOL>(nColumn), static_cast<SCROW>(nRow),
212*0deba7fbSSteve Yin 	//		nEndCol, nEndRow, maRange.aStart.Tab()))
213*0deba7fbSSteve Yin         //{
214*0deba7fbSSteve Yin 	//	    if (nEndCol > nColumn)
215*0deba7fbSSteve Yin 	//		    nCount = nEndCol - nColumn + 1;
216*0deba7fbSSteve Yin         //}
217*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
218cdf0e10cSrcweir 	}
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 	return nCount;
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleTableBase::getAccessibleRowHeaders(  )
224cdf0e10cSrcweir     				throw (uno::RuntimeException)
225cdf0e10cSrcweir {
226cdf0e10cSrcweir 	uno::Reference< XAccessibleTable > xAccessibleTable;
227cdf0e10cSrcweir 	DBG_ERROR("Here should be a implementation to fill the row headers");
228cdf0e10cSrcweir 
229cdf0e10cSrcweir     //CommitChange
230cdf0e10cSrcweir 	return xAccessibleTable;
231cdf0e10cSrcweir }
232cdf0e10cSrcweir 
233cdf0e10cSrcweir uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleTableBase::getAccessibleColumnHeaders(  )
234cdf0e10cSrcweir     				throw (uno::RuntimeException)
235cdf0e10cSrcweir {
236cdf0e10cSrcweir 	uno::Reference< XAccessibleTable > xAccessibleTable;
237cdf0e10cSrcweir 	DBG_ERROR("Here should be a implementation to fill the column headers");
238cdf0e10cSrcweir 
239cdf0e10cSrcweir     //CommitChange
240cdf0e10cSrcweir 	return xAccessibleTable;
241cdf0e10cSrcweir }
242cdf0e10cSrcweir 
243cdf0e10cSrcweir uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleTableBase::getSelectedAccessibleRows(  )
244cdf0e10cSrcweir     				throw (uno::RuntimeException)
245cdf0e10cSrcweir {
246cdf0e10cSrcweir 	DBG_ERROR("not implemented yet");
247cdf0e10cSrcweir 	uno::Sequence< sal_Int32 > aSequence;
248cdf0e10cSrcweir 	return aSequence;
249cdf0e10cSrcweir }
250cdf0e10cSrcweir 
251cdf0e10cSrcweir uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleTableBase::getSelectedAccessibleColumns(  )
252cdf0e10cSrcweir     				throw (uno::RuntimeException)
253cdf0e10cSrcweir {
254cdf0e10cSrcweir 	DBG_ERROR("not implemented yet");
255cdf0e10cSrcweir 	uno::Sequence< sal_Int32 > aSequence;
256cdf0e10cSrcweir 	return aSequence;
257cdf0e10cSrcweir }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleTableBase::isAccessibleRowSelected( sal_Int32 /* nRow */ )
260cdf0e10cSrcweir     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
261cdf0e10cSrcweir {
262cdf0e10cSrcweir 	DBG_ERROR("not implemented yet");
263cdf0e10cSrcweir 	return sal_False;
264cdf0e10cSrcweir }
265cdf0e10cSrcweir 
266cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleTableBase::isAccessibleColumnSelected( sal_Int32 /* nColumn */ )
267cdf0e10cSrcweir     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
268cdf0e10cSrcweir {
269cdf0e10cSrcweir 	DBG_ERROR("not implemented yet");
270cdf0e10cSrcweir 	return sal_False;
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
273cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleTableBase::getAccessibleCellAt( sal_Int32 /* nRow */, sal_Int32 /* nColumn */ )
274cdf0e10cSrcweir     				throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
275cdf0e10cSrcweir {
276cdf0e10cSrcweir 	DBG_ERROR("not implemented yet");
277cdf0e10cSrcweir 	uno::Reference< XAccessible > xAccessible;
278cdf0e10cSrcweir 	return xAccessible;
279cdf0e10cSrcweir }
280cdf0e10cSrcweir 
281cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleTableBase::getAccessibleCaption(  )
282cdf0e10cSrcweir     				throw (uno::RuntimeException)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir 	DBG_ERROR("not implemented yet");
285cdf0e10cSrcweir 	uno::Reference< XAccessible > xAccessible;
286cdf0e10cSrcweir 	return xAccessible;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL ScAccessibleTableBase::getAccessibleSummary(  )
290cdf0e10cSrcweir     				throw (uno::RuntimeException)
291cdf0e10cSrcweir {
292cdf0e10cSrcweir 	DBG_ERROR("not implemented yet");
293cdf0e10cSrcweir 	uno::Reference< XAccessible > xAccessible;
294cdf0e10cSrcweir 	return xAccessible;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir 
297cdf0e10cSrcweir sal_Bool SAL_CALL ScAccessibleTableBase::isAccessibleSelected( sal_Int32 /* nRow */, sal_Int32 /* nColumn */ )
298cdf0e10cSrcweir     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
299cdf0e10cSrcweir {
300cdf0e10cSrcweir 	DBG_ERROR("not implemented yet");
301cdf0e10cSrcweir 	return sal_False;
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 	//=====  XAccessibleExtendedTable  ========================================
305cdf0e10cSrcweir 
306cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
307cdf0e10cSrcweir     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
308cdf0e10cSrcweir {
309cdf0e10cSrcweir 	ScUnoGuard aGuard;
310cdf0e10cSrcweir     IsObjectValid();
311cdf0e10cSrcweir 
312cdf0e10cSrcweir     if (nRow > (maRange.aEnd.Row() - maRange.aStart.Row()) ||
313cdf0e10cSrcweir         nRow < 0 ||
314cdf0e10cSrcweir         nColumn > (maRange.aEnd.Col() - maRange.aStart.Col()) ||
315cdf0e10cSrcweir         nColumn < 0)
316cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     nRow -= maRange.aStart.Row();
319cdf0e10cSrcweir 	nColumn -= maRange.aStart.Col();
320cdf0e10cSrcweir 	return (nRow * (maRange.aEnd.Col() + 1)) + nColumn;
321cdf0e10cSrcweir }
322cdf0e10cSrcweir 
323cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRow( sal_Int32 nChildIndex )
324cdf0e10cSrcweir     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
325cdf0e10cSrcweir {
326cdf0e10cSrcweir 	ScUnoGuard aGuard;
327cdf0e10cSrcweir     IsObjectValid();
328cdf0e10cSrcweir 
329cdf0e10cSrcweir     if (nChildIndex >= getAccessibleChildCount() || nChildIndex < 0)
330cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     return nChildIndex / (maRange.aEnd.Col() - maRange.aStart.Col() + 1);
333cdf0e10cSrcweir }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumn( sal_Int32 nChildIndex )
336cdf0e10cSrcweir     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
337cdf0e10cSrcweir {
338cdf0e10cSrcweir 	ScUnoGuard aGuard;
339cdf0e10cSrcweir     IsObjectValid();
340cdf0e10cSrcweir 
341cdf0e10cSrcweir     if (nChildIndex >= getAccessibleChildCount() || nChildIndex < 0)
342cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
343cdf0e10cSrcweir 
344cdf0e10cSrcweir     return nChildIndex % static_cast<sal_Int32>(maRange.aEnd.Col() - maRange.aStart.Col() + 1);
345cdf0e10cSrcweir }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 	//=====  XAccessibleContext  ==============================================
348cdf0e10cSrcweir 
349cdf0e10cSrcweir sal_Int32 SAL_CALL
350cdf0e10cSrcweir 	ScAccessibleTableBase::getAccessibleChildCount(void)
351cdf0e10cSrcweir     				throw (uno::RuntimeException)
352cdf0e10cSrcweir {
353cdf0e10cSrcweir 	ScUnoGuard aGuard;
354cdf0e10cSrcweir     IsObjectValid();
355cdf0e10cSrcweir 	return static_cast<sal_Int32>(maRange.aEnd.Row() - maRange.aStart.Row() + 1) *
356cdf0e10cSrcweir 			(maRange.aEnd.Col() - maRange.aStart.Col() + 1);
357cdf0e10cSrcweir //	return 1;
358cdf0e10cSrcweir }
359cdf0e10cSrcweir 
360cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL
361cdf0e10cSrcweir 	ScAccessibleTableBase::getAccessibleChild(sal_Int32 nIndex)
362cdf0e10cSrcweir         throw (uno::RuntimeException,
363cdf0e10cSrcweir 		lang::IndexOutOfBoundsException)
364cdf0e10cSrcweir {
365cdf0e10cSrcweir 	ScUnoGuard aGuard;
366cdf0e10cSrcweir     IsObjectValid();
367cdf0e10cSrcweir 
368cdf0e10cSrcweir     if (nIndex >= getAccessibleChildCount() || nIndex < 0)
369cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 	sal_Int32 nRow(0);
372cdf0e10cSrcweir 	sal_Int32 nColumn(0);
373cdf0e10cSrcweir 	sal_Int32 nTemp(maRange.aEnd.Col() - maRange.aStart.Col() + 1);
374cdf0e10cSrcweir 	nRow = nIndex / nTemp;
375cdf0e10cSrcweir 	nColumn = nIndex % nTemp;
376cdf0e10cSrcweir 	return getAccessibleCellAt(nRow, nColumn);
377cdf0e10cSrcweir }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir ::rtl::OUString SAL_CALL
380cdf0e10cSrcweir     ScAccessibleTableBase::createAccessibleDescription(void)
381cdf0e10cSrcweir     throw (uno::RuntimeException)
382cdf0e10cSrcweir {
383cdf0e10cSrcweir     String sDesc(ScResId(STR_ACC_TABLE_DESCR));
384cdf0e10cSrcweir /*	String sCoreName;
385cdf0e10cSrcweir 	if (mpDoc && mpDoc->GetName( maRange.aStart.Tab(), sCoreName ))
386cdf0e10cSrcweir 		sDesc.SearchAndReplaceAscii("%1", sCoreName);
387cdf0e10cSrcweir     sDesc.SearchAndReplaceAscii("%2", String(ScResId(SCSTR_UNKNOWN)));*/
388cdf0e10cSrcweir     return rtl::OUString(sDesc);
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
391cdf0e10cSrcweir ::rtl::OUString SAL_CALL
392cdf0e10cSrcweir     ScAccessibleTableBase::createAccessibleName(void)
393cdf0e10cSrcweir     throw (uno::RuntimeException)
394cdf0e10cSrcweir {
395cdf0e10cSrcweir     String sName(ScResId(STR_ACC_TABLE_NAME));
396cdf0e10cSrcweir 	String sCoreName;
397cdf0e10cSrcweir 	if (mpDoc && mpDoc->GetName( maRange.aStart.Tab(), sCoreName ))
398cdf0e10cSrcweir 		sName.SearchAndReplaceAscii("%1", sCoreName);
399cdf0e10cSrcweir     return rtl::OUString(sName);
400cdf0e10cSrcweir }
401cdf0e10cSrcweir 
402cdf0e10cSrcweir uno::Reference<XAccessibleRelationSet> SAL_CALL
403cdf0e10cSrcweir     ScAccessibleTableBase::getAccessibleRelationSet(void)
404cdf0e10cSrcweir     throw (uno::RuntimeException)
405cdf0e10cSrcweir {
406cdf0e10cSrcweir 	DBG_ERROR("should be implemented in the abrevated class");
407cdf0e10cSrcweir 	return uno::Reference<XAccessibleRelationSet>();
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL
411cdf0e10cSrcweir 	ScAccessibleTableBase::getAccessibleStateSet(void)
412cdf0e10cSrcweir     throw (uno::RuntimeException)
413cdf0e10cSrcweir {
414cdf0e10cSrcweir 	DBG_ERROR("should be implemented in the abrevated class");
415cdf0e10cSrcweir 	uno::Reference< XAccessibleStateSet > xAccessibleStateSet;
416cdf0e10cSrcweir 	return xAccessibleStateSet;
417cdf0e10cSrcweir }
418cdf0e10cSrcweir 
419cdf0e10cSrcweir 	///=====  XAccessibleSelection  ===========================================
420cdf0e10cSrcweir 
421cdf0e10cSrcweir void SAL_CALL
422cdf0e10cSrcweir         ScAccessibleTableBase::selectAccessibleChild( sal_Int32 /* nChildIndex */ )
423cdf0e10cSrcweir 		throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
424cdf0e10cSrcweir {
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
427cdf0e10cSrcweir sal_Bool SAL_CALL
428cdf0e10cSrcweir 		ScAccessibleTableBase::isAccessibleChildSelected( sal_Int32 nChildIndex )
429cdf0e10cSrcweir 		throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
430cdf0e10cSrcweir {
431cdf0e10cSrcweir     // I don't need to guard, because the called funtions have a guard
432cdf0e10cSrcweir //    ScUnoGuard aGuard;
433cdf0e10cSrcweir     if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
434cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
435cdf0e10cSrcweir 	return isAccessibleSelected(getAccessibleRow(nChildIndex), getAccessibleColumn(nChildIndex));
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir void SAL_CALL
439cdf0e10cSrcweir 		ScAccessibleTableBase::clearAccessibleSelection(  )
440cdf0e10cSrcweir 		throw (uno::RuntimeException)
441cdf0e10cSrcweir {
442cdf0e10cSrcweir }
443cdf0e10cSrcweir 
444cdf0e10cSrcweir void SAL_CALL
445cdf0e10cSrcweir 		ScAccessibleTableBase::selectAllAccessibleChildren(  )
446cdf0e10cSrcweir 		throw (uno::RuntimeException)
447cdf0e10cSrcweir {
448cdf0e10cSrcweir }
449cdf0e10cSrcweir 
450cdf0e10cSrcweir sal_Int32 SAL_CALL
451cdf0e10cSrcweir 		ScAccessibleTableBase::getSelectedAccessibleChildCount(  )
452cdf0e10cSrcweir 		throw (uno::RuntimeException)
453cdf0e10cSrcweir {
454cdf0e10cSrcweir 	sal_Int32 nResult(0);
455cdf0e10cSrcweir 	return nResult;
456cdf0e10cSrcweir }
457cdf0e10cSrcweir 
458cdf0e10cSrcweir uno::Reference<XAccessible > SAL_CALL
459cdf0e10cSrcweir         ScAccessibleTableBase::getSelectedAccessibleChild( sal_Int32 /* nSelectedChildIndex */ )
460cdf0e10cSrcweir 		throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
461cdf0e10cSrcweir {
462cdf0e10cSrcweir 	uno::Reference < XAccessible > xAccessible;
463cdf0e10cSrcweir 	return xAccessible;
464cdf0e10cSrcweir }
465cdf0e10cSrcweir 
466cdf0e10cSrcweir void SAL_CALL
467cdf0e10cSrcweir         ScAccessibleTableBase::deselectAccessibleChild( sal_Int32 /* nSelectedChildIndex */ )
468cdf0e10cSrcweir 		throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
469cdf0e10cSrcweir {
470cdf0e10cSrcweir }
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 	//=====  XServiceInfo  ====================================================
473cdf0e10cSrcweir 
474cdf0e10cSrcweir ::rtl::OUString SAL_CALL ScAccessibleTableBase::getImplementationName(void)
475cdf0e10cSrcweir         throw (uno::RuntimeException)
476cdf0e10cSrcweir {
477cdf0e10cSrcweir 	return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleTableBase"));
478cdf0e10cSrcweir }
479cdf0e10cSrcweir 
480cdf0e10cSrcweir 	//=====  XTypeProvider  ===================================================
481cdf0e10cSrcweir 
482cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL ScAccessibleTableBase::getTypes()
483cdf0e10cSrcweir 		throw (uno::RuntimeException)
484cdf0e10cSrcweir {
485cdf0e10cSrcweir 	return comphelper::concatSequences(ScAccessibleTableBaseImpl::getTypes(), ScAccessibleContextBase::getTypes());
486cdf0e10cSrcweir }
487cdf0e10cSrcweir 
488cdf0e10cSrcweir uno::Sequence<sal_Int8> SAL_CALL
489cdf0e10cSrcweir 	ScAccessibleTableBase::getImplementationId(void)
490cdf0e10cSrcweir     throw (uno::RuntimeException)
491cdf0e10cSrcweir {
492cdf0e10cSrcweir     ScUnoGuard aGuard;
493cdf0e10cSrcweir     IsObjectValid();
494cdf0e10cSrcweir 	static uno::Sequence<sal_Int8> aId;
495cdf0e10cSrcweir 	if (aId.getLength() == 0)
496cdf0e10cSrcweir 	{
497cdf0e10cSrcweir 		aId.realloc (16);
498cdf0e10cSrcweir 		rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
499cdf0e10cSrcweir 	}
500cdf0e10cSrcweir 	return aId;
501cdf0e10cSrcweir }
502cdf0e10cSrcweir 
503cdf0e10cSrcweir void ScAccessibleTableBase::CommitTableModelChange(sal_Int32 nStartRow, sal_Int32 nStartCol, sal_Int32 nEndRow, sal_Int32 nEndCol, sal_uInt16 nId)
504cdf0e10cSrcweir {
505cdf0e10cSrcweir 	AccessibleTableModelChange aModelChange;
506cdf0e10cSrcweir 	aModelChange.FirstRow = nStartRow;
507cdf0e10cSrcweir 	aModelChange.FirstColumn = nStartCol;
508cdf0e10cSrcweir 	aModelChange.LastRow = nEndRow;
509cdf0e10cSrcweir 	aModelChange.LastColumn = nEndCol;
510cdf0e10cSrcweir 	aModelChange.Type = nId;
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 	AccessibleEventObject aEvent;
513cdf0e10cSrcweir 	aEvent.EventId = AccessibleEventId::TABLE_MODEL_CHANGED;
514cdf0e10cSrcweir 	aEvent.Source = uno::Reference< XAccessibleContext >(this);
515cdf0e10cSrcweir 	aEvent.NewValue <<= aModelChange;
516cdf0e10cSrcweir 
517cdf0e10cSrcweir 	CommitChange(aEvent);
518cdf0e10cSrcweir }
519*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009-----
520*0deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleTableBase::selectRow( sal_Int32 )
521*0deba7fbSSteve Yin throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
522*0deba7fbSSteve Yin {
523*0deba7fbSSteve Yin 	return sal_True;
524*0deba7fbSSteve Yin }
525*0deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleTableBase::selectColumn( sal_Int32 )
526*0deba7fbSSteve Yin 		throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
527*0deba7fbSSteve Yin {
528*0deba7fbSSteve Yin 	return sal_True;
529*0deba7fbSSteve Yin }
530*0deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleTableBase::unselectRow( sal_Int32 )
531*0deba7fbSSteve Yin 		throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
532*0deba7fbSSteve Yin {
533*0deba7fbSSteve Yin 		return sal_True;
534*0deba7fbSSteve Yin }
535*0deba7fbSSteve Yin sal_Bool SAL_CALL ScAccessibleTableBase::unselectColumn( sal_Int32 )
536*0deba7fbSSteve Yin 		throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
537*0deba7fbSSteve Yin {
538*0deba7fbSSteve Yin 	return sal_True;
539*0deba7fbSSteve Yin }
540*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009
541*0deba7fbSSteve Yin 
542*0deba7fbSSteve Yin 
543