Placing cursor in the document for a given position using PyUNO

290 Views Asked by At

I am having Libreoffice7 installed with custom python 3.8.6 in Windows. I want to use PyUNO to navigate the view cursor to a specific position based on the X, Y coordinates(of instance com.sun.star.awt.Point) in a writer document. Is there a way by which this can be achieved? I am unable to find any resource or documentation that helps. Please let me know if any other info or clarifications needed. Thank you in advance.

1

There are 1 best solutions below

0
On

Precise positioning using points and pixels is difficult or impossible with the UNO API. The numbers seem to be unpredictable, for example https://ask.libreoffice.org/t/what-is-the-base-for-cursor-x-position-in-basic/71827.

Instead, move the cursor to a character or paragraph or object, for example with goRight().

To investigate point positioning further, take a look at this discussion on positioning a dialog in Calc: https://ask.libreoffice.org/t/dynamically-position-a-dialog/67289/39