예제 #1
0
 /**
  * This function creates a paragraph style using. It uses the createParagraphStyle function
  * from the stylefactory helper class but takes care of the extra handling required for the
  * font-size attribute.
  *
  * The function returns the name of the new style or NULL if all relevant properties are empty.
  *
  * @author LarsDW223
  *
  * @param array $properties
  * @param array $disabled_props
  * @return string|null
  */
 protected function _createParagraphStyle($properties, $disabled_props = NULL)
 {
     $save = $disabled_props['font-size'];
     $odt_fo_size = '';
     if (empty($disabled_props['font-size'])) {
         $odt_fo_size = $properties['font-size'];
     }
     $parent = '';
     $length = strlen($odt_fo_size);
     if ($length > 0 && $odt_fo_size[$length - 1] == '%') {
         // A font-size in percent is only supported in common style definitions, not in automatic
         // styles. Create a common style and set it as parent for this automatic style.
         $name = 'Size' . trim($odt_fo_size, '%') . 'pc';
         $this->styles[$name] = $this->_odtBuildSizeStyle($name, $odt_fo_size);
         $parent = $name;
     }
     $length = strlen($properties['text-indent']);
     if ($length > 0 && $properties['text-indent'][$length - 1] == '%') {
         // Percentage value needs to be converted to absolute value.
         // ODT standard says that percentage value should work if used in a common style.
         // This did not work with LibreOffice 4.4.3.2.
         $value = trim($properties['text-indent'], '%');
         $properties['text-indent'] = $this->_getAbsWidthMindMargins($value) . 'cm';
     }
     $style_name = $this->factory->createParagraphStyle($style, $properties, $disabled_props, $parent);
     if ($style_name == NULL) {
         return NULL;
     }
     $this->autostyles[$style_name] = $style;
     $disabled_props['font-size'] = $save;
     return $style_name;
 }