1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_accessibility.hxx"
32 #include "accessibility/extended/AccessibleGridControlHeader.hxx"
33 #include "accessibility/extended/AccessibleGridControlHeaderCell.hxx"
34 #include "accessibility/extended/AccessibleGridControlTableCell.hxx"
35 #include <svtools/accessibletable.hxx>
38 // ============================================================================
40 using ::rtl::OUString
;
42 using ::com::sun::star::uno::Reference
;
43 using ::com::sun::star::uno::Sequence
;
44 using ::com::sun::star::uno::Any
;
46 using namespace ::com::sun::star::uno
;
47 using namespace ::com::sun::star
;
48 using namespace ::com::sun::star::lang
;
49 using namespace ::com::sun::star::accessibility
;
50 using namespace ::svt
;
51 using namespace ::svt::table
;
53 // ============================================================================
55 namespace accessibility
{
57 // ============================================================================
59 DBG_NAME( AccessibleGridControlHeader
)
61 AccessibleGridControlHeader::AccessibleGridControlHeader(
62 const Reference
< XAccessible
>& rxParent
,
63 ::svt::table::IAccessibleTable
& rTable
,
64 ::svt::table::AccessibleTableControlObjType eObjType
):
65 AccessibleGridControlTableBase( rxParent
, rTable
, eObjType
)
67 DBG_ASSERT( isRowBar() || isColumnBar(),
68 "accessibility/extended/AccessibleGridControlHeaderBar - invalid object type" );
71 AccessibleGridControlHeader::~AccessibleGridControlHeader()
75 // XAccessibleContext ---------------------------------------------------------
77 Reference
< XAccessible
> SAL_CALL
78 AccessibleGridControlHeader::getAccessibleChild( sal_Int32 nChildIndex
)
79 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
81 TCSolarGuard aSolarGuard
;
82 ::osl::MutexGuard
aGuard( getOslMutex() );
84 if (nChildIndex
<0 || nChildIndex
>=getAccessibleChildCount())
85 throw IndexOutOfBoundsException();
87 Reference
< XAccessible
> xChild
;
88 if(m_eObjType
== svt::table::TCTYPE_COLUMNHEADERBAR
)
90 AccessibleGridControlHeaderCell
* pColHeaderCell
= new AccessibleGridControlHeaderCell(nChildIndex
, this, m_aTable
, svt::table::TCTYPE_COLUMNHEADERCELL
);
91 xChild
= pColHeaderCell
;
93 else if(m_eObjType
== svt::table::TCTYPE_ROWHEADERBAR
)
95 AccessibleGridControlHeaderCell
* pRowHeaderCell
= new AccessibleGridControlHeaderCell(nChildIndex
, this, m_aTable
, svt::table::TCTYPE_ROWHEADERCELL
);
96 xChild
= pRowHeaderCell
;
101 sal_Int32 SAL_CALL
AccessibleGridControlHeader::getAccessibleIndexInParent()
102 throw ( uno::RuntimeException
)
105 if(m_eObjType
== svt::table::TCTYPE_ROWHEADERBAR
&& m_aTable
.HasColHeader())
111 // XAccessibleComponent -------------------------------------------------------
113 Reference
< XAccessible
> SAL_CALL
114 AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point
& rPoint
)
115 throw ( uno::RuntimeException
)
117 TCSolarGuard aSolarGuard
;
118 ::osl::MutexGuard
aGuard( getOslMutex() );
122 sal_Int32 nColumnPos
= 0;
123 sal_Bool bConverted
= isRowBar() ?
124 m_aTable
.ConvertPointToCellAddress( nRow
, nColumnPos
, VCLPoint( rPoint
) ) :
125 m_aTable
.ConvertPointToCellAddress( nRow
, nColumnPos
, VCLPoint( rPoint
) );
127 return bConverted
? implGetChild( nRow
, nColumnPos
) : Reference
< XAccessible
>();
130 void SAL_CALL
AccessibleGridControlHeader::grabFocus()
131 throw ( uno::RuntimeException
)
134 // focus on header not supported
137 Any SAL_CALL
AccessibleGridControlHeader::getAccessibleKeyBinding()
138 throw ( uno::RuntimeException
)
141 return Any(); // no special key bindings for header
144 // XAccessibleTable -----------------------------------------------------------
146 OUString SAL_CALL
AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow
)
147 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
149 TCSolarGuard aSolarGuard
;
150 ::osl::MutexGuard
aGuard( getOslMutex() );
152 ensureIsValidRow( nRow
);
153 return OUString(); // no headers in headers
156 OUString SAL_CALL
AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn
)
157 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
159 TCSolarGuard aSolarGuard
;
160 ::osl::MutexGuard
aGuard( getOslMutex() );
162 ensureIsValidColumn( nColumn
);
163 return OUString(); // no headers in headers
166 Reference
< XAccessibleTable
> SAL_CALL
AccessibleGridControlHeader::getAccessibleRowHeaders()
167 throw ( uno::RuntimeException
)
170 return NULL
; // no headers in headers
173 Reference
< XAccessibleTable
> SAL_CALL
AccessibleGridControlHeader::getAccessibleColumnHeaders()
174 throw ( uno::RuntimeException
)
177 return NULL
; // no headers in headers
180 Sequence
< sal_Int32
> SAL_CALL
AccessibleGridControlHeader::getSelectedAccessibleRows()
181 throw ( uno::RuntimeException
)
183 Sequence
< sal_Int32
> aSelSeq(0);
186 //columns aren't selectable
187 Sequence
< sal_Int32
> SAL_CALL
AccessibleGridControlHeader::getSelectedAccessibleColumns()
188 throw ( uno::RuntimeException
)
190 Sequence
< sal_Int32
> aSelSeq(0);
193 //row headers not selectable
194 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32
/*nRow*/ )
195 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
199 //columns aren't selectable
200 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32 nColumn
)
201 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
207 Reference
< XAccessible
> SAL_CALL
AccessibleGridControlHeader::getAccessibleCellAt(
208 sal_Int32
/*nRow*/, sal_Int32
/*nColumn*/ )
209 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
214 sal_Bool SAL_CALL
AccessibleGridControlHeader::isAccessibleSelected(
215 sal_Int32
/*nRow*/, sal_Int32
/*nColumn */)
216 throw ( lang::IndexOutOfBoundsException
, uno::RuntimeException
)
221 // XServiceInfo ---------------------------------------------------------------
223 OUString SAL_CALL
AccessibleGridControlHeader::getImplementationName()
224 throw ( uno::RuntimeException
)
226 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlHeader" ) );
229 Sequence
< sal_Int8
> SAL_CALL
AccessibleGridControlHeader::getImplementationId()
230 throw ( uno::RuntimeException
)
232 ::osl::MutexGuard
aGuard( getOslGlobalMutex() );
233 static Sequence
< sal_Int8
> aId
;
234 implCreateUuid( aId
);
238 // internal virtual methods ---------------------------------------------------
240 Rectangle
AccessibleGridControlHeader::implGetBoundingBox()
242 return m_aTable
.calcHeaderRect(isColumnBar());
245 Rectangle
AccessibleGridControlHeader::implGetBoundingBoxOnScreen()
247 return m_aTable
.calcHeaderRect(isColumnBar());
250 sal_Int32
AccessibleGridControlHeader::implGetRowCount() const
255 sal_Int32
AccessibleGridControlHeader::implGetColumnCount() const
260 // internal helper methods ----------------------------------------------------
262 Reference
< XAccessible
> AccessibleGridControlHeader::implGetChild(
263 sal_Int32 nRow
, sal_uInt32 nColumnPos
)
265 Reference
< XAccessible
> xChild
;
266 if(m_eObjType
== svt::table::TCTYPE_COLUMNHEADERBAR
)
268 AccessibleGridControlHeaderCell
* pColHeaderCell
= new AccessibleGridControlHeaderCell(nColumnPos
, this, m_aTable
, svt::table::TCTYPE_COLUMNHEADERCELL
);
269 xChild
= pColHeaderCell
;
271 else if(m_eObjType
== svt::table::TCTYPE_ROWHEADERBAR
)
273 AccessibleGridControlHeaderCell
* pRowHeaderCell
= new AccessibleGridControlHeaderCell(nRow
, this, m_aTable
, svt::table::TCTYPE_ROWHEADERCELL
);
274 xChild
= pRowHeaderCell
;
279 // ============================================================================
281 } // namespace accessibility
283 // ============================================================================