Alternative Cycle Case
Tags: Extensions Writer
last edited: 2023-01-24
Alternative Cycle Case command with more intuitive behavior
Adds a LibreOffice Basic macro which re-implements Writer’s Cycle Case command (Shift+F3) with the following differences:
- Selection is always respected. The built-in command may modify the entire sentence or paragraph regardless of the current selection.
- Without selection, always acts on the current word. Without an existing selection, the built-in command may act either on the word containing the cursor or the entire sentence.
- Redundant steps are skipped. The built-in command ignores the current state of the text and may apply, for example, ALL CAPS to a selection is already in all caps.
- Works on the word you just typed. The built-in command requires the user to select the word or at least move the cursor back inside it.
This behavior should also be more familiar to users coming from Microsoft Word. Installing the extension adds a Format ► Text ► Cycle Case (Alt.) entry in the main menu but the most convenient way to use the command is to assign a shortcut to the AltCycleCase.Main.CycleCase macro, either replacing the default Shift+F3, or a different one, such as Alt+F3.
WARNING: The macro supports noncontiguous selections using a hack because I could not get the UNO API to remember and restore a multi-range selection. It marks the selected text with a rarely used attribute (flashing characters), then searches for it to restore the selection after changing the text. If you use this attribute for other purposes, you may prefer to assign a shortcut to the AltCycleCase.Main.CycleCaseNoMultiselection macro which disables this hack and supports only contiguous selections.
Release: Initial release –
Initial release of the extension. Noncontiguous selection is supported using a hack with character attributes. Main functionality should already work well but the extension is tested only on LO 7.1 under Windows 10. Feedback is welcome.