summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2022-10-28 22:11:59 +0200
committerTomaž Vajngerl <quikee@gmail.com>2022-11-18 02:05:55 +0100
commit00128f14c400b661444676410b2088aca357291c (patch)
tree52b89f59e8419117ad24fdbdd81c884a9b629bd5
parent0eec6d44c65f895c6fe2172792717418627db05d (diff)
sw: add a menu option to enable/disable online a11y check
Change-Id: I656037ef4e40e7c79daef5dd73f8f10c9818ac25 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142215 Tested-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--include/sfx2/sfxsids.hrc14
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu14
-rw-r--r--svx/sdi/svx.sdi18
-rw-r--r--sw/inc/OnlineAccessibilityCheck.hxx5
-rw-r--r--sw/inc/node.hxx1
-rw-r--r--sw/sdi/_viewsh.sdi11
-rw-r--r--sw/source/core/txtnode/OnlineAccessibilityCheck.cxx42
-rw-r--r--sw/source/uibase/uiview/view0.cxx24
-rw-r--r--sw/uiconfig/sglobal/menubar/menubar.xml1
-rw-r--r--sw/uiconfig/swriter/menubar/menubar.xml1
10 files changed, 119 insertions, 12 deletions
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 8333ce792d9d..eb729e873fd2 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -459,15 +459,15 @@ class SvxZoomItem;
#define SID_PASTE_ONLY_FORMULA (SID_SFX_START + 803)
#define SID_PASTE_ONLY_VALUE (SID_SFX_START + 804)
#define SID_PASTE_TEXTIMPORT_DIALOG (SID_SFX_START + 805)
-#define SID_PASTE_TRANSPOSED (SID_SFX_START + 812)
-#define SID_PASTE_AS_LINK (SID_SFX_START + 813)
+#define SID_PASTE_TRANSPOSED (SID_SFX_START + 808)
+#define SID_PASTE_AS_LINK (SID_SFX_START + 809)
// Used for redaction
-#define SID_SHAPE_NAME (SID_SFX_START + 808)
- // FREE: SID_SFX_START + 809
-#define SID_GRAPHIC_SIZE_CHECK (SID_SFX_START + 809)
-#define SID_ACCESSIBILITY_CHECK (SID_SFX_START + 810)
-#define SID_ASYNCHRON (SID_SFX_START + 811)
+#define SID_SHAPE_NAME (SID_SFX_START + 810)
+#define SID_GRAPHIC_SIZE_CHECK (SID_SFX_START + 811)
+#define SID_ACCESSIBILITY_CHECK (SID_SFX_START + 812)
+#define SID_ASYNCHRON (SID_SFX_START + 813)
+#define SID_ACCESSIBILITY_CHECK_ONLINE (SID_SFX_START + 814)
// default-ids for configuration
#define SID_CONFIG (SID_SFX_START + 904)
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index 20817a9b4239..c355eb776ad3 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -5020,6 +5020,20 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8
<value>9</value>
</prop>
</node>
+ <node oor:name=".uno:AccessibilityCheckOnline" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Automatic Accessibility Checking</value>
+ </prop>
+ <prop oor:name="ContextLabel" oor:type="xs:string">
+ <value xml:lang="en-US">Automatic A~ccessibility Checking</value>
+ </prop>
+ <prop oor:name="TooltipLabel" oor:type="xs:string">
+ <value xml:lang="en-US">Toggle Automatic Accessibility Checking</value>
+ </prop>
+ <prop oor:name="Properties" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ </node>
<node oor:name=".uno:HideSpellMark" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Do Not Mark Errors</value>
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 0be42759ae94..d4e4f62450b6 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -12546,6 +12546,24 @@ SfxVoidItem AccessibilityCheck SID_ACCESSIBILITY_CHECK
GroupId = SfxGroupId::Modify;
]
+SfxBoolItem AccessibilityCheckOnline SID_ACCESSIBILITY_CHECK_ONLINE
+(SfxBoolItem Enable FN_PARAM_1)
+[
+ AutoUpdate = TRUE,
+ FastCall = FALSE,
+ ReadOnlyDoc = TRUE,
+ Toggle = TRUE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+
+
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ ToolBoxConfig = TRUE,
+ GroupId = SfxGroupId::Options;
+]
+
XColorItem GlowColor SID_ATTR_GLOW_COLOR
[
diff --git a/sw/inc/OnlineAccessibilityCheck.hxx b/sw/inc/OnlineAccessibilityCheck.hxx
index 7a37f05cc432..fe4652949d64 100644
--- a/sw/inc/OnlineAccessibilityCheck.hxx
+++ b/sw/inc/OnlineAccessibilityCheck.hxx
@@ -52,15 +52,18 @@ private:
SwNodeOffset m_nPreviousNodeIndex;
sal_Int32 m_nAccessibilityIssues;
bool m_bInitialCheck;
+ bool m_bOnlineCheckStatus;
void runAccessibilityCheck(SwNode* pNode);
void updateStatusbar();
void updateNodeStatus(SwNode* pContentNode);
void initialCheck();
+ void lookForPreviousNodeAndUpdate(SwPosition const& rNewPos);
+ void clearAccessibilityIssuesFromAllNodes();
public:
OnlineAccessibilityCheck(SwDoc& rDocument);
- void update(const SwPosition& rNewPos);
+ void update(SwPosition const& rNewPos);
sal_Int32 getNumberOfAccessibilityIssues() { return m_nAccessibilityIssues; }
};
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index 0d0561d6f024..e04266de1037 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -87,7 +87,6 @@ namespace sw
struct AccessibilityCheckStatus
{
std::unique_ptr<sfx::AccessibilityIssueCollection> pCollection;
- bool bDirty = true;
};
}
diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi
index 2dc3235cc3a8..c3096bc57d3a 100644
--- a/sw/sdi/_viewsh.sdi
+++ b/sw/sdi/_viewsh.sdi
@@ -825,10 +825,17 @@ interface BaseTextEditView
StateMethod = GetState ;
DisableFlags="SfxDisableFlags::SwOnProtectedCursor";
]
+
SID_AUTOSPELL_CHECK
[
- ExecMethod = ExecViewOptions ;
- StateMethod = StateViewOptions ;
+ ExecMethod = ExecViewOptions;
+ StateMethod = StateViewOptions;
+ ]
+
+ SID_ACCESSIBILITY_CHECK_ONLINE
+ [
+ ExecMethod = ExecViewOptions;
+ StateMethod = StateViewOptions;
]
//Extra/Options/View
diff --git a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
index 464cc55d2803..db1212600644 100644
--- a/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
+++ b/sw/source/core/txtnode/OnlineAccessibilityCheck.cxx
@@ -66,6 +66,8 @@ OnlineAccessibilityCheck::OnlineAccessibilityCheck(SwDoc& rDocument)
, m_nPreviousNodeIndex(-1)
, m_nAccessibilityIssues(0)
, m_bInitialCheck(false)
+ , m_bOnlineCheckStatus(
+ officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get())
{
}
@@ -159,9 +161,32 @@ void OnlineAccessibilityCheck::update(const SwPosition& rNewPos)
bool bOnlineCheckStatus
= officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get();
+ if (bOnlineCheckStatus != m_bOnlineCheckStatus)
+ {
+ EndListeningAll();
+ m_pPreviousNode = nullptr;
+ m_nPreviousNodeIndex = SwNodeOffset(-1);
+ m_bInitialCheck = false; // force initial check
+
+ if (!bOnlineCheckStatus)
+ {
+ clearAccessibilityIssuesFromAllNodes(); // cleanup all accessibility check data on nodes
+ updateStatusbar();
+ }
+
+ m_bOnlineCheckStatus = bOnlineCheckStatus;
+ }
+
if (!bOnlineCheckStatus)
return;
+ initialCheck();
+
+ lookForPreviousNodeAndUpdate(rNewPos);
+}
+
+void OnlineAccessibilityCheck::lookForPreviousNodeAndUpdate(const SwPosition& rNewPos)
+{
auto nCurrenNodeIndex = rNewPos.GetNodeIndex();
auto* pCurrentNode = &rNewPos.GetNode();
@@ -217,8 +242,23 @@ void OnlineAccessibilityCheck::update(const SwPosition& rNewPos)
m_pPreviousNode = nullptr;
m_nPreviousNodeIndex = SwNodeOffset(-1);
}
+}
- initialCheck();
+void OnlineAccessibilityCheck::clearAccessibilityIssuesFromAllNodes()
+{
+ auto const& pNodes = m_rDocument.GetNodes();
+ for (SwNodeOffset n(0); n < pNodes.Count(); ++n)
+ {
+ SwNode* pNode = pNodes[n];
+ if (pNode)
+ {
+ auto& rStatus = pNode->getAccessibilityCheckStatus();
+ rStatus.pCollection.reset();
+ }
+ }
+
+ m_aNodes.clear();
+ updateStatusbar();
}
} // end sw
diff --git a/sw/source/uibase/uiview/view0.cxx b/sw/source/uibase/uiview/view0.cxx
index fefada834a84..c6b9d0e22d34 100644
--- a/sw/source/uibase/uiview/view0.cxx
+++ b/sw/source/uibase/uiview/view0.cxx
@@ -25,6 +25,7 @@
#include <unotools/configmgr.hxx>
#include <unotools/linguprops.hxx>
#include <unotools/lingucfg.hxx>
+#include <officecfg/Office/Common.hxx>
#include <viewopt.hxx>
#include <globals.h>
#include <sfx2/infobar.hxx>
@@ -326,6 +327,12 @@ void SwView::StateViewOptions(SfxItemSet &rSet)
case SID_AUTOSPELL_CHECK:
aBool.SetValue( pOpt->IsOnlineSpell() );
break;
+ case SID_ACCESSIBILITY_CHECK_ONLINE:
+ {
+ bool bOnlineAccessibilityCheck = officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get();
+ aBool.SetValue(bOnlineAccessibilityCheck);
+ }
+ break;
case FN_SHADOWCURSOR:
if ( pOpt->getBrowseMode() )
{
@@ -574,6 +581,23 @@ void SwView::ExecViewOptions(SfxRequest &rReq)
}
break;
+ case SID_ACCESSIBILITY_CHECK_ONLINE:
+ {
+ if (pArgs && pArgs->HasItem(FN_PARAM_1, &pItem))
+ {
+ bSet = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+ }
+ else if (STATE_TOGGLE == eState)
+ {
+ bool bOnlineCheck = officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::get();
+ bSet = !bOnlineCheck;
+ }
+ std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
+ officecfg::Office::Common::Accessibility::OnlineAccessibilityCheck::set(bSet, batch);
+ batch->commit();
+ }
+ break;
+
case FN_SHADOWCURSOR:
if( STATE_TOGGLE == eState )
{
diff --git a/sw/uiconfig/sglobal/menubar/menubar.xml b/sw/uiconfig/sglobal/menubar/menubar.xml
index 4e305c1410f4..b933889b88f2 100644
--- a/sw/uiconfig/sglobal/menubar/menubar.xml
+++ b/sw/uiconfig/sglobal/menubar/menubar.xml
@@ -719,6 +719,7 @@
</menu:menu>
<menu:menuitem menu:id=".uno:WordCountDialog" menu:style="text"/>
<menu:menuitem menu:id=".uno:AccessibilityCheck"/>
+ <menu:menuitem menu:id=".uno:AccessibilityCheckOnline"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:Translate" menu:style="text"/>
<menu:menuseparator/>
diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml
index 06823b5beacc..3c60d9b8895a 100644
--- a/sw/uiconfig/swriter/menubar/menubar.xml
+++ b/sw/uiconfig/swriter/menubar/menubar.xml
@@ -744,6 +744,7 @@
</menu:menu>
<menu:menuitem menu:id=".uno:WordCountDialog"/>
<menu:menuitem menu:id=".uno:AccessibilityCheck"/>
+ <menu:menuitem menu:id=".uno:AccessibilityCheckOnline"/>
<menu:menuseparator/>
<menu:menuitem menu:id=".uno:Translate"/>
<menu:menuseparator/>