LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / accessibility / source / extended / AccessibleBrowseBoxTable.cxx
blobd245c5155ba8a83d6782ca866c174c5c0b037df8
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 <toolkit/helper/convert.hxx>
22 #include <vcl/accessibletableprovider.hxx>
23 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26 using ::com::sun::star::uno::Reference;
27 using ::com::sun::star::uno::Sequence;
29 using namespace ::com::sun::star;
30 using namespace ::com::sun::star::accessibility;
33 namespace accessibility {
36 // Ctor/Dtor/disposing --------------------------------------------------------
38 AccessibleBrowseBoxTable::AccessibleBrowseBoxTable(
39 const Reference< XAccessible >& rxParent,
40 vcl::IAccessibleTableProvider& rBrowseBox ) :
41 AccessibleBrowseBoxTableBase( rxParent, rBrowseBox, AccessibleBrowseBoxObjType::Table )
45 AccessibleBrowseBoxTable::~AccessibleBrowseBoxTable()
49 // XAccessibleContext ---------------------------------------------------------
51 Reference< XAccessible > SAL_CALL
52 AccessibleBrowseBoxTable::getAccessibleChild( sal_Int32 nChildIndex )
54 SolarMethodGuard aGuard(getMutex());
55 ensureIsAlive();
57 ensureIsValidIndex( nChildIndex );
58 return mpBrowseBox->CreateAccessibleCell(
59 implGetRow( nChildIndex ), static_cast<sal_Int16>(implGetColumn( nChildIndex )) );
62 sal_Int32 SAL_CALL AccessibleBrowseBoxTable::getAccessibleIndexInParent()
64 osl::MutexGuard aGuard( getMutex() );
65 ensureIsAlive();
66 return vcl::BBINDEX_TABLE;
69 // XAccessibleComponent -------------------------------------------------------
71 Reference< XAccessible > SAL_CALL
72 AccessibleBrowseBoxTable::getAccessibleAtPoint( const awt::Point& rPoint )
74 SolarMethodGuard aGuard(getMutex());
75 ensureIsAlive();
77 Reference< XAccessible > xChild;
78 sal_Int32 nRow = 0;
79 sal_uInt16 nColumnPos = 0;
80 if( mpBrowseBox->ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) )
81 xChild = mpBrowseBox->CreateAccessibleCell( nRow, nColumnPos );
83 return xChild;
86 void SAL_CALL AccessibleBrowseBoxTable::grabFocus()
88 SolarMethodGuard aGuard(getMutex());
89 ensureIsAlive();
90 mpBrowseBox->GrabTableFocus();
93 // XAccessibleTable -----------------------------------------------------------
95 OUString SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowDescription( sal_Int32 nRow )
97 SolarMethodGuard aGuard(getMutex());
98 ensureIsAlive();
99 ensureIsValidRow( nRow );
100 return mpBrowseBox->GetRowDescription( nRow );
103 OUString SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnDescription( sal_Int32 nColumn )
105 SolarMethodGuard aGuard(getMutex());
106 ensureIsAlive();
108 ensureIsValidColumn( nColumn );
109 return mpBrowseBox->GetColumnDescription( static_cast<sal_uInt16>(nColumn) );
112 Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowHeaders()
114 ::osl::MutexGuard aGuard( getMutex() );
115 ensureIsAlive();
116 return implGetHeaderBar( vcl::BBINDEX_ROWHEADERBAR );
119 Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnHeaders()
121 ::osl::MutexGuard aGuard( getMutex() );
122 ensureIsAlive();
123 return implGetHeaderBar( vcl::BBINDEX_COLUMNHEADERBAR );
126 Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleRows()
128 SolarMethodGuard aGuard(getMutex());
129 ensureIsAlive();
131 Sequence< sal_Int32 > aSelSeq;
132 implGetSelectedRows( aSelSeq );
133 return aSelSeq;
136 Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleColumns()
138 SolarMethodGuard aGuard(getMutex());
139 ensureIsAlive();
141 Sequence< sal_Int32 > aSelSeq;
142 implGetSelectedColumns( aSelSeq );
143 return aSelSeq;
146 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleRowSelected( sal_Int32 nRow )
148 SolarMethodGuard aGuard(getMutex());
149 ensureIsAlive();
151 ensureIsValidRow( nRow );
152 return implIsRowSelected( nRow );
155 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleColumnSelected( sal_Int32 nColumn )
157 SolarMethodGuard aGuard(getMutex());
158 ensureIsAlive();
160 ensureIsValidColumn( nColumn );
161 return implIsColumnSelected( nColumn );
164 Reference< XAccessible > SAL_CALL AccessibleBrowseBoxTable::getAccessibleCellAt(
165 sal_Int32 nRow, sal_Int32 nColumn )
167 SolarMethodGuard aGuard(getMutex());
168 ensureIsAlive();
170 ensureIsValidAddress( nRow, nColumn );
171 return mpBrowseBox->CreateAccessibleCell( nRow, static_cast<sal_Int16>(nColumn) );
174 sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleSelected(
175 sal_Int32 nRow, sal_Int32 nColumn )
177 SolarMethodGuard aGuard(getMutex());
178 ensureIsAlive();
180 ensureIsValidAddress( nRow, nColumn );
181 return implIsRowSelected( nRow ) || implIsColumnSelected( nColumn );
184 // XServiceInfo ---------------------------------------------------------------
186 OUString SAL_CALL AccessibleBrowseBoxTable::getImplementationName()
188 return "com.sun.star.comp.svtools.AccessibleBrowseBoxTable";
191 // internal virtual methods ---------------------------------------------------
193 tools::Rectangle AccessibleBrowseBoxTable::implGetBoundingBox()
195 return mpBrowseBox->calcTableRect(false);
198 tools::Rectangle AccessibleBrowseBoxTable::implGetBoundingBoxOnScreen()
200 return mpBrowseBox->calcTableRect();
203 // internal helper methods ----------------------------------------------------
205 Reference< XAccessibleTable > AccessibleBrowseBoxTable::implGetHeaderBar(
206 sal_Int32 nChildIndex )
208 Reference< XAccessible > xRet;
209 Reference< XAccessibleContext > xContext( mxParent, uno::UNO_QUERY );
210 if( xContext.is() )
214 xRet = xContext->getAccessibleChild( nChildIndex );
216 catch (const lang::IndexOutOfBoundsException&)
218 OSL_FAIL( "implGetHeaderBar - wrong child index" );
220 // RuntimeException goes to caller
222 return Reference< XAccessibleTable >( xRet, uno::UNO_QUERY );
226 } // namespace accessibility
229 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */