sw/inc/AccessibilityCheckStrings.hrc | 1 sw/source/core/access/AccessibilityCheck.cxx | 35 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
New commits: commit 528cc99c57fa90a08c92e8bf654a0efee8ecf39f Author: Ivan Stefanenko <ivan.stefane...@collabora.com> AuthorDate: Fri Sep 18 19:52:34 2020 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Sep 30 12:06:23 2020 +0200 tdf#137104 Added a check for headings in tables New check checks if a node is a heading and if it is in a table. Change-Id: I53938ddb57573f80c7823b05bff2d1dd2cee1b8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103014 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/inc/AccessibilityCheckStrings.hrc b/sw/inc/AccessibilityCheckStrings.hrc index 5583d0fa6419..73ac5043e57b 100644 --- a/sw/inc/AccessibilityCheckStrings.hrc +++ b/sw/inc/AccessibilityCheckStrings.hrc @@ -25,6 +25,7 @@ #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_HEADING_IN_TABLE NC_("STR_HEADING_IN_TABLE", "Tables must not contain headings.") #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 ea8034152ce8..1127f9576cda 100644 --- a/sw/source/core/access/AccessibilityCheck.cxx +++ b/sw/source/core/access/AccessibilityCheck.cxx @@ -691,6 +691,40 @@ public: } }; +/// Heading paragraphs (with outline levels > 0) are not allowed in tables +class TableHeadingCheck : public NodeCheck +{ +private: + // Boolean indicaing if heading-in-table warning is already triggered. + bool bPrevPassed; + +public: + TableHeadingCheck(sfx::AccessibilityIssueCollection& rIssueCollection) + : NodeCheck(rIssueCollection) + , bPrevPassed(true) + { + } + + void check(SwNode* pCurrent) override + { + if (!bPrevPassed) + return; + + const SwTextNode* textNode = pCurrent->GetTextNode(); + + if (textNode && textNode->GetAttrOutlineLevel() != 0) + { + const SwTableNode* parentTable = pCurrent->FindTableNode(); + + if (parentTable) + { + bPrevPassed = false; + lclAddIssue(m_rIssueCollection, SwResId(STR_HEADING_IN_TABLE)); + } + } + } +}; + class DocumentCheck : public BaseCheck { public: @@ -843,6 +877,7 @@ void AccessibilityCheck::check() 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)); + aNodeChecks.push_back(std::make_unique<TableHeadingCheck>(m_aIssueCollection)); auto const& pNodes = m_pDoc->GetNodes(); SwNode* pNode = nullptr; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits