Ejemplo n.º 1
0
 /**
  * Test setting style values with normal value
  */
 public function testSetStyleValueNormal()
 {
     $object = new Paragraph();
     $attributes = array('spaceAfter' => 240, 'spaceBefore' => 240, 'indent' => 1, 'hanging' => 1, 'spacing' => 120, 'basedOn' => 'Normal', 'next' => 'Normal', 'numStyle' => 'numStyle', 'numLevel' => 1, 'widowControl' => false, 'keepNext' => true, 'keepLines' => true, 'pageBreakBefore' => true);
     foreach ($attributes as $key => $value) {
         $get = "get{$key}";
         $object->setStyleValue("{$key}", $value);
         if ('indent' == $key || 'hanging' == $key) {
             $value = $value * 720;
         } elseif ('spacing' == $key) {
             $value += 240;
         }
         $this->assertEquals($value, $object->{$get}());
     }
 }
Ejemplo n.º 2
0
 /**
  * Set style values and put it to static style collection
  *
  * @param string $styleName
  * @param Paragraph|Font|Table|Numbering $styleObject
  * @param array|null $styleValues
  */
 private static function setStyleValues($styleName, $styleObject, $styleValues = null)
 {
     if (!array_key_exists($styleName, self::$styles)) {
         if (!is_null($styleValues) && is_array($styleValues)) {
             foreach ($styleValues as $key => $value) {
                 $styleObject->setStyleValue($key, $value);
             }
         }
         $styleObject->setStyleName($styleName);
         $styleObject->setIndex(self::countStyles() + 1);
         // One based index
         self::$styles[$styleName] = $styleObject;
     }
 }