Skip to content

Commit 510f9cd

Browse files
author
Roman Syroeshko
committed
https://github.com/PHPOffice/PHPWord/issues/58
Part I.
1 parent f4d7fa4 commit 510f9cd

38 files changed

+485
-497
lines changed

Classes/PHPWord.php

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
* @version 0.8.0
2626
*/
2727

28+
namespace PhpOffice;
29+
30+
use PhpOffice\PhpWord\DocumentProperties;
31+
use PhpOffice\PhpWord\Section;
32+
use PhpOffice\PhpWord\Style;
33+
use PhpOffice\PhpWord\Template;
34+
2835
/** PHPWORD_BASE_PATH */
2936
// @codeCoverageIgnoreStart
3037
if (!defined('PHPWORD_BASE_PATH')) {
@@ -36,12 +43,8 @@
3643

3744
use PhpOffice\PhpWord\Exceptions\Exception;
3845

39-
/**
40-
* PHPWord
41-
*/
42-
class PHPWord
46+
class PhpWord
4347
{
44-
4548
/**
4649
* Default font name (Arial)
4750
*/
@@ -67,7 +70,7 @@ class PHPWord
6770
/**
6871
* Document properties
6972
*
70-
* @var PHPWord_DocumentProperties
73+
* @var PhpOffice\PhpWord\DocumentProperties
7174
*/
7275
private $_properties;
7376

@@ -98,14 +101,14 @@ class PHPWord
98101
*/
99102
public function __construct()
100103
{
101-
$this->_properties = new PHPWord_DocumentProperties();
104+
$this->_properties = new DocumentProperties();
102105
$this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME;
103106
$this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE;
104107
}
105108

106109
/**
107110
* Get properties
108-
* @return PHPWord_DocumentProperties
111+
* @return PhpOffice\PhpWord\DocumentProperties
109112
*/
110113
public function getProperties()
111114
{
@@ -115,10 +118,10 @@ public function getProperties()
115118
/**
116119
* Set properties
117120
*
118-
* @param PHPWord_DocumentProperties $value
119-
* @return PHPWord
121+
* @param PhpOffice\PhpWord\DocumentProperties $value
122+
* @return PhpOffice\PHPWord
120123
*/
121-
public function setProperties(PHPWord_DocumentProperties $value)
124+
public function setProperties(DocumentProperties $value)
122125
{
123126
$this->_properties = $value;
124127
return $this;
@@ -127,14 +130,14 @@ public function setProperties(PHPWord_DocumentProperties $value)
127130
/**
128131
* Create a new Section
129132
*
130-
* @param PHPWord_Section_Settings $settings
131-
* @return PHPWord_Section
133+
* @param PhpOffice\PhpWord\Section\Settings $settings
134+
* @return PhpOffice\PhpWord\Section
132135
*/
133136
public function createSection($settings = null)
134137
{
135138
$sectionCount = $this->_countSections() + 1;
136139

137-
$section = new PHPWord_Section($sectionCount, $settings);
140+
$section = new Section($sectionCount, $settings);
138141
$this->_sectionCollection[] = $section;
139142
return $section;
140143
}
@@ -182,7 +185,7 @@ public function setDefaultFontSize($pValue)
182185
*/
183186
public function setDefaultParagraphStyle($styles)
184187
{
185-
PHPWord_Style::setDefaultParagraphStyle($styles);
188+
Style::setDefaultParagraphStyle($styles);
186189
}
187190

188191
/**
@@ -193,7 +196,7 @@ public function setDefaultParagraphStyle($styles)
193196
*/
194197
public function addParagraphStyle($styleName, $styles)
195198
{
196-
PHPWord_Style::addParagraphStyle($styleName, $styles);
199+
Style::addParagraphStyle($styleName, $styles);
197200
}
198201

199202
/**
@@ -204,7 +207,7 @@ public function addParagraphStyle($styleName, $styles)
204207
*/
205208
public function addFontStyle($styleName, $styleFont, $styleParagraph = null)
206209
{
207-
PHPWord_Style::addFontStyle($styleName, $styleFont, $styleParagraph);
210+
Style::addFontStyle($styleName, $styleFont, $styleParagraph);
208211
}
209212

210213
/**
@@ -215,7 +218,7 @@ public function addFontStyle($styleName, $styleFont, $styleParagraph = null)
215218
*/
216219
public function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
217220
{
218-
PHPWord_Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
221+
Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
219222
}
220223

221224
/**
@@ -226,7 +229,7 @@ public function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
226229
*/
227230
public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
228231
{
229-
PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
232+
Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
230233
}
231234

232235
/**
@@ -237,12 +240,12 @@ public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null)
237240
*/
238241
public function addLinkStyle($styleName, $styles)
239242
{
240-
PHPWord_Style::addLinkStyle($styleName, $styles);
243+
Style::addLinkStyle($styleName, $styles);
241244
}
242245

243246
/**
244247
* Get sections
245-
* @return PHPWord_Section[]
248+
* @return PhpOffice\PhpWord\Section[]
246249
*/
247250
public function getSections()
248251
{
@@ -253,14 +256,13 @@ public function getSections()
253256
* Load a Template File
254257
*
255258
* @param string $strFilename
256-
* @return PHPWord_Template
259+
* @return PhpOffice\PhpWord\Template
257260
* @throws Exception
258261
*/
259262
public function loadTemplate($strFilename)
260263
{
261264
if (file_exists($strFilename)) {
262-
$template = new PHPWord_Template($strFilename);
263-
return $template;
265+
return new Template($strFilename);
264266
}
265267
throw new Exception("Template file {$strFilename} not found.");
266268
}

Classes/PHPWord/DocumentProperties.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525
* @version 0.8.0
2626
*/
2727

28-
/**
29-
* Class PHPWord_DocumentProperties
30-
*/
31-
class PHPWord_DocumentProperties
28+
namespace PhpOffice\PhpWord;
29+
30+
class DocumentProperties
3231
{
3332
/** Constants */
3433
const PROPERTY_TYPE_BOOLEAN = 'b';
@@ -123,7 +122,7 @@ class PHPWord_DocumentProperties
123122
private $_customProperties = array();
124123

125124
/**
126-
* Create new PHPWord_DocumentProperties
125+
* Create new DocumentProperties
127126
*/
128127
public function __construct()
129128
{
@@ -154,7 +153,7 @@ public function getCreator()
154153
* Set Creator
155154
*
156155
* @param string $pValue
157-
* @return PHPWord_DocumentProperties
156+
* @return PhpOffice\PhpWord\DocumentProperties
158157
*/
159158
public function setCreator($pValue = '')
160159
{
@@ -176,7 +175,7 @@ public function getLastModifiedBy()
176175
* Set Last Modified By
177176
*
178177
* @param string $pValue
179-
* @return PHPWord_DocumentProperties
178+
* @return PhpOffice\PhpWord\DocumentProperties
180179
*/
181180
public function setLastModifiedBy($pValue = '')
182181
{
@@ -198,7 +197,7 @@ public function getCreated()
198197
* Set Created
199198
*
200199
* @param datetime $pValue
201-
* @return PHPWord_DocumentProperties
200+
* @return PhpOffice\PhpWord\DocumentProperties
202201
*/
203202
public function setCreated($pValue = null)
204203
{
@@ -223,7 +222,7 @@ public function getModified()
223222
* Set Modified
224223
*
225224
* @param datetime $pValue
226-
* @return PHPWord_DocumentProperties
225+
* @return PhpOffice\PhpWord\DocumentProperties
227226
*/
228227
public function setModified($pValue = null)
229228
{
@@ -248,7 +247,7 @@ public function getTitle()
248247
* Set Title
249248
*
250249
* @param string $pValue
251-
* @return PHPWord_DocumentProperties
250+
* @return PhpOffice\PhpWord\DocumentProperties
252251
*/
253252
public function setTitle($pValue = '')
254253
{
@@ -270,7 +269,7 @@ public function getDescription()
270269
* Set Description
271270
*
272271
* @param string $pValue
273-
* @return PHPWord_DocumentProperties
272+
* @return PhpOffice\PhpWord\DocumentProperties
274273
*/
275274
public function setDescription($pValue = '')
276275
{
@@ -292,7 +291,7 @@ public function getSubject()
292291
* Set Subject
293292
*
294293
* @param string $pValue
295-
* @return PHPWord_DocumentProperties
294+
* @return PhpOffice\PhpWord\DocumentProperties
296295
*/
297296
public function setSubject($pValue = '')
298297
{
@@ -314,7 +313,7 @@ public function getKeywords()
314313
* Set Keywords
315314
*
316315
* @param string $pValue
317-
* @return PHPWord_DocumentProperties
316+
* @return PhpOffice\PhpWord\DocumentProperties
318317
*/
319318
public function setKeywords($pValue = '')
320319
{
@@ -336,7 +335,7 @@ public function getCategory()
336335
* Set Category
337336
*
338337
* @param string $pValue
339-
* @return PHPWord_DocumentProperties
338+
* @return PhpOffice\PhpWord\DocumentProperties
340339
*/
341340
public function setCategory($pValue = '')
342341
{
@@ -358,7 +357,7 @@ public function getCompany()
358357
* Set Company
359358
*
360359
* @param string $pValue
361-
* @return PHPWord_DocumentProperties
360+
* @return PhpOffice\PhpWord\DocumentProperties
362361
*/
363362
public function setCompany($pValue = '')
364363
{
@@ -380,7 +379,7 @@ public function getManager()
380379
* Set Manager
381380
*
382381
* @param string $pValue
383-
* @return PHPExcel_DocumentProperties
382+
* @return PhpOffice\PhpWord\DocumentProperties
384383
*/
385384
public function setManager($pValue = '')
386385
{
@@ -448,7 +447,7 @@ public function getCustomPropertyType($propertyName)
448447
* 's': String
449448
* 'd': Date/Time
450449
* 'b': Boolean
451-
* @return PHPExcel_DocumentProperties
450+
* @return PhpOffice\PhpWord\DocumentProperties
452451
*/
453452
public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null)
454453
{
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<?php
22
namespace PhpOffice\PhpWord\Exceptions;
33

4-
/**
5-
* Class Exception
6-
*/
74
class Exception extends \Exception
85
{
96
}

Classes/PHPWord/Exceptions/InvalidImageException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
*/
1111
class InvalidImageException extends Exception
1212
{
13-
}
13+
}

Classes/PHPWord/Exceptions/UnsupportedImageTypeException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
*/
1111
class UnsupportedImageTypeException extends Exception
1212
{
13-
}
13+
}

Classes/PHPWord/Footnote.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@
2525
* @version 0.8.0
2626
*/
2727

28+
namespace PhpOffice\PhpWord;
2829

29-
/**
30-
* PHPWord_Footnote
31-
*/
32-
class PHPWord_Footnote
30+
class Footnote
3331
{
34-
3532
/**
3633
* Footnote Elements
3734
*
@@ -54,7 +51,7 @@ class PHPWord_Footnote
5451
*
5552
* @return mixed
5653
*/
57-
public static function addFootnoteElement(PHPWord_Section_Footnote $footnote)
54+
public static function addFootnoteElement(PhpOffice\PhpWord\Section\Footnote $footnote)
5855
{
5956
$refID = self::countFootnoteElements() + 2;
6057

0 commit comments

Comments
 (0)