Skip to content

Commit dbf0a3e

Browse files
Word2007 Writer : Fixed first footnote appearing as separator (#2635)
* Fix first footnote appearing as separator * Add test * Update changelog * Fixed changelog --------- Co-authored-by: Progi1984 <[email protected]>
1 parent 1691301 commit dbf0a3e

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

docs/changes/2.x/2.0.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- Documentation : Updated Comment element by [@laminga](https://github.com/laminga) in [#2650](https://github.com/PHPOffice/PHPWord/pull/2650)
2626
- 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)
2727
- 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)
28+
- 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)
2829

2930
### Miscellaneous
3031

src/PhpWord/Writer/Word2007/Element/Footnote.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function write(): void
5151
$xmlWriter->endElement(); // w:rStyle
5252
$xmlWriter->endElement(); // w:rPr
5353
$xmlWriter->startElement("w:{$this->referenceType}");
54-
$xmlWriter->writeAttribute('w:id', $element->getRelationId());
54+
$xmlWriter->writeAttribute('w:id', $element->getRelationId() + 1);
5555
$xmlWriter->endElement(); // w:$referenceType
5656
$xmlWriter->endElement(); // w:r
5757

src/PhpWord/Writer/Word2007/Part/Footnotes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function setElements($elements)
141141
protected function writeNote(XMLWriter $xmlWriter, $element): void
142142
{
143143
$xmlWriter->startElement($this->elementNode);
144-
$xmlWriter->writeAttribute('w:id', $element->getRelationId());
144+
$xmlWriter->writeAttribute('w:id', $element->getRelationId() + 1);
145145
$xmlWriter->startElement('w:p');
146146

147147
// Paragraph style

tests/PhpWordTests/Writer/Word2007/Part/FootnotesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,8 @@ public function testWriteFootnotes(): void
4949

5050
self::assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:footnoteReference'));
5151
self::assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:endnoteReference'));
52+
53+
self::assertFalse($doc->elementExists('/w:document/w:body/w:p/w:r/w:footnoteReference[@w:id="0"]'));
54+
self::assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:footnoteReference[@w:id="1"]'));
5255
}
5356
}

0 commit comments

Comments
 (0)