If openoffice template specifies pagerepeat, use it

This commit is contained in:
Nathan Gray 2012-05-07 21:09:31 +00:00
parent 679073abcf
commit 94cd19a50c

View File

@ -659,15 +659,23 @@ abstract class bo_merge
} }
if ($mimetype == 'application/vnd.oasis.opendocument.text' && count($ids) > 1) if ($mimetype == 'application/vnd.oasis.opendocument.text' && count($ids) > 1)
{ {
//for odt files we have to split the content and add a style for page break to the style area if(strpos($content, '$$pagerepeat') === false)
list($contentstart,$contentrepeat,$contentend) = preg_split('/office:body>/',$content,-1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat {
$contentstart = substr($contentstart,0,strlen($contentstart)-1); //remove "<" //for odt files we have to split the content and add a style for page break to the style area
$contentrepeat = substr($contentrepeat,0,strlen($contentrepeat)-2); //remove "</"; list($contentstart,$contentrepeat,$contentend) = preg_split('/office:body>/',$content,-1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat
// need to add page-break style to the style list $contentstart = substr($contentstart,0,strlen($contentstart)-1); //remove "<"
list($stylestart,$stylerepeat,$styleend) = preg_split('/<\/office:automatic-styles>/',$content,-1, PREG_SPLIT_NO_EMPTY); //get differt parts of document style sheets $contentrepeat = substr($contentrepeat,0,strlen($contentrepeat)-2); //remove "</";
$contentstart = $stylestart.'<style:style style:name="P200" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:break-before="page"/></style:style></office:automatic-styles>'; // need to add page-break style to the style list
$contentstart .= '<office:body>'; list($stylestart,$stylerepeat,$styleend) = preg_split('/<\/office:automatic-styles>/',$content,-1, PREG_SPLIT_NO_EMPTY); //get differt parts of document style sheets
$contentend = '</office:body></office:document-content>'; $contentstart = $stylestart.'<style:style style:name="P200" style:family="paragraph" style:parent-style-name="Standard"><style:paragraph-properties fo:break-before="page"/></style:style></office:automatic-styles>';
$contentstart .= '<office:body>';
$contentend = '</office:body></office:document-content>';
}
else
{
// Template specifies where to repeat
list($contentstart,$contentrepeat,$contentend) = preg_split('/\$\$pagerepeat\$\$/',$content,-1, PREG_SPLIT_NO_EMPTY); //get different parts of document, seperated by pagerepeat
}
} }
if ($mimetype == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' && count($ids) > 1) if ($mimetype == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' && count($ids) > 1)
{ {
@ -1380,7 +1388,6 @@ abstract class bo_merge
//error_log(__METHOD__."() !this->merge() err=$err"); //error_log(__METHOD__."() !this->merge() err=$err");
return $err; return $err;
} }
// Apply HTML formatting to target document, if possible // Apply HTML formatting to target document, if possible
// check if we can use the XSL extension, to not give a fatal error and rendering whole merge-print non-functional // check if we can use the XSL extension, to not give a fatal error and rendering whole merge-print non-functional
if (class_exists(XSLTProcessor) && class_exists(DOMDocument) && $this->parse_html_styles) if (class_exists(XSLTProcessor) && class_exists(DOMDocument) && $this->parse_html_styles)