document->paragraphClose(); $hid = self::headerToLink($params->document, $text, true); $TOCRef = $params->document->buildTOCReferenceID($text); $style = $params->document->getStyleName('heading'.$level); // Change page format if pending if ( $params->document->pageFormatChangeIsPending() ) { $pageStyle = $params->document->doPageFormatChange($style); if ( isset($pageStyle) ) { $style = $pageStyle; // Delete pagebreak, the format change will also introduce a pagebreak. $params->document->setPagebreakPending(false); } } // Insert pagebreak if pending if ( $params->document->pagebreakIsPending() ) { $style = $params->document->createPagebreakStyle ($style); $params->document->setPagebreakPending(false); } $params->content .= ''; // Insert page bookmark if requested and not done yet. $params->document->insertPendingPageBookmark(); $params->content .= ''; $params->content .= ''; $params->content .= $params->document->replaceXMLEntities($text); $params->content .= ''; $params->content .= ''; $params->content .= ''; // Do not add headings in frames $frame = $params->document->state->getCurrentFrame(); if (!isset($frame)) { $params->document->tocAddItemInternal($TOCRef, $hid, $text, $level); } } /** * Creates a linkid from a headline * * @param string $title The headline title * @param boolean $create Create a new unique ID? * @return string * * @author Andreas Gohr */ static protected function headerToLink(ODTDocument $doc, $title,$create=false) { // FIXME: not DokuWiki dependant function woud be nicer... $title = str_replace(':','',cleanID($title)); $title = ltrim($title,'0123456789._-'); if(empty($title)) { $title='section'; } if($create){ // Make sure tiles are unique $num = ''; while($doc->headerExists($title.$num)){ ($num) ? $num++ : $num = 1; } $title = $title.$num; $doc->addHeader($title); } return $title; } }