macro to randomise table rows, lists or lines

In Writer, I am looking to create a macro which randomises the rows of a table (including formatting such as cell colour), the items of a bullet-point list or text separated by paragraph breaks or by line breaks. As I haven’t been able to find thorough documentation of LibreOffice Basic or the available objects, I am somewhat at a loss as to where to begin. I currently use Linux LibreOffice and would be thankful for pointers especially as to where I can find the object library. Concrete scripting suggestions are of course welcome as well.

If you attach an example, I can evaluate for develop macro. By the way, I recommend you used Python instead of Basic for this.

I have now broken into Python scripting for LibreOffice (see below) and added the following script to my Scripts/python directory. The script only deals with the text strings and background colours of cells. Other properties are ignored.

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import uno,random

def RandomiseTable(*args):
    desktop = XSCRIPTCONTEXT.getDesktop()
    model = desktop.getCurrentComponent()
    table = model.getCurrentController().getViewCursor().TextTable
    if not table:
    rowCount = table.getRows().getCount()
    columnCount = table.getColumns().getCount()
    rowdata = []
    for i in range(0,rowCount):
        row = []
        for j in range(0,columnCount):
            cell = table.getCellByPosition(j,i)
            string = cell.getString()
            backcolor = cell.BackColor

    for i in range(0,rowCount):
        for j in range(0,columnCount):
            cell = table.getCellByPosition(j,i)

A key resource for getting into Python macros has been the tutorial gives handy lines of code that allow you to have LibreOffice open and manipulate a document from the Python console in your terminal. This means I can delve into the LibreOffice objects via tab completion, which in my case has been priceless.

The given examples are for Windows and Mac OS: I have found that in Linux (Fedora), LibreOffice does not come with a bundled Python executable, but is installed against the Python on the machine. My regular Python 3.7.5 has access to the uno library and is able to communicate with LibreOffice via the socket method presented in the tutorial.