Skip to content

Commit d87fa2a

Browse files
committed
MS Word report corrupted DOCX when there's more than 1 section and footnote applied not on the first section. OO is fine.
Bug source: [Content-Types].xml entry is different with document.xml.rels
1 parent 645d237 commit d87fa2a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

Classes/PHPWord/Section.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ public function createFooter()
422422
*/
423423
public function getFooter()
424424
{
425+
if (!($this->_footer instanceOf PHPWord_Section_Footer)) {
426+
$this->_footer = new PHPWord_Section_Footer($this->_sectionCount);
427+
}
425428
return $this->_footer;
426429
}
427430

Classes/PHPWord/Writer/Word2007.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,12 @@ public function save($pFilename = null)
139139
}
140140

141141
$_footer = $section->getFooter();
142-
if (!is_null($_footer)) {
143-
$_cFtrs++;
144-
$_footer->setRelationId(++$rID);
145-
$_footerCount = $_footer->getFooterCount();
146-
$_footerFile = 'footer' . $_footerCount . '.xml';
147-
$sectionElements[] = array('target' => $_footerFile, 'type' => 'footer', 'rID' => $rID);
148-
$objZip->addFromString('word/' . $_footerFile, $this->getWriterPart('footer')->writeFooter($_footer));
149-
}
142+
$_cFtrs++;
143+
$_footer->setRelationId(++$rID);
144+
$_footerCount = $_footer->getFooterCount();
145+
$_footerFile = 'footer' . $_footerCount . '.xml';
146+
$sectionElements[] = array('target' => $_footerFile, 'type' => 'footer', 'rID' => $rID);
147+
$objZip->addFromString('word/' . $_footerFile, $this->getWriterPart('footer')->writeFooter($_footer));
150148
}
151149

152150
if (PHPWord_Footnote::countFootnoteElements() > 0) {

0 commit comments

Comments
 (0)