sw/source/core/access/acccell.cxx | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
New commits: commit 43bf1cab57e7ac65ff376c46b2e3bd6b3cd91806 Author: Michael Weghorn <[email protected]> AuthorDate: Thu Mar 5 18:23:57 2026 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Mar 6 07:19:40 2026 +0100 tdf#171086 sw a11y: Report "{row,col}indextext" for Writer cells Similar to how commit c2165ec33c5549dcc494ad9197727e096678fc3c Author: Michael Weghorn <[email protected]> Date: Tue Nov 14 10:18:37 2023 +0100 tdf#158030 sc a11y: Report cell coords via {row,col}indextext obj attr had done for cells in Calc, also report the "rowindextext" and "colindextext" object attributes for cells in Writer tables. Determine them by extracting them from the cell name, which consists of the column name (containing only letters) and the row number (containing only digits). Sample steps to test: * start Writer with the qt6 VCL plugin * insert a table * start Accerciser * in Accerciser's treeview of the LO a11y hierarchy, select the first table cell (which has an a11y name of "A1") * check the object attributes in Accerciser's IPython console: In [2]: acc.getAttributes() Out[2]: ['colindextext:A', 'rowindextext:1'] Change-Id: Ib120c187ff4c0b913ba14c42660f8f27451b6abe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201064 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/sw/source/core/access/acccell.cxx b/sw/source/core/access/acccell.cxx index 940190a71898..1df76fbe7dcc 100644 --- a/sw/source/core/access/acccell.cxx +++ b/sw/source/core/access/acccell.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <cppuhelper/typeprovider.hxx> +#include <vcl/accessibility/AccessibleAttribute.hxx> #include <vcl/svapp.hxx> #include <cellfrm.hxx> #include <tabfrm.hxx> @@ -301,14 +302,33 @@ uno::Any SwAccessibleCell::getMinimumIncrement( ) std::unordered_map<OUString, OUString> SwAccessibleCell::implGetExtendedAttributes() { + std::unordered_map<OUString, OUString> aAttributes; + + // extract row/col index name attributes from cell name + const OUString sQualifiedName = GetCellFrame().GetTabBox().GetName(); + if (!sQualifiedName.isEmpty()) + { + // SwTableBox::GetName returns path including hierarchy, only last part is of interest + std::u16string_view sCellName = sQualifiedName; + const int nLastCellNameIndex = sQualifiedName.lastIndexOf(u'.'); + if (nLastCellNameIndex >= 0) + { + assert(sQualifiedName.getLength() > nLastCellNameIndex); + sCellName = sQualifiedName.subView(nLastCellNameIndex + 1); + } + // cell name consists of column name (using letters) and row name (using digits) + const size_t nRowNameStartIndex = sCellName.find_first_of(u"0123456789"); + assert(nRowNameStartIndex >= 0 && "Cell name doesn't contain a row number"); + aAttributes.emplace(AccessibleAttribute::ColIndexText, sCellName.substr(0, nRowNameStartIndex)); + aAttributes.emplace(AccessibleAttribute::RowIndexText, sCellName.substr(nRowNameStartIndex)); + } + SwFrameFormat *pFrameFormat = GetTableBoxFormat(); assert(pFrameFormat); - const SwTableBoxFormula& tbl_formula = pFrameFormat->GetTableBoxFormula(); - OUString sFormula = tbl_formula.GetFormula(); if (sFormula.isEmpty()) - return {}; + return aAttributes; // ensure the use of readable cell references (like "<A1>") instead of internal pointers if (const SwTabFrame* pTabFrame = m_pAccTable ? m_pAccTable->GetTabFrame() : nullptr) @@ -326,7 +346,9 @@ std::unordered_map<OUString, OUString> SwAccessibleCell::implGetExtendedAttribut .replaceAll(u"=", u"\=") .replaceAll(u",", u"\,") .replaceAll(u":", u"\:"); - return { { u"Formula"_ustr, sFormula } }; + aAttributes.emplace(u"Formula"_ustr, sFormula); + + return aAttributes; } sal_Int32 SAL_CALL SwAccessibleCell::getBackground()
