Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/accessibility/AccessibleBrowseBoxHeaderCell.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 <rtl/ref.hxx>
21
#include <tools/gen.hxx>
22
#include <vcl/accessibility/AccessibleBrowseBoxHeaderCell.hxx>
23
#include <vcl/accessibletableprovider.hxx>
24
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
25
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26
27
using namespace ::com::sun::star::accessibility;
28
using namespace ::com::sun::star::lang;
29
using namespace ::com::sun::star::uno;
30
31
AccessibleBrowseBoxHeaderCell::AccessibleBrowseBoxHeaderCell(
32
    sal_Int32 _nColumnRowId, const rtl::Reference<OAccessible>& rpParent,
33
    vcl::IAccessibleTableProvider& rBrowseBox, AccessibleBrowseBoxObjType eObjType)
34
0
    : AccessibleBrowseBoxBase(rpParent, rBrowseBox, nullptr, eObjType,
35
0
                              rBrowseBox.GetAccessibleObjectName(eObjType, _nColumnRowId),
36
0
                              rBrowseBox.GetAccessibleObjectDescription(eObjType, _nColumnRowId))
37
0
    , m_nColumnRowId(_nColumnRowId)
38
0
{
39
0
}
40
/** Return a bitset of states of the current object.
41
*/
42
sal_Int64 AccessibleBrowseBoxHeaderCell::implCreateStateSet()
43
0
{
44
0
    SolarMethodGuard aGuard( getMutex() );
45
46
0
    sal_Int64 nStateSet = 0;
47
48
0
    if( isAlive() )
49
0
    {
50
        // SHOWING done with mxParent
51
0
        if( implIsShowing() )
52
0
            nStateSet |= AccessibleStateType::SHOWING;
53
54
0
        mpBrowseBox->FillAccessibleStateSet( nStateSet, getType() );
55
0
        nStateSet |= AccessibleStateType::VISIBLE;
56
0
        nStateSet |= AccessibleStateType::FOCUSABLE;
57
0
        nStateSet |= AccessibleStateType::TRANSIENT;
58
0
        nStateSet |= AccessibleStateType::SELECTABLE;
59
60
0
        bool bSelected = isRowBarCell() ? mpBrowseBox->IsRowSelected(m_nColumnRowId) : mpBrowseBox->IsColumnSelected(m_nColumnRowId);
61
0
        if ( bSelected )
62
0
            nStateSet |= AccessibleStateType::SELECTED;
63
0
    }
64
0
    else
65
0
        nStateSet |= AccessibleStateType::DEFUNC;
66
67
0
    return nStateSet;
68
0
}
69
70
/** @return
71
        The count of visible children.
72
*/
73
sal_Int64 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChildCount()
74
0
{
75
0
    return 0;
76
0
}
77
78
79
/** @return
80
        The XAccessible interface of the specified child.
81
*/
82
Reference<XAccessible > SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleChild( sal_Int64 )
83
0
{
84
0
    throw IndexOutOfBoundsException();
85
0
}
86
87
88
/** Grabs the focus to the column header. */
89
void SAL_CALL AccessibleBrowseBoxHeaderCell::grabFocus()
90
0
{
91
0
    SolarMethodGuard aGuard(getMutex());
92
0
    ensureIsAlive();
93
94
0
    if ( isRowBarCell() )
95
0
        mpBrowseBox->SelectRow(m_nColumnRowId);
96
0
    else
97
0
        mpBrowseBox->SelectColumn(static_cast<sal_uInt16>(m_nColumnRowId)); //!!!
98
0
}
99
100
/** @return
101
        The name of this class.
102
*/
103
OUString SAL_CALL AccessibleBrowseBoxHeaderCell::getImplementationName()
104
0
{
105
0
    return u"com.sun.star.comp.svtools.AccessibleBrowseBoxHeaderCell"_ustr;
106
0
}
107
108
tools::Rectangle AccessibleBrowseBoxHeaderCell::implGetBoundingBox()
109
0
{
110
0
    sal_Int32 nRow  = 0;
111
0
    sal_uInt16 nCol =  static_cast<sal_uInt16>(m_nColumnRowId);
112
0
    if (isRowBarCell())
113
0
    {
114
0
        nRow = m_nColumnRowId + 1;
115
0
        nCol = 0;
116
0
    }
117
118
0
    tools::Rectangle aRet(mpBrowseBox->calcFieldRectPixel(nRow , nCol, true));
119
0
    return tools::Rectangle(aRet.TopLeft() - Point(0, aRet.GetHeight()), aRet.GetSize());
120
0
}
121
122
sal_Int64 SAL_CALL AccessibleBrowseBoxHeaderCell::getAccessibleIndexInParent()
123
0
{
124
0
    ::osl::MutexGuard aGuard( getMutex() );
125
0
    ensureIsAlive();
126
0
    sal_Int64 nIndex = m_nColumnRowId;
127
0
    if ( mpBrowseBox->HasRowHeader() )
128
0
        --nIndex;
129
0
    return nIndex;
130
0
}
131
132
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */