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/lang/IndexOutOfBoundsException.hpp>
21 #include <extended/AccessibleGridControlHeader.hxx>
22 #include <extended/AccessibleGridControlHeaderCell.hxx>
23 #include <vcl/accessibletable.hxx>
24 #include <vcl/svapp.hxx>
25 #include <vcl/unohelp.hxx>
27 using ::com::sun::star::uno::Reference
;
28 using ::com::sun::star::uno::Sequence
;
30 using namespace ::com::sun::star::uno
;
31 using namespace ::com::sun::star
;
32 using namespace ::com::sun::star::lang
;
33 using namespace ::com::sun::star::accessibility
;
34 using namespace ::vcl
;
35 using namespace ::vcl::table
;
38 namespace accessibility
{
41 AccessibleGridControlHeader::AccessibleGridControlHeader(
42 const Reference
< XAccessible
>& rxParent
,
43 ::vcl::table::IAccessibleTable
& rTable
,
44 ::vcl::table::AccessibleTableControlObjType eObjType
):
45 AccessibleGridControlTableBase( rxParent
, rTable
, eObjType
)
47 OSL_ENSURE( isRowBar() || isColumnBar(),
48 "extended/AccessibleGridControlHeaderBar - invalid object type" );
51 // XAccessibleContext ---------------------------------------------------------
53 Reference
< XAccessible
> SAL_CALL
54 AccessibleGridControlHeader::getAccessibleChild( sal_Int64 nChildIndex
)
56 SolarMutexGuard aSolarGuard
;
58 if (nChildIndex
<0 || nChildIndex
>=getAccessibleChildCount())
59 throw IndexOutOfBoundsException();
61 Reference
< XAccessible
> xChild
;
62 if (m_eObjType
== vcl::table::AccessibleTableControlObjType::COLUMNHEADERBAR
)
64 rtl::Reference
<AccessibleGridControlHeaderCell
> pColHeaderCell
= new AccessibleGridControlHeaderCell(nChildIndex
, this, m_aTable
,
65 vcl::table::AccessibleTableControlObjType::COLUMNHEADERCELL
);
66 xChild
= pColHeaderCell
;
68 else if (m_eObjType
== vcl::table::AccessibleTableControlObjType::ROWHEADERBAR
)
70 rtl::Reference
<AccessibleGridControlHeaderCell
> pRowHeaderCell
= new AccessibleGridControlHeaderCell(nChildIndex
, this, m_aTable
,
71 vcl::table::AccessibleTableControlObjType::ROWHEADERCELL
);
72 xChild
= pRowHeaderCell
;
77 sal_Int64 SAL_CALL
AccessibleGridControlHeader::getAccessibleIndexInParent()
79 SolarMutexGuard aSolarGuard
;
82 if (m_eObjType
== vcl::table::AccessibleTableControlObjType::ROWHEADERBAR
&& m_aTable
.HasColHeader())
88 // XAccessibleComponent -------------------------------------------------------
90 Reference
< XAccessible
> SAL_CALL
91 AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point
& rPoint
)
93 SolarMutexGuard aSolarGuard
;
98 sal_Int32 nColumnPos
= 0;
99 bool bConverted
= m_aTable
.ConvertPointToCellAddress(nRow
, nColumnPos
,
100 vcl::unohelper::ConvertToVCLPoint(rPoint
));
101 return bConverted
? implGetChild( nRow
, nColumnPos
) : Reference
< XAccessible
>();
104 void SAL_CALL
AccessibleGridControlHeader::grabFocus()
107 // focus on header not supported
110 // XAccessibleTable -----------------------------------------------------------
112 OUString SAL_CALL
AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow
)
114 SolarMutexGuard aSolarGuard
;
117 ensureIsValidRow( nRow
);
118 return OUString(); // no headers in headers
121 OUString SAL_CALL
AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn
)
123 SolarMutexGuard aSolarGuard
;
126 ensureIsValidColumn( nColumn
);
127 return OUString(); // no headers in headers
130 Reference
< XAccessibleTable
> SAL_CALL
AccessibleGridControlHeader::getAccessibleRowHeaders()
135 return nullptr; // no headers in headers
138 Reference
< XAccessibleTable
> SAL_CALL
AccessibleGridControlHeader::getAccessibleColumnHeaders()
143 return nullptr; // no headers in headers
146 Sequence
< sal_Int32
> SAL_CALL
AccessibleGridControlHeader::getSelectedAccessibleRows()
150 //columns aren't selectable
151 Sequence
< sal_Int32
> SAL_CALL
AccessibleGridControlHeader::getSelectedAccessibleColumns()
155 //row headers not selectable
156 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32
/*nRow*/ )
160 //columns aren't selectable
161 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32
)
166 Reference
< XAccessible
> SAL_CALL
AccessibleGridControlHeader::getAccessibleCellAt(
167 sal_Int32 nRow
, sal_Int32 nColumn
)
172 ensureIsValidAddress(nRow
, nColumn
);
173 return implGetChild(nRow
, nColumn
);
176 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleSelected(
177 sal_Int32
/*nRow*/, sal_Int32
/*nColumn */)
182 // XServiceInfo ---------------------------------------------------------------
184 OUString SAL_CALL
AccessibleGridControlHeader::getImplementationName()
186 return u
"com.sun.star.accessibility.AccessibleGridControlHeader"_ustr
;
189 Sequence
< sal_Int8
> SAL_CALL
AccessibleGridControlHeader::getImplementationId()
191 return css::uno::Sequence
<sal_Int8
>();
194 // internal virtual methods ---------------------------------------------------
196 tools::Rectangle
AccessibleGridControlHeader::implGetBoundingBox()
198 vcl::Window
* pParent
= m_aTable
.GetAccessibleParentWindow();
199 tools::Rectangle
aGridRect( m_aTable
.GetWindowExtentsRelative( *pParent
) );
200 tools::Rectangle
aHeaderRect (m_aTable
.calcHeaderRect(isColumnBar()));
202 return tools::Rectangle(aGridRect
.TopLeft(), Size(aGridRect
.getOpenWidth(),aHeaderRect
.getOpenHeight()));
204 return tools::Rectangle(aGridRect
.TopLeft(), Size(aHeaderRect
.getOpenWidth(),aGridRect
.getOpenHeight()));
208 AbsoluteScreenPixelRectangle
AccessibleGridControlHeader::implGetBoundingBoxOnScreen()
210 AbsoluteScreenPixelRectangle
aGridRect( m_aTable
.GetWindowExtentsAbsolute() );
211 tools::Rectangle
aHeaderRect (m_aTable
.calcHeaderRect(isColumnBar()));
213 return AbsoluteScreenPixelRectangle(aGridRect
.TopLeft(), Size(aGridRect
.getOpenWidth(),aHeaderRect
.getOpenHeight()));
215 return AbsoluteScreenPixelRectangle(aGridRect
.TopLeft(), Size(aHeaderRect
.getOpenWidth(),aGridRect
.getOpenHeight()));
218 // internal helper methods ----------------------------------------------------
219 Reference
< XAccessible
> AccessibleGridControlHeader::implGetChild(
220 sal_Int32 nRow
, sal_uInt32 nColumnPos
)
222 Reference
< XAccessible
> xChild
;
223 if (m_eObjType
== vcl::table::AccessibleTableControlObjType::COLUMNHEADERBAR
)
225 rtl::Reference
<AccessibleGridControlHeaderCell
> pColHeaderCell
= new AccessibleGridControlHeaderCell(nColumnPos
, this, m_aTable
,
226 vcl::table::AccessibleTableControlObjType::COLUMNHEADERCELL
);
227 xChild
= pColHeaderCell
;
229 else if (m_eObjType
== vcl::table::AccessibleTableControlObjType::ROWHEADERBAR
)
231 rtl::Reference
<AccessibleGridControlHeaderCell
> pRowHeaderCell
= new AccessibleGridControlHeaderCell(nRow
, this, m_aTable
,
232 vcl::table::AccessibleTableControlObjType::ROWHEADERCELL
);
233 xChild
= pRowHeaderCell
;
238 } // namespace accessibility
240 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */