A TextDocument.newTextDocument() creates a bad hierarchy of master-pages and their style:page-layout-names.
<office:master-styles>
<style:master-page style:name="Standard" style:page-layout-name="pm1"/>
<style:master-page style:name="Endnote" style:page-layout-name="pm2"/>
<style:master-page style:name="Envelope" style:page-layout-name="pm3"/>
<style:master-page style:name="Footnote" style:page-layout-name="pm2"/>
<style:master-page style:display-name="First Page" style:name="First_20_Page" style:next-style-name="Standard" style:page-layout-name="pm1"/>
<style:master-page style:name="HTML" style:page-layout-name="pm4"/>
<style:master-page style:name="Index" style:page-layout-name="pm1"/>
<style:master-page style:display-name="Left Page" style:name="Left_20_Page" style:page-layout-name="pm5"/>
<style:master-page style:display-name="Right Page" style:name="Right_20_Page" style:page-layout-name="pm6"/>
</office:master-styles>
Instead of having a separate page-layout for each master-page-style some re-use the layout of others.
So if you modify e.g. the page-layout pm1 of the "Standard" style you accidentally change "Index" and "First Page", too.
A TextDocument.newTextDocument() creates a bad hierarchy of master-pages and their style:page-layout-names.
Instead of having a separate page-layout for each master-page-style some re-use the layout of others.
So if you modify e.g. the page-layout pm1 of the "Standard" style you accidentally change "Index" and "First Page", too.