1
This commit is contained in:
@@ -30,7 +30,7 @@ abstract class AbstractStyle
|
||||
/**
|
||||
* Style name.
|
||||
*
|
||||
* @var string
|
||||
* @var ?string
|
||||
*/
|
||||
protected $styleName;
|
||||
|
||||
@@ -62,7 +62,7 @@ abstract class AbstractStyle
|
||||
/**
|
||||
* Get style name.
|
||||
*
|
||||
* @return string
|
||||
* @return ?string
|
||||
*/
|
||||
public function getStyleName()
|
||||
{
|
||||
@@ -161,7 +161,7 @@ abstract class AbstractStyle
|
||||
* Check if the set method is exists. Throws an exception?
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @param array|int|string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -202,10 +202,10 @@ abstract class AbstractStyle
|
||||
/**
|
||||
* Set default for null and empty value.
|
||||
*
|
||||
* @param string $value (was: mixed)
|
||||
* @param string $default (was: mixed)
|
||||
* @param ?string $value
|
||||
* @param string $default
|
||||
*
|
||||
* @return string (was: mixed)
|
||||
* @return string
|
||||
*/
|
||||
protected function setNonEmptyVal($value, $default)
|
||||
{
|
||||
@@ -253,7 +253,7 @@ abstract class AbstractStyle
|
||||
/**
|
||||
* Set integer value: Convert string that contains only numeric into integer.
|
||||
*
|
||||
* @param null|int $value
|
||||
* @param null|float|int|string $value
|
||||
* @param null|int $default
|
||||
*
|
||||
* @return null|int
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace PhpOffice\PhpWord\Style;
|
||||
*/
|
||||
class Border extends AbstractStyle
|
||||
{
|
||||
const DEFAULT_MARGIN = 1440; // In twips.
|
||||
|
||||
/**
|
||||
* Border Top Size.
|
||||
*
|
||||
@@ -106,6 +108,34 @@ class Border extends AbstractStyle
|
||||
*/
|
||||
protected $borderBottomStyle;
|
||||
|
||||
/**
|
||||
* Top margin spacing.
|
||||
*
|
||||
* @var float|int
|
||||
*/
|
||||
protected $marginTop = self::DEFAULT_MARGIN;
|
||||
|
||||
/**
|
||||
* Left margin spacing.
|
||||
*
|
||||
* @var float|int
|
||||
*/
|
||||
protected $marginLeft = self::DEFAULT_MARGIN;
|
||||
|
||||
/**
|
||||
* Right margin spacing.
|
||||
*
|
||||
* @var float|int
|
||||
*/
|
||||
protected $marginRight = self::DEFAULT_MARGIN;
|
||||
|
||||
/**
|
||||
* Bottom margin spacing.
|
||||
*
|
||||
* @var float|int
|
||||
*/
|
||||
protected $marginBottom = self::DEFAULT_MARGIN;
|
||||
|
||||
/**
|
||||
* Get border size.
|
||||
*
|
||||
@@ -501,4 +531,100 @@ class Border extends AbstractStyle
|
||||
|
||||
return $borders !== array_filter($borders, 'is_null');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Margin Top.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getMarginTop()
|
||||
{
|
||||
return $this->marginTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Margin Top.
|
||||
*
|
||||
* @param float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMarginTop($value = null)
|
||||
{
|
||||
$this->marginTop = $this->setNumericVal($value, self::DEFAULT_MARGIN);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Margin Left.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getMarginLeft()
|
||||
{
|
||||
return $this->marginLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Margin Left.
|
||||
*
|
||||
* @param float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMarginLeft($value = null)
|
||||
{
|
||||
$this->marginLeft = $this->setNumericVal($value, self::DEFAULT_MARGIN);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Margin Right.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getMarginRight()
|
||||
{
|
||||
return $this->marginRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Margin Right.
|
||||
*
|
||||
* @param float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMarginRight($value = null)
|
||||
{
|
||||
$this->marginRight = $this->setNumericVal($value, self::DEFAULT_MARGIN);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Margin Bottom.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getMarginBottom()
|
||||
{
|
||||
return $this->marginBottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Margin Bottom.
|
||||
*
|
||||
* @param float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMarginBottom($value = null)
|
||||
{
|
||||
$this->marginBottom = $this->setNumericVal($value, self::DEFAULT_MARGIN);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ class Cell extends Border
|
||||
/**
|
||||
* Width.
|
||||
*
|
||||
* @var int
|
||||
* @var ?int
|
||||
*/
|
||||
private $width;
|
||||
|
||||
@@ -118,6 +118,13 @@ class Cell extends Border
|
||||
*/
|
||||
private $unit = TblWidth::TWIP;
|
||||
|
||||
/**
|
||||
* Prevent text from wrapping in the cell.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $noWrap = true;
|
||||
|
||||
/**
|
||||
* Get vertical align.
|
||||
*
|
||||
@@ -162,7 +169,14 @@ class Cell extends Border
|
||||
*/
|
||||
public function setTextDirection($value = null)
|
||||
{
|
||||
$enum = [self::TEXT_DIR_BTLR, self::TEXT_DIR_TBRL];
|
||||
$enum = [
|
||||
self::TEXT_DIR_BTLR,
|
||||
self::TEXT_DIR_TBRL,
|
||||
self::TEXT_DIR_LRTB,
|
||||
self::TEXT_DIR_LRTBV,
|
||||
self::TEXT_DIR_TBRLV,
|
||||
self::TEXT_DIR_TBLRV,
|
||||
];
|
||||
$this->textDirection = $this->setEnumVal($value, $enum, $this->textDirection);
|
||||
|
||||
return $this;
|
||||
@@ -270,7 +284,7 @@ class Cell extends Border
|
||||
/**
|
||||
* Get cell width.
|
||||
*
|
||||
* @return int
|
||||
* @return ?int
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
@@ -286,7 +300,7 @@ class Cell extends Border
|
||||
*/
|
||||
public function setWidth($value)
|
||||
{
|
||||
$this->setIntVal($value);
|
||||
$this->width = $this->setIntVal($value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -312,4 +326,22 @@ class Cell extends Border
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set noWrap.
|
||||
*/
|
||||
public function setNoWrap(bool $value): self
|
||||
{
|
||||
$this->noWrap = $this->setBoolVal($value, true);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get noWrap.
|
||||
*/
|
||||
public function getNoWrap(): bool
|
||||
{
|
||||
return $this->noWrap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
|
||||
namespace PhpOffice\PhpWord\Style;
|
||||
|
||||
use PhpOffice\PhpWord\Settings;
|
||||
use PhpOffice\PhpWord\Shared\Validate;
|
||||
|
||||
/**
|
||||
* Font style.
|
||||
*/
|
||||
@@ -230,7 +233,7 @@ class Font extends AbstractStyle
|
||||
/**
|
||||
* Right to left languages.
|
||||
*
|
||||
* @var bool
|
||||
* @var ?bool
|
||||
*/
|
||||
private $rtl;
|
||||
|
||||
@@ -245,7 +248,7 @@ class Font extends AbstractStyle
|
||||
/**
|
||||
* Languages.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\Language
|
||||
* @var null|\PhpOffice\PhpWord\Style\Language
|
||||
*/
|
||||
private $lang;
|
||||
|
||||
@@ -267,6 +270,20 @@ class Font extends AbstractStyle
|
||||
*/
|
||||
private $position;
|
||||
|
||||
/**
|
||||
* Preservation of white space in html.
|
||||
*
|
||||
* @var string Value used for css white-space
|
||||
*/
|
||||
private $whiteSpace = '';
|
||||
|
||||
/**
|
||||
* Generic font as fallback for html.
|
||||
*
|
||||
* @var string generic font name
|
||||
*/
|
||||
private $fallbackFont = '';
|
||||
|
||||
/**
|
||||
* Create new font style.
|
||||
*
|
||||
@@ -288,7 +305,7 @@ class Font extends AbstractStyle
|
||||
*/
|
||||
public function getStyleValues()
|
||||
{
|
||||
$styles = [
|
||||
return [
|
||||
'name' => $this->getStyleName(),
|
||||
'basic' => [
|
||||
'name' => $this->getName(),
|
||||
@@ -319,9 +336,9 @@ class Font extends AbstractStyle
|
||||
'rtl' => $this->isRTL(),
|
||||
'shading' => $this->getShading(),
|
||||
'lang' => $this->getLang(),
|
||||
'whiteSpace' => $this->getWhiteSpace(),
|
||||
'fallbackFont' => $this->getFallbackFont(),
|
||||
];
|
||||
|
||||
return $styles;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -827,17 +844,17 @@ class Font extends AbstractStyle
|
||||
/**
|
||||
* Get rtl.
|
||||
*
|
||||
* @return bool
|
||||
* @return ?bool
|
||||
*/
|
||||
public function isRTL()
|
||||
{
|
||||
return $this->rtl;
|
||||
return $this->rtl ?? Settings::isDefaultRtl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set rtl.
|
||||
*
|
||||
* @param bool $value
|
||||
* @param ?bool $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -875,7 +892,7 @@ class Font extends AbstractStyle
|
||||
/**
|
||||
* Get language.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Language
|
||||
* @return null|\PhpOffice\PhpWord\Style\Language
|
||||
*/
|
||||
public function getLang()
|
||||
{
|
||||
@@ -946,4 +963,44 @@ class Font extends AbstractStyle
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set html css white-space value. It is expected that only pre-wrap and normal (default) are useful.
|
||||
*
|
||||
* @param null|string $value Should be one of pre-wrap, normal, nowrap, pre, pre-line, initial, inherit
|
||||
*/
|
||||
public function setWhiteSpace(?string $value): self
|
||||
{
|
||||
$this->whiteSpace = Validate::validateCSSWhiteSpace($value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get html css white-space value.
|
||||
*/
|
||||
public function getWhiteSpace(): string
|
||||
{
|
||||
return $this->whiteSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set generic font for fallback for html.
|
||||
*
|
||||
* @param string $value generic font name
|
||||
*/
|
||||
public function setFallbackFont(?string $value): self
|
||||
{
|
||||
$this->fallbackFont = Validate::validateCSSGenericFont($value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get html fallback generic font.
|
||||
*/
|
||||
public function getFallbackFont(): string
|
||||
{
|
||||
return $this->fallbackFont;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class Indentation extends AbstractStyle
|
||||
*
|
||||
* @var float|int
|
||||
*/
|
||||
private $firstLine;
|
||||
private $firstLine = 0;
|
||||
|
||||
/**
|
||||
* Indentation removed from first line (twip).
|
||||
@@ -80,7 +80,7 @@ class Indentation extends AbstractStyle
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setLeft($value = null)
|
||||
public function setLeft($value)
|
||||
{
|
||||
$this->left = $this->setNumericVal($value, $this->left);
|
||||
|
||||
@@ -104,7 +104,7 @@ class Indentation extends AbstractStyle
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setRight($value = null)
|
||||
public function setRight($value)
|
||||
{
|
||||
$this->right = $this->setNumericVal($value, $this->right);
|
||||
|
||||
@@ -128,7 +128,7 @@ class Indentation extends AbstractStyle
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setFirstLine($value = null)
|
||||
public function setFirstLine($value)
|
||||
{
|
||||
$this->firstLine = $this->setNumericVal($value, $this->firstLine);
|
||||
|
||||
|
||||
@@ -40,18 +40,27 @@ final class Language extends AbstractStyle
|
||||
const FR_BE = 'fr-BE';
|
||||
const FR_BE_ID = 2060;
|
||||
|
||||
const FR_CH = 'fr-CH';
|
||||
const FR_CH_ID = 4108;
|
||||
|
||||
const ES_ES = 'es-ES';
|
||||
const ES_ES_ID = 3082;
|
||||
|
||||
const DE_DE = 'de-DE';
|
||||
const DE_DE_ID = 1031;
|
||||
|
||||
const DE_CH = 'de-CH';
|
||||
const DE_CH_ID = 2055;
|
||||
|
||||
const HE_IL = 'he-IL';
|
||||
const HE_IL_ID = 1037;
|
||||
|
||||
const IT_IT = 'it-IT';
|
||||
const IT_IT_ID = 1040;
|
||||
|
||||
const IT_CH = 'it-CH';
|
||||
const IT_CH_ID = 2064;
|
||||
|
||||
const JA_JP = 'ja-JP';
|
||||
const JA_JP_ID = 1041;
|
||||
|
||||
@@ -70,6 +79,9 @@ final class Language extends AbstractStyle
|
||||
const NL_NL = 'nl-NL';
|
||||
const NL_NL_ID = 1043;
|
||||
|
||||
const SV_SE = 'sv-SE';
|
||||
const SV_SE_ID = 1053;
|
||||
|
||||
const UK_UA = 'uk-UA';
|
||||
const UK_UA_ID = 1058;
|
||||
|
||||
@@ -244,7 +256,9 @@ final class Language extends AbstractStyle
|
||||
if ($locale !== null && strlen($locale) === 2) {
|
||||
return strtolower($locale) . '-' . strtoupper($locale);
|
||||
}
|
||||
|
||||
if ($locale === 'und') {
|
||||
return 'en-EN';
|
||||
}
|
||||
if ($locale !== null && $locale !== 'zxx' && strstr($locale, '-') === false) {
|
||||
throw new InvalidArgumentException($locale . ' is not a valid language code');
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
namespace PhpOffice\PhpWord\Style;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\InvalidStyleException;
|
||||
use PhpOffice\PhpWord\Settings;
|
||||
use PhpOffice\PhpWord\Shared\Text;
|
||||
use PhpOffice\PhpWord\SimpleType\Jc;
|
||||
use PhpOffice\PhpWord\SimpleType\TextAlignment;
|
||||
@@ -99,7 +100,7 @@ class Paragraph extends Border
|
||||
/**
|
||||
* Text line height.
|
||||
*
|
||||
* @var int
|
||||
* @var null|float|int
|
||||
*/
|
||||
private $lineHeight;
|
||||
|
||||
@@ -169,9 +170,9 @@ class Paragraph extends Border
|
||||
/**
|
||||
* Right to Left Paragraph Layout.
|
||||
*
|
||||
* @var bool
|
||||
* @var ?bool
|
||||
*/
|
||||
private $bidi = false;
|
||||
private $bidi;
|
||||
|
||||
/**
|
||||
* Vertical Character Alignment on Line.
|
||||
@@ -321,9 +322,9 @@ class Paragraph extends Border
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shading.
|
||||
* Get indentation.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\Indentation
|
||||
* @return null|\PhpOffice\PhpWord\Style\Indentation
|
||||
*/
|
||||
public function getIndentation()
|
||||
{
|
||||
@@ -419,7 +420,7 @@ class Paragraph extends Border
|
||||
/**
|
||||
* Get space before paragraph.
|
||||
*
|
||||
* @return int
|
||||
* @return null|float|int
|
||||
*/
|
||||
public function getSpaceBefore()
|
||||
{
|
||||
@@ -429,7 +430,7 @@ class Paragraph extends Border
|
||||
/**
|
||||
* Set space before paragraph.
|
||||
*
|
||||
* @param int $value
|
||||
* @param null|float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -441,7 +442,7 @@ class Paragraph extends Border
|
||||
/**
|
||||
* Get space after paragraph.
|
||||
*
|
||||
* @return int
|
||||
* @return null|float|int
|
||||
*/
|
||||
public function getSpaceAfter()
|
||||
{
|
||||
@@ -451,7 +452,7 @@ class Paragraph extends Border
|
||||
/**
|
||||
* Set space after paragraph.
|
||||
*
|
||||
* @param int $value
|
||||
* @param null|float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -463,7 +464,7 @@ class Paragraph extends Border
|
||||
/**
|
||||
* Get spacing between lines.
|
||||
*
|
||||
* @return float|int
|
||||
* @return null|float|int
|
||||
*/
|
||||
public function getSpacing()
|
||||
{
|
||||
@@ -473,7 +474,7 @@ class Paragraph extends Border
|
||||
/**
|
||||
* Set spacing between lines.
|
||||
*
|
||||
* @param float|int $value
|
||||
* @param null|float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -507,7 +508,7 @@ class Paragraph extends Border
|
||||
/**
|
||||
* Get line height.
|
||||
*
|
||||
* @return float|int
|
||||
* @return null|float|int
|
||||
*/
|
||||
public function getLineHeight()
|
||||
{
|
||||
@@ -759,17 +760,17 @@ class Paragraph extends Border
|
||||
/**
|
||||
* Get bidirectional.
|
||||
*
|
||||
* @return bool
|
||||
* @return ?bool
|
||||
*/
|
||||
public function isBidi()
|
||||
{
|
||||
return $this->bidi;
|
||||
return $this->bidi ?? Settings::isDefaultRtl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bidi.
|
||||
*
|
||||
* @param bool $bidi
|
||||
* @param ?bool $bidi
|
||||
* Set to true to write from right to left
|
||||
*
|
||||
* @return self
|
||||
|
||||
@@ -40,7 +40,6 @@ class Section extends Border
|
||||
*/
|
||||
const DEFAULT_WIDTH = 11905.511811024; // In twips.
|
||||
const DEFAULT_HEIGHT = 16837.79527559; // In twips.
|
||||
const DEFAULT_MARGIN = 1440; // In twips.
|
||||
const DEFAULT_GUTTER = 0; // In twips.
|
||||
const DEFAULT_HEADER_HEIGHT = 720; // In twips.
|
||||
const DEFAULT_FOOTER_HEIGHT = 720; // In twips.
|
||||
@@ -77,34 +76,6 @@ class Section extends Border
|
||||
*/
|
||||
private $pageSizeH = self::DEFAULT_HEIGHT;
|
||||
|
||||
/**
|
||||
* Top margin spacing.
|
||||
*
|
||||
* @var float|int
|
||||
*/
|
||||
private $marginTop = self::DEFAULT_MARGIN;
|
||||
|
||||
/**
|
||||
* Left margin spacing.
|
||||
*
|
||||
* @var float|int
|
||||
*/
|
||||
private $marginLeft = self::DEFAULT_MARGIN;
|
||||
|
||||
/**
|
||||
* Right margin spacing.
|
||||
*
|
||||
* @var float|int
|
||||
*/
|
||||
private $marginRight = self::DEFAULT_MARGIN;
|
||||
|
||||
/**
|
||||
* Bottom margin spacing.
|
||||
*
|
||||
* @var float|int
|
||||
*/
|
||||
private $marginBottom = self::DEFAULT_MARGIN;
|
||||
|
||||
/**
|
||||
* Page gutter spacing.
|
||||
*
|
||||
@@ -159,7 +130,7 @@ class Section extends Border
|
||||
* - evenPage: Even page section break
|
||||
* - oddPage: Odd page section break
|
||||
*
|
||||
* @var string
|
||||
* @var ?string
|
||||
*/
|
||||
private $breakType;
|
||||
|
||||
@@ -176,7 +147,7 @@ class Section extends Border
|
||||
* Vertical Text Alignment on Page
|
||||
* One of \PhpOffice\PhpWord\SimpleType\VerticalJc.
|
||||
*
|
||||
* @var string
|
||||
* @var ?string
|
||||
*/
|
||||
private $vAlign;
|
||||
|
||||
@@ -224,7 +195,7 @@ class Section extends Border
|
||||
* Set Setting Value.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @param array|int|string $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -344,102 +315,6 @@ class Section extends Border
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Margin Top.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getMarginTop()
|
||||
{
|
||||
return $this->marginTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Margin Top.
|
||||
*
|
||||
* @param float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMarginTop($value = null)
|
||||
{
|
||||
$this->marginTop = $this->setNumericVal($value, self::DEFAULT_MARGIN);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Margin Left.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getMarginLeft()
|
||||
{
|
||||
return $this->marginLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Margin Left.
|
||||
*
|
||||
* @param float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMarginLeft($value = null)
|
||||
{
|
||||
$this->marginLeft = $this->setNumericVal($value, self::DEFAULT_MARGIN);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Margin Right.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getMarginRight()
|
||||
{
|
||||
return $this->marginRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Margin Right.
|
||||
*
|
||||
* @param float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMarginRight($value = null)
|
||||
{
|
||||
$this->marginRight = $this->setNumericVal($value, self::DEFAULT_MARGIN);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Margin Bottom.
|
||||
*
|
||||
* @return float|int
|
||||
*/
|
||||
public function getMarginBottom()
|
||||
{
|
||||
return $this->marginBottom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Margin Bottom.
|
||||
*
|
||||
* @param float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setMarginBottom($value = null)
|
||||
{
|
||||
$this->marginBottom = $this->setNumericVal($value, self::DEFAULT_MARGIN);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gutter.
|
||||
*
|
||||
@@ -587,7 +462,7 @@ class Section extends Border
|
||||
/**
|
||||
* Get Break Type.
|
||||
*
|
||||
* @return string
|
||||
* @return ?string
|
||||
*/
|
||||
public function getBreakType()
|
||||
{
|
||||
@@ -635,7 +510,7 @@ class Section extends Border
|
||||
/**
|
||||
* Get vertical alignment.
|
||||
*
|
||||
* @return string
|
||||
* @return ?string
|
||||
*/
|
||||
public function getVAlign()
|
||||
{
|
||||
|
||||
@@ -30,21 +30,21 @@ class Spacing extends AbstractStyle
|
||||
/**
|
||||
* Spacing above paragraph (twip).
|
||||
*
|
||||
* @var float|int
|
||||
* @var null|float|int
|
||||
*/
|
||||
private $before;
|
||||
|
||||
/**
|
||||
* Spacing below paragraph (twip).
|
||||
*
|
||||
* @var float|int
|
||||
* @var null|float|int
|
||||
*/
|
||||
private $after;
|
||||
|
||||
/**
|
||||
* Spacing between lines in paragraph (twip).
|
||||
*
|
||||
* @var float|int
|
||||
* @var null|float|int
|
||||
*/
|
||||
private $line;
|
||||
|
||||
@@ -68,7 +68,7 @@ class Spacing extends AbstractStyle
|
||||
/**
|
||||
* Get before.
|
||||
*
|
||||
* @return float|int
|
||||
* @return null|float|int
|
||||
*/
|
||||
public function getBefore()
|
||||
{
|
||||
@@ -78,7 +78,7 @@ class Spacing extends AbstractStyle
|
||||
/**
|
||||
* Set before.
|
||||
*
|
||||
* @param float|int $value
|
||||
* @param null|float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -92,7 +92,7 @@ class Spacing extends AbstractStyle
|
||||
/**
|
||||
* Get after.
|
||||
*
|
||||
* @return float|int
|
||||
* @return null|float|int
|
||||
*/
|
||||
public function getAfter()
|
||||
{
|
||||
@@ -102,7 +102,7 @@ class Spacing extends AbstractStyle
|
||||
/**
|
||||
* Set after.
|
||||
*
|
||||
* @param float|int $value
|
||||
* @param null|float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
@@ -116,7 +116,7 @@ class Spacing extends AbstractStyle
|
||||
/**
|
||||
* Get line.
|
||||
*
|
||||
* @return float|int
|
||||
* @return null|float|int
|
||||
*/
|
||||
public function getLine()
|
||||
{
|
||||
@@ -126,7 +126,7 @@ class Spacing extends AbstractStyle
|
||||
/**
|
||||
* Set distance.
|
||||
*
|
||||
* @param float|int $value
|
||||
* @param null|float|int $value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
|
||||
@@ -18,9 +18,11 @@
|
||||
namespace PhpOffice\PhpWord\Style;
|
||||
|
||||
use PhpOffice\PhpWord\ComplexType\TblWidth as TblWidthComplexType;
|
||||
use PhpOffice\PhpWord\Settings;
|
||||
use PhpOffice\PhpWord\SimpleType\Jc;
|
||||
use PhpOffice\PhpWord\SimpleType\JcTable;
|
||||
use PhpOffice\PhpWord\SimpleType\TblWidth;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
|
||||
class Table extends Border
|
||||
{
|
||||
@@ -131,7 +133,7 @@ class Table extends Border
|
||||
private $unit = TblWidth::AUTO;
|
||||
|
||||
/**
|
||||
* @var float|int cell spacing value
|
||||
* @var null|float|int cell spacing value
|
||||
*/
|
||||
protected $cellSpacing;
|
||||
|
||||
@@ -143,7 +145,7 @@ class Table extends Border
|
||||
/**
|
||||
* Position.
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Style\TablePosition
|
||||
* @var ?\PhpOffice\PhpWord\Style\TablePosition
|
||||
*/
|
||||
private $position;
|
||||
|
||||
@@ -162,9 +164,9 @@ class Table extends Border
|
||||
*
|
||||
* @see http://www.datypic.com/sc/ooxml/e-w_bidiVisual-1.html
|
||||
*
|
||||
* @var bool
|
||||
* @var ?bool
|
||||
*/
|
||||
private $bidiVisual = false;
|
||||
private $bidiVisual;
|
||||
|
||||
/**
|
||||
* Create new table style.
|
||||
@@ -188,7 +190,7 @@ class Table extends Border
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float|int $cellSpacing
|
||||
* @param null|float|int $cellSpacing
|
||||
*/
|
||||
public function setCellSpacing($cellSpacing = null): void
|
||||
{
|
||||
@@ -196,7 +198,7 @@ class Table extends Border
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float|int
|
||||
* @return null|float|int
|
||||
*/
|
||||
public function getCellSpacing()
|
||||
{
|
||||
@@ -216,7 +218,7 @@ class Table extends Border
|
||||
/**
|
||||
* Get background.
|
||||
*
|
||||
* @return string
|
||||
* @return ?string
|
||||
*/
|
||||
public function getBgColor()
|
||||
{
|
||||
@@ -704,7 +706,7 @@ class Table extends Border
|
||||
/**
|
||||
* Get position.
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Style\TablePosition
|
||||
* @return ?\PhpOffice\PhpWord\Style\TablePosition
|
||||
*/
|
||||
public function getPosition()
|
||||
{
|
||||
@@ -726,7 +728,7 @@ class Table extends Border
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TblWidthComplexType
|
||||
* @return ?TblWidthComplexType
|
||||
*/
|
||||
public function getIndent()
|
||||
{
|
||||
@@ -768,17 +770,17 @@ class Table extends Border
|
||||
/**
|
||||
* Get bidiVisual.
|
||||
*
|
||||
* @return bool
|
||||
* @return ?bool
|
||||
*/
|
||||
public function isBidiVisual()
|
||||
{
|
||||
return $this->bidiVisual;
|
||||
return $this->bidiVisual ?? Settings::isDefaultRtl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bidiVisual.
|
||||
*
|
||||
* @param bool $bidi
|
||||
* @param ?bool $bidi
|
||||
* Set to true to visually present table as Right to Left
|
||||
*
|
||||
* @return self
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
*
|
||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||
* General Public License version 3 as published by the Free Software Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please read the LICENSE
|
||||
* file that was distributed with this source code. For the full list of
|
||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
@@ -27,121 +25,128 @@ class TextBox extends Image
|
||||
/**
|
||||
* margin top.
|
||||
*
|
||||
* @var int
|
||||
* @var null|int
|
||||
*/
|
||||
private $innerMarginTop;
|
||||
|
||||
/**
|
||||
* margin left.
|
||||
*
|
||||
* @var int
|
||||
* @var null|int
|
||||
*/
|
||||
private $innerMarginLeft;
|
||||
|
||||
/**
|
||||
* margin right.
|
||||
*
|
||||
* @var int
|
||||
* @var null|int
|
||||
*/
|
||||
private $innerMarginRight;
|
||||
|
||||
/**
|
||||
* Cell margin bottom.
|
||||
*
|
||||
* @var int
|
||||
* @var null|int
|
||||
*/
|
||||
private $innerMarginBottom;
|
||||
|
||||
/**
|
||||
* border size.
|
||||
*
|
||||
* @var int
|
||||
* @var null|int
|
||||
*/
|
||||
private $borderSize;
|
||||
|
||||
/**
|
||||
* border color.
|
||||
*
|
||||
* @var string
|
||||
* @var null|string
|
||||
*/
|
||||
private $borderColor;
|
||||
|
||||
/**
|
||||
* Set margin top.
|
||||
* background color.
|
||||
*
|
||||
* @param int $value
|
||||
* @var null|string
|
||||
*/
|
||||
public function setInnerMarginTop($value = null): void
|
||||
private $bgColor;
|
||||
|
||||
/**
|
||||
* Set background color.
|
||||
*/
|
||||
public function setBgColor(?string $value = null): void
|
||||
{
|
||||
$this->bgColor = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get background color.
|
||||
*/
|
||||
public function getBgColor(): ?string
|
||||
{
|
||||
return $this->bgColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set margin top.
|
||||
*/
|
||||
public function setInnerMarginTop(?int $value = null): void
|
||||
{
|
||||
$this->innerMarginTop = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get margin top.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getInnerMarginTop()
|
||||
public function getInnerMarginTop(): ?int
|
||||
{
|
||||
return $this->innerMarginTop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set margin left.
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setInnerMarginLeft($value = null): void
|
||||
public function setInnerMarginLeft(?int $value = null): void
|
||||
{
|
||||
$this->innerMarginLeft = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get margin left.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getInnerMarginLeft()
|
||||
public function getInnerMarginLeft(): ?int
|
||||
{
|
||||
return $this->innerMarginLeft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set margin right.
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setInnerMarginRight($value = null): void
|
||||
public function setInnerMarginRight(?int $value = null): void
|
||||
{
|
||||
$this->innerMarginRight = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get margin right.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getInnerMarginRight()
|
||||
public function getInnerMarginRight(): ?int
|
||||
{
|
||||
return $this->innerMarginRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set margin bottom.
|
||||
*
|
||||
* @param int $value
|
||||
*/
|
||||
public function setInnerMarginBottom($value = null): void
|
||||
public function setInnerMarginBottom(?int $value = null): void
|
||||
{
|
||||
$this->innerMarginBottom = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get margin bottom.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getInnerMarginBottom()
|
||||
public function getInnerMarginBottom(): ?int
|
||||
{
|
||||
return $this->innerMarginBottom;
|
||||
}
|
||||
@@ -149,9 +154,9 @@ class TextBox extends Image
|
||||
/**
|
||||
* Set TLRB cell margin.
|
||||
*
|
||||
* @param int $value Margin in twips
|
||||
* @param null|int $value Margin in twips
|
||||
*/
|
||||
public function setInnerMargin($value = null): void
|
||||
public function setInnerMargin(?int $value = null): void
|
||||
{
|
||||
$this->setInnerMarginTop($value);
|
||||
$this->setInnerMarginLeft($value);
|
||||
@@ -164,17 +169,15 @@ class TextBox extends Image
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function getInnerMargin()
|
||||
public function getInnerMargin(): array
|
||||
{
|
||||
return [$this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom];
|
||||
}
|
||||
|
||||
/**
|
||||
* Has inner margin?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasInnerMargins()
|
||||
public function hasInnerMargins(): bool
|
||||
{
|
||||
$hasInnerMargins = false;
|
||||
$margins = $this->getInnerMargin();
|
||||
@@ -191,39 +194,33 @@ class TextBox extends Image
|
||||
/**
|
||||
* Set border size.
|
||||
*
|
||||
* @param int $value Size in points
|
||||
* @param null|int $value Size in points
|
||||
*/
|
||||
public function setBorderSize($value = null): void
|
||||
public function setBorderSize(?int $value = null): void
|
||||
{
|
||||
$this->borderSize = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border size.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBorderSize()
|
||||
public function getBorderSize(): ?int
|
||||
{
|
||||
return $this->borderSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set border color.
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
public function setBorderColor($value = null): void
|
||||
public function setBorderColor(?string $value = null): void
|
||||
{
|
||||
$this->borderColor = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get border color.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBorderColor()
|
||||
public function getBorderColor(): ?string
|
||||
{
|
||||
return $this->borderColor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user