Draw: Sorting Pages by Name?

Is there any facility to sort pages in a [large] draw document by name?

I have a 98 page draw document with each page named.

Hi @whitemice, I can’t see an easy way. Moreover, Page Pane only show the name page as a tooltip. The Navigator (F5) could bring some help showing the pages order.

image description

One hands-in-the-code workaround is to open the content.xml component of the .odg file, search for all the <draw:page draw:name=" codes, insert a new paragraph before each one, sort these paragraphs, and save again.

Worked for me. The code in the sample is little because all three pages were empty.

Tested with LibreOffice 6.3.6.2 (x86); OS: Windows 6.1.


Add Answer is reserved for solutions.

Press edit below your question if you want to add more information; also can comment an answer.

Check the mark (Correct answer mark) to the left of the answer that solves your question.

An another workaround/solution with macros.

Here is a prepared sample file with embedded macros. The subroutine SortDrawPagesAscendingByName is assigned to the Page menu (the last custom item), it will be appeared and works in scope of the actual document only. (Copy the macros into a Module of the Standard library under the MyMacros if you want to use it with other drawing documents too. Note: Use a COPY of your important document when you try the macro!!!

Tha macro gets the names of the pages, then sort the name strings in ascending order. Then it re-sort the pages by a “copy-paste-delete-rename” method.

The custom names of the pages in my sample file: “C page”, “A page”, “D page”, “B page”. Enable the macro running. Open the file. Click on the menu item: Page - SortDrawPagesAscendingByName.

The code of these two routines are from AOO forum/WIKI. I just modified them. The links are in the first two REM lines of the code.

Sortpages.odg

SortDrawPages2.odg

I get a “BASIC runtime error. Variable not defined.” at line 31.
oController = oDoc.CurrentController

Warning!!!

I fixed some bugs in my code, but I can not control the Pages pane appropriately from the macro code. (I can not Select AND Focused(?) a Page on the Pages pane programatically.

Therefore you MUST deselect (manually) the selected graphical objects, and then MUST click on a slide of the Pages pane to Select it - before ou launc the macro. (Not matter which one will be selected.)
(The border of a properly selected Page icon is thicker than border of a page what was activated from the Navigator.)
Otherwise the document will be garbled: one page will be copied/pasted twice or more. Try it on a COPY of a document!!

You can download the modified sample file at my answer above.

I just reassigned the macro to the Pages Pane context menu. Right click on the selected Page on the Pages pane, and then click on the last item named “SortDrawPagesAscendingByName”.