general updates

Change "some" code to comply to php-cs rules
Update copyright year to 2010-2017
This commit is contained in:
troosan 2017-09-24 22:15:42 +02:00
commit a8ade6d22d
383 changed files with 1287 additions and 1805 deletions

View File

@ -1,8 +1,8 @@
<?php <?php
$finder = PhpCsFixer\Finder::create() $finder = PhpCsFixer\Finder::create()
->exclude('vendor') ->notName('pclzip.lib.php')
->notPath('src/PhpWord/Shared/PCLZip/pclzip.lib.php') ->notName('OLERead.php')
->in('samples') ->in('samples')
->in('src') ->in('src')
->in('tests'); ->in('tests');
@ -10,18 +10,18 @@ $finder = PhpCsFixer\Finder::create()
return PhpCsFixer\Config::create() return PhpCsFixer\Config::create()
->setRiskyAllowed(true) ->setRiskyAllowed(true)
->setFinder($finder) ->setFinder($finder)
->setRules([ ->setRules(array(
'array_syntax' => ['syntax' => 'long'], 'array_syntax' => array('syntax' => 'long'),
'binary_operator_spaces' => ['align_double_arrow' => true], 'binary_operator_spaces' => array('align_double_arrow' => true),
'blank_line_after_namespace' => true, 'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true, 'blank_line_after_opening_tag' => false,
'blank_line_before_return' => true, 'blank_line_before_return' => true,
'braces' => true, 'braces' => true,
'cast_spaces' => true, 'cast_spaces' => true,
'class_definition' => true, 'class_definition' => true,
'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE 'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE
'combine_consecutive_unsets' => true, 'combine_consecutive_unsets' => true,
'concat_space' => ['spacing' => 'one'], 'concat_space' => array('spacing' => 'one'),
'declare_equal_normalize' => true, 'declare_equal_normalize' => true,
'declare_strict_types' => false, // Too early to adopt strict types 'declare_strict_types' => false, // Too early to adopt strict types
'dir_constant' => true, 'dir_constant' => true,
@ -58,7 +58,7 @@ return PhpCsFixer\Config::create()
'no_empty_comment' => true, 'no_empty_comment' => true,
'no_empty_phpdoc' => true, 'no_empty_phpdoc' => true,
'no_empty_statement' => true, 'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'useTrait', 'curly_brace_block', 'parenthesis_brace_block', 'square_brace_block'], 'no_extra_consecutive_blank_lines' => array('break', 'continue', 'extra', 'return', 'throw', 'use', 'useTrait', 'curly_brace_block', 'parenthesis_brace_block', 'square_brace_block'),
'no_leading_import_slash' => true, 'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true, 'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => true, 'no_mixed_echo_print' => true,
@ -99,7 +99,7 @@ return PhpCsFixer\Config::create()
'phpdoc_inline_tag' => true, 'phpdoc_inline_tag' => true,
'phpdoc_no_access' => true, 'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => false, //@see instead of @link 'phpdoc_no_alias_tag' => false, //@see instead of @link
'phpdoc_no_empty_return' => true, 'phpdoc_no_empty_return' => false, //TODO: reactivate
'phpdoc_no_package' => true, 'phpdoc_no_package' => true,
'phpdoc_no_useless_inheritdoc' => true, 'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_order' => true, 'phpdoc_order' => true,
@ -113,7 +113,7 @@ return PhpCsFixer\Config::create()
'phpdoc_types' => true, 'phpdoc_types' => true,
'phpdoc_var_without_name' => true, 'phpdoc_var_without_name' => true,
'pow_to_exponentiation' => false, 'pow_to_exponentiation' => false,
'pre_increment' => true, 'pre_increment' => false,
'protected_to_private' => true, 'protected_to_private' => true,
'psr0' => true, 'psr0' => true,
'psr4' => true, 'psr4' => true,
@ -143,4 +143,4 @@ return PhpCsFixer\Config::create()
'unary_operator_spaces' => true, 'unary_operator_spaces' => true,
'visibility_required' => true, 'visibility_required' => true,
'whitespace_after_comma_in_array' => true, 'whitespace_after_comma_in_array' => true,
]); ));

View File

@ -22,6 +22,7 @@ cache:
directories: directories:
- vendor - vendor
- $HOME/.composer/cache - $HOME/.composer/cache
- $HOME/.php-cs-fixer
env: env:
global: global:
@ -46,7 +47,7 @@ script:
## PHP_CodeSniffer ## PHP_CodeSniffer
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip ; fi - if [ -z "$COVERAGE" ]; then ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip ; fi
## PHP-CS-Fixer ## PHP-CS-Fixer
#- if [ -z "$COVERAGE" ]; then ./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run ; fi - if [ -z "$COVERAGE" ]; then ./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run --cache-dir=$HOME/.php-cs-fixer ; fi
## PHP Mess Detector ## PHP Mess Detector
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php ; fi - if [ -z "$COVERAGE" ]; then ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php ; fi
## PHPUnit ## PHPUnit

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. test bootstrap * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. test bootstrap
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */

14
run_tests.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
## PHP_CodeSniffer
./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
## PHP-CS-Fixer
./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run
## PHP Mess Detector
./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
## PHPUnit
./vendor/bin/phpunit -c ./ --no-coverage

View File

@ -14,7 +14,7 @@ $phpWord->addParagraphStyle(
new \PhpOffice\PhpWord\Style\Tab('left', 1550), new \PhpOffice\PhpWord\Style\Tab('left', 1550),
new \PhpOffice\PhpWord\Style\Tab('center', 3200), new \PhpOffice\PhpWord\Style\Tab('center', 3200),
new \PhpOffice\PhpWord\Style\Tab('right', 5300), new \PhpOffice\PhpWord\Style\Tab('right', 5300),
) ),
) )
); );

View File

@ -1,62 +1,62 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
// Template processor instance creation // Template processor instance creation
echo date('H:i:s'), ' Creating new TemplateProcessor instance...', EOL; echo date('H:i:s'), ' Creating new TemplateProcessor instance...', EOL;
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx'); $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx');
// Variables on different parts of document // Variables on different parts of document
$templateProcessor->setValue('weekday', date('l')); // On section/content $templateProcessor->setValue('weekday', date('l')); // On section/content
$templateProcessor->setValue('time', date('H:i')); // On footer $templateProcessor->setValue('time', date('H:i')); // On footer
$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header $templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
// Simple table // Simple table
$templateProcessor->cloneRow('rowValue', 10); $templateProcessor->cloneRow('rowValue', 10);
$templateProcessor->setValue('rowValue#1', 'Sun'); $templateProcessor->setValue('rowValue#1', 'Sun');
$templateProcessor->setValue('rowValue#2', 'Mercury'); $templateProcessor->setValue('rowValue#2', 'Mercury');
$templateProcessor->setValue('rowValue#3', 'Venus'); $templateProcessor->setValue('rowValue#3', 'Venus');
$templateProcessor->setValue('rowValue#4', 'Earth'); $templateProcessor->setValue('rowValue#4', 'Earth');
$templateProcessor->setValue('rowValue#5', 'Mars'); $templateProcessor->setValue('rowValue#5', 'Mars');
$templateProcessor->setValue('rowValue#6', 'Jupiter'); $templateProcessor->setValue('rowValue#6', 'Jupiter');
$templateProcessor->setValue('rowValue#7', 'Saturn'); $templateProcessor->setValue('rowValue#7', 'Saturn');
$templateProcessor->setValue('rowValue#8', 'Uranus'); $templateProcessor->setValue('rowValue#8', 'Uranus');
$templateProcessor->setValue('rowValue#9', 'Neptun'); $templateProcessor->setValue('rowValue#9', 'Neptun');
$templateProcessor->setValue('rowValue#10', 'Pluto'); $templateProcessor->setValue('rowValue#10', 'Pluto');
$templateProcessor->setValue('rowNumber#1', '1'); $templateProcessor->setValue('rowNumber#1', '1');
$templateProcessor->setValue('rowNumber#2', '2'); $templateProcessor->setValue('rowNumber#2', '2');
$templateProcessor->setValue('rowNumber#3', '3'); $templateProcessor->setValue('rowNumber#3', '3');
$templateProcessor->setValue('rowNumber#4', '4'); $templateProcessor->setValue('rowNumber#4', '4');
$templateProcessor->setValue('rowNumber#5', '5'); $templateProcessor->setValue('rowNumber#5', '5');
$templateProcessor->setValue('rowNumber#6', '6'); $templateProcessor->setValue('rowNumber#6', '6');
$templateProcessor->setValue('rowNumber#7', '7'); $templateProcessor->setValue('rowNumber#7', '7');
$templateProcessor->setValue('rowNumber#8', '8'); $templateProcessor->setValue('rowNumber#8', '8');
$templateProcessor->setValue('rowNumber#9', '9'); $templateProcessor->setValue('rowNumber#9', '9');
$templateProcessor->setValue('rowNumber#10', '10'); $templateProcessor->setValue('rowNumber#10', '10');
// Table with a spanned cell // Table with a spanned cell
$templateProcessor->cloneRow('userId', 3); $templateProcessor->cloneRow('userId', 3);
$templateProcessor->setValue('userId#1', '1'); $templateProcessor->setValue('userId#1', '1');
$templateProcessor->setValue('userFirstName#1', 'James'); $templateProcessor->setValue('userFirstName#1', 'James');
$templateProcessor->setValue('userName#1', 'Taylor'); $templateProcessor->setValue('userName#1', 'Taylor');
$templateProcessor->setValue('userPhone#1', '+1 428 889 773'); $templateProcessor->setValue('userPhone#1', '+1 428 889 773');
$templateProcessor->setValue('userId#2', '2'); $templateProcessor->setValue('userId#2', '2');
$templateProcessor->setValue('userFirstName#2', 'Robert'); $templateProcessor->setValue('userFirstName#2', 'Robert');
$templateProcessor->setValue('userName#2', 'Bell'); $templateProcessor->setValue('userName#2', 'Bell');
$templateProcessor->setValue('userPhone#2', '+1 428 889 774'); $templateProcessor->setValue('userPhone#2', '+1 428 889 774');
$templateProcessor->setValue('userId#3', '3'); $templateProcessor->setValue('userId#3', '3');
$templateProcessor->setValue('userFirstName#3', 'Michael'); $templateProcessor->setValue('userFirstName#3', 'Michael');
$templateProcessor->setValue('userName#3', 'Ray'); $templateProcessor->setValue('userName#3', 'Ray');
$templateProcessor->setValue('userPhone#3', '+1 428 889 775'); $templateProcessor->setValue('userPhone#3', '+1 428 889 775');
echo date('H:i:s'), ' Saving the result document...', EOL; echo date('H:i:s'), ' Saving the result document...', EOL;
$templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx'); $templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx');
echo getEndingNotes(array('Word2007' => 'docx')); echo getEndingNotes(array('Word2007' => 'docx'));
if (!CLI) { if (!CLI) {
include_once 'Sample_Footer.php'; include_once 'Sample_Footer.php';
} }

View File

@ -19,7 +19,7 @@ $section->addText(
'Below are the samples on how to control your paragraph ' 'Below are the samples on how to control your paragraph '
. 'pagination. See "Line and Page Break" tab on paragraph properties ' . 'pagination. See "Line and Page Break" tab on paragraph properties '
. 'window to see the attribute set by these controls.', . 'window to see the attribute set by these controls.',
array('bold' => true), array('bold' => true),
array('space' => array('before' => 360, 'after' => 480)) array('space' => array('before' => 360, 'after' => 480))
); );

View File

@ -46,11 +46,11 @@ for ($i = 1; $i <= 8; $i++) {
$table->addCell(2000)->addText("Cell {$i}"); $table->addCell(2000)->addText("Cell {$i}");
$table->addCell(2000)->addText("Cell {$i}"); $table->addCell(2000)->addText("Cell {$i}");
$table->addCell(2000)->addText("Cell {$i}"); $table->addCell(2000)->addText("Cell {$i}");
$text = (0== $i % 2) ? 'X' : ''; $text = (0 == $i % 2) ? 'X' : '';
$table->addCell(500)->addText($text); $table->addCell(500)->addText($text);
} }
/** /*
* 3. colspan (gridSpan) and rowspan (vMerge) * 3. colspan (gridSpan) and rowspan (vMerge)
* --------------------- * ---------------------
* | | B | | * | | B | |
@ -93,7 +93,7 @@ $table->addCell(2000, $cellVCentered)->addText('C', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered); $table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered);
$table->addCell(null, $cellRowContinue); $table->addCell(null, $cellRowContinue);
/** /*
* 4. colspan (gridSpan) and rowspan (vMerge) * 4. colspan (gridSpan) and rowspan (vMerge)
* --------------------- * ---------------------
* | | B | 1 | * | | B | 1 |
@ -104,6 +104,7 @@ $table->addCell(null, $cellRowContinue);
* --------------------- * ---------------------
* @see https://github.com/PHPOffice/PHPWord/issues/806 * @see https://github.com/PHPOffice/PHPWord/issues/806
*/ */
$section->addPageBreak(); $section->addPageBreak();
$section->addText('Table with colspan and rowspan', $header); $section->addText('Table with colspan and rowspan', $header);
@ -114,12 +115,12 @@ $table = $section->addTable('Colspan Rowspan');
$row = $table->addRow(); $row = $table->addRow();
$row->addCell(null, array('vMerge' => 'restart'))->addText('A'); $row->addCell(null, array('vMerge' => 'restart'))->addText('A');
$row->addCell(null, array('gridSpan' => 2, 'vMerge' => 'restart',))->addText('B'); $row->addCell(null, array('gridSpan' => 2, 'vMerge' => 'restart'))->addText('B');
$row->addCell()->addText('1'); $row->addCell()->addText('1');
$row = $table->addRow(); $row = $table->addRow();
$row->addCell(null, array('vMerge' => 'continue')); $row->addCell(null, array('vMerge' => 'continue'));
$row->addCell(null, array('vMerge' => 'continue','gridSpan' => 2,)); $row->addCell(null, array('vMerge' => 'continue', 'gridSpan' => 2));
$row->addCell()->addText('2'); $row->addCell()->addText('2');
$row = $table->addRow(); $row = $table->addRow();
$row->addCell(null, array('vMerge' => 'continue')); $row->addCell(null, array('vMerge' => 'continue'));

View File

@ -23,7 +23,7 @@ $section->addImage($source);
// Image from string // Image from string
$source = 'resources/_mars.jpg'; $source = 'resources/_mars.jpg';
$fileContent = file_get_contents($source); $fileContent = file_get_contents($source);
$section->addText("Image from string"); $section->addText('Image from string');
$section->addImage($fileContent); $section->addImage($fileContent);
//Wrapping style //Wrapping style

View File

@ -28,7 +28,7 @@ $textrun->addText('here:');
$indexEntryText = new TextRun(); $indexEntryText = new TextRun();
$indexEntryText->addText('My '); $indexEntryText->addText('My ');
$indexEntryText->addText('bold index', ['bold' => true]); $indexEntryText->addText('bold index', array('bold' => true));
$indexEntryText->addText(' entry'); $indexEntryText->addText(' entry');
$textrun = $section->addTextRun(); $textrun = $section->addTextRun();

View File

@ -47,7 +47,7 @@ $image->setCommentRangeStart($commentOnImage);
$section->addTextBreak(2); $section->addTextBreak(2);
// We can also do things the other way round, link the comment to the element // We can also do things the other way round, link the comment to the element
$anotherText = $section->addText("another text"); $anotherText = $section->addText('another text');
$comment1 = new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials'); $comment1 = new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials');
$comment1->addText('Test', array('bold' => true)); $comment1->addText('Test', array('bold' => true));
@ -55,7 +55,6 @@ $comment1->setStartElement($anotherText);
$comment1->setEndElement($anotherText); $comment1->setEndElement($anotherText);
$phpWord->addComment($comment1); $phpWord->addComment($comment1);
// Save file // Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers); echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) { if (!CLI) {

View File

@ -89,8 +89,8 @@ function getEndingNotes($writers)
// Do not show execution time for index // Do not show execution time for index
if (!IS_INDEX) { if (!IS_INDEX) {
$result .= date('H:i:s') . " Done writing file(s)" . EOL; $result .= date('H:i:s') . ' Done writing file(s)' . EOL;
$result .= date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" . EOL; $result .= date('H:i:s') . ' Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . ' MB' . EOL;
} }
// Return // Return

View File

@ -13,7 +13,7 @@ $requirements = array(
'xsl' => array('PHP extension XSL (optional)', extension_loaded('xsl')), 'xsl' => array('PHP extension XSL (optional)', extension_loaded('xsl')),
); );
if (!CLI) { if (!CLI) {
?> ?>
<div class="jumbotron"> <div class="jumbotron">
<p>Welcome to PHPWord, a library written in pure PHP that provides a set of classes to write to and read from different document file formats, i.e. Office Open XML (.docx), Open Document Format (.odt), and Rich Text Format (.rtf).</p> <p>Welcome to PHPWord, a library written in pure PHP that provides a set of classes to write to and read from different document file formats, i.e. Office Open XML (.docx), Open Document Format (.odt), and Rich Text Format (.rtf).</p>
<p>&nbsp;</p> <p>&nbsp;</p>
@ -25,14 +25,14 @@ if (!CLI) {
<?php <?php
} }
if (!CLI) { if (!CLI) {
echo "<h3>Requirement check:</h3>"; echo '<h3>Requirement check:</h3>';
echo "<ul>"; echo '<ul>';
foreach ($requirements as $key => $value) { foreach ($requirements as $key => $value) {
list($label, $result) = $value; list($label, $result) = $value;
$status = $result ? 'passed' : 'failed'; $status = $result ? 'passed' : 'failed';
echo "<li>{$label} ... <span class='{$status}'>{$status}</span></li>"; echo "<li>{$label} ... <span class='{$status}'>{$status}</span></li>";
} }
echo "</ul>"; echo '</ul>';
include_once 'Sample_Footer.php'; include_once 'Sample_Footer.php';
} else { } else {
echo 'Requirement check:' . PHP_EOL; echo 'Requirement check:' . PHP_EOL;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**
@ -51,9 +50,9 @@ abstract class AbstractCollection
{ {
if (array_key_exists($index, $this->items)) { if (array_key_exists($index, $this->items)) {
return $this->items[$index]; return $this->items[$index];
} else {
return null;
} }
return null;
} }
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Collection; namespace PhpOffice\PhpWord\Collection;
/** /**

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\ComplexType; namespace PhpOffice\PhpWord\ComplexType;
@ -25,7 +25,6 @@ use PhpOffice\PhpWord\SimpleType\NumberFormat;
*/ */
final class FootnoteProperties final class FootnoteProperties
{ {
const RESTART_NUMBER_CONTINUOUS = 'continuous'; const RESTART_NUMBER_CONTINUOUS = 'continuous';
const RESTART_NUMBER_EACH_SECTION = 'eachSect'; const RESTART_NUMBER_EACH_SECTION = 'eachSect';
const RESTART_NUMBER_EACH_PAGE = 'eachPage'; const RESTART_NUMBER_EACH_PAGE = 'eachPage';
@ -52,7 +51,7 @@ final class FootnoteProperties
/** /**
* Footnote and Endnote Numbering Starting Value * Footnote and Endnote Numbering Starting Value
* *
* @var double * @var float
*/ */
private $numStart; private $numStart;
@ -65,7 +64,7 @@ final class FootnoteProperties
/** /**
* Get the Footnote Positioning Location * Get the Footnote Positioning Location
* *
* @return string * @return string
*/ */
public function getPos() public function getPos()
@ -75,7 +74,7 @@ final class FootnoteProperties
/** /**
* Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd) * Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd)
* *
* @param string $pos * @param string $pos
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return self * @return self
@ -86,20 +85,21 @@ final class FootnoteProperties
self::POSITION_PAGE_BOTTOM, self::POSITION_PAGE_BOTTOM,
self::POSITION_BENEATH_TEXT, self::POSITION_BENEATH_TEXT,
self::POSITION_SECTION_END, self::POSITION_SECTION_END,
self::POSITION_DOC_END self::POSITION_DOC_END,
); );
if (in_array($pos, $position)) { if (in_array($pos, $position)) {
$this->pos = $pos; $this->pos = $pos;
} else { } else {
throw new \InvalidArgumentException("Invalid value, on of " . implode(', ', $position) . " possible"); throw new \InvalidArgumentException('Invalid value, on of ' . implode(', ', $position) . ' possible');
} }
return $this; return $this;
} }
/** /**
* Get the Footnote Numbering Format * Get the Footnote Numbering Format
* *
* @return string * @return string
*/ */
public function getNumFmt() public function getNumFmt()
@ -109,7 +109,7 @@ final class FootnoteProperties
/** /**
* Set the Footnote Numbering Format * Set the Footnote Numbering Format
* *
* @param string $numFmt One of NumberFormat * @param string $numFmt One of NumberFormat
* @return self * @return self
*/ */
@ -117,13 +117,14 @@ final class FootnoteProperties
{ {
NumberFormat::validate($numFmt); NumberFormat::validate($numFmt);
$this->numFmt = $numFmt; $this->numFmt = $numFmt;
return $this; return $this;
} }
/** /**
* Get the Footnote Numbering Format * Get the Footnote Numbering Format
* *
* @return double * @return float
*/ */
public function getNumStart() public function getNumStart()
{ {
@ -132,19 +133,20 @@ final class FootnoteProperties
/** /**
* Set the Footnote Numbering Format * Set the Footnote Numbering Format
* *
* @param double $numStart * @param float $numStart
* @return self * @return self
*/ */
public function setNumStart($numStart) public function setNumStart($numStart)
{ {
$this->numStart = $numStart; $this->numStart = $numStart;
return $this; return $this;
} }
/** /**
* Get the Footnote and Endnote Numbering Starting Value * Get the Footnote and Endnote Numbering Starting Value
* *
* @return string * @return string
*/ */
public function getNumRestart() public function getNumRestart()
@ -154,7 +156,7 @@ final class FootnoteProperties
/** /**
* Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage) * Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage)
* *
* @param string $numRestart * @param string $numRestart
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return self * @return self
@ -164,14 +166,15 @@ final class FootnoteProperties
$restartNumbers = array( $restartNumbers = array(
self::RESTART_NUMBER_CONTINUOUS, self::RESTART_NUMBER_CONTINUOUS,
self::RESTART_NUMBER_EACH_SECTION, self::RESTART_NUMBER_EACH_SECTION,
self::RESTART_NUMBER_EACH_PAGE self::RESTART_NUMBER_EACH_PAGE,
); );
if (in_array($numRestart, $restartNumbers)) { if (in_array($numRestart, $restartNumbers)) {
$this->numRestart= $numRestart; $this->numRestart = $numRestart;
} else { } else {
throw new \InvalidArgumentException("Invalid value, on of " . implode(', ', $restartNumbers) . " possible"); throw new \InvalidArgumentException('Invalid value, on of ' . implode(', ', $restartNumbers) . ' possible');
} }
return $this; return $this;
} }
} }

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\ComplexType; namespace PhpOffice\PhpWord\ComplexType;
@ -23,7 +23,6 @@ namespace PhpOffice\PhpWord\ComplexType;
*/ */
final class ProofState final class ProofState
{ {
/** /**
* Check Completed * Check Completed
*/ */
@ -51,7 +50,7 @@ final class ProofState
/** /**
* Set the Spell Checking State (dirty or clean) * Set the Spell Checking State (dirty or clean)
* *
* @param string $spelling * @param string $spelling
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return self * @return self
*/ */
@ -60,8 +59,9 @@ final class ProofState
if ($spelling == self::CLEAN || $spelling == self::DIRTY) { if ($spelling == self::CLEAN || $spelling == self::DIRTY) {
$this->spelling = $spelling; $this->spelling = $spelling;
} else { } else {
throw new \InvalidArgumentException("Invalid value, dirty or clean possible"); throw new \InvalidArgumentException('Invalid value, dirty or clean possible');
} }
return $this; return $this;
} }
@ -78,7 +78,7 @@ final class ProofState
/** /**
* Set the Grammatical Checking State (dirty or clean) * Set the Grammatical Checking State (dirty or clean)
* *
* @param string $grammar * @param string $grammar
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return self * @return self
*/ */
@ -87,8 +87,9 @@ final class ProofState
if ($grammar == self::CLEAN || $grammar == self::DIRTY) { if ($grammar == self::CLEAN || $grammar == self::DIRTY) {
$this->grammar = $grammar; $this->grammar = $grammar;
} else { } else {
throw new \InvalidArgumentException("Invalid value, dirty or clean possible"); throw new \InvalidArgumentException('Invalid value, dirty or clean possible');
} }
return $this; return $this;
} }

View File

@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\ComplexType; namespace PhpOffice\PhpWord\ComplexType;
@ -23,46 +23,45 @@ namespace PhpOffice\PhpWord\ComplexType;
*/ */
final class TrackChangesView final class TrackChangesView
{ {
/** /**
* Display Visual Indicator Of Markup Area * Display Visual Indicator Of Markup Area
* *
* @var boolean * @var bool
*/ */
private $markup; private $markup;
/** /**
* Display Comments * Display Comments
* *
* @var boolean * @var bool
*/ */
private $comments; private $comments;
/** /**
* Display Content Revisions * Display Content Revisions
* *
* @var boolean * @var bool
*/ */
private $insDel; private $insDel;
/** /**
* Display Formatting Revisions * Display Formatting Revisions
* *
* @var boolean * @var bool
*/ */
private $formatting; private $formatting;
/** /**
* Display Ink Annotations * Display Ink Annotations
* *
* @var boolean * @var bool
*/ */
private $inkAnnotations; private $inkAnnotations;
/** /**
* Get Display Visual Indicator Of Markup Area * Get Display Visual Indicator Of Markup Area
* *
* @return boolean True if markup is shown * @return bool True if markup is shown
*/ */
public function hasMarkup() public function hasMarkup()
{ {
@ -72,7 +71,7 @@ final class TrackChangesView
/** /**
* Set Display Visual Indicator Of Markup Area * Set Display Visual Indicator Of Markup Area
* *
* @param boolean $markup * @param bool $markup
* Set to true to show markup * Set to true to show markup
*/ */
public function setMarkup($markup) public function setMarkup($markup)
@ -83,7 +82,7 @@ final class TrackChangesView
/** /**
* Get Display Comments * Get Display Comments
* *
* @return boolean True if comments are shown * @return bool True if comments are shown
*/ */
public function hasComments() public function hasComments()
{ {
@ -93,7 +92,7 @@ final class TrackChangesView
/** /**
* Set Display Comments * Set Display Comments
* *
* @param boolean $comments * @param bool $comments
* Set to true to show comments * Set to true to show comments
*/ */
public function setComments($comments) public function setComments($comments)
@ -104,7 +103,7 @@ final class TrackChangesView
/** /**
* Get Display Content Revisions * Get Display Content Revisions
* *
* @return boolean True if content revisions are shown * @return bool True if content revisions are shown
*/ */
public function hasInsDel() public function hasInsDel()
{ {
@ -114,7 +113,7 @@ final class TrackChangesView
/** /**
* Set Display Content Revisions * Set Display Content Revisions
* *
* @param boolean $insDel * @param bool $insDel
* Set to true to show content revisions * Set to true to show content revisions
*/ */
public function setInsDel($insDel) public function setInsDel($insDel)
@ -125,7 +124,7 @@ final class TrackChangesView
/** /**
* Get Display Formatting Revisions * Get Display Formatting Revisions
* *
* @return boolean True if formatting revisions are shown * @return bool True if formatting revisions are shown
*/ */
public function hasFormatting() public function hasFormatting()
{ {
@ -135,7 +134,7 @@ final class TrackChangesView
/** /**
* Set Display Formatting Revisions * Set Display Formatting Revisions
* *
* @param boolean $insDel * @param bool $formatting
* Set to true to show formatting revisions * Set to true to show formatting revisions
*/ */
public function setFormatting($formatting) public function setFormatting($formatting)
@ -146,7 +145,7 @@ final class TrackChangesView
/** /**
* Get Display Ink Annotations * Get Display Ink Annotations
* *
* @return boolean True if ink annotations are shown * @return bool True if ink annotations are shown
*/ */
public function hasInkAnnotations() public function hasInkAnnotations()
{ {
@ -156,7 +155,7 @@ final class TrackChangesView
/** /**
* Set Display Ink Annotations * Set Display Ink Annotations
* *
* @param boolean $inkAnnotations * @param bool $inkAnnotations
* Set to true to show ink annotations * Set to true to show ink annotations
*/ */
public function setInkAnnotations($inkAnnotations) public function setInkAnnotations($inkAnnotations)

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
/** /**
@ -37,7 +36,7 @@ namespace PhpOffice\PhpWord\Element;
* @method PageBreak addPageBreak() * @method PageBreak addPageBreak()
* @method Table addTable(mixed $style = null) * @method Table addTable(mixed $style = null)
* @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false) * @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false)
* @method Object addObject(string $source, mixed $style = null) * @method \PhpOffice\PhpWord\Element\Object addObject(string $source, mixed $style = null)
* @method TextBox addTextBox(mixed $style = null) * @method TextBox addTextBox(mixed $style = null)
* @method Field addField(string $type = null, array $properties = array(), array $options = array(), mixed $text = null) * @method Field addField(string $type = null, array $properties = array(), array $options = array(), mixed $text = null)
* @method Line addLine(mixed $lineStyle = null) * @method Line addLine(mixed $lineStyle = null)
@ -83,7 +82,7 @@ abstract class AbstractContainer extends AbstractElement
'ListItem', 'ListItemRun', 'Table', 'Image', 'Object', 'ListItem', 'ListItemRun', 'Table', 'Image', 'Object',
'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field', 'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field',
'Line', 'Shape', 'Title', 'TOC', 'PageBreak', 'Line', 'Shape', 'Title', 'TOC', 'PageBreak',
'Chart', 'FormField', 'SDT', 'Comment' 'Chart', 'FormField', 'SDT', 'Comment',
); );
$functions = array(); $functions = array();
foreach ($elements as $element) { foreach ($elements as $element) {
@ -105,9 +104,8 @@ abstract class AbstractContainer extends AbstractElement
for ($i = 1; $i <= $count; $i++) { for ($i = 1; $i <= $count; $i++) {
$this->addElement($element, $fontStyle, $paragraphStyle); $this->addElement($element, $fontStyle, $paragraphStyle);
} }
// All other elements
} else { } else {
// All other elements
array_unshift($args, $element); // Prepend element name to the beginning of args array array_unshift($args, $element); // Prepend element name to the beginning of args array
return call_user_func_array(array($this, 'addElement'), $args); return call_user_func_array(array($this, 'addElement'), $args);
} }
@ -181,9 +179,8 @@ abstract class AbstractContainer extends AbstractElement
* *
* @param string $method * @param string $method
* *
* @return bool
*
* @throws \BadMethodCallException * @throws \BadMethodCallException
* @return bool
*/ */
private function checkValidity($method) private function checkValidity($method)
{ {

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Media;
@ -116,14 +115,14 @@ abstract class AbstractElement
/** /**
* The start position for the linked comment * The start position for the linked comment
* *
* @var Comment * @var Comment
*/ */
protected $commentRangeStart; protected $commentRangeStart;
/** /**
* The end position for the linked comment * The end position for the linked comment
* *
* @var Comment * @var Comment
*/ */
protected $commentRangeEnd; protected $commentRangeEnd;
@ -142,7 +141,6 @@ abstract class AbstractElement
* Set PhpWord as reference. * Set PhpWord as reference.
* *
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* @return void
*/ */
public function setPhpWord(PhpWord $phpWord = null) public function setPhpWord(PhpWord $phpWord = null)
{ {
@ -164,7 +162,6 @@ abstract class AbstractElement
* *
* @param string $docPart * @param string $docPart
* @param int $docPartId * @param int $docPartId
* @return void
*/ */
public function setDocPart($docPart, $docPartId = 1) public function setDocPart($docPart, $docPartId = 1)
{ {
@ -221,7 +218,6 @@ abstract class AbstractElement
* Set element index. * Set element index.
* *
* @param int $value * @param int $value
* @return void
*/ */
public function setElementIndex($value) public function setElementIndex($value)
{ {
@ -240,8 +236,6 @@ abstract class AbstractElement
/** /**
* Set element unique ID from 6 first digit of md5. * Set element unique ID from 6 first digit of md5.
*
* @return void
*/ */
public function setElementId() public function setElementId()
{ {
@ -262,7 +256,6 @@ abstract class AbstractElement
* Set relation Id. * Set relation Id.
* *
* @param int $value * @param int $value
* @return void
*/ */
public function setRelationId($value) public function setRelationId($value)
{ {
@ -291,15 +284,15 @@ abstract class AbstractElement
/** /**
* Set comment start * Set comment start
* *
* @param Comment $value * @param Comment $value
*/ */
public function setCommentRangeStart(Comment $value) public function setCommentRangeStart(Comment $value)
{ {
if ($this instanceof Comment) { if ($this instanceof Comment) {
throw new \InvalidArgumentException("Cannot set a Comment on a Comment"); throw new \InvalidArgumentException('Cannot set a Comment on a Comment');
} }
$this->commentRangeStart= $value; $this->commentRangeStart = $value;
$this->commentRangeStart->setStartElement($this); $this->commentRangeStart->setStartElement($this);
} }
@ -317,14 +310,13 @@ abstract class AbstractElement
* Set comment end * Set comment end
* *
* @param Comment $value * @param Comment $value
* @return void
*/ */
public function setCommentRangeEnd(Comment $value) public function setCommentRangeEnd(Comment $value)
{ {
if ($this instanceof Comment) { if ($this instanceof Comment) {
throw new \InvalidArgumentException("Cannot set a Comment on a Comment"); throw new \InvalidArgumentException('Cannot set a Comment on a Comment');
} }
$this->commentRangeEnd= $value; $this->commentRangeEnd = $value;
$this->commentRangeEnd->setEndElement($this); $this->commentRangeEnd->setEndElement($this);
} }
@ -334,7 +326,6 @@ abstract class AbstractElement
* Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell) * Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)
* *
* @param \PhpOffice\PhpWord\Element\AbstractElement $container * @param \PhpOffice\PhpWord\Element\AbstractElement $container
* @return void
*/ */
public function setParentContainer(AbstractElement $container) public function setParentContainer(AbstractElement $container)
{ {
@ -363,8 +354,6 @@ abstract class AbstractElement
* *
* - Image element needs to be passed to Media object * - Image element needs to be passed to Media object
* - Icon needs to be set for Object element * - Icon needs to be set for Object element
*
* @return void
*/ */
private function setMediaRelation() private function setMediaRelation()
{ {
@ -391,8 +380,6 @@ abstract class AbstractElement
/** /**
* Set relation Id for elements that will be registered in the Collection subnamespaces. * Set relation Id for elements that will be registered in the Collection subnamespaces.
*
* @return void
*/ */
private function setCollectionRelation() private function setCollectionRelation()
{ {
@ -411,7 +398,7 @@ abstract class AbstractElement
*/ */
public function isInSection() public function isInSection()
{ {
return ($this->docPart == 'Section'); return $this->docPart == 'Section';
} }
/** /**
@ -441,9 +428,8 @@ abstract class AbstractElement
* @param array $enum * @param array $enum
* @param mixed $default * @param mixed $default
* *
* @return mixed
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return mixed
* *
* @todo Merge with the same method in AbstractStyle * @todo Merge with the same method in AbstractStyle
*/ */

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\Common\Text as CommonText; use PhpOffice\Common\Text as CommonText;
@ -45,8 +44,8 @@ class Bookmark extends AbstractElement
*/ */
public function __construct($name) public function __construct($name)
{ {
$this->name = CommonText::toUTF8($name); $this->name = CommonText::toUTF8($name);
return $this; return $this;
} }

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Cell as CellStyle; use PhpOffice\PhpWord\Style\Cell as CellStyle;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Chart as ChartStyle; use PhpOffice\PhpWord\Style\Chart as ChartStyle;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\Common\Text as CommonText; use PhpOffice\Common\Text as CommonText;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
/** /**
@ -31,14 +30,14 @@ class Comment extends TrackChange
/** /**
* The Element where this comment starts * The Element where this comment starts
* *
* @var AbstractElement * @var AbstractElement
*/ */
private $startElement; private $startElement;
/** /**
* The Element where this comment ends * The Element where this comment ends
* *
* @var AbstractElement * @var AbstractElement
*/ */
private $endElement; private $endElement;
@ -61,6 +60,7 @@ class Comment extends TrackChange
{ {
parent::__construct($author, $date); parent::__construct($author, $date);
$this->initials = $initials; $this->initials = $initials;
return $this; return $this;
} }
@ -76,7 +76,7 @@ class Comment extends TrackChange
/** /**
* Sets the element where this comment starts * Sets the element where this comment starts
* *
* @param \PhpOffice\PhpWord\Element\AbstractElement $value * @param \PhpOffice\PhpWord\Element\AbstractElement $value
*/ */
public function setStartElement(AbstractElement $value) public function setStartElement(AbstractElement $value)
@ -89,7 +89,7 @@ class Comment extends TrackChange
/** /**
* Get the element where this comment starts * Get the element where this comment starts
* *
* @return \PhpOffice\PhpWord\Element\AbstractElement * @return \PhpOffice\PhpWord\Element\AbstractElement
*/ */
public function getStartElement() public function getStartElement()
@ -99,7 +99,7 @@ class Comment extends TrackChange
/** /**
* Sets the element where this comment ends * Sets the element where this comment ends
* *
* @param \PhpOffice\PhpWord\Element\AbstractElement $value * @param \PhpOffice\PhpWord\Element\AbstractElement $value
*/ */
public function setEndElement(AbstractElement $value) public function setEndElement(AbstractElement $value)
@ -112,7 +112,7 @@ class Comment extends TrackChange
/** /**
* Get the element where this comment ends * Get the element where this comment ends
* *
* @return \PhpOffice\PhpWord\Element\AbstractElement * @return \PhpOffice\PhpWord\Element\AbstractElement
*/ */
public function getEndElement() public function getEndElement()

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
/** /**
@ -32,36 +31,36 @@ class Field extends AbstractElement
* @var array * @var array
*/ */
protected $fieldsArray = array( protected $fieldsArray = array(
'PAGE'=>array( 'PAGE' => array(
'properties'=>array( 'properties' => array(
'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'), 'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'),
), ),
'options'=>array('PreserveFormat') 'options' => array('PreserveFormat'),
), ),
'NUMPAGES'=>array( 'NUMPAGES' => array(
'properties'=>array( 'properties' => array(
'format' => array('Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText', 'format' => array('Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText',
'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper'), 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper', ),
'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%') 'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%'),
), ),
'options'=>array('PreserveFormat') 'options' => array('PreserveFormat'),
), ),
'DATE'=>array( 'DATE' => array(
'properties'=> array( 'properties' => array(
'dateformat' =>array('d-M-yyyy', 'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-M-yy', 'yyyy-MM-dd', 'dateformat' => array('d-M-yyyy', 'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-M-yy', 'yyyy-MM-dd',
'd-MMM-yy', 'd/M/yyyy', 'd MMM. yy', 'd/M/yy', 'MMM-yy', 'd-M-yyy H:mm', 'd-M-yyyy H:mm:ss', 'd-MMM-yy', 'd/M/yyyy', 'd MMM. yy', 'd/M/yy', 'MMM-yy', 'd-M-yyy H:mm', 'd-M-yyyy H:mm:ss',
'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss') 'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss', ),
), ),
'options'=>array('PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat') 'options' => array('PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat'),
), ),
'XE'=>array( 'XE' => array(
'properties' => array(), 'properties' => array(),
'options' => array('Bold', 'Italic') 'options' => array('Bold', 'Italic'),
), ),
'INDEX'=>array( 'INDEX' => array(
'properties' => array(), 'properties' => array(),
'options' => array('PreserveFormat') 'options' => array('PreserveFormat'),
) ),
); );
/** /**
@ -113,9 +112,8 @@ class Field extends AbstractElement
* *
* @param string $type * @param string $type
* *
* @return string
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return string
*/ */
public function setType($type = null) public function setType($type = null)
{ {
@ -126,6 +124,7 @@ class Field extends AbstractElement
throw new \InvalidArgumentException("Invalid type '$type'"); throw new \InvalidArgumentException("Invalid type '$type'");
} }
} }
return $this->type; return $this->type;
} }
@ -144,9 +143,8 @@ class Field extends AbstractElement
* *
* @param array $properties * @param array $properties
* *
* @return self
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return self
*/ */
public function setProperties($properties = array()) public function setProperties($properties = array())
{ {
@ -158,6 +156,7 @@ class Field extends AbstractElement
} }
$this->properties = array_merge($this->properties, $properties); $this->properties = array_merge($this->properties, $properties);
} }
return $this->properties; return $this->properties;
} }
@ -176,9 +175,8 @@ class Field extends AbstractElement
* *
* @param array $options * @param array $options
* *
* @return self
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return self
*/ */
public function setOptions($options = array()) public function setOptions($options = array())
{ {
@ -190,6 +188,7 @@ class Field extends AbstractElement
} }
$this->options = array_merge($this->options, $options); $this->options = array_merge($this->options, $options);
} }
return $this->options; return $this->options;
} }
@ -208,9 +207,8 @@ class Field extends AbstractElement
* *
* @param string | TextRun $text * @param string | TextRun $text
* *
* @return string | TextRun
*
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
* @return string | TextRun
*/ */
public function setText($text) public function setText($text)
{ {
@ -218,9 +216,10 @@ class Field extends AbstractElement
if (is_string($text) || $text instanceof TextRun) { if (is_string($text) || $text instanceof TextRun) {
$this->text = $text; $this->text = $text;
} else { } else {
throw new \InvalidArgumentException("Invalid text"); throw new \InvalidArgumentException('Invalid text');
} }
} }
return $this->text; return $this->text;
} }

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
/** /**
@ -28,9 +27,9 @@ class Footer extends AbstractContainer
* @var string * @var string
* @link http://www.datypic.com/sc/ooxml/t-w_ST_HdrFtr.html Header or Footer Type * @link http://www.datypic.com/sc/ooxml/t-w_ST_HdrFtr.html Header or Footer Type
*/ */
const AUTO = 'default'; // default and odd pages const AUTO = 'default'; // default and odd pages
const FIRST = 'first'; const FIRST = 'first';
const EVEN = 'even'; const EVEN = 'even';
/** /**
* @var string Container type * @var string Container type

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException; use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
@ -61,7 +60,7 @@ class Image extends AbstractElement
/** /**
* Is watermark * Is watermark
* *
* @var boolean * @var bool
*/ */
private $watermark; private $watermark;
@ -96,7 +95,7 @@ class Image extends AbstractElement
/** /**
* Is memory image * Is memory image
* *
* @var boolean * @var bool
*/ */
private $memoryImage; private $memoryImage;
@ -110,7 +109,7 @@ class Image extends AbstractElement
/** /**
* Image media index * Image media index
* *
* @var integer * @var int
*/ */
private $mediaIndex; private $mediaIndex;
@ -126,7 +125,7 @@ class Image extends AbstractElement
* *
* @param string $source * @param string $source
* @param mixed $style * @param mixed $style
* @param boolean $watermark * @param bool $watermark
* *
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException * @throws \PhpOffice\PhpWord\Exception\InvalidImageException
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException * @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
@ -183,7 +182,7 @@ class Image extends AbstractElement
/** /**
* Get is watermark * Get is watermark
* *
* @return boolean * @return bool
*/ */
public function isWatermark() public function isWatermark()
{ {
@ -193,7 +192,7 @@ class Image extends AbstractElement
/** /**
* Set is watermark * Set is watermark
* *
* @param boolean $value * @param bool $value
*/ */
public function setIsWatermark($value) public function setIsWatermark($value)
{ {
@ -243,7 +242,7 @@ class Image extends AbstractElement
/** /**
* Get is memory image * Get is memory image
* *
* @return boolean * @return bool
*/ */
public function isMemImage() public function isMemImage()
{ {
@ -264,7 +263,6 @@ class Image extends AbstractElement
* Set target file name. * Set target file name.
* *
* @param string $value * @param string $value
* @return void
*/ */
public function setTarget($value) public function setTarget($value)
{ {
@ -274,7 +272,7 @@ class Image extends AbstractElement
/** /**
* Get media index * Get media index
* *
* @return integer * @return int
*/ */
public function getMediaIndex() public function getMediaIndex()
{ {
@ -284,8 +282,7 @@ class Image extends AbstractElement
/** /**
* Set media index. * Set media index.
* *
* @param integer $value * @param int $value
* @return void
*/ */
public function setMediaIndex($value) public function setMediaIndex($value)
{ {
@ -368,8 +365,6 @@ class Image extends AbstractElement
/** /**
* Check memory image, supported type, image functions, and proportional width/height. * Check memory image, supported type, image functions, and proportional width/height.
* *
* @return void
*
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException * @throws \PhpOffice\PhpWord\Exception\InvalidImageException
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException * @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
*/ */
@ -380,7 +375,7 @@ class Image extends AbstractElement
// Check image data // Check image data
if ($this->sourceType == self::SOURCE_ARCHIVE) { if ($this->sourceType == self::SOURCE_ARCHIVE) {
$imageData = $this->getArchiveImageSize($this->source); $imageData = $this->getArchiveImageSize($this->source);
} else if ($this->sourceType == self::SOURCE_STRING) { } elseif ($this->sourceType == self::SOURCE_STRING) {
$imageData = $this->getStringImageSize($this->source); $imageData = $this->getStringImageSize($this->source);
} else { } else {
$imageData = @getimagesize($this->source); $imageData = @getimagesize($this->source);
@ -407,8 +402,6 @@ class Image extends AbstractElement
/** /**
* Set source type. * Set source type.
*
* @return void
*/ */
private function setSourceType() private function setSourceType()
{ {
@ -443,9 +436,9 @@ class Image extends AbstractElement
* *
* @param string $source * @param string $source
* *
* @return array|null
*
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
*
* @return array|null
*/ */
private function getArchiveImageSize($source) private function getArchiveImageSize($source)
{ {
@ -476,26 +469,26 @@ class Image extends AbstractElement
/** /**
* get image size from string * get image size from string
* *
* @param string $source * @param string $source
* *
* @codeCoverageIgnore this method is just a replacement for getimagesizefromstring which exists only as of PHP 5.4 * @codeCoverageIgnore this method is just a replacement for getimagesizefromstring which exists only as of PHP 5.4
*/ */
private function getStringImageSize($source) private function getStringImageSize($source)
{ {
$result = false;
if (!function_exists('getimagesizefromstring')) { if (!function_exists('getimagesizefromstring')) {
$uri = 'data://application/octet-stream;base64,' . base64_encode($source); $uri = 'data://application/octet-stream;base64,' . base64_encode($source);
return @getimagesize($uri); $result = @getimagesize($uri);
} else { } else {
return @getimagesizefromstring($source); $result = @getimagesizefromstring($source);
} }
return false;
return $result;
} }
/** /**
* Set image functions and extensions. * Set image functions and extensions.
*
* @return void
*/ */
private function setFunctions() private function setFunctions()
{ {
@ -530,9 +523,8 @@ class Image extends AbstractElement
/** /**
* Set proportional width/height if one dimension not available. * Set proportional width/height if one dimension not available.
* *
* @param integer $actualWidth * @param int $actualWidth
* @param integer $actualHeight * @param int $actualHeight
* @return void
*/ */
private function setProportionalSize($actualWidth, $actualHeight) private function setProportionalSize($actualWidth, $actualHeight)
{ {

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Line as LineStyle; use PhpOffice\PhpWord\Style\Line as LineStyle;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\Common\Text as CommonText; use PhpOffice\Common\Text as CommonText;
@ -75,6 +74,7 @@ class Link extends AbstractElement
* @param string $text * @param string $text
* @param mixed $fontStyle * @param mixed $fontStyle
* @param mixed $paragraphStyle * @param mixed $paragraphStyle
* @param bool $internal
*/ */
public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false) public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
{ {
@ -83,6 +83,7 @@ class Link extends AbstractElement
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle); $this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle); $this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
$this->internal = $internal; $this->internal = $internal;
return $this; return $this;
} }

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\Common\Text as CommonText; use PhpOffice\Common\Text as CommonText;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle; use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
@ -74,10 +73,10 @@ class ListItemRun extends TextRun
return $this->style; return $this->style;
} }
/** /**
* Get ListItem depth. * Get ListItem depth.
* *
* @return int * @return int
*/ */
public function getDepth() public function getDepth()
{ {

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Exception\InvalidObjectException; use PhpOffice\PhpWord\Exception\InvalidObjectException;
@ -84,9 +83,9 @@ class Object extends AbstractElement
$this->icon = realpath(__DIR__ . "/../resources/{$ext}.png"); $this->icon = realpath(__DIR__ . "/../resources/{$ext}.png");
return $this; return $this;
} else {
throw new InvalidObjectException();
} }
throw new InvalidObjectException();
} }
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\Common\Text as CommonText; use PhpOffice\Common\Text as CommonText;
@ -47,7 +46,6 @@ class PreserveText extends AbstractElement
*/ */
private $paragraphStyle; private $paragraphStyle;
/** /**
* Create a new Preserve Text Element * Create a new Preserve Text Element
* *

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Row as RowStyle; use PhpOffice\PhpWord\Style\Row as RowStyle;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\ComplexType\FootnoteProperties; use PhpOffice\PhpWord\ComplexType\FootnoteProperties;
@ -50,7 +49,7 @@ class Section extends AbstractContainer
/** /**
* The properties for the footnote of this section * The properties for the footnote of this section
* *
* @var FootnoteProperties * @var FootnoteProperties
*/ */
private $footnoteProperties; private $footnoteProperties;
@ -148,7 +147,7 @@ class Section extends AbstractContainer
/** /**
* Get the footnote properties * Get the footnote properties
* *
* @return \PhpOffice\PhpWord\Element\FooterProperties * @return \PhpOffice\PhpWord\Element\FooterProperties
*/ */
public function getFootnotePropoperties() public function getFootnotePropoperties()
@ -158,7 +157,7 @@ class Section extends AbstractContainer
/** /**
* Set the footnote properties * Set the footnote properties
* *
* @param FootnoteProperties $footnoteProperties * @param FootnoteProperties $footnoteProperties
*/ */
public function setFootnoteProperties(FootnoteProperties $footnoteProperties = null) public function setFootnoteProperties(FootnoteProperties $footnoteProperties = null)
@ -172,7 +171,7 @@ class Section extends AbstractContainer
* If any of the Header instances have a type of Header::FIRST then this method returns true. * If any of the Header instances have a type of Header::FIRST then this method returns true.
* False otherwise. * False otherwise.
* *
* @return boolean * @return bool
*/ */
public function hasDifferentFirstPage() public function hasDifferentFirstPage()
{ {
@ -186,6 +185,7 @@ class Section extends AbstractContainer
return true; return true;
} }
} }
return false; return false;
} }
@ -195,11 +195,11 @@ class Section extends AbstractContainer
* @since 0.10.0 * @since 0.10.0
* *
* @param string $type * @param string $type
* @param boolean $header * @param bool $header
*
* @return Header|Footer
* *
* @throws \Exception * @throws \Exception
*
* @return Header|Footer
*/ */
private function addHeaderFooter($type = Header::AUTO, $header = true) private function addHeaderFooter($type = Header::AUTO, $header = true)
{ {
@ -215,11 +215,10 @@ class Section extends AbstractContainer
$container->setPhpWord($this->phpWord); $container->setPhpWord($this->phpWord);
$collection[$index] = $container; $collection[$index] = $container;
return $container;
} else {
throw new \Exception('Invalid header/footer type.');
}
return $container;
}
throw new \Exception('Invalid header/footer type.');
} }
/** /**
@ -291,8 +290,8 @@ class Section extends AbstractContainer
{ {
if (empty($this->footers)) { if (empty($this->footers)) {
return null; return null;
} else {
return $this->footers[1];
} }
return $this->footers[1];
} }
} }

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Shape as ShapeStyle; use PhpOffice\PhpWord\Style\Shape as ShapeStyle;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
@ -54,14 +53,13 @@ class TOC extends AbstractElement
*/ */
private $maxDepth = 9; private $maxDepth = 9;
/** /**
* Create a new Table-of-Contents Element * Create a new Table-of-Contents Element
* *
* @param mixed $fontStyle * @param mixed $fontStyle
* @param array $tocStyle * @param array $tocStyle
* @param integer $minDepth * @param int $minDepth
* @param integer $maxDepth * @param int $maxDepth
*/ */
public function __construct($fontStyle = null, $tocStyle = null, $minDepth = 1, $maxDepth = 9) public function __construct($fontStyle = null, $tocStyle = null, $minDepth = 1, $maxDepth = 9)
{ {

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Table as TableStyle; use PhpOffice\PhpWord\Style\Table as TableStyle;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\Common\Text as CommonText; use PhpOffice\Common\Text as CommonText;
@ -105,12 +104,12 @@ class Text extends AbstractElement
public function setParagraphStyle($style = null) public function setParagraphStyle($style = null)
{ {
if (is_array($style)) { if (is_array($style)) {
$this->paragraphStyle = new Paragraph; $this->paragraphStyle = new Paragraph();
$this->paragraphStyle->setStyleByArray($style); $this->paragraphStyle->setStyleByArray($style);
} elseif ($style instanceof Paragraph) { } elseif ($style instanceof Paragraph) {
$this->paragraphStyle = $style; $this->paragraphStyle = $style;
} elseif (null === $style) { } elseif (null === $style) {
$this->paragraphStyle = new Paragraph; $this->paragraphStyle = new Paragraph();
} else { } else {
$this->paragraphStyle = $style; $this->paragraphStyle = $style;
} }

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle; use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Font;
@ -74,6 +73,7 @@ class TextBreak extends AbstractElement
$this->fontStyle = $style; $this->fontStyle = $style;
$this->setParagraphStyle($paragraphStyle); $this->setParagraphStyle($paragraphStyle);
} }
return $this->fontStyle; return $this->fontStyle;
} }
@ -96,13 +96,14 @@ class TextBreak extends AbstractElement
public function setParagraphStyle($style = null) public function setParagraphStyle($style = null)
{ {
if (is_array($style)) { if (is_array($style)) {
$this->paragraphStyle = new Paragraph; $this->paragraphStyle = new Paragraph();
$this->paragraphStyle->setStyleByArray($style); $this->paragraphStyle->setStyleByArray($style);
} elseif ($style instanceof Paragraph) { } elseif ($style instanceof Paragraph) {
$this->paragraphStyle = $style; $this->paragraphStyle = $style;
} else { } else {
$this->paragraphStyle = $style; $this->paragraphStyle = $style;
} }
return $this->paragraphStyle; return $this->paragraphStyle;
} }

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\Paragraph;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
use PhpOffice\Common\Text as CommonText; use PhpOffice\Common\Text as CommonText;
@ -83,7 +82,7 @@ class Title extends AbstractElement
/** /**
* Get depth * Get depth
* *
* @return integer * @return int
*/ */
public function getDepth() public function getDepth()
{ {

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Element; namespace PhpOffice\PhpWord\Element;
/** /**
@ -49,9 +48,9 @@ class TrackChange extends AbstractContainer
*/ */
public function __construct($author, \DateTime $date) public function __construct($author, \DateTime $date)
{ {
$this->author = $author; $this->author = $author;
$this->date = $date; $this->date = $date;
return $this; return $this;
} }

View File

@ -11,15 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Escaper; namespace PhpOffice\PhpWord\Escaper;
/** /**
* @since 0.13.0 * @since 0.13.0
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
abstract class AbstractEscaper implements EscaperInterface abstract class AbstractEscaper implements EscaperInterface

View File

@ -11,15 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Escaper; namespace PhpOffice\PhpWord\Escaper;
/** /**
* @since 0.13.0 * @since 0.13.0
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
interface EscaperInterface interface EscaperInterface

View File

@ -11,15 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Escaper; namespace PhpOffice\PhpWord\Escaper;
/** /**
* @since 0.13.0 * @since 0.13.0
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class RegExp extends AbstractEscaper class RegExp extends AbstractEscaper

View File

@ -11,15 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Escaper; namespace PhpOffice\PhpWord\Escaper;
/** /**
* @since 0.13.0 * @since 0.13.0
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class Rtf extends AbstractEscaper class Rtf extends AbstractEscaper
@ -28,9 +27,9 @@ class Rtf extends AbstractEscaper
{ {
if (20 > $code || $code >= 80) { if (20 > $code || $code >= 80) {
return '{\u' . $code . '}'; return '{\u' . $code . '}';
} else {
return chr($code);
} }
return chr($code);
} }
protected function escapeMultibyteCharacter($code) protected function escapeMultibyteCharacter($code)
@ -40,6 +39,7 @@ class Rtf extends AbstractEscaper
/** /**
* @see http://www.randomchaos.com/documents/?source=php_and_unicode * @see http://www.randomchaos.com/documents/?source=php_and_unicode
* @param string $input
*/ */
protected function escapeSingleValue($input) protected function escapeSingleValue($input)
{ {
@ -57,9 +57,9 @@ class Rtf extends AbstractEscaper
if (0 == count($bytes)) { if (0 == count($bytes)) {
if ($asciiCode < 224) { if ($asciiCode < 224) {
$numberOfBytes = 2; $numberOfBytes = 2;
} else if ($asciiCode < 240) { } elseif ($asciiCode < 240) {
$numberOfBytes = 3; $numberOfBytes = 3;
} else if ($asciiCode < 248) { } elseif ($asciiCode < 248) {
$numberOfBytes = 4; $numberOfBytes = 4;
} }
} }

View File

@ -11,15 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Escaper; namespace PhpOffice\PhpWord\Escaper;
/** /**
* @since 0.13.0 * @since 0.13.0
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
class Xml extends AbstractEscaper class Xml extends AbstractEscaper

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Exception; namespace PhpOffice\PhpWord\Exception;
/** /**
@ -23,10 +22,10 @@ namespace PhpOffice\PhpWord\Exception;
final class CopyFileException extends Exception final class CopyFileException extends Exception
{ {
/** /**
* @param string $source The fully qualified source file name. * @param string $source The fully qualified source file name
* @param string $destination The fully qualified destination file name. * @param string $destination The fully qualified destination file name
* @param integer $code The user defined exception code. * @param int $code The user defined exception code
* @param \Exception $previous The previous exception used for the exception chaining. * @param \Exception $previous The previous exception used for the exception chaining
*/ */
final public function __construct($source, $destination, $code = 0, \Exception $previous = null) final public function __construct($source, $destination, $code = 0, \Exception $previous = null)
{ {

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Exception; namespace PhpOffice\PhpWord\Exception;
/** /**
@ -23,8 +22,8 @@ namespace PhpOffice\PhpWord\Exception;
final class CreateTemporaryFileException extends Exception final class CreateTemporaryFileException extends Exception
{ {
/** /**
* @param integer $code The user defined exception code. * @param int $code The user defined exception code
* @param \Exception $previous The previous exception used for the exception chaining. * @param \Exception $previous The previous exception used for the exception chaining
*/ */
final public function __construct($code = 0, \Exception $previous = null) final public function __construct($code = 0, \Exception $previous = null)
{ {

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Exception; namespace PhpOffice\PhpWord\Exception;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Exception; namespace PhpOffice\PhpWord\Exception;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Exception; namespace PhpOffice\PhpWord\Exception;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Exception; namespace PhpOffice\PhpWord\Exception;
use InvalidArgumentException; use InvalidArgumentException;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Exception; namespace PhpOffice\PhpWord\Exception;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord; namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Exception\Exception;
@ -29,9 +28,9 @@ abstract class IOFactory
* @param PhpWord $phpWord * @param PhpWord $phpWord
* @param string $name * @param string $name
* *
* @return WriterInterface
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*
* @return WriterInterface
*/ */
public static function createWriter(PhpWord $phpWord, $name = 'Word2007') public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
{ {
@ -49,9 +48,9 @@ abstract class IOFactory
* *
* @param string $name * @param string $name
* *
* @return ReaderInterface
*
* @throws Exception * @throws Exception
*
* @return ReaderInterface
*/ */
public static function createReader($name = 'Word2007') public static function createReader($name = 'Word2007')
{ {
@ -65,19 +64,19 @@ abstract class IOFactory
* @param string $name * @param string $name
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* *
* @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*
* @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
*/ */
private static function createObject($type, $name, $phpWord = null) private static function createObject($type, $name, $phpWord = null)
{ {
$class = "PhpOffice\\PhpWord\\{$type}\\{$name}"; $class = "PhpOffice\\PhpWord\\{$type}\\{$name}";
if (class_exists($class) && self::isConcreteClass($class)) { if (class_exists($class) && self::isConcreteClass($class)) {
return new $class($phpWord); return new $class($phpWord);
} else {
throw new Exception("\"{$name}\" is not a valid {$type}.");
} }
throw new Exception("\"{$name}\" is not a valid {$type}.");
} }
/** /**
* Loads PhpWord from file * Loads PhpWord from file
* *
@ -89,8 +88,10 @@ abstract class IOFactory
{ {
/** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */ /** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */
$reader = self::createReader($readerName); $reader = self::createReader($readerName);
return $reader->load($filename); return $reader->load($filename);
} }
/** /**
* Check if it's a concrete class (not abstract nor interface) * Check if it's a concrete class (not abstract nor interface)
* *
@ -100,6 +101,7 @@ abstract class IOFactory
private static function isConcreteClass($class) private static function isConcreteClass($class)
{ {
$reflection = new \ReflectionClass($class); $reflection = new \ReflectionClass($class);
return !$reflection->isAbstract() && !$reflection->isInterface(); return !$reflection->isAbstract() && !$reflection->isInterface();
} }
} }

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord; namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Element\Image; use PhpOffice\PhpWord\Element\Image;
@ -43,9 +42,9 @@ class Media
* @param string $source * @param string $source
* @param \PhpOffice\PhpWord\Element\Image $image * @param \PhpOffice\PhpWord\Element\Image $image
* *
* @return integer
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*
* @return int
*/ */
public static function addElement($container, $mediaType, $source, Image $image = null) public static function addElement($container, $mediaType, $source, Image $image = null)
{ {
@ -83,12 +82,10 @@ class Media
$image->setTarget($target); $image->setTarget($target);
$image->setMediaIndex($mediaTypeCount); $image->setMediaIndex($mediaTypeCount);
break; break;
// Objects // Objects
case 'object': case 'object':
$target = "{$container}_oleObject{$mediaTypeCount}.bin"; $target = "{$container}_oleObject{$mediaTypeCount}.bin";
break; break;
// Links // Links
case 'link': case 'link':
$target = $source; $target = $source;
@ -100,15 +97,17 @@ class Media
$mediaData['type'] = $mediaType; $mediaData['type'] = $mediaType;
$mediaData['rID'] = $rId; $mediaData['rID'] = $rId;
self::$elements[$container][$mediaId] = $mediaData; self::$elements[$container][$mediaId] = $mediaData;
return $rId; return $rId;
} else {
$mediaData = self::$elements[$container][$mediaId];
if (!is_null($image)) {
$image->setTarget($mediaData['target']);
$image->setMediaIndex($mediaData['mediaIndex']);
}
return $mediaData['rID'];
} }
$mediaData = self::$elements[$container][$mediaId];
if (!is_null($image)) {
$image->setTarget($mediaData['target']);
$image->setMediaIndex($mediaData['mediaIndex']);
}
return $mediaData['rID'];
} }
/** /**
@ -116,7 +115,7 @@ class Media
* *
* @param string $container section|headerx|footerx|footnote|endnote * @param string $container section|headerx|footerx|footnote|endnote
* @param string $mediaType image|object|link * @param string $mediaType image|object|link
* @return integer * @return int
* @since 0.10.0 * @since 0.10.0
*/ */
public static function countElements($container, $mediaType = null) public static function countElements($container, $mediaType = null)
@ -157,13 +156,15 @@ class Media
$elements[$key] = $val; $elements[$key] = $val;
} }
} }
return $elements; return $elements;
} else {
if (!isset(self::$elements[$container])) {
return $elements;
}
return self::getElementsByType($container, $type);
} }
if (!isset(self::$elements[$container])) {
return $elements;
}
return self::getElementsByType($container, $type);
} }
/** /**
@ -208,7 +209,7 @@ class Media
* @param string $type * @param string $type
* @param \PhpOffice\PhpWord\Element\Image $image * @param \PhpOffice\PhpWord\Element\Image $image
* *
* @return integer * @return int
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -224,7 +225,7 @@ class Media
* *
* @param string $linkSrc * @param string $linkSrc
* *
* @return integer * @return int
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -256,7 +257,7 @@ class Media
* *
* @param string $key * @param string $key
* *
* @return integer * @return int
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -270,11 +271,11 @@ class Media
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
* *
* @param integer $headerCount * @param int $headerCount
* @param string $src * @param string $src
* @param \PhpOffice\PhpWord\Element\Image $image * @param \PhpOffice\PhpWord\Element\Image $image
* *
* @return integer * @return int
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -290,7 +291,7 @@ class Media
* *
* @param string $key * @param string $key
* *
* @return integer * @return int
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -318,11 +319,11 @@ class Media
* *
* @deprecated 0.10.0 * @deprecated 0.10.0
* *
* @param integer $footerCount * @param int $footerCount
* @param string $src * @param string $src
* @param \PhpOffice\PhpWord\Element\Image $image * @param \PhpOffice\PhpWord\Element\Image $image
* *
* @return integer * @return int
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -338,7 +339,7 @@ class Media
* *
* @param string $key * @param string $key
* *
* @return integer * @return int
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Metadata; namespace PhpOffice\PhpWord\Metadata;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Metadata; namespace PhpOffice\PhpWord\Metadata;
/** /**
@ -119,17 +118,17 @@ class DocInfo
*/ */
public function __construct() public function __construct()
{ {
$this->creator = ''; $this->creator = '';
$this->lastModifiedBy = $this->creator; $this->lastModifiedBy = $this->creator;
$this->created = time(); $this->created = time();
$this->modified = time(); $this->modified = time();
$this->title = ''; $this->title = '';
$this->subject = ''; $this->subject = '';
$this->description = ''; $this->description = '';
$this->keywords = ''; $this->keywords = '';
$this->category = ''; $this->category = '';
$this->company = ''; $this->company = '';
$this->manager = ''; $this->manager = '';
} }
/** /**
@ -399,7 +398,7 @@ class DocInfo
* Check if a Custom Property is defined * Check if a Custom Property is defined
* *
* @param string $propertyName * @param string $propertyName
* @return boolean * @return bool
*/ */
public function isCustomPropertySet($propertyName) public function isCustomPropertySet($propertyName)
{ {
@ -416,9 +415,9 @@ class DocInfo
{ {
if ($this->isCustomPropertySet($propertyName)) { if ($this->isCustomPropertySet($propertyName)) {
return $this->customProperties[$propertyName]['value']; return $this->customProperties[$propertyName]['value'];
} else {
return null;
} }
return null;
} }
/** /**
@ -431,9 +430,9 @@ class DocInfo
{ {
if ($this->isCustomPropertySet($propertyName)) { if ($this->isCustomPropertySet($propertyName)) {
return $this->customProperties[$propertyName]['type']; return $this->customProperties[$propertyName]['type'];
} else {
return null;
} }
return null;
} }
/** /**
@ -456,7 +455,7 @@ class DocInfo
self::PROPERTY_TYPE_FLOAT, self::PROPERTY_TYPE_FLOAT,
self::PROPERTY_TYPE_STRING, self::PROPERTY_TYPE_STRING,
self::PROPERTY_TYPE_DATE, self::PROPERTY_TYPE_DATE,
self::PROPERTY_TYPE_BOOLEAN self::PROPERTY_TYPE_BOOLEAN,
); );
if (($propertyType === null) || (!in_array($propertyType, $propertyTypes))) { if (($propertyType === null) || (!in_array($propertyType, $propertyTypes))) {
if ($propertyValue === null) { if ($propertyValue === null) {
@ -474,8 +473,9 @@ class DocInfo
$this->customProperties[$propertyName] = array( $this->customProperties[$propertyName] = array(
'value' => $propertyValue, 'value' => $propertyValue,
'type' => $propertyType 'type' => $propertyType,
); );
return $this; return $this;
} }

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Metadata; namespace PhpOffice\PhpWord\Metadata;
/** /**

View File

@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Metadata; namespace PhpOffice\PhpWord\Metadata;
use PhpOffice\PhpWord\ComplexType\ProofState; use PhpOffice\PhpWord\ComplexType\ProofState;
use PhpOffice\PhpWord\SimpleType\Zoom;
use PhpOffice\PhpWord\ComplexType\TrackChangesView; use PhpOffice\PhpWord\ComplexType\TrackChangesView;
use PhpOffice\PhpWord\SimpleType\Zoom;
/** /**
* Setting class * Setting class
@ -28,7 +28,6 @@ use PhpOffice\PhpWord\ComplexType\TrackChangesView;
*/ */
class Settings class Settings
{ {
/** /**
* Magnification Setting * Magnification Setting
* *
@ -40,14 +39,14 @@ class Settings
/** /**
* Hide spelling errors * Hide spelling errors
* *
* @var boolean * @var bool
*/ */
private $hideSpellingErrors = false; private $hideSpellingErrors = false;
/** /**
* Hide grammatical errors * Hide grammatical errors
* *
* @var boolean * @var bool
*/ */
private $hideGrammaticalErrors = false; private $hideGrammaticalErrors = false;
@ -61,21 +60,21 @@ class Settings
/** /**
* Track Revisions to Document * Track Revisions to Document
* *
* @var boolean * @var bool
*/ */
private $trackRevisions = false; private $trackRevisions = false;
/** /**
* Do Not Use Move Syntax When Tracking Revisions * Do Not Use Move Syntax When Tracking Revisions
* *
* @var boolean * @var bool
*/ */
private $doNotTrackMoves = false; private $doNotTrackMoves = false;
/** /**
* Do Not Track Formatting Revisions When Tracking Revisions * Do Not Track Formatting Revisions When Tracking Revisions
* *
* @var boolean * @var bool
*/ */
private $doNotTrackFormatting = false; private $doNotTrackFormatting = false;
@ -115,6 +114,7 @@ class Settings
if ($this->documentProtection == null) { if ($this->documentProtection == null) {
$this->documentProtection = new Protection(); $this->documentProtection = new Protection();
} }
return $this->documentProtection; return $this->documentProtection;
} }
@ -134,6 +134,7 @@ class Settings
if ($this->proofState == null) { if ($this->proofState == null) {
$this->proofState = new ProofState(); $this->proofState = new ProofState();
} }
return $this->proofState; return $this->proofState;
} }
@ -148,7 +149,7 @@ class Settings
/** /**
* Are spelling errors hidden * Are spelling errors hidden
* *
* @return boolean * @return bool
*/ */
public function hasHideSpellingErrors() public function hasHideSpellingErrors()
{ {
@ -158,7 +159,7 @@ class Settings
/** /**
* Hide spelling errors * Hide spelling errors
* *
* @param boolean $hideSpellingErrors * @param bool $hideSpellingErrors
*/ */
public function setHideSpellingErrors($hideSpellingErrors) public function setHideSpellingErrors($hideSpellingErrors)
{ {
@ -168,7 +169,7 @@ class Settings
/** /**
* Are grammatical errors hidden * Are grammatical errors hidden
* *
* @return boolean * @return bool
*/ */
public function hasHideGrammaticalErrors() public function hasHideGrammaticalErrors()
{ {
@ -178,7 +179,7 @@ class Settings
/** /**
* Hide grammatical errors * Hide grammatical errors
* *
* @param boolean $hideGrammaticalErrors * @param bool $hideGrammaticalErrors
*/ */
public function setHideGrammaticalErrors($hideGrammaticalErrors) public function setHideGrammaticalErrors($hideGrammaticalErrors)
{ {
@ -186,7 +187,7 @@ class Settings
} }
/** /**
* @return boolean * @return bool
*/ */
public function hasEvenAndOddHeaders() public function hasEvenAndOddHeaders()
{ {
@ -194,7 +195,7 @@ class Settings
} }
/** /**
* @param boolean $evenAndOddHeaders * @param bool $evenAndOddHeaders
*/ */
public function setEvenAndOddHeaders($evenAndOddHeaders) public function setEvenAndOddHeaders($evenAndOddHeaders)
{ {
@ -203,7 +204,7 @@ class Settings
/** /**
* Get the Visibility of Annotation Types * Get the Visibility of Annotation Types
* *
* @return \PhpOffice\PhpWord\ComplexType\TrackChangesView * @return \PhpOffice\PhpWord\ComplexType\TrackChangesView
*/ */
public function getRevisionView() public function getRevisionView()
@ -213,7 +214,7 @@ class Settings
/** /**
* Set the Visibility of Annotation Types * Set the Visibility of Annotation Types
* *
* @param TrackChangesView $trackChangesView * @param TrackChangesView $trackChangesView
*/ */
public function setRevisionView(TrackChangesView $trackChangesView = null) public function setRevisionView(TrackChangesView $trackChangesView = null)
@ -222,7 +223,7 @@ class Settings
} }
/** /**
* @return boolean * @return bool
*/ */
public function hasTrackRevisions() public function hasTrackRevisions()
{ {
@ -230,7 +231,7 @@ class Settings
} }
/** /**
* @param boolean $trackRevisions * @param bool $trackRevisions
*/ */
public function setTrackRevisions($trackRevisions) public function setTrackRevisions($trackRevisions)
{ {
@ -238,7 +239,7 @@ class Settings
} }
/** /**
* @return boolean * @return bool
*/ */
public function hasDoNotTrackMoves() public function hasDoNotTrackMoves()
{ {
@ -246,7 +247,7 @@ class Settings
} }
/** /**
* @param boolean $doNotTrackMoves * @param bool $doNotTrackMoves
*/ */
public function setDoNotTrackMoves($doNotTrackMoves) public function setDoNotTrackMoves($doNotTrackMoves)
{ {
@ -254,7 +255,7 @@ class Settings
} }
/** /**
* @return boolean * @return bool
*/ */
public function hasDoNotTrackFormatting() public function hasDoNotTrackFormatting()
{ {
@ -262,7 +263,7 @@ class Settings
} }
/** /**
* @param boolean $doNotTrackFormatting * @param bool $doNotTrackFormatting
*/ */
public function setDoNotTrackFormatting($doNotTrackFormatting) public function setDoNotTrackFormatting($doNotTrackFormatting)
{ {
@ -293,7 +294,7 @@ class Settings
/** /**
* Returns the Radix Point for Field Code Evaluation * Returns the Radix Point for Field Code Evaluation
* *
* @return string * @return string
*/ */
public function getDecimalSymbol() public function getDecimalSymbol()
@ -303,7 +304,7 @@ class Settings
/** /**
* sets the Radix Point for Field Code Evaluation * sets the Radix Point for Field Code Evaluation
* *
* @param string $decimalSymbol * @param string $decimalSymbol
*/ */
public function setDecimalSymbol($decimalSymbol) public function setDecimalSymbol($decimalSymbol)

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord; namespace PhpOffice\PhpWord;
use PhpOffice\PhpWord\Element\Section; use PhpOffice\PhpWord\Element\Section;
@ -108,9 +107,9 @@ class PhpWord
* @param mixed $function * @param mixed $function
* @param mixed $args * @param mixed $args
* *
* @return mixed
*
* @throws \BadMethodCallException * @throws \BadMethodCallException
*
* @return mixed
*/ */
public function __call($function, $args) public function __call($function, $args)
{ {
@ -251,7 +250,7 @@ class PhpWord
/** /**
* Get default font size * Get default font size
* *
* @return integer * @return int
*/ */
public function getDefaultFontSize() public function getDefaultFontSize()
{ {
@ -285,21 +284,20 @@ class PhpWord
* *
* @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead. * @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead.
* *
* @param string $filename Fully qualified filename. * @param string $filename Fully qualified filename
*
* @return TemplateProcessor
* *
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
* *
* @return TemplateProcessor
*
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
public function loadTemplate($filename) public function loadTemplate($filename)
{ {
if (file_exists($filename)) { if (file_exists($filename)) {
return new TemplateProcessor($filename); return new TemplateProcessor($filename);
} else {
throw new Exception("Template file {$filename} not found.");
} }
throw new Exception("Template file {$filename} not found.");
} }
/** /**
@ -325,7 +323,7 @@ class PhpWord
$writer = IOFactory::createWriter($this, $format); $writer = IOFactory::createWriter($this, $format);
if ($download === true) { if ($download === true) {
header("Content-Description: File Transfer"); header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Type: ' . $mime[$format]); header('Content-Type: ' . $mime[$format]);
header('Content-Transfer-Encoding: binary'); header('Content-Transfer-Encoding: binary');

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader; namespace PhpOffice\PhpWord\Reader;
use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Exception\Exception;
@ -62,6 +61,7 @@ abstract class AbstractReader implements ReaderInterface
public function setReadDataOnly($value = true) public function setReadDataOnly($value = true)
{ {
$this->readDataOnly = $value; $this->readDataOnly = $value;
return $this; return $this;
} }
@ -70,21 +70,21 @@ abstract class AbstractReader implements ReaderInterface
* *
* @param string $filename * @param string $filename
* *
* @return resource
*
* @throws \PhpOffice\PhpWord\Exception\Exception * @throws \PhpOffice\PhpWord\Exception\Exception
*
* @return resource
*/ */
protected function openFile($filename) protected function openFile($filename)
{ {
// Check if file exists // Check if file exists
if (!file_exists($filename) || !is_readable($filename)) { if (!file_exists($filename) || !is_readable($filename)) {
throw new Exception("Could not open " . $filename . " for reading! File does not exist."); throw new Exception("Could not open $filename for reading! File does not exist.");
} }
// Open file // Open file
$this->fileHandle = fopen($filename, 'r'); $this->fileHandle = fopen($filename, 'r');
if ($this->fileHandle === false) { if ($this->fileHandle === false) {
throw new Exception("Could not open file " . $filename . " for reading."); throw new Exception("Could not open file $filename for reading.");
} }
} }

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader; namespace PhpOffice\PhpWord\Reader;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;

View File

@ -11,16 +11,15 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader; namespace PhpOffice\PhpWord\Reader;
use PhpOffice\Common\Drawing; use PhpOffice\Common\Drawing;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Shared\OLERead; use PhpOffice\PhpWord\Shared\OLERead;
use PhpOffice\PhpWord\Style;
/** /**
* Reader for Word97 * Reader for Word97
@ -164,13 +163,14 @@ class MsDoc extends AbstractReader implements ReaderInterface
$arrayCP[$inc] = self::getInt4d($data, $posMem); $arrayCP[$inc] = self::getInt4d($data, $posMem);
$posMem += 4; $posMem += 4;
} }
return $arrayCP; return $arrayCP;
} }
/** /**
*
* @link http://msdn.microsoft.com/en-us/library/dd949344%28v=office.12%29.aspx * @link http://msdn.microsoft.com/en-us/library/dd949344%28v=office.12%29.aspx
* @link https://igor.io/2012/09/24/binary-parsing.html * @link https://igor.io/2012/09/24/binary-parsing.html
* @param string $data
*/ */
private function readFib($data) private function readFib($data)
{ {
@ -1095,6 +1095,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
$this->arrayFib['lcbColorSchemeMapping'] = self::getInt4d($data, $pos); $this->arrayFib['lcbColorSchemeMapping'] = self::getInt4d($data, $pos);
$pos += 4; $pos += 4;
} }
return $pos; return $pos;
} }
@ -1215,7 +1216,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
} }
$this->arrayFonts[] = array( $this->arrayFonts[] = array(
'main' => $xszFfn, 'main' => $xszFfn,
'alt' => $xszAlt, 'alt' => $xszAlt,
); );
} }
} }
@ -1303,7 +1304,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
print_r('$sprm.ispmd : 0x'.dechex($sprm_IsPmd).PHP_EOL); print_r('$sprm.ispmd : 0x'.dechex($sprm_IsPmd).PHP_EOL);
print_r('$sprm.f : 0x'.dechex($sprm_F).PHP_EOL); print_r('$sprm.f : 0x'.dechex($sprm_F).PHP_EOL);
print_r('$sprm.sgc : 0x'.dechex($sprm_Sgc)); print_r('$sprm.sgc : 0x'.dechex($sprm_Sgc));
switch(dechex($sprm_Sgc)) { switch (dechex($sprm_Sgc)) {
case 0x01: case 0x01:
print_r(' (Paragraph property)'); print_r(' (Paragraph property)');
break; break;
@ -1322,12 +1323,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
} }
print_r(PHP_EOL); print_r(PHP_EOL);
print_r('$sprm.spra : 0x'.dechex($sprm_Spra).PHP_EOL); print_r('$sprm.spra : 0x'.dechex($sprm_Spra).PHP_EOL);
switch(dechex($sprm_Spra)) { switch (dechex($sprm_Spra)) {
case 0x0: case 0x0:
$operand = self::getInt1d($this->dataWorkDocument, $offset); $operand = self::getInt1d($this->dataWorkDocument, $offset);
$offset += 1; $offset += 1;
$cb -= 1; $cb -= 1;
switch(dechex($operand)) { switch (dechex($operand)) {
case 0x00: case 0x00:
$operand = 'OFF'; $operand = 'OFF';
break; break;
@ -1376,9 +1377,9 @@ class MsDoc extends AbstractReader implements ReaderInterface
} }
// //
switch(dechex($sprm_Sgc)) { switch (dechex($sprm_Sgc)) {
case 0x01: // Sprm is modifying a paragraph property. case 0x01: // Sprm is modifying a paragraph property.
switch($sprm_IsPmd) { switch ($sprm_IsPmd) {
case 0x0A: // sprmPIlvl case 0x0A: // sprmPIlvl
print_r('sprmPIlvl : '.$operand.PHP_EOL.PHP_EOL); print_r('sprmPIlvl : '.$operand.PHP_EOL.PHP_EOL);
break; break;
@ -1391,28 +1392,28 @@ class MsDoc extends AbstractReader implements ReaderInterface
} }
break; break;
case 0x02: // Sprm is modifying a character property. case 0x02: // Sprm is modifying a character property.
switch($sprm_IsPmd) { switch ($sprm_IsPmd) {
default: default:
print_r('$sprm_IsPmd(2) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); print_r('$sprm_IsPmd(2) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
break; break;
} }
break; break;
case 0x03: // Sprm is modifying a picture property. case 0x03: // Sprm is modifying a picture property.
switch($sprm_IsPmd) { switch ($sprm_IsPmd) {
default: default:
print_r('$sprm_IsPmd(3) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); print_r('$sprm_IsPmd(3) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
break; break;
} }
break; break;
case 0x04: // Sprm is modifying a section property. case 0x04: // Sprm is modifying a section property.
switch($sprm_IsPmd) { switch ($sprm_IsPmd) {
default: default:
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
break; break;
} }
break; break;
case 0x05: // Sprm is modifying a table property. case 0x05: // Sprm is modifying a table property.
switch($sprm_IsPmd) { switch ($sprm_IsPmd) {
default: default:
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL); print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
break; break;
@ -1471,7 +1472,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
foreach ($arrayRGB as $keyRGB => $rgb) { foreach ($arrayRGB as $keyRGB => $rgb) {
$oStyle = new \stdClass(); $oStyle = new \stdClass();
$oStyle->pos_start = $start; $oStyle->pos_start = $start;
$oStyle->pos_len = (int)ceil((($arrayRGFC[$keyRGB] -1) - $arrayRGFC[$keyRGB -1]) / 2); $oStyle->pos_len = (int) ceil((($arrayRGFC[$keyRGB] - 1) - $arrayRGFC[$keyRGB - 1]) / 2);
$start += $oStyle->pos_len; $start += $oStyle->pos_len;
if ($rgb > 0) { if ($rgb > 0) {
@ -1500,12 +1501,13 @@ class MsDoc extends AbstractReader implements ReaderInterface
$oSprm->f = ($sprm / 512) & 0x0001; $oSprm->f = ($sprm / 512) & 0x0001;
$oSprm->sgc = ($sprm / 1024) & 0x0007; $oSprm->sgc = ($sprm / 1024) & 0x0007;
$oSprm->spra = ($sprm / 8192); $oSprm->spra = ($sprm / 8192);
return $oSprm; return $oSprm;
} }
/** /**
* @param string $data * @param string $data
* @param integer $pos * @param int $pos
* @param \stdClass $oSprm * @param \stdClass $oSprm
* @return array * @return array
*/ */
@ -1514,11 +1516,11 @@ class MsDoc extends AbstractReader implements ReaderInterface
$length = 0; $length = 0;
$operand = null; $operand = null;
switch(dechex($oSprm->spra)) { switch (dechex($oSprm->spra)) {
case 0x0: case 0x0:
$operand = self::getInt1d($data, $pos); $operand = self::getInt1d($data, $pos);
$length = 1; $length = 1;
switch(dechex($operand)) { switch (dechex($operand)) {
case 0x00: case 0x00:
$operand = false; $operand = false;
break; break;
@ -1558,14 +1560,15 @@ class MsDoc extends AbstractReader implements ReaderInterface
} }
return array( return array(
'length' => $length, 'length' => $length,
'operand' => $operand, 'operand' => $operand,
); );
} }
/** /**
* @param $data integer * @param $data int
* @param $pos integer * @param $pos int
* @param $cbNum int
* @return \stdClass * @return \stdClass
* @link http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx * @link http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx
*/ */
@ -1593,7 +1596,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
$cbNum -= $arrayReturn['length']; $cbNum -= $arrayReturn['length'];
$operand = $arrayReturn['operand']; $operand = $arrayReturn['operand'];
switch(dechex($oSprm->sgc)) { switch (dechex($oSprm->sgc)) {
// Paragraph property // Paragraph property
case 0x01: case 0x01:
break; break;
@ -1602,7 +1605,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
if (!isset($oStylePrl->styleFont)) { if (!isset($oStylePrl->styleFont)) {
$oStylePrl->styleFont = array(); $oStylePrl->styleFont = array();
} }
switch($oSprm->isPmd) { switch ($oSprm->isPmd) {
// sprmCFRMarkIns // sprmCFRMarkIns
case 0x01: case 0x01:
break; break;
@ -1620,7 +1623,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
// sprmCFItalic // sprmCFItalic
case 0x36: case 0x36:
// By default, text is not italicized. // By default, text is not italicized.
switch($operand) { switch ($operand) {
case false: case false:
case true: case true:
$oStylePrl->styleFont['italic'] = $operand; $oStylePrl->styleFont['italic'] = $operand;
@ -1640,7 +1643,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
// sprmCFBold // sprmCFBold
case 0x35: case 0x35:
// By default, text is not bold. // By default, text is not bold.
switch($operand) { switch ($operand) {
case false: case false:
case true: case true:
$oStylePrl->styleFont['bold'] = $operand; $oStylePrl->styleFont['bold'] = $operand;
@ -1656,7 +1659,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
// sprmCFStrike // sprmCFStrike
case 0x37: case 0x37:
// By default, text is not struck through. // By default, text is not struck through.
switch($operand) { switch ($operand) {
case false: case false:
case true: case true:
$oStylePrl->styleFont['strikethrough'] = $operand; $oStylePrl->styleFont['strikethrough'] = $operand;
@ -1671,7 +1674,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
break; break;
// sprmCKul // sprmCKul
case 0x3E: case 0x3E:
switch(dechex($operand)) { switch (dechex($operand)) {
case 0x00: case 0x00:
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE; $oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE;
break; break;
@ -1734,7 +1737,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
// sprmCIco // sprmCIco
//@link http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx //@link http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx
case 0x42: case 0x42:
switch(dechex($operand)) { switch (dechex($operand)) {
case 0x00: case 0x00:
case 0x01: case 0x01:
$oStylePrl->styleFont['color'] = '000000'; $oStylePrl->styleFont['color'] = '000000';
@ -1787,7 +1790,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
break; break;
// sprmCHps // sprmCHps
case 0x43: case 0x43:
$oStylePrl->styleFont['size'] = dechex($operand/2); $oStylePrl->styleFont['size'] = dechex($operand / 2);
break; break;
// sprmCIss // sprmCIss
case 0x48: case 0x48:
@ -1857,7 +1860,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
$blue = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT); $blue = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT);
$pos += 1; $pos += 1;
$pos += 1; $pos += 1;
$oStylePrl->styleFont['color'] = $red.$green.$blue; $oStylePrl->styleFont['color'] = $red . $green . $blue;
$cbNum -= 4; $cbNum -= 4;
break; break;
default: default:
@ -1873,7 +1876,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
if (!isset($oStylePrl->styleSection)) { if (!isset($oStylePrl->styleSection)) {
$oStylePrl->styleSection = array(); $oStylePrl->styleSection = array();
} }
switch($oSprm->isPmd) { switch ($oSprm->isPmd) {
// sprmSNfcPgn // sprmSNfcPgn
case 0x0E: case 0x0E:
// numbering format used for page numbers // numbering format used for page numbers
@ -1925,7 +1928,6 @@ class MsDoc extends AbstractReader implements ReaderInterface
default: default:
// print_r('@todo Section : 0x'.dechex($oSprm->isPmd)); // print_r('@todo Section : 0x'.dechex($oSprm->isPmd));
// print_r(PHP_EOL); // print_r(PHP_EOL);
} }
break; break;
// Table property // Table property
@ -2193,13 +2195,14 @@ class MsDoc extends AbstractReader implements ReaderInterface
} }
$oStylePrl->length = $pos - $posStart; $oStylePrl->length = $pos - $posStart;
return $oStylePrl; return $oStylePrl;
} }
/** /**
* Read a record header * Read a record header
* @param string $stream * @param string $stream
* @param integer $pos * @param int $pos
* @return array * @return array
*/ */
private function loadRecordHeader($stream, $pos) private function loadRecordHeader($stream, $pos)
@ -2207,11 +2210,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
$rec = self::getInt2d($stream, $pos); $rec = self::getInt2d($stream, $pos);
$recType = self::getInt2d($stream, $pos + 2); $recType = self::getInt2d($stream, $pos + 2);
$recLen = self::getInt4d($stream, $pos + 4); $recLen = self::getInt4d($stream, $pos + 4);
return array( return array(
'recVer' => ($rec >> 0) & bindec('1111'), 'recVer' => ($rec >> 0) & bindec('1111'),
'recInstance' => ($rec >> 4) & bindec('111111111111'), 'recInstance' => ($rec >> 4) & bindec('111111111111'),
'recType' => $recType, 'recType' => $recType,
'recLen' => $recLen, 'recLen' => $recLen,
); );
} }
@ -2274,7 +2278,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
} }
if (ord($sText[0]) == 1) { if (ord($sText[0]) == 1) {
if (isset($oCharacters->style->image)) { if (isset($oCharacters->style->image)) {
$fileImage = tempnam(sys_get_temp_dir(), 'PHPWord_MsDoc').'.'.$oCharacters->style->image['format']; $fileImage = tempnam(sys_get_temp_dir(), 'PHPWord_MsDoc') . '.' . $oCharacters->style->image['format'];
file_put_contents($fileImage, $oCharacters->style->image['data']); file_put_contents($fileImage, $oCharacters->style->image['data']);
$oSection->addImage($fileImage, array('width' => $oCharacters->style->image['width'], 'height' => $oCharacters->style->image['height'])); $oSection->addImage($fileImage, array('width' => $oCharacters->style->image['width'], 'height' => $oCharacters->style->image['height']));
// print_r('>addImage<'.$fileImage.'>'.EOL); // print_r('>addImage<'.$fileImage.'>'.EOL);
@ -2285,7 +2289,6 @@ class MsDoc extends AbstractReader implements ReaderInterface
} }
} }
} }
} }
} }
@ -2310,7 +2313,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
*/ */
public static function getInt2d($data, $pos) public static function getInt2d($data, $pos)
{ {
return ord($data[$pos]) | (ord($data[$pos+1]) << 8); return ord($data[$pos]) | (ord($data[$pos + 1]) << 8);
} }
/** /**
@ -2322,7 +2325,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
*/ */
public static function getInt3d($data, $pos) public static function getInt3d($data, $pos)
{ {
return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16); return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16);
} }
/** /**
@ -2344,6 +2347,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
} else { } else {
$ord24 = ($or24 & 127) << 24; $ord24 = ($or24 & 127) << 24;
} }
return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $ord24;
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $ord24;
} }
} }

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader; namespace PhpOffice\PhpWord\Reader;
use PhpOffice\Common\XMLReader; use PhpOffice\Common\XMLReader;
@ -40,7 +39,7 @@ class ODText extends AbstractReader implements ReaderInterface
$readerParts = array( $readerParts = array(
'content.xml' => 'Content', 'content.xml' => 'Content',
'meta.xml' => 'Meta', 'meta.xml' => 'Meta',
); );
foreach ($readerParts as $xmlFile => $partName) { foreach ($readerParts as $xmlFile => $partName) {

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\ODText; namespace PhpOffice\PhpWord\Reader\ODText;
use PhpOffice\PhpWord\Reader\Word2007\AbstractPart as Word2007AbstractPart; use PhpOffice\PhpWord\Reader\Word2007\AbstractPart as Word2007AbstractPart;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\ODText; namespace PhpOffice\PhpWord\Reader\ODText;
use PhpOffice\Common\XMLReader; use PhpOffice\Common\XMLReader;
@ -44,16 +43,13 @@ class Content extends AbstractPart
foreach ($nodes as $node) { foreach ($nodes as $node) {
// $styleName = $xmlReader->getAttribute('text:style-name', $node); // $styleName = $xmlReader->getAttribute('text:style-name', $node);
switch ($node->nodeName) { switch ($node->nodeName) {
case 'text:h': // Heading case 'text:h': // Heading
$depth = $xmlReader->getAttribute('text:outline-level', $node); $depth = $xmlReader->getAttribute('text:outline-level', $node);
$section->addTitle($node->nodeValue, $depth); $section->addTitle($node->nodeValue, $depth);
break; break;
case 'text:p': // Paragraph case 'text:p': // Paragraph
$section->addText($node->nodeValue); $section->addText($node->nodeValue);
break; break;
case 'text:list': // List case 'text:list': // List
$listItems = $xmlReader->getElements('text:list-item/text:p', $node); $listItems = $xmlReader->getElements('text:list-item/text:p', $node);
foreach ($listItems as $listItem) { foreach ($listItems as $listItem) {

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\ODText; namespace PhpOffice\PhpWord\Reader\ODText;
use PhpOffice\Common\XMLReader; use PhpOffice\Common\XMLReader;
@ -70,9 +69,8 @@ class Meta extends AbstractPart
if (in_array($property, array('Category', 'Company', 'Manager'))) { if (in_array($property, array('Category', 'Company', 'Manager'))) {
$method = "set{$property}"; $method = "set{$property}";
$docProps->$method($propertyNode->nodeValue); $docProps->$method($propertyNode->nodeValue);
// Set other custom properties
} else { } else {
// Set other custom properties
$docProps->setCustomProperty($property, $propertyNode->nodeValue); $docProps->setCustomProperty($property, $propertyNode->nodeValue);
} }
} }

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader; namespace PhpOffice\PhpWord\Reader;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\RTF; namespace PhpOffice\PhpWord\Reader\RTF;
use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\PhpWord;
@ -153,7 +152,7 @@ class Document
// Walk each characters // Walk each characters
while ($this->offset < $this->length) { while ($this->offset < $this->length) {
$char = $this->rtf[$this->offset]; $char = $this->rtf[$this->offset];
$ascii = ord($char); $ascii = ord($char);
if (isset($markers[$ascii])) { // Marker found: {, }, \, LF, or CR if (isset($markers[$ascii])) { // Marker found: {, }, \, LF, or CR
@ -163,7 +162,7 @@ class Document
if (false === $this->isControl) { // Non control word: Push character if (false === $this->isControl) { // Non control word: Push character
$this->pushText($char); $this->pushText($char);
} else { } else {
if (preg_match("/^[a-zA-Z0-9-]?$/", $char)) { // No delimiter: Buffer control if (preg_match('/^[a-zA-Z0-9-]?$/', $char)) { // No delimiter: Buffer control
$this->control .= $char; $this->control .= $char;
$this->isFirst = false; $this->isFirst = false;
} else { // Delimiter found: Parse buffered control } else { // Delimiter found: Parse buffered control
@ -256,7 +255,7 @@ class Document
*/ */
private function flushControl($isControl = false) private function flushControl($isControl = false)
{ {
if (1 === preg_match("/^([A-Za-z]+)(-?[0-9]*) ?$/", $this->control, $match)) { if (1 === preg_match('/^([A-Za-z]+)(-?[0-9]*) ?$/', $this->control, $match)) {
list(, $control, $parameter) = $match; list(, $control, $parameter) = $match;
$this->parseControl($control, $parameter); $this->parseControl($control, $parameter);
} }
@ -313,9 +312,9 @@ class Document
private function pushText($char) private function pushText($char)
{ {
if ('<' == $char) { if ('<' == $char) {
$this->text .= "&lt;"; $this->text .= '&lt;';
} elseif ('>' == $char) { } elseif ('>' == $char) {
$this->text .= "&gt;"; $this->text .= '&gt;';
} else { } else {
$this->text .= $char; $this->text .= $char;
} }
@ -332,13 +331,13 @@ class Document
{ {
$controls = array( $controls = array(
'par' => array(self::PARA, 'paragraph', true), 'par' => array(self::PARA, 'paragraph', true),
'b' => array(self::STYL, 'font', 'bold', true), 'b' => array(self::STYL, 'font', 'bold', true),
'i' => array(self::STYL, 'font', 'italic', true), 'i' => array(self::STYL, 'font', 'italic', true),
'u' => array(self::STYL, 'font', 'underline', true), 'u' => array(self::STYL, 'font', 'underline', true),
'strike' => array(self::STYL, 'font', 'strikethrough',true), 'strike' => array(self::STYL, 'font', 'strikethrough', true),
'fs' => array(self::STYL, 'font', 'size', $parameter), 'fs' => array(self::STYL, 'font', 'size', $parameter),
'qc' => array(self::STYL, 'paragraph', 'alignment', Jc::CENTER), 'qc' => array(self::STYL, 'paragraph', 'alignment', Jc::CENTER),
'sa' => array(self::STYL, 'paragraph', 'spaceAfter', $parameter), 'sa' => array(self::STYL, 'paragraph', 'spaceAfter', $parameter),
'fonttbl' => array(self::SKIP, 'fonttbl', null), 'fonttbl' => array(self::SKIP, 'fonttbl', null),
'colortbl' => array(self::SKIP, 'colortbl', null), 'colortbl' => array(self::SKIP, 'colortbl', null),
'info' => array(self::SKIP, 'info', null), 'info' => array(self::SKIP, 'info', null),

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader; namespace PhpOffice\PhpWord\Reader;
/** /**
@ -28,7 +27,7 @@ interface ReaderInterface
* Can the current ReaderInterface read the file? * Can the current ReaderInterface read the file?
* *
* @param string $filename * @param string $filename
* @return boolean * @return bool
*/ */
public function canRead($filename); public function canRead($filename);

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader; namespace PhpOffice\PhpWord\Reader;
use PhpOffice\Common\XMLReader; use PhpOffice\Common\XMLReader;
@ -55,7 +54,7 @@ class Word2007 extends AbstractReader implements ReaderInterface
array('stepPart' => 'document', 'stepItems' => array( array('stepPart' => 'document', 'stepItems' => array(
'endnotes' => 'Endnotes', 'endnotes' => 'Endnotes',
'footnotes' => 'Footnotes', 'footnotes' => 'Footnotes',
'settings' => 'Settings', 'settings' => 'Settings',
)), )),
); );
@ -94,7 +93,6 @@ class Word2007 extends AbstractReader implements ReaderInterface
$part->setRels($relationships); $part->setRels($relationships);
$part->read($phpWord); $part->read($phpWord);
} }
} }
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\Word2007; namespace PhpOffice\PhpWord\Reader\Word2007;
use PhpOffice\Common\XMLReader; use PhpOffice\Common\XMLReader;
@ -36,9 +35,9 @@ abstract class AbstractPart
*/ */
const READ_VALUE = 'attributeValue'; // Read attribute value const READ_VALUE = 'attributeValue'; // Read attribute value
const READ_EQUAL = 'attributeEquals'; // Read `true` when attribute value equals specified value const READ_EQUAL = 'attributeEquals'; // Read `true` when attribute value equals specified value
const READ_TRUE = 'attributeTrue'; // Read `true` when element exists const READ_TRUE = 'attributeTrue'; // Read `true` when element exists
const READ_FALSE = 'attributeFalse'; // Read `false` when element exists const READ_FALSE = 'attributeFalse'; // Read `false` when element exists
const READ_SIZE = 'attributeMultiplyByTwo'; // Read special attribute value for Font::$size const READ_SIZE = 'attributeMultiplyByTwo'; // Read special attribute value for Font::$size
/** /**
* Document file * Document file
@ -137,9 +136,8 @@ abstract class AbstractPart
} }
} }
$parent->addPreserveText($textContent, $fontStyle, $paragraphStyle); $parent->addPreserveText($textContent, $fontStyle, $paragraphStyle);
// List item
} elseif ($xmlReader->elementExists('w:pPr/w:numPr', $domNode)) { } elseif ($xmlReader->elementExists('w:pPr/w:numPr', $domNode)) {
// List item
$textContent = ''; $textContent = '';
$numId = $xmlReader->getAttribute('w:val', $domNode, 'w:pPr/w:numPr/w:numId'); $numId = $xmlReader->getAttribute('w:val', $domNode, 'w:pPr/w:numPr/w:numId');
$levelId = $xmlReader->getAttribute('w:val', $domNode, 'w:pPr/w:numPr/w:ilvl'); $levelId = $xmlReader->getAttribute('w:val', $domNode, 'w:pPr/w:numPr/w:ilvl');
@ -148,18 +146,16 @@ abstract class AbstractPart
$textContent .= $xmlReader->getValue('w:t', $node); $textContent .= $xmlReader->getValue('w:t', $node);
} }
$parent->addListItem($textContent, $levelId, null, "PHPWordList{$numId}", $paragraphStyle); $parent->addListItem($textContent, $levelId, null, "PHPWordList{$numId}", $paragraphStyle);
// Heading
} elseif (!empty($headingMatches)) { } elseif (!empty($headingMatches)) {
// Heading
$textContent = ''; $textContent = '';
$nodes = $xmlReader->getElements('w:r', $domNode); $nodes = $xmlReader->getElements('w:r', $domNode);
foreach ($nodes as $node) { foreach ($nodes as $node) {
$textContent .= $xmlReader->getValue('w:t', $node); $textContent .= $xmlReader->getValue('w:t', $node);
} }
$parent->addTitle($textContent, $headingMatches[1]); $parent->addTitle($textContent, $headingMatches[1]);
// Text and TextRun
} else { } else {
// Text and TextRun
$runCount = $xmlReader->countElements('w:r', $domNode); $runCount = $xmlReader->countElements('w:r', $domNode);
$linkCount = $xmlReader->countElements('w:hyperlink', $domNode); $linkCount = $xmlReader->countElements('w:hyperlink', $domNode);
$runLinkCount = $runCount + $linkCount; $runLinkCount = $runCount + $linkCount;
@ -205,25 +201,22 @@ abstract class AbstractPart
$parent->addLink($target, $textContent, $fontStyle, $paragraphStyle); $parent->addLink($target, $textContent, $fontStyle, $paragraphStyle);
} }
} else { } else {
// Footnote
if ($xmlReader->elementExists('w:footnoteReference', $domNode)) { if ($xmlReader->elementExists('w:footnoteReference', $domNode)) {
// Footnote
$parent->addFootnote(); $parent->addFootnote();
// Endnote
} elseif ($xmlReader->elementExists('w:endnoteReference', $domNode)) { } elseif ($xmlReader->elementExists('w:endnoteReference', $domNode)) {
// Endnote
$parent->addEndnote(); $parent->addEndnote();
// Image
} elseif ($xmlReader->elementExists('w:pict', $domNode)) { } elseif ($xmlReader->elementExists('w:pict', $domNode)) {
// Image
$rId = $xmlReader->getAttribute('r:id', $domNode, 'w:pict/v:shape/v:imagedata'); $rId = $xmlReader->getAttribute('r:id', $domNode, 'w:pict/v:shape/v:imagedata');
$target = $this->getMediaTarget($docPart, $rId); $target = $this->getMediaTarget($docPart, $rId);
if (!is_null($target)) { if (!is_null($target)) {
$imageSource = "zip://{$this->docFile}#{$target}"; $imageSource = "zip://{$this->docFile}#{$target}";
$parent->addImage($imageSource); $parent->addImage($imageSource);
} }
// Object
} elseif ($xmlReader->elementExists('w:object', $domNode)) { } elseif ($xmlReader->elementExists('w:object', $domNode)) {
// Object
$rId = $xmlReader->getAttribute('r:id', $domNode, 'w:object/o:OLEObject'); $rId = $xmlReader->getAttribute('r:id', $domNode, 'w:object/o:OLEObject');
// $rIdIcon = $xmlReader->getAttribute('r:id', $domNode, 'w:object/v:shape/v:imagedata'); // $rIdIcon = $xmlReader->getAttribute('r:id', $domNode, 'w:object/v:shape/v:imagedata');
$target = $this->getMediaTarget($docPart, $rId); $target = $this->getMediaTarget($docPart, $rId);
@ -231,9 +224,8 @@ abstract class AbstractPart
$textContent = "<Object: {$target}>"; $textContent = "<Object: {$target}>";
$parent->addText($textContent, $fontStyle, $paragraphStyle); $parent->addText($textContent, $fontStyle, $paragraphStyle);
} }
// TextRun
} else { } else {
// TextRun
$textContent = $xmlReader->getValue('w:t', $domNode); $textContent = $xmlReader->getValue('w:t', $domNode);
$parent->addText($textContent, $fontStyle, $paragraphStyle); $parent->addText($textContent, $fontStyle, $paragraphStyle);
} }
@ -263,7 +255,6 @@ abstract class AbstractPart
foreach ($tblNodes as $tblNode) { foreach ($tblNodes as $tblNode) {
if ('w:tblGrid' == $tblNode->nodeName) { // Column if ('w:tblGrid' == $tblNode->nodeName) { // Column
// @todo Do something with table columns // @todo Do something with table columns
} elseif ('w:tr' == $tblNode->nodeName) { // Row } elseif ('w:tr' == $tblNode->nodeName) { // Row
$rowHeight = $xmlReader->getAttribute('w:val', $tblNode, 'w:trPr/w:trHeight'); $rowHeight = $xmlReader->getAttribute('w:val', $tblNode, 'w:trPr/w:trHeight');
$rowHRule = $xmlReader->getAttribute('w:hRule', $tblNode, 'w:trPr/w:trHeight'); $rowHRule = $xmlReader->getAttribute('w:hRule', $tblNode, 'w:trPr/w:trHeight');
@ -279,7 +270,6 @@ abstract class AbstractPart
foreach ($rowNodes as $rowNode) { foreach ($rowNodes as $rowNode) {
if ('w:trPr' == $rowNode->nodeName) { // Row style if ('w:trPr' == $rowNode->nodeName) { // Row style
// @todo Do something with row style // @todo Do something with row style
} elseif ('w:tc' == $rowNode->nodeName) { // Cell } elseif ('w:tc' == $rowNode->nodeName) { // Cell
$cellWidth = $xmlReader->getAttribute('w:w', $rowNode, 'w:tcPr/w:tcW'); $cellWidth = $xmlReader->getAttribute('w:w', $rowNode, 'w:tcPr/w:tcW');
$cellStyle = null; $cellStyle = null;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\Word2007; namespace PhpOffice\PhpWord\Reader\Word2007;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\Word2007; namespace PhpOffice\PhpWord\Reader\Word2007;
use PhpOffice\Common\XMLReader; use PhpOffice\Common\XMLReader;
@ -33,15 +32,15 @@ class DocPropsCore extends AbstractPart
* @var array * @var array
*/ */
protected $mapping = array( protected $mapping = array(
'dc:creator' => 'setCreator', 'dc:creator' => 'setCreator',
'dc:title' => 'setTitle', 'dc:title' => 'setTitle',
'dc:description' => 'setDescription', 'dc:description' => 'setDescription',
'dc:subject' => 'setSubject', 'dc:subject' => 'setSubject',
'cp:keywords' => 'setKeywords', 'cp:keywords' => 'setKeywords',
'cp:category' => 'setCategory', 'cp:category' => 'setCategory',
'cp:lastModifiedBy' => 'setLastModifiedBy', 'cp:lastModifiedBy' => 'setLastModifiedBy',
'dcterms:created' => 'setCreated', 'dcterms:created' => 'setCreated',
'dcterms:modified' => 'setModified', 'dcterms:modified' => 'setModified',
); );
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\Word2007; namespace PhpOffice\PhpWord\Reader\Word2007;
use PhpOffice\Common\XMLReader; use PhpOffice\Common\XMLReader;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\Word2007; namespace PhpOffice\PhpWord\Reader\Word2007;
use PhpOffice\Common\XMLReader; use PhpOffice\Common\XMLReader;
@ -40,7 +39,6 @@ class Document extends AbstractPart
* Read document.xml. * Read document.xml.
* *
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* @return void
*/ */
public function read(PhpWord $phpWord) public function read(PhpWord $phpWord)
{ {
@ -66,7 +64,6 @@ class Document extends AbstractPart
* *
* @param array $settings * @param array $settings
* @param \PhpOffice\PhpWord\Element\Section &$section * @param \PhpOffice\PhpWord\Element\Section &$section
* @return void
*/ */
private function readHeaderFooter($settings, Section &$section) private function readHeaderFooter($settings, Section &$section)
{ {
@ -131,7 +128,7 @@ class Document extends AbstractPart
$id = $xmlReader->getAttribute('r:id', $node); $id = $xmlReader->getAttribute('r:id', $node);
$styles['hf'][$id] = array( $styles['hf'][$id] = array(
'method' => str_replace('w:', '', str_replace('Reference', '', $node->nodeName)), 'method' => str_replace('w:', '', str_replace('Reference', '', $node->nodeName)),
'type' => $xmlReader->getAttribute('w:type', $node), 'type' => $xmlReader->getAttribute('w:type', $node),
); );
} }
} }
@ -145,7 +142,6 @@ class Document extends AbstractPart
* @param \PhpOffice\Common\XMLReader $xmlReader * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $node * @param \DOMElement $node
* @param \PhpOffice\PhpWord\Element\Section &$section * @param \PhpOffice\PhpWord\Element\Section &$section
* @return void
* *
* @todo <w:lastRenderedPageBreak> * @todo <w:lastRenderedPageBreak>
*/ */
@ -175,7 +171,6 @@ class Document extends AbstractPart
* @param \PhpOffice\Common\XMLReader $xmlReader * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $node * @param \DOMElement $node
* @param \PhpOffice\PhpWord\Element\Section &$section * @param \PhpOffice\PhpWord\Element\Section &$section
* @return void
*/ */
private function readWSectPrNode(XMLReader $xmlReader, \DOMElement $node, Section &$section) private function readWSectPrNode(XMLReader $xmlReader, \DOMElement $node, Section &$section)
{ {

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\Word2007; namespace PhpOffice\PhpWord\Reader\Word2007;
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\Word2007; namespace PhpOffice\PhpWord\Reader\Word2007;
use PhpOffice\Common\XMLReader; use PhpOffice\Common\XMLReader;

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\Word2007; namespace PhpOffice\PhpWord\Reader\Word2007;
use PhpOffice\Common\XMLReader; use PhpOffice\Common\XMLReader;
@ -31,7 +30,6 @@ class Numbering extends AbstractPart
* Read numbering.xml. * Read numbering.xml.
* *
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* @return void
*/ */
public function read(PhpWord $phpWord) public function read(PhpWord $phpWord)
{ {
@ -92,7 +90,7 @@ class Numbering extends AbstractPart
* *
* @param \PhpOffice\Common\XMLReader $xmlReader * @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $subnode * @param \DOMElement $subnode
* @param integer $levelId * @param int $levelId
* @return array * @return array
*/ */
private function readLevel(XMLReader $xmlReader, \DOMElement $subnode, $levelId) private function readLevel(XMLReader $xmlReader, \DOMElement $subnode, $levelId)

View File

@ -11,15 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\Word2007; namespace PhpOffice\PhpWord\Reader\Word2007;
use PhpOffice\Common\XMLReader; use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\ComplexType\TrackChangesView; use PhpOffice\PhpWord\ComplexType\TrackChangesView;
use PhpOffice\PhpWord\PhpWord;
/** /**
* Settings reader * Settings reader
@ -28,14 +27,12 @@ use PhpOffice\PhpWord\ComplexType\TrackChangesView;
*/ */
class Settings extends AbstractPart class Settings extends AbstractPart
{ {
private static $booleanProperties = array('hideSpellingErrors', 'hideGrammaticalErrors', 'trackRevisions', 'doNotTrackMoves', 'doNotTrackFormatting', 'evenAndOddHeaders'); private static $booleanProperties = array('hideSpellingErrors', 'hideGrammaticalErrors', 'trackRevisions', 'doNotTrackMoves', 'doNotTrackFormatting', 'evenAndOddHeaders');
/** /**
* Read settings.xml. * Read settings.xml.
* *
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* @return void
*/ */
public function read(PhpWord $phpWord) public function read(PhpWord $phpWord)
{ {
@ -57,9 +54,9 @@ class Settings extends AbstractPart
} else { } else {
$docSettings->$method(true); $docSettings->$method(true);
} }
} else if (method_exists($this, $method)) { } elseif (method_exists($this, $method)) {
$this->$method($xmlReader, $phpWord, $node); $this->$method($xmlReader, $phpWord, $node);
} else if (method_exists($docSettings, $method)) { } elseif (method_exists($docSettings, $method)) {
$docSettings->$method($value); $docSettings->$method($value);
} }
} }
@ -68,7 +65,7 @@ class Settings extends AbstractPart
/** /**
* Sets the document protection * Sets the document protection
* *
* @param XMLReader $xmlReader * @param XMLReader $xmlReader
* @param PhpWord $phpWord * @param PhpWord $phpWord
* @param \DOMNode $node * @param \DOMNode $node
@ -83,7 +80,7 @@ class Settings extends AbstractPart
/** /**
* Sets the proof state * Sets the proof state
* *
* @param XMLReader $xmlReader * @param XMLReader $xmlReader
* @param PhpWord $phpWord * @param PhpWord $phpWord
* @param \DOMNode $node * @param \DOMNode $node
@ -105,7 +102,7 @@ class Settings extends AbstractPart
/** /**
* Sets the proof state * Sets the proof state
* *
* @param XMLReader $xmlReader * @param XMLReader $xmlReader
* @param PhpWord $phpWord * @param PhpWord $phpWord
* @param \DOMNode $node * @param \DOMNode $node
@ -122,7 +119,7 @@ class Settings extends AbstractPart
/** /**
* Set the Revision view * Set the Revision view
* *
* @param XMLReader $xmlReader * @param XMLReader $xmlReader
* @param PhpWord $phpWord * @param PhpWord $phpWord
* @param \DOMNode $node * @param \DOMNode $node

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Reader\Word2007; namespace PhpOffice\PhpWord\Reader\Word2007;
use PhpOffice\Common\XMLReader; use PhpOffice\Common\XMLReader;
@ -31,7 +30,6 @@ class Styles extends AbstractPart
* Read styles.xml. * Read styles.xml.
* *
* @param \PhpOffice\PhpWord\PhpWord $phpWord * @param \PhpOffice\PhpWord\PhpWord $phpWord
* @return void
*/ */
public function read(PhpWord $phpWord) public function read(PhpWord $phpWord)
{ {
@ -49,7 +47,6 @@ class Styles extends AbstractPart
preg_match('/Heading(\d)/', $name, $headingMatches); preg_match('/Heading(\d)/', $name, $headingMatches);
// $default = ($xmlReader->getAttribute('w:default', $node) == 1); // $default = ($xmlReader->getAttribute('w:default', $node) == 1);
switch ($type) { switch ($type) {
case 'paragraph': case 'paragraph':
$paragraphStyle = $this->readParagraphStyle($xmlReader, $node); $paragraphStyle = $this->readParagraphStyle($xmlReader, $node);
$fontStyle = $this->readFontStyle($xmlReader, $node); $fontStyle = $this->readFontStyle($xmlReader, $node);
@ -65,14 +62,12 @@ class Styles extends AbstractPart
} }
} }
break; break;
case 'character': case 'character':
$fontStyle = $this->readFontStyle($xmlReader, $node); $fontStyle = $this->readFontStyle($xmlReader, $node);
if (!empty($fontStyle)) { if (!empty($fontStyle)) {
$phpWord->addFontStyle($name, $fontStyle); $phpWord->addFontStyle($name, $fontStyle);
} }
break; break;
case 'table': case 'table':
$tStyle = $this->readTableStyle($xmlReader, $node); $tStyle = $this->readTableStyle($xmlReader, $node);
if (!empty($tStyle)) { if (!empty($tStyle)) {

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord; namespace PhpOffice\PhpWord;
/** /**
@ -30,8 +29,8 @@ class Settings
* @const string * @const string
*/ */
const ZIPARCHIVE = 'ZipArchive'; const ZIPARCHIVE = 'ZipArchive';
const PCLZIP = 'PclZip'; const PCLZIP = 'PclZip';
const OLD_LIB = 'PhpOffice\\PhpWord\\Shared\\ZipArchive'; // @deprecated 0.11 const OLD_LIB = 'PhpOffice\\PhpWord\\Shared\\ZipArchive'; // @deprecated 0.11
/** /**
* PDF rendering libraries * PDF rendering libraries
@ -39,8 +38,8 @@ class Settings
* @const string * @const string
*/ */
const PDF_RENDERER_DOMPDF = 'DomPDF'; const PDF_RENDERER_DOMPDF = 'DomPDF';
const PDF_RENDERER_TCPDF = 'TCPDF'; const PDF_RENDERER_TCPDF = 'TCPDF';
const PDF_RENDERER_MPDF = 'MPDF'; const PDF_RENDERER_MPDF = 'MPDF';
/** /**
* Measurement units multiplication factor * Measurement units multiplication factor
@ -53,12 +52,12 @@ class Settings
* *
* @const string * @const string
*/ */
const UNIT_TWIP = 'twip'; // = 1/20 point const UNIT_TWIP = 'twip'; // = 1/20 point
const UNIT_CM = 'cm'; const UNIT_CM = 'cm';
const UNIT_MM = 'mm'; const UNIT_MM = 'mm';
const UNIT_INCH = 'inch'; const UNIT_INCH = 'inch';
const UNIT_POINT = 'point'; // = 1/72 inch const UNIT_POINT = 'point'; // = 1/72 inch
const UNIT_PICA = 'pica'; // = 1/6 inch = 12 points const UNIT_PICA = 'pica'; // = 1/6 inch = 12 points
/** /**
* Default font settings * Default font settings
@ -154,7 +153,7 @@ class Settings
*/ */
public static function setCompatibility($compatibility) public static function setCompatibility($compatibility)
{ {
$compatibility = (bool)$compatibility; $compatibility = (bool) $compatibility;
self::$xmlWriterCompatibility = $compatibility; self::$xmlWriterCompatibility = $compatibility;
return true; return true;
@ -180,6 +179,7 @@ class Settings
{ {
if (in_array($zipClass, array(self::PCLZIP, self::ZIPARCHIVE, self::OLD_LIB))) { if (in_array($zipClass, array(self::PCLZIP, self::ZIPARCHIVE, self::OLD_LIB))) {
self::$zipClass = $zipClass; self::$zipClass = $zipClass;
return true; return true;
} }
@ -229,7 +229,6 @@ class Settings
return true; return true;
} }
/** /**
* Return the directory path to the PDF Rendering Library. * Return the directory path to the PDF Rendering Library.
* *
@ -275,7 +274,7 @@ class Settings
public static function setMeasurementUnit($value) public static function setMeasurementUnit($value)
{ {
$units = array(self::UNIT_TWIP, self::UNIT_CM, self::UNIT_MM, self::UNIT_INCH, $units = array(self::UNIT_TWIP, self::UNIT_CM, self::UNIT_MM, self::UNIT_INCH,
self::UNIT_POINT, self::UNIT_PICA); self::UNIT_POINT, self::UNIT_PICA, );
if (!in_array($value, $units)) { if (!in_array($value, $units)) {
return false; return false;
} }
@ -289,7 +288,7 @@ class Settings
* *
* @since 0.12.0 * @since 0.12.0
* *
* @param string $tempDir The user defined path to temporary directory. * @param string $tempDir The user defined path to temporary directory
* *
* @return void * @return void
*/ */
@ -318,8 +317,8 @@ class Settings
/** /**
* @since 0.13.0 * @since 0.13.0
* *
* @return boolean * @return bool
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -330,8 +329,8 @@ class Settings
/** /**
* @since 0.13.0 * @since 0.13.0
* *
* @param boolean $outputEscapingEnabled * @param bool $outputEscapingEnabled
* *
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
@ -360,6 +359,7 @@ class Settings
{ {
if (is_string($value) && trim($value) !== '') { if (is_string($value) && trim($value) !== '') {
self::$defaultFontName = $value; self::$defaultFontName = $value;
return true; return true;
} }
@ -369,7 +369,7 @@ class Settings
/** /**
* Get default font size * Get default font size
* *
* @return integer * @return int
*/ */
public static function getDefaultFontSize() public static function getDefaultFontSize()
{ {
@ -384,9 +384,10 @@ class Settings
*/ */
public static function setDefaultFontSize($value) public static function setDefaultFontSize($value)
{ {
$value = intval($value); $value = (int) $value;
if ($value > 0) { if ($value > 0) {
self::$defaultFontSize = $value; self::$defaultFontSize = $value;
return true; return true;
} }

View File

@ -3,7 +3,6 @@ namespace PhpOffice\PhpWord\Shared;
abstract class AbstractEnum abstract class AbstractEnum
{ {
private static $constCacheArray = null; private static $constCacheArray = null;
private static function getConstants() private static function getConstants()
@ -12,16 +11,17 @@ abstract class AbstractEnum
self::$constCacheArray = array(); self::$constCacheArray = array();
} }
$calledClass = get_called_class(); $calledClass = get_called_class();
if (! array_key_exists($calledClass, self::$constCacheArray)) { if (!array_key_exists($calledClass, self::$constCacheArray)) {
$reflect = new \ReflectionClass($calledClass); $reflect = new \ReflectionClass($calledClass);
self::$constCacheArray[$calledClass] = $reflect->getConstants(); self::$constCacheArray[$calledClass] = $reflect->getConstants();
} }
return self::$constCacheArray[$calledClass]; return self::$constCacheArray[$calledClass];
} }
/** /**
* Returns all values for this enum * Returns all values for this enum
* *
* @return array * @return array
*/ */
public static function values() public static function values()
@ -31,19 +31,20 @@ abstract class AbstractEnum
/** /**
* Returns true the value is valid for this enum * Returns true the value is valid for this enum
* *
* @param strign $value * @param strign $value
* @return boolean true if value is valid * @return bool true if value is valid
*/ */
public static function isValid($value) public static function isValid($value)
{ {
$values = array_values(self::getConstants()); $values = array_values(self::getConstants());
return in_array($value, $values, true); return in_array($value, $values, true);
} }
/** /**
* Validates that the value passed is a valid value * Validates that the value passed is a valid value
* *
* @param string $value * @param string $value
* @throws \InvalidArgumentException if the value passed is not valid for this enum * @throws \InvalidArgumentException if the value passed is not valid for this enum
*/ */

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Shared; namespace PhpOffice\PhpWord\Shared;
/** /**
@ -22,12 +21,12 @@ namespace PhpOffice\PhpWord\Shared;
*/ */
class Converter class Converter
{ {
const INCH_TO_CM = 2.54; const INCH_TO_CM = 2.54;
const INCH_TO_TWIP = 1440; const INCH_TO_TWIP = 1440;
const INCH_TO_PIXEL = 96; const INCH_TO_PIXEL = 96;
const INCH_TO_POINT = 72; const INCH_TO_POINT = 72;
const PIXEL_TO_EMU = 9525; const PIXEL_TO_EMU = 9525;
const DEGREE_TO_ANGLE = 60000; const DEGREE_TO_ANGLE = 60000;
/** /**
* Convert centimeter to twip * Convert centimeter to twip
@ -235,7 +234,7 @@ class Converter
*/ */
public static function degreeToAngle($degree = 1) public static function degreeToAngle($degree = 1)
{ {
return (int)round($degree * self::DEGREE_TO_ANGLE); return (int) round($degree * self::DEGREE_TO_ANGLE);
} }
/** /**

View File

@ -11,10 +11,9 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
* *
* @link https://github.com/PHPOffice/PHPWord * @link https://github.com/PHPOffice/PHPWord
* @copyright 2010-2016 PHPWord contributors * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/ */
namespace PhpOffice\PhpWord\Shared; namespace PhpOffice\PhpWord\Shared;
use PhpOffice\PhpWord\Element\AbstractContainer; use PhpOffice\PhpWord\Element\AbstractContainer;
@ -235,7 +234,7 @@ class Html
// Commented as source of bug #257. `method_exists` doesn't seems to work properly in this case. // Commented as source of bug #257. `method_exists` doesn't seems to work properly in this case.
// @todo Find better error checking for this one // @todo Find better error checking for this one
// if (method_exists($element, 'addText')) { // if (method_exists($element, 'addText')) {
$element->addText($node->nodeValue, $styles['font'], $styles['paragraph']); $element->addText($node->nodeValue, $styles['font'], $styles['paragraph']);
// } // }
return null; return null;
@ -275,14 +274,14 @@ class Html
// $attributes = $node->attributes; // $attributes = $node->attributes;
// if ($attributes->getNamedItem('width') !== null) { // if ($attributes->getNamedItem('width') !== null) {
// $newElement->setWidth($attributes->getNamedItem('width')->value); // $newElement->setWidth($attributes->getNamedItem('width')->value);
// } // }
// if ($attributes->getNamedItem('height') !== null) { // if ($attributes->getNamedItem('height') !== null) {
// $newElement->setHeight($attributes->getNamedItem('height')->value); // $newElement->setHeight($attributes->getNamedItem('height')->value);
// } // }
// if ($attributes->getNamedItem('width') !== null) { // if ($attributes->getNamedItem('width') !== null) {
// $newElement=$element->addCell($width=$attributes->getNamedItem('width')->value); // $newElement=$element->addCell($width=$attributes->getNamedItem('width')->value);
// } // }
return $newElement; return $newElement;
@ -364,10 +363,10 @@ class Html
$styles['alignment'] = $cValue; // todo: any mapping? $styles['alignment'] = $cValue; // todo: any mapping?
break; break;
case 'color': case 'color':
$styles['color'] = trim($cValue, "#"); $styles['color'] = trim($cValue, '#');
break; break;
case 'background-color': case 'background-color':
$styles['bgColor'] = trim($cValue, "#"); $styles['bgColor'] = trim($cValue, '#');
break; break;
} }
} }

Some files were not shown because too many files have changed in this diff Show More