Debian Codegraph @

toolkit/source/controls/table/AccessibleGridControlHeaderCell.cxx

raw
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 <controls/table/AccessibleGridControlHeaderCell.hxx>
23 #include <vcl/svapp.hxx>
24
25 namespace accessibility
26 {
27 using namespace ::com::sun::star::accessibility;
28 using namespace ::com::sun::star::lang;
29 using namespace ::com::sun::star::uno;
30 using namespace ::vcl;
31
32 AccessibleGridControlHeaderCell::AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId,
33 const Reference< XAccessible >& rxParent,
34 svt::table::TableControl& rTable,
35 AccessibleTableControlObjType eObjType)
36 : AccessibleGridControlCell(rxParent, rTable,
37 (eObjType == AccessibleTableControlObjType::ROWHEADERCELL) ? _nColumnRowId : 0,
38 (eObjType == AccessibleTableControlObjType::ROWHEADERCELL) ? 0 : _nColumnRowId,
39 eObjType)
40 , m_nColumnRowId(_nColumnRowId)
41 {
42 assert(eObjType == AccessibleTableControlObjType::ROWHEADERCELL || eObjType == AccessibleTableControlObjType::COLUMNHEADERCELL);
43 }
44
45 /** Return a bitset of states of the current object.
46 */
47 sal_Int64 AccessibleGridControlHeaderCell::implCreateStateSet()
48 {
49 sal_Int64 nStateSet = 0;
50
51 if( isAlive() )
52 {
53 // SHOWING done with mxParent
54 if( implIsShowing() )
55 nStateSet |= AccessibleStateType::SHOWING;
56
57 nStateSet |= AccessibleStateType::VISIBLE;
58 nStateSet |= AccessibleStateType::FOCUSABLE;
59 nStateSet |= AccessibleStateType::TRANSIENT;
60 nStateSet |= AccessibleStateType::SELECTABLE;
61
62 if ( m_aTable.IsRowSelected(m_nColumnRowId) )
63 nStateSet |= AccessibleStateType::SELECTED;
64 }
65 else
66 nStateSet |= AccessibleStateType::DEFUNC;
67
68 return nStateSet;
69 }
70
71 /** @return
72 The count of visible children.
73 */
74 sal_Int64 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChildCount()
75 {
76 return 0;
77 }
78
79
80 /** @return
81 The XAccessible interface of the specified child.
82 */
83 Reference<XAccessible > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int64 )
84 {
85 throw IndexOutOfBoundsException();
86 }
87
88 /** Grabs the focus to the column header. */
89 void SAL_CALL AccessibleGridControlHeaderCell::grabFocus()
90 {
91 }
92
93 /** @return
94 The name of this class.
95 */
96 OUString SAL_CALL AccessibleGridControlHeaderCell::getImplementationName()
97 {
98 return u"com.sun.star.accessibility.AccessibleGridControlHeaderCell"_ustr;
99 }
100
101 AbsoluteScreenPixelRectangle AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen()
102 {
103 AbsoluteScreenPixelRectangle aGridRect( m_aTable.GetWindowExtentsAbsolute() );
104 sal_Int32 nIndex = getAccessibleIndexInParent();
105 tools::Rectangle aCellRect;
106 if (m_eObjType == AccessibleTableControlObjType::COLUMNHEADERCELL)
107 aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
108 else
109 aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
110 return AbsoluteScreenPixelRectangle(AbsoluteScreenPixelPoint(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
111 }
112
113 sal_Int64 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleIndexInParent()
114 {
115 SolarMutexGuard g;
116
117 ensureAlive();
118 return m_nColumnRowId;
119 }
120
121 } // namespace accessibility
122
123
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */