Posts

Showing posts with the label beanshell

BeanShell scripting in LibreOffice

Image
Here is a BeanShell script to xploit functionalities from LibreOffice spreadsheeat: import com.sun.star.uno.UnoRuntime; import com.sun.star.sheet.XSpreadsheetView; import com.sun.star.text.XText; import com.sun.star.sheet.XCellRangeData; // // Get active spreadsheet // model = XSCRIPTCONTEXT.getDocument(); controller = model.getCurrentController(); view = UnoRuntime.queryInterface(XSpreadsheetView.class, controller); sheet = view.getActiveSheet(); // // Create a TEXT CELL // // Get cell by position cell = sheet.getCellByPosition(0, 0); // Access the cell text cellText = UnoRuntime.queryInterface(XText.class, cell); // Get the text cursor of the cell text textCursor = cellText.createTextCursor(); // Insert a string in the cell through the text cursor and overwrite the cell content // Using 'false' as third parameter adds the inserted string cellText.insertString(textCursor, "BeanShell macro example", true); // // Access and modify VALUE CELLS // // Get cell by position...