Python macro to insert text at GUI cursor position [closed]
I'm trying to get a simple python macro working in Writer. It's little more than a glorified "Hello World", all it needs to do is insert some text in the current document, at the current GUI cursor position.
I'm finding it absurdly complicated to perform this trivial task. I've tried several approaches, all seem to hit some problem. I can insert the text at the beginning or end of the document, but haven't found a way to insert text at the cursor position.
I've looked at the documentation, but I've not figured this out. I've seen something called TextCursor, which I've used, but this is not what I want. I've seen something called TextViewCursor, and this might be what I want, but I've not been able to get the code working, because apparently TextViewCursors are entirely different things from TextCursors and I can't figure out how to create one.
So, anyone got pointers for a python "Hello World" macro that inserts the string at the current cursor position?
I have the same issue, but I am trying to write a javascript macro. The sparse examples I can find say invoke getViewCursor() on the CurrentController object, but both controllers from the document {oDoc = XSCRIPTCONTEXT.getDocument();} and the text document { xTextDoc = UnoRuntime.queryInterface(XTextDocument,oDoc) } do not recognize a getViewCursor() method.