summaryrefslogtreecommitdiff
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2023-05-15 15:14:09 +0200
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2023-05-15 21:20:04 +0200
commit168528094262f59aa5862dfb396ee4d95a989394 (patch)
tree823a0877e8ac86826ea9ee093429129b04e2fac7 /sw/source/uibase
parent9b90463351919d05c6ce602e7788c4583c5f5534 (diff)
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.mehrbrodt@allotropia.de>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/sidebar/A11yCheckIssuesPanel.cxx30
-rw-r--r--sw/source/uibase/sidebar/A11yCheckIssuesPanel.hxx2
2 files changed, 31 insertions, 1 deletions
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