Skip to content

Commit 8e17598

Browse files
committed
Merge pull request #115 from ivanlanin/develop
Reorganize samples and write unsupported element to ODText and RTF
2 parents f711e8a + 1aa83b9 commit 8e17598

Some content is hidden

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

41 files changed

+780
-388
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ vendor
1818
*.docx
1919
*.rtf
2020
*.txt
21-
*.xml
22-
nbproject
21+
*.xml

Classes/PHPWord/Reader/Word2007.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ public function load($pFilename)
254254
if ($elm->getName() != 'style') {
255255
continue;
256256
}
257-
unset($pStyle);
258-
unset($fStyle);
257+
$pStyle = null;
258+
$fStyle = null;
259259
$hasParagraphStyle = isset($elm->pPr);
260260
$hasFontStyle = isset($elm->rPr);
261261
$styleName = (string)$elm->name['val'];

Classes/PHPWord/Section.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ public function addObject($src, $style = null)
243243
$this->_elementCollection[] = $object;
244244
return $object;
245245
} else {
246-
trigger_error('Source does not exist or unsupported object type.');
246+
throw new PHPWord_Exception(
247+
'Source does not exist or unsupported object type.'
248+
);
247249
}
248250
}
249251

@@ -265,7 +267,9 @@ public function addImage($src, $style = null)
265267
$this->_elementCollection[] = $image;
266268
return $image;
267269
} else {
268-
trigger_error('Source does not exist or unsupported image type.');
270+
throw new PHPWord_Exception(
271+
'Source does not exist or unsupported image type.'
272+
);
269273
}
270274
}
271275

@@ -286,7 +290,9 @@ public function addMemoryImage($link, $style = null)
286290
$this->_elementCollection[] = $memoryImage;
287291
return $memoryImage;
288292
} else {
289-
trigger_error('Unsupported image type.');
293+
throw new PHPWord_Exception(
294+
'Unsupported image type.'
295+
);
290296
}
291297
}
292298

Classes/PHPWord/Section/Footer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function addImage($src, $style = null)
133133
$this->_elementCollection[] = $image;
134134
return $image;
135135
} else {
136-
trigger_error('Src does not exist or invalid image type.', E_USER_ERROR);
136+
throw new Exception('Src does not exist or invalid image type.');
137137
}
138138
}
139139

@@ -154,7 +154,7 @@ public function addMemoryImage($link, $style = null)
154154
$this->_elementCollection[] = $memoryImage;
155155
return $memoryImage;
156156
} else {
157-
trigger_error('Unsupported image type.');
157+
throw new Exception('Unsupported image type.');
158158
}
159159
}
160160

Classes/PHPWord/Section/Header.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public function addImage($src, $style = null)
162162
$this->_elementCollection[] = $image;
163163
return $image;
164164
} else {
165-
trigger_error('Src does not exist or invalid image type.', E_USER_ERROR);
165+
throw new Exception('Src does not exist or invalid image type.');
166166
}
167167
}
168168

@@ -183,7 +183,7 @@ public function addMemoryImage($link, $style = null)
183183
$this->_elementCollection[] = $memoryImage;
184184
return $memoryImage;
185185
} else {
186-
trigger_error('Unsupported image type.');
186+
throw new Exception('Unsupported image type.');
187187
}
188188
}
189189

@@ -223,7 +223,7 @@ public function addWatermark($src, $style = null)
223223
$this->_elementCollection[] = $image;
224224
return $image;
225225
} else {
226-
trigger_error('Src does not exist or invalid image type.', E_USER_ERROR);
226+
throw new Exception('Src does not exist or invalid image type.');
227227
}
228228
}
229229

Classes/PHPWord/Section/MemoryImage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,4 @@ public function getImageExtension()
229229
{
230230
return $this->_imageExtension;
231231
}
232-
}
232+
}

Classes/PHPWord/Section/Table/Cell.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function addLink($linkSrc, $linkName = null, $style = null)
140140
$this->_elementCollection[] = $link;
141141
return $link;
142142
} else {
143-
trigger_error('Unsupported Link header / footer reference');
143+
throw new Exception('Unsupported Link header / footer reference');
144144
return false;
145145
}
146146
}
@@ -198,7 +198,7 @@ public function addImage($src, $style = null)
198198
$this->_elementCollection[] = $image;
199199
return $image;
200200
} else {
201-
trigger_error('Source does not exist or unsupported image type.');
201+
throw new Exception('Source does not exist or unsupported image type.');
202202
}
203203
}
204204

@@ -225,7 +225,7 @@ public function addMemoryImage($link, $style = null)
225225
$this->_elementCollection[] = $memoryImage;
226226
return $memoryImage;
227227
} else {
228-
trigger_error('Unsupported image type.');
228+
throw new Exception('Unsupported image type.');
229229
}
230230
}
231231

@@ -266,7 +266,7 @@ public function addObject($src, $style = null)
266266
$this->_elementCollection[] = $object;
267267
return $object;
268268
} else {
269-
trigger_error('Source does not exist or unsupported object type.');
269+
throw new Exception('Source does not exist or unsupported object type.');
270270
}
271271
}
272272

@@ -288,7 +288,7 @@ public function addPreserveText($text, $styleFont = null, $styleParagraph = null
288288
$this->_elementCollection[] = $ptext;
289289
return $ptext;
290290
} else {
291-
trigger_error('addPreserveText only supported in footer/header.');
291+
throw new Exception('addPreserveText only supported in footer/header.');
292292
}
293293
}
294294

Classes/PHPWord/Section/TextRun.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function addImage($imageSrc, $style = null)
127127
$this->_elementCollection[] = $image;
128128
return $image;
129129
} else {
130-
trigger_error('Source does not exist or unsupported image type.');
130+
throw new Exception('Source does not exist or unsupported image type.');
131131
}
132132
}
133133

Classes/PHPWord/Settings.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
/**
2929
* PHPWord_Settings
3030
*/
31-
class PHPWord_Settings {
31+
class PHPWord_Settings
32+
{
3233
/**
3334
* Compatibility option for XMLWriter
3435
*
@@ -42,12 +43,13 @@ class PHPWord_Settings {
4243
* @param boolean $compatibility This sets the setIndent and setIndentString for better compatibility
4344
* @return boolean Success or failure
4445
*/
45-
public static function setCompatibility($compatibility) {
46+
public static function setCompatibility($compatibility)
47+
{
4648
if (is_bool($compatibility)) {
4749
self::$_xmlWriterCompatibility = $compatibility;
48-
return TRUE;
50+
return true;
4951
}
50-
return FALSE;
52+
return false;
5153
} // function setCompatibility()
5254

5355

@@ -56,7 +58,8 @@ public static function setCompatibility($compatibility) {
5658
*
5759
* @return boolean Compatibility
5860
*/
59-
public static function getCompatibility() {
61+
public static function getCompatibility()
62+
{
6063
return self::$_xmlWriterCompatibility;
6164
} // function getCompatibility()
62-
}
65+
}

Classes/PHPWord/Style/Font.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ public function __construct($type = 'text', $paragraphStyle = null)
179179
} elseif (is_array($paragraphStyle)) {
180180
$this->_paragraphStyle = new PHPWord_Style_Paragraph;
181181
$this->_paragraphStyle->setArrayStyle($paragraphStyle);
182-
} elseif (null === $paragraphStyle) {
183-
$this->_paragraphStyle = new PHPWord_Style_Paragraph;
184182
} else {
185183
$this->_paragraphStyle = $paragraphStyle;
186184
}

0 commit comments

Comments
 (0)