diff options
author | Stefanenko <ivan.stefanenko@collabora.com> | 2020-09-03 13:20:35 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-09-08 12:32:16 +0200 |
commit | 0655e72add8386642abdf6e2990c5af7532b32a6 (patch) | |
tree | ad80e65658f4a09d6e848b9cf3cb21a9bd54b73c | |
parent | 6caa412d911e806f805633f1296ddc5908eab868 (diff) |
tdf#136468 Added a new check for objects and nodes.
Floating objects with text create problems with reading order
A new check for floating text field inserted into checkObject function and into node-checking mechanism.
Change-Id: Ice97d8a3e24de21ee6c6d2b0a6f89c348f665c8d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101994
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
-rw-r--r-- | sw/inc/AccessibilityCheckStrings.hrc | 1 | ||||
-rw-r--r-- | sw/source/core/access/AccessibilityCheck.cxx | 34 |
2 files changed, 35 insertions, 0 deletions
diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index 874f910f324d..5583d0fa6419 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -24,6 +24,7 @@ #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_FLOATING_TEXT NC_("STR_FLOATING_TEXT", "Avoid floating text.") #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 ab5d5e2aa29a..72c127ae6b8c 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -32,6 +32,9 @@ #include <txtftn.hxx> #include <svl/itemiter.hxx> #include <o3tl/vector_utils.hxx> +#include <svx/swframetypes.hxx> +#include <fmtanchr.hxx> +#include <dcontact.hxx> namespace sw { @@ -664,6 +667,30 @@ public: } }; +/// Check for floating text frames, as it causes problems with reading order. +class FloatingTextCheck : public NodeCheck +{ +public: + FloatingTextCheck(sfx::AccessibilityIssueCollection& rIssueCollection) + : NodeCheck(rIssueCollection) + { + } + + void check(SwNode* pCurrent) override + { + // if node is a text-node and if it has text, we proceed. Otherwise - return. + const SwTextNode* textNode = pCurrent->GetTextNode(); + if (!textNode || textNode->GetText().isEmpty()) + return; + + // If a node is in fly and if it is not anchored as char, throw warning. + const SwNode* startFly = pCurrent->FindFlyStartNode(); + if (startFly + && startFly->GetFlyFormat()->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR) + lclAddIssue(m_rIssueCollection, SwResId(STR_FLOATING_TEXT)); + } +}; + class DocumentCheck : public BaseCheck { public: @@ -772,6 +799,12 @@ void AccessibilityCheck::checkObject(SdrObject* pObject) if (!pObject) return; + // Checking if there is floating Writer text draw object and if so, throwing a warning. + // (Floating objects with text create problems with reading order) + if (pObject->HasText() + && FindFrameFormat(pObject)->GetAnchor().GetAnchorId() != RndStdIds::FLY_AS_CHAR) + lclAddIssue(m_aIssueCollection, SwResId(STR_FLOATING_TEXT)); + if (pObject->GetObjIdentifier() == OBJ_CUSTOMSHAPE || pObject->GetObjIdentifier() == OBJ_TEXT) { OUString sAlternative = pObject->GetTitle(); @@ -809,6 +842,7 @@ void AccessibilityCheck::check() 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)); + aNodeChecks.push_back(std::make_unique<FloatingTextCheck>(m_aIssueCollection)); auto const& pNodes = m_pDoc->GetNodes(); SwNode* pNode = nullptr; |