Skip to content

Commit 39e4dd2

Browse files
author
Gabriel Bull
committed
Merge branch 'master' of https://github.com/PHPOffice/PHPWord
Conflicts: .gitignore Classes/PHPWord.php Classes/PHPWord/Section.php Classes/PHPWord/Section/Footer.php Classes/PHPWord/Section/Header.php Classes/PHPWord/Section/Table/Cell.php Classes/PHPWord/Section/TextRun.php Classes/PHPWord/Shared/String.php Classes/PHPWord/Style/Cell.php Classes/PHPWord/Style/Paragraph.php Classes/PHPWord/Template.php Classes/PHPWord/Writer/Word2007.php Classes/PHPWord/Writer/Word2007/Base.php Classes/PHPWord/Writer/Word2007/Document.php Examples/AdvancedTable.php Examples/BasicTable.php Examples/HeaderFooter.php Examples/Link.php Examples/ListItem.php Examples/Object.php Examples/Section.php Examples/Template.php Examples/Textrun.php Examples/TitleTOC.php Examples/Watermark.php Examples/_earth.JPG Examples/_mars.jpg Examples/_sheet.xls changelog.txt samples/old/AdvancedTable.php samples/old/BasicTable.php samples/old/Image.php samples/old/Link.php samples/old/ListItem.php samples/old/Object.php samples/old/Section.php samples/old/Template.php samples/old/Textrun.php samples/old/TitleTOC.php samples/old/Watermark.php samples/old/_earth.jpg samples/old/_mars.jpg samples/old/_sheet.xls src/Examples/AdvancedTable.php src/Examples/BasicTable.php src/Examples/Link.php src/Examples/ListItem.php src/Examples/Object.php src/Examples/Section.php src/Examples/Template.php src/Examples/Textrun.php src/Examples/TitleTOC.php src/Examples/Watermark.php src/Examples/_earth.JPG src/Examples/_mars.jpg src/Examples/_sheet.xls
2 parents 5c6319f + fa7de9c commit 39e4dd2

Some content is hidden

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

106 files changed

+4340
-3909
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ vendor
1313
/.buildpath
1414
/.project
1515
/docs
16+
*.odt
17+
*.docx
18+
*.rtf
19+
*.txt
20+
*.xml

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ before_script:
2626

2727
script:
2828
## PHP_CodeSniffer
29-
- phpcs --standard=PSR1 src/
30-
- phpcs --standard=PSR2 src/
29+
- phpcs --standard=PSR1 Classes/
30+
- phpcs --standard=PSR2 Classes/
3131
## PHP Copy/Paste Detector
32-
- php phpcpd.phar --verbose src/
32+
- php phpcpd.phar --verbose Classes/
3333
## PHP Mess Detector
34-
- phpmd src/ text codesize,unusedcode,naming,design
34+
- phpmd Classes/ text codesize,unusedcode,naming,design
3535
## PHPLOC
36-
- php phploc.phar src/
36+
- php phploc.phar Classes/
3737

3838
notifications:
3939
email:

Classes/PHPWord.php

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
<?php
2+
/**
3+
* PHPWord
4+
*
5+
* Copyright (c) 2011 PHPWord
6+
*
7+
* This library is free software; you can redistribute it and/or
8+
* modify it under the terms of the GNU Lesser General Public
9+
* License as published by the Free Software Foundation; either
10+
* version 2.1 of the License, or (at your option) any later version.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* @category PHPWord
22+
* @package PHPWord
23+
* @copyright Copyright (c) 010 PHPWord
24+
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25+
* @version Beta 0.6.3, 08.07.2011
26+
*/
27+
28+
/** PHPWORD_BASE_PATH */
29+
if(!defined('PHPWORD_BASE_PATH')) {
30+
define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/');
31+
require PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php';
32+
PHPWord_Autoloader::Register();
33+
}
34+
35+
36+
/**
37+
* PHPWord
38+
*
39+
* @category PHPWord
40+
* @package PHPWord
41+
* @copyright Copyright (c) 2011 PHPWord
42+
*/
43+
class PHPWord {
44+
45+
/**
46+
* Document properties
47+
*
48+
* @var PHPWord_DocumentProperties
49+
*/
50+
private $_properties;
51+
52+
/**
53+
* Default Font Name
54+
*
55+
* @var string
56+
*/
57+
private $_defaultFontName;
58+
59+
/**
60+
* Default Font Size
61+
*
62+
* @var int
63+
*/
64+
private $_defaultFontSize;
65+
66+
/**
67+
* Collection of section elements
68+
*
69+
* @var array
70+
*/
71+
private $_sectionCollection = array();
72+
73+
74+
/**
75+
* Create a new PHPWord Document
76+
*/
77+
public function __construct() {
78+
$this->_properties = new PHPWord_DocumentProperties();
79+
$this->_defaultFontName = 'Arial';
80+
$this->_defaultFontSize = 20;
81+
}
82+
83+
/**
84+
* Get properties
85+
* @return PHPWord_DocumentProperties
86+
*/
87+
public function getProperties() {
88+
return $this->_properties;
89+
}
90+
91+
/**
92+
* Set properties
93+
*
94+
* @param PHPWord_DocumentProperties $value
95+
* @return PHPWord
96+
*/
97+
public function setProperties(PHPWord_DocumentProperties $value) {
98+
$this->_properties = $value;
99+
return $this;
100+
}
101+
102+
/**
103+
* Create a new Section
104+
*
105+
* @param PHPWord_Section_Settings $settings
106+
* @return PHPWord_Section
107+
*/
108+
public function createSection($settings = null) {
109+
$sectionCount = $this->_countSections() + 1;
110+
111+
$section = new PHPWord_Section($sectionCount, $settings);
112+
$this->_sectionCollection[] = $section;
113+
return $section;
114+
}
115+
116+
/**
117+
* Get default Font name
118+
* @return string
119+
*/
120+
public function getDefaultFontName() {
121+
return $this->_defaultFontName;
122+
}
123+
124+
/**
125+
* Set default Font name
126+
* @param string $pValue
127+
*/
128+
public function setDefaultFontName($pValue) {
129+
$this->_defaultFontName = $pValue;
130+
}
131+
132+
/**
133+
* Get default Font size
134+
* @return string
135+
*/
136+
public function getDefaultFontSize() {
137+
return $this->_defaultFontSize;
138+
}
139+
140+
/**
141+
* Set default Font size
142+
* @param int $pValue
143+
*/
144+
public function setDefaultFontSize($pValue) {
145+
$pValue = $pValue * 2;
146+
$this->_defaultFontSize = $pValue;
147+
}
148+
149+
/**
150+
* Adds a paragraph style definition to styles.xml
151+
*
152+
* @param $styleName string
153+
* @param $styles array
154+
*/
155+
public function addParagraphStyle($styleName, $styles) {
156+
PHPWord_Style::addParagraphStyle($styleName, $styles);
157+
}
158+
159+
/**
160+
* Adds a font style definition to styles.xml
161+
*
162+
* @param $styleName string
163+
* @param $styles array
164+
*/
165+
public function addFontStyle($styleName, $styleFont, $styleParagraph = null) {
166+
PHPWord_Style::addFontStyle($styleName, $styleFont, $styleParagraph);
167+
}
168+
169+
/**
170+
* Adds a table style definition to styles.xml
171+
*
172+
* @param $styleName string
173+
* @param $styles array
174+
*/
175+
public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) {
176+
PHPWord_Style::addTableStyle($styleName, $styleTable, $styleFirstRow);
177+
}
178+
179+
/**
180+
* Adds a heading style definition to styles.xml
181+
*
182+
* @param $titleCount int
183+
* @param $styles array
184+
*/
185+
public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) {
186+
PHPWord_Style::addTitleStyle($titleCount, $styleFont, $styleParagraph);
187+
}
188+
189+
/**
190+
* Adds a hyperlink style to styles.xml
191+
*
192+
* @param $styleName string
193+
* @param $styles array
194+
*/
195+
public function addLinkStyle($styleName, $styles) {
196+
PHPWord_Style::addLinkStyle($styleName, $styles);
197+
}
198+
199+
/**
200+
* Get sections
201+
* @return PHPWord_Section[]
202+
*/
203+
public function getSections() {
204+
return $this->_sectionCollection;
205+
}
206+
207+
/**
208+
* Get section count
209+
* @return int
210+
*/
211+
private function _countSections() {
212+
return count($this->_sectionCollection);
213+
}
214+
215+
/**
216+
* Load a Template File
217+
*
218+
* @param string $strFilename
219+
* @return PHPWord_Template
220+
*/
221+
public function loadTemplate($strFilename) {
222+
if(file_exists($strFilename)) {
223+
$template = new PHPWord_Template($strFilename);
224+
return $template;
225+
} else {
226+
trigger_error('Template file '.$strFilename.' not found.', E_USER_ERROR);
227+
}
228+
}
229+
}
File renamed without changes.

Classes/PHPWord/Exception.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* PHPWord
4+
*
5+
* Copyright (c) 2009 - 2010 PHPWord
6+
*
7+
* This library is free software; you can redistribute it and/or
8+
* modify it under the terms of the GNU Lesser General Public
9+
* License as published by the Free Software Foundation; either
10+
* version 2.1 of the License, or (at your option) any later version.
11+
*
12+
* This library is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this library; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
*
21+
* @category PHPWord
22+
* @package PHPWord
23+
* @copyright Copyright (c) 2009 - 2010 PHPWord (http://www.codeplex.com/PHPWord)
24+
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25+
* @version ##VERSION##, ##DATE##
26+
*/
27+
28+
29+
/**
30+
* PHPWord_Exception
31+
*
32+
* @category PHPWord
33+
* @package PHPWord
34+
* @copyright Copyright (c) 2006 - 2013 PHPWord (http://www.codeplex.com/PHPWord)
35+
*/
36+
class PHPWord_Exception extends Exception {
37+
/**
38+
* Error handler callback
39+
*
40+
* @param mixed $code
41+
* @param mixed $string
42+
* @param mixed $file
43+
* @param mixed $line
44+
* @param mixed $context
45+
*/
46+
public static function errorHandlerCallback($code, $string, $file, $line, $context) {
47+
$e = new self($string, $code);
48+
$e->line = $line;
49+
$e->file = $file;
50+
throw $e;
51+
}
52+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)