summaryrefslogtreecommitdiff
path: root/sw/source/core/crsr/crsrsh.cxx
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2023-03-17 12:37:15 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2023-03-20 21:21:30 +0000
commit4a93739e619fd4f4ec369932e923554d71297900 (patch)
tree963ac7eca47c65b15b3203d5d4ddf4addfe55e8c /sw/source/core/crsr/crsrsh.cxx
parent92b732ce29f734d91fb6c9350b9a8b6df7f9293e (diff)
tdf#136760 sw a11y: Provide page-relative cursor pos via doc attr
This introduce 2 new extended accessible attributes "cursor-position-in-page-horizontal" and "cursor-position-in-page-vertical" to expose the page-relative position of the cursor in Writer to assistive technology. This is similar to how the current page number is already exposed (attribute "page-number"). Together with a corresponding pull request for the NVDA screen reader [1], this allows NVDA to announce the position similar to how it is done for Microsoft Word (where the information is not retrieved via the accessibility APIs but the MS Office COM API, s. discussion in the corresponding NVDA issue [2] for more details). (Side note: Currently there is no a11y object for a Writer page in the a11y tree, but "normal" paragraphs are direct children of the document object.) For performance reasons, introduce a new method `SwCursorShell::GetCursorPagePos` to get the position instead of passing the result from `SwCursorShell::GetCursorDocPos` to `SwFEShell::GetRelativePagePosition` to avoid iterating over the doc pages. [1] https://github.com/nvaccess/nvda/pull/14727 [2] https://github.com/nvaccess/nvda/issues/11696 Change-Id: I6fd56c5c7d051840bab836ce5fe525fdc061b376 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149051 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'sw/source/core/crsr/crsrsh.cxx')
-rw-r--r--sw/source/core/crsr/crsrsh.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 298801ace223..9d94c133f028 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1168,6 +1168,20 @@ bool SwCursorShell::IsCursorInFootnote() const
return aStartNodeType == SwStartNodeType::SwFootnoteStartNode;
}
+Point SwCursorShell::GetCursorPagePos() const
+{
+ Point aRet(-1, -1);
+ if (SwFrame *pFrame = GetCurrFrame())
+ {
+ if (SwPageFrame* pCurrentPage = pFrame->FindPageFrame())
+ {
+ const Point& rDocPos = GetCursorDocPos();
+ aRet = rDocPos - pCurrentPage->getFrameArea().TopLeft();
+ }
+ }
+ return aRet;
+}
+
bool SwCursorShell::IsInFrontOfLabel() const
{
return m_pCurrentCursor->IsInFrontOfLabel();