2

In Writer, I would like to search for some text and when found position the view to the top of the view/window.

Using the following code,

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "SearchItem.SearchString"
args1(0).Value = ":"

dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())

the view changes and it shows the selection but it is not in any particular place. I want it to be at the top of the window/view.

I've also found elsewhere the use of ThisComponent.currentController.getViewData() and restoreViewData(). So I experimented and determined how to change the data returned in order to get a vertical scroll but nothing happens. For example...

vd = ThisComponent.currentController.getViewData()
vdParts = Split(vd, ";")
vdParts(6) = CLng(vdParts(6)) + 1000
vd = join(vdParts, ";")
ThisComponent.currentController.restoreViewData(vd)

Any suggestions?

PS: I am running version 5.0.5.2 on Windows 7 x64

4

1 回答 1

1

电子表格具有可操作的视图窗格,但 Writer 中似乎没有类似的界面。

相反,使用视图光标向下一页或两页,然后移回搜索结果的位置。

此外,请勿使用调度程序进行搜索。请改用 API,如Andrew Pitonyak 的宏文档的第 7.14 节。

于 2016-04-04T19:04:40.503 回答