xref: /aoo42x/main/sw/source/core/access/acctable.cxx (revision 4d7c9de0)
1efeef26fSAndrew Rist /**************************************************************
2efeef26fSAndrew Rist  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include <vos/mutex.hxx>
27cdf0e10cSrcweir #include <rtl/uuid.h>
28cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <list>
31cdf0e10cSrcweir #include <set>
32cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
33cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
34cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
35cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
36cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
37cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
38cdf0e10cSrcweir #include <vcl/svapp.hxx>
39cdf0e10cSrcweir #include <frmfmt.hxx>
40cdf0e10cSrcweir #include <tabfrm.hxx>
41cdf0e10cSrcweir #include <rowfrm.hxx>
42cdf0e10cSrcweir #include <cellfrm.hxx>
43cdf0e10cSrcweir #include <swtable.hxx>
44cdf0e10cSrcweir #include <crsrsh.hxx>
45cdf0e10cSrcweir #include <viscrs.hxx>
46cdf0e10cSrcweir #include <hints.hxx>
47cdf0e10cSrcweir #include <fesh.hxx>
48cdf0e10cSrcweir #include <accfrmobjslist.hxx>
49cdf0e10cSrcweir #include <accmap.hxx>
50cdf0e10cSrcweir #include <access.hrc>
51cdf0e10cSrcweir #include <acctable.hxx>
52ca62e2c2SSteve Yin #include <rowfrm.hxx>
53ca62e2c2SSteve Yin #include <layfrm.hxx>
54cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleText.hpp>
55cdf0e10cSrcweir 
56ca62e2c2SSteve Yin #include <editeng/brshitem.hxx>
57ca62e2c2SSteve Yin #include <swatrset.hxx>
58ca62e2c2SSteve Yin #include <frmatr.hxx>
59ca62e2c2SSteve Yin 
60cdf0e10cSrcweir using namespace ::com::sun::star;
61cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
62cdf0e10cSrcweir using ::rtl::OUString;
63cdf0e10cSrcweir using ::rtl::OUStringBuffer;
64cdf0e10cSrcweir using namespace ::sw::access;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir const sal_Char sServiceName[] = "com.sun.star.table.AccessibleTableView";
67cdf0e10cSrcweir const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleTableView";
68cdf0e10cSrcweir 
69cdf0e10cSrcweir typedef ::std::less < sal_Int32 > Int32Less_Impl;
70cdf0e10cSrcweir typedef ::std::set < sal_Int32, Int32Less_Impl > Int32Set_Impl;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir typedef ::std::pair < sal_Int32, sal_Int32 > Int32Pair_Impl;
73cdf0e10cSrcweir typedef ::std::list < Int32Pair_Impl > Int32PairList_Impl;
74cdf0e10cSrcweir 
75*39f158abSPavel Janík const unsigned int SELECTION_WITH_NUM = 10;
76ca62e2c2SSteve Yin 
77cdf0e10cSrcweir class SwAccTableSelHander_Impl
78cdf0e10cSrcweir {
79cdf0e10cSrcweir public:
80cdf0e10cSrcweir 	virtual void Unselect( sal_Int32 nRowOrCol, sal_Int32 nExt ) = 0;
81cdf0e10cSrcweir };
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 
84cdf0e10cSrcweir //------------------------------------------------------------------------------
85cdf0e10cSrcweir 
86cdf0e10cSrcweir class SwAccessibleTableData_Impl
87cdf0e10cSrcweir {
88cdf0e10cSrcweir     SwAccessibleMap& mrAccMap;
89cdf0e10cSrcweir 	Int32Set_Impl	maRows;
90cdf0e10cSrcweir 	Int32Set_Impl	maColumns;
91cdf0e10cSrcweir 	Int32PairList_Impl maExtents;	// cell extends for event processing only
92cdf0e10cSrcweir 	Point 	maTabFrmPos;
93cdf0e10cSrcweir 	const SwTabFrm *mpTabFrm;
94cdf0e10cSrcweir     sal_Bool mbIsInPagePreview;
95cdf0e10cSrcweir     bool mbOnlyTableColumnHeader;
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 	void CollectData( const SwFrm *pFrm );
98ca62e2c2SSteve Yin 	void CollectColumnHeaderData( const SwFrm *pFrm );
99ca62e2c2SSteve Yin 	void CollectRowHeaderData( const SwFrm *pFrm );
100cdf0e10cSrcweir 	void CollectExtents( const SwFrm *pFrm );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	sal_Bool FindCell( const Point& rPos, const SwFrm *pFrm ,
103cdf0e10cSrcweir 						   sal_Bool bExact, const SwFrm *& rFrm ) const;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	void GetSelection( const Point& rTabPos, const SwRect& rArea,
106cdf0e10cSrcweir 					   const SwSelBoxes& rSelBoxes, const SwFrm *pFrm,
107cdf0e10cSrcweir 					   SwAccTableSelHander_Impl& rSelHdl,
108cdf0e10cSrcweir 					   sal_Bool bColumns ) const;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     // --> OD 2007-06-27 #i77106#
IncludeRow(const SwFrm & rFrm) const111cdf0e10cSrcweir     inline bool IncludeRow( const SwFrm& rFrm ) const
112cdf0e10cSrcweir     {
113cdf0e10cSrcweir         return !mbOnlyTableColumnHeader ||
114cdf0e10cSrcweir                mpTabFrm->IsInHeadline( rFrm );
115cdf0e10cSrcweir     }
116cdf0e10cSrcweir     // <--
117cdf0e10cSrcweir public:
118cdf0e10cSrcweir     // --> OD 2007-06-27 #i77106#
119cdf0e10cSrcweir     // add third optional parameter <bOnlyTableColumnHeader>, default value <false>
120cdf0e10cSrcweir     SwAccessibleTableData_Impl( SwAccessibleMap& rAccMap,
121cdf0e10cSrcweir                                 const SwTabFrm *pTabFrm,
122cdf0e10cSrcweir                                 sal_Bool bIsInPagePreview,
123cdf0e10cSrcweir                                 bool bOnlyTableColumnHeader = false );
124cdf0e10cSrcweir     // <--
125cdf0e10cSrcweir 
GetRows() const126cdf0e10cSrcweir 	const Int32Set_Impl& GetRows() const { return maRows; }
GetColumns() const127cdf0e10cSrcweir 	const Int32Set_Impl& GetColumns() const { return maColumns; }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	inline Int32Set_Impl::const_iterator GetRowIter( sal_Int32 nRow ) const;
130cdf0e10cSrcweir 	inline Int32Set_Impl::const_iterator GetColumnIter( sal_Int32 nCol ) const;
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	const SwFrm *GetCell( sal_Int32 nRow, sal_Int32 nColumn, sal_Bool bExact,
133cdf0e10cSrcweir 						  SwAccessibleTable *pThis ) const
134cdf0e10cSrcweir 		throw(lang::IndexOutOfBoundsException );
135cdf0e10cSrcweir 	const SwFrm *GetCellAtPos( sal_Int32 nLeft, sal_Int32 nTop,
136cdf0e10cSrcweir 								   	  sal_Bool bExact ) const;
137cdf0e10cSrcweir 	inline sal_Int32 GetRowCount() const;
138cdf0e10cSrcweir 	inline sal_Int32 GetColumnCount() const;
139cdf0e10cSrcweir 	sal_Bool CompareExtents( const SwAccessibleTableData_Impl& r ) const;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	void GetSelection( sal_Int32 nStart, sal_Int32 nEnd,
142cdf0e10cSrcweir 					   const SwSelBoxes& rSelBoxes,
143cdf0e10cSrcweir 		   			   SwAccTableSelHander_Impl& rSelHdl,
144cdf0e10cSrcweir 					   sal_Bool bColumns ) const;
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 	void CheckRowAndCol( sal_Int32 nRow, sal_Int32 nCol,
147cdf0e10cSrcweir 						 SwAccessibleTable *pThis ) const
148cdf0e10cSrcweir 		throw(lang::IndexOutOfBoundsException );
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	void GetRowColumnAndExtent( const SwRect& rBox,
151cdf0e10cSrcweir 								  sal_Int32& rRow, sal_Int32& rColumn,
152cdf0e10cSrcweir 								  sal_Int32& rRowExtent,
153cdf0e10cSrcweir 								  sal_Int32& rColumnExtent ) const;
154cdf0e10cSrcweir 
GetTablePos() const155cdf0e10cSrcweir 	const Point& GetTablePos() const { return maTabFrmPos; }
SetTablePos(const Point & rPos)156cdf0e10cSrcweir 	void SetTablePos( const Point& rPos ) { maTabFrmPos = rPos; }
157cdf0e10cSrcweir };
158cdf0e10cSrcweir 
CollectData(const SwFrm * pFrm)159cdf0e10cSrcweir void SwAccessibleTableData_Impl::CollectData( const SwFrm *pFrm )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     const SwAccessibleChildSList aList( *pFrm, mrAccMap );
162cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aIter( aList.begin() );
163cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aEndIter( aList.end() );
164cdf0e10cSrcweir 	while( aIter != aEndIter )
165cdf0e10cSrcweir 	{
166cdf0e10cSrcweir         const SwAccessibleChild& rLower = *aIter;
167cdf0e10cSrcweir 		const SwFrm *pLower = rLower.GetSwFrm();
168cdf0e10cSrcweir 		if( pLower )
169cdf0e10cSrcweir 		{
170cdf0e10cSrcweir 			if( pLower->IsRowFrm() )
171cdf0e10cSrcweir 			{
172cdf0e10cSrcweir                 // --> OD 2007-06-27 #i77106#
173cdf0e10cSrcweir                 if ( IncludeRow( *pLower ) )
174cdf0e10cSrcweir                 {
175cdf0e10cSrcweir                     maRows.insert( pLower->Frm().Top() - maTabFrmPos.Y() );
176cdf0e10cSrcweir                     CollectData( pLower );
177cdf0e10cSrcweir                 }
178cdf0e10cSrcweir                 // <--
179cdf0e10cSrcweir 			}
180cdf0e10cSrcweir 			else if( pLower->IsCellFrm() &&
181cdf0e10cSrcweir                      rLower.IsAccessible( mbIsInPagePreview ) )
182cdf0e10cSrcweir 			{
183cdf0e10cSrcweir 				maColumns.insert( pLower->Frm().Left() - maTabFrmPos.X() );
184cdf0e10cSrcweir 			}
185cdf0e10cSrcweir 			else
186cdf0e10cSrcweir 			{
187cdf0e10cSrcweir 				CollectData( pLower );
188cdf0e10cSrcweir 			}
189cdf0e10cSrcweir 		}
190cdf0e10cSrcweir 		++aIter;
191cdf0e10cSrcweir 	}
192cdf0e10cSrcweir }
193cdf0e10cSrcweir 
CollectRowHeaderData(const SwFrm * pFrm)194ca62e2c2SSteve Yin void SwAccessibleTableData_Impl::CollectRowHeaderData( const SwFrm *pFrm )
195ca62e2c2SSteve Yin {
196ca62e2c2SSteve Yin     const SwAccessibleChildSList aList( *pFrm, mrAccMap );
197ca62e2c2SSteve Yin     SwAccessibleChildSList::const_iterator aIter( aList.begin() );
198ca62e2c2SSteve Yin     SwAccessibleChildSList::const_iterator aEndIter( aList.end() );
199ca62e2c2SSteve Yin 	while( aIter != aEndIter )
200ca62e2c2SSteve Yin 	{
201ca62e2c2SSteve Yin         const SwAccessibleChild& rLower = *aIter;
202ca62e2c2SSteve Yin 		const SwFrm *pLower = rLower.GetSwFrm();
203ca62e2c2SSteve Yin 		if( pLower )
204ca62e2c2SSteve Yin 		{
205ca62e2c2SSteve Yin 			if( pLower->IsRowFrm() )
206ca62e2c2SSteve Yin 			{
207ca62e2c2SSteve Yin 
208ca62e2c2SSteve Yin 				const SwTableLine* pLine = ((SwRowFrm*)pLower)->GetTabLine();
209ca62e2c2SSteve Yin 				while( pLine->GetUpper() )
210ca62e2c2SSteve Yin 					pLine = pLine->GetUpper()->GetUpper();
211ca62e2c2SSteve Yin 
212ca62e2c2SSteve Yin 				// Headerline?
213ca62e2c2SSteve Yin 				//if(mpTabFrm->GetTable()->GetTabLines()[ 0 ] != pLine)
214ca62e2c2SSteve Yin 				//return ;
215ca62e2c2SSteve Yin 
216ca62e2c2SSteve Yin 				maRows.insert( pLower->Frm().Top() - maTabFrmPos.Y() );
217ca62e2c2SSteve Yin 
218ca62e2c2SSteve Yin 				CollectRowHeaderData( pLower );
219ca62e2c2SSteve Yin 
220ca62e2c2SSteve Yin 
221ca62e2c2SSteve Yin 			}
222ca62e2c2SSteve Yin 			else if( pLower->IsCellFrm() &&
223ca62e2c2SSteve Yin                      rLower.IsAccessible( mbIsInPagePreview ) )
224ca62e2c2SSteve Yin 			{
225ca62e2c2SSteve Yin 				//Added by yanjun. Can't find the "GetRowHeaderFlag" function(Need vefiry).
226ca62e2c2SSteve Yin 				//if(((SwCellFrm*)pLower)->GetRowHeaderFlag())
227ca62e2c2SSteve Yin 				//	maColumns.insert( pLower->Frm().Left() - maTabFrmPos.X() );
228ca62e2c2SSteve Yin 			}
229ca62e2c2SSteve Yin 			else
230ca62e2c2SSteve Yin 			{
231ca62e2c2SSteve Yin 				CollectRowHeaderData( pLower );
232ca62e2c2SSteve Yin 			}
233ca62e2c2SSteve Yin 		}
234ca62e2c2SSteve Yin 		++aIter;
235ca62e2c2SSteve Yin 	}
236ca62e2c2SSteve Yin }
237ca62e2c2SSteve Yin 
CollectColumnHeaderData(const SwFrm * pFrm)238ca62e2c2SSteve Yin void SwAccessibleTableData_Impl::CollectColumnHeaderData( const SwFrm *pFrm )
239ca62e2c2SSteve Yin {
240ca62e2c2SSteve Yin     const SwAccessibleChildSList aList( *pFrm, mrAccMap );
241ca62e2c2SSteve Yin     SwAccessibleChildSList::const_iterator aIter( aList.begin() );
242ca62e2c2SSteve Yin     SwAccessibleChildSList::const_iterator aEndIter( aList.end() );
243ca62e2c2SSteve Yin 	while( aIter != aEndIter )
244ca62e2c2SSteve Yin 	{
245ca62e2c2SSteve Yin         const SwAccessibleChild& rLower = *aIter;
246ca62e2c2SSteve Yin 		const SwFrm *pLower = rLower.GetSwFrm();
247ca62e2c2SSteve Yin 		if( pLower )
248ca62e2c2SSteve Yin 		{
249ca62e2c2SSteve Yin 			if( pLower->IsRowFrm() )
250ca62e2c2SSteve Yin 			{
251ca62e2c2SSteve Yin 
252ca62e2c2SSteve Yin 				const SwTableLine* pLine = ((SwRowFrm*)pLower)->GetTabLine();
253ca62e2c2SSteve Yin 				while( pLine->GetUpper() )
254ca62e2c2SSteve Yin 					pLine = pLine->GetUpper()->GetUpper();
255ca62e2c2SSteve Yin 
256ca62e2c2SSteve Yin 				// Headerline?
257ca62e2c2SSteve Yin 				//if(mpTabFrm->GetTable()->GetTabLines()[ 0 ] != pLine)
258ca62e2c2SSteve Yin 				//return ;
259ca62e2c2SSteve Yin 
260ca62e2c2SSteve Yin 				//if the current line is now header line, then return ;
261ca62e2c2SSteve Yin 				sal_Int16 iCurrentRowIndex = mpTabFrm->GetTable()->GetTabLines().GetPos( pLine);
262ca62e2c2SSteve Yin 				if(iCurrentRowIndex >= mpTabFrm->GetTable()->_GetRowsToRepeat())
263ca62e2c2SSteve Yin 					return ;
264ca62e2c2SSteve Yin 
265ca62e2c2SSteve Yin 				maRows.insert( pLower->Frm().Top() - maTabFrmPos.Y() );
266ca62e2c2SSteve Yin 
267ca62e2c2SSteve Yin 				CollectColumnHeaderData( pLower );
268ca62e2c2SSteve Yin 
269ca62e2c2SSteve Yin 
270ca62e2c2SSteve Yin 			}
271ca62e2c2SSteve Yin 			else if( pLower->IsCellFrm() &&
272ca62e2c2SSteve Yin                      rLower.IsAccessible( mbIsInPagePreview ) )
273ca62e2c2SSteve Yin 			{
274ca62e2c2SSteve Yin 				maColumns.insert( pLower->Frm().Left() - maTabFrmPos.X() );
275ca62e2c2SSteve Yin 			}
276ca62e2c2SSteve Yin 			else
277ca62e2c2SSteve Yin 			{
278ca62e2c2SSteve Yin 				CollectColumnHeaderData( pLower );
279ca62e2c2SSteve Yin 			}
280ca62e2c2SSteve Yin 		}
281ca62e2c2SSteve Yin 		++aIter;
282ca62e2c2SSteve Yin 	}
283ca62e2c2SSteve Yin }
CollectExtents(const SwFrm * pFrm)284cdf0e10cSrcweir void SwAccessibleTableData_Impl::CollectExtents( const SwFrm *pFrm )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir     const SwAccessibleChildSList aList( *pFrm, mrAccMap );
287cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aIter( aList.begin() );
288cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aEndIter( aList.end() );
289cdf0e10cSrcweir 	while( aIter != aEndIter )
290cdf0e10cSrcweir 	{
291cdf0e10cSrcweir         const SwAccessibleChild& rLower = *aIter;
292cdf0e10cSrcweir 		const SwFrm *pLower = rLower.GetSwFrm();
293cdf0e10cSrcweir 		if( pLower )
294cdf0e10cSrcweir 		{
295cdf0e10cSrcweir 			if( pLower->IsCellFrm() &&
296cdf0e10cSrcweir                 rLower.IsAccessible( mbIsInPagePreview ) )
297cdf0e10cSrcweir 			{
298cdf0e10cSrcweir 				sal_Int32 nRow, nCol;
299cdf0e10cSrcweir 				Int32Pair_Impl aCellExtents;
300cdf0e10cSrcweir 				GetRowColumnAndExtent( pLower->Frm(), nRow, nCol,
301cdf0e10cSrcweir 									   aCellExtents.first,
302cdf0e10cSrcweir 									   aCellExtents.second );
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 				maExtents.push_back( aCellExtents );
305cdf0e10cSrcweir 			}
306cdf0e10cSrcweir 			else
307cdf0e10cSrcweir 			{
308cdf0e10cSrcweir                 // --> OD 2007-06-27 #i77106#
309cdf0e10cSrcweir                 if ( !pLower->IsRowFrm() ||
310cdf0e10cSrcweir                      IncludeRow( *pLower ) )
311cdf0e10cSrcweir                 {
312cdf0e10cSrcweir                     CollectExtents( pLower );
313cdf0e10cSrcweir                 }
314cdf0e10cSrcweir                 // <--
315cdf0e10cSrcweir 			}
316cdf0e10cSrcweir 		}
317cdf0e10cSrcweir 		++aIter;
318cdf0e10cSrcweir 	}
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
FindCell(const Point & rPos,const SwFrm * pFrm,sal_Bool bExact,const SwFrm * & rRet) const321cdf0e10cSrcweir sal_Bool SwAccessibleTableData_Impl::FindCell(
322cdf0e10cSrcweir 		const Point& rPos, const SwFrm *pFrm, sal_Bool bExact,
323cdf0e10cSrcweir 		const SwFrm *& rRet	) const
324cdf0e10cSrcweir {
325cdf0e10cSrcweir 	sal_Bool bFound = sal_False;
326cdf0e10cSrcweir 
327cdf0e10cSrcweir     const SwAccessibleChildSList aList( *pFrm, mrAccMap );
328cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aIter( aList.begin() );
329cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aEndIter( aList.end() );
330cdf0e10cSrcweir 	while( !bFound && aIter != aEndIter )
331cdf0e10cSrcweir 	{
332cdf0e10cSrcweir         const SwAccessibleChild& rLower = *aIter;
333cdf0e10cSrcweir 		const SwFrm *pLower = rLower.GetSwFrm();
334cdf0e10cSrcweir 		ASSERT( pLower, "child should be a frame" );
335cdf0e10cSrcweir 		if( pLower )
336cdf0e10cSrcweir 		{
337cdf0e10cSrcweir 			if( rLower.IsAccessible( mbIsInPagePreview ) )
338cdf0e10cSrcweir 			{
339cdf0e10cSrcweir 				ASSERT( pLower->IsCellFrm(), "lower is not a cell frame" );
340cdf0e10cSrcweir 				const SwRect& rFrm = pLower->Frm();
341cdf0e10cSrcweir 				if( rFrm.Right() >= rPos.X() && rFrm.Bottom() >= rPos.Y() )
342cdf0e10cSrcweir 				{
343cdf0e10cSrcweir 					// We have found the cell
344cdf0e10cSrcweir 					ASSERT( rFrm.Left() <= rPos.X() && rFrm.Top() <= rPos.Y(),
345cdf0e10cSrcweir 							"find frame moved to far!" );
346cdf0e10cSrcweir 					bFound = sal_True;
347cdf0e10cSrcweir 					if( !bExact ||
348cdf0e10cSrcweir 						(rFrm.Top() == rPos.Y() && rFrm.Left() == rPos.Y() ) )
349cdf0e10cSrcweir 					{
350cdf0e10cSrcweir 						rRet = pLower;
351cdf0e10cSrcweir 					}
352cdf0e10cSrcweir 				}
353cdf0e10cSrcweir 			}
354cdf0e10cSrcweir 			else
355cdf0e10cSrcweir 			{
356cdf0e10cSrcweir                 // --> OD 2007-06-27 #i77106#
357cdf0e10cSrcweir                 if ( !pLower->IsRowFrm() ||
358cdf0e10cSrcweir                      IncludeRow( *pLower ) )
359cdf0e10cSrcweir                 {
360cdf0e10cSrcweir                     bFound = FindCell( rPos, pLower, bExact, rRet );
361cdf0e10cSrcweir                 }
362cdf0e10cSrcweir                 // <--
363cdf0e10cSrcweir 			}
364cdf0e10cSrcweir 		}
365cdf0e10cSrcweir 		++aIter;
366cdf0e10cSrcweir 	}
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	return bFound;
369cdf0e10cSrcweir }
370cdf0e10cSrcweir 
GetSelection(const Point & rTabPos,const SwRect & rArea,const SwSelBoxes & rSelBoxes,const SwFrm * pFrm,SwAccTableSelHander_Impl & rSelHdl,sal_Bool bColumns) const371cdf0e10cSrcweir void SwAccessibleTableData_Impl::GetSelection(
372cdf0e10cSrcweir 			const Point& rTabPos,
373cdf0e10cSrcweir 			const SwRect& rArea,
374cdf0e10cSrcweir 			const SwSelBoxes& rSelBoxes,
375cdf0e10cSrcweir 			const SwFrm *pFrm,
376cdf0e10cSrcweir 			SwAccTableSelHander_Impl& rSelHdl,
377cdf0e10cSrcweir 			sal_Bool bColumns ) const
378cdf0e10cSrcweir {
379cdf0e10cSrcweir     const SwAccessibleChildSList aList( *pFrm, mrAccMap );
380cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aIter( aList.begin() );
381cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aEndIter( aList.end() );
382cdf0e10cSrcweir 	while( aIter != aEndIter )
383cdf0e10cSrcweir 	{
384cdf0e10cSrcweir         const SwAccessibleChild& rLower = *aIter;
385cdf0e10cSrcweir 		const SwFrm *pLower = rLower.GetSwFrm();
386cdf0e10cSrcweir 		ASSERT( pLower, "child should be a frame" );
387cdf0e10cSrcweir         const SwRect& rBox = rLower.GetBox( mrAccMap );
388cdf0e10cSrcweir 		if( pLower && rBox.IsOver( rArea ) )
389cdf0e10cSrcweir 		{
390cdf0e10cSrcweir 			if( rLower.IsAccessible( mbIsInPagePreview ) )
391cdf0e10cSrcweir 			{
392cdf0e10cSrcweir 				ASSERT( pLower->IsCellFrm(), "lower is not a cell frame" );
393cdf0e10cSrcweir 				const SwCellFrm *pCFrm =
394cdf0e10cSrcweir 						static_cast < const SwCellFrm * >( pLower );
395cdf0e10cSrcweir 				SwTableBox *pBox =
396cdf0e10cSrcweir 					const_cast< SwTableBox *>( pCFrm->GetTabBox() ); //SVPtrArr!
397cdf0e10cSrcweir 				if( !rSelBoxes.Seek_Entry( pBox ) )
398cdf0e10cSrcweir 				{
399cdf0e10cSrcweir 					const Int32Set_Impl	rRowsOrCols =
400cdf0e10cSrcweir 						bColumns ? maColumns : maRows;
401cdf0e10cSrcweir 
402cdf0e10cSrcweir 					sal_Int32 nPos = bColumns ? (rBox.Left() - rTabPos.X())
403cdf0e10cSrcweir 											  : (rBox.Top() - rTabPos.Y());
404cdf0e10cSrcweir 					Int32Set_Impl::const_iterator aSttRowOrCol(
405cdf0e10cSrcweir 						rRowsOrCols.lower_bound( nPos ) );
406cdf0e10cSrcweir 					sal_Int32 nRowOrCol =
407cdf0e10cSrcweir 						static_cast< sal_Int32 >( ::std::distance(
408cdf0e10cSrcweir 							rRowsOrCols.begin(), aSttRowOrCol ) );
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 					nPos = bColumns ? (rBox.Right() - rTabPos.X())
411cdf0e10cSrcweir 									: (rBox.Bottom() - rTabPos.Y());
412cdf0e10cSrcweir 					Int32Set_Impl::const_iterator aEndRowOrCol(
413cdf0e10cSrcweir 						rRowsOrCols.upper_bound( nPos ) );
414cdf0e10cSrcweir 					sal_Int32 nExt =
415cdf0e10cSrcweir 						static_cast< sal_Int32 >( ::std::distance(
416cdf0e10cSrcweir 							aSttRowOrCol, aEndRowOrCol ) );
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 					rSelHdl.Unselect( nRowOrCol, nExt );
419cdf0e10cSrcweir 				}
420cdf0e10cSrcweir 			}
421cdf0e10cSrcweir 			else
422cdf0e10cSrcweir 			{
423cdf0e10cSrcweir                 // --> OD 2007-06-27 #i77106#
424cdf0e10cSrcweir                 if ( !pLower->IsRowFrm() ||
425cdf0e10cSrcweir                      IncludeRow( *pLower ) )
426cdf0e10cSrcweir                 {
427cdf0e10cSrcweir                     GetSelection( rTabPos, rArea, rSelBoxes, pLower, rSelHdl,
428cdf0e10cSrcweir                                   bColumns );
429cdf0e10cSrcweir                 }
430cdf0e10cSrcweir                 // <--
431cdf0e10cSrcweir 			}
432cdf0e10cSrcweir 		}
433cdf0e10cSrcweir 		++aIter;
434cdf0e10cSrcweir 	}
435cdf0e10cSrcweir }
436cdf0e10cSrcweir 
GetCell(sal_Int32 nRow,sal_Int32 nColumn,sal_Bool,SwAccessibleTable * pThis) const437cdf0e10cSrcweir const SwFrm *SwAccessibleTableData_Impl::GetCell(
438cdf0e10cSrcweir         sal_Int32 nRow, sal_Int32 nColumn, sal_Bool,
439cdf0e10cSrcweir 		SwAccessibleTable *pThis ) const
440cdf0e10cSrcweir 	throw(lang::IndexOutOfBoundsException )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir 	CheckRowAndCol( nRow, nColumn, pThis );
443cdf0e10cSrcweir 
444cdf0e10cSrcweir 	Int32Set_Impl::const_iterator aSttCol( GetColumnIter( nColumn ) );
445cdf0e10cSrcweir 	Int32Set_Impl::const_iterator aSttRow( GetRowIter( nRow ) );
446cdf0e10cSrcweir 	const SwFrm *pCellFrm = GetCellAtPos( *aSttCol, *aSttRow, sal_False );
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 	return pCellFrm;
449cdf0e10cSrcweir }
450cdf0e10cSrcweir 
GetSelection(sal_Int32 nStart,sal_Int32 nEnd,const SwSelBoxes & rSelBoxes,SwAccTableSelHander_Impl & rSelHdl,sal_Bool bColumns) const451cdf0e10cSrcweir void SwAccessibleTableData_Impl::GetSelection(
452cdf0e10cSrcweir 					   sal_Int32 nStart, sal_Int32 nEnd,
453cdf0e10cSrcweir 					   const SwSelBoxes& rSelBoxes,
454cdf0e10cSrcweir 		   			   SwAccTableSelHander_Impl& rSelHdl,
455cdf0e10cSrcweir 					   sal_Bool bColumns ) const
456cdf0e10cSrcweir {
457cdf0e10cSrcweir 	SwRect aArea( mpTabFrm->Frm() );
458cdf0e10cSrcweir 	Point aPos( aArea.Pos() );
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 	const Int32Set_Impl& rRowsOrColumns = bColumns ? maColumns : maRows;
461cdf0e10cSrcweir 	if( nStart > 0 )
462cdf0e10cSrcweir 	{
463cdf0e10cSrcweir 		Int32Set_Impl::const_iterator aStt( rRowsOrColumns.begin() );
464cdf0e10cSrcweir 		::std::advance( aStt,
465cdf0e10cSrcweir 			static_cast< Int32Set_Impl::difference_type >( nStart ) );
466cdf0e10cSrcweir 		if( bColumns )
467cdf0e10cSrcweir 			aArea.Left( *aStt + aPos.X() );
468cdf0e10cSrcweir 		else
469cdf0e10cSrcweir 			aArea.Top( *aStt + aPos.Y() );
470cdf0e10cSrcweir 	}
471cdf0e10cSrcweir 	if( nEnd < static_cast< sal_Int32 >( rRowsOrColumns.size() ) )
472cdf0e10cSrcweir 	{
473cdf0e10cSrcweir 		Int32Set_Impl::const_iterator aEnd( rRowsOrColumns.begin() );
474cdf0e10cSrcweir 		::std::advance( aEnd,
475cdf0e10cSrcweir 			static_cast< Int32Set_Impl::difference_type >( nEnd ) );
476cdf0e10cSrcweir 		if( bColumns )
477cdf0e10cSrcweir 			aArea.Right( *aEnd + aPos.X() - 1 );
478cdf0e10cSrcweir 		else
479cdf0e10cSrcweir 			aArea.Bottom( *aEnd + aPos.Y() - 1 );
480cdf0e10cSrcweir 	}
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 	GetSelection( aPos, aArea, rSelBoxes, mpTabFrm, rSelHdl, bColumns );
483cdf0e10cSrcweir }
484cdf0e10cSrcweir 
GetCellAtPos(sal_Int32 nLeft,sal_Int32 nTop,sal_Bool bExact) const485cdf0e10cSrcweir const SwFrm *SwAccessibleTableData_Impl::GetCellAtPos(
486cdf0e10cSrcweir 		sal_Int32 nLeft, sal_Int32 nTop, sal_Bool bExact ) const
487cdf0e10cSrcweir {
488cdf0e10cSrcweir 	Point aPos( mpTabFrm->Frm().Pos() );
489cdf0e10cSrcweir 	aPos.Move( nLeft, nTop );
490cdf0e10cSrcweir 	const SwFrm *pRet = 0;
491cdf0e10cSrcweir 	FindCell( aPos, mpTabFrm, bExact, pRet );
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 	return pRet;
494cdf0e10cSrcweir }
495cdf0e10cSrcweir 
GetRowCount() const496cdf0e10cSrcweir inline sal_Int32 SwAccessibleTableData_Impl::GetRowCount() const
497cdf0e10cSrcweir {
498ca62e2c2SSteve Yin 	sal_Int32 count =  static_cast< sal_Int32 >( maRows.size() ) ;
499ca62e2c2SSteve Yin 	count = (count <=0)? 1:count;
500ca62e2c2SSteve Yin 	return count;
501cdf0e10cSrcweir }
502cdf0e10cSrcweir 
GetColumnCount() const503cdf0e10cSrcweir inline sal_Int32 SwAccessibleTableData_Impl::GetColumnCount() const
504cdf0e10cSrcweir {
505cdf0e10cSrcweir 	return static_cast< sal_Int32 >( maColumns.size() );
506cdf0e10cSrcweir }
507cdf0e10cSrcweir 
CompareExtents(const SwAccessibleTableData_Impl & rCmp) const508cdf0e10cSrcweir sal_Bool SwAccessibleTableData_Impl::CompareExtents(
509cdf0e10cSrcweir 								const SwAccessibleTableData_Impl& rCmp ) const
510cdf0e10cSrcweir {
511cdf0e10cSrcweir 	if( maExtents.size() != rCmp.maExtents.size() )
512cdf0e10cSrcweir 		return sal_False;
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 	Int32PairList_Impl::const_iterator aIter( maExtents.begin() );
515cdf0e10cSrcweir 	Int32PairList_Impl::const_iterator aEndIter( maExtents.end() );
516cdf0e10cSrcweir 	Int32PairList_Impl::const_iterator aCmpIter( rCmp.maExtents.begin() );
517cdf0e10cSrcweir 	while( aIter != aEndIter )
518cdf0e10cSrcweir 	{
519cdf0e10cSrcweir 		if( *aIter != *aCmpIter )
520cdf0e10cSrcweir 			return sal_False;
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 		++aIter;
523cdf0e10cSrcweir 		++aCmpIter;
524cdf0e10cSrcweir 	}
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 	return sal_True;
527cdf0e10cSrcweir }
528cdf0e10cSrcweir 
SwAccessibleTableData_Impl(SwAccessibleMap & rAccMap,const SwTabFrm * pTabFrm,sal_Bool bIsInPagePreview,bool bOnlyTableColumnHeader)529cdf0e10cSrcweir SwAccessibleTableData_Impl::SwAccessibleTableData_Impl( SwAccessibleMap& rAccMap,
530cdf0e10cSrcweir                                                         const SwTabFrm *pTabFrm,
531cdf0e10cSrcweir                                                         sal_Bool bIsInPagePreview,
532cdf0e10cSrcweir                                                         bool bOnlyTableColumnHeader )
533cdf0e10cSrcweir     : mrAccMap( rAccMap )
534cdf0e10cSrcweir     , maTabFrmPos( pTabFrm->Frm().Pos() )
535cdf0e10cSrcweir     , mpTabFrm( pTabFrm )
536cdf0e10cSrcweir     , mbIsInPagePreview( bIsInPagePreview )
537cdf0e10cSrcweir     , mbOnlyTableColumnHeader( bOnlyTableColumnHeader )
538cdf0e10cSrcweir {
539cdf0e10cSrcweir 	CollectData( mpTabFrm );
540cdf0e10cSrcweir 	CollectExtents( mpTabFrm );
541cdf0e10cSrcweir }
542cdf0e10cSrcweir 
GetRowIter(sal_Int32 nRow) const543cdf0e10cSrcweir inline Int32Set_Impl::const_iterator SwAccessibleTableData_Impl::GetRowIter(
544cdf0e10cSrcweir 		sal_Int32 nRow ) const
545cdf0e10cSrcweir {
546cdf0e10cSrcweir 	Int32Set_Impl::const_iterator aCol( GetRows().begin() );
547cdf0e10cSrcweir 	if( nRow > 0 )
548cdf0e10cSrcweir 	{
549cdf0e10cSrcweir 		::std::advance( aCol,
550cdf0e10cSrcweir 					static_cast< Int32Set_Impl::difference_type >( nRow ) );
551cdf0e10cSrcweir 	}
552cdf0e10cSrcweir 	return aCol;
553cdf0e10cSrcweir }
554cdf0e10cSrcweir 
GetColumnIter(sal_Int32 nColumn) const555cdf0e10cSrcweir inline Int32Set_Impl::const_iterator SwAccessibleTableData_Impl::GetColumnIter(
556cdf0e10cSrcweir 		sal_Int32 nColumn ) const
557cdf0e10cSrcweir {
558cdf0e10cSrcweir 	Int32Set_Impl::const_iterator aCol = GetColumns().begin();
559cdf0e10cSrcweir 	if( nColumn > 0 )
560cdf0e10cSrcweir 	{
561cdf0e10cSrcweir 		::std::advance( aCol,
562cdf0e10cSrcweir 					static_cast< Int32Set_Impl::difference_type >( nColumn ) );
563cdf0e10cSrcweir 	}
564cdf0e10cSrcweir 	return aCol;
565cdf0e10cSrcweir }
566cdf0e10cSrcweir 
CheckRowAndCol(sal_Int32 nRow,sal_Int32 nCol,SwAccessibleTable * pThis) const567cdf0e10cSrcweir void SwAccessibleTableData_Impl::CheckRowAndCol(
568cdf0e10cSrcweir 		sal_Int32 nRow, sal_Int32 nCol, SwAccessibleTable *pThis ) const
569cdf0e10cSrcweir 	throw(lang::IndexOutOfBoundsException )
570cdf0e10cSrcweir {
571cdf0e10cSrcweir 	if( ( nRow < 0 || nRow >= static_cast< sal_Int32 >( maRows.size() ) ) ||
572cdf0e10cSrcweir 		( nCol < 0 || nCol >= static_cast< sal_Int32 >( maColumns.size() ) ) )
573cdf0e10cSrcweir 	{
574cdf0e10cSrcweir 		uno::Reference < XAccessibleTable > xThis( pThis );
575cdf0e10cSrcweir 		lang::IndexOutOfBoundsException aExcept(
576cdf0e10cSrcweir 			   OUString( RTL_CONSTASCII_USTRINGPARAM(
577cdf0e10cSrcweir 					   "row or column index out of range") ),
578cdf0e10cSrcweir 			   xThis );
579cdf0e10cSrcweir 		throw aExcept;
580cdf0e10cSrcweir 	}
581cdf0e10cSrcweir }
582cdf0e10cSrcweir 
GetRowColumnAndExtent(const SwRect & rBox,sal_Int32 & rRow,sal_Int32 & rColumn,sal_Int32 & rRowExtent,sal_Int32 & rColumnExtent) const583cdf0e10cSrcweir void SwAccessibleTableData_Impl::GetRowColumnAndExtent(
584cdf0e10cSrcweir 		const SwRect& rBox,
585cdf0e10cSrcweir 		sal_Int32& rRow, sal_Int32& rColumn,
586cdf0e10cSrcweir 		sal_Int32& rRowExtent, sal_Int32& rColumnExtent ) const
587cdf0e10cSrcweir {
588cdf0e10cSrcweir 	Int32Set_Impl::const_iterator aStt(
589cdf0e10cSrcweir 				maRows.lower_bound( rBox.Top() - maTabFrmPos.Y() ) );
590cdf0e10cSrcweir 	Int32Set_Impl::const_iterator aEnd(
591cdf0e10cSrcweir 				maRows.upper_bound( rBox.Bottom() - maTabFrmPos.Y() ) );
592cdf0e10cSrcweir 	rRow =
593cdf0e10cSrcweir 		 static_cast< sal_Int32 >( ::std::distance( maRows.begin(), aStt ) );
594cdf0e10cSrcweir 	rRowExtent =
595cdf0e10cSrcweir 		 static_cast< sal_Int32 >( ::std::distance( aStt, aEnd ) );
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 	aStt = maColumns.lower_bound( rBox.Left() - maTabFrmPos.X() );
598cdf0e10cSrcweir 	aEnd = maColumns.upper_bound( rBox.Right() - maTabFrmPos.X() );
599cdf0e10cSrcweir 	rColumn =
600cdf0e10cSrcweir 		 static_cast< sal_Int32 >( ::std::distance( maColumns.begin(), aStt ) );
601cdf0e10cSrcweir 	rColumnExtent =
602cdf0e10cSrcweir 		 static_cast< sal_Int32 >( ::std::distance( aStt, aEnd ) );
603cdf0e10cSrcweir }
604cdf0e10cSrcweir 
605cdf0e10cSrcweir //------------------------------------------------------------------------------
606cdf0e10cSrcweir 
607cdf0e10cSrcweir class SwAccSingleTableSelHander_Impl : public SwAccTableSelHander_Impl
608cdf0e10cSrcweir {
609cdf0e10cSrcweir 	sal_Bool bSelected;
610cdf0e10cSrcweir 
611cdf0e10cSrcweir public:
612cdf0e10cSrcweir 
613cdf0e10cSrcweir 	inline SwAccSingleTableSelHander_Impl();
614cdf0e10cSrcweir 
IsSelected() const615cdf0e10cSrcweir 	inline sal_Bool IsSelected() const { return bSelected; }
616cdf0e10cSrcweir 
617cdf0e10cSrcweir 	virtual void Unselect( sal_Int32, sal_Int32 );
618cdf0e10cSrcweir };
619cdf0e10cSrcweir 
SwAccSingleTableSelHander_Impl()620cdf0e10cSrcweir inline SwAccSingleTableSelHander_Impl::SwAccSingleTableSelHander_Impl() :
621cdf0e10cSrcweir 	bSelected( sal_True )
622cdf0e10cSrcweir {
623cdf0e10cSrcweir }
624cdf0e10cSrcweir 
Unselect(sal_Int32,sal_Int32)625cdf0e10cSrcweir void SwAccSingleTableSelHander_Impl::Unselect( sal_Int32, sal_Int32 )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir 	bSelected = sal_False;
628cdf0e10cSrcweir }
629cdf0e10cSrcweir 
630cdf0e10cSrcweir //------------------------------------------------------------------------------
631cdf0e10cSrcweir 
632cdf0e10cSrcweir class SwAccAllTableSelHander_Impl : public SwAccTableSelHander_Impl
633cdf0e10cSrcweir 
634cdf0e10cSrcweir {
635cdf0e10cSrcweir 	::std::vector< sal_Bool > aSelected;
636cdf0e10cSrcweir 	sal_Int32 nCount;
637cdf0e10cSrcweir 
638cdf0e10cSrcweir public:
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 	inline SwAccAllTableSelHander_Impl( sal_Int32 nSize );
641cdf0e10cSrcweir 
642cdf0e10cSrcweir 	uno::Sequence < sal_Int32 > GetSelSequence();
643cdf0e10cSrcweir 
644cdf0e10cSrcweir 	virtual void Unselect( sal_Int32 nRowOrCol, sal_Int32 nExt );
645cdf0e10cSrcweir     virtual ~SwAccAllTableSelHander_Impl();
646cdf0e10cSrcweir };
647cdf0e10cSrcweir 
~SwAccAllTableSelHander_Impl()648cdf0e10cSrcweir SwAccAllTableSelHander_Impl::~SwAccAllTableSelHander_Impl()
649cdf0e10cSrcweir {
650cdf0e10cSrcweir }
651cdf0e10cSrcweir 
SwAccAllTableSelHander_Impl(sal_Int32 nSize)652cdf0e10cSrcweir inline SwAccAllTableSelHander_Impl::SwAccAllTableSelHander_Impl( sal_Int32 nSize ) :
653cdf0e10cSrcweir 	aSelected( nSize, sal_True ),
654cdf0e10cSrcweir 	nCount( nSize )
655cdf0e10cSrcweir {
656cdf0e10cSrcweir }
657cdf0e10cSrcweir 
GetSelSequence()658cdf0e10cSrcweir uno::Sequence < sal_Int32 > SwAccAllTableSelHander_Impl::GetSelSequence()
659cdf0e10cSrcweir {
660cdf0e10cSrcweir 	ASSERT( nCount >= 0, "underflow" );
661cdf0e10cSrcweir 	uno::Sequence < sal_Int32 > aRet( nCount );
662cdf0e10cSrcweir 	sal_Int32 *pRet = aRet.getArray();
663cdf0e10cSrcweir 	sal_Int32 nPos = 0;
664cdf0e10cSrcweir 	size_t nSize = aSelected.size();
665cdf0e10cSrcweir 	for( size_t i=0; i < nSize && nPos < nCount; i++ )
666cdf0e10cSrcweir 	{
667cdf0e10cSrcweir 		if( aSelected[i] )
668cdf0e10cSrcweir 		{
669cdf0e10cSrcweir 			*pRet++ = i;
670cdf0e10cSrcweir 			nPos++;
671cdf0e10cSrcweir 		}
672cdf0e10cSrcweir 	}
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 	ASSERT( nPos == nCount, "count is wrong" );
675cdf0e10cSrcweir 
676cdf0e10cSrcweir 	return aRet;
677cdf0e10cSrcweir }
678cdf0e10cSrcweir 
Unselect(sal_Int32 nRowOrCol,sal_Int32 nExt)679cdf0e10cSrcweir void SwAccAllTableSelHander_Impl::Unselect( sal_Int32 nRowOrCol,
680cdf0e10cSrcweir 										    sal_Int32 nExt )
681cdf0e10cSrcweir {
682cdf0e10cSrcweir 	ASSERT( static_cast< size_t >( nRowOrCol ) < aSelected.size(),
683cdf0e10cSrcweir 		 	"index to large" );
684cdf0e10cSrcweir 	ASSERT( static_cast< size_t >( nRowOrCol+nExt ) <= aSelected.size(),
685cdf0e10cSrcweir 		 	"extent to large" );
686cdf0e10cSrcweir 	while( nExt )
687cdf0e10cSrcweir 	{
688cdf0e10cSrcweir 		if( aSelected[static_cast< size_t >( nRowOrCol )] )
689cdf0e10cSrcweir 		{
690cdf0e10cSrcweir 			aSelected[static_cast< size_t >( nRowOrCol )] = sal_False;
691cdf0e10cSrcweir 			nCount--;
692cdf0e10cSrcweir 		}
693cdf0e10cSrcweir 		nExt--;
694cdf0e10cSrcweir 		nRowOrCol++;
695cdf0e10cSrcweir 	}
696cdf0e10cSrcweir }
697cdf0e10cSrcweir 
698cdf0e10cSrcweir //------------------------------------------------------------------------------
699cdf0e10cSrcweir 
GetSelBoxes() const700cdf0e10cSrcweir const SwSelBoxes *SwAccessibleTable::GetSelBoxes() const
701cdf0e10cSrcweir {
702cdf0e10cSrcweir 	const SwSelBoxes *pSelBoxes = 0;
703cdf0e10cSrcweir     const SwCrsrShell *pCSh = GetCrsrShell();
704cdf0e10cSrcweir     if( (pCSh != NULL) && pCSh->IsTableMode() )
705cdf0e10cSrcweir 	{
706cdf0e10cSrcweir         pSelBoxes = &pCSh->GetTableCrsr()->GetBoxes();
707cdf0e10cSrcweir     }
708cdf0e10cSrcweir 
709cdf0e10cSrcweir 	return pSelBoxes;
710cdf0e10cSrcweir }
711cdf0e10cSrcweir 
FireTableChangeEvent(const SwAccessibleTableData_Impl & rTableData)712cdf0e10cSrcweir void SwAccessibleTable::FireTableChangeEvent(
713cdf0e10cSrcweir 		const SwAccessibleTableData_Impl& rTableData )
714cdf0e10cSrcweir {
715cdf0e10cSrcweir 	AccessibleTableModelChange aModelChange;
716cdf0e10cSrcweir 	aModelChange.Type = AccessibleTableModelChangeType::UPDATE;
717cdf0e10cSrcweir 	aModelChange.FirstRow = 0;
718cdf0e10cSrcweir 	aModelChange.LastRow = rTableData.GetRowCount() - 1;
719cdf0e10cSrcweir 	aModelChange.FirstColumn = 0;
720cdf0e10cSrcweir 	aModelChange.LastColumn = rTableData.GetColumnCount() - 1;
721cdf0e10cSrcweir 
722cdf0e10cSrcweir 	AccessibleEventObject aEvent;
723cdf0e10cSrcweir 	aEvent.EventId = AccessibleEventId::TABLE_MODEL_CHANGED;
724cdf0e10cSrcweir 	aEvent.NewValue <<= aModelChange;
725cdf0e10cSrcweir 
726cdf0e10cSrcweir 	FireAccessibleEvent( aEvent );
727cdf0e10cSrcweir }
728cdf0e10cSrcweir 
729cdf0e10cSrcweir 
GetTableBox(sal_Int32 nChildIndex) const730cdf0e10cSrcweir const SwTableBox* SwAccessibleTable::GetTableBox( sal_Int32 nChildIndex ) const
731cdf0e10cSrcweir {
732cdf0e10cSrcweir     DBG_ASSERT( nChildIndex >= 0, "Illegal child index." );
733cdf0e10cSrcweir     // --> OD 2007-06-27 #i77106#
734cdf0e10cSrcweir     DBG_ASSERT( nChildIndex < const_cast<SwAccessibleTable*>(this)->getAccessibleChildCount(), "Illegal child index." );
735cdf0e10cSrcweir     // <--
736cdf0e10cSrcweir 
737cdf0e10cSrcweir     const SwTableBox* pBox = NULL;
738cdf0e10cSrcweir 
739cdf0e10cSrcweir     // get table box for 'our' table cell
740cdf0e10cSrcweir     SwAccessibleChild aCell( GetChild( *(const_cast<SwAccessibleMap*>(GetMap())), nChildIndex ) );
741cdf0e10cSrcweir     if( aCell.GetSwFrm()  )
742cdf0e10cSrcweir     {
743cdf0e10cSrcweir         const SwFrm* pChildFrm = aCell.GetSwFrm();
744cdf0e10cSrcweir         if( (pChildFrm != NULL) && pChildFrm->IsCellFrm() )
745cdf0e10cSrcweir         {
746cdf0e10cSrcweir             const SwCellFrm* pCellFrm =
747cdf0e10cSrcweir                 static_cast<const SwCellFrm*>( pChildFrm );
748cdf0e10cSrcweir 			pBox = pCellFrm->GetTabBox();
749cdf0e10cSrcweir         }
750cdf0e10cSrcweir     }
751cdf0e10cSrcweir 
752cdf0e10cSrcweir     DBG_ASSERT( pBox != NULL, "We need the table box." );
753cdf0e10cSrcweir     return pBox;
754cdf0e10cSrcweir }
755cdf0e10cSrcweir 
IsChildSelected(sal_Int32 nChildIndex) const756cdf0e10cSrcweir sal_Bool SwAccessibleTable::IsChildSelected( sal_Int32 nChildIndex ) const
757cdf0e10cSrcweir {
758cdf0e10cSrcweir     sal_Bool bRet = sal_False;
759cdf0e10cSrcweir     const SwSelBoxes* pSelBoxes = GetSelBoxes();
760cdf0e10cSrcweir     if( pSelBoxes )
761cdf0e10cSrcweir     {
762cdf0e10cSrcweir         const SwTableBox* pBox = GetTableBox( nChildIndex );
763cdf0e10cSrcweir         DBG_ASSERT( pBox != NULL, "We need the table box." );
764cdf0e10cSrcweir         bRet = pSelBoxes->Seek_Entry( const_cast<SwTableBox*>( pBox ) );
765cdf0e10cSrcweir     }
766cdf0e10cSrcweir 
767cdf0e10cSrcweir     return bRet;
768cdf0e10cSrcweir }
769cdf0e10cSrcweir 
GetIndexOfSelectedChild(sal_Int32 nSelectedChildIndex) const770cdf0e10cSrcweir sal_Int32 SwAccessibleTable::GetIndexOfSelectedChild(
771cdf0e10cSrcweir 				sal_Int32 nSelectedChildIndex ) const
772cdf0e10cSrcweir {
773cdf0e10cSrcweir     // iterate over all children to n-th isAccessibleChildSelected()
774cdf0e10cSrcweir     // --> OD 2007-06-27 #i77106#
775cdf0e10cSrcweir     sal_Int32 nChildren = const_cast<SwAccessibleTable*>(this)->getAccessibleChildCount();
776cdf0e10cSrcweir     // <--
777cdf0e10cSrcweir 	if( nSelectedChildIndex >= nChildren )
778cdf0e10cSrcweir 		return -1L;
779cdf0e10cSrcweir 
780cdf0e10cSrcweir     sal_Int32 n = 0;
781cdf0e10cSrcweir     while( n < nChildren )
782cdf0e10cSrcweir     {
783cdf0e10cSrcweir         if( IsChildSelected( n ) )
784cdf0e10cSrcweir 		{
785cdf0e10cSrcweir 			if( 0 == nSelectedChildIndex )
786cdf0e10cSrcweir 				break;
787cdf0e10cSrcweir 			else
788cdf0e10cSrcweir 				--nSelectedChildIndex;
789cdf0e10cSrcweir 		}
790cdf0e10cSrcweir         ++n;
791cdf0e10cSrcweir     }
792cdf0e10cSrcweir 
793cdf0e10cSrcweir 	return n < nChildren ? n : -1L;
794cdf0e10cSrcweir }
795cdf0e10cSrcweir 
GetStates(::utl::AccessibleStateSetHelper & rStateSet)796cdf0e10cSrcweir void SwAccessibleTable::GetStates(
797cdf0e10cSrcweir 		::utl::AccessibleStateSetHelper& rStateSet )
798cdf0e10cSrcweir {
799cdf0e10cSrcweir 	SwAccessibleContext::GetStates( rStateSet );
800ca62e2c2SSteve Yin 	//Solution:Add resizable state to table
801ca62e2c2SSteve Yin 	rStateSet.AddState( AccessibleStateType::RESIZABLE );
802cdf0e10cSrcweir 	// MULTISELECTABLE
803ca62e2c2SSteve Yin 	rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE );
804cdf0e10cSrcweir     SwCrsrShell* pCrsrShell = GetCrsrShell();
805cdf0e10cSrcweir     if( pCrsrShell  )
806cdf0e10cSrcweir 		rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE );
807cdf0e10cSrcweir }
808cdf0e10cSrcweir 
SwAccessibleTable(SwAccessibleMap * pInitMap,const SwTabFrm * pTabFrm)809cdf0e10cSrcweir SwAccessibleTable::SwAccessibleTable(
810cdf0e10cSrcweir         SwAccessibleMap* pInitMap,
811cdf0e10cSrcweir         const SwTabFrm* pTabFrm  ) :
812cdf0e10cSrcweir     SwAccessibleContext( pInitMap, AccessibleRole::TABLE, pTabFrm ),
813cdf0e10cSrcweir 	mpTableData( 0 )
814cdf0e10cSrcweir {
815cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
816cdf0e10cSrcweir 
817cdf0e10cSrcweir 	const SwFrmFmt *pFrmFmt = pTabFrm->GetFmt();
818cdf0e10cSrcweir 	const_cast< SwFrmFmt * >( pFrmFmt )->Add( this );
819cdf0e10cSrcweir 	const String& rName = pFrmFmt->GetName();
820cdf0e10cSrcweir 
821cdf0e10cSrcweir 	OUStringBuffer aBuffer( rName.Len() + 4 );
822cdf0e10cSrcweir 	aBuffer.append( OUString(rName) );
823cdf0e10cSrcweir 	aBuffer.append( static_cast<sal_Unicode>( '-' ) );
824cdf0e10cSrcweir 	aBuffer.append( static_cast<sal_Int32>( pTabFrm->GetPhyPageNum() ) );
825cdf0e10cSrcweir 
826cdf0e10cSrcweir 	SetName( aBuffer.makeStringAndClear() );
827cdf0e10cSrcweir 
828cdf0e10cSrcweir 	OUString sArg1( static_cast< const SwTabFrm * >( GetFrm() )
829cdf0e10cSrcweir 										->GetFmt()->GetName() );
830cdf0e10cSrcweir 	OUString sArg2( GetFormattedPageNumber() );
831cdf0e10cSrcweir 
832cdf0e10cSrcweir 	sDesc = GetResource( STR_ACCESS_TABLE_DESC, &sArg1, &sArg2 );
833ca62e2c2SSteve Yin 	UpdateTableData();
834cdf0e10cSrcweir }
835cdf0e10cSrcweir 
~SwAccessibleTable()836cdf0e10cSrcweir SwAccessibleTable::~SwAccessibleTable()
837cdf0e10cSrcweir {
838cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
839cdf0e10cSrcweir 
840cdf0e10cSrcweir 	delete mpTableData;
841cdf0e10cSrcweir }
842cdf0e10cSrcweir 
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)843cdf0e10cSrcweir void SwAccessibleTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
844cdf0e10cSrcweir {
845cdf0e10cSrcweir 	sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ;
846cdf0e10cSrcweir 	const SwTabFrm *pTabFrm = static_cast< const SwTabFrm * >( GetFrm() );
847cdf0e10cSrcweir 	switch( nWhich )
848cdf0e10cSrcweir 	{
849cdf0e10cSrcweir 	case RES_NAME_CHANGED:
850cdf0e10cSrcweir 		if( pTabFrm )
851cdf0e10cSrcweir 		{
852cdf0e10cSrcweir 			const SwFrmFmt *pFrmFmt = pTabFrm->GetFmt();
853cdf0e10cSrcweir 			ASSERT( pFrmFmt == GetRegisteredIn(), "invalid frame" );
854cdf0e10cSrcweir 
855cdf0e10cSrcweir 			OUString sOldName( GetName() );
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 			const String& rNewTabName = pFrmFmt->GetName();
858cdf0e10cSrcweir 			OUStringBuffer aBuffer( rNewTabName.Len() + 4 );
859cdf0e10cSrcweir 			aBuffer.append( OUString(rNewTabName) );
860cdf0e10cSrcweir 			aBuffer.append( static_cast<sal_Unicode>( '-' ) );
861cdf0e10cSrcweir 			aBuffer.append( static_cast<sal_Int32>( pTabFrm->GetPhyPageNum() ) );
862cdf0e10cSrcweir 
863cdf0e10cSrcweir 			SetName( aBuffer.makeStringAndClear() );
864cdf0e10cSrcweir 			if( sOldName != GetName() )
865cdf0e10cSrcweir 			{
866cdf0e10cSrcweir 				AccessibleEventObject aEvent;
867cdf0e10cSrcweir 				aEvent.EventId = AccessibleEventId::NAME_CHANGED;
868cdf0e10cSrcweir 				aEvent.OldValue <<= sOldName;
869cdf0e10cSrcweir 				aEvent.NewValue <<= GetName();
870cdf0e10cSrcweir 				FireAccessibleEvent( aEvent );
871cdf0e10cSrcweir 			}
872cdf0e10cSrcweir 
873cdf0e10cSrcweir 			OUString sOldDesc( sDesc );
874cdf0e10cSrcweir 			OUString sArg1( rNewTabName );
875cdf0e10cSrcweir 			OUString sArg2( GetFormattedPageNumber() );
876cdf0e10cSrcweir 
877cdf0e10cSrcweir 			sDesc = GetResource( STR_ACCESS_TABLE_DESC, &sArg1, &sArg2 );
878cdf0e10cSrcweir 			if( sDesc != sOldDesc )
879cdf0e10cSrcweir 			{
880cdf0e10cSrcweir 				AccessibleEventObject aEvent;
881cdf0e10cSrcweir 				aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED;
882cdf0e10cSrcweir 				aEvent.OldValue <<= sOldDesc;
883cdf0e10cSrcweir 				aEvent.NewValue <<= sDesc;
884cdf0e10cSrcweir 				FireAccessibleEvent( aEvent );
885cdf0e10cSrcweir 			}
886cdf0e10cSrcweir 		}
887cdf0e10cSrcweir 		break;
888cdf0e10cSrcweir 
889cdf0e10cSrcweir 	case RES_OBJECTDYING:
890cdf0e10cSrcweir         // mba: it seems that this class intentionally does not call code in base class SwClient
891ca62e2c2SSteve Yin 		if( pOld && ( GetRegisteredIn() == static_cast< SwModify *>( static_cast< const SwPtrMsgPoolItem * >( pOld )->pObject ) ) )
892cdf0e10cSrcweir 			GetRegisteredInNonConst()->Remove( this );
893cdf0e10cSrcweir 		break;
894cdf0e10cSrcweir 
895cdf0e10cSrcweir 	default:
896cdf0e10cSrcweir         // mba: former call to base class method removed as it is meant to handle only RES_OBJECTDYING
897cdf0e10cSrcweir 		break;
898cdf0e10cSrcweir 	}
899cdf0e10cSrcweir }
900cdf0e10cSrcweir 
queryInterface(const uno::Type & rType)901cdf0e10cSrcweir uno::Any SwAccessibleTable::queryInterface( const uno::Type& rType )
902cdf0e10cSrcweir     throw (uno::RuntimeException)
903cdf0e10cSrcweir {
904cdf0e10cSrcweir     uno::Any aRet;
905cdf0e10cSrcweir     if ( rType == ::getCppuType( static_cast< uno::Reference< XAccessibleTable > * >( 0 ) ) )
906cdf0e10cSrcweir     {
907cdf0e10cSrcweir         uno::Reference<XAccessibleTable> xThis( this );
908cdf0e10cSrcweir        	aRet <<= xThis;
909cdf0e10cSrcweir     }
910cdf0e10cSrcweir     else if ( rType == ::getCppuType( static_cast< uno::Reference< XAccessibleSelection > * >( 0 ) ) )
911cdf0e10cSrcweir     {
912cdf0e10cSrcweir         uno::Reference<XAccessibleSelection> xSelection( this );
913cdf0e10cSrcweir         aRet <<= xSelection;
914cdf0e10cSrcweir     }
915ca62e2c2SSteve Yin 	else if ( rType == ::getCppuType((uno::Reference<XAccessibleTableSelection> *)0) )
916ca62e2c2SSteve Yin     {
917ca62e2c2SSteve Yin 		uno::Reference<XAccessibleTableSelection> xTableExtent( this );
918ca62e2c2SSteve Yin         aRet <<= xTableExtent;
919ca62e2c2SSteve Yin     }
920cdf0e10cSrcweir     else
921cdf0e10cSrcweir     {
922cdf0e10cSrcweir         aRet = SwAccessibleContext::queryInterface(rType);
923cdf0e10cSrcweir     }
924cdf0e10cSrcweir 
925cdf0e10cSrcweir     return aRet;
926cdf0e10cSrcweir }
927cdf0e10cSrcweir 
928cdf0e10cSrcweir //====== XTypeProvider ====================================================
getTypes()929cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL SwAccessibleTable::getTypes()
930cdf0e10cSrcweir     throw(uno::RuntimeException)
931cdf0e10cSrcweir {
932cdf0e10cSrcweir 	uno::Sequence< uno::Type > aTypes( SwAccessibleContext::getTypes() );
933cdf0e10cSrcweir 
934cdf0e10cSrcweir 	sal_Int32 nIndex = aTypes.getLength();
935cdf0e10cSrcweir 	aTypes.realloc( nIndex + 2 );
936cdf0e10cSrcweir 
937cdf0e10cSrcweir 	uno::Type* pTypes = aTypes.getArray();
938cdf0e10cSrcweir 	pTypes[nIndex++] = ::getCppuType( static_cast< uno::Reference< XAccessibleSelection > * >( 0 ) );
939cdf0e10cSrcweir 	pTypes[nIndex++] = ::getCppuType( static_cast< uno::Reference< XAccessibleTable > * >( 0 ) );
940cdf0e10cSrcweir 
941cdf0e10cSrcweir 	return aTypes;
942cdf0e10cSrcweir }
943cdf0e10cSrcweir 
getImplementationId()944cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleTable::getImplementationId()
945cdf0e10cSrcweir 		throw(uno::RuntimeException)
946cdf0e10cSrcweir {
947cdf0e10cSrcweir     vos::OGuard aGuard(Application::GetSolarMutex());
948cdf0e10cSrcweir     static uno::Sequence< sal_Int8 > aId( 16 );
949cdf0e10cSrcweir     static sal_Bool bInit = sal_False;
950cdf0e10cSrcweir     if(!bInit)
951cdf0e10cSrcweir     {
952cdf0e10cSrcweir         rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
953cdf0e10cSrcweir         bInit = sal_True;
954cdf0e10cSrcweir     }
955cdf0e10cSrcweir     return aId;
956cdf0e10cSrcweir }
957cdf0e10cSrcweir 
958cdf0e10cSrcweir // --> OD 2007-06-28 #i77106#
CreateNewTableData()959cdf0e10cSrcweir SwAccessibleTableData_Impl* SwAccessibleTable::CreateNewTableData()
960cdf0e10cSrcweir {
961cdf0e10cSrcweir     const SwTabFrm* pTabFrm = static_cast<const SwTabFrm*>( GetFrm() );
962cdf0e10cSrcweir     return new SwAccessibleTableData_Impl( *GetMap(), pTabFrm, IsInPagePreview() );
963cdf0e10cSrcweir }
964cdf0e10cSrcweir // <--
965cdf0e10cSrcweir 
UpdateTableData()966cdf0e10cSrcweir void SwAccessibleTable::UpdateTableData()
967cdf0e10cSrcweir {
968cdf0e10cSrcweir     // --> OD 2007-06-28 #i77106# - usage of new method <CreateNewTableData()>
969cdf0e10cSrcweir     delete mpTableData;
970cdf0e10cSrcweir     mpTableData = CreateNewTableData();
971cdf0e10cSrcweir     // <--
972cdf0e10cSrcweir }
973cdf0e10cSrcweir 
ClearTableData()974cdf0e10cSrcweir void SwAccessibleTable::ClearTableData()
975cdf0e10cSrcweir {
976cdf0e10cSrcweir 	delete mpTableData;
977cdf0e10cSrcweir 	mpTableData = 0;
978cdf0e10cSrcweir }
979cdf0e10cSrcweir 
getAccessibleDescription(void)980cdf0e10cSrcweir OUString SAL_CALL SwAccessibleTable::getAccessibleDescription (void)
981cdf0e10cSrcweir         throw (uno::RuntimeException)
982cdf0e10cSrcweir {
983cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
984cdf0e10cSrcweir 
985cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleContext )
986cdf0e10cSrcweir 
987cdf0e10cSrcweir 	return sDesc;
988cdf0e10cSrcweir }
989cdf0e10cSrcweir 
getAccessibleRowCount()990cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleRowCount()
991cdf0e10cSrcweir 	throw (uno::RuntimeException)
992cdf0e10cSrcweir {
993cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
994cdf0e10cSrcweir 
995cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
996cdf0e10cSrcweir 
997cdf0e10cSrcweir 	return  GetTableData().GetRowCount();
998cdf0e10cSrcweir }
999cdf0e10cSrcweir 
getAccessibleColumnCount()1000cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleColumnCount(  )
1001cdf0e10cSrcweir 	throw (uno::RuntimeException)
1002cdf0e10cSrcweir {
1003cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1004cdf0e10cSrcweir 
1005cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir 	return GetTableData().GetColumnCount();
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir 
getAccessibleRowDescription(sal_Int32 nRow)1010cdf0e10cSrcweir OUString SAL_CALL SwAccessibleTable::getAccessibleRowDescription(
1011cdf0e10cSrcweir 			sal_Int32 nRow )
1012cdf0e10cSrcweir 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir     // --> OD 2010-03-10 #i87532#
1015cdf0e10cSrcweir     // determine table cell in <nRow>th row and in first column of row header table
1016cdf0e10cSrcweir     // and return its text content.
1017cdf0e10cSrcweir     OUString sRowDesc;
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir     GetTableData().CheckRowAndCol(nRow, 0, this);
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir     uno::Reference< XAccessibleTable > xTableRowHeader = getAccessibleRowHeaders();
1022cdf0e10cSrcweir     if ( xTableRowHeader.is() )
1023cdf0e10cSrcweir     {
1024cdf0e10cSrcweir         uno::Reference< XAccessible > xRowHeaderCell =
1025cdf0e10cSrcweir                         xTableRowHeader->getAccessibleCellAt( nRow, 0 );
1026cdf0e10cSrcweir         ASSERT( xRowHeaderCell.is(),
1027cdf0e10cSrcweir                 "<SwAccessibleTable::getAccessibleRowDescription(..)> - missing row header cell -> serious issue." );
1028cdf0e10cSrcweir         uno::Reference< XAccessibleContext > xRowHeaderCellContext =
1029cdf0e10cSrcweir                                     xRowHeaderCell->getAccessibleContext();
1030cdf0e10cSrcweir         const sal_Int32 nCellChildCount( xRowHeaderCellContext->getAccessibleChildCount() );
1031cdf0e10cSrcweir         for ( sal_Int32 nChildIndex = 0; nChildIndex < nCellChildCount; ++nChildIndex )
1032cdf0e10cSrcweir         {
1033cdf0e10cSrcweir             uno::Reference< XAccessible > xChild = xRowHeaderCellContext->getAccessibleChild( nChildIndex );
1034cdf0e10cSrcweir             uno::Reference< XAccessibleText > xChildText( xChild, uno::UNO_QUERY );
1035cdf0e10cSrcweir             if ( xChildText.is() )
1036cdf0e10cSrcweir             {
1037cdf0e10cSrcweir                 sRowDesc = sRowDesc + xChildText->getText();
1038cdf0e10cSrcweir             }
1039cdf0e10cSrcweir         }
1040cdf0e10cSrcweir     }
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir     return sRowDesc;
1043cdf0e10cSrcweir     // <--
1044cdf0e10cSrcweir }
1045cdf0e10cSrcweir 
getAccessibleColumnDescription(sal_Int32 nColumn)1046cdf0e10cSrcweir OUString SAL_CALL SwAccessibleTable::getAccessibleColumnDescription(
1047cdf0e10cSrcweir 			sal_Int32 nColumn )
1048cdf0e10cSrcweir 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1049cdf0e10cSrcweir {
1050cdf0e10cSrcweir     // --> OD 2010-03-10 #i87532#
1051cdf0e10cSrcweir     // determine table cell in first row and in <nColumn>th column of column header table
1052cdf0e10cSrcweir     // and return its text content.
1053cdf0e10cSrcweir     OUString sColumnDesc;
1054cdf0e10cSrcweir 
1055cdf0e10cSrcweir     GetTableData().CheckRowAndCol(0, nColumn, this);
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir     uno::Reference< XAccessibleTable > xTableColumnHeader = getAccessibleColumnHeaders();
1058cdf0e10cSrcweir     if ( xTableColumnHeader.is() )
1059cdf0e10cSrcweir     {
1060cdf0e10cSrcweir         uno::Reference< XAccessible > xColumnHeaderCell =
1061cdf0e10cSrcweir                         xTableColumnHeader->getAccessibleCellAt( 0, nColumn );
1062cdf0e10cSrcweir         ASSERT( xColumnHeaderCell.is(),
1063cdf0e10cSrcweir                 "<SwAccessibleTable::getAccessibleColumnDescription(..)> - missing column header cell -> serious issue." );
1064cdf0e10cSrcweir         uno::Reference< XAccessibleContext > xColumnHeaderCellContext =
1065cdf0e10cSrcweir                                     xColumnHeaderCell->getAccessibleContext();
1066cdf0e10cSrcweir         const sal_Int32 nCellChildCount( xColumnHeaderCellContext->getAccessibleChildCount() );
1067cdf0e10cSrcweir         for ( sal_Int32 nChildIndex = 0; nChildIndex < nCellChildCount; ++nChildIndex )
1068cdf0e10cSrcweir         {
1069cdf0e10cSrcweir             uno::Reference< XAccessible > xChild = xColumnHeaderCellContext->getAccessibleChild( nChildIndex );
1070cdf0e10cSrcweir             uno::Reference< XAccessibleText > xChildText( xChild, uno::UNO_QUERY );
1071cdf0e10cSrcweir             if ( xChildText.is() )
1072cdf0e10cSrcweir             {
1073cdf0e10cSrcweir                 sColumnDesc = sColumnDesc + xChildText->getText();
1074cdf0e10cSrcweir             }
1075cdf0e10cSrcweir         }
1076cdf0e10cSrcweir     }
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir     return sColumnDesc;
1079cdf0e10cSrcweir     // <--
1080cdf0e10cSrcweir }
1081cdf0e10cSrcweir 
getAccessibleRowExtentAt(sal_Int32 nRow,sal_Int32 nColumn)1082cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleRowExtentAt(
1083cdf0e10cSrcweir 			sal_Int32 nRow, sal_Int32 nColumn )
1084cdf0e10cSrcweir 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1085cdf0e10cSrcweir {
1086cdf0e10cSrcweir 	sal_Int32 nExtend = -1;
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
1091cdf0e10cSrcweir 
1092ca62e2c2SSteve Yin 	UpdateTableData();
1093cdf0e10cSrcweir 	GetTableData().CheckRowAndCol( nRow, nColumn, this );
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir 	Int32Set_Impl::const_iterator aSttCol(
1096cdf0e10cSrcweir 									GetTableData().GetColumnIter( nColumn ) );
1097cdf0e10cSrcweir 	Int32Set_Impl::const_iterator aSttRow(
1098cdf0e10cSrcweir 									GetTableData().GetRowIter( nRow ) );
1099cdf0e10cSrcweir 	const SwFrm *pCellFrm = GetTableData().GetCellAtPos( *aSttCol, *aSttRow,
1100cdf0e10cSrcweir 														 sal_False );
1101cdf0e10cSrcweir 	if( pCellFrm )
1102cdf0e10cSrcweir 	{
1103cdf0e10cSrcweir 		sal_Int32 nBottom = pCellFrm->Frm().Bottom();
1104cdf0e10cSrcweir 		nBottom -= GetFrm()->Frm().Top();
1105cdf0e10cSrcweir 		Int32Set_Impl::const_iterator aEndRow(
1106cdf0e10cSrcweir 				GetTableData().GetRows().upper_bound( nBottom ) );
1107cdf0e10cSrcweir 		nExtend =
1108cdf0e10cSrcweir 			 static_cast< sal_Int32 >( ::std::distance( aSttRow, aEndRow ) );
1109cdf0e10cSrcweir 	}
1110cdf0e10cSrcweir 
1111cdf0e10cSrcweir 	return nExtend;
1112cdf0e10cSrcweir }
1113cdf0e10cSrcweir 
getAccessibleColumnExtentAt(sal_Int32 nRow,sal_Int32 nColumn)1114cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleColumnExtentAt(
1115cdf0e10cSrcweir 		   	sal_Int32 nRow, sal_Int32 nColumn )
1116cdf0e10cSrcweir 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1117cdf0e10cSrcweir {
1118cdf0e10cSrcweir 	sal_Int32 nExtend = -1;
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
1123ca62e2c2SSteve Yin 	UpdateTableData();
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir 	GetTableData().CheckRowAndCol( nRow, nColumn, this );
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir 	Int32Set_Impl::const_iterator aSttCol(
1128cdf0e10cSrcweir 									GetTableData().GetColumnIter( nColumn ) );
1129cdf0e10cSrcweir 	Int32Set_Impl::const_iterator aSttRow(
1130cdf0e10cSrcweir 									GetTableData().GetRowIter( nRow ) );
1131cdf0e10cSrcweir 	const SwFrm *pCellFrm = GetTableData().GetCellAtPos( *aSttCol, *aSttRow,
1132cdf0e10cSrcweir 														 sal_False );
1133cdf0e10cSrcweir 	if( pCellFrm )
1134cdf0e10cSrcweir 	{
1135cdf0e10cSrcweir 		sal_Int32 nRight = pCellFrm->Frm().Right();
1136cdf0e10cSrcweir 		nRight -= GetFrm()->Frm().Left();
1137cdf0e10cSrcweir 		Int32Set_Impl::const_iterator aEndCol(
1138cdf0e10cSrcweir 				GetTableData().GetColumns().upper_bound( nRight ) );
1139cdf0e10cSrcweir 		nExtend =
1140cdf0e10cSrcweir 			 static_cast< sal_Int32 >( ::std::distance( aSttCol, aEndCol ) );
1141cdf0e10cSrcweir 	}
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir 	return nExtend;
1144cdf0e10cSrcweir }
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir uno::Reference< XAccessibleTable > SAL_CALL
getAccessibleRowHeaders()1147cdf0e10cSrcweir 		SwAccessibleTable::getAccessibleRowHeaders(  )
1148cdf0e10cSrcweir 	throw (uno::RuntimeException)
1149cdf0e10cSrcweir {
1150cdf0e10cSrcweir     // Row headers aren't supported
1151cdf0e10cSrcweir 	return uno::Reference< XAccessibleTable >();
1152cdf0e10cSrcweir }
1153cdf0e10cSrcweir 
1154cdf0e10cSrcweir uno::Reference< XAccessibleTable > SAL_CALL
getAccessibleColumnHeaders()1155cdf0e10cSrcweir 		SwAccessibleTable::getAccessibleColumnHeaders(  )
1156cdf0e10cSrcweir 	throw (uno::RuntimeException)
1157cdf0e10cSrcweir {
1158ca62e2c2SSteve Yin // MT IA2: Which one should win nowadys???
1159ca62e2c2SSteve Yin /*
1160ca62e2c2SSteve Yin     // IA2 version:
1161ca62e2c2SSteve Yin 	uno::Reference< XAccessibleTable > xRet;
1162ca62e2c2SSteve Yin 	SwTabFrm* pTabFrm =( SwTabFrm*)( GetFrm() );
1163ca62e2c2SSteve Yin 	if (pTabFrm)
1164ca62e2c2SSteve Yin 	{
1165ca62e2c2SSteve Yin 		if(pTabFrm->GetTable()->_GetRowsToRepeat() > 0)
1166ca62e2c2SSteve Yin 		{
1167ca62e2c2SSteve Yin 			//for errata table header
1168ca62e2c2SSteve Yin 			SwAccessibleTableData_Impl *mpHeadTableData = new SwAccessibleTableData_Impl( pTabFrm, sal_False, sal_True);
11690deba7fbSSteve Yin 			//for errata table header
1170ca62e2c2SSteve Yin 			SwAccessibleTable *pHeadAccessibleTable = new SwAccessibleTable(GetMap(),pTabFrm);
1171ca62e2c2SSteve Yin 			pHeadAccessibleTable->SetTableData(mpHeadTableData);
1172ca62e2c2SSteve Yin 			xRet = pHeadAccessibleTable;
1173ca62e2c2SSteve Yin 		}
1174ca62e2c2SSteve Yin 	}
1175ca62e2c2SSteve Yin 	return xRet;
1176ca62e2c2SSteve Yin */
1177cdf0e10cSrcweir     // --> OD 2010-03-10 #i87532#
1178cdf0e10cSrcweir     // assure that return accesible object is empty, if no column header exists.
1179cdf0e10cSrcweir     SwAccessibleTableColHeaders* pTableColHeaders =
1180cdf0e10cSrcweir         new SwAccessibleTableColHeaders( GetMap(), static_cast< const SwTabFrm *>( GetFrm() ) );
1181cdf0e10cSrcweir     uno::Reference< XAccessibleTable > xTableColumnHeaders( pTableColHeaders );
1182cdf0e10cSrcweir     if ( pTableColHeaders->getAccessibleChildCount() <= 0 )
1183cdf0e10cSrcweir     {
1184cdf0e10cSrcweir         return uno::Reference< XAccessibleTable >();
1185cdf0e10cSrcweir     }
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir     return xTableColumnHeaders;
1188cdf0e10cSrcweir     // <--
1189cdf0e10cSrcweir }
1190cdf0e10cSrcweir 
getSelectedAccessibleRows()1191cdf0e10cSrcweir uno::Sequence< sal_Int32 > SAL_CALL SwAccessibleTable::getSelectedAccessibleRows()
1192cdf0e10cSrcweir 	throw (uno::RuntimeException)
1193cdf0e10cSrcweir {
1194cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1195cdf0e10cSrcweir 
1196cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
1197cdf0e10cSrcweir 
1198cdf0e10cSrcweir 	const SwSelBoxes *pSelBoxes = GetSelBoxes();
1199cdf0e10cSrcweir 	if( pSelBoxes )
1200cdf0e10cSrcweir 	{
1201cdf0e10cSrcweir 		sal_Int32 nRows = GetTableData().GetRowCount();
1202cdf0e10cSrcweir 		SwAccAllTableSelHander_Impl aSelRows( nRows  );
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir 		GetTableData().GetSelection( 0, nRows, *pSelBoxes, aSelRows,
1205cdf0e10cSrcweir 								 	 sal_False );
1206cdf0e10cSrcweir 
1207cdf0e10cSrcweir 		return aSelRows.GetSelSequence();
1208cdf0e10cSrcweir 	}
1209cdf0e10cSrcweir 	else
1210cdf0e10cSrcweir 	{
1211cdf0e10cSrcweir 		return uno::Sequence< sal_Int32 >( 0 );
1212cdf0e10cSrcweir 	}
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir 
getSelectedAccessibleColumns()1215cdf0e10cSrcweir uno::Sequence< sal_Int32 > SAL_CALL SwAccessibleTable::getSelectedAccessibleColumns()
1216cdf0e10cSrcweir 	throw (uno::RuntimeException)
1217cdf0e10cSrcweir {
1218cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1219cdf0e10cSrcweir 
1220cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir 	const SwSelBoxes *pSelBoxes = GetSelBoxes();
1223cdf0e10cSrcweir 	if( pSelBoxes )
1224cdf0e10cSrcweir 	{
1225cdf0e10cSrcweir 		sal_Int32 nCols = GetTableData().GetColumnCount();
1226cdf0e10cSrcweir 		SwAccAllTableSelHander_Impl aSelCols( nCols );
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir 		GetTableData().GetSelection( 0, nCols, *pSelBoxes, aSelCols, sal_True );
1229cdf0e10cSrcweir 
1230cdf0e10cSrcweir 		return aSelCols.GetSelSequence();
1231cdf0e10cSrcweir 	}
1232cdf0e10cSrcweir 	else
1233cdf0e10cSrcweir 	{
1234cdf0e10cSrcweir 		return uno::Sequence< sal_Int32 >( 0 );
1235cdf0e10cSrcweir 	}
1236cdf0e10cSrcweir }
1237cdf0e10cSrcweir 
isAccessibleRowSelected(sal_Int32 nRow)1238cdf0e10cSrcweir sal_Bool SAL_CALL SwAccessibleTable::isAccessibleRowSelected( sal_Int32 nRow )
1239cdf0e10cSrcweir 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1240cdf0e10cSrcweir {
1241cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
1244cdf0e10cSrcweir 
1245cdf0e10cSrcweir 	GetTableData().CheckRowAndCol( nRow, 0, this );
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir 	sal_Bool bRet;
1248cdf0e10cSrcweir 	const SwSelBoxes *pSelBoxes = GetSelBoxes();
1249cdf0e10cSrcweir 	if( pSelBoxes )
1250cdf0e10cSrcweir 	{
1251cdf0e10cSrcweir 		SwAccSingleTableSelHander_Impl aSelRow;
1252cdf0e10cSrcweir 		GetTableData().GetSelection( nRow, nRow+1, *pSelBoxes, aSelRow,
1253cdf0e10cSrcweir 									 sal_False );
1254cdf0e10cSrcweir 		bRet = aSelRow.IsSelected();
1255cdf0e10cSrcweir 	}
1256cdf0e10cSrcweir 	else
1257cdf0e10cSrcweir 	{
1258cdf0e10cSrcweir 		bRet = sal_False;
1259cdf0e10cSrcweir 	}
1260cdf0e10cSrcweir 
1261cdf0e10cSrcweir 	return bRet;
1262cdf0e10cSrcweir }
1263cdf0e10cSrcweir 
isAccessibleColumnSelected(sal_Int32 nColumn)1264cdf0e10cSrcweir sal_Bool SAL_CALL SwAccessibleTable::isAccessibleColumnSelected(
1265cdf0e10cSrcweir 		sal_Int32 nColumn )
1266cdf0e10cSrcweir 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1267cdf0e10cSrcweir {
1268cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1269cdf0e10cSrcweir 
1270cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir 	GetTableData().CheckRowAndCol( 0, nColumn, this );
1273cdf0e10cSrcweir 
1274cdf0e10cSrcweir 	sal_Bool bRet;
1275cdf0e10cSrcweir 	const SwSelBoxes *pSelBoxes = GetSelBoxes();
1276cdf0e10cSrcweir 	if( pSelBoxes )
1277cdf0e10cSrcweir 	{
1278cdf0e10cSrcweir 		SwAccSingleTableSelHander_Impl aSelCol;
1279cdf0e10cSrcweir 
1280cdf0e10cSrcweir 		GetTableData().GetSelection( nColumn, nColumn+1, *pSelBoxes, aSelCol,
1281cdf0e10cSrcweir 									 sal_True );
1282cdf0e10cSrcweir 		bRet = aSelCol.IsSelected();
1283cdf0e10cSrcweir 	}
1284cdf0e10cSrcweir 	else
1285cdf0e10cSrcweir 	{
1286cdf0e10cSrcweir 		bRet = sal_False;
1287cdf0e10cSrcweir 	}
1288cdf0e10cSrcweir 
1289cdf0e10cSrcweir 	return bRet;
1290cdf0e10cSrcweir }
1291cdf0e10cSrcweir 
getAccessibleCellAt(sal_Int32 nRow,sal_Int32 nColumn)1292cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL SwAccessibleTable::getAccessibleCellAt(
1293cdf0e10cSrcweir 		sal_Int32 nRow, sal_Int32 nColumn )
1294cdf0e10cSrcweir 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1295cdf0e10cSrcweir {
1296cdf0e10cSrcweir 	uno::Reference< XAccessible > xRet;
1297cdf0e10cSrcweir 
1298cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1299cdf0e10cSrcweir 
1300cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
1301cdf0e10cSrcweir 
1302cdf0e10cSrcweir 	const SwFrm *pCellFrm =
1303cdf0e10cSrcweir 					GetTableData().GetCell( nRow, nColumn, sal_False, this );
1304cdf0e10cSrcweir 	if( pCellFrm )
1305cdf0e10cSrcweir 		xRet = GetMap()->GetContext( pCellFrm, sal_True );
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir 	return xRet;
1308cdf0e10cSrcweir }
1309cdf0e10cSrcweir 
getAccessibleCaption()1310cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL SwAccessibleTable::getAccessibleCaption()
1311cdf0e10cSrcweir 	throw (uno::RuntimeException)
1312cdf0e10cSrcweir {
1313cdf0e10cSrcweir 	// captions aren't supported
1314cdf0e10cSrcweir 	return uno::Reference< XAccessible >();
1315cdf0e10cSrcweir }
1316cdf0e10cSrcweir 
getAccessibleSummary()1317cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL SwAccessibleTable::getAccessibleSummary()
1318cdf0e10cSrcweir 	throw (uno::RuntimeException)
1319cdf0e10cSrcweir {
1320cdf0e10cSrcweir 	// summaries aren't supported
1321cdf0e10cSrcweir 	return uno::Reference< XAccessible >();
1322cdf0e10cSrcweir }
1323cdf0e10cSrcweir 
isAccessibleSelected(sal_Int32 nRow,sal_Int32 nColumn)1324cdf0e10cSrcweir sal_Bool SAL_CALL SwAccessibleTable::isAccessibleSelected(
1325cdf0e10cSrcweir 			sal_Int32 nRow, sal_Int32 nColumn )
1326cdf0e10cSrcweir 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1327cdf0e10cSrcweir {
1328cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1329cdf0e10cSrcweir 
1330cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1331cdf0e10cSrcweir 
1332cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
1333cdf0e10cSrcweir 
1334cdf0e10cSrcweir 	const SwFrm *pFrm =
1335cdf0e10cSrcweir 					GetTableData().GetCell( nRow, nColumn, sal_False, this );
1336cdf0e10cSrcweir 	if( pFrm && pFrm->IsCellFrm() )
1337cdf0e10cSrcweir 	{
1338cdf0e10cSrcweir 		const SwSelBoxes *pSelBoxes = GetSelBoxes();
1339cdf0e10cSrcweir 		if( pSelBoxes )
1340cdf0e10cSrcweir 		{
1341cdf0e10cSrcweir 			const SwCellFrm *pCFrm = static_cast < const SwCellFrm * >( pFrm );
1342cdf0e10cSrcweir 			SwTableBox *pBox =
1343cdf0e10cSrcweir 				const_cast< SwTableBox *>( pCFrm->GetTabBox() ); //SVPtrArr!
1344cdf0e10cSrcweir 			bRet = pSelBoxes->Seek_Entry( pBox );
1345cdf0e10cSrcweir 		}
1346cdf0e10cSrcweir 	}
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir 	return bRet;
1349cdf0e10cSrcweir }
1350cdf0e10cSrcweir 
getAccessibleIndex(sal_Int32 nRow,sal_Int32 nColumn)1351cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleIndex(
1352cdf0e10cSrcweir 			sal_Int32 nRow, sal_Int32 nColumn )
1353cdf0e10cSrcweir 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir 	sal_Int32 nRet = -1;
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1358cdf0e10cSrcweir 
1359cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
1360cdf0e10cSrcweir 
1361cdf0e10cSrcweir     SwAccessibleChild aCell( GetTableData().GetCell( nRow, nColumn, sal_False, this ));
1362cdf0e10cSrcweir     if ( aCell.IsValid() )
1363cdf0e10cSrcweir     {
1364cdf0e10cSrcweir         nRet = GetChildIndex( *(GetMap()), aCell );
1365cdf0e10cSrcweir     }
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir 	return nRet;
1368cdf0e10cSrcweir }
1369cdf0e10cSrcweir 
getAccessibleRow(sal_Int32 nChildIndex)1370cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleRow( sal_Int32 nChildIndex )
1371cdf0e10cSrcweir 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1372cdf0e10cSrcweir {
1373cdf0e10cSrcweir 	sal_Int32 nRet = -1;
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
1378cdf0e10cSrcweir 
1379cdf0e10cSrcweir     // --> OD 2007-06-27 #i77106#
1380cdf0e10cSrcweir     if ( ( nChildIndex < 0 ) ||
1381cdf0e10cSrcweir          ( nChildIndex >= getAccessibleChildCount() ) )
1382cdf0e10cSrcweir     {
1383cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
1384cdf0e10cSrcweir     }
1385cdf0e10cSrcweir     // <--
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir     SwAccessibleChild aCell( GetChild( *(GetMap()), nChildIndex ) );
1388cdf0e10cSrcweir     if ( aCell.GetSwFrm()  )
1389cdf0e10cSrcweir 	{
1390cdf0e10cSrcweir 		sal_Int32 nTop = aCell.GetSwFrm()->Frm().Top();
1391cdf0e10cSrcweir 		nTop -= GetFrm()->Frm().Top();
1392cdf0e10cSrcweir 		Int32Set_Impl::const_iterator aRow(
1393cdf0e10cSrcweir 				GetTableData().GetRows().lower_bound( nTop ) );
1394cdf0e10cSrcweir 		nRet = static_cast< sal_Int32 >( ::std::distance(
1395cdf0e10cSrcweir 					GetTableData().GetRows().begin(), aRow ) );
1396cdf0e10cSrcweir 	}
1397cdf0e10cSrcweir     else
1398cdf0e10cSrcweir     {
1399cdf0e10cSrcweir         ASSERT( !aCell.IsValid(), "SwAccessibleTable::getAccessibleColumn:"
1400cdf0e10cSrcweir                 "aCell not expected to be valid.");
1401cdf0e10cSrcweir 
1402cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
1403cdf0e10cSrcweir     }
1404cdf0e10cSrcweir 
1405cdf0e10cSrcweir 	return nRet;
1406cdf0e10cSrcweir }
1407cdf0e10cSrcweir 
getAccessibleColumn(sal_Int32 nChildIndex)1408cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleTable::getAccessibleColumn(
1409cdf0e10cSrcweir 		sal_Int32 nChildIndex )
1410cdf0e10cSrcweir 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1411cdf0e10cSrcweir {
1412cdf0e10cSrcweir 	sal_Int32 nRet = -1;
1413cdf0e10cSrcweir 
1414cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1415cdf0e10cSrcweir 
1416cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable )
1417cdf0e10cSrcweir 
1418cdf0e10cSrcweir     // --> OD 2007-06-27 #i77106#
1419cdf0e10cSrcweir     if ( ( nChildIndex < 0 ) ||
1420cdf0e10cSrcweir          ( nChildIndex >= getAccessibleChildCount() ) )
1421cdf0e10cSrcweir     {
1422cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
1423cdf0e10cSrcweir     }
1424cdf0e10cSrcweir     // <--
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir     SwAccessibleChild aCell( GetChild( *(GetMap()), nChildIndex ) );
1427cdf0e10cSrcweir     if ( aCell.GetSwFrm()  )
1428cdf0e10cSrcweir 	{
1429cdf0e10cSrcweir 		sal_Int32 nLeft = aCell.GetSwFrm()->Frm().Left();
1430cdf0e10cSrcweir 		nLeft -= GetFrm()->Frm().Left();
1431cdf0e10cSrcweir 		Int32Set_Impl::const_iterator aCol(
1432cdf0e10cSrcweir 				GetTableData().GetColumns().lower_bound( nLeft ) );
1433cdf0e10cSrcweir 		nRet = static_cast< sal_Int32 >( ::std::distance(
1434cdf0e10cSrcweir 					GetTableData().GetColumns().begin(), aCol ) );
1435cdf0e10cSrcweir 	}
1436cdf0e10cSrcweir     else
1437cdf0e10cSrcweir     {
1438cdf0e10cSrcweir         ASSERT( !aCell.IsValid(), "SwAccessibleTable::getAccessibleColumn:"
1439cdf0e10cSrcweir                 "aCell not expected to be valid.");
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
1442cdf0e10cSrcweir     }
1443cdf0e10cSrcweir 
1444cdf0e10cSrcweir 	return nRet;
1445cdf0e10cSrcweir }
1446cdf0e10cSrcweir 
1447cdf0e10cSrcweir 
getImplementationName()1448cdf0e10cSrcweir OUString SAL_CALL SwAccessibleTable::getImplementationName()
1449cdf0e10cSrcweir         throw( uno::RuntimeException )
1450cdf0e10cSrcweir {
1451cdf0e10cSrcweir 	return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationName));
1452cdf0e10cSrcweir }
1453cdf0e10cSrcweir 
supportsService(const OUString & sTestServiceName)1454cdf0e10cSrcweir sal_Bool SAL_CALL SwAccessibleTable::supportsService(
1455cdf0e10cSrcweir 		const OUString& sTestServiceName)
1456cdf0e10cSrcweir 	throw (uno::RuntimeException)
1457cdf0e10cSrcweir {
1458cdf0e10cSrcweir 	return sTestServiceName.equalsAsciiL( sServiceName,
1459cdf0e10cSrcweir 										  sizeof(sServiceName)-1 ) ||
1460cdf0e10cSrcweir 		   sTestServiceName.equalsAsciiL( sAccessibleServiceName,
1461cdf0e10cSrcweir 				   						  sizeof(sAccessibleServiceName)-1 );
1462cdf0e10cSrcweir }
1463cdf0e10cSrcweir 
getSupportedServiceNames()1464cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SwAccessibleTable::getSupportedServiceNames()
1465cdf0e10cSrcweir 		throw( uno::RuntimeException )
1466cdf0e10cSrcweir {
1467cdf0e10cSrcweir 	uno::Sequence< OUString > aRet(2);
1468cdf0e10cSrcweir 	OUString* pArray = aRet.getArray();
1469cdf0e10cSrcweir 	pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceName) );
1470cdf0e10cSrcweir 	pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) );
1471cdf0e10cSrcweir 	return aRet;
1472cdf0e10cSrcweir }
1473cdf0e10cSrcweir 
InvalidatePosOrSize(const SwRect & rOldBox)1474cdf0e10cSrcweir void SwAccessibleTable::InvalidatePosOrSize( const SwRect& rOldBox )
1475cdf0e10cSrcweir {
1476cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1477cdf0e10cSrcweir 
1478ca62e2c2SSteve Yin 	//need to update children
1479ca62e2c2SSteve Yin 	SwAccessibleTableData_Impl *pNewTableData = CreateNewTableData();
1480ca62e2c2SSteve Yin 	if( !pNewTableData->CompareExtents( GetTableData() ) )
1481ca62e2c2SSteve Yin 	{
1482ca62e2c2SSteve Yin 		delete mpTableData;
1483ca62e2c2SSteve Yin 		mpTableData = pNewTableData;
1484ca62e2c2SSteve Yin 		FireTableChangeEvent(*mpTableData);
1485ca62e2c2SSteve Yin 	}
1486cdf0e10cSrcweir 	if( HasTableData() )
1487cdf0e10cSrcweir 		GetTableData().SetTablePos( GetFrm()->Frm().Pos() );
1488cdf0e10cSrcweir 
1489cdf0e10cSrcweir 	SwAccessibleContext::InvalidatePosOrSize( rOldBox );
1490cdf0e10cSrcweir }
1491cdf0e10cSrcweir 
Dispose(sal_Bool bRecursive)1492cdf0e10cSrcweir void SwAccessibleTable::Dispose( sal_Bool bRecursive )
1493cdf0e10cSrcweir {
1494cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1495cdf0e10cSrcweir 
1496cdf0e10cSrcweir 	if( GetRegisteredIn() )
1497cdf0e10cSrcweir 		GetRegisteredInNonConst()->Remove( this );
1498cdf0e10cSrcweir 
1499cdf0e10cSrcweir 	SwAccessibleContext::Dispose( bRecursive );
1500cdf0e10cSrcweir }
1501cdf0e10cSrcweir 
DisposeChild(const SwAccessibleChild & rChildFrmOrObj,sal_Bool bRecursive)1502cdf0e10cSrcweir void SwAccessibleTable::DisposeChild( const SwAccessibleChild& rChildFrmOrObj,
1503cdf0e10cSrcweir                                       sal_Bool bRecursive )
1504cdf0e10cSrcweir {
1505cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1506cdf0e10cSrcweir 
1507cdf0e10cSrcweir 	const SwFrm *pFrm = rChildFrmOrObj.GetSwFrm();
1508cdf0e10cSrcweir 	ASSERT( pFrm, "frame expected" );
1509cdf0e10cSrcweir 	if( HasTableData() )
1510cdf0e10cSrcweir 	{
1511cdf0e10cSrcweir 		FireTableChangeEvent( GetTableData() );
1512cdf0e10cSrcweir 		ClearTableData();
1513cdf0e10cSrcweir 	}
1514cdf0e10cSrcweir 
1515cdf0e10cSrcweir 	// There are two reason why this method has been called. The first one
1516cdf0e10cSrcweir 	// is there is no context for pFrm. The method is them called by
1517cdf0e10cSrcweir 	// the map, and we have to call our superclass.
1518cdf0e10cSrcweir 	// The other situation is that we have been call by a call to get notified
1519cdf0e10cSrcweir 	// about its change. We then must not call the superclass
1520cdf0e10cSrcweir 	uno::Reference< XAccessible > xAcc( GetMap()->GetContext( pFrm, sal_False ) );
1521cdf0e10cSrcweir 	if( !xAcc.is() )
1522cdf0e10cSrcweir 		SwAccessibleContext::DisposeChild( rChildFrmOrObj, bRecursive );
1523cdf0e10cSrcweir }
1524cdf0e10cSrcweir 
InvalidateChildPosOrSize(const SwAccessibleChild & rChildFrmOrObj,const SwRect & rOldBox)1525cdf0e10cSrcweir void SwAccessibleTable::InvalidateChildPosOrSize( const SwAccessibleChild& rChildFrmOrObj,
1526cdf0e10cSrcweir 												  const SwRect& rOldBox )
1527cdf0e10cSrcweir {
1528cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1529cdf0e10cSrcweir 
1530cdf0e10cSrcweir 	if( HasTableData() )
1531cdf0e10cSrcweir 	{
1532cdf0e10cSrcweir 		ASSERT( !HasTableData() ||
1533cdf0e10cSrcweir 				GetFrm()->Frm().Pos() == GetTableData().GetTablePos(),
1534cdf0e10cSrcweir 				"table has invalid position" );
1535cdf0e10cSrcweir 		if( HasTableData() )
1536cdf0e10cSrcweir 		{
1537cdf0e10cSrcweir             // --> OD 2007-06-28 #i77106#
1538cdf0e10cSrcweir             SwAccessibleTableData_Impl *pNewTableData = CreateNewTableData();
1539cdf0e10cSrcweir             // <--
1540cdf0e10cSrcweir 			if( !pNewTableData->CompareExtents( GetTableData() ) )
1541cdf0e10cSrcweir 			{
1542ca62e2c2SSteve Yin 				if(pNewTableData->GetRowCount()!= mpTableData->GetRowCount())
1543ca62e2c2SSteve Yin 				{
1544ca62e2c2SSteve Yin 					Int32Set_Impl::const_iterator aSttCol( GetTableData().GetColumnIter( 0 ) );
1545ca62e2c2SSteve Yin 					Int32Set_Impl::const_iterator aSttRow( GetTableData().GetRowIter( 1 ) );
1546ca62e2c2SSteve Yin 					const SwFrm *pCellFrm = GetTableData().GetCellAtPos( *aSttCol, *aSttRow, sal_False );
1547ca62e2c2SSteve Yin 					Int32Set_Impl::const_iterator aSttCol2(	pNewTableData->GetColumnIter( 0 ) );
1548ca62e2c2SSteve Yin 					Int32Set_Impl::const_iterator aSttRow2( pNewTableData->GetRowIter( 0 ) );
1549ca62e2c2SSteve Yin 					const SwFrm *pCellFrm2 = pNewTableData->GetCellAtPos( *aSttCol2, *aSttRow2,	sal_False );
1550ca62e2c2SSteve Yin 
1551ca62e2c2SSteve Yin 					if(pCellFrm == pCellFrm2)
1552ca62e2c2SSteve Yin 					{
1553ca62e2c2SSteve Yin 						AccessibleTableModelChange aModelChange;
1554ca62e2c2SSteve Yin 						aModelChange.Type = AccessibleTableModelChangeType::UPDATE;
1555ca62e2c2SSteve Yin 						aModelChange.FirstRow = 0;
1556ca62e2c2SSteve Yin 						aModelChange.LastRow = mpTableData->GetRowCount() - 1;
1557ca62e2c2SSteve Yin 						aModelChange.FirstColumn = 0;
1558ca62e2c2SSteve Yin 						aModelChange.LastColumn = mpTableData->GetColumnCount() - 1;
1559ca62e2c2SSteve Yin 
1560ca62e2c2SSteve Yin 						AccessibleEventObject aEvent;
1561ca62e2c2SSteve Yin 						aEvent.EventId = AccessibleEventId::TABLE_COLUMN_HEADER_CHANGED;
1562ca62e2c2SSteve Yin 						aEvent.NewValue <<= aModelChange;
1563ca62e2c2SSteve Yin 
1564ca62e2c2SSteve Yin 						FireAccessibleEvent( aEvent );
1565ca62e2c2SSteve Yin 					}
1566ca62e2c2SSteve Yin 				}
1567ca62e2c2SSteve Yin 				else
1568cdf0e10cSrcweir 				FireTableChangeEvent( GetTableData() );
1569cdf0e10cSrcweir 				ClearTableData();
1570cdf0e10cSrcweir 				mpTableData = pNewTableData;
1571cdf0e10cSrcweir 			}
1572cdf0e10cSrcweir 			else
1573cdf0e10cSrcweir 			{
1574cdf0e10cSrcweir 				delete pNewTableData;
1575cdf0e10cSrcweir 			}
1576cdf0e10cSrcweir 		}
1577cdf0e10cSrcweir 	}
1578cdf0e10cSrcweir 
1579cdf0e10cSrcweir     // --> OD 2010-02-18 #i013961# - always call super class method
1580cdf0e10cSrcweir     SwAccessibleContext::InvalidateChildPosOrSize( rChildFrmOrObj, rOldBox );
1581cdf0e10cSrcweir     // <--
1582cdf0e10cSrcweir }
1583cdf0e10cSrcweir 
1584cdf0e10cSrcweir 
1585cdf0e10cSrcweir //
1586cdf0e10cSrcweir //  XAccessibleSelection
1587cdf0e10cSrcweir //
1588cdf0e10cSrcweir 
selectAccessibleChild(sal_Int32 nChildIndex)1589cdf0e10cSrcweir void SAL_CALL SwAccessibleTable::selectAccessibleChild(
1590cdf0e10cSrcweir     sal_Int32 nChildIndex )
1591cdf0e10cSrcweir     throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
1592cdf0e10cSrcweir {
1593cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1594cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable );
1595cdf0e10cSrcweir 
1596cdf0e10cSrcweir     // --> OD 2007-06-27 #i77106#
1597cdf0e10cSrcweir     if( (nChildIndex < 0) || (nChildIndex >= getAccessibleChildCount()) )
1598cdf0e10cSrcweir     // <--
1599cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir     // preliminaries: get 'our' table box, and get the cursor shell
1602cdf0e10cSrcweir     const SwTableBox* pBox = GetTableBox( nChildIndex );
1603cdf0e10cSrcweir     DBG_ASSERT( pBox != NULL, "We need the table box." );
1604cdf0e10cSrcweir 
1605cdf0e10cSrcweir     SwCrsrShell* pCrsrShell = GetCrsrShell();
1606cdf0e10cSrcweir     if( pCrsrShell == NULL )
1607cdf0e10cSrcweir         return;
1608cdf0e10cSrcweir 
1609cdf0e10cSrcweir     // --> OD 2004-11-16 #111714# - assure, that child, indentified by the given
1610cdf0e10cSrcweir     // index, isn't already selected.
1611cdf0e10cSrcweir     if ( IsChildSelected( nChildIndex ) )
1612cdf0e10cSrcweir     {
1613cdf0e10cSrcweir         return;
1614cdf0e10cSrcweir     }
1615cdf0e10cSrcweir     // <--
1616cdf0e10cSrcweir 
1617cdf0e10cSrcweir     // now we can start to do the work: check whether we already have
1618cdf0e10cSrcweir     // a table selection (in 'our' table). If so, extend the
1619cdf0e10cSrcweir     // selection, else select the current cell.
1620cdf0e10cSrcweir 
1621cdf0e10cSrcweir     // if we have a selection in a table, check if it's in the
1622cdf0e10cSrcweir     // same table that we're trying to select in
1623cdf0e10cSrcweir     const SwTableNode* pSelectedTable = pCrsrShell->IsCrsrInTbl();
1624cdf0e10cSrcweir     if( pSelectedTable != NULL )
1625cdf0e10cSrcweir     {
1626cdf0e10cSrcweir         // get top-most table line
1627cdf0e10cSrcweir         const SwTableLine* pUpper = pBox->GetUpper();
1628cdf0e10cSrcweir         while( pUpper->GetUpper() != NULL )
1629cdf0e10cSrcweir             pUpper = pUpper->GetUpper()->GetUpper();
1630cdf0e10cSrcweir         sal_uInt16 nPos =
1631cdf0e10cSrcweir             pSelectedTable->GetTable().GetTabLines().GetPos( pUpper );
1632cdf0e10cSrcweir         if( nPos == USHRT_MAX )
1633cdf0e10cSrcweir             pSelectedTable = NULL;
1634cdf0e10cSrcweir     }
1635cdf0e10cSrcweir 
1636cdf0e10cSrcweir     // create the new selection
1637cdf0e10cSrcweir     const SwStartNode* pStartNode = pBox->GetSttNd();
1638cdf0e10cSrcweir     if( pSelectedTable == NULL || !pCrsrShell->GetTblCrs() )
1639cdf0e10cSrcweir     {
1640cdf0e10cSrcweir         // if we're in the wrong table, or there's no table selection
1641cdf0e10cSrcweir         // at all, then select the current table cell.
1642cdf0e10cSrcweir //      SwPaM* pPaM = pCrsrShell->GetCrsr();
1643cdf0e10cSrcweir //      pPaM->DeleteMark();
1644cdf0e10cSrcweir //      *(pPaM->GetPoint()) = SwPosition( *pStartNode );
1645cdf0e10cSrcweir //  	pPaM->Move( fnMoveForward, fnGoNode );
1646cdf0e10cSrcweir // //   pCrsrShell->SelTblBox();
1647cdf0e10cSrcweir 
1648cdf0e10cSrcweir 		pCrsrShell->StartAction();
1649cdf0e10cSrcweir 		// Set cursor into current cell. This deletes any table cursor.
1650cdf0e10cSrcweir         SwPaM aPaM( *pStartNode );
1651cdf0e10cSrcweir         aPaM.Move( fnMoveForward, fnGoNode );
1652cdf0e10cSrcweir 		Select( aPaM );
1653cdf0e10cSrcweir 		// Move cursor to the end of the table creating a selection and a table
1654cdf0e10cSrcweir 		// cursor.
1655cdf0e10cSrcweir 		pCrsrShell->SetMark();
1656cdf0e10cSrcweir 		pCrsrShell->MoveTable( fnTableCurr, fnTableEnd );
1657cdf0e10cSrcweir 		// now set the cursor into the cell again.
1658cdf0e10cSrcweir 		SwPaM *pPaM = pCrsrShell->GetTblCrs() ? pCrsrShell->GetTblCrs()
1659cdf0e10cSrcweir 													: pCrsrShell->GetCrsr();
1660cdf0e10cSrcweir 		*pPaM->GetPoint() = *pPaM->GetMark();
1661cdf0e10cSrcweir 		pCrsrShell->EndAction();
1662cdf0e10cSrcweir 		// we now have one cell selected!
1663cdf0e10cSrcweir     }
1664cdf0e10cSrcweir     else
1665cdf0e10cSrcweir     {
1666cdf0e10cSrcweir         // if the cursor is already in this table,
1667cdf0e10cSrcweir         // expand the current selection (i.e., set
1668cdf0e10cSrcweir         // point to new position; keep mark)
1669cdf0e10cSrcweir         SwPaM aPaM( *pStartNode );
1670cdf0e10cSrcweir         aPaM.Move( fnMoveForward, fnGoNode );
1671cdf0e10cSrcweir         aPaM.SetMark();
1672cdf0e10cSrcweir 		const SwPaM *pPaM = pCrsrShell->GetTblCrs() ? pCrsrShell->GetTblCrs()
1673cdf0e10cSrcweir 													: pCrsrShell->GetCrsr();
1674cdf0e10cSrcweir         *(aPaM.GetMark()) = *pPaM->GetMark();
1675cdf0e10cSrcweir 		Select( aPaM );
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir         // if only one box is selected, we select this one in
1678cdf0e10cSrcweir         // order to maintain our table selection
1679cdf0e10cSrcweir //        if( aPaM.GetPoint()->nNode.GetNode().FindTableBoxStartNode() ==
1680cdf0e10cSrcweir //           aPaM.GetMark()->nNode.GetNode().FindTableBoxStartNode() )
1681cdf0e10cSrcweir //        {
1682cdf0e10cSrcweir // //            pCrsrShell->SelTblBox();
1683cdf0e10cSrcweir //         }
1684cdf0e10cSrcweir //         else
1685cdf0e10cSrcweir //         {
1686cdf0e10cSrcweir             // finally; set the selection. This will call UpdateCursor
1687cdf0e10cSrcweir             // on the cursor shell, too.
1688cdf0e10cSrcweir //            pCrsrShell->KillPams();
1689cdf0e10cSrcweir  //           pCrsrShell->SetSelection( aPaM );
1690cdf0e10cSrcweir //         }
1691cdf0e10cSrcweir     }
1692cdf0e10cSrcweir }
1693cdf0e10cSrcweir 
1694cdf0e10cSrcweir 
isAccessibleChildSelected(sal_Int32 nChildIndex)1695cdf0e10cSrcweir sal_Bool SAL_CALL SwAccessibleTable::isAccessibleChildSelected(
1696cdf0e10cSrcweir     sal_Int32 nChildIndex )
1697cdf0e10cSrcweir     throw ( lang::IndexOutOfBoundsException,
1698cdf0e10cSrcweir             uno::RuntimeException )
1699cdf0e10cSrcweir {
1700cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1701cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable );
1702cdf0e10cSrcweir 
1703cdf0e10cSrcweir     // --> OD 2007-06-27 #i77106#
1704cdf0e10cSrcweir     if( (nChildIndex < 0) || (nChildIndex >= getAccessibleChildCount()) )
1705cdf0e10cSrcweir     // <--
1706cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
1707cdf0e10cSrcweir 
1708cdf0e10cSrcweir     return IsChildSelected( nChildIndex );
1709cdf0e10cSrcweir }
1710cdf0e10cSrcweir 
clearAccessibleSelection()1711cdf0e10cSrcweir void SAL_CALL SwAccessibleTable::clearAccessibleSelection(  )
1712cdf0e10cSrcweir     throw ( uno::RuntimeException )
1713cdf0e10cSrcweir {
1714cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1715cdf0e10cSrcweir 
1716cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable );
1717cdf0e10cSrcweir 
1718cdf0e10cSrcweir     SwCrsrShell* pCrsrShell = GetCrsrShell();
1719cdf0e10cSrcweir     if( pCrsrShell != NULL )
1720cdf0e10cSrcweir 	{
1721cdf0e10cSrcweir         pCrsrShell->StartAction();
1722cdf0e10cSrcweir         pCrsrShell->ClearMark();
1723cdf0e10cSrcweir         pCrsrShell->EndAction();
1724cdf0e10cSrcweir 	}
1725cdf0e10cSrcweir }
1726cdf0e10cSrcweir 
selectAllAccessibleChildren()1727cdf0e10cSrcweir void SAL_CALL SwAccessibleTable::selectAllAccessibleChildren(  )
1728cdf0e10cSrcweir     throw ( uno::RuntimeException )
1729cdf0e10cSrcweir {
1730cdf0e10cSrcweir     // first clear selection, then select first and last child
1731cdf0e10cSrcweir     clearAccessibleSelection();
1732cdf0e10cSrcweir     selectAccessibleChild( 0 );
1733cdf0e10cSrcweir     // --> OD 2007-06-27 #i77106#
1734cdf0e10cSrcweir     selectAccessibleChild( getAccessibleChildCount()-1 );
1735cdf0e10cSrcweir     // <--
1736cdf0e10cSrcweir }
1737cdf0e10cSrcweir 
getSelectedAccessibleChildCount()1738cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleTable::getSelectedAccessibleChildCount(  )
1739cdf0e10cSrcweir     throw ( uno::RuntimeException )
1740cdf0e10cSrcweir {
1741cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1742cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable );
1743cdf0e10cSrcweir 
1744cdf0e10cSrcweir     // iterate over all children and count isAccessibleChildSelected()
1745cdf0e10cSrcweir     sal_Int32 nCount = 0;
1746cdf0e10cSrcweir 
1747cdf0e10cSrcweir     // --> OD 2007-06-27 #i71106#
1748cdf0e10cSrcweir     sal_Int32 nChildren = getAccessibleChildCount();
1749cdf0e10cSrcweir     // <--
1750cdf0e10cSrcweir     for( sal_Int32 n = 0; n < nChildren; n++ )
1751cdf0e10cSrcweir         if( IsChildSelected( n ) )
1752cdf0e10cSrcweir             nCount++;
1753cdf0e10cSrcweir 
1754cdf0e10cSrcweir     return nCount;
1755cdf0e10cSrcweir }
1756cdf0e10cSrcweir 
getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)1757cdf0e10cSrcweir uno::Reference<XAccessible> SAL_CALL SwAccessibleTable::getSelectedAccessibleChild(
1758cdf0e10cSrcweir     sal_Int32 nSelectedChildIndex )
1759cdf0e10cSrcweir     throw ( lang::IndexOutOfBoundsException,
1760cdf0e10cSrcweir             uno::RuntimeException)
1761cdf0e10cSrcweir {
1762cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1763cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable );
1764cdf0e10cSrcweir 
1765cdf0e10cSrcweir     // paremter checking (part 1): index lower 0
1766cdf0e10cSrcweir     if( nSelectedChildIndex < 0 )
1767cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
1768cdf0e10cSrcweir 
1769cdf0e10cSrcweir 	sal_Int32 nChildIndex = GetIndexOfSelectedChild( nSelectedChildIndex );
1770cdf0e10cSrcweir 
1771cdf0e10cSrcweir     // parameter checking (part 2): index higher than selected children?
1772cdf0e10cSrcweir     if( nChildIndex < 0 )
1773cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
1774cdf0e10cSrcweir 
1775cdf0e10cSrcweir     // --> OD 2007-06-28 #i77106#
1776cdf0e10cSrcweir     if ( nChildIndex >= getAccessibleChildCount() )
1777cdf0e10cSrcweir     {
1778cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
1779cdf0e10cSrcweir     }
1780cdf0e10cSrcweir     // <--
1781cdf0e10cSrcweir 
1782cdf0e10cSrcweir     return getAccessibleChild( nChildIndex );
1783cdf0e10cSrcweir }
1784cdf0e10cSrcweir 
1785cdf0e10cSrcweir // --> OD 2004-11-16 #111714# - index has to be treated as global child index.
deselectAccessibleChild(sal_Int32 nChildIndex)1786cdf0e10cSrcweir void SAL_CALL SwAccessibleTable::deselectAccessibleChild(
1787cdf0e10cSrcweir     sal_Int32 nChildIndex )
1788cdf0e10cSrcweir     throw ( lang::IndexOutOfBoundsException,
1789cdf0e10cSrcweir             uno::RuntimeException )
1790cdf0e10cSrcweir {
1791cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1792cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleTable );
1793cdf0e10cSrcweir 
1794cdf0e10cSrcweir     SwCrsrShell* pCrsrShell = GetCrsrShell();
1795cdf0e10cSrcweir 
1796cdf0e10cSrcweir     // --> OD 2004-11-16 #111714# - index has to be treated as global child index
1797cdf0e10cSrcweir     if ( !pCrsrShell )
1798cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
1799cdf0e10cSrcweir 
1800cdf0e10cSrcweir     // assure, that given child index is in bounds.
1801cdf0e10cSrcweir     // --> OD 2007-06-27 #i77106#
1802cdf0e10cSrcweir     if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
1803cdf0e10cSrcweir     // <--
1804cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
1805cdf0e10cSrcweir 
1806cdf0e10cSrcweir     // assure, that child, identified by the given index, is selected.
1807cdf0e10cSrcweir     if ( !IsChildSelected( nChildIndex ) )
1808cdf0e10cSrcweir         return;
1809cdf0e10cSrcweir     // <--
1810cdf0e10cSrcweir 
1811cdf0e10cSrcweir     const SwTableBox* pBox = GetTableBox( nChildIndex );
1812cdf0e10cSrcweir     DBG_ASSERT( pBox != NULL, "We need the table box." );
1813cdf0e10cSrcweir 
1814cdf0e10cSrcweir 	// If we unselect point, then set cursor to mark. If we clear another
1815cdf0e10cSrcweir 	// selected box, then set cursor to point.
1816cdf0e10cSrcweir 	// reduce selection to mark.
1817cdf0e10cSrcweir 	SwPaM *pPaM = pCrsrShell->GetTblCrs() ? pCrsrShell->GetTblCrs()
1818cdf0e10cSrcweir 												: pCrsrShell->GetCrsr();
1819cdf0e10cSrcweir 	sal_Bool bDeselectPoint =
1820cdf0e10cSrcweir 		pBox->GetSttNd() ==
1821cdf0e10cSrcweir 			pPaM->GetPoint()->nNode.GetNode().FindTableBoxStartNode();
1822cdf0e10cSrcweir 
1823cdf0e10cSrcweir 	SwPaM aPaM( bDeselectPoint ? *pPaM->GetMark() : *pPaM->GetPoint() );
1824cdf0e10cSrcweir 
1825cdf0e10cSrcweir 	pCrsrShell->StartAction();
1826cdf0e10cSrcweir 
1827cdf0e10cSrcweir 	// Set cursor into either point or mark
1828cdf0e10cSrcweir 	Select( aPaM );
1829cdf0e10cSrcweir 	// Move cursor to the end of the table creating a selection and a table
1830cdf0e10cSrcweir 	// cursor.
1831cdf0e10cSrcweir 	pCrsrShell->SetMark();
1832cdf0e10cSrcweir 	pCrsrShell->MoveTable( fnTableCurr, fnTableEnd );
1833cdf0e10cSrcweir 	// now set the cursor into the cell again.
1834cdf0e10cSrcweir 	pPaM = pCrsrShell->GetTblCrs() ? pCrsrShell->GetTblCrs()
1835cdf0e10cSrcweir 										: pCrsrShell->GetCrsr();
1836cdf0e10cSrcweir 	*pPaM->GetPoint() = *pPaM->GetMark();
1837cdf0e10cSrcweir 	pCrsrShell->EndAction();
1838cdf0e10cSrcweir }
1839cdf0e10cSrcweir 
SetTableData(SwAccessibleTableData_Impl * mpNewTableData)1840ca62e2c2SSteve Yin void  SwAccessibleTable::SetTableData(SwAccessibleTableData_Impl* mpNewTableData)
1841ca62e2c2SSteve Yin {
1842ca62e2c2SSteve Yin 	mpTableData = mpNewTableData;
1843ca62e2c2SSteve Yin }
1844ca62e2c2SSteve Yin 
getBackground()1845ca62e2c2SSteve Yin sal_Int32 SAL_CALL SwAccessibleTable::getBackground()
1846ca62e2c2SSteve Yin 		throw (::com::sun::star::uno::RuntimeException)
1847ca62e2c2SSteve Yin {
1848ca62e2c2SSteve Yin 	const SvxBrushItem &rBack = GetFrm()->GetAttrSet()->GetBackground();
1849ca62e2c2SSteve Yin 	sal_uInt32 crBack = rBack.GetColor().GetColor();
1850ca62e2c2SSteve Yin 
1851ca62e2c2SSteve Yin 	if (COL_AUTO == crBack)
1852ca62e2c2SSteve Yin 	{
1853ca62e2c2SSteve Yin 		uno::Reference<XAccessible> xAccDoc = getAccessibleParent();
1854ca62e2c2SSteve Yin 		if (xAccDoc.is())
1855ca62e2c2SSteve Yin 		{
1856ca62e2c2SSteve Yin 			uno::Reference<XAccessibleComponent> xCompoentDoc(xAccDoc,uno::UNO_QUERY);
1857ca62e2c2SSteve Yin 			if (xCompoentDoc.is())
1858ca62e2c2SSteve Yin 			{
1859ca62e2c2SSteve Yin 				crBack = (sal_uInt32)xCompoentDoc->getBackground();
1860ca62e2c2SSteve Yin 			}
1861ca62e2c2SSteve Yin 		}
1862ca62e2c2SSteve Yin 	}
1863ca62e2c2SSteve Yin 	return crBack;
1864ca62e2c2SSteve Yin }
1865ca62e2c2SSteve Yin 
FireSelectionEvent()1866ca62e2c2SSteve Yin void SwAccessibleTable::FireSelectionEvent( )
1867ca62e2c2SSteve Yin {
1868ca62e2c2SSteve Yin 	AccessibleEventObject aEvent;
1869ca62e2c2SSteve Yin 
1870ca62e2c2SSteve Yin 	aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_REMOVE;
1871ca62e2c2SSteve Yin 
1872ca62e2c2SSteve Yin //    int nRemove = m_vecCellRemove.size();
1873ca62e2c2SSteve Yin //    int nAdd = m_vecCellAdd.size();
1874ca62e2c2SSteve Yin 
1875ca62e2c2SSteve Yin 	VEC_CELL::iterator vi = m_vecCellRemove.begin();
1876ca62e2c2SSteve Yin 	for (; vi != m_vecCellRemove.end()  ; ++vi)
1877ca62e2c2SSteve Yin 	{
1878ca62e2c2SSteve Yin 		SwAccessibleContext *pAccCell = const_cast<SwAccessibleContext *>(*vi);
1879ca62e2c2SSteve Yin 		OSL_ASSERT(pAccCell != NULL );
1880ca62e2c2SSteve Yin 		pAccCell->FireAccessibleEvent(aEvent);
1881ca62e2c2SSteve Yin 	}
1882ca62e2c2SSteve Yin 
1883ca62e2c2SSteve Yin 	if (m_vecCellAdd.size() <= SELECTION_WITH_NUM)
1884ca62e2c2SSteve Yin 	{
1885ca62e2c2SSteve Yin 		aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_ADD;
1886ca62e2c2SSteve Yin 		vi = m_vecCellAdd.begin();
1887ca62e2c2SSteve Yin 		for (; vi != m_vecCellAdd.end()  ; ++vi)
1888ca62e2c2SSteve Yin 		{
1889ca62e2c2SSteve Yin 			SwAccessibleContext *pAccCell = const_cast<SwAccessibleContext *>(*vi);
1890ca62e2c2SSteve Yin 			OSL_ASSERT(pAccCell != NULL );
1891ca62e2c2SSteve Yin 			pAccCell->FireAccessibleEvent(aEvent);
1892ca62e2c2SSteve Yin 		}
1893ca62e2c2SSteve Yin 		return ;
1894ca62e2c2SSteve Yin 	}
1895ca62e2c2SSteve Yin 	else
1896ca62e2c2SSteve Yin 	{
1897ca62e2c2SSteve Yin 		aEvent.EventId = AccessibleEventId::SELECTION_CHANGED_WITHIN;
1898ca62e2c2SSteve Yin 		FireAccessibleEvent(aEvent);
1899ca62e2c2SSteve Yin 	}
1900ca62e2c2SSteve Yin }
1901ca62e2c2SSteve Yin 
ClearSelectionCellCache()1902ca62e2c2SSteve Yin void SwAccessibleTable::ClearSelectionCellCache()
1903ca62e2c2SSteve Yin {
1904ca62e2c2SSteve Yin 	m_vecCellAdd.clear();
1905ca62e2c2SSteve Yin 	m_vecCellRemove.clear();
1906ca62e2c2SSteve Yin }
1907ca62e2c2SSteve Yin 
AddSelectionCell(const SwAccessibleContext * pAccCell,sal_Bool bAddOrRemove)1908ca62e2c2SSteve Yin void SwAccessibleTable::AddSelectionCell(const SwAccessibleContext* pAccCell ,sal_Bool bAddOrRemove)
1909ca62e2c2SSteve Yin {
1910ca62e2c2SSteve Yin 	if (bAddOrRemove)
1911ca62e2c2SSteve Yin 	{
1912ca62e2c2SSteve Yin 		m_vecCellAdd.push_back(pAccCell);
1913ca62e2c2SSteve Yin 	}
1914ca62e2c2SSteve Yin 	else
1915ca62e2c2SSteve Yin 	{
1916ca62e2c2SSteve Yin 		m_vecCellRemove.push_back(pAccCell);
1917ca62e2c2SSteve Yin 	}
1918ca62e2c2SSteve Yin }
1919ca62e2c2SSteve Yin 
1920ca62e2c2SSteve Yin //=====  XAccessibleTableSelection  ============================================
selectRow(sal_Int32 row)1921ca62e2c2SSteve Yin sal_Bool SAL_CALL SwAccessibleTable::selectRow( sal_Int32 row )
1922ca62e2c2SSteve Yin 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1923ca62e2c2SSteve Yin {
1924ca62e2c2SSteve Yin 	if( isAccessibleColumnSelected( row ) )
1925ca62e2c2SSteve Yin 		return sal_True;
1926ca62e2c2SSteve Yin 
1927ca62e2c2SSteve Yin 	long lCol, lColumnCount, lChildIndex;
1928ca62e2c2SSteve Yin 	lColumnCount = getAccessibleColumnCount();
1929ca62e2c2SSteve Yin 	for(lCol = 0; lCol < lColumnCount; lCol ++)
1930ca62e2c2SSteve Yin 	{
1931ca62e2c2SSteve Yin 		lChildIndex = getAccessibleIndex(row, lCol);
1932ca62e2c2SSteve Yin 		selectAccessibleChild(lChildIndex);
1933ca62e2c2SSteve Yin 	}
1934ca62e2c2SSteve Yin 
1935ca62e2c2SSteve Yin 	return sal_True;
1936ca62e2c2SSteve Yin }
selectColumn(sal_Int32 column)1937ca62e2c2SSteve Yin sal_Bool SAL_CALL SwAccessibleTable::selectColumn( sal_Int32 column )
1938ca62e2c2SSteve Yin 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1939ca62e2c2SSteve Yin {
1940ca62e2c2SSteve Yin 	if( isAccessibleColumnSelected( column ) )
1941ca62e2c2SSteve Yin 		return sal_True;
1942ca62e2c2SSteve Yin 
1943ca62e2c2SSteve Yin 	long lRow, lRowCount, lChildIndex;
1944ca62e2c2SSteve Yin 	lRowCount = getAccessibleRowCount();
1945ca62e2c2SSteve Yin 
1946ca62e2c2SSteve Yin 	for(lRow = 0; lRow < lRowCount; lRow ++)
1947ca62e2c2SSteve Yin 	{
1948ca62e2c2SSteve Yin 		lChildIndex = getAccessibleIndex(lRow, column);
1949ca62e2c2SSteve Yin 		selectAccessibleChild(lChildIndex);
1950ca62e2c2SSteve Yin 	}
1951ca62e2c2SSteve Yin 	return sal_True;
1952ca62e2c2SSteve Yin }
unselectRow(sal_Int32 row)1953ca62e2c2SSteve Yin sal_Bool SAL_CALL SwAccessibleTable::unselectRow( sal_Int32 row )
1954ca62e2c2SSteve Yin 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1955ca62e2c2SSteve Yin {
1956ca62e2c2SSteve Yin 	if( isAccessibleSelected( row , 0 ) &&  isAccessibleSelected( row , getAccessibleColumnCount()-1 ) )
1957ca62e2c2SSteve Yin 	{
1958ca62e2c2SSteve Yin 		SwCrsrShell* pCrsrShell = GetCrsrShell();
1959ca62e2c2SSteve Yin 		if( pCrsrShell != NULL )
1960ca62e2c2SSteve Yin 		{
1961ca62e2c2SSteve Yin 			pCrsrShell->StartAction();
1962ca62e2c2SSteve Yin 			pCrsrShell->ClearMark();
1963ca62e2c2SSteve Yin 			pCrsrShell->EndAction();
1964ca62e2c2SSteve Yin 			return sal_True;
1965ca62e2c2SSteve Yin 		}
1966ca62e2c2SSteve Yin 	}
1967ca62e2c2SSteve Yin 	return sal_True;
1968ca62e2c2SSteve Yin }
unselectColumn(sal_Int32 column)1969ca62e2c2SSteve Yin sal_Bool SAL_CALL SwAccessibleTable::unselectColumn( sal_Int32 column )
1970ca62e2c2SSteve Yin 	throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
1971ca62e2c2SSteve Yin {
1972ca62e2c2SSteve Yin 	if( isAccessibleSelected( 0 , column ) &&  isAccessibleSelected( getAccessibleRowCount()-1,column))
1973ca62e2c2SSteve Yin 	{
1974ca62e2c2SSteve Yin 		SwCrsrShell* pCrsrShell = GetCrsrShell();
1975ca62e2c2SSteve Yin 		if( pCrsrShell != NULL )
1976ca62e2c2SSteve Yin 		{
1977ca62e2c2SSteve Yin 			pCrsrShell->StartAction();
1978ca62e2c2SSteve Yin 			pCrsrShell->ClearMark();
1979ca62e2c2SSteve Yin 			pCrsrShell->EndAction();
1980ca62e2c2SSteve Yin 			return sal_True;
1981ca62e2c2SSteve Yin 		}
1982ca62e2c2SSteve Yin 	}
1983ca62e2c2SSteve Yin 	return sal_True;
1984ca62e2c2SSteve Yin }
1985cdf0e10cSrcweir // --> OD 2007-06-28 #i77106#
1986cdf0e10cSrcweir // implementation of class <SwAccessibleTableColHeaders>
SwAccessibleTableColHeaders(SwAccessibleMap * pMap2,const SwTabFrm * pTabFrm)1987cdf0e10cSrcweir SwAccessibleTableColHeaders::SwAccessibleTableColHeaders( SwAccessibleMap *pMap2,
1988cdf0e10cSrcweir                                                           const SwTabFrm *pTabFrm )
1989cdf0e10cSrcweir     : SwAccessibleTable( pMap2, pTabFrm )
1990cdf0e10cSrcweir {
1991cdf0e10cSrcweir     vos::OGuard aGuard(Application::GetSolarMutex());
1992cdf0e10cSrcweir 
1993cdf0e10cSrcweir     const SwFrmFmt *pFrmFmt = pTabFrm->GetFmt();
1994cdf0e10cSrcweir     const_cast< SwFrmFmt * >( pFrmFmt )->Add( this );
1995cdf0e10cSrcweir     const String& rName = pFrmFmt->GetName();
1996cdf0e10cSrcweir 
1997cdf0e10cSrcweir     OUStringBuffer aBuffer( rName.Len() + 15 + 6 );
1998cdf0e10cSrcweir     aBuffer.append( OUString(rName) );
1999cdf0e10cSrcweir     aBuffer.append( String::CreateFromAscii("-ColumnHeaders-") );
2000cdf0e10cSrcweir     aBuffer.append( static_cast<sal_Int32>( pTabFrm->GetPhyPageNum() ) );
2001cdf0e10cSrcweir 
2002cdf0e10cSrcweir     SetName( aBuffer.makeStringAndClear() );
2003cdf0e10cSrcweir 
2004cdf0e10cSrcweir     OUStringBuffer aBuffer2( rName.Len() + 14 );
2005cdf0e10cSrcweir     aBuffer2.append( OUString(rName) );
2006cdf0e10cSrcweir     aBuffer2.append( String::CreateFromAscii("-ColumnHeaders") );
2007cdf0e10cSrcweir     OUString sArg1( aBuffer2.makeStringAndClear() );
2008cdf0e10cSrcweir     OUString sArg2( GetFormattedPageNumber() );
2009cdf0e10cSrcweir 
2010cdf0e10cSrcweir     OUString sDesc2 = GetResource( STR_ACCESS_TABLE_DESC, &sArg1, &sArg2 );
2011cdf0e10cSrcweir     SetDesc( sDesc2 );
2012cdf0e10cSrcweir 
2013cdf0e10cSrcweir     // --> OD 2008-03-10 #i85634#
2014cdf0e10cSrcweir     NotRegisteredAtAccessibleMap();
2015cdf0e10cSrcweir     // <--
2016cdf0e10cSrcweir }
2017cdf0e10cSrcweir 
CreateNewTableData()2018cdf0e10cSrcweir SwAccessibleTableData_Impl* SwAccessibleTableColHeaders::CreateNewTableData()
2019cdf0e10cSrcweir {
2020cdf0e10cSrcweir     const SwTabFrm* pTabFrm = static_cast<const SwTabFrm*>( GetFrm() );
2021cdf0e10cSrcweir     return new SwAccessibleTableData_Impl( *(GetMap()), pTabFrm, IsInPagePreview(), true );
2022cdf0e10cSrcweir }
2023cdf0e10cSrcweir 
2024cdf0e10cSrcweir 
Modify(const SfxPoolItem *,const SfxPoolItem *)2025cdf0e10cSrcweir void SwAccessibleTableColHeaders::Modify( const SfxPoolItem * /*pOld*/, const SfxPoolItem * /*pNew*/ )
2026cdf0e10cSrcweir {
2027cdf0e10cSrcweir }
2028cdf0e10cSrcweir 
2029cdf0e10cSrcweir //=====  XInterface  ======================================================
queryInterface(const uno::Type & aType)2030cdf0e10cSrcweir uno::Any SAL_CALL SwAccessibleTableColHeaders::queryInterface( const uno::Type& aType )
2031cdf0e10cSrcweir         throw (uno::RuntimeException)
2032cdf0e10cSrcweir {
2033cdf0e10cSrcweir     return SwAccessibleTable::queryInterface( aType );
2034cdf0e10cSrcweir }
2035cdf0e10cSrcweir 
2036cdf0e10cSrcweir //=====  XAccessibleContext  ==============================================
getAccessibleChildCount(void)2037cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleTableColHeaders::getAccessibleChildCount(void)
2038cdf0e10cSrcweir         throw (uno::RuntimeException)
2039cdf0e10cSrcweir {
2040cdf0e10cSrcweir     vos::OGuard aGuard(Application::GetSolarMutex());
2041cdf0e10cSrcweir 
2042cdf0e10cSrcweir     CHECK_FOR_DEFUNC( XAccessibleContext )
2043cdf0e10cSrcweir 
2044cdf0e10cSrcweir     sal_Int32 nCount = 0;
2045cdf0e10cSrcweir 
2046cdf0e10cSrcweir     const SwTabFrm* pTabFrm = static_cast<const SwTabFrm*>( GetFrm() );
2047cdf0e10cSrcweir     const SwAccessibleChildSList aVisList( GetVisArea(), *pTabFrm, *(GetMap()) );
2048cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
2049cdf0e10cSrcweir     while( aIter != aVisList.end() )
2050cdf0e10cSrcweir     {
2051cdf0e10cSrcweir         const SwAccessibleChild& rLower = *aIter;
2052cdf0e10cSrcweir         if( rLower.IsAccessible( IsInPagePreview() ) )
2053cdf0e10cSrcweir         {
2054cdf0e10cSrcweir             nCount++;
2055cdf0e10cSrcweir         }
2056cdf0e10cSrcweir         else if( rLower.GetSwFrm() )
2057cdf0e10cSrcweir         {
2058cdf0e10cSrcweir             // There are no unaccessible SdrObjects that count
2059cdf0e10cSrcweir             if ( !rLower.GetSwFrm()->IsRowFrm() ||
2060cdf0e10cSrcweir                  pTabFrm->IsInHeadline( *(rLower.GetSwFrm()) ) )
2061cdf0e10cSrcweir             {
2062cdf0e10cSrcweir                 nCount += SwAccessibleFrame::GetChildCount( *(GetMap()),
2063cdf0e10cSrcweir                                                             GetVisArea(),
2064cdf0e10cSrcweir                                                             rLower.GetSwFrm(),
2065cdf0e10cSrcweir                                                             IsInPagePreview() );
2066cdf0e10cSrcweir             }
2067cdf0e10cSrcweir         }
2068cdf0e10cSrcweir         ++aIter;
2069cdf0e10cSrcweir     }
2070cdf0e10cSrcweir 
2071cdf0e10cSrcweir     return nCount;
2072cdf0e10cSrcweir }
2073cdf0e10cSrcweir 
2074cdf0e10cSrcweir uno::Reference< XAccessible> SAL_CALL
getAccessibleChild(sal_Int32 nIndex)2075cdf0e10cSrcweir         SwAccessibleTableColHeaders::getAccessibleChild (sal_Int32 nIndex)
2076cdf0e10cSrcweir         throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
2077cdf0e10cSrcweir {
2078cdf0e10cSrcweir     if ( nIndex < 0 || nIndex >= getAccessibleChildCount() )
2079cdf0e10cSrcweir     {
2080cdf0e10cSrcweir         throw lang::IndexOutOfBoundsException();
2081cdf0e10cSrcweir     }
2082cdf0e10cSrcweir 
2083cdf0e10cSrcweir     return SwAccessibleTable::getAccessibleChild( nIndex );
2084cdf0e10cSrcweir }
2085cdf0e10cSrcweir 
2086cdf0e10cSrcweir //=====  XAccessibleTable  ================================================
2087cdf0e10cSrcweir uno::Reference< XAccessibleTable >
getAccessibleRowHeaders()2088cdf0e10cSrcweir         SAL_CALL SwAccessibleTableColHeaders::getAccessibleRowHeaders()
2089cdf0e10cSrcweir         throw (uno::RuntimeException)
2090cdf0e10cSrcweir {
2091cdf0e10cSrcweir     return uno::Reference< XAccessibleTable >();
2092cdf0e10cSrcweir }
2093cdf0e10cSrcweir 
2094cdf0e10cSrcweir uno::Reference< XAccessibleTable >
getAccessibleColumnHeaders()2095cdf0e10cSrcweir         SAL_CALL SwAccessibleTableColHeaders::getAccessibleColumnHeaders()
2096cdf0e10cSrcweir         throw (uno::RuntimeException)
2097cdf0e10cSrcweir {
2098cdf0e10cSrcweir     return uno::Reference< XAccessibleTable >();
2099cdf0e10cSrcweir }
2100cdf0e10cSrcweir 
2101cdf0e10cSrcweir //=====  XServiceInfo  ====================================================
2102cdf0e10cSrcweir 
getImplementationName(void)2103cdf0e10cSrcweir ::rtl::OUString SAL_CALL SwAccessibleTableColHeaders::getImplementationName (void)
2104cdf0e10cSrcweir         throw (uno::RuntimeException)
2105cdf0e10cSrcweir {
2106cdf0e10cSrcweir     static const sal_Char sImplName[] = "com.sun.star.comp.Writer.SwAccessibleTableColumnHeadersView";
2107cdf0e10cSrcweir     return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplName));
2108cdf0e10cSrcweir }
2109