/** * Add a Title Element * * @param string $text * @param int $depth * @return PHPWord_Section_Title */ public function addTitle($text, $depth = 1) { $text = @iconv("UTF-8", "UTF-8//IGNORE", $text); $styles = Document_Word_Writer_Style::getStyles(); if (array_key_exists('Heading_' . $depth, $styles)) { $style = 'Heading' . $depth; } else { $style = null; } require_once __DIR__ . '/Section/Title.php'; $title = new Document_Word_Writer_Section_Title($text, $depth, $style); $data = Document_Word_Writer_TOC::addTitle($text, $depth); $anchor = $data[0]; $bookmarkId = $data[1]; $title->setAnchor($anchor); $title->setBookmarkId($bookmarkId); $this->_elementCollection[] = $title; return $title; }