Bug 159966 - getAccessibleName no longer returns string for vertical scrollbar
Summary: getAccessibleName no longer returns string for vertical scrollbar
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.6.5.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisected, bisected, regression
Depends on:
Blocks: a11y, Accessibility
  Show dependency treegraph
 
Reported: 2024-02-29 16:02 UTC by Jordi
Modified: 2024-03-04 20:53 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jordi 2024-02-29 16:02:14 UTC
I've been using the following code to keep the visual cursor at a higher position in the viewable area. It relies on getAccessibleName to locate the vertical scrollbar. It now returns an empty string.

'
' From https://forum.openoffice.org//en/forum/viewtopic.php?f=20&p=495197
'
sub VCToCentreScreen
   
   Dim doc: doc = thiscomponent
   Dim vc: vc =doc.currentcontroller.viewcursor
   Dim y: y= vc.position.y 'position is in page/metric coordinates
   
   Dim svalue
   'svalue = (y+someothervalue )/ (10/(2.83465 * 2)) 'converts value to scrollbar uses half points
   svalue = (y+0)/ (10/(2.83465 * 2)) 'converts value to scrollbar uses half points
   
   
   Dim comp
   comp = doc.currentcontroller.frame.getcomponentwindow
   
   Dim compchild
   compchild=comp.getAccessibleContext.getAccessibleChild(0)
   
   Dim jc: jc=compchild.getAccessibleContext.getAccessibleChildcount
   
   Dim j
   for j = 0 to jc -1 'find the scrollbar
      with compchild.getAccessibleContext.getAccessibleChild(j)
	 Dim n: n = .getAccessibleContext.getAccessibleName
         if n = "Vertical scroll bar" then
         '.getblockincrement is usually the amount scrolled when screen down
         'subtract a bit for that /2 doesn't work on my machine /5 roughly does
            'svalue = svalue - someothervalue
            svalue = svalue - .getblockincrement/5
            .getAccessibleContext.setcurrentvalue clng(svalue)
            exit for
         end if
      end with
   next
end sub		


It works in v7.4.7.2 but NOT in v7.6.5.1 and the latest,

Version: 24.2.1.2 (X86_64) / LibreOffice Community
Build ID: db4def46b0453cc22e2d0305797cf981b68ef5ac
CPU threads: 4; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: en-AU (en_AU); UI: en-US
Calc: threaded
Comment 1 Xisco Faulí 2024-02-29 17:14:18 UTC Comment hidden (obsolete)
Comment 2 Xisco Faulí 2024-02-29 17:16:13 UTC
Reproduced in

Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: fd948fd27356e703fffc7e46df0f0e3a22f57967
CPU threads: 8; OS: Linux 6.1; UI render: default; VCL: gtk3
Locale: es-ES (es_ES.UTF-8); UI: en-US
Calc: threaded
Comment 3 Xisco Faulí 2024-02-29 17:22:59 UTC
Regression introduced by:

author	Caolán McNamara <caolanm@redhat.com>	2022-08-02 16:44:44 +0100
committer	Caolán McNamara <caolanm@redhat.com>	2022-08-03 20:23:49 +0200
commit 6c12f6dca251ba583297090def8aa9597a818c14 (patch)
tree 8437a70e0df8c00684d8f2bee45796f562b44d1e
parent adc15ce09e5f7fbcf5857238a9898f96da5acb9f (diff)
tdf#117388 use native scrollbar under gtk in writer

Bisected with: bibisect-linux64-7.5
Comment 4 Xisco Faulí 2024-02-29 17:24:25 UTC
Also reproducible with GEN
Comment 5 Caolán McNamara 2024-03-03 20:50:29 UTC
So this is a pretty unusual macro that depends on finding a particular accessibility component and internal widget at a particular place to manipulate it in ways I don't think anyone ever had in mind :-)

Anyhow, the original report is for windows, and there the searched for accessibility component is still in the a11y hierarchy (and the same XScrollBar widget is likewise still in the widget hierarchy) just not where it used to be.

I've tested this alternative macro on Windows and should give the same outcome on all versions as the original one did in older versions. I've just extracted "GetVertScrollbar" to recursively search for that "Vertical scroll bar" accessibility component so it can find it in its new home. It won't work for the gtk case, and there's no guarantee that this will always work, but it probably will for the foreseeable future.

I hope the below helps.

Function GetVertScrollbar(parent) as Variant
   Dim jc: jc=parent.getAccessibleContext.getAccessibleChildcount()
   
   Dim j
   for j = 0 to jc -1 'find the scrollbar
      Dim child: child = parent.getAccessibleContext.getAccessibleChild(j)
      Dim n: n = child.getAccessibleContext.getAccessibleName()
	  if n = "Vertical scroll bar" then
         GetVertScrollbar = child
         exit for
      end if
      Dim result: result = GetVertScrollbar(child)
      if result then
         GetVertScrollbar = result
         exit for
      end if
   next
end Function

sub VCToCentreScreen
   
   Dim doc: doc = thiscomponent
   Dim vc: vc = doc.currentcontroller.viewcursor
   Dim y: y= vc.position.y 'position is in page/metric coordinates
   
   Dim svalue
   'svalue = (y+someothervalue )/ (10/(2.83465 * 2)) 'converts value to scrollbar uses half points
   svalue = (y+0)/ (10/(2.83465 * 2)) 'converts value to scrollbar uses half points
   
   
   Dim comp
   comp = doc.currentcontroller.frame.getcomponentwindow()
   
   Dim compchild
   compchild=comp.getAccessibleContext.getAccessibleChild(0)
   
   Dim scrollBar
   scrollBar = GetVertScrollbar(compchild)
   
   if scrollBar then
      '.getblockincrement is usually the amount scrolled when screen down
      'subtract a bit for that /2 doesn't work on my machine /5 roughly does
      'svalue = svalue - someothervalue
      svalue = svalue - scrollBar.getBlockIncrement()/5
      scrollBar.getAccessibleContext.setCurrentValue clng(svalue)
   end if
end sub
Comment 6 Jordi 2024-03-04 20:53:44 UTC
Confirmed. It works on latest stable and older 7.4 I am using currently. 

Many thanks Caolán.