Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/accessibility/AccessibleBrowseBoxTable.cxx
Line
Count
Source
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 <vcl/accessibility/AccessibleBrowseBoxTable.hxx>
21
#include <vcl/accessibletableprovider.hxx>
22
#include <vcl/unohelp.hxx>
23
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
24
25
26
using ::com::sun::star::uno::Reference;
27
using ::com::sun::star::uno::Sequence;
28
29
using namespace ::com::sun::star;
30
using namespace ::com::sun::star::accessibility;
31
32
33
// Ctor/Dtor/disposing --------------------------------------------------------
34
35
AccessibleBrowseBoxTable::AccessibleBrowseBoxTable(
36
        const Reference< XAccessible >& rxParent,
37
        vcl::IAccessibleTableProvider& rBrowseBox ) :
38
0
    AccessibleBrowseBoxTableBase( rxParent, rBrowseBox, AccessibleBrowseBoxObjType::Table )
39
0
{
40
0
}
41
42
AccessibleBrowseBoxTable::~AccessibleBrowseBoxTable()
43
0
{
44
0
}
45
46
// XAccessibleContext ---------------------------------------------------------
47
48
Reference< XAccessible > SAL_CALL
49
AccessibleBrowseBoxTable::getAccessibleChild( sal_Int64 nChildIndex )
50
0
{
51
0
    SolarMethodGuard aGuard(getMutex());
52
0
    ensureIsAlive();
53
54
0
    ensureIsValidIndex( nChildIndex );
55
0
    return mpBrowseBox->CreateAccessibleCell(
56
0
        implGetRow( nChildIndex ), static_cast<sal_Int16>(implGetColumn( nChildIndex )) );
57
0
}
58
59
sal_Int64 SAL_CALL AccessibleBrowseBoxTable::getAccessibleIndexInParent()
60
0
{
61
0
    osl::MutexGuard aGuard( getMutex() );
62
0
    ensureIsAlive();
63
0
    return vcl::BBINDEX_TABLE;
64
0
}
65
66
// XAccessibleComponent -------------------------------------------------------
67
68
Reference< XAccessible > SAL_CALL
69
AccessibleBrowseBoxTable::getAccessibleAtPoint( const awt::Point& rPoint )
70
0
{
71
0
    SolarMethodGuard aGuard(getMutex());
72
0
    ensureIsAlive();
73
74
0
    Reference< XAccessible > xChild;
75
0
    sal_Int32 nRow = 0;
76
0
    sal_uInt16 nColumnPos = 0;
77
0
    if (mpBrowseBox->ConvertPointToCellAddress(nRow, nColumnPos,
78
0
                                               vcl::unohelper::ConvertToVCLPoint(rPoint)))
79
0
        xChild = mpBrowseBox->CreateAccessibleCell( nRow, nColumnPos );
80
81
0
    return xChild;
82
0
}
83
84
void SAL_CALL AccessibleBrowseBoxTable::grabFocus()
85
0
{
86
0
    SolarMethodGuard aGuard(getMutex());
87
0
    ensureIsAlive();
88
0
    mpBrowseBox->GrabTableFocus();
89
0
}
90
91
// XAccessibleTable -----------------------------------------------------------
92
93
OUString SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowDescription( sal_Int32 nRow )
94
0
{
95
0
    SolarMethodGuard aGuard(getMutex());
96
0
    ensureIsAlive();
97
0
    ensureIsValidRow( nRow );
98
0
    return mpBrowseBox->GetRowDescription( nRow );
99
0
}
100
101
OUString SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnDescription( sal_Int32 nColumn )
102
0
{
103
0
    SolarMethodGuard aGuard(getMutex());
104
0
    ensureIsAlive();
105
106
0
    ensureIsValidColumn( nColumn );
107
0
    return mpBrowseBox->GetColumnDescription( static_cast<sal_uInt16>(nColumn) );
108
0
}
109
110
Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleRowHeaders()
111
0
{
112
0
    ::osl::MutexGuard aGuard( getMutex() );
113
0
    ensureIsAlive();
114
0
    return implGetHeaderBar( vcl::BBINDEX_ROWHEADERBAR );
115
0
}
116
117
Reference< XAccessibleTable > SAL_CALL AccessibleBrowseBoxTable::getAccessibleColumnHeaders()
118
0
{
119
0
    ::osl::MutexGuard aGuard( getMutex() );
120
0
    ensureIsAlive();
121
0
    return implGetHeaderBar( vcl::BBINDEX_COLUMNHEADERBAR );
122
0
}
123
124
Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleRows()
125
0
{
126
0
    SolarMethodGuard aGuard(getMutex());
127
0
    ensureIsAlive();
128
129
0
    Sequence< sal_Int32 > aSelSeq;
130
0
    implGetSelectedRows( aSelSeq );
131
0
    return aSelSeq;
132
0
}
133
134
Sequence< sal_Int32 > SAL_CALL AccessibleBrowseBoxTable::getSelectedAccessibleColumns()
135
0
{
136
0
    SolarMethodGuard aGuard(getMutex());
137
0
    ensureIsAlive();
138
139
0
    Sequence< sal_Int32 > aSelSeq;
140
0
    implGetSelectedColumns( aSelSeq );
141
0
    return aSelSeq;
142
0
}
143
144
sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleRowSelected( sal_Int32 nRow )
145
0
{
146
0
    SolarMethodGuard aGuard(getMutex());
147
0
    ensureIsAlive();
148
149
0
    ensureIsValidRow( nRow );
150
0
    return implIsRowSelected( nRow );
151
0
}
152
153
sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleColumnSelected( sal_Int32 nColumn )
154
0
{
155
0
    SolarMethodGuard aGuard(getMutex());
156
0
    ensureIsAlive();
157
158
0
    ensureIsValidColumn( nColumn );
159
0
    return implIsColumnSelected( nColumn );
160
0
}
161
162
Reference< XAccessible > SAL_CALL AccessibleBrowseBoxTable::getAccessibleCellAt(
163
        sal_Int32 nRow, sal_Int32 nColumn )
164
0
{
165
0
    SolarMethodGuard aGuard(getMutex());
166
0
    ensureIsAlive();
167
168
0
    ensureIsValidAddress( nRow, nColumn );
169
0
    return mpBrowseBox->CreateAccessibleCell( nRow, static_cast<sal_Int16>(nColumn) );
170
0
}
171
172
sal_Bool SAL_CALL AccessibleBrowseBoxTable::isAccessibleSelected(
173
        sal_Int32 nRow, sal_Int32 nColumn )
174
0
{
175
0
    SolarMethodGuard aGuard(getMutex());
176
0
    ensureIsAlive();
177
178
0
    ensureIsValidAddress( nRow, nColumn );
179
0
    return implIsRowSelected( nRow ) || implIsColumnSelected( nColumn );
180
0
}
181
182
// XServiceInfo ---------------------------------------------------------------
183
184
OUString SAL_CALL AccessibleBrowseBoxTable::getImplementationName()
185
0
{
186
0
    return u"com.sun.star.comp.svtools.AccessibleBrowseBoxTable"_ustr;
187
0
}
188
189
// internal virtual methods ---------------------------------------------------
190
191
tools::Rectangle AccessibleBrowseBoxTable::implGetBoundingBox()
192
0
{
193
0
    return mpBrowseBox->calcTableRect();
194
0
}
195
196
// internal helper methods ----------------------------------------------------
197
198
Reference< XAccessibleTable > AccessibleBrowseBoxTable::implGetHeaderBar(
199
        sal_Int32 nChildIndex )
200
0
{
201
0
    assert(nChildIndex == vcl::BBINDEX_ROWHEADERBAR || nChildIndex == vcl::BBINDEX_COLUMNHEADERBAR);
202
203
0
    Reference< XAccessible > xRet;
204
0
    Reference< XAccessibleContext > xContext( mxParent, uno::UNO_QUERY );
205
0
    if( xContext.is() )
206
0
    {
207
0
        if (nChildIndex == vcl::BBINDEX_COLUMNHEADERBAR || mpBrowseBox->HasRowHeader())
208
0
        {
209
0
            try
210
0
            {
211
0
                xRet = xContext->getAccessibleChild( nChildIndex );
212
0
            }
213
0
            catch (const lang::IndexOutOfBoundsException&)
214
0
            {
215
0
                OSL_FAIL( "implGetHeaderBar - wrong child index" );
216
0
            }
217
            // RuntimeException goes to caller
218
0
        }
219
0
    }
220
0
    return Reference< XAccessibleTable >( xRet, uno::UNO_QUERY );
221
0
}
222
223
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */