[Libreoffice-commits] core.git: sw/inc sw/source

Stefanenko (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 8 10:32:59 UTC 2020


 sw/inc/AccessibilityCheckStrings.hrc         |    1 
 sw/source/core/access/AccessibilityCheck.cxx |   34 +++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

New commits:
commit 0655e72add8386642abdf6e2990c5af7532b32a6
Author:     Stefanenko <ivan.stefanenko at collabora.com>
AuthorDate: Thu Sep 3 13:20:35 2020 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Sep 8 12:32:16 2020 +0200

    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 at collabora.com>
    Tested-by: Jenkins

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;


More information about the Libreoffice-commits mailing list