diff options
author | Stefanenko <ivan.stefanenko@collabora.com> | 2020-09-02 11:39:33 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-09-03 10:24:54 +0200 |
commit | 129e0cfc4321974f9a3aa59489399dd2420d0ffc (patch) | |
tree | 901e986414d3e91d7f81a9e073e5c5e6e176d1b4 /sw | |
parent | 4d57fd4557d818c6ec5aea12cdd797899b4fdcf7 (diff) |
tdf#136399 AccessibilityCheck: Inserted a new check
A new check responsible for checking if the input forms are not formed by manual typing consecutive "_", "..." or "…".
Made a new check class and inserted it into the main checking mechanism, also added a related string.
Change-Id: I6ecc3878114dc432d43ce1ad27ea45d512366320
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101921
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/AccessibilityCheckStrings.hrc | 1 | ||||
-rw-r--r-- | sw/source/core/access/AccessibilityCheck.cxx | 39 |
2 files changed, 40 insertions, 0 deletions
diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index e51f26c79e6f..874f910f324d 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -23,6 +23,7 @@ #define STR_AVOID_ENDNOTES NC_("STR_AVOID_ENDNOTES", "Avoid endnotes.") #define STR_HEADINGS_NOT_IN_ORDER NC_("STR_HEADINGS_NOT_IN_ORDER", "Headings not in order.") #define STR_TEXT_FORMATTING_CONVEYS_MEANING NC_("STR_TEXT_FORMATTING_CONVEYS_MEANING", "The text formatting conveys additional meaning.") +#define STR_NON_INTERACTIVE_FORMS NC_("STR_NON_INTERACTIVE_FORMS", "An input form is not interactive.") #define STR_DOCUMENT_DEFAULT_LANGUAGE NC_("STR_DOCUMENT_DEFAULT_LANGUAGE", "Document default language is not set") #define STR_STYLE_NO_LANGUAGE NC_("STR_STYLE_NO_LANGUAGE", "Style '%STYLE_NAME%' has no language set") diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx index 55f0e214bbe3..ab5d5e2aa29a 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -626,6 +626,44 @@ public: } }; +// ISO 142891-1 : 7.14 +class NonInteractiveFormCheck : public NodeCheck +{ +public: + NonInteractiveFormCheck(sfx::AccessibilityIssueCollection& rIssueCollection) + : NodeCheck(rIssueCollection) + { + } + + void check(SwNode* pCurrent) override + { + if (!pCurrent->IsTextNode()) + return; + + const auto& text = pCurrent->GetTextNode()->GetText(); + + // Series of tests to detect if there are fake forms in the text. + + bool bCheck = text.indexOf("___") == -1; // Repeated underscores. + + if (bCheck) + bCheck = text.indexOf("....") == -1; // Repeated dots. + + if (bCheck) + bCheck = text.indexOf(u"……") == -1; // Repeated ellipsis. + + if (bCheck) + bCheck = text.indexOf(u"….") == -1; // A dot after an ellipsis. + + if (bCheck) + bCheck = text.indexOf(u".…") == -1; // An ellipsis after a dot. + + // Checking if all the tests are passed successfully. If not, adding a warning. + if (!bCheck) + lclAddIssue(m_rIssueCollection, SwResId(STR_NON_INTERACTIVE_FORMS)); + } +}; + class DocumentCheck : public BaseCheck { public: @@ -770,6 +808,7 @@ void AccessibilityCheck::check() aNodeChecks.push_back(std::make_unique<BlinkingTextCheck>(m_aIssueCollection)); aNodeChecks.push_back(std::make_unique<HeaderCheck>(m_aIssueCollection)); aNodeChecks.push_back(std::make_unique<TextFormattingCheck>(m_aIssueCollection)); + aNodeChecks.push_back(std::make_unique<NonInteractiveFormCheck>(m_aIssueCollection)); auto const& pNodes = m_pDoc->GetNodes(); SwNode* pNode = nullptr; |