Skip to content

Commit 6837b11

Browse files
committed
Merge pull request #134 from PHPOffice/develop
Version 0.8.0
2 parents 5a6cb08 + 542451d commit 6837b11

File tree

174 files changed

+9540
-1329
lines changed

Some content is hidden

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

174 files changed

+9540
-1329
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ phpunit.xml
99
composer.lock
1010
composer.phar
1111
vendor
12+
/report
1213
/.settings
1314
/.buildpath
1415
/.project

Classes/PHPWord.php

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,42 @@
2626
*/
2727

2828
/** PHPWORD_BASE_PATH */
29+
// @codeCoverageIgnoreStart
2930
if (!defined('PHPWORD_BASE_PATH')) {
3031
define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/');
3132
require PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php';
3233
PHPWord_Autoloader::Register();
3334
}
34-
35+
// @codeCoverageIgnoreEnd
3536

3637
/**
3738
* PHPWord
3839
*/
3940
class PHPWord
4041
{
4142

43+
/**
44+
* Default font name (Arial)
45+
*/
46+
const DEFAULT_FONT_NAME = 'Arial';
47+
/**
48+
* Default Font Content Type(default)
49+
* default|eastAsia|cs
50+
*/
51+
const DEFAULT_FONT_CONTENT_TYPE='default';
52+
/**
53+
* Default font size in points (10pt)
54+
*
55+
* OOXML defined font size values in halfpoints, i.e. twice of what PHPWord
56+
* use, and the conversion will be conducted during XML writing.
57+
*/
58+
const DEFAULT_FONT_SIZE = 10;
59+
60+
/**
61+
* Default font color (black)
62+
*/
63+
const DEFAULT_FONT_COLOR = '000000';
64+
4265
/**
4366
* Document properties
4467
*
@@ -74,8 +97,8 @@ class PHPWord
7497
public function __construct()
7598
{
7699
$this->_properties = new PHPWord_DocumentProperties();
77-
$this->_defaultFontName = 'Arial';
78-
$this->_defaultFontSize = 20;
100+
$this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME;
101+
$this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE;
79102
}
80103

81104
/**
@@ -133,7 +156,7 @@ public function setDefaultFontName($pValue)
133156
}
134157

135158
/**
136-
* Get default Font size
159+
* Get default Font size (in points)
137160
* @return string
138161
*/
139162
public function getDefaultFontSize()
@@ -142,15 +165,24 @@ public function getDefaultFontSize()
142165
}
143166

144167
/**
145-
* Set default Font size
168+
* Set default Font size (in points)
146169
* @param int $pValue
147170
*/
148171
public function setDefaultFontSize($pValue)
149172
{
150-
$pValue = $pValue * 2;
151173
$this->_defaultFontSize = $pValue;
152174
}
153175

176+
/**
177+
* Set default paragraph style definition to styles.xml
178+
*
179+
* @param array $styles Paragraph style definition
180+
*/
181+
public function setDefaultParagraphStyle($styles)
182+
{
183+
PHPWord_Style::setDefaultParagraphStyle($styles);
184+
}
185+
154186
/**
155187
* Adds a paragraph style definition to styles.xml
156188
*
@@ -215,15 +247,6 @@ public function getSections()
215247
return $this->_sectionCollection;
216248
}
217249

218-
/**
219-
* Get section count
220-
* @return int
221-
*/
222-
private function _countSections()
223-
{
224-
return count($this->_sectionCollection);
225-
}
226-
227250
/**
228251
* Load a Template File
229252
*
@@ -236,7 +259,18 @@ public function loadTemplate($strFilename)
236259
$template = new PHPWord_Template($strFilename);
237260
return $template;
238261
} else {
239-
trigger_error('Template file ' . $strFilename . ' not found.', E_USER_ERROR);
262+
throw new PHPWord_Exception(
263+
"Template file {$strFilename} not found."
264+
);
240265
}
241266
}
242-
}
267+
268+
/**
269+
* Get section count
270+
* @return int
271+
*/
272+
private function _countSections()
273+
{
274+
return count($this->_sectionCollection);
275+
}
276+
}

Classes/PHPWord/Autoloader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*/
3737
class PHPWord_Autoloader
3838
{
39-
const PREFIX = 'PHPWord';
39+
const PREFIX = 'PhpOffice\PhpWord';
4040

4141
/**
4242
* Register the autoloader
@@ -82,4 +82,4 @@ public static function autoload($class)
8282
}
8383
}
8484
}
85-
}
85+
}

0 commit comments

Comments
 (0)