2022-07-26

LibreOffice Calc Sheet to Markdown Slide

This note shows how to create a slide with LibreOffice Calc which can be easily included in a remark-markdown presentation. As shown in the video below, an area (white background) inside the working sheet has been defined for drawing the entire slide.

Eight column by twenty row wide, each column with a width equal to 2.60 cm (= 20.8 cm), and each row with height equal to 0.60 cm (= 12.0 cm), approximates well the slide aspect ratio.

As an example, this Pareto chart has been recreated inside the printable area. The below LibreOffice macro will copy everything inside this area and save it to the clipboard.

    sub Main
    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 ----------------------------------------------------------------------
    rem Define the printable area 
    dim args1(0) as new com.sun.star.beans.PropertyValue
    args1(0).Name = "ToPoint"
    args1(0).Value = "$A$1:$H$20"

    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

    rem ----------------------------------------------------------------------
    dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
    msgbox("Copy Saved to Clipboard ")

    end sub
    

Remarkpy uses the bitmap image stored in the clipboard and saves it to the local server static directory. At the same time, it will also save to the clipboard the local image URL in markdown format. This can be pasted directly inside the presentation text file.