$value) { if (substr($key, 0, 1) == '_') { $key = substr($key, 1); } self::$TOCStyle->setStyleValue($key, $value); } } if (!is_null($styleFont)) { if (is_array($styleFont)) { self::$fontStyle = new Font(); foreach ($styleFont as $key => $value) { if (substr($key, 0, 1) == '_') { $key = substr($key, 1); } self::$fontStyle->setStyleValue($key, $value); } } else { self::$fontStyle = $styleFont; } } $this->minDepth = $minDepth; $this->maxDepth = $maxDepth; } /** * Add a Title * * @param string $text * @param int $depth * @return array */ public static function addTitle($text, $depth = 0) { $anchor = '_Toc' . ++self::$anchor; $bookmarkId = self::$bookmarkId++; $title = array(); $title['text'] = $text; $title['depth'] = $depth; $title['anchor'] = $anchor; $title['bookmarkId'] = $bookmarkId; self::$titles[] = $title; return array($anchor, $bookmarkId); } /** * Get all titles * * @return array */ public function getTitles() { $titles = self::$titles; foreach ($titles as $i => $title) { if ($this->minDepth > $title['depth']) { unset($titles[$i]); } if (($this->maxDepth != 0) && ($this->maxDepth < $title['depth'])) { unset($titles[$i]); } } $titles = array_merge(array(), $titles); return $titles; } /** * Reset titles */ public static function resetTitles() { self::$titles = array(); } /** * Get TOC Style * * @return TOCStyle */ public static function getStyleTOC() { return self::$TOCStyle; } /** * Get Font Style * * @return Font */ public static function getStyleFont() { return self::$fontStyle; } /** * Set max depth * * @param int $value */ public function setMaxDepth($value) { $this->maxDepth = $value; } /** * Get Max Depth * * @return int Max depth of titles */ public function getMaxDepth() { return $this->maxDepth; } /** * Set min depth * * @param int $value */ public function setMinDepth($value) { $this->minDepth = $value; } /** * Get Min Depth * * @return int Min depth of titles */ public function getMinDepth() { return $this->minDepth; } }