Skip to content

Commit 8267a9e

Browse files
author
Roman Syroeshko
committed
#58 - Part VI (PhpWord).
1 parent 32ed6a3 commit 8267a9e

File tree

161 files changed

+1034
-1098
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+1034
-1098
lines changed

Classes/PHPWord.php

Lines changed: 44 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
/**
3-
* PHPWord
3+
* PhpWord
44
*
5-
* Copyright (c) 2014 PHPWord
5+
* Copyright (c) 2014 PhpWord
66
*
77
* This library is free software; you can redistribute it and/or
88
* modify it under the terms of the GNU Lesser General Public
@@ -18,16 +18,17 @@
1818
* License along with this library; if not, write to the Free Software
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020
*
21-
* @category PHPWord
22-
* @package PHPWord
23-
* @copyright Copyright (c) 2014 PHPWord
21+
* @category PhpWord
22+
* @package PhpWord
23+
* @copyright Copyright (c) 2014 PhpWord
2424
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2525
* @version 0.8.0
2626
*/
2727

2828
namespace PhpOffice;
2929

3030
use PhpOffice\PhpWord\DocumentProperties;
31+
use PhpOffice\PhpWord\Exceptions\Exception;
3132
use PhpOffice\PhpWord\Section;
3233
use PhpOffice\PhpWord\Style;
3334
use PhpOffice\PhpWord\Template;
@@ -36,114 +37,83 @@
3637
// @codeCoverageIgnoreStart
3738
if (!defined('PHPWORD_BASE_PATH')) {
3839
define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/');
39-
require PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php';
40+
require PHPWORD_BASE_PATH . 'PhpWord/Autoloader.php';
4041
PHPWord_Autoloader::Register();
4142
}
4243
// @codeCoverageIgnoreEnd
4344

44-
use PhpOffice\PhpWord\Exceptions\Exception;
45-
4645
class PhpWord
4746
{
47+
const DEFAULT_FONT_COLOR = '000000'; // HEX
48+
const DEFAULT_FONT_CONTENT_TYPE = 'default'; // default|eastAsia|cs
49+
const DEFAULT_FONT_NAME = 'Arial';
4850
/**
49-
* Default font name (Arial)
50-
*/
51-
const DEFAULT_FONT_NAME = 'Arial';
52-
/**
53-
* Default Font Content Type(default)
54-
* default|eastAsia|cs
55-
*/
56-
const DEFAULT_FONT_CONTENT_TYPE='default';
57-
/**
58-
* Default font size in points (10pt)
51+
* Default font size, in points.
5952
*
60-
* OOXML defined font size values in halfpoints, i.e. twice of what PHPWord
53+
* OOXML defined font size values in halfpoints, i.e. twice of what PhpWord
6154
* use, and the conversion will be conducted during XML writing.
6255
*/
6356
const DEFAULT_FONT_SIZE = 10;
6457

6558
/**
66-
* Default font color (black)
67-
*/
68-
const DEFAULT_FONT_COLOR = '000000';
69-
70-
/**
71-
* Document properties
72-
*
7359
* @var PhpOffice\PhpWord\DocumentProperties
7460
*/
75-
private $_properties;
61+
private $_documentProperties;
7662

7763
/**
78-
* Default Font Name
79-
*
8064
* @var string
8165
*/
8266
private $_defaultFontName;
8367

8468
/**
85-
* Default Font Size
86-
*
8769
* @var int
8870
*/
8971
private $_defaultFontSize;
9072

9173
/**
92-
* Collection of section elements
93-
*
94-
* @var array
74+
* @var PhpOffice\PhpWord\Section[]
9575
*/
96-
private $_sectionCollection = array();
76+
private $_sections = array();
9777

98-
99-
/**
100-
* Create a new PHPWord Document
101-
*/
10278
public function __construct()
10379
{
104-
$this->_properties = new DocumentProperties();
105-
$this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME;
106-
$this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE;
80+
$this->_documentProperties = new DocumentProperties();
81+
$this->_defaultFontName = self::DEFAULT_FONT_NAME;
82+
$this->_defaultFontSize = self::DEFAULT_FONT_SIZE;
10783
}
10884

10985
/**
110-
* Get properties
11186
* @return PhpOffice\PhpWord\DocumentProperties
11287
*/
113-
public function getProperties()
88+
public function getDocumentProperties()
11489
{
115-
return $this->_properties;
90+
return $this->_documentProperties;
11691
}
11792

11893
/**
119-
* Set properties
120-
*
121-
* @param PhpOffice\PhpWord\DocumentProperties $value
122-
* @return PhpOffice\PHPWord
94+
* @param PhpOffice\PhpWord\DocumentProperties $documentProperties
95+
* @return PhpOffice\PhpWord
12396
*/
124-
public function setProperties(DocumentProperties $value)
97+
public function setDocumentProperties(DocumentProperties $documentProperties)
12598
{
126-
$this->_properties = $value;
99+
$this->_documentProperties = $documentProperties;
100+
127101
return $this;
128102
}
129103

130104
/**
131-
* Create a new Section
132-
*
133-
* @param PhpOffice\PhpWord\Section\Settings $settings
105+
* @param PhpOffice\PhpWord\Section\Settings $settings
134106
* @return PhpOffice\PhpWord\Section
135107
*/
136108
public function createSection($settings = null)
137109
{
138-
$sectionCount = $this->_countSections() + 1;
110+
$section = new Section(\count($this->_sections) + 1, $settings);
111+
$this->_sections[] = $section;
139112

140-
$section = new Section($sectionCount, $settings);
141-
$this->_sectionCollection[] = $section;
142113
return $section;
143114
}
144115

145116
/**
146-
* Get default Font name
147117
* @return string
148118
*/
149119
public function getDefaultFontName()
@@ -152,16 +122,14 @@ public function getDefaultFontName()
152122
}
153123

154124
/**
155-
* Set default Font name
156-
* @param string $pValue
125+
* @param string $fontName
157126
*/
158-
public function setDefaultFontName($pValue)
127+
public function setDefaultFontName($fontName)
159128
{
160-
$this->_defaultFontName = $pValue;
129+
$this->_defaultFontName = $fontName;
161130
}
162131

163132
/**
164-
* Get default Font size (in points)
165133
* @return string
166134
*/
167135
public function getDefaultFontSize()
@@ -170,18 +138,17 @@ public function getDefaultFontSize()
170138
}
171139

172140
/**
173-
* Set default Font size (in points)
174-
* @param int $pValue
141+
* @param int $fontSize
175142
*/
176-
public function setDefaultFontSize($pValue)
143+
public function setDefaultFontSize($fontSize)
177144
{
178-
$this->_defaultFontSize = $pValue;
145+
$this->_defaultFontSize = $fontSize;
179146
}
180147

181148
/**
182149
* Set default paragraph style definition to styles.xml
183150
*
184-
* @param array $styles Paragraph style definition
151+
* @param array $styles Paragraph style definition
185152
*/
186153
public function setDefaultParagraphStyle($styles)
187154
{
@@ -244,35 +211,24 @@ public function addLinkStyle($styleName, $styles)
244211
}
245212

246213
/**
247-
* Get sections
248214
* @return PhpOffice\PhpWord\Section[]
249215
*/
250216
public function getSections()
251217
{
252-
return $this->_sectionCollection;
218+
return $this->_sections;
253219
}
254220

255221
/**
256-
* Load a Template File
257-
*
258-
* @param string $strFilename
222+
* @param string $filename Fully qualified filename.
259223
* @return PhpOffice\PhpWord\Template
260-
* @throws Exception
224+
* @throws PhpOffice\PhpWord\Exceptions\Exception
261225
*/
262-
public function loadTemplate($strFilename)
226+
public function loadTemplate($filename)
263227
{
264-
if (file_exists($strFilename)) {
265-
return new Template($strFilename);
228+
if (\file_exists($filename)) {
229+
return new Template($filename);
230+
} else {
231+
throw new Exception("Template file {$filename} not found.");
266232
}
267-
throw new Exception("Template file {$strFilename} not found.");
268233
}
269-
270-
/**
271-
* Get section count
272-
* @return int
273-
*/
274-
private function _countSections()
275-
{
276-
return count($this->_sectionCollection);
277-
}
278-
}
234+
}

Classes/PHPWord/Autoloader.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
/**
3-
* PHPWord
3+
* PhpWord
44
*
5-
* Copyright (c) 2014 PHPWord
5+
* Copyright (c) 2014 PhpWord
66
*
77
* This library is free software; you can redistribute it and/or
88
* modify it under the terms of the GNU Lesser General Public
@@ -18,9 +18,9 @@
1818
* License along with this library; if not, write to the Free Software
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020
*
21-
* @category PHPWord
22-
* @package PHPWord
23-
* @copyright Copyright (c) 2014 PHPWord
21+
* @category PhpWord
22+
* @package PhpWord
23+
* @copyright Copyright (c) 2014 PhpWord
2424
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2525
* @version 0.8.0
2626
*/

Classes/PHPWord/DocumentProperties.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
/**
3-
* PHPWord
3+
* PhpWord
44
*
5-
* Copyright (c) 2014 PHPWord
5+
* Copyright (c) 2014 PhpWord
66
*
77
* This library is free software; you can redistribute it and/or
88
* modify it under the terms of the GNU Lesser General Public
@@ -18,9 +18,9 @@
1818
* License along with this library; if not, write to the Free Software
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020
*
21-
* @category PHPWord
22-
* @package PHPWord
23-
* @copyright Copyright (c) 2014 PHPWord
21+
* @category PhpWord
22+
* @package PhpWord
23+
* @copyright Copyright (c) 2014 PhpWord
2424
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2525
* @version 0.8.0
2626
*/

Classes/PHPWord/Exceptions/InvalidImageException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Exception used for when an image is not found
88
*
9-
* @package PHPWord
9+
* @package PhpWord
1010
*/
1111
class InvalidImageException extends Exception
1212
{

Classes/PHPWord/Exceptions/InvalidStyleException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* Exception used for when a style value is invalid
1010
*
11-
* @package PHPWord
11+
* @package PhpWord
1212
*/
1313
class InvalidStyleException extends InvalidArgumentException
1414
{

Classes/PHPWord/Exceptions/UnsupportedImageTypeException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Exception used for when an image type is unsupported
88
*
9-
* @package PHPWord
9+
* @package PhpWord
1010
*/
1111
class UnsupportedImageTypeException extends Exception
1212
{

Classes/PHPWord/Footnote.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
/**
3-
* PHPWord
3+
* PhpWord
44
*
5-
* Copyright (c) 2014 PHPWord
5+
* Copyright (c) 2014 PhpWord
66
*
77
* This library is free software; you can redistribute it and/or
88
* modify it under the terms of the GNU Lesser General Public
@@ -18,9 +18,9 @@
1818
* License along with this library; if not, write to the Free Software
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020
*
21-
* @category PHPWord
22-
* @package PHPWord
23-
* @copyright Copyright (c) 2014 PHPWord
21+
* @category PhpWord
22+
* @package PhpWord
23+
* @copyright Copyright (c) 2014 PhpWord
2424
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2525
* @version 0.8.0
2626
*/

Classes/PHPWord/HashTable.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
/**
3-
* PHPWord
3+
* PhpWord
44
*
5-
* Copyright (c) 2014 PHPWord
5+
* Copyright (c) 2014 PhpWord
66
*
77
* This library is free software; you can redistribute it and/or
88
* modify it under the terms of the GNU Lesser General Public
@@ -18,9 +18,9 @@
1818
* License along with this library; if not, write to the Free Software
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020
*
21-
* @category PHPWord
22-
* @package PHPWord
23-
* @copyright Copyright (c) 2014 PHPWord
21+
* @category PhpWord
22+
* @package PhpWord
23+
* @copyright Copyright (c) 2014 PhpWord
2424
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2525
* @version 0.8.0
2626
*/

0 commit comments

Comments
 (0)