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
This commit is contained in:
Ivan Lanin 2014-03-14 14:53:45 +07:00
parent 645d237582
commit d87fa2aa8b
2 changed files with 9 additions and 8 deletions

View File

@ -422,6 +422,9 @@ class PHPWord_Section
*/
public function getFooter()
{
if (!($this->_footer instanceOf PHPWord_Section_Footer)) {
$this->_footer = new PHPWord_Section_Footer($this->_sectionCount);
}
return $this->_footer;
}

View File

@ -139,14 +139,12 @@ class PHPWord_Writer_Word2007 implements PHPWord_Writer_IWriter
}
$_footer = $section->getFooter();
if (!is_null($_footer)) {
$_cFtrs++;
$_footer->setRelationId(++$rID);
$_footerCount = $_footer->getFooterCount();
$_footerFile = 'footer' . $_footerCount . '.xml';
$sectionElements[] = array('target' => $_footerFile, 'type' => 'footer', 'rID' => $rID);
$objZip->addFromString('word/' . $_footerFile, $this->getWriterPart('footer')->writeFooter($_footer));
}
$_cFtrs++;
$_footer->setRelationId(++$rID);
$_footerCount = $_footer->getFooterCount();
$_footerFile = 'footer' . $_footerCount . '.xml';
$sectionElements[] = array('target' => $_footerFile, 'type' => 'footer', 'rID' => $rID);
$objZip->addFromString('word/' . $_footerFile, $this->getWriterPart('footer')->writeFooter($_footer));
}
if (PHPWord_Footnote::countFootnoteElements() > 0) {