lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxTable.cxx
blobc9d296bc1b4944993178c075094aa3b87398a04d
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 <extended/AccessibleBrowseBoxTable.hxx>
21 #include <vcl/accessibletableprovider.hxx>
24 using ::com::sun::star::uno::Reference;
25 using ::com::sun::star::uno::Sequence;
27 using namespace ::com::sun::star;
28 using namespace ::com::sun::star::accessibility;
29 using namespace ::svt;
32 namespace accessibility {
35 // Ctor/Dtor/disposing --------------------------------------------------------
37 AccessibleBrowseBoxTable::AccessibleBrowseBoxTable(
38 const Reference< XAccessible >& rxParent,
39 vcl::IAccessibleTableProvider& rBrowseBox ) :
40 AccessibleBrowseBoxTableBase( rxParent, rBrowseBox, vcl::BBTYPE_TABLE )
44 AccessibleBrowseBoxTable::~AccessibleBrowseBoxTable()
48 // XAccessibleContext ---------------------------------------------------------
50 Reference< XAccessible > SAL_CALL
51 AccessibleBrowseBoxTable::getAccessibleChild( sal_Int32 nChildIndex )
53 SolarMethodGuard aGuard(getMutex());
54 ensureIsAlive();
56 ensureIsValidIndex( nChildIndex );
57 return mpBrowseBox->CreateAccessibleCell(
58 implGetRow( nChildIndex ), static_cast<sal_Int16>(implGetColumn( nChildIndex )) );
61 sal_Int32 SAL_CALL AccessibleBrowseBoxTable::getAccessibleIndexInParent()
63 osl::MutexGuard aGuard( getMutex() );
64 ensureIsAlive();
65 return vcl::BBINDEX_TABLE;
68 // XAccessibleComponent -------------------------------------------------------
70 Reference< XAccessible > SAL_CALL
71 AccessibleBrowseBoxTable::getAccessibleAtPoint( const awt::Point& rPoint )
73 SolarMethodGuard aGuard(getMutex());
74 ensureIsAlive();
76 Reference< XAccessible > xChild;
77 sal_Int32 nRow = 0;
78 sal_uInt16 nColumnPos = 0;
79 if( mpBrowseBox->ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) )
80 xChild = mpBrowseBox->CreateAccessibleCell( nRow, nColumnPos );
82 return xChild;
85 void SAL_CALL AccessibleBrowseBoxTable::grabFocus()
87 SolarMethodGuard aGuard(getMutex());
88 ensureIsAlive();
89 mpBrowseBox->GrabTableFocus();
92 // XAccessibleTable -----------------------------------------------------------
94 OUString SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowDescription( sal_Int32 nRow )
96 SolarMethodGuard aGuard(getMutex());
97 ensureIsAlive();
98 ensureIsValidRow( nRow );
99 return mpBrowseBox->GetRowDescription( nRow );
102 OUString SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnDescription( sal_Int32 nColumn )
104 SolarMethodGuard aGuard(getMutex());
105 ensureIsAlive();
107 ensureIsValidColumn( nColumn );
108 return mpBrowseBox->GetColumnDescription( static_cast<sal_uInt16>(nColumn) );
111 Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowHeaders()
113 ::osl::MutexGuard aGuard( getMutex() );
114 ensureIsAlive();
115 return implGetHeaderBar( vcl::BBINDEX_ROWHEADERBAR );
118 Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnHeaders()
120 ::osl::MutexGuard aGuard( getMutex() );
121 ensureIsAlive();
122 return implGetHeaderBar( vcl::BBINDEX_COLUMNHEADERBAR );
125 Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleRows()
127 SolarMethodGuard aGuard(getMutex());
128 ensureIsAlive();
130 Sequence< sal_Int32 > aSelSeq;
131 implGetSelectedRows( aSelSeq );
132 return aSelSeq;
135 Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleColumns()
137 SolarMethodGuard aGuard(getMutex());
138 ensureIsAlive();
140 Sequence< sal_Int32 > aSelSeq;
141 implGetSelectedColumns( aSelSeq );
142 return aSelSeq;
145 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleRowSelected( sal_Int32 nRow )
147 SolarMethodGuard aGuard(getMutex());
148 ensureIsAlive();
150 ensureIsValidRow( nRow );
151 return implIsRowSelected( nRow );
154 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleColumnSelected( sal_Int32 nColumn )
156 SolarMethodGuard aGuard(getMutex());
157 ensureIsAlive();
159 ensureIsValidColumn( nColumn );
160 return implIsColumnSelected( nColumn );
163 Reference< XAccessible > SAL_CALL AccessibleBrowseBoxTable::getAccessibleCellAt(
164 sal_Int32 nRow, sal_Int32 nColumn )
166 SolarMethodGuard aGuard(getMutex());
167 ensureIsAlive();
169 ensureIsValidAddress( nRow, nColumn );
170 return mpBrowseBox->CreateAccessibleCell( nRow, static_cast<sal_Int16>(nColumn) );
173 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleSelected(
174 sal_Int32 nRow, sal_Int32 nColumn )
176 SolarMethodGuard aGuard(getMutex());
177 ensureIsAlive();
179 ensureIsValidAddress( nRow, nColumn );
180 return implIsRowSelected( nRow ) || implIsColumnSelected( nColumn );
183 // XServiceInfo ---------------------------------------------------------------
185 OUString SAL_CALL AccessibleBrowseBoxTable::getImplementationName()
187 return OUString( "com.sun.star.comp.svtools.AccessibleBrowseBoxTable" );
190 // internal virtual methods ---------------------------------------------------
192 tools::Rectangle AccessibleBrowseBoxTable::implGetBoundingBox()
194 return mpBrowseBox->calcTableRect(false);
197 tools::Rectangle AccessibleBrowseBoxTable::implGetBoundingBoxOnScreen()
199 return mpBrowseBox->calcTableRect();
202 // internal helper methods ----------------------------------------------------
204 Reference< XAccessibleTable > AccessibleBrowseBoxTable::implGetHeaderBar(
205 sal_Int32 nChildIndex )
207 Reference< XAccessible > xRet;
208 Reference< XAccessibleContext > xContext( mxParent, uno::UNO_QUERY );
209 if( xContext.is() )
213 xRet = xContext->getAccessibleChild( nChildIndex );
215 catch (const lang::IndexOutOfBoundsException&)
217 OSL_FAIL( "implGetHeaderBar - wrong child index" );
219 // RuntimeException goes to caller
221 return Reference< XAccessibleTable >( xRet, uno::UNO_QUERY );
225 } // namespace accessibility
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */