I know I can get a view cursor for the document with
viewCursor = ThisComponent.CurrentController.getViewCursor
And I can get a text cursor in a frame with
oFrame = ThisComponent.createInstance( "com.sun.star.text.TextFrame" )
frameCursor = oFrame.getText().createTextCursor()
But I don’t know how to set the view cursor to the range of the text cursor. If I try to do
viewCursor.gotoRange(frameCursor, true)
it gives an error with no message. I assume it is a conflict because the view cursor is outside the frame and I’m trying to set it to a range inside the frame. I think I need to create a different view cursor inside the frame somehow?
Ultimately I want to be able to search for all-caps words inside the frame and set them to small caps. I don’t think this can be done directly with LO Basic, so I figured I would just select the frame text and then run a macro which is a recording of a regex search followed by
dispatcher.executeDispatch(document, ".uno:SmallCaps", "", 0, Array())
But if there is a better way to do this whole thing, then that is great too.