10841af79SAndrew Rist /**************************************************************
2*d69df039Smseidel  *
30841af79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
40841af79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
50841af79SAndrew Rist  * distributed with this work for additional information
60841af79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
70841af79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
80841af79SAndrew Rist  * "License"); you may not use this file except in compliance
90841af79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d69df039Smseidel  *
110841af79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d69df039Smseidel  *
130841af79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
140841af79SAndrew Rist  * software distributed under the License is distributed on an
150841af79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
160841af79SAndrew Rist  * KIND, either express or implied.  See the License for the
170841af79SAndrew Rist  * specific language governing permissions and limitations
180841af79SAndrew Rist  * under the License.
19*d69df039Smseidel  *
200841af79SAndrew Rist  *************************************************************/
210841af79SAndrew Rist 
220841af79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_accessibility.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "accessibility/extended/AccessibleGridControlHeaderCell.hxx"
28cdf0e10cSrcweir #include <svtools/accessibletable.hxx>
29cdf0e10cSrcweir #include "accessibility/extended/AccessibleGridControl.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;
36*d69df039Smseidel 	using namespace ::svt;
37cdf0e10cSrcweir 	using namespace ::svt::table;
38cdf0e10cSrcweir 
AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId,const Reference<XAccessible> & rxParent,IAccessibleTable & rTable,AccessibleTableControlObjType eObjType)39cdf0e10cSrcweir AccessibleGridControlHeaderCell::AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId,
40cdf0e10cSrcweir 								  const Reference< XAccessible >& rxParent,
41cdf0e10cSrcweir 								  IAccessibleTable& rTable,
42cdf0e10cSrcweir 								  AccessibleTableControlObjType  eObjType)
43cdf0e10cSrcweir : AccessibleGridControlCell( rxParent, rTable, _nColumnRowId, 0, eObjType)
44cdf0e10cSrcweir , m_nColumnRowId(_nColumnRowId)
45cdf0e10cSrcweir {
46cdf0e10cSrcweir }
47cdf0e10cSrcweir /** Creates a new AccessibleStateSetHelper and fills it with states of the
48cdf0e10cSrcweir 	current object.
49cdf0e10cSrcweir 	@return
50cdf0e10cSrcweir 		A filled AccessibleStateSetHelper.
51cdf0e10cSrcweir */
implCreateStateSetHelper()52cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* AccessibleGridControlHeaderCell::implCreateStateSetHelper()
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	::osl::MutexGuard aGuard( getOslMutex() );
55cdf0e10cSrcweir 	::utl::AccessibleStateSetHelper*
56cdf0e10cSrcweir 		pStateSetHelper = new ::utl::AccessibleStateSetHelper;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 	if( isAlive() )
59cdf0e10cSrcweir 	{
60cdf0e10cSrcweir 		// SHOWING done with mxParent
61cdf0e10cSrcweir 		if( implIsShowing() )
62cdf0e10cSrcweir 			pStateSetHelper->AddState( AccessibleStateType::SHOWING );
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 		TCSolarGuard aSolarGuard;
65cdf0e10cSrcweir 		pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
66cdf0e10cSrcweir 		pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
67cdf0e10cSrcweir 		pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
68cdf0e10cSrcweir 		pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 		if ( m_aTable.IsRowSelected(m_nColumnRowId) )
71cdf0e10cSrcweir 			pStateSetHelper->AddState( AccessibleStateType::SELECTED );
72cdf0e10cSrcweir 	}
73cdf0e10cSrcweir 	else
74cdf0e10cSrcweir 		pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	return pStateSetHelper;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir // -----------------------------------------------------------------------------
79cdf0e10cSrcweir /** @return
80cdf0e10cSrcweir 		The count of visible children.
81cdf0e10cSrcweir */
getAccessibleChildCount()82cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChildCount()
83cdf0e10cSrcweir 	throw ( RuntimeException )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir 	return 0;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir // -----------------------------------------------------------------------------
88cdf0e10cSrcweir 
89cdf0e10cSrcweir /** @return
90cdf0e10cSrcweir 		The XAccessible interface of the specified child.
91cdf0e10cSrcweir */
getAccessibleChild(sal_Int32)92cdf0e10cSrcweir Reference<XAccessible > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int32 )
93cdf0e10cSrcweir 	throw ( IndexOutOfBoundsException,RuntimeException )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir 	throw IndexOutOfBoundsException();
96cdf0e10cSrcweir }
97cdf0e10cSrcweir // XInterface -------------------------------------------------------------
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	/** Queries for a new interface. */
queryInterface(const::com::sun::star::uno::Type & rType)100cdf0e10cSrcweir 	::com::sun::star::uno::Any SAL_CALL AccessibleGridControlHeaderCell::queryInterface(
101cdf0e10cSrcweir 			const ::com::sun::star::uno::Type& rType )
102cdf0e10cSrcweir 		throw ( ::com::sun::star::uno::RuntimeException )
103cdf0e10cSrcweir 	{
104cdf0e10cSrcweir 		Any aRet = AccessibleGridControlCell::queryInterface(rType);
105cdf0e10cSrcweir 		return aRet;
106cdf0e10cSrcweir 	}
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	/** Aquires the object (calls acquire() on base class). */
acquire()109cdf0e10cSrcweir 	void SAL_CALL AccessibleGridControlHeaderCell::acquire() throw ()
110cdf0e10cSrcweir 	{
111cdf0e10cSrcweir 		AccessibleGridControlCell::acquire();
112cdf0e10cSrcweir 	}
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	/** Releases the object (calls release() on base class). */
release()115cdf0e10cSrcweir 	void SAL_CALL AccessibleGridControlHeaderCell::release() throw ()
116cdf0e10cSrcweir 	{
117cdf0e10cSrcweir 		AccessibleGridControlCell::release();
118cdf0e10cSrcweir 	}
119cdf0e10cSrcweir 		/** @return  The XAccessibleContext interface of this object. */
getAccessibleContext()120cdf0e10cSrcweir 	Reference< com::sun::star::accessibility::XAccessibleContext > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleContext() throw ( RuntimeException )
121cdf0e10cSrcweir 	{
122cdf0e10cSrcweir 		ensureIsAlive();
123cdf0e10cSrcweir 		return this;
124cdf0e10cSrcweir 	}
125cdf0e10cSrcweir 
126cdf0e10cSrcweir // -----------------------------------------------------------------------------
127cdf0e10cSrcweir 
128cdf0e10cSrcweir /** Grabs the focus to the column header. */
grabFocus()129cdf0e10cSrcweir void SAL_CALL AccessibleGridControlHeaderCell::grabFocus()
130cdf0e10cSrcweir 	throw ( ::com::sun::star::uno::RuntimeException )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir }
133cdf0e10cSrcweir // -----------------------------------------------------------------------------
134cdf0e10cSrcweir /** @return
135cdf0e10cSrcweir 		The name of this class.
136cdf0e10cSrcweir */
getImplementationName()137cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleGridControlHeaderCell::getImplementationName()
138cdf0e10cSrcweir 	throw ( ::com::sun::star::uno::RuntimeException )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir 	return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlHeaderCell" ) );
141cdf0e10cSrcweir }
142cdf0e10cSrcweir // -----------------------------------------------------------------------------
implGetBoundingBox()143cdf0e10cSrcweir Rectangle AccessibleGridControlHeaderCell::implGetBoundingBox()
144cdf0e10cSrcweir {
145cdf0e10cSrcweir 	Window* pParent = m_aTable.GetAccessibleParentWindow();
146cdf0e10cSrcweir 	Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) );
147cdf0e10cSrcweir 	sal_Int32 nIndex = getAccessibleIndexInParent();
148cdf0e10cSrcweir 	Rectangle aCellRect;
149cdf0e10cSrcweir 	if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
150cdf0e10cSrcweir 		aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
151cdf0e10cSrcweir 	else
152cdf0e10cSrcweir 		aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
153cdf0e10cSrcweir 	return Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
154cdf0e10cSrcweir }
155cdf0e10cSrcweir // -----------------------------------------------------------------------------
156cdf0e10cSrcweir 
implGetBoundingBoxOnScreen()157cdf0e10cSrcweir Rectangle AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen()
158cdf0e10cSrcweir {
159cdf0e10cSrcweir 	Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( NULL ) );
160cdf0e10cSrcweir 	sal_Int32 nIndex = getAccessibleIndexInParent();
161cdf0e10cSrcweir 	Rectangle aCellRect;
162cdf0e10cSrcweir 	if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
163cdf0e10cSrcweir 		aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
164cdf0e10cSrcweir 	else
165cdf0e10cSrcweir 		aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
166cdf0e10cSrcweir 	return Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
167cdf0e10cSrcweir }
168cdf0e10cSrcweir // -----------------------------------------------------------------------------
getAccessibleIndexInParent()169cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleIndexInParent()
170*d69df039Smseidel 	throw ( RuntimeException )
171cdf0e10cSrcweir {
172*d69df039Smseidel 	::osl::MutexGuard aGuard( getOslMutex() );
173*d69df039Smseidel 	ensureIsAlive();
174*d69df039Smseidel 	sal_Int32 nIndex = m_nColumnRowId;
175*d69df039Smseidel 	return nIndex;
176cdf0e10cSrcweir }
177cdf0e10cSrcweir // -----------------------------------------------------------------------------
178cdf0e10cSrcweir } // namespace accessibility
179cdf0e10cSrcweir // -----------------------------------------------------------------------------
180