Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Word2007 Writer : Fixed first footnote appearing as separator #2635

Merged
merged 5 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changes/2.x/2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Documentation : Updated Comment element by [@laminga](https://github.com/laminga) in [#2650](https://github.com/PHPOffice/PHPWord/pull/2650)
- HTML Reader : Read width & height attributes in points fixing [#2589](https://github.com/PHPOffice/PHPWord/issues/2589) by [@Progi1984](https://github.com/Progi1984) in [#2654](https://github.com/PHPOffice/PHPWord/pull/2654)
- Template Processor : Fixed bad naming of variables fixing [#2586](https://github.com/PHPOffice/PHPWord/issues/2586) by [@Progi1984](https://github.com/Progi1984) in [#2655](https://github.com/PHPOffice/PHPWord/pull/2655)
- Word2007 Writer : Fix first footnote appearing as separator [#2634](https://github.com/PHPOffice/PHPWord/issues/2634) by [@jacksleight](https://github.com/jacksleight) in [#2635](https://github.com/PHPOffice/PHPWord/pull/2635)

### Miscellaneous

Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Writer/Word2007/Element/Footnote.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function write(): void
$xmlWriter->endElement(); // w:rStyle
$xmlWriter->endElement(); // w:rPr
$xmlWriter->startElement("w:{$this->referenceType}");
$xmlWriter->writeAttribute('w:id', $element->getRelationId());
$xmlWriter->writeAttribute('w:id', $element->getRelationId() + 1);
$xmlWriter->endElement(); // w:$referenceType
$xmlWriter->endElement(); // w:r

Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Writer/Word2007/Part/Footnotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function setElements($elements)
protected function writeNote(XMLWriter $xmlWriter, $element): void
{
$xmlWriter->startElement($this->elementNode);
$xmlWriter->writeAttribute('w:id', $element->getRelationId());
$xmlWriter->writeAttribute('w:id', $element->getRelationId() + 1);
$xmlWriter->startElement('w:p');

// Paragraph style
Expand Down
3 changes: 3 additions & 0 deletions tests/PhpWordTests/Writer/Word2007/Part/FootnotesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@ public function testWriteFootnotes(): void

self::assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:footnoteReference'));
self::assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:endnoteReference'));

self::assertFalse($doc->elementExists('/w:document/w:body/w:p/w:r/w:footnoteReference[@w:id="0"]'));
self::assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:footnoteReference[@w:id="1"]'));
}
}
Loading