Branch libreoffice-5-0-4
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxTable.cxx
blob4bf01ef380f7ae9bb3b89f346e62828423bfb83a
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/AccessibleBrowseBoxTable.hxx"
21 #include <svtools/accessibletableprovider.hxx>
25 using ::com::sun::star::uno::Reference;
26 using ::com::sun::star::uno::Sequence;
27 using ::com::sun::star::uno::Any;
29 using namespace ::com::sun::star;
30 using namespace ::com::sun::star::accessibility;
31 using namespace ::svt;
35 namespace accessibility {
39 // Ctor/Dtor/disposing --------------------------------------------------------
41 AccessibleBrowseBoxTable::AccessibleBrowseBoxTable(
42 const Reference< XAccessible >& rxParent,
43 IAccessibleTableProvider& rBrowseBox ) :
44 AccessibleBrowseBoxTableBase( rxParent, rBrowseBox, BBTYPE_TABLE )
48 AccessibleBrowseBoxTable::~AccessibleBrowseBoxTable()
52 // XAccessibleContext ---------------------------------------------------------
54 Reference< XAccessible > SAL_CALL
55 AccessibleBrowseBoxTable::getAccessibleChild( sal_Int32 nChildIndex )
56 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
58 SolarMutexGuard aSolarGuard;
59 ::osl::MutexGuard aGuard( getOslMutex() );
60 ensureIsAlive();
61 ensureIsValidIndex( nChildIndex );
62 return mpBrowseBox->CreateAccessibleCell(
63 implGetRow( nChildIndex ), (sal_Int16)implGetColumn( nChildIndex ) );
66 sal_Int32 SAL_CALL AccessibleBrowseBoxTable::getAccessibleIndexInParent()
67 throw ( uno::RuntimeException, std::exception )
69 ensureIsAlive();
70 return BBINDEX_TABLE;
73 // XAccessibleComponent -------------------------------------------------------
75 Reference< XAccessible > SAL_CALL
76 AccessibleBrowseBoxTable::getAccessibleAtPoint( const awt::Point& rPoint )
77 throw ( uno::RuntimeException, std::exception )
79 SolarMutexGuard aSolarGuard;
80 ::osl::MutexGuard aGuard( getOslMutex() );
81 ensureIsAlive();
83 Reference< XAccessible > xChild;
84 sal_Int32 nRow = 0;
85 sal_uInt16 nColumnPos = 0;
86 if( mpBrowseBox->ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) )
87 xChild = mpBrowseBox->CreateAccessibleCell( nRow, nColumnPos );
89 return xChild;
92 void SAL_CALL AccessibleBrowseBoxTable::grabFocus()
93 throw ( uno::RuntimeException, std::exception )
95 SolarMutexGuard aSolarGuard;
96 ::osl::MutexGuard aGuard( getOslMutex() );
97 ensureIsAlive();
98 mpBrowseBox->GrabTableFocus();
101 // XAccessibleTable -----------------------------------------------------------
103 OUString SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowDescription( sal_Int32 nRow )
104 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
106 SolarMutexGuard aSolarGuard;
107 ::osl::MutexGuard aGuard( getOslMutex() );
108 ensureIsAlive();
109 ensureIsValidRow( nRow );
110 return mpBrowseBox->GetRowDescription( nRow );
113 OUString SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnDescription( sal_Int32 nColumn )
114 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
116 SolarMutexGuard aSolarGuard;
117 ::osl::MutexGuard aGuard( getOslMutex() );
118 ensureIsAlive();
119 ensureIsValidColumn( nColumn );
120 return mpBrowseBox->GetColumnDescription( (sal_uInt16)nColumn );
123 Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowHeaders()
124 throw ( uno::RuntimeException, std::exception )
126 ::osl::MutexGuard aGuard( getOslMutex() );
127 ensureIsAlive();
128 return implGetHeaderBar( BBINDEX_ROWHEADERBAR );
131 Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnHeaders()
132 throw ( uno::RuntimeException, std::exception )
134 ::osl::MutexGuard aGuard( getOslMutex() );
135 ensureIsAlive();
136 return implGetHeaderBar( BBINDEX_COLUMNHEADERBAR );
139 Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleRows()
140 throw ( uno::RuntimeException, std::exception )
142 SolarMutexGuard aSolarGuard;
143 ::osl::MutexGuard aGuard( getOslMutex() );
144 ensureIsAlive();
146 Sequence< sal_Int32 > aSelSeq;
147 implGetSelectedRows( aSelSeq );
148 return aSelSeq;
151 Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleColumns()
152 throw ( uno::RuntimeException, std::exception )
154 SolarMutexGuard aSolarGuard;
155 ::osl::MutexGuard aGuard( getOslMutex() );
156 ensureIsAlive();
158 Sequence< sal_Int32 > aSelSeq;
159 implGetSelectedColumns( aSelSeq );
160 return aSelSeq;
163 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleRowSelected( sal_Int32 nRow )
164 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
166 SolarMutexGuard aSolarGuard;
167 ::osl::MutexGuard aGuard( getOslMutex() );
168 ensureIsAlive();
169 ensureIsValidRow( nRow );
170 return implIsRowSelected( nRow );
173 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleColumnSelected( sal_Int32 nColumn )
174 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
176 SolarMutexGuard aSolarGuard;
177 ::osl::MutexGuard aGuard( getOslMutex() );
178 ensureIsAlive();
179 ensureIsValidColumn( nColumn );
180 return implIsColumnSelected( nColumn );
183 Reference< XAccessible > SAL_CALL AccessibleBrowseBoxTable::getAccessibleCellAt(
184 sal_Int32 nRow, sal_Int32 nColumn )
185 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
187 SolarMutexGuard aSolarGuard;
188 ::osl::MutexGuard aGuard( getOslMutex() );
189 ensureIsAlive();
190 ensureIsValidAddress( nRow, nColumn );
191 return mpBrowseBox->CreateAccessibleCell( nRow, (sal_Int16)nColumn );
194 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleSelected(
195 sal_Int32 nRow, sal_Int32 nColumn )
196 throw ( lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception )
198 SolarMutexGuard aSolarGuard;
199 ::osl::MutexGuard aGuard( getOslMutex() );
200 ensureIsAlive();
201 ensureIsValidAddress( nRow, nColumn );
202 return implIsRowSelected( nRow ) || implIsColumnSelected( nColumn );
205 // XServiceInfo ---------------------------------------------------------------
207 OUString SAL_CALL AccessibleBrowseBoxTable::getImplementationName()
208 throw ( uno::RuntimeException, std::exception )
210 return OUString( "com.sun.star.comp.svtools.AccessibleBrowseBoxTable" );
213 // internal virtual methods ---------------------------------------------------
215 Rectangle AccessibleBrowseBoxTable::implGetBoundingBox()
217 return mpBrowseBox->calcTableRect(false);
220 Rectangle AccessibleBrowseBoxTable::implGetBoundingBoxOnScreen()
222 return mpBrowseBox->calcTableRect();
225 // internal helper methods ----------------------------------------------------
227 Reference< XAccessibleTable > AccessibleBrowseBoxTable::implGetHeaderBar(
228 sal_Int32 nChildIndex )
229 throw ( uno::RuntimeException )
231 Reference< XAccessible > xRet;
232 Reference< XAccessibleContext > xContext( mxParent, uno::UNO_QUERY );
233 if( xContext.is() )
237 xRet = xContext->getAccessibleChild( nChildIndex );
239 catch (const lang::IndexOutOfBoundsException&)
241 OSL_FAIL( "implGetHeaderBar - wrong child index" );
243 // RuntimeException goes to caller
245 return Reference< XAccessibleTable >( xRet, uno::UNO_QUERY );
250 } // namespace accessibility
254 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */