/** * Create new style by importing ODT style definition. * * @param $xmlCode Style definition in ODT XML format * @return ODTStyle New specific style */ public static function importODTStyle($xmlCode) { $style = new ODTMasterPageStyle(); // Get attributes for element 'style:master-page' $open = XMLUtil::getElementOpenTag('style:master-page', $xmlCode); if (!empty($open)) { $style->importODTStyleInternal(self::$master_fields, $open, $style->master_style); } // Get attributes for element 'style:header' $open = XMLUtil::getElementOpenTag('style:header', $xmlCode); if (!empty($open)) { $style->importODTStyleInternal(self::$header_footer_fields, $open, $style->style_header); $content_header = XMLUtil::getElementContent('style:header', $xmlCode); } // Get attributes for element 'style:footer' $open = XMLUtil::getElementOpenTag('style:footer', $xmlCode); if (!empty($open)) { $style->importODTStyleInternal(self::$header_footer_fields, $open, $style->style_footer); $content_footer = XMLUtil::getElementContent('style:footer', $xmlCode); } // Get attributes for element 'style:header-left' $open = XMLUtil::getElementOpenTag('style:header-left', $xmlCode); if (!empty($open)) { $style->importODTStyleInternal(self::$header_footer_fields, $open, $style->style_header_left); $content_header_left = XMLUtil::getElementContent('style:header-left', $xmlCode); } // Get attributes for element 'style:footer-left' $open = XMLUtil::getElementOpenTag('style:footer-left', $xmlCode); if (!empty($open)) { $style->importODTStyleInternal(self::$header_footer_fields, $open, $style->style_footer_left); $content_footer_left = XMLUtil::getElementContent('style:footer-left', $xmlCode); } return $style; }
/** * Create new style by importing ODT style definition. * * @param $xmlCode Style definition in ODT XML format * @return ODTStyle New specific style */ public static function importODTStyle($xmlCode) { $matches = array(); $pattern = '/<(\\w)+[^\\s\\/>]+/'; if (preg_match($pattern, $xmlCode, $matches) !== 1) { return NULL; } $element = trim($matches[0], '"<>'); $style = NULL; switch ($element) { case 'style:style': case 'style:default-style': $style = ODTStyleStyle::importODTStyle($xmlCode); break; case 'text:outline-style': $style = ODTTextOutlineStyle::importODTStyle($xmlCode); break; case 'text:list-style': $style = ODTTextListStyle::importODTStyle($xmlCode); break; case 'style:master-page': $style = ODTMasterPageStyle::importODTStyle($xmlCode); break; case 'style:page-layout': $style = ODTPageLayoutStyle::importODTStyle($xmlCode); break; default: break; } if ($style != NULL) { return $style; } // Unknown/not implemented style. // Create generic style which can not be changed. $unknown = ODTUnknownStyle::importODTStyle($xmlCode); $unknown->setElementName($element); return $unknown; }