Ask Your Question
0

Inserting valid comments with just a key combination?

asked 2018-02-08 10:12:57 +0200

FlyingCactus gravatar image

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!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-02-08 10:40:45 +0200

Lupp gravatar image

updated 2018-02-08 11:51:37 +0200

You will have to resort to user code.
See https://forum.openoffice.org/en/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.

edit flag offensive delete link more

Comments

Indeed that does the trick, thank you!

FlyingCactus gravatar imageFlyingCactus ( 2018-02-08 11:34:42 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-02-08 10:12:57 +0200

Seen: 58 times

Last updated: Feb 08 '18