/** * Get anchor */ public function testAnchor() { $oTitle = new Title('text'); $iVal = rand(1, 1000); $oTitle->setAnchor($iVal); $this->assertEquals($oTitle->getAnchor(), $iVal); }
/** * Add a Title Element * * @param string $text * @param int $depth * @return Title * @todo Enable title element in other containers */ public function addTitle($text, $depth = 1) { $this->checkValidity('title'); $styles = Style::getStyles(); if (array_key_exists('Heading_' . $depth, $styles)) { $style = 'Heading' . $depth; } else { $style = null; } $text = String::toUTF8($text); $title = new Title($text, $depth, $style); $title->setDocPart($this->getDocPart(), $this->getDocPartId()); $data = Titles::addTitle($text, $depth); $anchor = $data[0]; $bookmarkId = $data[1]; $title->setAnchor($anchor); $title->setBookmarkId($bookmarkId); $this->addElement($title); return $title; }