I've tried to solve this problem with the ".uno:ScrollToNext", but I don't know exactly how much this directive moves the scrollbar, and I don't seem to have control over the step size of the move. I just want to control the scrollbar to move down one line, similar to clicking the down arrow at the bottom of the scrollbar.
Move one line down with scrollbar, JAVA UNO API
Move one line down with scrollbar, JAVA UNO API
Libre Office 7.6 on Windows 11.
Re: How to control ScrollBar move one line down with JAVA UNO API
You can access the scrollbar through the accessiblecontext.
This in Basic for a writer document in OO does that scrollbar action on my system.
This in Basic for a writer document in OO does that scrollbar action on my system.
Code: Select all
dim ff,aa
ff = thiscomponent.currentcontroller.frame
aa =ff.componentwindow.windows(0).accessiblecontext.getaccessiblechild(0).accessiblecontext
with aa
for i = 0 to .AccessibleChildCount - 1
if .getaccessiblechild(i).accessiblecontext.AccessibleName = "Vertical scroll bar" then
.getaccessiblechild(i).accessiblecontext.doAccessibleAction 1
exit for
end if
next
end with
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: How to control ScrollBar move one line down with JAVA UNO API
This doesn't seem to work properly in my computer. I'm using version 7.6.3 of Libre Office. I made a simple modification to the Basic code and found that when the tmp variable is not equal to "Vertical scroll bar", the tmp variable is empty except for the first loop when it is equal to "Header".
I executed the above code using the Run Macro menu provided by Libre Office.
Code: Select all
REM ***** BASIC *****
Sub Main
dim ff,aa
ff = thiscomponent.currentcontroller.frame
aa =ff.componentwindow.windows(0).accessiblecontext.getaccessiblechild(0).accessiblecontext
with aa
for i = 0 to .AccessibleChildCount - 1
tmp = .getaccessiblechild(i).accessiblecontext.AccessibleName
if .getaccessiblechild(i).accessiblecontext.AccessibleName = "Vertical scroll bar" then
.getaccessiblechild(i).accessiblecontext.doAccessibleAction 1
exit for
end if
next
end with
End Sub
Libre Office 7.6 on Windows 11.
Re: How to control ScrollBar move one line down with JAVA UNO API
Yeah, I've used constants to get the scrollbar which work for me in OO.
This works for me on LO. If it doesn't for you then you can either explore with MRI, or write a more generic sub to find the scroll bar. If the accessible name isn't the same in your language, use the accessiblerole to find the scrollbar.
This works for me on LO. If it doesn't for you then you can either explore with MRI, or write a more generic sub to find the scroll bar. If the accessible name isn't the same in your language, use the accessiblerole to find the scrollbar.
Code: Select all
cc= thiscomponent.currentcontroller
comp =cc.frame.getcomponentwindow
compchild=comp.getAccessibleContext.getAccessibleChild(0)
for j = 0 to compchild.getAccessibleContext.getAccessibleChildcount -1
with compchild.getAccessibleContext.getAccessibleChild(j)
if .getAccessibleContext.getAccessibleName = "Vertical scroll bar" then
.getAccessibleContext.doaccessibleaction(1)
exit for
end if
end with
next
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: How to control ScrollBar move one line down with JAVA UNO API
Unfortunately it still doesn't work in my LO.
My AccessibleChildcount is equal to 3.And the first one is 'xxx' document's title,the second one is 'null',the last is 'Horizontal rulers'.
My AccessibleChildcount is equal to 3.And the first one is 'xxx' document's title,the second one is 'null',the last is 'Horizontal rulers'.
Libre Office 7.6 on Windows 11.
Re: How to control ScrollBar move one line down with JAVA UNO API
Same suggestions as before. I'm not on your computer so I can't investigate it for you. The window is there and that's how to do what you want - you just have to find the window. Again I suggest a more generic sub - I started with a constant of 0 - make that a loop for all children and keep going down all children till you find it.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)