[Libreoffice-commits] core.git: Branch 'feature/accessibilitycheck' - 2 commits - sw/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Sat Dec 7 12:22:31 UTC 2019
sw/source/core/access/AccessibilityCheck.cxx | 125 +++++++++++++++++++++------
sw/source/core/inc/AccessibilityCheck.hxx | 4
2 files changed, 103 insertions(+), 26 deletions(-)
New commits:
commit 239b5aa976cd4d052ea39ed700e47114f6057dff
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat Dec 7 13:12:12 2019 +0100
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Sat Dec 7 13:20:13 2019 +0100
acc. check: add check for Tables
Tables shouldn't use splitted or merge cells.
Change-Id: Ife6726413d9dd1ead098c081e03f4f82540f1012
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index f327105dc864..2f724d17b102 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -19,6 +19,55 @@
namespace
{
OUString sNoAlt("No alt text for graphic '%OBJECT_NAME%'");
+OUString sTableMergeSplit("Table '%OBJECT_NAME%' contains merges or splits");
+}
+
+void AccessibilityCheck::checkTableNode(SwTableNode* pTableNode)
+{
+ if (!pTableNode)
+ return;
+
+ SwTable const& rTable = pTableNode->GetTable();
+ if (rTable.IsTableComplex())
+ {
+ OUString sName = rTable.GetTableStyleName();
+ AccessibilityCheckResult aResult;
+ aResult.m_aIssueText = sTableMergeSplit.replaceAll("%OBJECT_NAME%", sName);
+ m_aAccessibilityCheckResultCollection.push_back(aResult);
+ }
+ else
+ {
+ if (rTable.GetTabLines().size() > 1)
+ {
+ int i = 0;
+ size_t nFirstLineSize = 0;
+ bool bAllColumnsSameSize = true;
+
+ for (SwTableLine const* pTableLine : rTable.GetTabLines())
+ {
+ if (i == 0)
+ {
+ nFirstLineSize = pTableLine->GetTabBoxes().size();
+ }
+ else
+ {
+ size_t nLineSize = pTableLine->GetTabBoxes().size();
+ if (nFirstLineSize != nLineSize)
+ {
+ bAllColumnsSameSize = false;
+ }
+ }
+ i++;
+ }
+ if (!bAllColumnsSameSize)
+ {
+ OUString sName = rTable.GetTableStyleName();
+ AccessibilityCheckResult aResult;
+ aResult.m_aIssueText = sTableMergeSplit.replaceAll("%OBJECT_NAME%", sName);
+ m_aAccessibilityCheckResultCollection.push_back(aResult);
+ }
+ }
+ }
}
// Check NoTextNodes: Graphic, OLE
@@ -73,6 +122,12 @@ void AccessibilityCheck::check()
if (pNoTextNode)
checkNoTextNode(pNoTextNode);
}
+ if (pNode->GetNodeType() & SwNodeType::Table)
+ {
+ SwTableNode* pTableNode = pNode->GetTableNode();
+ if (pTableNode)
+ checkTableNode(pTableNode);
+ }
}
}
diff --git a/sw/source/core/inc/AccessibilityCheck.hxx b/sw/source/core/inc/AccessibilityCheck.hxx
index 8a55142c63dd..2540b3063be5 100644
--- a/sw/source/core/inc/AccessibilityCheck.hxx
+++ b/sw/source/core/inc/AccessibilityCheck.hxx
@@ -32,6 +32,7 @@ public:
}
void check();
+ void checkTableNode(SwTableNode* pTableNode);
void checkNoTextNode(SwNoTextNode* pNoTextNode);
void checkObject(SdrObject* pObject);
};
commit 20b54fa8c904e50223807d002eb78d3f8cb16176
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat Dec 7 13:08:16 2019 +0100
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Sat Dec 7 13:18:20 2019 +0100
extract accessibility checks to it's own function
Change-Id: I986b863d152b515927c62785bfed39354559a743
diff --git a/sw/source/core/access/AccessibilityCheck.cxx b/sw/source/core/access/AccessibilityCheck.cxx
index a464dbd3e263..f327105dc864 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -14,15 +14,53 @@
#include <IDocumentDrawModelAccess.hxx>
#include <drawdoc.hxx>
#include <svx/svdpage.hxx>
+#include <swtable.hxx>
+
+namespace
+{
+OUString sNoAlt("No alt text for graphic '%OBJECT_NAME%'");
+}
+
+// Check NoTextNodes: Graphic, OLE
+void AccessibilityCheck::checkNoTextNode(SwNoTextNode* pNoTextNode)
+{
+ if (!pNoTextNode)
+ return;
+
+ OUString sAlternative = pNoTextNode->GetTitle();
+ if (sAlternative.isEmpty())
+ {
+ OUString sName = pNoTextNode->GetFlyFormat()->GetName();
+ AccessibilityCheckResult aResult;
+ aResult.m_aIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName);
+ m_aAccessibilityCheckResultCollection.push_back(aResult);
+ }
+}
+
+// Check Shapes, TextBox
+void AccessibilityCheck::checkObject(SdrObject* pObject)
+{
+ if (!pObject)
+ return;
+
+ if (pObject->GetObjIdentifier() == OBJ_CUSTOMSHAPE || pObject->GetObjIdentifier() == OBJ_TEXT)
+ {
+ OUString sAlternative = pObject->GetTitle();
+ if (sAlternative.isEmpty())
+ {
+ OUString sName = pObject->GetName();
+ AccessibilityCheckResult aResult;
+ aResult.m_aIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName);
+ m_aAccessibilityCheckResultCollection.push_back(aResult);
+ }
+ }
+}
void AccessibilityCheck::check()
{
if (m_pDoc == nullptr)
return;
- OUString sNoAlt("No alt text for graphic '%OBJECT_NAME%'");
-
- // Check NoTextNodes: Graphic, OLE
auto const& pNodes = m_pDoc->GetNodes();
for (sal_uLong n = 0; n < pNodes.Count(); ++n)
{
@@ -33,21 +71,11 @@ void AccessibilityCheck::check()
{
SwNoTextNode* pNoTextNode = pNode->GetNoTextNode();
if (pNoTextNode)
- {
- OUString sAlternative = pNoTextNode->GetTitle();
- if (sAlternative.isEmpty())
- {
- OUString sName = pNoTextNode->GetFlyFormat()->GetName();
- AccessibilityCheckResult aResult;
- aResult.m_aIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName);
- m_aAccessibilityCheckResultCollection.push_back(aResult);
- }
- }
+ checkNoTextNode(pNoTextNode);
}
}
}
- // Check Shapes, TextBox
IDocumentDrawModelAccess& rDrawModelAccess = m_pDoc->getIDocumentDrawModelAccess();
auto* pModel = rDrawModelAccess.GetDrawModel();
for (sal_uInt16 nPage = 0; nPage < pModel->GetPageCount(); ++nPage)
@@ -56,18 +84,8 @@ void AccessibilityCheck::check()
for (size_t nObject = 0; nObject < pPage->GetObjCount(); ++nObject)
{
SdrObject* pObject = pPage->GetObj(nObject);
- if (pObject->GetObjIdentifier() == OBJ_CUSTOMSHAPE
- || pObject->GetObjIdentifier() == OBJ_TEXT)
- {
- OUString sAlternative = pObject->GetTitle();
- if (sAlternative.isEmpty())
- {
- OUString sName = pObject->GetName();
- AccessibilityCheckResult aResult;
- aResult.m_aIssueText = sNoAlt.replaceAll("%OBJECT_NAME%", sName);
- m_aAccessibilityCheckResultCollection.push_back(aResult);
- }
- }
+ if (pObject)
+ checkObject(pObject);
}
}
}
diff --git a/sw/source/core/inc/AccessibilityCheck.hxx b/sw/source/core/inc/AccessibilityCheck.hxx
index 2fcca0ce9460..8a55142c63dd 100644
--- a/sw/source/core/inc/AccessibilityCheck.hxx
+++ b/sw/source/core/inc/AccessibilityCheck.hxx
@@ -13,6 +13,7 @@
#include <svx/AccessibilityCheckDialog.hxx>
#include <doc.hxx>
+#include <node.hxx>
class AccessibilityCheck
{
@@ -31,6 +32,8 @@ public:
}
void check();
+ void checkNoTextNode(SwNoTextNode* pNoTextNode);
+ void checkObject(SdrObject* pObject);
};
#endif
More information about the Libreoffice-commits
mailing list