|
30 | 30 | */
|
31 | 31 | class PHPWord_Section_TextBreak
|
32 | 32 | {
|
| 33 | + /** |
| 34 | + * Paragraph style |
| 35 | + * |
| 36 | + * @var PHPWord_Style_Pagaraph |
| 37 | + */ |
| 38 | + private $paragraphStyle = null; |
| 39 | + |
| 40 | + /** |
| 41 | + * Text style |
| 42 | + * |
| 43 | + * @var PHPWord_Style_Font |
| 44 | + */ |
| 45 | + private $fontStyle = null; |
33 | 46 |
|
34 | 47 | /**
|
35 | 48 | * Create a new TextBreak Element
|
36 | 49 | */
|
37 |
| - public function __construct() |
| 50 | + public function __construct($fontStyle = null, $paragraphStyle = null) |
| 51 | + { |
| 52 | + if (!is_null($paragraphStyle)) { |
| 53 | + $paragraphStyle = $this->setParagraphStyle($paragraphStyle); |
| 54 | + } |
| 55 | + if (!is_null($fontStyle)) { |
| 56 | + $this->setFontStyle($fontStyle, $paragraphStyle); |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Set Text style |
| 62 | + * |
| 63 | + * @param null|array|\PHPWord_Style_Font $style |
| 64 | + * @param null|array|\PHPWord_Style_Paragraph $paragraphStyle |
| 65 | + * @return PHPWord_Style_Font |
| 66 | + */ |
| 67 | + public function setFontStyle($style = null, $paragraphStyle = null) |
| 68 | + { |
| 69 | + if ($style instanceof PHPWord_Style_Font) { |
| 70 | + $this->fontStyle = $style; |
| 71 | + $this->setParagraphStyle($paragraphStyle); |
| 72 | + } elseif (is_array($style)) { |
| 73 | + $this->fontStyle = new PHPWord_Style_Font('text', $paragraphStyle); |
| 74 | + $this->fontStyle->setArrayStyle($style); |
| 75 | + } else { |
| 76 | + $this->fontStyle = $style; |
| 77 | + $this->setParagraphStyle($paragraphStyle); |
| 78 | + } |
| 79 | + return $this->fontStyle; |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * Get Text style |
| 84 | + * |
| 85 | + * @return PHPWord_Style_Font |
| 86 | + */ |
| 87 | + public function getFontStyle() |
| 88 | + { |
| 89 | + return $this->fontStyle; |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Set Paragraph style |
| 94 | + * |
| 95 | + * @param null|array|\PHPWord_Style_Paragraph $style |
| 96 | + * @return null|\PHPWord_Style_Paragraph |
| 97 | + */ |
| 98 | + public function setParagraphStyle($style = null) |
| 99 | + { |
| 100 | + if (is_array($style)) { |
| 101 | + $this->paragraphStyle = new PHPWord_Style_Paragraph; |
| 102 | + $this->paragraphStyle->setArrayStyle($style); |
| 103 | + } elseif ($style instanceof PHPWord_Style_Paragraph) { |
| 104 | + $this->paragraphStyle = $style; |
| 105 | + } else { |
| 106 | + $this->paragraphStyle = $style; |
| 107 | + } |
| 108 | + return $this->paragraphStyle; |
| 109 | + } |
| 110 | + |
| 111 | + /** |
| 112 | + * Get Paragraph style |
| 113 | + * |
| 114 | + * @return PHPWord_Style_Paragraph |
| 115 | + */ |
| 116 | + public function getParagraphStyle() |
38 | 117 | {
|
| 118 | + return $this->paragraphStyle; |
39 | 119 | }
|
40 | 120 | }
|
0 commit comments