Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / accessibility / source / extended / AccessibleGridControlHeaderCell.cxx
blob548c21b05e5b3fe315111d635925c326525c8228
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "accessibility/extended/AccessibleGridControlHeaderCell.hxx"
22 #include <svtools/accessibletable.hxx>
23 #include "accessibility/extended/AccessibleGridControl.hxx"
25 namespace accessibility
27 using namespace ::com::sun::star::accessibility;
28 using namespace ::com::sun::star::lang;
29 using namespace ::com::sun::star::uno;
30 using namespace ::svt;
31 using namespace ::svt::table;
33 AccessibleGridControlHeaderCell::AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId,
34 const Reference< XAccessible >& rxParent,
35 IAccessibleTable& rTable,
36 AccessibleTableControlObjType eObjType)
37 : AccessibleGridControlCell( rxParent, rTable, _nColumnRowId, 0, eObjType)
38 , m_nColumnRowId(_nColumnRowId)
41 /** Creates a new AccessibleStateSetHelper and fills it with states of the
42 current object.
43 @return
44 A filled AccessibleStateSetHelper.
46 ::utl::AccessibleStateSetHelper* AccessibleGridControlHeaderCell::implCreateStateSetHelper()
48 ::osl::MutexGuard aGuard( getOslMutex() );
49 ::utl::AccessibleStateSetHelper*
50 pStateSetHelper = new ::utl::AccessibleStateSetHelper;
52 if( isAlive() )
54 // SHOWING done with mxParent
55 if( implIsShowing() )
56 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
58 SolarMutexGuard aSolarGuard;
59 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
60 pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
61 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
62 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
64 if ( m_aTable.IsRowSelected(m_nColumnRowId) )
65 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
67 else
68 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
70 return pStateSetHelper;
72 // -----------------------------------------------------------------------------
73 /** @return
74 The count of visible children.
76 sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChildCount()
77 throw ( RuntimeException )
79 return 0;
81 // -----------------------------------------------------------------------------
83 /** @return
84 The XAccessible interface of the specified child.
86 Reference<XAccessible > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int32 )
87 throw ( IndexOutOfBoundsException,RuntimeException )
89 throw IndexOutOfBoundsException();
91 // XInterface -------------------------------------------------------------
93 /** Queries for a new interface. */
94 ::com::sun::star::uno::Any SAL_CALL AccessibleGridControlHeaderCell::queryInterface(
95 const ::com::sun::star::uno::Type& rType )
96 throw ( ::com::sun::star::uno::RuntimeException )
98 Any aRet = AccessibleGridControlCell::queryInterface(rType);
99 return aRet;
102 /** Aquires the object (calls acquire() on base class). */
103 void SAL_CALL AccessibleGridControlHeaderCell::acquire() throw ()
105 AccessibleGridControlCell::acquire();
108 /** Releases the object (calls release() on base class). */
109 void SAL_CALL AccessibleGridControlHeaderCell::release() throw ()
111 AccessibleGridControlCell::release();
113 /** @return The XAccessibleContext interface of this object. */
114 Reference< com::sun::star::accessibility::XAccessibleContext > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleContext() throw ( RuntimeException )
116 ensureIsAlive();
117 return this;
120 // -----------------------------------------------------------------------------
122 /** Grabs the focus to the column header. */
123 void SAL_CALL AccessibleGridControlHeaderCell::grabFocus()
124 throw ( ::com::sun::star::uno::RuntimeException )
127 // -----------------------------------------------------------------------------
128 /** @return
129 The name of this class.
131 OUString SAL_CALL AccessibleGridControlHeaderCell::getImplementationName()
132 throw ( ::com::sun::star::uno::RuntimeException )
134 return OUString( "com.sun.star.accessibility.AccessibleGridControlHeaderCell" );
136 // -----------------------------------------------------------------------------
137 Rectangle AccessibleGridControlHeaderCell::implGetBoundingBox()
139 Window* pParent = m_aTable.GetAccessibleParentWindow();
140 Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) );
141 sal_Int32 nIndex = getAccessibleIndexInParent();
142 Rectangle aCellRect;
143 if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
144 aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
145 else
146 aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
147 return Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
149 // -----------------------------------------------------------------------------
151 Rectangle AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen()
153 Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( NULL ) );
154 sal_Int32 nIndex = getAccessibleIndexInParent();
155 Rectangle aCellRect;
156 if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
157 aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
158 else
159 aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
160 return Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
162 // -----------------------------------------------------------------------------
163 sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleIndexInParent()
164 throw ( RuntimeException )
166 ::osl::MutexGuard aGuard( getOslMutex() );
167 ensureIsAlive();
168 sal_Int32 nIndex = m_nColumnRowId;
169 return nIndex;
171 // -----------------------------------------------------------------------------
172 } // namespace accessibility
173 // -----------------------------------------------------------------------------
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */