Jump to content

Insert a comment with custom presets

From The Document Foundation Wiki



Description

Insert a string in the cursor position in a current document.

Python code

def insert_in_cursor_position():
    data = 'Hello World with Python'

    # ~ Current document
    doc = XSCRIPTCONTEXT.getDocument()

    # ~ Current selection always return a ranges, and get to end
    text = doc.CurrentSelection[0].End
    
    # ~ Write data
    text.String = data
    
    return

References to API

Line Link
5 com.sun.star.text.TextDocument
8, 11 com.sun.star.text.XTextRange