1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
21 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
22 #include <extended/AccessibleGridControlHeaderCell.hxx>
23 #include <vcl/accessibletable.hxx>
24 #include <vcl/svapp.hxx>
25
26 namespace accessibility
27 {
28 using namespace ::com::sun::star::accessibility;
29 using namespace ::com::sun::star::lang;
30 using namespace ::com::sun::star::uno;
31 using namespace ::vcl;
32 using namespace ::vcl::table;
33
AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId,const Reference<XAccessible> & rxParent,IAccessibleTable & rTable,AccessibleTableControlObjType eObjType)34 AccessibleGridControlHeaderCell::AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId,
35 const Reference< XAccessible >& rxParent,
36 IAccessibleTable& rTable,
37 AccessibleTableControlObjType eObjType)
38 : AccessibleGridControlCell( rxParent, rTable, _nColumnRowId, 0, eObjType)
39 , m_nColumnRowId(_nColumnRowId)
40 {
41 }
42 /** Creates a new AccessibleStateSetHelper and fills it with states of the
43 current object.
44 @return
45 A filled AccessibleStateSetHelper.
46 */
implCreateStateSetHelper()47 ::utl::AccessibleStateSetHelper* AccessibleGridControlHeaderCell::implCreateStateSetHelper()
48 {
49 ::utl::AccessibleStateSetHelper*
50 pStateSetHelper = new ::utl::AccessibleStateSetHelper;
51
52 if( isAlive() )
53 {
54 // SHOWING done with mxParent
55 if( implIsShowing() )
56 pStateSetHelper->AddState( AccessibleStateType::SHOWING );
57
58 pStateSetHelper->AddState( AccessibleStateType::VISIBLE );
59 pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE );
60 pStateSetHelper->AddState( AccessibleStateType::TRANSIENT );
61 pStateSetHelper->AddState( AccessibleStateType::SELECTABLE );
62
63 if ( m_aTable.IsRowSelected(m_nColumnRowId) )
64 pStateSetHelper->AddState( AccessibleStateType::SELECTED );
65 }
66 else
67 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
68
69 return pStateSetHelper;
70 }
71
72 /** @return
73 The count of visible children.
74 */
getAccessibleChildCount()75 sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChildCount()
76 {
77 return 0;
78 }
79
80
81 /** @return
82 The XAccessible interface of the specified child.
83 */
getAccessibleChild(sal_Int32)84 Reference<XAccessible > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int32 )
85 {
86 throw IndexOutOfBoundsException();
87 }
88 // XInterface -------------------------------------------------------------
89
90 /** Queries for a new interface. */
queryInterface(const css::uno::Type & rType)91 css::uno::Any SAL_CALL AccessibleGridControlHeaderCell::queryInterface( const css::uno::Type& rType )
92 {
93 Any aRet = AccessibleGridControlCell::queryInterface(rType);
94 return aRet;
95 }
96
97 /** Acquires the object (calls acquire() on base class). */
acquire()98 void SAL_CALL AccessibleGridControlHeaderCell::acquire() throw ()
99 {
100 AccessibleGridControlCell::acquire();
101 }
102
103 /** Releases the object (calls release() on base class). */
release()104 void SAL_CALL AccessibleGridControlHeaderCell::release() throw ()
105 {
106 AccessibleGridControlCell::release();
107 }
108 /** @return The XAccessibleContext interface of this object. */
getAccessibleContext()109 Reference< css::accessibility::XAccessibleContext > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleContext()
110 {
111 ensureIsAlive();
112 return this;
113 }
114
115
116 /** Grabs the focus to the column header. */
grabFocus()117 void SAL_CALL AccessibleGridControlHeaderCell::grabFocus()
118 {
119 }
120
121 /** @return
122 The name of this class.
123 */
getImplementationName()124 OUString SAL_CALL AccessibleGridControlHeaderCell::getImplementationName()
125 {
126 return "com.sun.star.accessibility.AccessibleGridControlHeaderCell";
127 }
128
implGetBoundingBox()129 tools::Rectangle AccessibleGridControlHeaderCell::implGetBoundingBox()
130 {
131 vcl::Window* pParent = m_aTable.GetAccessibleParentWindow();
132 tools::Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) );
133 sal_Int32 nIndex = getAccessibleIndexInParent();
134 tools::Rectangle aCellRect;
135 if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
136 aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
137 else
138 aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
139 return tools::Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
140 }
141
142
implGetBoundingBoxOnScreen()143 tools::Rectangle AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen()
144 {
145 tools::Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( nullptr ) );
146 sal_Int32 nIndex = getAccessibleIndexInParent();
147 tools::Rectangle aCellRect;
148 if(m_eObjType == TCTYPE_COLUMNHEADERCELL)
149 aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
150 else
151 aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
152 return tools::Rectangle(Point(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
153 }
154
getAccessibleIndexInParent()155 sal_Int32 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleIndexInParent()
156 {
157 SolarMutexGuard g;
158
159 ensureIsAlive();
160 sal_Int32 nIndex = m_nColumnRowId;
161 return nIndex;
162 }
163
164 } // namespace accessibility
165
166
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
168