Office documents with LibreOffice
LibreOffice is installed as soffice (Writer, Calc, Impress, Draw). Two paths, cheapest first.
1. Headless, no window: conversions and batch work
soffice --headless --convert-to pdf --outdir ~/Documents report.docx # any format → PDF
soffice --headless --convert-to docx letter.odt # ODF ↔ Office formats
soffice --headless --convert-to csv:"Text - txt - csv (StarCalc)":44,34,76 data.xlsx
soffice --headless --convert-to xlsx table.csv
Tier: reversible (writes new files next to the source or in --outdir; never overwrites the source). Verify with ls -l and, for PDFs, pdfinfo if present.
To create a document from text without a GUI, write Markdown or HTML and convert it: soffice --headless --convert-to odt draft.html (headings, lists, tables and bold survive; images by absolute path).
2. In a window: editing, formatting, anything the user wants to see
- Open:
desktop_launchwithsofficeand the file (soffice --writer,--calc,--impressfor a new document of that kind). - LibreOffice exposes a complete accessibility tree.
desktop_elementslists the toolbar buttons, menu items, dialog fields and, for Writer, the paragraphs;desktop_readreturns the document text. Preferdesktop_element_clickanddesktop_element_set_textover pointer clicks and typing. - Menus: click the menu (
File,Format…) as an element, then calldesktop_elementsagain for the items that appeared. Dialogs (Save As, Export as PDF) are new windows:desktop_windowsshows them; their fields and buttons are elements. - Typing prose into Writer:
desktop_element_clickthe document area, thendesktop_typewith the window set. Cell values in Calc: click the cell, type, press Return. - Save: Ctrl+S with the window set (
desktop_key), or File → Save as elements. Saving in an Office format shows a "Keep current format" dialog: choose the format the user asked for.
Tier: reversible for edits to files under the snapshot root; Confirm when overwriting a file the user did not name.
Verify
Reopen or convert the result (soffice --headless --convert-to txt on a document gives its text) and read it back before reporting.