Exemple #1
0
 /**
  * Magic method
  * Set property value
  *
  * @param string $name
  * @param mixed $value
  */
 protected function __set($name, $value)
 {
     if (isset($this->map[$name])) {
         $this->element->applyStyle($this->map[$name], $value);
         $this->{$name} = $value;
     }
 }
 /**
  * Constructor
  *
  * @param DOMNode $node
  * @param OpenDocument $document
  */
 public function __construct(DOMNode $node, OpenDocument $document)
 {
     parent::__construct($node, $document);
     $this->location = $node->getAttributeNS(OpenDocument::NS_XLINK, 'href');
     $this->type = $node->getAttributeNS(OpenDocument::NS_XLINK, 'type');
     $this->target = $node->getAttributeNS(OpenDocument::NS_OFFICE, 'target');
     $this->name = $node->getAttributeNS(OpenDocument::NS_OFFICE, 'name');
     $this->allowedElements = array('OpenDocument_Span');
 }
Exemple #3
0
 /**
  * Constructor
  *
  * @param DOMNode $node
  * @param OpenDocument $document
  */
 public function __construct(DOMNode $node, OpenDocument $document)
 {
     parent::__construct($node, $document);
     $this->allowedElements = array('OpenDocument_Span', 'OpenDocument_Hyperlink');
 }
Exemple #4
0
 /**
  * Apply style information to object
  * If object has no style information yet, then create new style node
  * If object style information is similar to other object's style info, then apply the same style name
  *     And if object old style information was not shared with other objects then delete old style info
  *     Else leave old style info
  * Else just add new style description
  *
  * @param string $style_name
  * @param string $name
  * @param mixed $value
  * @param OpenDocument_StyledElement $object
  * @return string $style_name
  */
 public function applyStyle($style_name, $name, $value, OpenDocument_StyledElement $object)
 {
     //check if other nodes have the same style name
     $nodes = $this->cursor->getElementsByTagName('*');
     $count = 0;
     foreach ($nodes as $node) {
         if ($node->hasAttributeNS(self::NS_TEXT, 'style-name') && $node->getAttributeNS(self::NS_TEXT, 'style-name') == $style_name) {
             $count++;
             if ($count > 1) {
                 break;
             }
         }
     }
     $generate = false;
     //get style node
     if ($count > 1) {
         $style = $this->getStyleNode($style_name)->cloneNode(true);
         $this->styles->appendChild($style);
         $generate = true;
         $style_name = uniqid('tmp');
         //$object->generateStyleName();
         $style->setAttributeNS(self::NS_STYLE, 'name', $style_name);
     } else {
         $style = $this->getStyleNode($style_name);
     }
     if (empty($style)) {
         if (empty($style_name)) {
             $generate = true;
             $style_name = uniqid('tmp');
         }
         $style = $this->contentDOM->createElementNS(self::NS_STYLE, 'style');
         $style->setAttributeNS(self::NS_STYLE, 'name', $style_name);
         $style->setAttributeNS(self::NS_STYLE, 'family', 'paragraph');
         $style->setAttributeNS(self::NS_STYLE, 'parent-style-name', 'Standard');
         $this->styles->appendChild($style);
     }
     $nodes = $style->getElementsByTagNameNS(self::NS_STYLE, 'text-properties');
     if ($nodes->length) {
         $text_properties = $nodes->item(0);
     } else {
         $text_properties = $this->contentDOM->createElementNS(self::NS_STYLE, 'text-properties');
         $style->appendChild($text_properties);
     }
     $text_properties->setAttribute($name, $value);
     //find alike style
     $nodes = $this->styles->getElementsByTagNameNS(self::NS_STYLE, 'style');
     foreach ($nodes as $node) {
         if (!$style->isSameNode($node) && $this->compareChildNodes($style, $node)) {
             $style->parentNode->removeChild($style);
             return $node->getAttributeNS(self::NS_STYLE, 'name');
         }
     }
     if ($generate) {
         $style_name = $object->generateStyleName();
         $style->setAttributeNS(self::NS_STYLE, 'name', $style_name);
     }
     return $style->getAttributeNS(self::NS_STYLE, 'name');
 }
 /**
  * Set style name suxxif max value
  *
  * @param integer $number
  */
 public static function setStyleNameMaxNumber($number)
 {
     self::$styleNameMaxNumber = $number;
 }
Exemple #6
0
 /**
  * Get element properties
  *
  * @param string  $name
  * @return mixed
  */
 protected function __get($name)
 {
     if ($value = parent::__get($name)) {
         return $value;
     }
     if (isset($this->{$name})) {
         return $this->{$name};
     }
 }