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 <extended/AccessibleGridControlHeader.hxx>
21 #include <extended/AccessibleGridControlHeaderCell.hxx>
22 #include <extended/AccessibleGridControlTableCell.hxx>
23 #include <vcl/accessibletable.hxx>
25 using ::com::sun::star::uno::Reference
;
26 using ::com::sun::star::uno::Sequence
;
28 using namespace ::com::sun::star::uno
;
29 using namespace ::com::sun::star
;
30 using namespace ::com::sun::star::lang
;
31 using namespace ::com::sun::star::accessibility
;
32 using namespace ::vcl
;
33 using namespace ::vcl::table
;
36 namespace accessibility
{
39 AccessibleGridControlHeader::AccessibleGridControlHeader(
40 const Reference
< XAccessible
>& rxParent
,
41 ::vcl::table::IAccessibleTable
& rTable
,
42 ::vcl::table::AccessibleTableControlObjType eObjType
):
43 AccessibleGridControlTableBase( rxParent
, rTable
, eObjType
)
45 OSL_ENSURE( isRowBar() || isColumnBar(),
46 "extended/AccessibleGridControlHeaderBar - invalid object type" );
49 // XAccessibleContext ---------------------------------------------------------
51 Reference
< XAccessible
> SAL_CALL
52 AccessibleGridControlHeader::getAccessibleChild( sal_Int32 nChildIndex
)
54 SolarMutexGuard aSolarGuard
;
56 if (nChildIndex
<0 || nChildIndex
>=getAccessibleChildCount())
57 throw IndexOutOfBoundsException();
59 Reference
< XAccessible
> xChild
;
60 if(m_eObjType
== vcl::table::TCTYPE_COLUMNHEADERBAR
)
62 AccessibleGridControlHeaderCell
* pColHeaderCell
= new AccessibleGridControlHeaderCell(nChildIndex
, this, m_aTable
, vcl::table::TCTYPE_COLUMNHEADERCELL
);
63 xChild
= pColHeaderCell
;
65 else if(m_eObjType
== vcl::table::TCTYPE_ROWHEADERBAR
)
67 AccessibleGridControlHeaderCell
* pRowHeaderCell
= new AccessibleGridControlHeaderCell(nChildIndex
, this, m_aTable
, vcl::table::TCTYPE_ROWHEADERCELL
);
68 xChild
= pRowHeaderCell
;
73 sal_Int32 SAL_CALL
AccessibleGridControlHeader::getAccessibleIndexInParent()
76 if(m_eObjType
== vcl::table::TCTYPE_ROWHEADERBAR
&& m_aTable
.HasColHeader())
82 // XAccessibleComponent -------------------------------------------------------
84 Reference
< XAccessible
> SAL_CALL
85 AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point
& rPoint
)
87 SolarMutexGuard aSolarGuard
;
92 sal_Int32 nColumnPos
= 0;
93 bool bConverted
= m_aTable
.ConvertPointToCellAddress(nRow
, nColumnPos
, VCLPoint(rPoint
));
94 return bConverted
? implGetChild( nRow
, nColumnPos
) : Reference
< XAccessible
>();
97 void SAL_CALL
AccessibleGridControlHeader::grabFocus()
100 // focus on header not supported
103 // XAccessibleTable -----------------------------------------------------------
105 OUString SAL_CALL
AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow
)
107 SolarMutexGuard aSolarGuard
;
110 ensureIsValidRow( nRow
);
111 return OUString(); // no headers in headers
114 OUString SAL_CALL
AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn
)
116 SolarMutexGuard aSolarGuard
;
119 ensureIsValidColumn( nColumn
);
120 return OUString(); // no headers in headers
123 Reference
< XAccessibleTable
> SAL_CALL
AccessibleGridControlHeader::getAccessibleRowHeaders()
128 return nullptr; // no headers in headers
131 Reference
< XAccessibleTable
> SAL_CALL
AccessibleGridControlHeader::getAccessibleColumnHeaders()
136 return nullptr; // no headers in headers
139 Sequence
< sal_Int32
> SAL_CALL
AccessibleGridControlHeader::getSelectedAccessibleRows()
141 Sequence
< sal_Int32
> aSelSeq(0);
144 //columns aren't selectable
145 Sequence
< sal_Int32
> SAL_CALL
AccessibleGridControlHeader::getSelectedAccessibleColumns()
147 Sequence
< sal_Int32
> aSelSeq(0);
150 //row headers not selectable
151 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32
/*nRow*/ )
155 //columns aren't selectable
156 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32
)
161 Reference
< XAccessible
> SAL_CALL
AccessibleGridControlHeader::getAccessibleCellAt(
162 sal_Int32
/*nRow*/, sal_Int32
/*nColumn*/ )
167 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleSelected(
168 sal_Int32
/*nRow*/, sal_Int32
/*nColumn */)
173 // XServiceInfo ---------------------------------------------------------------
175 OUString SAL_CALL
AccessibleGridControlHeader::getImplementationName()
177 return OUString( "com.sun.star.accessibility.AccessibleGridControlHeader" );
180 Sequence
< sal_Int8
> SAL_CALL
AccessibleGridControlHeader::getImplementationId()
182 return css::uno::Sequence
<sal_Int8
>();
185 // internal virtual methods ---------------------------------------------------
187 tools::Rectangle
AccessibleGridControlHeader::implGetBoundingBox()
189 vcl::Window
* pParent
= m_aTable
.GetAccessibleParentWindow();
190 tools::Rectangle
aGridRect( m_aTable
.GetWindowExtentsRelative( pParent
) );
191 tools::Rectangle
aHeaderRect (m_aTable
.calcHeaderRect(isColumnBar()));
193 return tools::Rectangle(aGridRect
.TopLeft(), Size(aGridRect
.getWidth(),aHeaderRect
.getHeight()));
195 return tools::Rectangle(aGridRect
.TopLeft(), Size(aHeaderRect
.getWidth(),aGridRect
.getHeight()));
199 tools::Rectangle
AccessibleGridControlHeader::implGetBoundingBoxOnScreen()
201 tools::Rectangle
aGridRect( m_aTable
.GetWindowExtentsRelative( nullptr ) );
202 tools::Rectangle
aHeaderRect (m_aTable
.calcHeaderRect(isColumnBar()));
204 return tools::Rectangle(aGridRect
.TopLeft(), Size(aGridRect
.getWidth(),aHeaderRect
.getHeight()));
206 return tools::Rectangle(aGridRect
.TopLeft(), Size(aHeaderRect
.getWidth(),aGridRect
.getHeight()));
209 // internal helper methods ----------------------------------------------------
210 Reference
< XAccessible
> AccessibleGridControlHeader::implGetChild(
211 sal_Int32 nRow
, sal_uInt32 nColumnPos
)
213 Reference
< XAccessible
> xChild
;
214 if(m_eObjType
== vcl::table::TCTYPE_COLUMNHEADERBAR
)
216 AccessibleGridControlHeaderCell
* pColHeaderCell
= new AccessibleGridControlHeaderCell(nColumnPos
, this, m_aTable
, vcl::table::TCTYPE_COLUMNHEADERCELL
);
217 xChild
= pColHeaderCell
;
219 else if(m_eObjType
== vcl::table::TCTYPE_ROWHEADERBAR
)
221 AccessibleGridControlHeaderCell
* pRowHeaderCell
= new AccessibleGridControlHeaderCell(nRow
, this, m_aTable
, vcl::table::TCTYPE_ROWHEADERCELL
);
222 xChild
= pRowHeaderCell
;
227 } // namespace accessibility
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */