/** * Set Style value * * @param string $key * @param mixed $value * @return self */ public function setStyleValue($key, $value) { $key = String::removeUnderscorePrefix($key); if ($key == 'indent' || $key == 'hanging') { $value = $value * 720; } elseif ($key == 'spacing') { $value += 240; // because line height of 1 matches 240 twips } return parent::setStyleValue($key, $value); }
/** * Register fonts and colors * * @param \PhpOffice\PhpWord\Style\AbstractStyle $style */ private function registerFontItems($style) { $defaultFont = Settings::getDefaultFontName(); $defaultColor = Settings::DEFAULT_FONT_COLOR; if ($style instanceof Font) { $this->registerFontItem($this->fontTable, $style->getName(), $defaultFont); $this->registerFontItem($this->colorTable, $style->getColor(), $defaultColor); $this->registerFontItem($this->colorTable, $style->getFgColor(), $defaultColor); } }
/** * Set style values and put it to static style collection * * The $styleValues could be an array or object * * @param string $name * @param \PhpOffice\PhpWord\Style\AbstractStyle $style * @param array|\PhpOffice\PhpWord\Style\AbstractStyle $value * @return \PhpOffice\PhpWord\Style\AbstractStyle */ private static function setStyleValues($name, $style, $value = null) { if (!array_key_exists($name, self::$styles)) { if ($value !== null) { if (is_array($value)) { $style->setStyleByArray($value); } elseif ($value instanceof AbstractStyle) { if (get_class($style) == get_class($value)) { $style = $value; } } } $style->setStyleName($name); $style->setIndex(self::countStyles() + 1); // One based index self::$styles[$name] = $style; } return self::getStyle($name); }