Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / accessibility / source / extended / AccessibleGridControlHeader.cxx
blob3f431f9c49d5ba3f243c6cd034894fa557f01a78
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
27 // ============================================================================
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;
40 // ============================================================================
42 namespace accessibility {
44 // ============================================================================
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 )
66 SolarMutexGuard aSolarGuard;
67 ::osl::MutexGuard aGuard( getOslMutex() );
69 if (nChildIndex<0 || nChildIndex>=getAccessibleChildCount())
70 throw IndexOutOfBoundsException();
71 ensureIsAlive();
72 Reference< XAccessible > xChild;
73 if(m_eObjType == svt::table::TCTYPE_COLUMNHEADERBAR)
75 AccessibleGridControlHeaderCell* pColHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, svt::table::TCTYPE_COLUMNHEADERCELL);
76 xChild = pColHeaderCell;
78 else if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR)
80 AccessibleGridControlHeaderCell* pRowHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, svt::table::TCTYPE_ROWHEADERCELL);
81 xChild = pRowHeaderCell;
83 return xChild;
86 sal_Int32 SAL_CALL AccessibleGridControlHeader::getAccessibleIndexInParent()
87 throw ( uno::RuntimeException )
89 ensureIsAlive();
90 if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR && m_aTable.HasColHeader())
91 return 1;
92 else
93 return 0;
96 // XAccessibleComponent -------------------------------------------------------
98 Reference< XAccessible > SAL_CALL
99 AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point& rPoint )
100 throw ( uno::RuntimeException )
102 SolarMutexGuard aSolarGuard;
103 ::osl::MutexGuard aGuard( getOslMutex() );
104 ensureIsAlive();
106 sal_Int32 nRow = 0;
107 sal_Int32 nColumnPos = 0;
108 sal_Bool bConverted = isRowBar() ?
109 m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) :
110 m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) );
112 return bConverted ? implGetChild( nRow, nColumnPos ) : Reference< XAccessible >();
115 void SAL_CALL AccessibleGridControlHeader::grabFocus()
116 throw ( uno::RuntimeException )
118 ensureIsAlive();
119 // focus on header not supported
122 Any SAL_CALL AccessibleGridControlHeader::getAccessibleKeyBinding()
123 throw ( uno::RuntimeException )
125 ensureIsAlive();
126 return Any(); // no special key bindings for header
129 // XAccessibleTable -----------------------------------------------------------
131 OUString SAL_CALL AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow )
132 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
134 SolarMutexGuard aSolarGuard;
135 ::osl::MutexGuard aGuard( getOslMutex() );
136 ensureIsAlive();
137 ensureIsValidRow( nRow );
138 return OUString(); // no headers in headers
141 OUString SAL_CALL AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn )
142 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
144 SolarMutexGuard aSolarGuard;
145 ::osl::MutexGuard aGuard( getOslMutex() );
146 ensureIsAlive();
147 ensureIsValidColumn( nColumn );
148 return OUString(); // no headers in headers
151 Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleRowHeaders()
152 throw ( uno::RuntimeException )
154 ensureIsAlive();
155 return NULL; // no headers in headers
158 Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleColumnHeaders()
159 throw ( uno::RuntimeException )
161 ensureIsAlive();
162 return NULL; // no headers in headers
164 //not selectable
165 Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleRows()
166 throw ( uno::RuntimeException )
168 Sequence< sal_Int32 > aSelSeq(0);
169 return aSelSeq;
171 //columns aren't selectable
172 Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleColumns()
173 throw ( uno::RuntimeException )
175 Sequence< sal_Int32 > aSelSeq(0);
176 return aSelSeq;
178 //row headers not selectable
179 sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32 /*nRow*/ )
180 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
182 return sal_False;
184 //columns aren't selectable
185 sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32 nColumn )
186 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
188 (void)nColumn;
189 return sal_False;
191 //not implemented
192 Reference< XAccessible > SAL_CALL AccessibleGridControlHeader::getAccessibleCellAt(
193 sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ )
194 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
196 return NULL;
198 // not selectable
199 sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleSelected(
200 sal_Int32 /*nRow*/, sal_Int32 /*nColumn */)
201 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
203 return sal_False;
206 // XServiceInfo ---------------------------------------------------------------
208 OUString SAL_CALL AccessibleGridControlHeader::getImplementationName()
209 throw ( uno::RuntimeException )
211 return OUString( "com.sun.star.accessibility.AccessibleGridControlHeader" );
214 namespace
216 class theAccessibleGridControlHeaderImplementationId : public rtl::Static< UnoTunnelIdInit, theAccessibleGridControlHeaderImplementationId > {};
219 Sequence< sal_Int8 > SAL_CALL AccessibleGridControlHeader::getImplementationId()
220 throw ( uno::RuntimeException )
222 return theAccessibleGridControlHeaderImplementationId::get().getSeq();
225 // internal virtual methods ---------------------------------------------------
227 Rectangle AccessibleGridControlHeader::implGetBoundingBox()
229 Window* pParent = m_aTable.GetAccessibleParentWindow();
230 Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) );
231 Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar()));
232 if(isColumnBar())
233 return Rectangle(aGridRect.TopLeft(), Size(aGridRect.getWidth(),aHeaderRect.getHeight()));
234 else
235 return Rectangle(aGridRect.TopLeft(), Size(aHeaderRect.getWidth(),aGridRect.getHeight()));
239 Rectangle AccessibleGridControlHeader::implGetBoundingBoxOnScreen()
241 Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( NULL ) );
242 Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar()));
243 if(isColumnBar())
244 return Rectangle(aGridRect.TopLeft(), Size(aGridRect.getWidth(),aHeaderRect.getHeight()));
245 else
246 return Rectangle(aGridRect.TopLeft(), Size(aHeaderRect.getWidth(),aGridRect.getHeight()));
249 sal_Int32 AccessibleGridControlHeader::implGetRowCount() const
251 return 1;
254 sal_Int32 AccessibleGridControlHeader::implGetColumnCount() const
256 return 1;
259 // internal helper methods ----------------------------------------------------
261 Reference< XAccessible > AccessibleGridControlHeader::implGetChild(
262 sal_Int32 nRow, sal_uInt32 nColumnPos )
264 Reference< XAccessible > xChild;
265 if(m_eObjType == svt::table::TCTYPE_COLUMNHEADERBAR)
267 AccessibleGridControlHeaderCell* pColHeaderCell = new AccessibleGridControlHeaderCell(nColumnPos, this, m_aTable, svt::table::TCTYPE_COLUMNHEADERCELL);
268 xChild = pColHeaderCell;
270 else if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR)
272 AccessibleGridControlHeaderCell* pRowHeaderCell = new AccessibleGridControlHeaderCell(nRow, this, m_aTable, svt::table::TCTYPE_ROWHEADERCELL);
273 xChild = pRowHeaderCell;
275 return xChild;
278 // ============================================================================
280 } // namespace accessibility
282 // ============================================================================
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */