简体   繁体   English

使用 PyUNO 将 cursor 放置在给定 position 的文档中

[英]Placing cursor in the document for a given position using PyUNO

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 .我在 Windows 中安装了带有自定义 python 3.8.6 的 Libreoffice7。我想使用 PyUNO 将视图 cursor 导航到基于 awt 中的 X、Y 坐标(例如 com.sun.star.awt)的特定 position作家文件 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.先感谢您。

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 .使用 UNO API 很难或不可能使用点和像素进行精确定位。数字似乎无法预测,例如https://ask.libreoffice.org/t/what-is-the-base-for-cursor-x-基本位置/71827

Instead, move the cursor to a character or paragraph or object, for example with goRight() .相反,将 cursor 移动到字符或段落或 object,例如使用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要进一步研究点定位,请查看有关在 Calc 中定位对话框的讨论: https://ask.libreoffice.org/t/dynamically-position-a-dialog/67289/39

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM