sw/Library_sw.mk | 1 sw/inc/cmdid.h | 1 sw/sdi/_viewsh.sdi | 6 + sw/sdi/swriter.sdi | 17 +++++ sw/sdi/viewsh.sdi | 6 + sw/source/core/txtnode/OnlineAccessibilityCheck.cxx | 10 +++ sw/source/uibase/app/swmodule.cxx | 2 sw/source/uibase/inc/AccessibilityStatusBarControl.hxx | 30 +++++++++ sw/source/uibase/uiview/view2.cxx | 19 ++++++ sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx | 46 +++++++++++++++ sw/uiconfig/sglobal/statusbar/statusbar.xml | 1 sw/uiconfig/swriter/statusbar/statusbar.xml | 1 12 files changed, 138 insertions(+), 2 deletions(-)
New commits: commit e340b81d9d75d3aacfa941df4b531c6a9f5aaffa Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Oct 20 22:35:52 2022 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Nov 15 00:04:16 2022 +0100 sw: add accessibility check statusbar control A11y check statusbar control, which reports the current status of the online a11y check. Change-Id: I07528f39ed84136f99bc1ce07c10aa6163649305 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141605 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index 7785ba9b6254..0e6c2679cb66 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -768,6 +768,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/uibase/uno/unomodule \ sw/source/uibase/uno/unotxdoc \ sw/source/uibase/uno/unotxvw \ + sw/source/uibase/utlui/AccessibilityStatusBarControl \ sw/source/uibase/utlui/attrdesc \ sw/source/uibase/utlui/bookctrl \ sw/source/uibase/utlui/condedit \ diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index 5475184a5d2c..c0d31883c3e0 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -851,6 +851,7 @@ class SwUINumRuleItem; #define FN_STAT_SELMODE (FN_STAT + 5) #define FN_STAT_BOOKMARK (FN_STAT + 8) /* For Popup Bookmarks*/ #define FN_STAT_WORDCOUNT (FN_STAT + 9) +#define FN_STAT_ACCESSIBILITY_CHECK (FN_STAT + 10) // Region: Page preview #define FN_SHOW_TWO_PAGES (FN_PGPREVIEW + 1) diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi index b9fded634561..2dc3235cc3a8 100644 --- a/sw/sdi/_viewsh.sdi +++ b/sw/sdi/_viewsh.sdi @@ -398,6 +398,11 @@ interface BaseTextEditView ExecMethod = ExecuteStatusLine ; StateMethod = StateStatusLine ; ] + FN_STAT_ACCESSIBILITY_CHECK // status() + [ + ExecMethod = ExecuteStatusLine; + StateMethod = StateStatusLine; + ] FN_STAT_BOOKMARK // status() [ ExecMethod = ExecuteStatusLine ; @@ -986,4 +991,3 @@ interface BaseTextEditView ] } - diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index ca4aaf56ca8b..61e38bfe7f78 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -5974,6 +5974,23 @@ SfxStringItem StateWordCount FN_STAT_WORDCOUNT GroupId = SfxGroupId::View; ] +SfxStringItem StateAccessibilityCheck FN_STAT_ACCESSIBILITY_CHECK + +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = FALSE, + MenuConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::View; +] + SfxBoolItem SubScript FN_SET_SUB_SCRIPT [ diff --git a/sw/sdi/viewsh.sdi b/sw/sdi/viewsh.sdi index cb02b883ba65..e4f3c0a362e0 100644 --- a/sw/sdi/viewsh.sdi +++ b/sw/sdi/viewsh.sdi @@ -464,6 +464,11 @@ interface TextPrintPreview ExecMethod = Execute ; StateMethod = GetState ; ] + FN_STAT_ACCESSIBILITY_CHECK // status() + [ + ExecMethod = Execute ; + StateMethod = GetState ; + ] SID_JUMP_TO_SPECIFIC_PAGE // status() [ ExecMethod = Execute ; @@ -477,4 +482,3 @@ shell SwPagePreview { import TextPrintPreview; } - diff --git a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx index 109bac52545b..a26be4e6e0ec 100644 --- a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx +++ b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx @@ -21,6 +21,10 @@ #include <doc.hxx> #include <pam.hxx> #include <txtfrm.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <docsh.hxx> +#include <cmdid.h> #include <officecfg/Office/Common.hxx> namespace sw @@ -63,6 +67,12 @@ void OnlineAccessibilityCheck::runCheck(SwTextNode* pTextNode) m_nAccessibilityIssues += rStatus.pCollection->getIssues().size(); } } + + SfxBindings* pBindings = m_rDocument.GetDocShell() && m_rDocument.GetDocShell()->GetDispatcher() + ? m_rDocument.GetDocShell()->GetDispatcher()->GetBindings() + : nullptr; + if (pBindings) + pBindings->Invalidate(FN_STAT_ACCESSIBILITY_CHECK); } void OnlineAccessibilityCheck::update(const SwPosition& rNewPos) diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index b233bd7c989c..cda5bfc1a83f 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -81,6 +81,7 @@ #include <svx/zoomsliderctrl.hxx> #include <zoomctrl.hxx> #include <wordcountctrl.hxx> +#include <AccessibilityStatusBarControl.hxx> #include <workctrl.hxx> #include <fldwrap.hxx> #include <redlndlg.hxx> @@ -284,6 +285,7 @@ void SwDLL::RegisterControls() SvxSelectionModeControl::RegisterControl(FN_STAT_SELMODE, pMod ); XmlSecStatusBarControl::RegisterControl( SID_SIGNATURE, pMod ); SwWordCountStatusBarControl::RegisterControl(FN_STAT_WORDCOUNT, pMod); + sw::AccessibilityStatusBarControl::RegisterControl(FN_STAT_ACCESSIBILITY_CHECK, pMod); SwBookmarkControl::RegisterControl(FN_STAT_PAGE, pMod ); SwTemplateControl::RegisterControl(FN_STAT_TEMPLATE, pMod ); diff --git a/sw/source/uibase/inc/AccessibilityStatusBarControl.hxx b/sw/source/uibase/inc/AccessibilityStatusBarControl.hxx new file mode 100644 index 000000000000..52e64b99f5ac --- /dev/null +++ b/sw/source/uibase/inc/AccessibilityStatusBarControl.hxx @@ -0,0 +1,30 @@ +/* -*- 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/. + */ + +#pragma once + +#include <sfx2/stbitem.hxx> + +namespace sw +{ +class AccessibilityStatusBarControl final : public SfxStatusBarControl +{ +public: + SFX_DECL_STATUSBAR_CONTROL(); + + AccessibilityStatusBarControl(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar& rStb); + virtual ~AccessibilityStatusBarControl() override; + + virtual void StateChangedAtStatusBarControl(sal_uInt16 nSID, SfxItemState eState, + const SfxPoolItem* pState) override; +}; + +} // end sw + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx index a3d7ce3d3665..a3bdb6bc8a22 100644 --- a/sw/source/uibase/uiview/view2.cxx +++ b/sw/source/uibase/uiview/view2.cxx @@ -131,6 +131,7 @@ #include <unotextrange.hxx> #include <docstat.hxx> #include <wordcountdialog.hxx> +#include <OnlineAccessibilityCheck.hxx> #include <sfx2/sidebar/Sidebar.hxx> #include <vcl/GraphicNativeTransform.hxx> @@ -1812,6 +1813,24 @@ void SwView::StateStatusLine(SfxItemSet &rSet) pWrdCnt->SetCounts(selectionStats, documentStats); } break; + case FN_STAT_ACCESSIBILITY_CHECK: + { + if (rShell.GetDoc()->getOnlineAccessibilityCheck()) + { + auto nIssues = rShell.GetDoc()->getOnlineAccessibilityCheck()->getNumberOfAccessibilityIssues(); + OUString aString; + if (nIssues > 0) + { + aString = u"Issues: " + OUString::number(nIssues); + } + else + { + aString = u"No Issues"; + } + rSet.Put(SfxStringItem(FN_STAT_ACCESSIBILITY_CHECK, aString)); + } + } + break; case FN_STAT_TEMPLATE: { diff --git a/sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx b/sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx new file mode 100644 index 000000000000..55daee5d31d9 --- /dev/null +++ b/sw/source/uibase/utlui/AccessibilityStatusBarControl.cxx @@ -0,0 +1,46 @@ +/* -*- 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/stritem.hxx> +#include <vcl/status.hxx> + +SFX_IMPL_STATUSBAR_CONTROL(sw::AccessibilityStatusBarControl, SfxStringItem); + +namespace sw +{ +AccessibilityStatusBarControl::AccessibilityStatusBarControl(sal_uInt16 _nSlotId, sal_uInt16 _nId, + StatusBar& rStb) + : SfxStatusBarControl(_nSlotId, _nId, rStb) +{ +} + +AccessibilityStatusBarControl::~AccessibilityStatusBarControl() = default; + +void AccessibilityStatusBarControl::StateChangedAtStatusBarControl(sal_uInt16 /*nSID*/, + SfxItemState eState, + const SfxPoolItem* pState) +{ + if (eState == SfxItemState::DEFAULT) // Can access pState + { + GetStatusBar().SetItemText(GetId(), static_cast<const SfxStringItem*>(pState)->GetValue()); + GetStatusBar().SetQuickHelpText(GetId(), SwResId(STR_WORDCOUNT_HINT)); + } + else + { + GetStatusBar().SetItemText(GetId(), u""); + GetStatusBar().SetQuickHelpText(GetId(), u""); + } +} + +} // end sw + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/uiconfig/sglobal/statusbar/statusbar.xml b/sw/uiconfig/sglobal/statusbar/statusbar.xml index f85f07daa068..2f2e54f21c6d 100644 --- a/sw/uiconfig/sglobal/statusbar/statusbar.xml +++ b/sw/uiconfig/sglobal/statusbar/statusbar.xml @@ -20,6 +20,7 @@ <statusbar:statusbar xmlns:statusbar="http://openoffice.org/2001/statusbar" xmlns:xlink="http://www.w3.org/1999/xlink"> <statusbar:statusbaritem xlink:href=".uno:StatePageNumber" statusbar:align="left" statusbar:autosize="true" statusbar:mandatory="true" statusbar:width="54"/> <statusbar:statusbaritem xlink:href=".uno:StateWordCount" statusbar:align="left" statusbar:autosize="true"/> + <statusbar:statusbaritem xlink:href=".uno:StateAccessibilityCheck" statusbar:align="left" statusbar:width="50"/> <statusbar:statusbaritem xlink:href=".uno:PageStyleName" statusbar:align="left" statusbar:autosize="true" statusbar:width="79"/> <statusbar:statusbaritem xlink:href=".uno:LanguageStatus" statusbar:align="center" statusbar:autosize="true" statusbar:mandatory="false" statusbar:width="100"/> <statusbar:statusbaritem xlink:href=".uno:InsertMode" statusbar:align="center" statusbar:mandatory="false" statusbar:width="55"/> diff --git a/sw/uiconfig/swriter/statusbar/statusbar.xml b/sw/uiconfig/swriter/statusbar/statusbar.xml index cc20c57fa81e..090c44b1f941 100644 --- a/sw/uiconfig/swriter/statusbar/statusbar.xml +++ b/sw/uiconfig/swriter/statusbar/statusbar.xml @@ -21,6 +21,7 @@ <statusbar:statusbaritem xlink:href=".uno:ModifiedStatus" statusbar:align="center" statusbar:ownerdraw="true" statusbar:mandatory="true" statusbar:width="16"/> <statusbar:statusbaritem xlink:href=".uno:StatePageNumber" statusbar:align="left" statusbar:autosize="true" statusbar:mandatory="true" statusbar:width="54"/> <statusbar:statusbaritem xlink:href=".uno:StateWordCount" statusbar:align="left" statusbar:autosize="true"/> +<statusbar:statusbaritem xlink:href=".uno:StateAccessibilityCheck" statusbar:align="left" statusbar:width="50"/> <statusbar:statusbaritem xlink:href=".uno:PageStyleName" statusbar:align="left" statusbar:autosize="true" statusbar:width="79"/> <statusbar:statusbaritem xlink:href=".uno:LanguageStatus" statusbar:align="center" statusbar:autosize="true" statusbar:mandatory="false" statusbar:width="100"/> <statusbar:statusbaritem xlink:href=".uno:InsertMode" statusbar:align="center" statusbar:mandatory="false" statusbar:width="55"/>