Navigating the insides of LibreOffice

LibreOffice has Indent and Unindent functionality built-in. But what if you want to manage hanging indent the way it’s done in Microsoft Word, with Ctrl-T and Ctrl-Shift-T keystrokes? Here’s a pair of macro functions that do the work (they will need to be assigned to keystrokes using the Customize functionality in LibreOffice):

Sub HangingMore()
  oCursor = ThisComponent.CurrentController.getViewCursor()
  oCursor.ParaLeftMargin = oCursor.ParaLeftMargin + 1270
  oCursor.ParaFirstLineIndent = oCursor.ParaFirstLineIndent - 1270
End Sub

Sub HangingLess()
  oCursor = ThisComponent.CurrentController.getViewCursor()
  oCursor.ParaLeftMargin = oCursor.ParaLeftMargin - 1270
  oCursor.ParaFirstLineIndent = oCursor.ParaFirstLineIndent + 1270
End Sub

The macros are basically mirror images of each other. Each begins by capturing the properties of wherever the text cursor is into the oCursor variable. Those properties are then manipulated directly. The names of those properties should be self-explaining; the only trick is, margins and  indents are stored in 100ths of a millimeter. In other words, the number 1270 corresponds to 1.27 cm, or half-inch. Metrically-minded users may want to change this to the nice round 1000…

Leave a Reply

Your email address will not be published. Required fields are marked *