Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/accessibility/svtaccessiblenumericfield.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 <accessibility/svtaccessiblenumericfield.hxx>
21
#include <comphelper/accessiblecontexthelper.hxx>
22
23
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
24
#include <com/sun/star/accessibility/AccessibleRole.hpp>
25
#include <vcl/vclevent.hxx>
26
27
using namespace ::com::sun::star::accessibility;
28
using namespace ::comphelper;
29
30
SVTXAccessibleNumericField::SVTXAccessibleNumericField(FormattedField* pFormattedField)
31
0
    : ImplInheritanceHelper(pFormattedField)
32
0
{
33
0
}
34
35
void SVTXAccessibleNumericField::ProcessWindowEvent(const VclWindowEvent& rVclWindowEvent)
36
0
{
37
0
    VCLXAccessibleEdit::ProcessWindowEvent(rVclWindowEvent);
38
39
0
    if (rVclWindowEvent.GetId() == VclEventId::EditModify)
40
0
    {
41
0
        css::uno::Any aNewValue = getCurrentValue();
42
0
        NotifyAccessibleEvent(AccessibleEventId::VALUE_CHANGED, css::uno::Any(), aNewValue);
43
0
    }
44
0
}
45
46
0
sal_Int16 SVTXAccessibleNumericField::getAccessibleRole() { return AccessibleRole::SPIN_BOX; }
47
48
css::uno::Any SAL_CALL SVTXAccessibleNumericField::getCurrentValue()
49
0
{
50
0
    OExternalLockGuard aGuard(this);
51
52
0
    double dValue = 0;
53
0
    VclPtr<FormattedField> pField = GetAs<FormattedField>();
54
0
    if (pField)
55
0
        dValue = pField->GetFormatter().GetValue();
56
57
0
    return css::uno::Any(dValue);
58
0
}
59
60
sal_Bool SVTXAccessibleNumericField::setCurrentValue(const css::uno::Any& aNumber)
61
0
{
62
0
    OExternalLockGuard aGuard(this);
63
64
0
    VclPtr<FormattedField> pField = GetAs<FormattedField>();
65
0
    if (!pField)
66
0
        return false;
67
68
0
    double dValue = 0;
69
0
    aNumber >>= dValue;
70
0
    pField->GetFormatter().SetValue(dValue);
71
0
    return true;
72
0
}
73
74
css::uno::Any SAL_CALL SVTXAccessibleNumericField::getMaximumValue()
75
0
{
76
0
    OExternalLockGuard aGuard(this);
77
78
0
    double dValue = 0;
79
0
    VclPtr<FormattedField> pField = GetAs<FormattedField>();
80
0
    if (pField)
81
0
        dValue = pField->GetFormatter().GetMaxValue();
82
83
0
    return css::uno::Any(dValue);
84
0
}
85
86
css::uno::Any SAL_CALL SVTXAccessibleNumericField::getMinimumValue()
87
0
{
88
0
    OExternalLockGuard aGuard(this);
89
90
0
    double dValue = 0;
91
0
    VclPtr<FormattedField> pField = GetAs<FormattedField>();
92
0
    if (pField)
93
0
        dValue = pField->GetFormatter().GetMinValue();
94
95
0
    return css::uno::Any(dValue);
96
0
}
97
98
css::uno::Any SAL_CALL SVTXAccessibleNumericField::getMinimumIncrement()
99
0
{
100
0
    OExternalLockGuard aGuard(this);
101
102
0
    double dValue = 0;
103
0
    VclPtr<FormattedField> pField = GetAs<FormattedField>();
104
0
    if (pField)
105
0
        dValue = pField->GetFormatter().GetSpinSize();
106
107
0
    return css::uno::Any(dValue);
108
0
}
109
110
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */