sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx | 30 +++++++++++++++++++++- sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx | 2 + 2 files changed, 31 insertions(+), 1 deletion(-)
New commits: commit 168528094262f59aa5862dfb396ee4d95a989394 Author: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> AuthorDate: Mon May 15 15:14:09 2023 +0200 Commit: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> CommitDate: Mon May 15 21:20:04 2023 +0200 tdf#142978 Automatic a11y is required for this sidebar panel So enable it while using the panel; and restore the original state afterwards. Change-Id: I15d1d266454d6bf7595956880b646bc047e8be0e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151767 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx index f5673e24c058..cd5d76e23cb0 100644 --- a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx +++ b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx @@ -16,7 +16,10 @@ #include <ndtxt.hxx> #include <wrtsh.hxx> +#include <officecfg/Office/Common.hxx> +#include <sfx2/bindings.hxx> #include <sfx2/AccessibilityIssue.hxx> +#include <unotools/configmgr.hxx> #include <vcl/svapp.hxx> #include "A11yCheckIssuesPanel.hxx" @@ -68,6 +71,7 @@ A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* p : PanelLayout(pParent, "A11yCheckIssuesPanel", "modules/swriter/ui/a11ycheckissuespanel.ui") , m_xAccessibilityCheckBox(m_xBuilder->weld_box("accessibilityCheckBox")) , m_xScrolledWindow(m_xBuilder->weld_scrolled_window("scrolledwindow")) + , mpBindings(pBindings) , mpDoc(nullptr) , maA11yCheckController(FN_STAT_ACCESSIBILITY_CHECK, *pBindings, *this) , mnIssueCount(0) @@ -76,12 +80,36 @@ A11yCheckIssuesPanel::A11yCheckIssuesPanel(weld::Widget* pParent, SfxBindings* p if (!pDocSh) return; + // Automatic a11y checking must be enabled for this panel to work properly + mbAutomaticCheckEnabled + = officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get(); + if (!mbAutomaticCheckEnabled) + { + std::shared_ptr<comphelper::ConfigurationChanges> batch( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::set(true, batch); + batch->commit(); + pBindings->Invalidate(SID_ACCESSIBILITY_CHECK_ONLINE); + } + mpDoc = pDocSh->GetDoc(); populateIssues(); } -A11yCheckIssuesPanel::~A11yCheckIssuesPanel() { m_xAccessibilityCheckBox.reset(); } +A11yCheckIssuesPanel::~A11yCheckIssuesPanel() +{ + // Restore state when this panel is no longer used + if (!mbAutomaticCheckEnabled) + { + std::shared_ptr<comphelper::ConfigurationChanges> batch( + comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::set(false, batch); + batch->commit(); + mpBindings->Invalidate(SID_ACCESSIBILITY_CHECK_ONLINE); + } + m_xAccessibilityCheckBox.reset(); +} void A11yCheckIssuesPanel::populateIssues() { diff --git a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx index 21ffe9fbc057..46d74c97f5a1 100644 --- a/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx +++ b/sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx @@ -66,9 +66,11 @@ private: std::function<sfx::AccessibilityIssueCollection()> m_getIssueCollection; void populateIssues(); + SfxBindings* mpBindings; SwDoc* mpDoc; ::sfx2::sidebar::ControllerItem maA11yCheckController; sal_Int32 mnIssueCount; + bool mbAutomaticCheckEnabled; }; } //end of namespace sw::sidebar