@sokol92 yes, thank you, that worked. The code by @torrua from here worked.
I added
def find_grouped_sheets(doc, sheet_groups):
'''
Finds sheets with outline groups.
Parameters:
doc (obj):XSCRIPTCONTEXT.getDocument() from LO.
sheet_groups (dict):Empty dict for sheets with groups.
Returns:
sheet_groups (dict):dict with sheets with groups. key = sheet id; val = boolean True/False.
'''
uno_cmd = "Ungroup"
# omit first sheet
for i in range(1,len(doc.Sheets)):
sheet = doc.Sheets.getByIndex(i)
view = doc.getCurrentController()
cursor = sheet.createCursor()
cursor.gotoEndOfUsedArea(False)
cursor.gotoStartOfUsedArea(True)
view.select(cursor)
event = get_feature_state(doc, uno_cmd)
sheet_groups[i] = event.IsEnabled
return sheet_groups
def deselect(doc):
view = doc.getCurrentController()
# source: https://wiki.documentfoundation.org/Macros/Python_Guide/Useful_functions#Create_instances
desktop = create_instance("com.sun.star.frame.Desktop", True)
document = desktop.getCurrentComponent()
emptyRanges = document.createInstance("com.sun.star.sheet.SheetCellRanges")
view.select(emptyRanges)
deselect()
function is called elsewhere in the script to undo the selection of the find_grouped_sheets()
function.
An alternative I was thinking about was to parse the content.xml
file from within an odf file and search for table-column-group
tag as child from table
tag.