summaryrefslogtreecommitdiffstats
path: root/sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
commit267c6f2ac71f92999e969232431ba04678e7437e (patch)
tree358c9467650e1d0a1d7227a21dac2e3d08b622b2 /sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx
parentInitial commit. (diff)
downloadlibreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz
libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx81
1 files changed, 81 insertions, 0 deletions
diff --git a/sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx b/sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx
new file mode 100644
index 0000000000..9a99d3c578
--- /dev/null
+++ b/sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swtypes.hxx>
+#include <strings.hrc>
+#include <AccessibilityStatusBarControl.hxx>
+#include <svl/intitem.hxx>
+#include <vcl/status.hxx>
+#include <vcl/event.hxx>
+#include <officecfg/Office/Common.hxx>
+#include <bitmaps.hlst>
+
+SFX_IMPL_STATUSBAR_CONTROL(sw::AccessibilityStatusBarControl, SfxInt32Item);
+
+namespace sw
+{
+AccessibilityStatusBarControl::AccessibilityStatusBarControl(sal_uInt16 _nSlotId, sal_uInt16 _nId,
+ StatusBar& rStb)
+ : SfxStatusBarControl(_nSlotId, _nId, rStb)
+ , mnIssues(0)
+ , maImageIssuesFound(Image(StockImage::Yes, RID_BMP_A11Y_CHECK_ISSUES_FOUND))
+ , maImageIssuesNotFound(Image(StockImage::Yes, RID_BMP_A11Y_CHECK_ISSUES_NOT_FOUND))
+{
+}
+
+AccessibilityStatusBarControl::~AccessibilityStatusBarControl() = default;
+
+void AccessibilityStatusBarControl::StateChangedAtStatusBarControl(sal_uInt16 /*nSID*/,
+ SfxItemState eState,
+ const SfxPoolItem* pState)
+{
+ mnIssues = -1;
+
+ bool bOnlineCheckStatus
+ = officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get();
+
+ if (eState == SfxItemState::DEFAULT && bOnlineCheckStatus)
+ {
+ if (auto pItem = dynamic_cast<const SfxInt32Item*>(pState))
+ mnIssues = pItem->GetValue();
+ OUString aString = SwResId(STR_ACCESSIBILITY_CHECK_HINT)
+ .replaceFirst("%issues%", OUString::number(mnIssues));
+ GetStatusBar().SetQuickHelpText(GetId(), aString);
+ }
+ else
+ {
+ GetStatusBar().SetQuickHelpText(GetId(), u""_ustr);
+ }
+
+ GetStatusBar().Invalidate();
+}
+
+void AccessibilityStatusBarControl::Paint(const UserDrawEvent& rUserEvent)
+{
+ if (mnIssues < 0)
+ return;
+
+ vcl::RenderContext* pRenderContext = rUserEvent.GetRenderContext();
+
+ tools::Rectangle aRect = rUserEvent.GetRect();
+ const tools::Rectangle aControlRect = getControlRect();
+
+ Image aImage = mnIssues > 0 ? maImageIssuesFound : maImageIssuesNotFound;
+
+ Size aSize(aImage.GetSizePixel());
+
+ auto aPosition = Point(aRect.Left() + (aControlRect.GetWidth() - aSize.Width()) / 2,
+ aRect.Top() + (aControlRect.GetHeight() - aSize.Height()) / 2);
+
+ pRenderContext->DrawImage(aPosition, aImage);
+}
+
+} // end sw
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */