| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 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/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 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 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <controls/table/AccessibleGridControlHeader.hxx> |
| 21 |
#include <controls/table/AccessibleGridControlHeaderCell.hxx> |
| 22 |
|
| 23 |
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> |
| 24 |
#include <vcl/svapp.hxx> |
| 25 |
#include <vcl/unohelp.hxx> |
| 26 |
|
| 27 |
using ::com::sun::star::uno::Reference; |
| 28 |
using ::com::sun::star::uno::Sequence; |
| 29 |
|
| 30 |
using namespace ::com::sun::star::uno; |
| 31 |
using namespace ::com::sun::star; |
| 32 |
using namespace ::com::sun::star::lang; |
| 33 |
using namespace ::com::sun::star::accessibility; |
| 34 |
using namespace ::vcl; |
| 35 |
|
| 36 |
|
| 37 |
namespace accessibility { |
| 38 |
|
| 39 |
|
| 40 |
AccessibleGridControlHeader::AccessibleGridControlHeader( |
| 41 |
const Reference< XAccessible >& rxParent, |
| 42 |
svt::table::TableControl& rTable, |
| 43 |
AccessibleTableControlObjType eObjType): |
| 44 |
AccessibleGridControlTableBase( rxParent, rTable, eObjType ) |
| 45 |
{ |
| 46 |
OSL_ENSURE( isRowBar() || isColumnBar(), |
| 47 |
"AccessibleGridControlHeaderBar - invalid object type" ); |
| 48 |
} |
| 49 |
|
| 50 |
// XAccessibleContext --------------------------------------------------------- |
| 51 |
|
| 52 |
Reference< XAccessible > SAL_CALL |
| 53 |
AccessibleGridControlHeader::getAccessibleChild( sal_Int64 nChildIndex ) |
| 54 |
{ |
| 55 |
SolarMutexGuard aSolarGuard; |
| 56 |
|
| 57 |
ensureIsValidIndex(nChildIndex); |
| 58 |
ensureAlive(); |
| 59 |
|
| 60 |
return implGetChild(implGetRow(nChildIndex), implGetColumn(nChildIndex)); |
| 61 |
} |
| 62 |
|
| 63 |
sal_Int64 SAL_CALL AccessibleGridControlHeader::getAccessibleIndexInParent() |
| 64 |
{ |
| 65 |
SolarMutexGuard aSolarGuard; |
| 66 |
|
| 67 |
ensureAlive(); |
| 68 |
if (m_eObjType == AccessibleTableControlObjType::ROWHEADERBAR && m_aTable.HasColHeader()) |
| 69 |
return 1; |
| 70 |
else |
| 71 |
return 0; |
| 72 |
} |
| 73 |
|
| 74 |
// XAccessibleComponent ------------------------------------------------------- |
| 75 |
|
| 76 |
Reference< XAccessible > SAL_CALL |
| 77 |
AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point& rPoint ) |
| 78 |
{ |
| 79 |
SolarMutexGuard aSolarGuard; |
| 80 |
|
| 81 |
ensureAlive(); |
| 82 |
|
| 83 |
sal_Int32 nRow = 0; |
| 84 |
sal_Int32 nColumnPos = 0; |
| 85 |
bool bConverted = m_aTable.ConvertPointToCellAddress(nRow, nColumnPos, |
| 86 |
vcl::unohelper::ConvertToVCLPoint(rPoint)); |
| 87 |
return bConverted ? implGetChild( nRow, nColumnPos ) : Reference< XAccessible >(); |
| 88 |
} |
| 89 |
|
| 90 |
void SAL_CALL AccessibleGridControlHeader::grabFocus() |
| 91 |
{ |
| 92 |
ensureAlive(); |
| 93 |
// focus on header not supported |
| 94 |
} |
| 95 |
|
| 96 |
// XAccessibleTable ----------------------------------------------------------- |
| 97 |
|
| 98 |
OUString SAL_CALL AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow ) |
| 99 |
{ |
| 100 |
SolarMutexGuard aSolarGuard; |
| 101 |
|
| 102 |
ensureAlive(); |
| 103 |
ensureIsValidRow( nRow ); |
| 104 |
return OUString(); // no headers in headers |
| 105 |
} |
| 106 |
|
| 107 |
OUString SAL_CALL AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn ) |
| 108 |
{ |
| 109 |
SolarMutexGuard aSolarGuard; |
| 110 |
|
| 111 |
ensureAlive(); |
| 112 |
ensureIsValidColumn( nColumn ); |
| 113 |
return OUString(); // no headers in headers |
| 114 |
} |
| 115 |
|
| 116 |
Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleRowHeaders() |
| 117 |
{ |
| 118 |
SolarMutexGuard g; |
| 119 |
|
| 120 |
ensureAlive(); |
| 121 |
return nullptr; // no headers in headers |
| 122 |
} |
| 123 |
|
| 124 |
Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleColumnHeaders() |
| 125 |
{ |
| 126 |
SolarMutexGuard g; |
| 127 |
|
| 128 |
ensureAlive(); |
| 129 |
return nullptr; // no headers in headers |
| 130 |
} |
| 131 |
//not selectable |
| 132 |
Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleRows() |
| 133 |
{ |
| 134 |
return {}; |
| 135 |
} |
| 136 |
//columns aren't selectable |
| 137 |
Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleColumns() |
| 138 |
{ |
| 139 |
return {}; |
| 140 |
} |
| 141 |
//row headers not selectable |
| 142 |
sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32 /*nRow*/ ) |
| 143 |
{ |
| 144 |
return false; |
| 145 |
} |
| 146 |
//columns aren't selectable |
| 147 |
sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32 ) |
| 148 |
{ |
| 149 |
return false; |
| 150 |
} |
| 151 |
|
| 152 |
Reference< XAccessible > SAL_CALL AccessibleGridControlHeader::getAccessibleCellAt( |
| 153 |
sal_Int32 nRow, sal_Int32 nColumn) |
| 154 |
{ |
| 155 |
SolarMutexGuard g; |
| 156 |
|
| 157 |
ensureAlive(); |
| 158 |
ensureIsValidAddress(nRow, nColumn); |
| 159 |
return implGetChild(nRow, nColumn); |
| 160 |
} |
| 161 |
// not selectable |
| 162 |
sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleSelected( |
| 163 |
sal_Int32 /*nRow*/, sal_Int32 /*nColumn */) |
| 164 |
{ |
| 165 |
return false; |
| 166 |
} |
| 167 |
|
| 168 |
// XServiceInfo --------------------------------------------------------------- |
| 169 |
|
| 170 |
OUString SAL_CALL AccessibleGridControlHeader::getImplementationName() |
| 171 |
{ |
| 172 |
return u"com.sun.star.accessibility.AccessibleGridControlHeader"_ustr; |
| 173 |
} |
| 174 |
|
| 175 |
// internal virtual methods --------------------------------------------------- |
| 176 |
|
| 177 |
AbsoluteScreenPixelRectangle AccessibleGridControlHeader::implGetBoundingBoxOnScreen() |
| 178 |
{ |
| 179 |
AbsoluteScreenPixelRectangle aGridRect( m_aTable.GetWindowExtentsAbsolute() ); |
| 180 |
tools::Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar())); |
| 181 |
if(isColumnBar()) |
| 182 |
return AbsoluteScreenPixelRectangle(aGridRect.TopLeft(), Size(aGridRect.getOpenWidth(),aHeaderRect.getOpenHeight())); |
| 183 |
else |
| 184 |
return AbsoluteScreenPixelRectangle(aGridRect.TopLeft(), Size(aHeaderRect.getOpenWidth(),aGridRect.getOpenHeight())); |
| 185 |
} |
| 186 |
|
| 187 |
// internal helper methods ---------------------------------------------------- |
| 188 |
Reference< XAccessible > AccessibleGridControlHeader::implGetChild( |
| 189 |
sal_Int32 nRow, sal_uInt32 nColumnPos ) |
| 190 |
{ |
| 191 |
if (m_eObjType == AccessibleTableControlObjType::COLUMNHEADERBAR) |
| 192 |
{ |
| 193 |
rtl::Reference<AccessibleGridControlHeaderCell> pColHeaderCell = new AccessibleGridControlHeaderCell(nColumnPos, this, m_aTable, |
| 194 |
AccessibleTableControlObjType::COLUMNHEADERCELL); |
| 195 |
return pColHeaderCell; |
| 196 |
} |
| 197 |
else if (m_eObjType == AccessibleTableControlObjType::ROWHEADERBAR) |
| 198 |
{ |
| 199 |
rtl::Reference<AccessibleGridControlHeaderCell> pRowHeaderCell = new AccessibleGridControlHeaderCell(nRow, this, m_aTable, |
| 200 |
AccessibleTableControlObjType::ROWHEADERCELL); |
| 201 |
return pRowHeaderCell; |
| 202 |
} |
| 203 |
return nullptr; |
| 204 |
} |
| 205 |
|
| 206 |
} // namespace accessibility |
| 207 |
|
| 208 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |