I've been looking at how an add_page method would need to be implemented. I wrote a proof of concept and pushed it to my fork, but I believe there's still some decisions to be taken before a PR is opened, and also I don't want to conflict with work related to master pages.
Till now the process seems to be:
[x] Create visio\pages\pageX.xml file
[x] Add entry to visio\pages\_rels\pages.xml.rels
[x] Add entry to visio\pages\pages.xml
[x] Add entry to [Content_Types].xml
[x] Add entry to docProps\app.xml
[x] Create visio\pages\_rels\page.xml.rels -> I think this is to refer to masters files for shapes in the page -> only relevant if page has shapes
I think the major decision to be taken is how to go about adding the entry to pages.xml.
Currently I'm hard-coding the PageSheet element with default values. Another route is to have a template VSDX file in the package and copy+paste the element from that template (this is similar to how python-docx creates new files).
There are a couple of minor decisions as well:
[x] naming the new page: currently, I take the current number of pages +1 as a base line, ie Page-X. But if there is another page with that name, add a suffix as needed: Page-X-i.
[x] Reorder the elements in [Content_Types].xml such that elements related to pages (Override elements) stay together.
Further enhancements:
[x] Let user define the page name
[x] Let user decide the order of the pages (insert page at a specified location)
I've been looking at how an add_page method would need to be implemented. I wrote a proof of concept and pushed it to my fork, but I believe there's still some decisions to be taken before a PR is opened, and also I don't want to conflict with work related to master pages.
Till now the process seems to be:
Create visio\pages\_rels\page.xml.rels -> I think this is to refer to masters files for shapes in the page-> only relevant if page has shapesI think the major decision to be taken is how to go about adding the entry to pages.xml. Currently I'm hard-coding the PageSheet element with default values. Another route is to have a template VSDX file in the package and copy+paste the element from that template (this is similar to how python-docx creates new files).
There are a couple of minor decisions as well:
Further enhancements: