Skip to content

Instantly share code, notes, and snippets.

@dajare
Created August 25, 2013 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dajare/6336327 to your computer and use it in GitHub Desktop.
Save dajare/6336327 to your computer and use it in GitHub Desktop.
LibreOffice macro to start/stop small caps character formatting
sub SmallCapsStart
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "CaseMap"
args1(0).Value = 4
dispatcher.executeDispatch(document, ".uno:CaseMap", "", 0, args1())
end sub
sub SmallCapsStop
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "CaseMap"
args1(0).Value = 0
dispatcher.executeDispatch(document, ".uno:CaseMap", "", 0, args1())
end sub
@mrheaume
Copy link

mrheaume commented Feb 14, 2017

Hi! I found this macro on an OpenOffice.org forum, which toggles between Small Caps and no formating of the characters. Found it useful, thought I'd share it here:

sub ToggleSmallCaps
rem Read the case state of the current selection.
rem If it's SmallCaps (see http://api.openoffice.org/docs/common/ref/com/sun/star/style/CaseMap.html)
rem then set CaseMap=0, which is not necessarily lower case
rem but whatever the underlying text was without any caps effects
If ThisComponent.CurrentSelection.getByIndex(0).CharCaseMap = 4 then
ThisComponent.CurrentSelection.getByIndex(0).CharCaseMap = 0

Else
rem If it was not SmallCaps, then set it
ThisComponent.CurrentSelection.getByIndex(0).CharCaseMap = 4
End if

End sub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment