If you want to develop a system of “macros” for the purpose:
You can store ranges in different ways (e.g.):
Array of SheetCellRange
- or of the range addresses
One SheetCellRanges
object [myRgs = ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges")
]
Specialized structures you define yourself in Basic or… (Type declarations).
The way you choose may depend on the specific features you want to implement.
I don’t yet know a way to ask a spreadsheet for the current level of grouping. Tell me if you find out.
(And I personally next to never used outline groups… not to speak of AutoOutline.)
The (main) related API reference is LibreOffice: XSheetOutline Interface Reference
I would assume the levels are always defined implicitly by nesting.
A simplified example:
Sub createNestedOutlineGroups()
REM For a test I had multi-selected three single ranges in one sheet:
REM "Sheet1.A7:A17,Sheet1.B9:B16,Sheet1.C10:C12"
doc = ThisComponent
sel = doc.CurrentSelection
For Each rg in sel
ra = rg.RangeAddress
sheet = doc.Sheets(ra.Sheet)
sheet.group(ra, com.sun.star.table.TableOrientation.ROWS)
Next rg
REM The Sub created three (additional) nested outline levels as expected.
End Sub
REM In a different test the rows of second range weren't a subset of
REM the rows of the first range. There wasn't casted an error,
REM but the second group was not created.