xref: /trunk/main/accessibility/source/extended/AccessibleGridControlHeaderCell.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_accessibility.hxx"
30 
31 #include "accessibility/extended/AccessibleGridControlHeaderCell.hxx"
32 #include <svtools/accessibletable.hxx>
33 #include "accessibility/extended/AccessibleGridControl.hxx"
34 
35 namespace accessibility
36 {
37     using namespace ::com::sun::star::accessibility;
38     using namespace ::com::sun::star::lang;
39     using namespace ::com::sun::star::uno;
40     using namespace ::svt;
41     using namespace ::svt::table;
42 
43 AccessibleGridControlHeaderCell::AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId,
44                                   const Reference< XAccessible >& rxParent,
45                                   IAccessibleTable& rTable,
46                                   AccessibleTableControlObjType  eObjType)
47 : AccessibleGridControlCell( rxParent, rTable, _nColumnRowId, 0, eObjType)
48 , m_nColumnRowId(_nColumnRowId)
49 {
50 }
51 /** Creates a new AccessibleStateSetHelper and fills it with states of the
52     current object.
53     @return
54         A filled AccessibleStateSetHelper.
55 */
56 ::utl::AccessibleStateSetHelper* AccessibleGridControlHeaderCell::implCreateStateSetHelper()
57 {
58     ::osl::MutexGuard aGuard( getOslMutex() );
59     ::utl::AccessibleStateSetHelper*
60         pStateSetHelper = new ::utl::AccessibleStateSetHelper;
61 
62     if( isAlive() )
63     {
64         // SHOWING done with mxParent
65         if( implIsShowing() )
66             pStateSetHelper->AddState( AccessibleStateType::SHOWING );
67 
68         TCSolarGuard aSolarGuard;
69         pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
70         pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
71         pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
72         pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
73 
74         if ( m_aTable.IsRowSelected(m_nColumnRowId) )
75             pStateSetHelper->AddState( AccessibleStateType::SELECTED );
76     }
77     else
78         pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
79 
80     return pStateSetHelper;
81 }
82 // -----------------------------------------------------------------------------
83 /** @return
84         The count of visible children.
85 */
86 sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChildCount()
87     throw ( RuntimeException )
88 {
89     return 0;
90 }
91 // -----------------------------------------------------------------------------
92 
93 /** @return
94         The XAccessible interface of the specified child.
95 */
96 Reference<XAccessible > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int32 )
97     throw ( IndexOutOfBoundsException,RuntimeException )
98 {
99     throw IndexOutOfBoundsException();
100 }
101 // XInterface -------------------------------------------------------------
102 
103     /** Queries for a new interface. */
104     ::com::sun::star::uno::Any SAL_CALL AccessibleGridControlHeaderCell::queryInterface(
105             const ::com::sun::star::uno::Type& rType )
106         throw ( ::com::sun::star::uno::RuntimeException )
107     {
108         Any aRet = AccessibleGridControlCell::queryInterface(rType);
109         return aRet;
110     }
111 
112     /** Aquires the object (calls acquire() on base class). */
113     void SAL_CALL AccessibleGridControlHeaderCell::acquire() throw ()
114     {
115         AccessibleGridControlCell::acquire();
116     }
117 
118     /** Releases the object (calls release() on base class). */
119     void SAL_CALL AccessibleGridControlHeaderCell::release() throw ()
120     {
121         AccessibleGridControlCell::release();
122     }
123         /** @return  The XAccessibleContext interface of this object. */
124     Reference< com::sun::star::accessibility::XAccessibleContext > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleContext() throw ( RuntimeException )
125     {
126         ensureIsAlive();
127         return this;
128     }
129 
130 // -----------------------------------------------------------------------------
131 
132 /** Grabs the focus to the column header. */
133 void SAL_CALL AccessibleGridControlHeaderCell::grabFocus()
134     throw ( ::com::sun::star::uno::RuntimeException )
135 {
136 }
137 // -----------------------------------------------------------------------------
138 /** @return
139         The name of this class.
140 */
141 ::rtl::OUString SAL_CALL AccessibleGridControlHeaderCell::getImplementationName()
142     throw ( ::com::sun::star::uno::RuntimeException )
143 {
144     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlHeaderCell" ) );
145 }
146 // -----------------------------------------------------------------------------
147 Rectangle AccessibleGridControlHeaderCell::implGetBoundingBox()
148 {
149     Window* pParent = m_aTable.GetAccessibleParentWindow();
150     Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) );
151     sal_Int32 nIndex = getAccessibleIndexInParent();
152     Rectangle aCellRect;
153     if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
154         aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
155     else
156         aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
157     return Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
158 }
159 // -----------------------------------------------------------------------------
160 
161 Rectangle AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen()
162 {
163     Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( NULL ) );
164     sal_Int32 nIndex = getAccessibleIndexInParent();
165     Rectangle aCellRect;
166     if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
167         aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
168     else
169         aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
170     return Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
171 }
172 // -----------------------------------------------------------------------------
173 sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleIndexInParent()
174     throw ( RuntimeException )
175 {
176     ::osl::MutexGuard aGuard( getOslMutex() );
177     ensureIsAlive();
178     sal_Int32 nIndex = m_nColumnRowId;
179     return nIndex;
180 }
181 // -----------------------------------------------------------------------------
182 } // namespace accessibility
183 // -----------------------------------------------------------------------------
184 
185 
186