While working with the ViewCursor, it appears that if you run the macro from inside the macro editor by pressing F5, the view of the document displayed does not change. For example the following code when run from the editor will update the display to show the match found,
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 = "and"
r = dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())
where as running the following code in the editor using a view cursor to do the same thing does not,
Dim vDescriptor, vFound
oVCurs = ThisComponent.CurrentController.getViewCursor()
vDescriptor = ThisComponent.createSearchDescriptor()
With vDescriptor
.SearchString = "then"
.SearchWords = true
.SearchCaseSensitive = False
End With
vFound = ThisComponent.findNext(oVCurs, vDescriptor)
oVCurs.gotoRange(vFound,false)
but when I run the view cursor code above using a keyboard shortcut with the document in focus then the display is updated to show the view cursor selection.
To me this appears like a bug. I’ve wasted a fair amount of time trying to figure out why my view cursor code didn’t behave as explained…
I am running Version: 5.0.5.2 on Windows 7x64