1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
, _nColumnRowId
, 0, eObjType
)
39 , m_nColumnRowId(_nColumnRowId
)
42 /** Return a bitset of states of the current object.
44 sal_Int64
AccessibleGridControlHeaderCell::implCreateStateSet()
46 sal_Int64 nStateSet
= 0;
50 // SHOWING done with mxParent
52 nStateSet
|= AccessibleStateType::SHOWING
;
54 nStateSet
|= AccessibleStateType::VISIBLE
;
55 nStateSet
|= AccessibleStateType::FOCUSABLE
;
56 nStateSet
|= AccessibleStateType::TRANSIENT
;
57 nStateSet
|= AccessibleStateType::SELECTABLE
;
59 if ( m_aTable
.IsRowSelected(m_nColumnRowId
) )
60 nStateSet
|= AccessibleStateType::SELECTED
;
63 nStateSet
|= AccessibleStateType::DEFUNC
;
69 The count of visible children.
71 sal_Int64 SAL_CALL
AccessibleGridControlHeaderCell::getAccessibleChildCount()
78 The XAccessible interface of the specified child.
80 Reference
<XAccessible
> SAL_CALL
AccessibleGridControlHeaderCell::getAccessibleChild( sal_Int64
)
82 throw IndexOutOfBoundsException();
84 // XInterface -------------------------------------------------------------
86 /** Queries for a new interface. */
87 css::uno::Any SAL_CALL
AccessibleGridControlHeaderCell::queryInterface( const css::uno::Type
& rType
)
89 Any aRet
= AccessibleGridControlCell::queryInterface(rType
);
93 /** Acquires the object (calls acquire() on base class). */
94 void SAL_CALL
AccessibleGridControlHeaderCell::acquire() noexcept
96 AccessibleGridControlCell::acquire();
99 /** Releases the object (calls release() on base class). */
100 void SAL_CALL
AccessibleGridControlHeaderCell::release() noexcept
102 AccessibleGridControlCell::release();
104 /** @return The XAccessibleContext interface of this object. */
105 Reference
< css::accessibility::XAccessibleContext
> SAL_CALL
AccessibleGridControlHeaderCell::getAccessibleContext()
112 /** Grabs the focus to the column header. */
113 void SAL_CALL
AccessibleGridControlHeaderCell::grabFocus()
118 The name of this class.
120 OUString SAL_CALL
AccessibleGridControlHeaderCell::getImplementationName()
122 return "com.sun.star.accessibility.AccessibleGridControlHeaderCell";
125 tools::Rectangle
AccessibleGridControlHeaderCell::implGetBoundingBox()
127 vcl::Window
* pParent
= m_aTable
.GetAccessibleParentWindow();
128 tools::Rectangle
aGridRect( m_aTable
.GetWindowExtentsRelative( pParent
) );
129 sal_Int32 nIndex
= getAccessibleIndexInParent();
130 tools::Rectangle aCellRect
;
131 if(m_eObjType
== TCTYPE_COLUMNHEADERCELL
)
132 aCellRect
= m_aTable
.calcHeaderCellRect(true, nIndex
);
134 aCellRect
= m_aTable
.calcHeaderCellRect(false, nIndex
);
135 return tools::Rectangle(Point(aGridRect
.Left()+aCellRect
.Left(),aGridRect
.Top()+aCellRect
.Top()), aCellRect
.GetSize());
139 tools::Rectangle
AccessibleGridControlHeaderCell::implGetBoundingBoxOnScreen()
141 tools::Rectangle
aGridRect( m_aTable
.GetWindowExtentsRelative( nullptr ) );
142 sal_Int32 nIndex
= getAccessibleIndexInParent();
143 tools::Rectangle aCellRect
;
144 if(m_eObjType
== TCTYPE_COLUMNHEADERCELL
)
145 aCellRect
= m_aTable
.calcHeaderCellRect(true, nIndex
);
147 aCellRect
= m_aTable
.calcHeaderCellRect(false, nIndex
);
148 return tools::Rectangle(Point(aGridRect
.Left()+aCellRect
.Left(),aGridRect
.Top()+aCellRect
.Top()), aCellRect
.GetSize());
151 sal_Int64 SAL_CALL
AccessibleGridControlHeaderCell::getAccessibleIndexInParent()
156 return m_nColumnRowId
;
159 } // namespace accessibility
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */