Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / utlui / AccessibilityStatusBarControl.cxx
blobd0ce67fc2349c69363cd7bd19127fbe0ea265ff1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
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>
19 SFX_IMPL_STATUSBAR_CONTROL(sw::AccessibilityStatusBarControl, SfxInt32Item);
21 namespace sw
23 AccessibilityStatusBarControl::AccessibilityStatusBarControl(sal_uInt16 _nSlotId, sal_uInt16 _nId,
24 StatusBar& rStb)
25 : SfxStatusBarControl(_nSlotId, _nId, rStb)
26 , mnIssues(0)
27 , maImageIssuesFound(Image(StockImage::Yes, RID_BMP_A11Y_CHECK_ISSUES_FOUND))
28 , maImageIssuesNotFound(Image(StockImage::Yes, RID_BMP_A11Y_CHECK_ISSUES_NOT_FOUND))
32 AccessibilityStatusBarControl::~AccessibilityStatusBarControl() = default;
34 void AccessibilityStatusBarControl::StateChangedAtStatusBarControl(sal_uInt16 /*nSID*/,
35 SfxItemState eState,
36 const SfxPoolItem* pState)
38 mnIssues = -1;
40 bool bOnlineCheckStatus
41 = officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get();
43 if (eState == SfxItemState::DEFAULT && bOnlineCheckStatus)
45 if (auto pItem = dynamic_cast<const SfxInt32Item*>(pState))
46 mnIssues = pItem->GetValue();
47 OUString aString = SwResId(STR_ACCESSIBILITY_CHECK_HINT)
48 .replaceFirst("%issues%", OUString::number(mnIssues));
49 GetStatusBar().SetQuickHelpText(GetId(), aString);
51 else
53 GetStatusBar().SetQuickHelpText(GetId(), u"");
56 GetStatusBar().Invalidate();
59 void AccessibilityStatusBarControl::Paint(const UserDrawEvent& rUserEvent)
61 if (mnIssues < 0)
62 return;
64 vcl::RenderContext* pRenderContext = rUserEvent.GetRenderContext();
66 tools::Rectangle aRect = rUserEvent.GetRect();
67 const tools::Rectangle aControlRect = getControlRect();
69 Image aImage = mnIssues > 0 ? maImageIssuesFound : maImageIssuesNotFound;
71 Size aSize(aImage.GetSizePixel());
73 auto aPosition = Point(aRect.Left() + (aControlRect.GetWidth() - aSize.Width()) / 2,
74 aRect.Top() + (aControlRect.GetHeight() - aSize.Height()) / 2);
76 pRenderContext->DrawImage(aPosition, aImage);
79 } // end sw
81 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */