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 <toolkit/helper/convert.hxx>
24 #include <vcl/accessibletable.hxx>
25 #include <vcl/svapp.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_Int32 nChildIndex
)
56 SolarMutexGuard aSolarGuard
;
58 if (nChildIndex
<0 || nChildIndex
>=getAccessibleChildCount())
59 throw IndexOutOfBoundsException();
61 Reference
< XAccessible
> xChild
;
62 if(m_eObjType
== vcl::table::TCTYPE_COLUMNHEADERBAR
)
64 AccessibleGridControlHeaderCell
* pColHeaderCell
= new AccessibleGridControlHeaderCell(nChildIndex
, this, m_aTable
, vcl::table::TCTYPE_COLUMNHEADERCELL
);
65 xChild
= pColHeaderCell
;
67 else if(m_eObjType
== vcl::table::TCTYPE_ROWHEADERBAR
)
69 AccessibleGridControlHeaderCell
* pRowHeaderCell
= new AccessibleGridControlHeaderCell(nChildIndex
, this, m_aTable
, vcl::table::TCTYPE_ROWHEADERCELL
);
70 xChild
= pRowHeaderCell
;
75 sal_Int32 SAL_CALL
AccessibleGridControlHeader::getAccessibleIndexInParent()
78 if(m_eObjType
== vcl::table::TCTYPE_ROWHEADERBAR
&& m_aTable
.HasColHeader())
84 // XAccessibleComponent -------------------------------------------------------
86 Reference
< XAccessible
> SAL_CALL
87 AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point
& rPoint
)
89 SolarMutexGuard aSolarGuard
;
94 sal_Int32 nColumnPos
= 0;
95 bool bConverted
= m_aTable
.ConvertPointToCellAddress(nRow
, nColumnPos
, VCLPoint(rPoint
));
96 return bConverted
? implGetChild( nRow
, nColumnPos
) : Reference
< XAccessible
>();
99 void SAL_CALL
AccessibleGridControlHeader::grabFocus()
102 // focus on header not supported
105 // XAccessibleTable -----------------------------------------------------------
107 OUString SAL_CALL
AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow
)
109 SolarMutexGuard aSolarGuard
;
112 ensureIsValidRow( nRow
);
113 return OUString(); // no headers in headers
116 OUString SAL_CALL
AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn
)
118 SolarMutexGuard aSolarGuard
;
121 ensureIsValidColumn( nColumn
);
122 return OUString(); // no headers in headers
125 Reference
< XAccessibleTable
> SAL_CALL
AccessibleGridControlHeader::getAccessibleRowHeaders()
130 return nullptr; // no headers in headers
133 Reference
< XAccessibleTable
> SAL_CALL
AccessibleGridControlHeader::getAccessibleColumnHeaders()
138 return nullptr; // no headers in headers
141 Sequence
< sal_Int32
> SAL_CALL
AccessibleGridControlHeader::getSelectedAccessibleRows()
143 Sequence
< sal_Int32
> aSelSeq(0);
146 //columns aren't selectable
147 Sequence
< sal_Int32
> SAL_CALL
AccessibleGridControlHeader::getSelectedAccessibleColumns()
149 Sequence
< sal_Int32
> aSelSeq(0);
152 //row headers not selectable
153 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32
/*nRow*/ )
157 //columns aren't selectable
158 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32
)
163 Reference
< XAccessible
> SAL_CALL
AccessibleGridControlHeader::getAccessibleCellAt(
164 sal_Int32
/*nRow*/, sal_Int32
/*nColumn*/ )
169 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleSelected(
170 sal_Int32
/*nRow*/, sal_Int32
/*nColumn */)
175 // XServiceInfo ---------------------------------------------------------------
177 OUString SAL_CALL
AccessibleGridControlHeader::getImplementationName()
179 return "com.sun.star.accessibility.AccessibleGridControlHeader";
182 Sequence
< sal_Int8
> SAL_CALL
AccessibleGridControlHeader::getImplementationId()
184 return css::uno::Sequence
<sal_Int8
>();
187 // internal virtual methods ---------------------------------------------------
189 tools::Rectangle
AccessibleGridControlHeader::implGetBoundingBox()
191 vcl::Window
* pParent
= m_aTable
.GetAccessibleParentWindow();
192 tools::Rectangle
aGridRect( m_aTable
.GetWindowExtentsRelative( pParent
) );
193 tools::Rectangle
aHeaderRect (m_aTable
.calcHeaderRect(isColumnBar()));
195 return tools::Rectangle(aGridRect
.TopLeft(), Size(aGridRect
.getWidth(),aHeaderRect
.getHeight()));
197 return tools::Rectangle(aGridRect
.TopLeft(), Size(aHeaderRect
.getWidth(),aGridRect
.getHeight()));
201 tools::Rectangle
AccessibleGridControlHeader::implGetBoundingBoxOnScreen()
203 tools::Rectangle
aGridRect( m_aTable
.GetWindowExtentsRelative( nullptr ) );
204 tools::Rectangle
aHeaderRect (m_aTable
.calcHeaderRect(isColumnBar()));
206 return tools::Rectangle(aGridRect
.TopLeft(), Size(aGridRect
.getWidth(),aHeaderRect
.getHeight()));
208 return tools::Rectangle(aGridRect
.TopLeft(), Size(aHeaderRect
.getWidth(),aGridRect
.getHeight()));
211 // internal helper methods ----------------------------------------------------
212 Reference
< XAccessible
> AccessibleGridControlHeader::implGetChild(
213 sal_Int32 nRow
, sal_uInt32 nColumnPos
)
215 Reference
< XAccessible
> xChild
;
216 if(m_eObjType
== vcl::table::TCTYPE_COLUMNHEADERBAR
)
218 AccessibleGridControlHeaderCell
* pColHeaderCell
= new AccessibleGridControlHeaderCell(nColumnPos
, this, m_aTable
, vcl::table::TCTYPE_COLUMNHEADERCELL
);
219 xChild
= pColHeaderCell
;
221 else if(m_eObjType
== vcl::table::TCTYPE_ROWHEADERBAR
)
223 AccessibleGridControlHeaderCell
* pRowHeaderCell
= new AccessibleGridControlHeaderCell(nRow
, this, m_aTable
, vcl::table::TCTYPE_ROWHEADERCELL
);
224 xChild
= pRowHeaderCell
;
229 } // namespace accessibility
231 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */