Inserting valid comments with just a key combination?

Hello,

I’m currently writing a script that processes HTML documents exported from LibreOffice. I’d like to define regions in theses documents in order to have them process with the script and I figured comments would be the perfect fit as a marker defining these regions since they don’t disturb the document’s structure.

Thus I’m looking for a way to insert valids comments with just a key combination : either by allowing empty comments to be created and using the default key combination or by creating a key combination capable of creating and pre-filling the newly created comment.

Does any of these solutions can be done?

Thanks for your help!

You will have to resort to user code.
See [Solved] Insert Annotation/Coment in Writer from macro (View topic) • Apache OpenOffice Community Forum

You may try the module below. It is supposed to collapse the ViewCursor to its .End, and there to insert the annotation. In contrast to the original from the above linked-in thread of forum.openoffice.org it is designed to also allow to insert the annotation inside a frame (including image captions) or in a table cell,

Assign the Sub to an OK-button or to a shortcut combination in the well known way, e.g.

REM  *****  BASIC  *****

Global Const iaTextConstant = "dummyT", iaAuthorConstant = "dummyA"

Sub insertAnnotation(Optional pText As String, Optional pAuthor As String)
REM You may add a way to also insert a DateTimeValue (com.sun.star.util.DateTime).
If IsMissing(pText)   Then pText   = iaTextConstant
If IsMissing(pAuthor) Then pAuthor = iaAuthorConstant
newAnnotation = ThisComponent.createInstance("com.sun.star.text.textfield.Annotation")
newAnnotation.Content = pText
newAnnotation.Author  = pAuthor
theVC  = ThisComponent.CurrentController.ViewCursor
theVC.GoDown(0, False)
theText = theVC.Text
theText.insertTextContent(theVC.Start, newAnnotation, False)
End Sub  

Note: If you use the code to create annotations without an author (pAuthor=""), you will not have a means to delete all the annotations created this way in one go.

Indeed that does the trick, thank you!