summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/AccessibilityCheckStrings.hrc1
-rw-r--r--sw/source/core/access/AccessibilityCheck.cxx35
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;