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