Skip to content

Commit c7a940c

Browse files
committed
Merge branch 'textbox' of github.com:basjan/PHPWord
2 parents e0638f5 + 364131a commit c7a940c

File tree

11 files changed

+1385
-17
lines changed

11 files changed

+1385
-17
lines changed

src/PhpWord/Element/AbstractContainer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public function addCheckBox($name, $text, $fontStyle = null, $paragraphStyle = n
304304
private function checkValidity($method)
305305
{
306306
// Valid containers for each element
307-
$allContainers = array('section', 'header', 'footer', 'cell', 'textrun', 'footnote', 'endnote');
307+
$allContainers = array('section', 'header', 'footer', 'cell', 'textrun', 'footnote', 'endnote', 'textbox');
308308
$validContainers = array(
309309
'Text' => $allContainers,
310310
'Link' => $allContainers,

src/PhpWord/Element/AbstractElement.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,11 @@
2727
*/
2828
abstract class AbstractElement
2929
{
30-
/**
31-
* This file is part of PHPWord - A pure PHP library for reading and writing
32-
* word processing documents.
33-
*
34-
* PHPWord is free software distributed under the terms of the GNU Lesser
35-
* General Public License version 3 as published by the Free Software Foundation.
36-
*
37-
* For the full copyright and license information, please read the LICENSE
38-
* file that was distributed with this source code. For the full list of
39-
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. object
40-
*/
30+
4131
protected $phpWord;
4232

4333
/**
44-
* Container type section|header|footer|cell|textrun|footnote|endnote
34+
* Container type section|header|footer|cell|textrun|footnote|endnote|textbox
4535
*
4636
* @var string
4737
*/

src/PhpWord/Element/Footer.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,21 @@ public function evenPage()
115115
return $this->type = self::EVEN;
116116
}
117117

118+
/**
119+
* Add textbox element
120+
*
121+
* @param mixed $style
122+
* @return \PhpOffice\PhpWord\Element\TextBox
123+
* @todo Merge with the same function on Section
124+
*/
125+
public function addTextBox($style = null)
126+
{
127+
$textbox = new TextBox($this->getDocPart(), $this->getDocPartId(), $style);
128+
$this->addElement($textbox);
129+
130+
return $textbox;
131+
}
132+
118133
/**
119134
* Add table element
120135
*

src/PhpWord/Element/Section.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,21 @@ public function addPageBreak()
117117
$this->addElement(new PageBreak());
118118
}
119119

120+
/**
121+
* Add textbox element
122+
*
123+
* @param mixed $style
124+
* @return \PhpOffice\PhpWord\Element\TextBox
125+
* @todo Merge with the same function on Footer
126+
*/
127+
public function addTextBox($style = null)
128+
{
129+
$textbox = new TextBox($this->getDocPart(), $this->getDocPartId(), $style);
130+
$this->addElement($textbox);
131+
132+
return $textbox;
133+
}
134+
120135
/**
121136
* Add table element
122137
*

src/PhpWord/Element/TextBox.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* This file is part of PHPWord - A pure PHP library for reading and writing
4+
* word processing documents.
5+
*
6+
* PHPWord is free software distributed under the terms of the GNU Lesser
7+
* General Public License version 3 as published by the Free Software Foundation.
8+
*
9+
* For the full copyright and license information, please read the LICENSE
10+
* file that was distributed with this source code. For the full list of
11+
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
12+
*
13+
* @link https://github.com/PHPOffice/PHPWord
14+
* @copyright 2010-2014 PHPWord contributors
15+
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16+
*/
17+
18+
namespace PhpOffice\PhpWord\Element;
19+
20+
use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle;
21+
22+
/**
23+
* Table element
24+
*/
25+
class TextBox extends AbstractContainer
26+
{
27+
/**
28+
* TextBox style
29+
*
30+
* @var \PhpOffice\PhpWord\Style\TextBox
31+
*/
32+
private $style;
33+
34+
/**
35+
* Create a new textbox
36+
*
37+
* @param string $docPart
38+
* @param integer $docPartId
39+
* @param mixed $style
40+
*/
41+
public function __construct($docPart, $docPartId, $style = null)
42+
{
43+
$this->container = 'textbox';
44+
$this->setDocPart($docPart, $docPartId);
45+
$this->style = $this->setStyle(new TextBoxStyle(), $style);
46+
}
47+
48+
/**
49+
* Get textbox style
50+
*
51+
* @return \PhpOffice\PhpWord\Style\TextBox
52+
*/
53+
public function getStyle()
54+
{
55+
return $this->style;
56+
}
57+
}

0 commit comments

Comments
 (0)