Skip to content

Commit

Permalink
Merge pull request #4266 from oleibman/odspage
Browse files Browse the repository at this point in the history
Ods Writer Master Page Name
  • Loading branch information
oleibman authored Dec 15, 2024
2 parents b03e10b + ed158f2 commit 08e2260
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
### Fixed

- More context options may be needed for http(s) image. [Php issue 17121](https://github.com/php/php-src/issues/17121) [PR #4276](https://github.com/PHPOffice/PhpSpreadsheet/pull/4276)
- Several fixed to ODS Writer. [Issue #4261](https://github.com/PHPOffice/PhpSpreadsheet/issues/4261) [PR #4263](https://github.com/PHPOffice/PhpSpreadsheet/pull/4263) [PR #4264](https://github.com/PHPOffice/PhpSpreadsheet/pull/4264) [PR #4266](https://github.com/PHPOffice/PhpSpreadsheet/pull/4266)

## 2024-12-08 - 3.6.0

Expand Down
1 change: 1 addition & 0 deletions src/PhpSpreadsheet/Writer/Ods/Cell/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ public function writeTableStyle(Worksheet $worksheet, int $sheetId): void
'style:name',
sprintf('%s%d', self::TABLE_STYLE_PREFIX, $sheetId)
);
$this->writer->writeAttribute('style:master-page-name', 'Default');

$this->writer->startElement('style:table-properties');

Expand Down
13 changes: 11 additions & 2 deletions src/PhpSpreadsheet/Writer/Ods/Styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,17 @@ public function write(): string

$objWriter->writeElement('office:font-face-decls');
$objWriter->writeElement('office:styles');
$objWriter->writeElement('office:automatic-styles');
$objWriter->writeElement('office:master-styles');
$objWriter->startElement('office:automatic-styles');
$objWriter->startElement('style:page-layout');
$objWriter->writeAttribute('style:name', 'Mpm1');
$objWriter->endElement(); // style:page-layout
$objWriter->endElement(); // office:automatic-styles
$objWriter->startElement('office:master-styles');
$objWriter->startElement('style:master-page');
$objWriter->writeAttribute('style:name', 'Default');
$objWriter->writeAttribute('style:page-layout-name', 'Mpm1');
$objWriter->endElement(); //style:master-page
$objWriter->endElement(); //office:master-styles
$objWriter->endElement();

return $objWriter->getData();
Expand Down
2 changes: 1 addition & 1 deletion tests/data/Writer/Ods/content-arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<office:scripts/>
<office:font-face-decls/>
<office:automatic-styles>
<style:style style:family="table" style:name="ta1">
<style:style style:master-page-name="Default" style:family="table" style:name="ta1">
<style:table-properties table:display="true"/>
</style:style>
<style:style style:name="ce0" style:family="table-cell" style:parent-style-name="Default">
Expand Down
2 changes: 1 addition & 1 deletion tests/data/Writer/Ods/content-empty.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<office:scripts />
<office:font-face-decls />
<office:automatic-styles>
<style:style style:family="table" style:name="ta1">
<style:style style:family="table" style:master-page-name="Default" style:name="ta1">
<style:table-properties table:display="true" />
</style:style>
<style:style style:name="ce0" style:family="table-cell" style:parent-style-name="Default">
Expand Down
4 changes: 2 additions & 2 deletions tests/data/Writer/Ods/content-hidden-worksheet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<office:scripts />
<office:font-face-decls />
<office:automatic-styles>
<style:style style:family="table" style:name="ta1">
<style:style style:family="table" style:master-page-name="Default" style:name="ta1">
<style:table-properties table:display="true" />
</style:style>
<style:style style:family="table" style:name="ta2">
<style:style style:family="table" style:master-page-name="Default" style:name="ta2">
<style:table-properties table:display="false"/>
</style:style>
<style:style style:name="ce0" style:family="table-cell" style:parent-style-name="Default">
Expand Down
4 changes: 2 additions & 2 deletions tests/data/Writer/Ods/content-with-data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<office:scripts/>
<office:font-face-decls/>
<office:automatic-styles>
<style:style style:family="table" style:name="ta1">
<style:style style:family="table" style:master-page-name="Default" style:name="ta1">
<style:table-properties table:display="true" />
</style:style>
<style:style style:family="table" style:name="ta2">
<style:style style:family="table" style:master-page-name="Default" style:name="ta2">
<style:table-properties table:display="true" />
</style:style>
<style:style style:family="table-cell" style:name="ce0" style:parent-style-name="Default">
Expand Down

0 comments on commit 08e2260

Please sign in to comment.