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 "accessibility/extended/AccessibleGridControlHeader.hxx"
21 #include "accessibility/extended/AccessibleGridControlHeaderCell.hxx"
22 #include "accessibility/extended/AccessibleGridControlTableCell.hxx"
23 #include <svtools/accessibletable.hxx>
24 #include <comphelper/servicehelper.hxx>
29 using ::com::sun::star::uno::Reference
;
30 using ::com::sun::star::uno::Sequence
;
31 using ::com::sun::star::uno::Any
;
33 using namespace ::com::sun::star::uno
;
34 using namespace ::com::sun::star
;
35 using namespace ::com::sun::star::lang
;
36 using namespace ::com::sun::star::accessibility
;
37 using namespace ::svt
;
38 using namespace ::svt::table
;
42 namespace accessibility
{
46 AccessibleGridControlHeader::AccessibleGridControlHeader(
47 const Reference
< XAccessible
>& rxParent
,
48 ::svt::table::IAccessibleTable
& rTable
,
49 ::svt::table::AccessibleTableControlObjType eObjType
):
50 AccessibleGridControlTableBase( rxParent
, rTable
, eObjType
)
52 OSL_ENSURE( isRowBar() || isColumnBar(),
53 "accessibility/extended/AccessibleGridControlHeaderBar - invalid object type" );
56 AccessibleGridControlHeader::~AccessibleGridControlHeader()
60 // XAccessibleContext ---------------------------------------------------------
62 Reference
< XAccessible
> SAL_CALL
63 AccessibleGridControlHeader::getAccessibleChild( sal_Int32 nChildIndex
)
64 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
66 SolarMutexGuard aSolarGuard
;
68 if (nChildIndex
<0 || nChildIndex
>=getAccessibleChildCount())
69 throw IndexOutOfBoundsException();
71 Reference
< XAccessible
> xChild
;
72 if(m_eObjType
== svt::table::TCTYPE_COLUMNHEADERBAR
)
74 AccessibleGridControlHeaderCell
* pColHeaderCell
= new AccessibleGridControlHeaderCell(nChildIndex
, this, m_aTable
, svt::table::TCTYPE_COLUMNHEADERCELL
);
75 xChild
= pColHeaderCell
;
77 else if(m_eObjType
== svt::table::TCTYPE_ROWHEADERBAR
)
79 AccessibleGridControlHeaderCell
* pRowHeaderCell
= new AccessibleGridControlHeaderCell(nChildIndex
, this, m_aTable
, svt::table::TCTYPE_ROWHEADERCELL
);
80 xChild
= pRowHeaderCell
;
85 sal_Int32 SAL_CALL
AccessibleGridControlHeader::getAccessibleIndexInParent()
86 throw ( uno::RuntimeException
, std::exception
)
89 if(m_eObjType
== svt::table::TCTYPE_ROWHEADERBAR
&& m_aTable
.HasColHeader())
95 // XAccessibleComponent -------------------------------------------------------
97 Reference
< XAccessible
> SAL_CALL
98 AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point
& rPoint
)
99 throw ( uno::RuntimeException
, std::exception
)
101 SolarMutexGuard aSolarGuard
;
106 sal_Int32 nColumnPos
= 0;
107 bool bConverted
= m_aTable
.ConvertPointToCellAddress(nRow
, nColumnPos
, VCLPoint(rPoint
));
108 return bConverted
? implGetChild( nRow
, nColumnPos
) : Reference
< XAccessible
>();
111 void SAL_CALL
AccessibleGridControlHeader::grabFocus()
112 throw ( uno::RuntimeException
, std::exception
)
115 // focus on header not supported
118 // XAccessibleTable -----------------------------------------------------------
120 OUString SAL_CALL
AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow
)
121 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
123 SolarMutexGuard aSolarGuard
;
126 ensureIsValidRow( nRow
);
127 return OUString(); // no headers in headers
130 OUString SAL_CALL
AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn
)
131 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
133 SolarMutexGuard aSolarGuard
;
136 ensureIsValidColumn( nColumn
);
137 return OUString(); // no headers in headers
140 Reference
< XAccessibleTable
> SAL_CALL
AccessibleGridControlHeader::getAccessibleRowHeaders()
141 throw ( uno::RuntimeException
, std::exception
)
146 return NULL
; // no headers in headers
149 Reference
< XAccessibleTable
> SAL_CALL
AccessibleGridControlHeader::getAccessibleColumnHeaders()
150 throw ( uno::RuntimeException
, std::exception
)
155 return NULL
; // no headers in headers
158 Sequence
< sal_Int32
> SAL_CALL
AccessibleGridControlHeader::getSelectedAccessibleRows()
159 throw ( uno::RuntimeException
, std::exception
)
161 Sequence
< sal_Int32
> aSelSeq(0);
164 //columns aren't selectable
165 Sequence
< sal_Int32
> SAL_CALL
AccessibleGridControlHeader::getSelectedAccessibleColumns()
166 throw ( uno::RuntimeException
, std::exception
)
168 Sequence
< sal_Int32
> aSelSeq(0);
171 //row headers not selectable
172 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32
/*nRow*/ )
173 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
177 //columns aren't selectable
178 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32 nColumn
)
179 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
185 Reference
< XAccessible
> SAL_CALL
AccessibleGridControlHeader::getAccessibleCellAt(
186 sal_Int32
/*nRow*/, sal_Int32
/*nColumn*/ )
187 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
192 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleSelected(
193 sal_Int32
/*nRow*/, sal_Int32
/*nColumn */)
194 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
199 // XServiceInfo ---------------------------------------------------------------
201 OUString SAL_CALL
AccessibleGridControlHeader::getImplementationName()
202 throw ( uno::RuntimeException
, std::exception
)
204 return OUString( "com.sun.star.accessibility.AccessibleGridControlHeader" );
207 Sequence
< sal_Int8
> SAL_CALL
AccessibleGridControlHeader::getImplementationId()
208 throw ( uno::RuntimeException
, std::exception
)
210 return css::uno::Sequence
<sal_Int8
>();
213 // internal virtual methods ---------------------------------------------------
215 Rectangle
AccessibleGridControlHeader::implGetBoundingBox()
217 vcl::Window
* pParent
= m_aTable
.GetAccessibleParentWindow();
218 Rectangle
aGridRect( m_aTable
.GetWindowExtentsRelative( pParent
) );
219 Rectangle
aHeaderRect (m_aTable
.calcHeaderRect(isColumnBar()));
221 return Rectangle(aGridRect
.TopLeft(), Size(aGridRect
.getWidth(),aHeaderRect
.getHeight()));
223 return Rectangle(aGridRect
.TopLeft(), Size(aHeaderRect
.getWidth(),aGridRect
.getHeight()));
227 Rectangle
AccessibleGridControlHeader::implGetBoundingBoxOnScreen()
229 Rectangle
aGridRect( m_aTable
.GetWindowExtentsRelative( NULL
) );
230 Rectangle
aHeaderRect (m_aTable
.calcHeaderRect(isColumnBar()));
232 return Rectangle(aGridRect
.TopLeft(), Size(aGridRect
.getWidth(),aHeaderRect
.getHeight()));
234 return Rectangle(aGridRect
.TopLeft(), Size(aHeaderRect
.getWidth(),aGridRect
.getHeight()));
237 // internal helper methods ----------------------------------------------------
238 Reference
< XAccessible
> AccessibleGridControlHeader::implGetChild(
239 sal_Int32 nRow
, sal_uInt32 nColumnPos
)
241 Reference
< XAccessible
> xChild
;
242 if(m_eObjType
== svt::table::TCTYPE_COLUMNHEADERBAR
)
244 AccessibleGridControlHeaderCell
* pColHeaderCell
= new AccessibleGridControlHeaderCell(nColumnPos
, this, m_aTable
, svt::table::TCTYPE_COLUMNHEADERCELL
);
245 xChild
= pColHeaderCell
;
247 else if(m_eObjType
== svt::table::TCTYPE_ROWHEADERBAR
)
249 AccessibleGridControlHeaderCell
* pRowHeaderCell
= new AccessibleGridControlHeaderCell(nRow
, this, m_aTable
, svt::table::TCTYPE_ROWHEADERCELL
);
250 xChild
= pRowHeaderCell
;
255 } // namespace accessibility
257 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */