Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Ivan Lanin 2014-03-13 20:23:55 +07:00
commit fd95a1c1ec

View File

@ -30,8 +30,8 @@ use PhpOffice\PhpWord\Exceptions\InvalidStyleException;
/** /**
* Class PHPWord_Style_Font * Class PHPWord_Style_Font
*/ */
class PHPWord_Style_Font { class PHPWord_Style_Font
{
const UNDERLINE_NONE = 'none'; const UNDERLINE_NONE = 'none';
const UNDERLINE_DASH = 'dash'; const UNDERLINE_DASH = 'dash';
const UNDERLINE_DASHHEAVY = 'dashHeavy'; const UNDERLINE_DASHHEAVY = 'dashHeavy';
@ -170,7 +170,8 @@ class PHPWord_Style_Font {
* @param string $type Type of font * @param string $type Type of font
* @param array $paragraphStyle Paragraph styles definition * @param array $paragraphStyle Paragraph styles definition
*/ */
public function __construct($type = 'text', $paragraphStyle = null) { public function __construct($type = 'text', $paragraphStyle = null)
{
$this->_type = $type; $this->_type = $type;
if ($paragraphStyle instanceof PHPWord_Style_Paragraph) { if ($paragraphStyle instanceof PHPWord_Style_Paragraph) {
@ -187,7 +188,8 @@ class PHPWord_Style_Font {
* @param array $style * @param array $style
* @return $this * @return $this
*/ */
public function setArrayStyle(array $style = array()) { public function setArrayStyle(array $style = array())
{
foreach ($style as $key => $value) { foreach ($style as $key => $value) {
if ($key === 'line-height') { if ($key === 'line-height') {
$this->setLineHeight($value); $this->setLineHeight($value);
@ -207,7 +209,8 @@ class PHPWord_Style_Font {
* @param string $key * @param string $key
* @param mixed $value * @param mixed $value
*/ */
public function setStyleValue($key, $value) { public function setStyleValue($key, $value)
{
$method = 'set' . substr($key, 1); $method = 'set' . substr($key, 1);
if (method_exists($this, $method)) { if (method_exists($this, $method)) {
$this->$method($value); $this->$method($value);
@ -219,7 +222,8 @@ class PHPWord_Style_Font {
* *
* @return bool * @return bool
*/ */
public function getName() { public function getName()
{
return $this->_name; return $this->_name;
} }
@ -229,21 +233,23 @@ class PHPWord_Style_Font {
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setName($pValue = PHPWord::DEFAULT_FONT_NAME) { public function setName($pValue = PHPWord::DEFAULT_FONT_NAME)
{
if (is_null($pValue) || $pValue == '') { if (is_null($pValue) || $pValue == '') {
$pValue = PHPWord::DEFAULT_FONT_NAME; $pValue = PHPWord::DEFAULT_FONT_NAME;
} }
$this->_name = $pValue; $this->_name = $pValue;
return $this; return $this;
} }
/** /**
* Get font size * Get font size
* *
* @return int|float * @return int|float
*/ */
public function getSize() { public function getSize()
{
return $this->_size; return $this->_size;
} }
@ -253,7 +259,8 @@ class PHPWord_Style_Font {
* @param int|float $pValue * @param int|float $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE) { public function setSize($pValue = PHPWord::DEFAULT_FONT_SIZE)
{
if (!is_numeric($pValue)) { if (!is_numeric($pValue)) {
$pValue = PHPWord::DEFAULT_FONT_SIZE; $pValue = PHPWord::DEFAULT_FONT_SIZE;
} }
@ -266,7 +273,8 @@ class PHPWord_Style_Font {
* *
* @return bool * @return bool
*/ */
public function getBold() { public function getBold()
{
return $this->_bold; return $this->_bold;
} }
@ -276,7 +284,8 @@ class PHPWord_Style_Font {
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setBold($pValue = false) { public function setBold($pValue = false)
{
if (!is_bool($pValue)) { if (!is_bool($pValue)) {
$pValue = false; $pValue = false;
} }
@ -289,7 +298,8 @@ class PHPWord_Style_Font {
* *
* @return bool * @return bool
*/ */
public function getItalic() { public function getItalic()
{
return $this->_italic; return $this->_italic;
} }
@ -299,7 +309,8 @@ class PHPWord_Style_Font {
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setItalic($pValue = false) { public function setItalic($pValue = false)
{
if (!is_bool($pValue)) { if (!is_bool($pValue)) {
$pValue = false; $pValue = false;
} }
@ -312,7 +323,8 @@ class PHPWord_Style_Font {
* *
* @return bool * @return bool
*/ */
public function getSuperScript() { public function getSuperScript()
{
return $this->_superScript; return $this->_superScript;
} }
@ -322,7 +334,8 @@ class PHPWord_Style_Font {
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setSuperScript($pValue = false) { public function setSuperScript($pValue = false)
{
if (!is_bool($pValue)) { if (!is_bool($pValue)) {
$pValue = false; $pValue = false;
} }
@ -336,7 +349,8 @@ class PHPWord_Style_Font {
* *
* @return bool * @return bool
*/ */
public function getSubScript() { public function getSubScript()
{
return $this->_subScript; return $this->_subScript;
} }
@ -346,7 +360,8 @@ class PHPWord_Style_Font {
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setSubScript($pValue = false) { public function setSubScript($pValue = false)
{
if (!is_bool($pValue)) { if (!is_bool($pValue)) {
$pValue = false; $pValue = false;
} }
@ -360,7 +375,8 @@ class PHPWord_Style_Font {
* *
* @return string * @return string
*/ */
public function getUnderline() { public function getUnderline()
{
return $this->_underline; return $this->_underline;
} }
@ -370,7 +386,8 @@ class PHPWord_Style_Font {
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE) { public function setUnderline($pValue = PHPWord_Style_Font::UNDERLINE_NONE)
{
if ($pValue == '') { if ($pValue == '') {
$pValue = PHPWord_Style_Font::UNDERLINE_NONE; $pValue = PHPWord_Style_Font::UNDERLINE_NONE;
} }
@ -383,7 +400,8 @@ class PHPWord_Style_Font {
* *
* @return bool * @return bool
*/ */
public function getStrikethrough() { public function getStrikethrough()
{
return $this->_strikethrough; return $this->_strikethrough;
} }
@ -393,7 +411,8 @@ class PHPWord_Style_Font {
* @param bool $pValue * @param bool $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setStrikethrough($pValue = false) { public function setStrikethrough($pValue = false)
{
if (!is_bool($pValue)) { if (!is_bool($pValue)) {
$pValue = false; $pValue = false;
} }
@ -406,7 +425,8 @@ class PHPWord_Style_Font {
* *
* @return string * @return string
*/ */
public function getColor() { public function getColor()
{
return $this->_color; return $this->_color;
} }
@ -416,7 +436,8 @@ class PHPWord_Style_Font {
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR) { public function setColor($pValue = PHPWord::DEFAULT_FONT_COLOR)
{
if (is_null($pValue) || $pValue == '') { if (is_null($pValue) || $pValue == '') {
$pValue = PHPWord::DEFAULT_FONT_COLOR; $pValue = PHPWord::DEFAULT_FONT_COLOR;
} }
@ -429,7 +450,8 @@ class PHPWord_Style_Font {
* *
* @return bool * @return bool
*/ */
public function getFgColor() { public function getFgColor()
{
return $this->_fgColor; return $this->_fgColor;
} }
@ -439,7 +461,8 @@ class PHPWord_Style_Font {
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setFgColor($pValue = null) { public function setFgColor($pValue = null)
{
$this->_fgColor = $pValue; $this->_fgColor = $pValue;
return $this; return $this;
} }
@ -449,7 +472,8 @@ class PHPWord_Style_Font {
* *
* @return string * @return string
*/ */
public function getStyleType() { public function getStyleType()
{
return $this->_type; return $this->_type;
} }
@ -458,7 +482,8 @@ class PHPWord_Style_Font {
* *
* @return PHPWord_Style_Paragraph * @return PHPWord_Style_Paragraph
*/ */
public function getParagraphStyle() { public function getParagraphStyle()
{
return $this->_paragraphStyle; return $this->_paragraphStyle;
} }
@ -469,7 +494,8 @@ class PHPWord_Style_Font {
* @return $this * @return $this
* @throws InvalidStyleException * @throws InvalidStyleException
*/ */
public function setLineHeight($lineHeight) { public function setLineHeight($lineHeight)
{
if (is_string($lineHeight)) { if (is_string($lineHeight)) {
$lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight)); $lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight));
} }
@ -486,24 +512,29 @@ class PHPWord_Style_Font {
/** /**
* @return int|float * @return int|float
*/ */
public function getLineHeight() { public function getLineHeight()
{
return $this->lineHeight; return $this->lineHeight;
} }
/** /**
* Get Font Content Type * Get Font Content Type
* *
* @return bool * @return bool
*/ */
public function getHint() { public function getHint()
{
return $this->_hint; return $this->_hint;
} }
/** /**
* Set Font Content Type * Set Font Content Type
* *
* @param string $pValue * @param string $pValue
* @return PHPWord_Style_Font * @return PHPWord_Style_Font
*/ */
public function setHint($pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE) { public function setHint($pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE)
{
if (is_null($pValue) || $pValue == '') { if (is_null($pValue) || $pValue == '') {
$pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE; $pValue = PHPWord::DEFAULT_FONT_CONTENT_TYPE;
} }