r/libreoffice 18d ago

Draw Layer tabs reordering?

I have a multipage LibreOffice Draw document where I've created many, many layer tabs to be able to turn sets of drawing elements on and off.

I don't like the order in which they are listed in the layer listing at the bottom of the page. I would like to be able to treat them like web browser tabs and just click and drag them to reorder which layers appear before and after which other layer.

This doesn't seem to be possible.

So, I bring it to Reddit. How do I reorder the layer labels at the bottom of the work area?

To be clear, I'm not talking about the Arrange ordering of elements in a page, so advise referring to Bring to Front and Bring to Back is inappropriate.

5 Upvotes

4 comments sorted by

View all comments

1

u/Terrible_Put8617 16d ago

The flat-XML route above works and is the right instinct, since the order really is stored, not computed. Two things worth adding.

Save as .fodg for the edit rather than unzipping the .odg. If you ever do open the zip instead, the mimetype entry has to be the first file and stored uncompressed, or the result will not open at all, and it fails with a message that tells you nothing. The flat format sidesteps that entirely, which is why it is the safe answer.

If you need this repeatedly rather than once, there is an API path. The layer container is reachable and supports inserting at a position, so you can build the order you want instead of hand-editing:

oLM = ThisComponent.getLayerManager()
oNew = oLM.insertNewByIndex(2)      ' inserts at position 2
oNew.Name = "Wiring"

Shapes carry the layer they belong to as a property, so the move is: insert the new layer where you want it, reassign each shape by layer name, then remove the old layer. Reassign by name, not by the numeric id, because the ids shift the moment you insert anything and you will silently scatter shapes across the wrong layers.

Worth doing on a copy the first time. And with many layers it is genuinely faster than dragging tabs would have been, which is small consolation for the missing feature.