/**
  * 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 ODTTextStyle();
     $attrs = 0;
     $open = XMLUtil::getElementOpenTag('style:style', $xmlCode);
     if (!empty($open)) {
         $attrs += $style->importODTStyleInternal(ODTStyleStyle::getStyleProperties(), $open);
     } else {
         $open = XMLUtil::getElementOpenTag('style:default-style', $xmlCode);
         if (!empty($open)) {
             $style->setDefault(true);
             $attrs += $style->importODTStyleInternal(ODTStyleStyle::getStyleProperties(), $open);
         }
     }
     $open = XMLUtil::getElementOpenTag('style:text-properties', $xmlCode);
     if (!empty($open)) {
         $attrs += $style->importODTStyleInternal(self::$text_fields, $open);
     }
     // If style has no meaningfull content then throw it away
     if ($attrs == 0) {
         return NULL;
     }
     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)
 {
     $style = new ODTParagraphStyle();
     $attrs = 0;
     $open = XMLUtil::getElementOpenTag('style:style', $xmlCode);
     if (!empty($open)) {
         $attrs += $style->importODTStyleInternal(ODTStyleStyle::getStyleProperties(), $open, $style->style_properties);
     } else {
         $open = XMLUtil::getElementOpenTag('style:default-style', $xmlCode);
         if (!empty($open)) {
             $style->setDefault(true);
             $attrs += $style->importODTStyleInternal(ODTStyleStyle::getStyleProperties(), $open, $style->style_properties);
         }
     }
     $open = XMLUtil::getElementOpenTag('style:paragraph-properties', $xmlCode);
     if (!empty($open)) {
         $attrs += $style->importODTStyleInternal(self::$paragraph_fields, $xmlCode);
     }
     $open = XMLUtil::getElementOpenTag('style:text-properties', $xmlCode);
     if (!empty($open)) {
         $attrs += $style->importODTStyleInternal(ODTTextStyle::getTextProperties(), $open, $style->text_properties);
     }
     // Get all tab-stops.
     $tabs = XMLUtil::getElementContent('style:tab-stops', $xmlCode);
     if ($tabs != NULL) {
         $max = strlen($tabs);
         $pos = 0;
         $index = 0;
         $tab = XMLUtil::getElement('style:tab-stop', $tabs, $end);
         $pos = $end;
         while ($tab != NULL) {
             $style->tab_stops[$index] = array();
             $attrs += $style->importODTStyleInternal(self::$tab_stop_fields, $tab, $style->tab_stops[$index]);
             $index++;
             $tab = XMLUtil::getElement('style:tab-stop', substr($tabs, $pos), $end);
             $pos += $end;
         }
     }
     // If style has no meaningfull content then throw it away
     if ($attrs == 0) {
         return NULL;
     }
     return $style;
 }