Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/source/uibase/utlui/AccessibilityStatusBarControl.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
10
#include <swtypes.hxx>
11
#include <strings.hrc>
12
#include <AccessibilityStatusBarControl.hxx>
13
#include <svl/intitem.hxx>
14
#include <vcl/status.hxx>
15
#include <vcl/event.hxx>
16
#include <officecfg/Office/Common.hxx>
17
#include <bitmaps.hlst>
18
19
SFX_IMPL_STATUSBAR_CONTROL(sw::AccessibilityStatusBarControl, SfxInt32Item);
20
21
namespace sw
22
{
23
AccessibilityStatusBarControl::AccessibilityStatusBarControl(sal_uInt16 _nSlotId, sal_uInt16 _nId,
24
                                                             StatusBar& rStb)
25
0
    : SfxStatusBarControl(_nSlotId, _nId, rStb)
26
0
    , mnIssues(0)
27
0
    , maImageIssuesFound(Image(StockImage::Yes, RID_BMP_A11Y_CHECK_ISSUES_FOUND))
28
0
    , maImageIssuesNotFound(Image(StockImage::Yes, RID_BMP_A11Y_CHECK_ISSUES_NOT_FOUND))
29
0
{
30
0
}
31
32
0
AccessibilityStatusBarControl::~AccessibilityStatusBarControl() = default;
33
34
void AccessibilityStatusBarControl::StateChangedAtStatusBarControl(sal_uInt16 /*nSID*/,
35
                                                                   SfxItemState eState,
36
                                                                   const SfxPoolItem* pState)
37
0
{
38
0
    mnIssues = -1;
39
40
0
    bool bOnlineCheckStatus
41
0
        = officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get();
42
43
0
    if (eState == SfxItemState::DEFAULT && bOnlineCheckStatus)
44
0
    {
45
0
        if (auto pItem = dynamic_cast<const SfxInt32Item*>(pState))
46
0
            mnIssues = pItem->GetValue();
47
0
        OUString aString = SwResId(STR_ACCESSIBILITY_CHECK_HINT)
48
0
                               .replaceFirst("%issues%", OUString::number(mnIssues));
49
0
        GetStatusBar().SetQuickHelpText(GetId(), aString);
50
0
    }
51
0
    else
52
0
    {
53
0
        GetStatusBar().SetQuickHelpText(GetId(), u""_ustr);
54
0
    }
55
56
0
    GetStatusBar().Invalidate();
57
0
}
58
59
void AccessibilityStatusBarControl::Paint(const UserDrawEvent& rUserEvent)
60
0
{
61
0
    if (mnIssues < 0)
62
0
        return;
63
64
0
    vcl::RenderContext* pRenderContext = rUserEvent.GetRenderContext();
65
66
0
    tools::Rectangle aRect = rUserEvent.GetRect();
67
0
    const tools::Rectangle aControlRect = getControlRect();
68
69
0
    Image aImage = mnIssues > 0 ? maImageIssuesFound : maImageIssuesNotFound;
70
71
0
    Size aSize(aImage.GetSizePixel());
72
73
0
    auto aPosition = Point(aRect.Left() + (aControlRect.GetWidth() - aSize.Width()) / 2,
74
0
                           aRect.Top() + (aControlRect.GetHeight() - aSize.Height()) / 2);
75
76
0
    pRenderContext->DrawImage(aPosition, aImage);
77
0
}
78
79
} // end sw
80
81
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */