1*0841af79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*0841af79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*0841af79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*0841af79SAndrew Rist  * distributed with this work for additional information
6*0841af79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*0841af79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*0841af79SAndrew Rist  * "License"); you may not use this file except in compliance
9*0841af79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*0841af79SAndrew Rist  *
11*0841af79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*0841af79SAndrew Rist  *
13*0841af79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*0841af79SAndrew Rist  * software distributed under the License is distributed on an
15*0841af79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0841af79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*0841af79SAndrew Rist  * specific language governing permissions and limitations
18*0841af79SAndrew Rist  * under the License.
19*0841af79SAndrew Rist  *
20*0841af79SAndrew Rist  *************************************************************/
21*0841af79SAndrew Rist 
22*0841af79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "accessibility/extended/AccessibleBrowseBoxHeaderCell.hxx"
28cdf0e10cSrcweir #include <svtools/accessibletableprovider.hxx>
29cdf0e10cSrcweir #include "accessibility/extended/AccessibleBrowseBox.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir namespace accessibility
32cdf0e10cSrcweir {
33cdf0e10cSrcweir 	using namespace ::com::sun::star::accessibility;
34cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
35cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
36cdf0e10cSrcweir     using namespace ::svt;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir AccessibleBrowseBoxHeaderCell::AccessibleBrowseBoxHeaderCell(sal_Int32 _nColumnRowId,
39cdf0e10cSrcweir 								  const Reference< XAccessible >& rxParent,
40cdf0e10cSrcweir 								  IAccessibleTableProvider&                  rBrowseBox,
41cdf0e10cSrcweir 								  const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
42cdf0e10cSrcweir 								  AccessibleBrowseBoxObjType  eObjType)
43cdf0e10cSrcweir : BrowseBoxAccessibleElement(rxParent,
44cdf0e10cSrcweir 						  rBrowseBox,
45cdf0e10cSrcweir 						  _xFocusWindow,
46cdf0e10cSrcweir 						  eObjType,
47cdf0e10cSrcweir 						  rBrowseBox.GetAccessibleObjectName( eObjType ,_nColumnRowId),
48cdf0e10cSrcweir 						  rBrowseBox.GetAccessibleObjectDescription( eObjType ,_nColumnRowId))
49cdf0e10cSrcweir , m_nColumnRowId(_nColumnRowId)
50cdf0e10cSrcweir {
51cdf0e10cSrcweir }
52cdf0e10cSrcweir /** Creates a new AccessibleStateSetHelper and fills it with states of the
53cdf0e10cSrcweir 	current object.
54cdf0e10cSrcweir 	@return
55cdf0e10cSrcweir 		A filled AccessibleStateSetHelper.
56cdf0e10cSrcweir */
57cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* AccessibleBrowseBoxHeaderCell::implCreateStateSetHelper()
58cdf0e10cSrcweir {
59cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getOslMutex() );
60cdf0e10cSrcweir 	::utl::AccessibleStateSetHelper*
61cdf0e10cSrcweir 		pStateSetHelper = new ::utl::AccessibleStateSetHelper;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	if( isAlive() )
64cdf0e10cSrcweir 	{
65cdf0e10cSrcweir 		// SHOWING done with mxParent
66cdf0e10cSrcweir 		if( implIsShowing() )
67cdf0e10cSrcweir 			pStateSetHelper->AddState( AccessibleStateType::SHOWING );
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 		BBSolarGuard aSolarGuard;
70cdf0e10cSrcweir 		pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
71cdf0e10cSrcweir 		pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
72cdf0e10cSrcweir 		pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
73cdf0e10cSrcweir 		pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 		sal_Bool bSelected = isRowBarCell() ? mpBrowseBox->IsRowSelected(m_nColumnRowId) : mpBrowseBox->IsColumnSelected(m_nColumnRowId);
76cdf0e10cSrcweir 		if ( bSelected )
77cdf0e10cSrcweir 			pStateSetHelper->AddState( AccessibleStateType::SELECTED );
78cdf0e10cSrcweir 	}
79cdf0e10cSrcweir 	else
80cdf0e10cSrcweir 		pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	return pStateSetHelper;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir // -----------------------------------------------------------------------------
85cdf0e10cSrcweir /** @return
86cdf0e10cSrcweir 		The count of visible children.
87cdf0e10cSrcweir */
88cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChildCount()
89cdf0e10cSrcweir 	throw ( RuntimeException )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir 	return 0;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir // -----------------------------------------------------------------------------
94cdf0e10cSrcweir 
95cdf0e10cSrcweir /** @return
96cdf0e10cSrcweir 		The XAccessible interface of the specified child.
97cdf0e10cSrcweir */
98cdf0e10cSrcweir Reference<XAccessible > SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChild( sal_Int32 )
99cdf0e10cSrcweir 	throw ( IndexOutOfBoundsException,RuntimeException )
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
102cdf0e10cSrcweir }
103cdf0e10cSrcweir // -----------------------------------------------------------------------------
104cdf0e10cSrcweir 
105cdf0e10cSrcweir /** Grabs the focus to the column header. */
106cdf0e10cSrcweir void SAL_CALL AccessibleBrowseBoxHeaderCell::grabFocus()
107cdf0e10cSrcweir 	throw ( ::com::sun::star::uno::RuntimeException )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	BBSolarGuard aSolarGuard;
110cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getOslMutex() );
111cdf0e10cSrcweir 	ensureIsAlive();
112cdf0e10cSrcweir 	if ( isRowBarCell() )
113cdf0e10cSrcweir 		mpBrowseBox->SelectRow(m_nColumnRowId);
114cdf0e10cSrcweir 	else
115cdf0e10cSrcweir 		mpBrowseBox->SelectColumn(static_cast<sal_uInt16>(m_nColumnRowId)); //!!!
116cdf0e10cSrcweir }
117cdf0e10cSrcweir // -----------------------------------------------------------------------------
118cdf0e10cSrcweir /** @return
119cdf0e10cSrcweir 		The name of this class.
120cdf0e10cSrcweir */
121cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleBrowseBoxHeaderCell::getImplementationName()
122cdf0e10cSrcweir 	throw ( ::com::sun::star::uno::RuntimeException )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderCell" ) );
125cdf0e10cSrcweir }
126cdf0e10cSrcweir // -----------------------------------------------------------------------------
127cdf0e10cSrcweir namespace
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	Rectangle getRectangle(IAccessibleTableProvider* _pBrowseBox,sal_Int32 _nRowColIndex, sal_Bool _bOnScreen,sal_Bool _bRowBar)
130cdf0e10cSrcweir 	{
131cdf0e10cSrcweir 		sal_Int32 nRow  = 0;
132cdf0e10cSrcweir 		sal_uInt16 nCol =  (sal_uInt16)_nRowColIndex;
133cdf0e10cSrcweir 		if ( _bRowBar )
134cdf0e10cSrcweir 		{
135cdf0e10cSrcweir 			nRow = _nRowColIndex + 1;
136cdf0e10cSrcweir 			nCol = 0;
137cdf0e10cSrcweir 		}
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 		Rectangle aRet(_pBrowseBox->GetFieldRectPixelAbs( nRow , nCol, sal_True, _bOnScreen));
140cdf0e10cSrcweir 		return Rectangle(aRet.TopLeft() - Point(0,aRet.GetHeight()),aRet.GetSize());
141cdf0e10cSrcweir 	}
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBox()
145cdf0e10cSrcweir {
146cdf0e10cSrcweir 	return getRectangle(mpBrowseBox,m_nColumnRowId,sal_False,isRowBarCell());
147cdf0e10cSrcweir }
148cdf0e10cSrcweir // -----------------------------------------------------------------------------
149cdf0e10cSrcweir 
150cdf0e10cSrcweir Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBoxOnScreen()
151cdf0e10cSrcweir {
152cdf0e10cSrcweir 	return getRectangle(mpBrowseBox,m_nColumnRowId,sal_True,isRowBarCell());
153cdf0e10cSrcweir }
154cdf0e10cSrcweir // -----------------------------------------------------------------------------
155cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleIndexInParent()
156cdf0e10cSrcweir     throw ( RuntimeException )
157cdf0e10cSrcweir {
158cdf0e10cSrcweir     ::osl::MutexGuard aGuard( getOslMutex() );
159cdf0e10cSrcweir     ensureIsAlive();
160cdf0e10cSrcweir 	sal_Int32 nIndex = m_nColumnRowId;
161cdf0e10cSrcweir 	if ( mpBrowseBox->HasRowHeader() )
162cdf0e10cSrcweir 		--nIndex;
163cdf0e10cSrcweir 	return nIndex;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir // -----------------------------------------------------------------------------
166cdf0e10cSrcweir } // namespace accessibility
167cdf0e10cSrcweir // -----------------------------------------------------------------------------
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 
170