tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / accessibility / source / extended / AccessibleGridControlHeaderCell.cxx
blob57baebd2df28ffd03b24c3c0aff967ec61713613
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 .
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>
26 namespace accessibility
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;
34 AccessibleGridControlHeaderCell::AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId,
35 const Reference< XAccessible >& rxParent,
36 IAccessibleTable& rTable,
37 AccessibleTableControlObjType eObjType)
38 : AccessibleGridControlCell(rxParent, rTable,
39 (eObjType == AccessibleTableControlObjType::ROWHEADERCELL) ? _nColumnRowId : 0,
40 (eObjType == AccessibleTableControlObjType::ROWHEADERCELL) ? 0 : _nColumnRowId,
41 eObjType)
42 , m_nColumnRowId(_nColumnRowId)
44 assert(eObjType == AccessibleTableControlObjType::ROWHEADERCELL || eObjType == AccessibleTableControlObjType::COLUMNHEADERCELL);
46 /** Return a bitset of states of the current object.
48 sal_Int64 AccessibleGridControlHeaderCell::implCreateStateSet()
50 sal_Int64 nStateSet = 0;
52 if( isAlive() )
54 // SHOWING done with mxParent
55 if( implIsShowing() )
56 nStateSet |= AccessibleStateType::SHOWING;
58 nStateSet |= AccessibleStateType::VISIBLE;
59 nStateSet |= AccessibleStateType::FOCUSABLE;
60 nStateSet |= AccessibleStateType::TRANSIENT;
61 nStateSet |= AccessibleStateType::SELECTABLE;
63 if ( m_aTable.IsRowSelected(m_nColumnRowId) )
64 nStateSet |= AccessibleStateType::SELECTED;
66 else
67 nStateSet |= AccessibleStateType::DEFUNC;
69 return nStateSet;
72 /** @return
73 The count of visible children.
75 sal_Int64 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChildCount()
77 return 0;
81 /** @return
82 The XAccessible interface of the specified child.
84 Reference<XAccessible > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int64 )
86 throw IndexOutOfBoundsException();
88 // XInterface -------------------------------------------------------------
90 /** Queries for a new interface. */
91 css::uno::Any SAL_CALL AccessibleGridControlHeaderCell::queryInterface( const css::uno::Type& rType )
93 Any aRet = AccessibleGridControlCell::queryInterface(rType);
94 return aRet;
97 /** Acquires the object (calls acquire() on base class). */
98 void SAL_CALL AccessibleGridControlHeaderCell::acquire() noexcept
100 AccessibleGridControlCell::acquire();
103 /** Releases the object (calls release() on base class). */
104 void SAL_CALL AccessibleGridControlHeaderCell::release() noexcept
106 AccessibleGridControlCell::release();
108 /** @return The XAccessibleContext interface of this object. */
109 Reference< css::accessibility::XAccessibleContext > SAL_CALL AccessibleGridControlHeaderCell::getAccessibleContext()
111 ensureIsAlive();
112 return this;
116 /** Grabs the focus to the column header. */
117 void SAL_CALL AccessibleGridControlHeaderCell::grabFocus()
121 /** @return
122 The name of this class.
124 OUString SAL_CALL AccessibleGridControlHeaderCell::getImplementationName()
126 return u"com.sun.star.accessibility.AccessibleGridControlHeaderCell"_ustr;
129 tools::Rectangle AccessibleGridControlHeaderCell::implGetBoundingBox()
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 == AccessibleTableControlObjType::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());
143 AbsoluteScreenPixelRectangle AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen()
145 AbsoluteScreenPixelRectangle aGridRect( m_aTable.GetWindowExtentsAbsolute() );
146 sal_Int32 nIndex = getAccessibleIndexInParent();
147 tools::Rectangle aCellRect;
148 if (m_eObjType == AccessibleTableControlObjType::COLUMNHEADERCELL)
149 aCellRect = m_aTable.calcHeaderCellRect(true, nIndex);
150 else
151 aCellRect = m_aTable.calcHeaderCellRect(false, nIndex);
152 return AbsoluteScreenPixelRectangle(AbsoluteScreenPixelPoint(aGridRect.Left()+aCellRect.Left(),aGridRect.Top()+aCellRect.Top()), aCellRect.GetSize());
155 sal_Int64 SAL_CALL AccessibleGridControlHeaderCell::getAccessibleIndexInParent()
157 SolarMutexGuard g;
159 ensureIsAlive();
160 return m_nColumnRowId;
163 } // namespace accessibility
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */