xref: /AOO41X/main/svtools/source/brwbox/brwbox3.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_svtools.hxx"
30*cdf0e10cSrcweir #include <svtools/brwbox.hxx>
31*cdf0e10cSrcweir #include <svtools/AccessibleBrowseBoxObjType.hxx>
32*cdf0e10cSrcweir #include <tools/debug.hxx>
33*cdf0e10cSrcweir #include <tools/multisel.hxx>
34*cdf0e10cSrcweir #include "datwin.hxx"
35*cdf0e10cSrcweir #include "brwimpl.hxx"
36*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
38*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir // Accessibility ==============================================================
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir using ::rtl::OUString;
43*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
44*cdf0e10cSrcweir using ::com::sun::star::accessibility::XAccessible;
45*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir // ============================================================================
48*cdf0e10cSrcweir namespace svt
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
51*cdf0e10cSrcweir 	using namespace utl;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir 	Reference< XAccessible > getHeaderCell(	BrowseBoxImpl::THeaderCellMap& _raHeaderCells,
54*cdf0e10cSrcweir 											sal_Int32 _nPos,
55*cdf0e10cSrcweir 											AccessibleBrowseBoxObjType _eType,
56*cdf0e10cSrcweir 											const Reference< XAccessible >& _rParent,
57*cdf0e10cSrcweir 											BrowseBox& _rBrowseBox,
58*cdf0e10cSrcweir                                             IAccessibleFactory& rFactory
59*cdf0e10cSrcweir                                           )
60*cdf0e10cSrcweir 	{
61*cdf0e10cSrcweir 		Reference< XAccessible > xRet;
62*cdf0e10cSrcweir 		BrowseBoxImpl::THeaderCellMap::iterator aFind = _raHeaderCells.find( _nPos );
63*cdf0e10cSrcweir 		if ( aFind == _raHeaderCells.end() )
64*cdf0e10cSrcweir 		{
65*cdf0e10cSrcweir             Reference< XAccessible > xAccessible = rFactory.createAccessibleBrowseBoxHeaderCell(
66*cdf0e10cSrcweir 			    _nPos,
67*cdf0e10cSrcweir 				_rParent,
68*cdf0e10cSrcweir 				_rBrowseBox,
69*cdf0e10cSrcweir 				NULL,
70*cdf0e10cSrcweir 				_eType
71*cdf0e10cSrcweir             );
72*cdf0e10cSrcweir 			aFind = _raHeaderCells.insert( BrowseBoxImpl::THeaderCellMap::value_type( _nPos, xAccessible ) ).first;
73*cdf0e10cSrcweir 		}
74*cdf0e10cSrcweir 		if ( aFind != _raHeaderCells.end() )
75*cdf0e10cSrcweir 			xRet = aFind->second;
76*cdf0e10cSrcweir 		return xRet;
77*cdf0e10cSrcweir 	}
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir     // ============================================================================
80*cdf0e10cSrcweir     // ----------------------------------------------------------------------------
81*cdf0e10cSrcweir     Reference< XAccessible > BrowseBoxImpl::getAccessibleHeaderBar( AccessibleBrowseBoxObjType _eObjType )
82*cdf0e10cSrcweir     {
83*cdf0e10cSrcweir         if ( m_pAccessible && m_pAccessible->isAlive() )
84*cdf0e10cSrcweir 		    return m_pAccessible->getHeaderBar( _eObjType );
85*cdf0e10cSrcweir         return NULL;
86*cdf0e10cSrcweir     }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir     // ----------------------------------------------------------------------------
89*cdf0e10cSrcweir     Reference< XAccessible > BrowseBoxImpl::getAccessibleTable( )
90*cdf0e10cSrcweir     {
91*cdf0e10cSrcweir         if ( m_pAccessible && m_pAccessible->isAlive() )
92*cdf0e10cSrcweir 		    return m_pAccessible->getTable( );
93*cdf0e10cSrcweir         return NULL;
94*cdf0e10cSrcweir     }
95*cdf0e10cSrcweir }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir // ============================================================================
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessible()
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir     Window* pParent = GetAccessibleParentWindow();
102*cdf0e10cSrcweir     DBG_ASSERT( pParent, "BrowseBox::CreateAccessible - parent not found" );
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     if( pParent && !m_pImpl->m_pAccessible)
105*cdf0e10cSrcweir     {
106*cdf0e10cSrcweir         Reference< XAccessible > xAccParent = pParent->GetAccessible();
107*cdf0e10cSrcweir         if( xAccParent.is() )
108*cdf0e10cSrcweir 		{
109*cdf0e10cSrcweir             m_pImpl->m_pAccessible = getAccessibleFactory().createAccessibleBrowseBox(
110*cdf0e10cSrcweir                 xAccParent, *this
111*cdf0e10cSrcweir             );
112*cdf0e10cSrcweir 		}
113*cdf0e10cSrcweir 	}
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     Reference< XAccessible > xAccessible;
116*cdf0e10cSrcweir     if ( m_pImpl->m_pAccessible )
117*cdf0e10cSrcweir         xAccessible = m_pImpl->m_pAccessible->getMyself();
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir     return xAccessible;
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir // -----------------------------------------------------------------------------
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir // Children -------------------------------------------------------------------
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos )
126*cdf0e10cSrcweir {
127*cdf0e10cSrcweir 	// BBINDEX_TABLE must be the table
128*cdf0e10cSrcweir 	OSL_ENSURE(m_pImpl->m_pAccessible,"Invalid call: Accessible is null");
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     return m_pImpl->m_aFactoryAccess.getFactory().createAccessibleBrowseBoxTableCell(
131*cdf0e10cSrcweir         m_pImpl->getAccessibleTable(),
132*cdf0e10cSrcweir         *this,
133*cdf0e10cSrcweir         NULL,
134*cdf0e10cSrcweir         _nRow,
135*cdf0e10cSrcweir         _nColumnPos,
136*cdf0e10cSrcweir         OFFSET_DEFAULT
137*cdf0e10cSrcweir     );
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir // -----------------------------------------------------------------------------
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessibleRowHeader( sal_Int32 _nRow )
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir 	return svt::getHeaderCell(
144*cdf0e10cSrcweir 		m_pImpl->m_aRowHeaderCellMap,
145*cdf0e10cSrcweir 		_nRow,
146*cdf0e10cSrcweir 		svt::BBTYPE_ROWHEADERCELL,
147*cdf0e10cSrcweir 		m_pImpl->getAccessibleHeaderBar(svt::BBTYPE_ROWHEADERBAR),
148*cdf0e10cSrcweir 		*this,
149*cdf0e10cSrcweir         m_pImpl->m_aFactoryAccess.getFactory()
150*cdf0e10cSrcweir     );
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir // -----------------------------------------------------------------------------
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos )
155*cdf0e10cSrcweir {
156*cdf0e10cSrcweir 	return svt::getHeaderCell(
157*cdf0e10cSrcweir 			m_pImpl->m_aColHeaderCellMap,
158*cdf0e10cSrcweir 			_nColumnPos,
159*cdf0e10cSrcweir 			svt::BBTYPE_COLUMNHEADERCELL,
160*cdf0e10cSrcweir 			m_pImpl->getAccessibleHeaderBar(svt::BBTYPE_COLUMNHEADERBAR),
161*cdf0e10cSrcweir 			*this,
162*cdf0e10cSrcweir             m_pImpl->m_aFactoryAccess.getFactory()
163*cdf0e10cSrcweir     );
164*cdf0e10cSrcweir }
165*cdf0e10cSrcweir // -----------------------------------------------------------------------------
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir sal_Int32 BrowseBox::GetAccessibleControlCount() const
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir     return 0;
170*cdf0e10cSrcweir }
171*cdf0e10cSrcweir // -----------------------------------------------------------------------------
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir Reference< XAccessible > BrowseBox::CreateAccessibleControl( sal_Int32 )
174*cdf0e10cSrcweir {
175*cdf0e10cSrcweir 	DBG_ASSERT( sal_False, "BrowseBox::CreateAccessibleControl: to be overwritten!" );
176*cdf0e10cSrcweir     return NULL;
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir // -----------------------------------------------------------------------------
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir // Conversions ----------------------------------------------------------------
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir sal_Bool BrowseBox::ConvertPointToCellAddress(
183*cdf0e10cSrcweir         sal_Int32& rnRow, sal_uInt16& rnColumnPos, const Point& rPoint )
184*cdf0e10cSrcweir {
185*cdf0e10cSrcweir     //! TODO has to be checked
186*cdf0e10cSrcweir 	rnRow = GetRowAtYPosPixel(rPoint.Y());
187*cdf0e10cSrcweir 	rnColumnPos = GetColumnAtXPosPixel(rPoint.X());
188*cdf0e10cSrcweir     return rnRow != BROWSER_INVALIDID && rnColumnPos != BROWSER_INVALIDID;
189*cdf0e10cSrcweir }
190*cdf0e10cSrcweir // -----------------------------------------------------------------------------
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir sal_Bool BrowseBox::ConvertPointToRowHeader( sal_Int32& rnRow, const Point& rPoint )
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir     rnRow = GetRowAtYPosPixel(rPoint.Y());
195*cdf0e10cSrcweir 	//	sal_uInt16 nColumnId = GetColumnAtXPosPixel(rPoint.X());
196*cdf0e10cSrcweir     return rnRow != BROWSER_INVALIDID;// && nColumnId == 0;
197*cdf0e10cSrcweir }
198*cdf0e10cSrcweir // -----------------------------------------------------------------------------
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir sal_Bool BrowseBox::ConvertPointToColumnHeader( sal_uInt16& _rnColumnPos, const Point& _rPoint )
201*cdf0e10cSrcweir {
202*cdf0e10cSrcweir 	_rnColumnPos = GetColumnAtXPosPixel(_rPoint.X());
203*cdf0e10cSrcweir     return _rnColumnPos != BROWSER_INVALIDID;
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir // -----------------------------------------------------------------------------
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir sal_Bool BrowseBox::ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint )
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir     //! TODO has to be checked
210*cdf0e10cSrcweir 	sal_Int32 nRow = 0;
211*cdf0e10cSrcweir 	sal_uInt16 nColumn = 0;
212*cdf0e10cSrcweir 	sal_Bool bRet = ConvertPointToCellAddress(nRow,nColumn,_rPoint);
213*cdf0e10cSrcweir 	if ( bRet )
214*cdf0e10cSrcweir 		_rnIndex = nRow * ColCount() + nColumn;
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir     return bRet;
217*cdf0e10cSrcweir }
218*cdf0e10cSrcweir // -----------------------------------------------------------------------------
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir // Object data and state ------------------------------------------------------
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir OUString BrowseBox::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 ) const
223*cdf0e10cSrcweir {
224*cdf0e10cSrcweir     OUString aRetText;
225*cdf0e10cSrcweir     switch( eObjType )
226*cdf0e10cSrcweir     {
227*cdf0e10cSrcweir         case ::svt::BBTYPE_BROWSEBOX:
228*cdf0e10cSrcweir             aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "BrowseBox" ) );
229*cdf0e10cSrcweir 			break;
230*cdf0e10cSrcweir         case ::svt::BBTYPE_TABLE:
231*cdf0e10cSrcweir 			aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "Table" ) );
232*cdf0e10cSrcweir 			break;
233*cdf0e10cSrcweir         case ::svt::BBTYPE_ROWHEADERBAR:
234*cdf0e10cSrcweir 			aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "RowHeaderBar" ) );
235*cdf0e10cSrcweir 			break;
236*cdf0e10cSrcweir         case ::svt::BBTYPE_COLUMNHEADERBAR:
237*cdf0e10cSrcweir 			aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderBar" ) );
238*cdf0e10cSrcweir 			break;
239*cdf0e10cSrcweir         case ::svt::BBTYPE_TABLECELL:
240*cdf0e10cSrcweir             aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "TableCell" ) );
241*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
242*cdf0e10cSrcweir             aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) );
243*cdf0e10cSrcweir 			aRetText += OUString::valueOf(sal_Int32(GetCurRow()));
244*cdf0e10cSrcweir 			aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) );
245*cdf0e10cSrcweir 			aRetText += OUString::valueOf(sal_Int32(GetCurColumnId()));
246*cdf0e10cSrcweir 			aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "]" ) );
247*cdf0e10cSrcweir #endif
248*cdf0e10cSrcweir 			break;
249*cdf0e10cSrcweir         case ::svt::BBTYPE_ROWHEADERCELL:
250*cdf0e10cSrcweir 			aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "RowHeaderCell" ) );
251*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
252*cdf0e10cSrcweir             aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) );
253*cdf0e10cSrcweir 			aRetText += OUString::valueOf(sal_Int32(GetCurRow()));
254*cdf0e10cSrcweir 			aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) );
255*cdf0e10cSrcweir 			aRetText += OUString::valueOf(sal_Int32(GetCurColumnId()));
256*cdf0e10cSrcweir 			aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "]" ) );
257*cdf0e10cSrcweir #endif
258*cdf0e10cSrcweir 			break;
259*cdf0e10cSrcweir         case ::svt::BBTYPE_COLUMNHEADERCELL:
260*cdf0e10cSrcweir 			aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderCell" ) );
261*cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
262*cdf0e10cSrcweir             aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( " [" ) );
263*cdf0e10cSrcweir 			aRetText += OUString::valueOf(sal_Int32(GetCurRow()));
264*cdf0e10cSrcweir 			aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "," ) );
265*cdf0e10cSrcweir 			aRetText += OUString::valueOf(sal_Int32(GetCurColumnId()));
266*cdf0e10cSrcweir 			aRetText += OUString( RTL_CONSTASCII_USTRINGPARAM( "]" ) );
267*cdf0e10cSrcweir #endif
268*cdf0e10cSrcweir 			break;
269*cdf0e10cSrcweir 		default:
270*cdf0e10cSrcweir 			OSL_ENSURE(0,"BrowseBox::GetAccessibleName: invalid enum!");
271*cdf0e10cSrcweir     }
272*cdf0e10cSrcweir     return aRetText;
273*cdf0e10cSrcweir }
274*cdf0e10cSrcweir // -----------------------------------------------------------------------------
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir OUString BrowseBox::GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 ) const
277*cdf0e10cSrcweir {
278*cdf0e10cSrcweir     OUString aRetText;
279*cdf0e10cSrcweir     switch( eObjType )
280*cdf0e10cSrcweir     {
281*cdf0e10cSrcweir         case ::svt::BBTYPE_BROWSEBOX:
282*cdf0e10cSrcweir             aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "BrowseBox description" ) );
283*cdf0e10cSrcweir 			break;
284*cdf0e10cSrcweir         case ::svt::BBTYPE_TABLE:
285*cdf0e10cSrcweir 			//	aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLE description" ) );
286*cdf0e10cSrcweir 			break;
287*cdf0e10cSrcweir         case ::svt::BBTYPE_ROWHEADERBAR:
288*cdf0e10cSrcweir 			//	aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERBAR description" ) );
289*cdf0e10cSrcweir 			break;
290*cdf0e10cSrcweir         case ::svt::BBTYPE_COLUMNHEADERBAR:
291*cdf0e10cSrcweir 			//	aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERBAR description" ) );
292*cdf0e10cSrcweir 			break;
293*cdf0e10cSrcweir         case ::svt::BBTYPE_TABLECELL:
294*cdf0e10cSrcweir 			//	aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLECELL description" ) );
295*cdf0e10cSrcweir 			break;
296*cdf0e10cSrcweir         case ::svt::BBTYPE_ROWHEADERCELL:
297*cdf0e10cSrcweir 			//	aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERCELL description" ) );
298*cdf0e10cSrcweir 			break;
299*cdf0e10cSrcweir         case ::svt::BBTYPE_COLUMNHEADERCELL:
300*cdf0e10cSrcweir 			//	aRetText = OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERCELL description" ) );
301*cdf0e10cSrcweir 			break;
302*cdf0e10cSrcweir         case ::svt::BBTYPE_CHECKBOXCELL:
303*cdf0e10cSrcweir             break;
304*cdf0e10cSrcweir     }
305*cdf0e10cSrcweir     return aRetText;
306*cdf0e10cSrcweir }
307*cdf0e10cSrcweir // -----------------------------------------------------------------------------
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir OUString BrowseBox::GetRowDescription( sal_Int32 ) const
310*cdf0e10cSrcweir {
311*cdf0e10cSrcweir     return OUString();
312*cdf0e10cSrcweir }
313*cdf0e10cSrcweir // -----------------------------------------------------------------------------
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir OUString BrowseBox::GetColumnDescription( sal_uInt16 _nColumn ) const
316*cdf0e10cSrcweir {
317*cdf0e10cSrcweir     return OUString( GetColumnTitle( GetColumnId( _nColumn ) ) );
318*cdf0e10cSrcweir }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir // -----------------------------------------------------------------------------
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir void BrowseBox::FillAccessibleStateSet(
323*cdf0e10cSrcweir         ::utl::AccessibleStateSetHelper& rStateSet,
324*cdf0e10cSrcweir         ::svt::AccessibleBrowseBoxObjType eObjType ) const
325*cdf0e10cSrcweir {
326*cdf0e10cSrcweir 	switch( eObjType )
327*cdf0e10cSrcweir     {
328*cdf0e10cSrcweir         case ::svt::BBTYPE_BROWSEBOX:
329*cdf0e10cSrcweir 		case ::svt::BBTYPE_TABLE:
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir 			rStateSet.AddState( AccessibleStateType::FOCUSABLE );
332*cdf0e10cSrcweir 			if ( HasFocus() )
333*cdf0e10cSrcweir 				rStateSet.AddState( AccessibleStateType::FOCUSED );
334*cdf0e10cSrcweir 			if ( IsActive() )
335*cdf0e10cSrcweir 				rStateSet.AddState( AccessibleStateType::ACTIVE );
336*cdf0e10cSrcweir 			if ( GetUpdateMode() )
337*cdf0e10cSrcweir 				rStateSet.AddState( AccessibleStateType::EDITABLE );
338*cdf0e10cSrcweir 			if ( IsEnabled() )
339*cdf0e10cSrcweir             {
340*cdf0e10cSrcweir 				rStateSet.AddState( AccessibleStateType::ENABLED );
341*cdf0e10cSrcweir                 rStateSet.AddState( AccessibleStateType::SENSITIVE );
342*cdf0e10cSrcweir             }
343*cdf0e10cSrcweir 			if ( IsReallyVisible() )
344*cdf0e10cSrcweir 				rStateSet.AddState( AccessibleStateType::VISIBLE );
345*cdf0e10cSrcweir 			if ( eObjType == ::svt::BBTYPE_TABLE )
346*cdf0e10cSrcweir 				rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir 			break;
349*cdf0e10cSrcweir         case ::svt::BBTYPE_ROWHEADERBAR:
350*cdf0e10cSrcweir 			rStateSet.AddState( AccessibleStateType::FOCUSABLE );
351*cdf0e10cSrcweir 			rStateSet.AddState( AccessibleStateType::VISIBLE );
352*cdf0e10cSrcweir 			if ( GetSelectRowCount() )
353*cdf0e10cSrcweir 				rStateSet.AddState( AccessibleStateType::FOCUSED );
354*cdf0e10cSrcweir 			rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
355*cdf0e10cSrcweir 			break;
356*cdf0e10cSrcweir         case ::svt::BBTYPE_COLUMNHEADERBAR:
357*cdf0e10cSrcweir 			rStateSet.AddState( AccessibleStateType::FOCUSABLE );
358*cdf0e10cSrcweir 			rStateSet.AddState( AccessibleStateType::VISIBLE );
359*cdf0e10cSrcweir 			if ( GetSelectColumnCount() )
360*cdf0e10cSrcweir 				rStateSet.AddState( AccessibleStateType::FOCUSED );
361*cdf0e10cSrcweir 			rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
362*cdf0e10cSrcweir 			break;
363*cdf0e10cSrcweir         case ::svt::BBTYPE_TABLECELL:
364*cdf0e10cSrcweir 			{
365*cdf0e10cSrcweir 				sal_Int32 nRow = GetCurRow();
366*cdf0e10cSrcweir 				sal_uInt16 nColumn = GetCurColumnId();
367*cdf0e10cSrcweir 				if ( IsFieldVisible(nRow,nColumn) )
368*cdf0e10cSrcweir 					rStateSet.AddState( AccessibleStateType::VISIBLE );
369*cdf0e10cSrcweir 				if ( !IsFrozen( nColumn ) )
370*cdf0e10cSrcweir 					rStateSet.AddState( AccessibleStateType::FOCUSABLE );
371*cdf0e10cSrcweir 				rStateSet.AddState( AccessibleStateType::TRANSIENT );
372*cdf0e10cSrcweir 			}
373*cdf0e10cSrcweir 			break;
374*cdf0e10cSrcweir         case ::svt::BBTYPE_ROWHEADERCELL:
375*cdf0e10cSrcweir 		case ::svt::BBTYPE_COLUMNHEADERCELL:
376*cdf0e10cSrcweir         case ::svt::BBTYPE_CHECKBOXCELL:
377*cdf0e10cSrcweir 			OSL_ENSURE(0,"Illegal call here!");
378*cdf0e10cSrcweir 			break;
379*cdf0e10cSrcweir     }
380*cdf0e10cSrcweir }
381*cdf0e10cSrcweir // -----------------------------------------------------------------------
382*cdf0e10cSrcweir void BrowseBox::FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet,
383*cdf0e10cSrcweir 											   sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const
384*cdf0e10cSrcweir {
385*cdf0e10cSrcweir 	//! TODO check if the state is valid for table cells
386*cdf0e10cSrcweir 	if ( IsCellVisible( _nRow, _nColumnPos ) )
387*cdf0e10cSrcweir 		_rStateSet.AddState( AccessibleStateType::VISIBLE );
388*cdf0e10cSrcweir 	if ( GetCurrRow() == _nRow && GetCurrColumn() == _nColumnPos )
389*cdf0e10cSrcweir 		_rStateSet.AddState( AccessibleStateType::FOCUSED );
390*cdf0e10cSrcweir 	else // only transient when column is not focused
391*cdf0e10cSrcweir 		_rStateSet.AddState( AccessibleStateType::TRANSIENT );
392*cdf0e10cSrcweir }
393*cdf0e10cSrcweir // -----------------------------------------------------------------------------
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir void BrowseBox::GrabTableFocus()
396*cdf0e10cSrcweir {
397*cdf0e10cSrcweir     GrabFocus();
398*cdf0e10cSrcweir }
399*cdf0e10cSrcweir // -----------------------------------------------------------------------------
400*cdf0e10cSrcweir String BrowseBox::GetCellText(long, sal_uInt16 ) const
401*cdf0e10cSrcweir {
402*cdf0e10cSrcweir 	DBG_ASSERT(0,"This method has to be implemented by the derived classes! BUG!!");
403*cdf0e10cSrcweir 	return String();
404*cdf0e10cSrcweir }
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir // -----------------------------------------------------------------------------
407*cdf0e10cSrcweir void BrowseBox::commitHeaderBarEvent(sal_Int16 nEventId,
408*cdf0e10cSrcweir         const Any& rNewValue, const Any& rOldValue, sal_Bool _bColumnHeaderBar )
409*cdf0e10cSrcweir {
410*cdf0e10cSrcweir     if ( isAccessibleAlive() )
411*cdf0e10cSrcweir 	    m_pImpl->m_pAccessible->commitHeaderBarEvent( nEventId,
412*cdf0e10cSrcweir             rNewValue, rOldValue, _bColumnHeaderBar );
413*cdf0e10cSrcweir }
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir // -----------------------------------------------------------------------------
416*cdf0e10cSrcweir void BrowseBox::commitTableEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue )
417*cdf0e10cSrcweir {
418*cdf0e10cSrcweir     if ( isAccessibleAlive() )
419*cdf0e10cSrcweir 	    m_pImpl->m_pAccessible->commitTableEvent( _nEventId, _rNewValue, _rOldValue );
420*cdf0e10cSrcweir }
421*cdf0e10cSrcweir // -----------------------------------------------------------------------------
422*cdf0e10cSrcweir void BrowseBox::commitBrowseBoxEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue )
423*cdf0e10cSrcweir {
424*cdf0e10cSrcweir     if ( isAccessibleAlive() )
425*cdf0e10cSrcweir 	    m_pImpl->m_pAccessible->commitEvent( _nEventId, _rNewValue, _rOldValue);
426*cdf0e10cSrcweir }
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir // -----------------------------------------------------------------------------
429*cdf0e10cSrcweir ::svt::IAccessibleFactory& BrowseBox::getAccessibleFactory()
430*cdf0e10cSrcweir {
431*cdf0e10cSrcweir     return m_pImpl->m_aFactoryAccess.getFactory();
432*cdf0e10cSrcweir }
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir // -----------------------------------------------------------------------------
435*cdf0e10cSrcweir sal_Bool BrowseBox::isAccessibleAlive( ) const
436*cdf0e10cSrcweir {
437*cdf0e10cSrcweir     return ( NULL != m_pImpl->m_pAccessible ) && m_pImpl->m_pAccessible->isAlive();
438*cdf0e10cSrcweir }
439*cdf0e10cSrcweir // -----------------------------------------------------------------------------
440*cdf0e10cSrcweir // IAccessibleTableProvider
441*cdf0e10cSrcweir // -----------------------------------------------------------------------------
442*cdf0e10cSrcweir sal_Int32 BrowseBox::GetCurrRow() const
443*cdf0e10cSrcweir {
444*cdf0e10cSrcweir 	return GetCurRow();
445*cdf0e10cSrcweir }
446*cdf0e10cSrcweir // -----------------------------------------------------------------------------
447*cdf0e10cSrcweir sal_uInt16 BrowseBox::GetCurrColumn() const
448*cdf0e10cSrcweir {
449*cdf0e10cSrcweir 	return GetColumnPos( GetCurColumnId() );
450*cdf0e10cSrcweir }
451*cdf0e10cSrcweir // -----------------------------------------------------------------------------
452*cdf0e10cSrcweir sal_Bool BrowseBox::HasRowHeader() const
453*cdf0e10cSrcweir {
454*cdf0e10cSrcweir     return ( GetColumnId( 0 ) == 0 ); // HandleColumn == RowHeader
455*cdf0e10cSrcweir }
456*cdf0e10cSrcweir // -----------------------------------------------------------------------------
457*cdf0e10cSrcweir sal_Bool BrowseBox::IsCellFocusable() const
458*cdf0e10cSrcweir {
459*cdf0e10cSrcweir 	return sal_True;
460*cdf0e10cSrcweir }
461*cdf0e10cSrcweir // -----------------------------------------------------------------------------
462*cdf0e10cSrcweir sal_Bool BrowseBox::GoToCell( sal_Int32 _nRow, sal_uInt16 _nColumn )
463*cdf0e10cSrcweir {
464*cdf0e10cSrcweir 	return GoToRowColumnId( _nRow, GetColumnId( _nColumn ) );
465*cdf0e10cSrcweir }
466*cdf0e10cSrcweir // -----------------------------------------------------------------------------
467*cdf0e10cSrcweir void BrowseBox::SelectColumn( sal_uInt16 _nColumn, sal_Bool _bSelect )
468*cdf0e10cSrcweir {
469*cdf0e10cSrcweir 	SelectColumnPos( _nColumn, _bSelect );
470*cdf0e10cSrcweir }
471*cdf0e10cSrcweir // -----------------------------------------------------------------------------
472*cdf0e10cSrcweir sal_Bool BrowseBox::IsColumnSelected( long _nColumn ) const
473*cdf0e10cSrcweir {
474*cdf0e10cSrcweir     return ( pColSel && (0 <= _nColumn) && (_nColumn <= 0xFFF) ) ?
475*cdf0e10cSrcweir         pColSel->IsSelected( static_cast< sal_uInt16 >( _nColumn ) ) :
476*cdf0e10cSrcweir         sal_False;
477*cdf0e10cSrcweir }
478*cdf0e10cSrcweir // -----------------------------------------------------------------------------
479*cdf0e10cSrcweir sal_Int32 BrowseBox::GetSelectedRowCount() const
480*cdf0e10cSrcweir {
481*cdf0e10cSrcweir 	return GetSelectRowCount();
482*cdf0e10cSrcweir }
483*cdf0e10cSrcweir // -----------------------------------------------------------------------------
484*cdf0e10cSrcweir sal_Int32 BrowseBox::GetSelectedColumnCount() const
485*cdf0e10cSrcweir {
486*cdf0e10cSrcweir     const MultiSelection* pColumnSel = GetColumnSelection();
487*cdf0e10cSrcweir     return pColumnSel ? pColumnSel->GetSelectCount() : 0;
488*cdf0e10cSrcweir }
489*cdf0e10cSrcweir // -----------------------------------------------------------------------------
490*cdf0e10cSrcweir void BrowseBox::GetAllSelectedRows( ::com::sun::star::uno::Sequence< sal_Int32 >& _rRows ) const
491*cdf0e10cSrcweir {
492*cdf0e10cSrcweir     sal_Int32 nCount = GetSelectRowCount();
493*cdf0e10cSrcweir     if( nCount )
494*cdf0e10cSrcweir     {
495*cdf0e10cSrcweir         _rRows.realloc( nCount );
496*cdf0e10cSrcweir         _rRows[ 0 ] = const_cast< BrowseBox* >( this )->FirstSelectedRow();
497*cdf0e10cSrcweir         for( sal_Int32 nIndex = 1; nIndex < nCount; ++nIndex )
498*cdf0e10cSrcweir             _rRows[ nIndex ] = const_cast< BrowseBox* >( this )->NextSelectedRow();
499*cdf0e10cSrcweir         DBG_ASSERT( const_cast< BrowseBox* >( this )->NextSelectedRow() == BROWSER_ENDOFSELECTION,
500*cdf0e10cSrcweir 					"BrowseBox::GetAllSelectedRows - too many selected rows found" );
501*cdf0e10cSrcweir     }
502*cdf0e10cSrcweir }
503*cdf0e10cSrcweir // -----------------------------------------------------------------------------
504*cdf0e10cSrcweir void BrowseBox::GetAllSelectedColumns( ::com::sun::star::uno::Sequence< sal_Int32 >& _rColumns ) const
505*cdf0e10cSrcweir {
506*cdf0e10cSrcweir     const MultiSelection* pColumnSel = GetColumnSelection();
507*cdf0e10cSrcweir     sal_Int32 nCount = GetSelectedColumnCount();
508*cdf0e10cSrcweir     if( pColumnSel && nCount )
509*cdf0e10cSrcweir     {
510*cdf0e10cSrcweir         _rColumns.realloc( nCount );
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir         sal_Int32 nIndex = 0;
513*cdf0e10cSrcweir         sal_uInt32 nRangeCount = pColumnSel->GetRangeCount();
514*cdf0e10cSrcweir         for( sal_uInt32 nRange = 0; nRange < nRangeCount; ++nRange )
515*cdf0e10cSrcweir         {
516*cdf0e10cSrcweir             const Range& rRange = pColumnSel->GetRange( nRange );
517*cdf0e10cSrcweir             // loop has to include aRange.Max()
518*cdf0e10cSrcweir             for( sal_Int32 nCol = rRange.Min(); nCol <= rRange.Max(); ++nCol )
519*cdf0e10cSrcweir             {
520*cdf0e10cSrcweir                 DBG_ASSERT( nIndex < nCount,
521*cdf0e10cSrcweir                     "GetAllSelectedColumns - range overflow" );
522*cdf0e10cSrcweir                 _rColumns[ nIndex ] = nCol;
523*cdf0e10cSrcweir                 ++nIndex;
524*cdf0e10cSrcweir             }
525*cdf0e10cSrcweir         }
526*cdf0e10cSrcweir     }
527*cdf0e10cSrcweir }
528*cdf0e10cSrcweir // -----------------------------------------------------------------------------
529*cdf0e10cSrcweir sal_Bool BrowseBox::IsCellVisible( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const
530*cdf0e10cSrcweir {
531*cdf0e10cSrcweir 	return IsFieldVisible( _nRow, GetColumnId( _nColumnPos ) );
532*cdf0e10cSrcweir }
533*cdf0e10cSrcweir // -----------------------------------------------------------------------------
534*cdf0e10cSrcweir String BrowseBox::GetAccessibleCellText(long _nRow, sal_uInt16 _nColPos) const
535*cdf0e10cSrcweir {
536*cdf0e10cSrcweir     return GetCellText( _nRow, GetColumnId( _nColPos ) );
537*cdf0e10cSrcweir }
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir // -----------------------------------------------------------------------------
540*cdf0e10cSrcweir sal_Bool BrowseBox::GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector )
541*cdf0e10cSrcweir {
542*cdf0e10cSrcweir 	return Control::GetGlyphBoundRects( rOrigin, rStr, nIndex, nLen, nBase, rVector );
543*cdf0e10cSrcweir }
544*cdf0e10cSrcweir // -----------------------------------------------------------------------------
545*cdf0e10cSrcweir Rectangle BrowseBox::GetWindowExtentsRelative( Window *pRelativeWindow ) const
546*cdf0e10cSrcweir {
547*cdf0e10cSrcweir 	return Control::GetWindowExtentsRelative( pRelativeWindow );
548*cdf0e10cSrcweir }
549*cdf0e10cSrcweir // -----------------------------------------------------------------------------
550*cdf0e10cSrcweir void BrowseBox::GrabFocus()
551*cdf0e10cSrcweir {
552*cdf0e10cSrcweir 	Control::GrabFocus();
553*cdf0e10cSrcweir }
554*cdf0e10cSrcweir // -----------------------------------------------------------------------------
555*cdf0e10cSrcweir Reference< XAccessible > BrowseBox::GetAccessible( sal_Bool bCreate )
556*cdf0e10cSrcweir {
557*cdf0e10cSrcweir 	return Control::GetAccessible( bCreate );
558*cdf0e10cSrcweir }
559*cdf0e10cSrcweir // -----------------------------------------------------------------------------
560*cdf0e10cSrcweir Window* BrowseBox::GetAccessibleParentWindow() const
561*cdf0e10cSrcweir {
562*cdf0e10cSrcweir 	return Control::GetAccessibleParentWindow();
563*cdf0e10cSrcweir }
564*cdf0e10cSrcweir // -----------------------------------------------------------------------------
565*cdf0e10cSrcweir Window* BrowseBox::GetWindowInstance()
566*cdf0e10cSrcweir {
567*cdf0e10cSrcweir 	return this;
568*cdf0e10cSrcweir }
569