diff options
author | Ivan Stefanenko <ivan.stefanenko@collabora.com> | 2020-09-18 19:52:34 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-09-30 12:06:23 +0200 |
commit | 528cc99c57fa90a08c92e8bf654a0efee8ecf39f (patch) | |
tree | 0d931258cf21a4a7be637c2999ac4771479e8be8 /sw | |
parent | 7ced53424a21ab264374d97aacdfb4ec166c8171 (diff) |
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.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/AccessibilityCheckStrings.hrc | 1 | ||||
-rw-r--r-- | sw/source/core/access/AccessibilityCheck.cxx | 35 |
2 files changed, 36 insertions, 0 deletions
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; |