general updates
Change "some" code to comply to php-cs rules Update copyright year to 2010-2017
This commit is contained in:
commit
a8ade6d22d
22
.php_cs.dist
22
.php_cs.dist
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->exclude('vendor')
|
||||
->notPath('src/PhpWord/Shared/PCLZip/pclzip.lib.php')
|
||||
->notName('pclzip.lib.php')
|
||||
->notName('OLERead.php')
|
||||
->in('samples')
|
||||
->in('src')
|
||||
->in('tests');
|
||||
|
|
@ -10,18 +10,18 @@ $finder = PhpCsFixer\Finder::create()
|
|||
return PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setFinder($finder)
|
||||
->setRules([
|
||||
'array_syntax' => ['syntax' => 'long'],
|
||||
'binary_operator_spaces' => ['align_double_arrow' => true],
|
||||
->setRules(array(
|
||||
'array_syntax' => array('syntax' => 'long'),
|
||||
'binary_operator_spaces' => array('align_double_arrow' => true),
|
||||
'blank_line_after_namespace' => true,
|
||||
'blank_line_after_opening_tag' => true,
|
||||
'blank_line_after_opening_tag' => false,
|
||||
'blank_line_before_return' => true,
|
||||
'braces' => true,
|
||||
'cast_spaces' => true,
|
||||
'class_definition' => true,
|
||||
'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE
|
||||
'combine_consecutive_unsets' => true,
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'concat_space' => array('spacing' => 'one'),
|
||||
'declare_equal_normalize' => true,
|
||||
'declare_strict_types' => false, // Too early to adopt strict types
|
||||
'dir_constant' => true,
|
||||
|
|
@ -58,7 +58,7 @@ return PhpCsFixer\Config::create()
|
|||
'no_empty_comment' => true,
|
||||
'no_empty_phpdoc' => 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_namespace_whitespace' => true,
|
||||
'no_mixed_echo_print' => true,
|
||||
|
|
@ -99,7 +99,7 @@ return PhpCsFixer\Config::create()
|
|||
'phpdoc_inline_tag' => true,
|
||||
'phpdoc_no_access' => true,
|
||||
'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_useless_inheritdoc' => true,
|
||||
'phpdoc_order' => true,
|
||||
|
|
@ -113,7 +113,7 @@ return PhpCsFixer\Config::create()
|
|||
'phpdoc_types' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
'pow_to_exponentiation' => false,
|
||||
'pre_increment' => true,
|
||||
'pre_increment' => false,
|
||||
'protected_to_private' => true,
|
||||
'psr0' => true,
|
||||
'psr4' => true,
|
||||
|
|
@ -143,4 +143,4 @@ return PhpCsFixer\Config::create()
|
|||
'unary_operator_spaces' => true,
|
||||
'visibility_required' => true,
|
||||
'whitespace_after_comma_in_array' => true,
|
||||
]);
|
||||
));
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ cache:
|
|||
directories:
|
||||
- vendor
|
||||
- $HOME/.composer/cache
|
||||
- $HOME/.php-cs-fixer
|
||||
|
||||
env:
|
||||
global:
|
||||
|
|
@ -46,7 +47,7 @@ script:
|
|||
## PHP_CodeSniffer
|
||||
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip ; fi
|
||||
## 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
|
||||
- if [ -z "$COVERAGE" ]; then ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php ; fi
|
||||
## PHPUnit
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. test bootstrap
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ $phpWord->addParagraphStyle(
|
|||
new \PhpOffice\PhpWord\Style\Tab('left', 1550),
|
||||
new \PhpOffice\PhpWord\Style\Tab('center', 3200),
|
||||
new \PhpOffice\PhpWord\Style\Tab('right', 5300),
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,62 +1,62 @@
|
|||
<?php
|
||||
include_once 'Sample_Header.php';
|
||||
|
||||
// Template processor instance creation
|
||||
echo date('H:i:s'), ' Creating new TemplateProcessor instance...', EOL;
|
||||
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx');
|
||||
|
||||
// Variables on different parts of document
|
||||
$templateProcessor->setValue('weekday', date('l')); // On section/content
|
||||
$templateProcessor->setValue('time', date('H:i')); // On footer
|
||||
$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
|
||||
|
||||
// Simple table
|
||||
$templateProcessor->cloneRow('rowValue', 10);
|
||||
|
||||
$templateProcessor->setValue('rowValue#1', 'Sun');
|
||||
$templateProcessor->setValue('rowValue#2', 'Mercury');
|
||||
$templateProcessor->setValue('rowValue#3', 'Venus');
|
||||
$templateProcessor->setValue('rowValue#4', 'Earth');
|
||||
$templateProcessor->setValue('rowValue#5', 'Mars');
|
||||
$templateProcessor->setValue('rowValue#6', 'Jupiter');
|
||||
$templateProcessor->setValue('rowValue#7', 'Saturn');
|
||||
$templateProcessor->setValue('rowValue#8', 'Uranus');
|
||||
$templateProcessor->setValue('rowValue#9', 'Neptun');
|
||||
$templateProcessor->setValue('rowValue#10', 'Pluto');
|
||||
|
||||
$templateProcessor->setValue('rowNumber#1', '1');
|
||||
$templateProcessor->setValue('rowNumber#2', '2');
|
||||
$templateProcessor->setValue('rowNumber#3', '3');
|
||||
$templateProcessor->setValue('rowNumber#4', '4');
|
||||
$templateProcessor->setValue('rowNumber#5', '5');
|
||||
$templateProcessor->setValue('rowNumber#6', '6');
|
||||
$templateProcessor->setValue('rowNumber#7', '7');
|
||||
$templateProcessor->setValue('rowNumber#8', '8');
|
||||
$templateProcessor->setValue('rowNumber#9', '9');
|
||||
$templateProcessor->setValue('rowNumber#10', '10');
|
||||
|
||||
// Table with a spanned cell
|
||||
$templateProcessor->cloneRow('userId', 3);
|
||||
|
||||
$templateProcessor->setValue('userId#1', '1');
|
||||
$templateProcessor->setValue('userFirstName#1', 'James');
|
||||
$templateProcessor->setValue('userName#1', 'Taylor');
|
||||
$templateProcessor->setValue('userPhone#1', '+1 428 889 773');
|
||||
|
||||
$templateProcessor->setValue('userId#2', '2');
|
||||
$templateProcessor->setValue('userFirstName#2', 'Robert');
|
||||
$templateProcessor->setValue('userName#2', 'Bell');
|
||||
$templateProcessor->setValue('userPhone#2', '+1 428 889 774');
|
||||
|
||||
$templateProcessor->setValue('userId#3', '3');
|
||||
$templateProcessor->setValue('userFirstName#3', 'Michael');
|
||||
$templateProcessor->setValue('userName#3', 'Ray');
|
||||
$templateProcessor->setValue('userPhone#3', '+1 428 889 775');
|
||||
|
||||
echo date('H:i:s'), ' Saving the result document...', EOL;
|
||||
$templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx');
|
||||
|
||||
echo getEndingNotes(array('Word2007' => 'docx'));
|
||||
if (!CLI) {
|
||||
include_once 'Sample_Footer.php';
|
||||
}
|
||||
<?php
|
||||
include_once 'Sample_Header.php';
|
||||
|
||||
// Template processor instance creation
|
||||
echo date('H:i:s'), ' Creating new TemplateProcessor instance...', EOL;
|
||||
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('resources/Sample_07_TemplateCloneRow.docx');
|
||||
|
||||
// Variables on different parts of document
|
||||
$templateProcessor->setValue('weekday', date('l')); // On section/content
|
||||
$templateProcessor->setValue('time', date('H:i')); // On footer
|
||||
$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
|
||||
|
||||
// Simple table
|
||||
$templateProcessor->cloneRow('rowValue', 10);
|
||||
|
||||
$templateProcessor->setValue('rowValue#1', 'Sun');
|
||||
$templateProcessor->setValue('rowValue#2', 'Mercury');
|
||||
$templateProcessor->setValue('rowValue#3', 'Venus');
|
||||
$templateProcessor->setValue('rowValue#4', 'Earth');
|
||||
$templateProcessor->setValue('rowValue#5', 'Mars');
|
||||
$templateProcessor->setValue('rowValue#6', 'Jupiter');
|
||||
$templateProcessor->setValue('rowValue#7', 'Saturn');
|
||||
$templateProcessor->setValue('rowValue#8', 'Uranus');
|
||||
$templateProcessor->setValue('rowValue#9', 'Neptun');
|
||||
$templateProcessor->setValue('rowValue#10', 'Pluto');
|
||||
|
||||
$templateProcessor->setValue('rowNumber#1', '1');
|
||||
$templateProcessor->setValue('rowNumber#2', '2');
|
||||
$templateProcessor->setValue('rowNumber#3', '3');
|
||||
$templateProcessor->setValue('rowNumber#4', '4');
|
||||
$templateProcessor->setValue('rowNumber#5', '5');
|
||||
$templateProcessor->setValue('rowNumber#6', '6');
|
||||
$templateProcessor->setValue('rowNumber#7', '7');
|
||||
$templateProcessor->setValue('rowNumber#8', '8');
|
||||
$templateProcessor->setValue('rowNumber#9', '9');
|
||||
$templateProcessor->setValue('rowNumber#10', '10');
|
||||
|
||||
// Table with a spanned cell
|
||||
$templateProcessor->cloneRow('userId', 3);
|
||||
|
||||
$templateProcessor->setValue('userId#1', '1');
|
||||
$templateProcessor->setValue('userFirstName#1', 'James');
|
||||
$templateProcessor->setValue('userName#1', 'Taylor');
|
||||
$templateProcessor->setValue('userPhone#1', '+1 428 889 773');
|
||||
|
||||
$templateProcessor->setValue('userId#2', '2');
|
||||
$templateProcessor->setValue('userFirstName#2', 'Robert');
|
||||
$templateProcessor->setValue('userName#2', 'Bell');
|
||||
$templateProcessor->setValue('userPhone#2', '+1 428 889 774');
|
||||
|
||||
$templateProcessor->setValue('userId#3', '3');
|
||||
$templateProcessor->setValue('userFirstName#3', 'Michael');
|
||||
$templateProcessor->setValue('userName#3', 'Ray');
|
||||
$templateProcessor->setValue('userPhone#3', '+1 428 889 775');
|
||||
|
||||
echo date('H:i:s'), ' Saving the result document...', EOL;
|
||||
$templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx');
|
||||
|
||||
echo getEndingNotes(array('Word2007' => 'docx'));
|
||||
if (!CLI) {
|
||||
include_once 'Sample_Footer.php';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ $section->addText(
|
|||
'Below are the samples on how to control your paragraph '
|
||||
. 'pagination. See "Line and Page Break" tab on paragraph properties '
|
||||
. 'window to see the attribute set by these controls.',
|
||||
array('bold' => true),
|
||||
array('bold' => true),
|
||||
array('space' => array('before' => 360, 'after' => 480))
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -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}");
|
||||
$text = (0== $i % 2) ? 'X' : '';
|
||||
$text = (0 == $i % 2) ? 'X' : '';
|
||||
$table->addCell(500)->addText($text);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* 3. colspan (gridSpan) and rowspan (vMerge)
|
||||
* ---------------------
|
||||
* | | B | |
|
||||
|
|
@ -93,7 +93,7 @@ $table->addCell(2000, $cellVCentered)->addText('C', null, $cellHCentered);
|
|||
$table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered);
|
||||
$table->addCell(null, $cellRowContinue);
|
||||
|
||||
/**
|
||||
/*
|
||||
* 4. colspan (gridSpan) and rowspan (vMerge)
|
||||
* ---------------------
|
||||
* | | B | 1 |
|
||||
|
|
@ -104,6 +104,7 @@ $table->addCell(null, $cellRowContinue);
|
|||
* ---------------------
|
||||
* @see https://github.com/PHPOffice/PHPWord/issues/806
|
||||
*/
|
||||
|
||||
$section->addPageBreak();
|
||||
$section->addText('Table with colspan and rowspan', $header);
|
||||
|
||||
|
|
@ -114,12 +115,12 @@ $table = $section->addTable('Colspan Rowspan');
|
|||
$row = $table->addRow();
|
||||
|
||||
$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 = $table->addRow();
|
||||
$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 = $table->addRow();
|
||||
$row->addCell(null, array('vMerge' => 'continue'));
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ $section->addImage($source);
|
|||
// Image from string
|
||||
$source = 'resources/_mars.jpg';
|
||||
$fileContent = file_get_contents($source);
|
||||
$section->addText("Image from string");
|
||||
$section->addText('Image from string');
|
||||
$section->addImage($fileContent);
|
||||
|
||||
//Wrapping style
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ $textrun->addText('here:');
|
|||
|
||||
$indexEntryText = new TextRun();
|
||||
$indexEntryText->addText('My ');
|
||||
$indexEntryText->addText('bold index', ['bold' => true]);
|
||||
$indexEntryText->addText('bold index', array('bold' => true));
|
||||
$indexEntryText->addText(' entry');
|
||||
|
||||
$textrun = $section->addTextRun();
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ $image->setCommentRangeStart($commentOnImage);
|
|||
$section->addTextBreak(2);
|
||||
|
||||
// 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->addText('Test', array('bold' => true));
|
||||
|
|
@ -55,7 +55,6 @@ $comment1->setStartElement($anotherText);
|
|||
$comment1->setEndElement($anotherText);
|
||||
$phpWord->addComment($comment1);
|
||||
|
||||
|
||||
// Save file
|
||||
echo write($phpWord, basename(__FILE__, '.php'), $writers);
|
||||
if (!CLI) {
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ function getEndingNotes($writers)
|
|||
|
||||
// Do not show execution time for index
|
||||
if (!IS_INDEX) {
|
||||
$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') . ' Done writing file(s)' . EOL;
|
||||
$result .= date('H:i:s') . ' Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . ' MB' . EOL;
|
||||
}
|
||||
|
||||
// Return
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ $requirements = array(
|
|||
'xsl' => array('PHP extension XSL (optional)', extension_loaded('xsl')),
|
||||
);
|
||||
if (!CLI) {
|
||||
?>
|
||||
?>
|
||||
<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> </p>
|
||||
|
|
@ -25,14 +25,14 @@ if (!CLI) {
|
|||
<?php
|
||||
}
|
||||
if (!CLI) {
|
||||
echo "<h3>Requirement check:</h3>";
|
||||
echo "<ul>";
|
||||
echo '<h3>Requirement check:</h3>';
|
||||
echo '<ul>';
|
||||
foreach ($requirements as $key => $value) {
|
||||
list($label, $result) = $value;
|
||||
$status = $result ? 'passed' : 'failed';
|
||||
echo "<li>{$label} ... <span class='{$status}'>{$status}</span></li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
echo '</ul>';
|
||||
include_once 'Sample_Footer.php';
|
||||
} else {
|
||||
echo 'Requirement check:' . PHP_EOL;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
/**
|
||||
|
|
@ -51,9 +50,9 @@ abstract class AbstractCollection
|
|||
{
|
||||
if (array_key_exists($index, $this->items)) {
|
||||
return $this->items[$index];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Collection;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\ComplexType;
|
||||
|
|
@ -25,7 +25,6 @@ use PhpOffice\PhpWord\SimpleType\NumberFormat;
|
|||
*/
|
||||
final class FootnoteProperties
|
||||
{
|
||||
|
||||
const RESTART_NUMBER_CONTINUOUS = 'continuous';
|
||||
const RESTART_NUMBER_EACH_SECTION = 'eachSect';
|
||||
const RESTART_NUMBER_EACH_PAGE = 'eachPage';
|
||||
|
|
@ -52,7 +51,7 @@ final class FootnoteProperties
|
|||
/**
|
||||
* Footnote and Endnote Numbering Starting Value
|
||||
*
|
||||
* @var double
|
||||
* @var float
|
||||
*/
|
||||
private $numStart;
|
||||
|
||||
|
|
@ -65,7 +64,7 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Get the Footnote Positioning Location
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPos()
|
||||
|
|
@ -75,7 +74,7 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd)
|
||||
*
|
||||
*
|
||||
* @param string $pos
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
|
|
@ -86,20 +85,21 @@ final class FootnoteProperties
|
|||
self::POSITION_PAGE_BOTTOM,
|
||||
self::POSITION_BENEATH_TEXT,
|
||||
self::POSITION_SECTION_END,
|
||||
self::POSITION_DOC_END
|
||||
self::POSITION_DOC_END,
|
||||
);
|
||||
|
||||
if (in_array($pos, $position)) {
|
||||
$this->pos = $pos;
|
||||
} else {
|
||||
throw new \InvalidArgumentException("Invalid value, on of " . implode(', ', $position) . " possible");
|
||||
throw new \InvalidArgumentException('Invalid value, on of ' . implode(', ', $position) . ' possible');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Footnote Numbering Format
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNumFmt()
|
||||
|
|
@ -109,7 +109,7 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Set the Footnote Numbering Format
|
||||
*
|
||||
*
|
||||
* @param string $numFmt One of NumberFormat
|
||||
* @return self
|
||||
*/
|
||||
|
|
@ -117,13 +117,14 @@ final class FootnoteProperties
|
|||
{
|
||||
NumberFormat::validate($numFmt);
|
||||
$this->numFmt = $numFmt;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Footnote Numbering Format
|
||||
*
|
||||
* @return double
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getNumStart()
|
||||
{
|
||||
|
|
@ -132,19 +133,20 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Set the Footnote Numbering Format
|
||||
*
|
||||
* @param double $numStart
|
||||
*
|
||||
* @param float $numStart
|
||||
* @return self
|
||||
*/
|
||||
public function setNumStart($numStart)
|
||||
{
|
||||
$this->numStart = $numStart;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Footnote and Endnote Numbering Starting Value
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNumRestart()
|
||||
|
|
@ -154,7 +156,7 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage)
|
||||
*
|
||||
*
|
||||
* @param string $numRestart
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
|
|
@ -164,14 +166,15 @@ final class FootnoteProperties
|
|||
$restartNumbers = array(
|
||||
self::RESTART_NUMBER_CONTINUOUS,
|
||||
self::RESTART_NUMBER_EACH_SECTION,
|
||||
self::RESTART_NUMBER_EACH_PAGE
|
||||
self::RESTART_NUMBER_EACH_PAGE,
|
||||
);
|
||||
|
||||
if (in_array($numRestart, $restartNumbers)) {
|
||||
$this->numRestart= $numRestart;
|
||||
$this->numRestart = $numRestart;
|
||||
} else {
|
||||
throw new \InvalidArgumentException("Invalid value, on of " . implode(', ', $restartNumbers) . " possible");
|
||||
throw new \InvalidArgumentException('Invalid value, on of ' . implode(', ', $restartNumbers) . ' possible');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\ComplexType;
|
||||
|
|
@ -23,7 +23,6 @@ namespace PhpOffice\PhpWord\ComplexType;
|
|||
*/
|
||||
final class ProofState
|
||||
{
|
||||
|
||||
/**
|
||||
* Check Completed
|
||||
*/
|
||||
|
|
@ -51,7 +50,7 @@ final class ProofState
|
|||
/**
|
||||
* Set the Spell Checking State (dirty or clean)
|
||||
*
|
||||
* @param string $spelling
|
||||
* @param string $spelling
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
*/
|
||||
|
|
@ -60,8 +59,9 @@ final class ProofState
|
|||
if ($spelling == self::CLEAN || $spelling == self::DIRTY) {
|
||||
$this->spelling = $spelling;
|
||||
} else {
|
||||
throw new \InvalidArgumentException("Invalid value, dirty or clean possible");
|
||||
throw new \InvalidArgumentException('Invalid value, dirty or clean possible');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ final class ProofState
|
|||
/**
|
||||
* Set the Grammatical Checking State (dirty or clean)
|
||||
*
|
||||
* @param string $grammar
|
||||
* @param string $grammar
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
*/
|
||||
|
|
@ -87,8 +87,9 @@ final class ProofState
|
|||
if ($grammar == self::CLEAN || $grammar == self::DIRTY) {
|
||||
$this->grammar = $grammar;
|
||||
} else {
|
||||
throw new \InvalidArgumentException("Invalid value, dirty or clean possible");
|
||||
throw new \InvalidArgumentException('Invalid value, dirty or clean possible');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\ComplexType;
|
||||
|
|
@ -23,46 +23,45 @@ namespace PhpOffice\PhpWord\ComplexType;
|
|||
*/
|
||||
final class TrackChangesView
|
||||
{
|
||||
|
||||
/**
|
||||
* Display Visual Indicator Of Markup Area
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $markup;
|
||||
|
||||
/**
|
||||
* Display Comments
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $comments;
|
||||
|
||||
/**
|
||||
* Display Content Revisions
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $insDel;
|
||||
|
||||
/**
|
||||
* Display Formatting Revisions
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $formatting;
|
||||
|
||||
/**
|
||||
* Display Ink Annotations
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $inkAnnotations;
|
||||
|
||||
/**
|
||||
* Get Display Visual Indicator Of Markup Area
|
||||
*
|
||||
* @return boolean True if markup is shown
|
||||
* @return bool True if markup is shown
|
||||
*/
|
||||
public function hasMarkup()
|
||||
{
|
||||
|
|
@ -72,7 +71,7 @@ final class TrackChangesView
|
|||
/**
|
||||
* Set Display Visual Indicator Of Markup Area
|
||||
*
|
||||
* @param boolean $markup
|
||||
* @param bool $markup
|
||||
* Set to true to show markup
|
||||
*/
|
||||
public function setMarkup($markup)
|
||||
|
|
@ -83,7 +82,7 @@ final class TrackChangesView
|
|||
/**
|
||||
* Get Display Comments
|
||||
*
|
||||
* @return boolean True if comments are shown
|
||||
* @return bool True if comments are shown
|
||||
*/
|
||||
public function hasComments()
|
||||
{
|
||||
|
|
@ -93,7 +92,7 @@ final class TrackChangesView
|
|||
/**
|
||||
* Set Display Comments
|
||||
*
|
||||
* @param boolean $comments
|
||||
* @param bool $comments
|
||||
* Set to true to show comments
|
||||
*/
|
||||
public function setComments($comments)
|
||||
|
|
@ -104,7 +103,7 @@ final class TrackChangesView
|
|||
/**
|
||||
* Get Display Content Revisions
|
||||
*
|
||||
* @return boolean True if content revisions are shown
|
||||
* @return bool True if content revisions are shown
|
||||
*/
|
||||
public function hasInsDel()
|
||||
{
|
||||
|
|
@ -114,7 +113,7 @@ final class TrackChangesView
|
|||
/**
|
||||
* Set Display Content Revisions
|
||||
*
|
||||
* @param boolean $insDel
|
||||
* @param bool $insDel
|
||||
* Set to true to show content revisions
|
||||
*/
|
||||
public function setInsDel($insDel)
|
||||
|
|
@ -125,7 +124,7 @@ final class TrackChangesView
|
|||
/**
|
||||
* Get Display Formatting Revisions
|
||||
*
|
||||
* @return boolean True if formatting revisions are shown
|
||||
* @return bool True if formatting revisions are shown
|
||||
*/
|
||||
public function hasFormatting()
|
||||
{
|
||||
|
|
@ -135,7 +134,7 @@ final class TrackChangesView
|
|||
/**
|
||||
* Set Display Formatting Revisions
|
||||
*
|
||||
* @param boolean $insDel
|
||||
* @param bool $formatting
|
||||
* Set to true to show formatting revisions
|
||||
*/
|
||||
public function setFormatting($formatting)
|
||||
|
|
@ -146,7 +145,7 @@ final class TrackChangesView
|
|||
/**
|
||||
* Get Display Ink Annotations
|
||||
*
|
||||
* @return boolean True if ink annotations are shown
|
||||
* @return bool True if ink annotations are shown
|
||||
*/
|
||||
public function hasInkAnnotations()
|
||||
{
|
||||
|
|
@ -156,7 +155,7 @@ final class TrackChangesView
|
|||
/**
|
||||
* Set Display Ink Annotations
|
||||
*
|
||||
* @param boolean $inkAnnotations
|
||||
* @param bool $inkAnnotations
|
||||
* Set to true to show ink annotations
|
||||
*/
|
||||
public function setInkAnnotations($inkAnnotations)
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
|
|
@ -37,7 +36,7 @@ namespace PhpOffice\PhpWord\Element;
|
|||
* @method PageBreak addPageBreak()
|
||||
* @method Table addTable(mixed $style = null)
|
||||
* @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 Field addField(string $type = null, array $properties = array(), array $options = array(), mixed $text = null)
|
||||
* @method Line addLine(mixed $lineStyle = null)
|
||||
|
|
@ -83,7 +82,7 @@ abstract class AbstractContainer extends AbstractElement
|
|||
'ListItem', 'ListItemRun', 'Table', 'Image', 'Object',
|
||||
'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field',
|
||||
'Line', 'Shape', 'Title', 'TOC', 'PageBreak',
|
||||
'Chart', 'FormField', 'SDT', 'Comment'
|
||||
'Chart', 'FormField', 'SDT', 'Comment',
|
||||
);
|
||||
$functions = array();
|
||||
foreach ($elements as $element) {
|
||||
|
|
@ -105,9 +104,8 @@ abstract class AbstractContainer extends AbstractElement
|
|||
for ($i = 1; $i <= $count; $i++) {
|
||||
$this->addElement($element, $fontStyle, $paragraphStyle);
|
||||
}
|
||||
|
||||
// All other elements
|
||||
} else {
|
||||
// All other elements
|
||||
array_unshift($args, $element); // Prepend element name to the beginning of args array
|
||||
return call_user_func_array(array($this, 'addElement'), $args);
|
||||
}
|
||||
|
|
@ -181,9 +179,8 @@ abstract class AbstractContainer extends AbstractElement
|
|||
*
|
||||
* @param string $method
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
* @return bool
|
||||
*/
|
||||
private function checkValidity($method)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Media;
|
||||
|
|
@ -116,14 +115,14 @@ abstract class AbstractElement
|
|||
|
||||
/**
|
||||
* The start position for the linked comment
|
||||
*
|
||||
*
|
||||
* @var Comment
|
||||
*/
|
||||
protected $commentRangeStart;
|
||||
|
||||
/**
|
||||
* The end position for the linked comment
|
||||
*
|
||||
*
|
||||
* @var Comment
|
||||
*/
|
||||
protected $commentRangeEnd;
|
||||
|
|
@ -142,7 +141,6 @@ abstract class AbstractElement
|
|||
* Set PhpWord as reference.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @return void
|
||||
*/
|
||||
public function setPhpWord(PhpWord $phpWord = null)
|
||||
{
|
||||
|
|
@ -164,7 +162,6 @@ abstract class AbstractElement
|
|||
*
|
||||
* @param string $docPart
|
||||
* @param int $docPartId
|
||||
* @return void
|
||||
*/
|
||||
public function setDocPart($docPart, $docPartId = 1)
|
||||
{
|
||||
|
|
@ -221,7 +218,6 @@ abstract class AbstractElement
|
|||
* Set element index.
|
||||
*
|
||||
* @param int $value
|
||||
* @return void
|
||||
*/
|
||||
public function setElementIndex($value)
|
||||
{
|
||||
|
|
@ -240,8 +236,6 @@ abstract class AbstractElement
|
|||
|
||||
/**
|
||||
* Set element unique ID from 6 first digit of md5.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setElementId()
|
||||
{
|
||||
|
|
@ -262,7 +256,6 @@ abstract class AbstractElement
|
|||
* Set relation Id.
|
||||
*
|
||||
* @param int $value
|
||||
* @return void
|
||||
*/
|
||||
public function setRelationId($value)
|
||||
{
|
||||
|
|
@ -291,15 +284,15 @@ abstract class AbstractElement
|
|||
|
||||
/**
|
||||
* Set comment start
|
||||
*
|
||||
*
|
||||
* @param Comment $value
|
||||
*/
|
||||
public function setCommentRangeStart(Comment $value)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -317,14 +310,13 @@ abstract class AbstractElement
|
|||
* Set comment end
|
||||
*
|
||||
* @param Comment $value
|
||||
* @return void
|
||||
*/
|
||||
public function setCommentRangeEnd(Comment $value)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -334,7 +326,6 @@ abstract class AbstractElement
|
|||
* Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $container
|
||||
* @return void
|
||||
*/
|
||||
public function setParentContainer(AbstractElement $container)
|
||||
{
|
||||
|
|
@ -363,8 +354,6 @@ abstract class AbstractElement
|
|||
*
|
||||
* - Image element needs to be passed to Media object
|
||||
* - Icon needs to be set for Object element
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function setMediaRelation()
|
||||
{
|
||||
|
|
@ -391,8 +380,6 @@ abstract class AbstractElement
|
|||
|
||||
/**
|
||||
* Set relation Id for elements that will be registered in the Collection subnamespaces.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function setCollectionRelation()
|
||||
{
|
||||
|
|
@ -411,7 +398,7 @@ abstract class AbstractElement
|
|||
*/
|
||||
public function isInSection()
|
||||
{
|
||||
return ($this->docPart == 'Section');
|
||||
return $this->docPart == 'Section';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -441,9 +428,8 @@ abstract class AbstractElement
|
|||
* @param array $enum
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return mixed
|
||||
*
|
||||
* @todo Merge with the same method in AbstractStyle
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\Common\Text as CommonText;
|
||||
|
|
@ -45,8 +44,8 @@ class Bookmark extends AbstractElement
|
|||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
|
||||
$this->name = CommonText::toUTF8($name);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Cell as CellStyle;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Chart as ChartStyle;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\Common\Text as CommonText;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
|
|
@ -31,14 +30,14 @@ class Comment extends TrackChange
|
|||
|
||||
/**
|
||||
* The Element where this comment starts
|
||||
*
|
||||
*
|
||||
* @var AbstractElement
|
||||
*/
|
||||
private $startElement;
|
||||
|
||||
/**
|
||||
* The Element where this comment ends
|
||||
*
|
||||
*
|
||||
* @var AbstractElement
|
||||
*/
|
||||
private $endElement;
|
||||
|
|
@ -61,6 +60,7 @@ class Comment extends TrackChange
|
|||
{
|
||||
parent::__construct($author, $date);
|
||||
$this->initials = $initials;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ class Comment extends TrackChange
|
|||
|
||||
/**
|
||||
* Sets the element where this comment starts
|
||||
*
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $value
|
||||
*/
|
||||
public function setStartElement(AbstractElement $value)
|
||||
|
|
@ -89,7 +89,7 @@ class Comment extends TrackChange
|
|||
|
||||
/**
|
||||
* Get the element where this comment starts
|
||||
*
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
public function getStartElement()
|
||||
|
|
@ -99,7 +99,7 @@ class Comment extends TrackChange
|
|||
|
||||
/**
|
||||
* Sets the element where this comment ends
|
||||
*
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $value
|
||||
*/
|
||||
public function setEndElement(AbstractElement $value)
|
||||
|
|
@ -112,7 +112,7 @@ class Comment extends TrackChange
|
|||
|
||||
/**
|
||||
* Get the element where this comment ends
|
||||
*
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
public function getEndElement()
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
|
|
@ -32,36 +31,36 @@ class Field extends AbstractElement
|
|||
* @var array
|
||||
*/
|
||||
protected $fieldsArray = array(
|
||||
'PAGE'=>array(
|
||||
'properties'=>array(
|
||||
'PAGE' => array(
|
||||
'properties' => array(
|
||||
'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'),
|
||||
),
|
||||
'options'=>array('PreserveFormat')
|
||||
'options' => array('PreserveFormat'),
|
||||
),
|
||||
'NUMPAGES'=>array(
|
||||
'properties'=>array(
|
||||
'NUMPAGES' => array(
|
||||
'properties' => array(
|
||||
'format' => array('Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText',
|
||||
'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper'),
|
||||
'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%')
|
||||
'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper', ),
|
||||
'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%'),
|
||||
),
|
||||
'options'=>array('PreserveFormat')
|
||||
'options' => array('PreserveFormat'),
|
||||
),
|
||||
'DATE'=>array(
|
||||
'properties'=> array(
|
||||
'dateformat' =>array('d-M-yyyy', 'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-M-yy', 'yyyy-MM-dd',
|
||||
'DATE' => array(
|
||||
'properties' => array(
|
||||
'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',
|
||||
'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(),
|
||||
'options' => array('Bold', 'Italic')
|
||||
'options' => array('Bold', 'Italic'),
|
||||
),
|
||||
'INDEX'=>array(
|
||||
'INDEX' => array(
|
||||
'properties' => array(),
|
||||
'options' => array('PreserveFormat')
|
||||
)
|
||||
'options' => array('PreserveFormat'),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
@ -113,9 +112,8 @@ class Field extends AbstractElement
|
|||
*
|
||||
* @param string $type
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return string
|
||||
*/
|
||||
public function setType($type = null)
|
||||
{
|
||||
|
|
@ -126,6 +124,7 @@ class Field extends AbstractElement
|
|||
throw new \InvalidArgumentException("Invalid type '$type'");
|
||||
}
|
||||
}
|
||||
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
|
|
@ -144,9 +143,8 @@ class Field extends AbstractElement
|
|||
*
|
||||
* @param array $properties
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
*/
|
||||
public function setProperties($properties = array())
|
||||
{
|
||||
|
|
@ -158,6 +156,7 @@ class Field extends AbstractElement
|
|||
}
|
||||
$this->properties = array_merge($this->properties, $properties);
|
||||
}
|
||||
|
||||
return $this->properties;
|
||||
}
|
||||
|
||||
|
|
@ -176,9 +175,8 @@ class Field extends AbstractElement
|
|||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return self
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
*/
|
||||
public function setOptions($options = array())
|
||||
{
|
||||
|
|
@ -190,6 +188,7 @@ class Field extends AbstractElement
|
|||
}
|
||||
$this->options = array_merge($this->options, $options);
|
||||
}
|
||||
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
|
|
@ -208,9 +207,8 @@ class Field extends AbstractElement
|
|||
*
|
||||
* @param string | TextRun $text
|
||||
*
|
||||
* @return string | TextRun
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @return string | TextRun
|
||||
*/
|
||||
public function setText($text)
|
||||
{
|
||||
|
|
@ -218,9 +216,10 @@ class Field extends AbstractElement
|
|||
if (is_string($text) || $text instanceof TextRun) {
|
||||
$this->text = $text;
|
||||
} else {
|
||||
throw new \InvalidArgumentException("Invalid text");
|
||||
throw new \InvalidArgumentException('Invalid text');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
|
|
@ -28,9 +27,9 @@ class Footer extends AbstractContainer
|
|||
* @var string
|
||||
* @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 EVEN = 'even';
|
||||
const EVEN = 'even';
|
||||
|
||||
/**
|
||||
* @var string Container type
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\CreateTemporaryFileException;
|
||||
|
|
@ -61,7 +60,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Is watermark
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $watermark;
|
||||
|
||||
|
|
@ -96,7 +95,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Is memory image
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $memoryImage;
|
||||
|
||||
|
|
@ -110,7 +109,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Image media index
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
private $mediaIndex;
|
||||
|
||||
|
|
@ -126,7 +125,7 @@ class Image extends AbstractElement
|
|||
*
|
||||
* @param string $source
|
||||
* @param mixed $style
|
||||
* @param boolean $watermark
|
||||
* @param bool $watermark
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
||||
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
||||
|
|
@ -183,7 +182,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Get is watermark
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isWatermark()
|
||||
{
|
||||
|
|
@ -193,7 +192,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Set is watermark
|
||||
*
|
||||
* @param boolean $value
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setIsWatermark($value)
|
||||
{
|
||||
|
|
@ -243,7 +242,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Get is memory image
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isMemImage()
|
||||
{
|
||||
|
|
@ -264,7 +263,6 @@ class Image extends AbstractElement
|
|||
* Set target file name.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public function setTarget($value)
|
||||
{
|
||||
|
|
@ -274,7 +272,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Get media index
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getMediaIndex()
|
||||
{
|
||||
|
|
@ -284,8 +282,7 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Set media index.
|
||||
*
|
||||
* @param integer $value
|
||||
* @return void
|
||||
* @param int $value
|
||||
*/
|
||||
public function setMediaIndex($value)
|
||||
{
|
||||
|
|
@ -368,8 +365,6 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Check memory image, supported type, image functions, and proportional width/height.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
||||
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
||||
*/
|
||||
|
|
@ -380,7 +375,7 @@ class Image extends AbstractElement
|
|||
// Check image data
|
||||
if ($this->sourceType == self::SOURCE_ARCHIVE) {
|
||||
$imageData = $this->getArchiveImageSize($this->source);
|
||||
} else if ($this->sourceType == self::SOURCE_STRING) {
|
||||
} elseif ($this->sourceType == self::SOURCE_STRING) {
|
||||
$imageData = $this->getStringImageSize($this->source);
|
||||
} else {
|
||||
$imageData = @getimagesize($this->source);
|
||||
|
|
@ -407,8 +402,6 @@ class Image extends AbstractElement
|
|||
|
||||
/**
|
||||
* Set source type.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function setSourceType()
|
||||
{
|
||||
|
|
@ -443,9 +436,9 @@ class Image extends AbstractElement
|
|||
*
|
||||
* @param string $source
|
||||
*
|
||||
* @return array|null
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
private function getArchiveImageSize($source)
|
||||
{
|
||||
|
|
@ -476,26 +469,26 @@ class Image extends AbstractElement
|
|||
|
||||
/**
|
||||
* get image size from string
|
||||
*
|
||||
*
|
||||
* @param string $source
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore this method is just a replacement for getimagesizefromstring which exists only as of PHP 5.4
|
||||
*/
|
||||
private function getStringImageSize($source)
|
||||
{
|
||||
$result = false;
|
||||
if (!function_exists('getimagesizefromstring')) {
|
||||
$uri = 'data://application/octet-stream;base64,' . base64_encode($source);
|
||||
return @getimagesize($uri);
|
||||
$uri = 'data://application/octet-stream;base64,' . base64_encode($source);
|
||||
$result = @getimagesize($uri);
|
||||
} else {
|
||||
return @getimagesizefromstring($source);
|
||||
$result = @getimagesizefromstring($source);
|
||||
}
|
||||
return false;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image functions and extensions.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function setFunctions()
|
||||
{
|
||||
|
|
@ -530,9 +523,8 @@ class Image extends AbstractElement
|
|||
/**
|
||||
* Set proportional width/height if one dimension not available.
|
||||
*
|
||||
* @param integer $actualWidth
|
||||
* @param integer $actualHeight
|
||||
* @return void
|
||||
* @param int $actualWidth
|
||||
* @param int $actualHeight
|
||||
*/
|
||||
private function setProportionalSize($actualWidth, $actualHeight)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Line as LineStyle;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\Common\Text as CommonText;
|
||||
|
|
@ -75,6 +74,7 @@ class Link extends AbstractElement
|
|||
* @param string $text
|
||||
* @param mixed $fontStyle
|
||||
* @param mixed $paragraphStyle
|
||||
* @param bool $internal
|
||||
*/
|
||||
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->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
|
||||
$this->internal = $internal;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\Common\Text as CommonText;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
|
||||
|
|
@ -74,10 +73,10 @@ class ListItemRun extends TextRun
|
|||
return $this->style;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get ListItem depth.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDepth()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\InvalidObjectException;
|
||||
|
|
@ -84,9 +83,9 @@ class Object extends AbstractElement
|
|||
$this->icon = realpath(__DIR__ . "/../resources/{$ext}.png");
|
||||
|
||||
return $this;
|
||||
} else {
|
||||
throw new InvalidObjectException();
|
||||
}
|
||||
|
||||
throw new InvalidObjectException();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\Common\Text as CommonText;
|
||||
|
|
@ -47,7 +46,6 @@ class PreserveText extends AbstractElement
|
|||
*/
|
||||
private $paragraphStyle;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Preserve Text Element
|
||||
*
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Row as RowStyle;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\ComplexType\FootnoteProperties;
|
||||
|
|
@ -50,7 +49,7 @@ class Section extends AbstractContainer
|
|||
|
||||
/**
|
||||
* The properties for the footnote of this section
|
||||
*
|
||||
*
|
||||
* @var FootnoteProperties
|
||||
*/
|
||||
private $footnoteProperties;
|
||||
|
|
@ -148,7 +147,7 @@ class Section extends AbstractContainer
|
|||
|
||||
/**
|
||||
* Get the footnote properties
|
||||
*
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\FooterProperties
|
||||
*/
|
||||
public function getFootnotePropoperties()
|
||||
|
|
@ -158,7 +157,7 @@ class Section extends AbstractContainer
|
|||
|
||||
/**
|
||||
* Set the footnote properties
|
||||
*
|
||||
*
|
||||
* @param FootnoteProperties $footnoteProperties
|
||||
*/
|
||||
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.
|
||||
* False otherwise.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDifferentFirstPage()
|
||||
{
|
||||
|
|
@ -186,6 +185,7 @@ class Section extends AbstractContainer
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -195,11 +195,11 @@ class Section extends AbstractContainer
|
|||
* @since 0.10.0
|
||||
*
|
||||
* @param string $type
|
||||
* @param boolean $header
|
||||
*
|
||||
* @return Header|Footer
|
||||
* @param bool $header
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return Header|Footer
|
||||
*/
|
||||
private function addHeaderFooter($type = Header::AUTO, $header = true)
|
||||
{
|
||||
|
|
@ -215,11 +215,10 @@ class Section extends AbstractContainer
|
|||
$container->setPhpWord($this->phpWord);
|
||||
|
||||
$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)) {
|
||||
return null;
|
||||
} else {
|
||||
return $this->footers[1];
|
||||
}
|
||||
|
||||
return $this->footers[1];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Shape as ShapeStyle;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
|
|
@ -54,14 +53,13 @@ class TOC extends AbstractElement
|
|||
*/
|
||||
private $maxDepth = 9;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Table-of-Contents Element
|
||||
*
|
||||
* @param mixed $fontStyle
|
||||
* @param array $tocStyle
|
||||
* @param integer $minDepth
|
||||
* @param integer $maxDepth
|
||||
* @param int $minDepth
|
||||
* @param int $maxDepth
|
||||
*/
|
||||
public function __construct($fontStyle = null, $tocStyle = null, $minDepth = 1, $maxDepth = 9)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Table as TableStyle;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\Common\Text as CommonText;
|
||||
|
|
@ -105,12 +104,12 @@ class Text extends AbstractElement
|
|||
public function setParagraphStyle($style = null)
|
||||
{
|
||||
if (is_array($style)) {
|
||||
$this->paragraphStyle = new Paragraph;
|
||||
$this->paragraphStyle = new Paragraph();
|
||||
$this->paragraphStyle->setStyleByArray($style);
|
||||
} elseif ($style instanceof Paragraph) {
|
||||
$this->paragraphStyle = $style;
|
||||
} elseif (null === $style) {
|
||||
$this->paragraphStyle = new Paragraph;
|
||||
$this->paragraphStyle = new Paragraph();
|
||||
} else {
|
||||
$this->paragraphStyle = $style;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
|
|
@ -74,6 +73,7 @@ class TextBreak extends AbstractElement
|
|||
$this->fontStyle = $style;
|
||||
$this->setParagraphStyle($paragraphStyle);
|
||||
}
|
||||
|
||||
return $this->fontStyle;
|
||||
}
|
||||
|
||||
|
|
@ -96,13 +96,14 @@ class TextBreak extends AbstractElement
|
|||
public function setParagraphStyle($style = null)
|
||||
{
|
||||
if (is_array($style)) {
|
||||
$this->paragraphStyle = new Paragraph;
|
||||
$this->paragraphStyle = new Paragraph();
|
||||
$this->paragraphStyle->setStyleByArray($style);
|
||||
} elseif ($style instanceof Paragraph) {
|
||||
$this->paragraphStyle = $style;
|
||||
} else {
|
||||
$this->paragraphStyle = $style;
|
||||
}
|
||||
|
||||
return $this->paragraphStyle;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
use PhpOffice\Common\Text as CommonText;
|
||||
|
|
@ -83,7 +82,7 @@ class Title extends AbstractElement
|
|||
/**
|
||||
* Get depth
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getDepth()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Element;
|
||||
|
||||
/**
|
||||
|
|
@ -49,9 +48,9 @@ class TrackChange extends AbstractContainer
|
|||
*/
|
||||
public function __construct($author, \DateTime $date)
|
||||
{
|
||||
|
||||
$this->author = $author;
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,15 +11,14 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Escaper;
|
||||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
abstract class AbstractEscaper implements EscaperInterface
|
||||
|
|
|
|||
|
|
@ -11,15 +11,14 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Escaper;
|
||||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
interface EscaperInterface
|
||||
|
|
|
|||
|
|
@ -11,15 +11,14 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Escaper;
|
||||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class RegExp extends AbstractEscaper
|
||||
|
|
|
|||
|
|
@ -11,15 +11,14 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Escaper;
|
||||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Rtf extends AbstractEscaper
|
||||
|
|
@ -28,9 +27,9 @@ class Rtf extends AbstractEscaper
|
|||
{
|
||||
if (20 > $code || $code >= 80) {
|
||||
return '{\u' . $code . '}';
|
||||
} else {
|
||||
return chr($code);
|
||||
}
|
||||
|
||||
return chr($code);
|
||||
}
|
||||
|
||||
protected function escapeMultibyteCharacter($code)
|
||||
|
|
@ -40,6 +39,7 @@ class Rtf extends AbstractEscaper
|
|||
|
||||
/**
|
||||
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
|
||||
* @param string $input
|
||||
*/
|
||||
protected function escapeSingleValue($input)
|
||||
{
|
||||
|
|
@ -57,9 +57,9 @@ class Rtf extends AbstractEscaper
|
|||
if (0 == count($bytes)) {
|
||||
if ($asciiCode < 224) {
|
||||
$numberOfBytes = 2;
|
||||
} else if ($asciiCode < 240) {
|
||||
} elseif ($asciiCode < 240) {
|
||||
$numberOfBytes = 3;
|
||||
} else if ($asciiCode < 248) {
|
||||
} elseif ($asciiCode < 248) {
|
||||
$numberOfBytes = 4;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,15 +11,14 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Escaper;
|
||||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Xml extends AbstractEscaper
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Exception;
|
||||
|
||||
/**
|
||||
|
|
@ -23,10 +22,10 @@ namespace PhpOffice\PhpWord\Exception;
|
|||
final class CopyFileException extends Exception
|
||||
{
|
||||
/**
|
||||
* @param string $source The fully qualified source file name.
|
||||
* @param string $destination The fully qualified destination file name.
|
||||
* @param integer $code The user defined exception code.
|
||||
* @param \Exception $previous The previous exception used for the exception chaining.
|
||||
* @param string $source The fully qualified source file name
|
||||
* @param string $destination The fully qualified destination file name
|
||||
* @param int $code The user defined exception code
|
||||
* @param \Exception $previous The previous exception used for the exception chaining
|
||||
*/
|
||||
final public function __construct($source, $destination, $code = 0, \Exception $previous = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Exception;
|
||||
|
||||
/**
|
||||
|
|
@ -23,8 +22,8 @@ namespace PhpOffice\PhpWord\Exception;
|
|||
final class CreateTemporaryFileException extends Exception
|
||||
{
|
||||
/**
|
||||
* @param integer $code The user defined exception code.
|
||||
* @param \Exception $previous The previous exception used for the exception chaining.
|
||||
* @param int $code The user defined exception code
|
||||
* @param \Exception $previous The previous exception used for the exception chaining
|
||||
*/
|
||||
final public function __construct($code = 0, \Exception $previous = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Exception;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Exception;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Exception;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Exception;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Exception;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
|
|
@ -29,9 +28,9 @@ abstract class IOFactory
|
|||
* @param PhpWord $phpWord
|
||||
* @param string $name
|
||||
*
|
||||
* @return WriterInterface
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*
|
||||
* @return WriterInterface
|
||||
*/
|
||||
public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
|
||||
{
|
||||
|
|
@ -49,9 +48,9 @@ abstract class IOFactory
|
|||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return ReaderInterface
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @return ReaderInterface
|
||||
*/
|
||||
public static function createReader($name = 'Word2007')
|
||||
{
|
||||
|
|
@ -65,19 +64,19 @@ abstract class IOFactory
|
|||
* @param string $name
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
|
||||
*/
|
||||
private static function createObject($type, $name, $phpWord = null)
|
||||
{
|
||||
$class = "PhpOffice\\PhpWord\\{$type}\\{$name}";
|
||||
if (class_exists($class) && self::isConcreteClass($class)) {
|
||||
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
|
||||
*
|
||||
|
|
@ -89,8 +88,10 @@ abstract class IOFactory
|
|||
{
|
||||
/** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */
|
||||
$reader = self::createReader($readerName);
|
||||
|
||||
return $reader->load($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if it's a concrete class (not abstract nor interface)
|
||||
*
|
||||
|
|
@ -100,6 +101,7 @@ abstract class IOFactory
|
|||
private static function isConcreteClass($class)
|
||||
{
|
||||
$reflection = new \ReflectionClass($class);
|
||||
|
||||
return !$reflection->isAbstract() && !$reflection->isInterface();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Image;
|
||||
|
|
@ -43,9 +42,9 @@ class Media
|
|||
* @param string $source
|
||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function addElement($container, $mediaType, $source, Image $image = null)
|
||||
{
|
||||
|
|
@ -83,12 +82,10 @@ class Media
|
|||
$image->setTarget($target);
|
||||
$image->setMediaIndex($mediaTypeCount);
|
||||
break;
|
||||
|
||||
// Objects
|
||||
case 'object':
|
||||
$target = "{$container}_oleObject{$mediaTypeCount}.bin";
|
||||
break;
|
||||
|
||||
// Links
|
||||
case 'link':
|
||||
$target = $source;
|
||||
|
|
@ -100,15 +97,17 @@ class Media
|
|||
$mediaData['type'] = $mediaType;
|
||||
$mediaData['rID'] = $rId;
|
||||
self::$elements[$container][$mediaId] = $mediaData;
|
||||
|
||||
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 $mediaType image|object|link
|
||||
* @return integer
|
||||
* @return int
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static function countElements($container, $mediaType = null)
|
||||
|
|
@ -157,13 +156,15 @@ class Media
|
|||
$elements[$key] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
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 \PhpOffice\PhpWord\Element\Image $image
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -224,7 +225,7 @@ class Media
|
|||
*
|
||||
* @param string $linkSrc
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -256,7 +257,7 @@ class Media
|
|||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -270,11 +271,11 @@ class Media
|
|||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param integer $headerCount
|
||||
* @param int $headerCount
|
||||
* @param string $src
|
||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -290,7 +291,7 @@ class Media
|
|||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -318,11 +319,11 @@ class Media
|
|||
*
|
||||
* @deprecated 0.10.0
|
||||
*
|
||||
* @param integer $footerCount
|
||||
* @param int $footerCount
|
||||
* @param string $src
|
||||
* @param \PhpOffice\PhpWord\Element\Image $image
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -338,7 +339,7 @@ class Media
|
|||
*
|
||||
* @param string $key
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Metadata;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Metadata;
|
||||
|
||||
/**
|
||||
|
|
@ -119,17 +118,17 @@ class DocInfo
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->creator = '';
|
||||
$this->creator = '';
|
||||
$this->lastModifiedBy = $this->creator;
|
||||
$this->created = time();
|
||||
$this->modified = time();
|
||||
$this->title = '';
|
||||
$this->subject = '';
|
||||
$this->description = '';
|
||||
$this->keywords = '';
|
||||
$this->category = '';
|
||||
$this->company = '';
|
||||
$this->manager = '';
|
||||
$this->created = time();
|
||||
$this->modified = time();
|
||||
$this->title = '';
|
||||
$this->subject = '';
|
||||
$this->description = '';
|
||||
$this->keywords = '';
|
||||
$this->category = '';
|
||||
$this->company = '';
|
||||
$this->manager = '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -399,7 +398,7 @@ class DocInfo
|
|||
* Check if a Custom Property is defined
|
||||
*
|
||||
* @param string $propertyName
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isCustomPropertySet($propertyName)
|
||||
{
|
||||
|
|
@ -416,9 +415,9 @@ class DocInfo
|
|||
{
|
||||
if ($this->isCustomPropertySet($propertyName)) {
|
||||
return $this->customProperties[$propertyName]['value'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -431,9 +430,9 @@ class DocInfo
|
|||
{
|
||||
if ($this->isCustomPropertySet($propertyName)) {
|
||||
return $this->customProperties[$propertyName]['type'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -456,7 +455,7 @@ class DocInfo
|
|||
self::PROPERTY_TYPE_FLOAT,
|
||||
self::PROPERTY_TYPE_STRING,
|
||||
self::PROPERTY_TYPE_DATE,
|
||||
self::PROPERTY_TYPE_BOOLEAN
|
||||
self::PROPERTY_TYPE_BOOLEAN,
|
||||
);
|
||||
if (($propertyType === null) || (!in_array($propertyType, $propertyTypes))) {
|
||||
if ($propertyValue === null) {
|
||||
|
|
@ -474,8 +473,9 @@ class DocInfo
|
|||
|
||||
$this->customProperties[$propertyName] = array(
|
||||
'value' => $propertyValue,
|
||||
'type' => $propertyType
|
||||
'type' => $propertyType,
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Metadata;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,14 +11,14 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Metadata;
|
||||
|
||||
use PhpOffice\PhpWord\ComplexType\ProofState;
|
||||
use PhpOffice\PhpWord\SimpleType\Zoom;
|
||||
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
||||
use PhpOffice\PhpWord\SimpleType\Zoom;
|
||||
|
||||
/**
|
||||
* Setting class
|
||||
|
|
@ -28,7 +28,6 @@ use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
|||
*/
|
||||
class Settings
|
||||
{
|
||||
|
||||
/**
|
||||
* Magnification Setting
|
||||
*
|
||||
|
|
@ -40,14 +39,14 @@ class Settings
|
|||
/**
|
||||
* Hide spelling errors
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $hideSpellingErrors = false;
|
||||
|
||||
/**
|
||||
* Hide grammatical errors
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $hideGrammaticalErrors = false;
|
||||
|
||||
|
|
@ -61,21 +60,21 @@ class Settings
|
|||
/**
|
||||
* Track Revisions to Document
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $trackRevisions = false;
|
||||
|
||||
/**
|
||||
* Do Not Use Move Syntax When Tracking Revisions
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $doNotTrackMoves = false;
|
||||
|
||||
/**
|
||||
* Do Not Track Formatting Revisions When Tracking Revisions
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
private $doNotTrackFormatting = false;
|
||||
|
||||
|
|
@ -115,6 +114,7 @@ class Settings
|
|||
if ($this->documentProtection == null) {
|
||||
$this->documentProtection = new Protection();
|
||||
}
|
||||
|
||||
return $this->documentProtection;
|
||||
}
|
||||
|
||||
|
|
@ -134,6 +134,7 @@ class Settings
|
|||
if ($this->proofState == null) {
|
||||
$this->proofState = new ProofState();
|
||||
}
|
||||
|
||||
return $this->proofState;
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +149,7 @@ class Settings
|
|||
/**
|
||||
* Are spelling errors hidden
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function hasHideSpellingErrors()
|
||||
{
|
||||
|
|
@ -158,7 +159,7 @@ class Settings
|
|||
/**
|
||||
* Hide spelling errors
|
||||
*
|
||||
* @param boolean $hideSpellingErrors
|
||||
* @param bool $hideSpellingErrors
|
||||
*/
|
||||
public function setHideSpellingErrors($hideSpellingErrors)
|
||||
{
|
||||
|
|
@ -168,7 +169,7 @@ class Settings
|
|||
/**
|
||||
* Are grammatical errors hidden
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function hasHideGrammaticalErrors()
|
||||
{
|
||||
|
|
@ -178,7 +179,7 @@ class Settings
|
|||
/**
|
||||
* Hide grammatical errors
|
||||
*
|
||||
* @param boolean $hideGrammaticalErrors
|
||||
* @param bool $hideGrammaticalErrors
|
||||
*/
|
||||
public function setHideGrammaticalErrors($hideGrammaticalErrors)
|
||||
{
|
||||
|
|
@ -186,7 +187,7 @@ class Settings
|
|||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEvenAndOddHeaders()
|
||||
{
|
||||
|
|
@ -194,7 +195,7 @@ class Settings
|
|||
}
|
||||
|
||||
/**
|
||||
* @param boolean $evenAndOddHeaders
|
||||
* @param bool $evenAndOddHeaders
|
||||
*/
|
||||
public function setEvenAndOddHeaders($evenAndOddHeaders)
|
||||
{
|
||||
|
|
@ -203,7 +204,7 @@ class Settings
|
|||
|
||||
/**
|
||||
* Get the Visibility of Annotation Types
|
||||
*
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\ComplexType\TrackChangesView
|
||||
*/
|
||||
public function getRevisionView()
|
||||
|
|
@ -213,7 +214,7 @@ class Settings
|
|||
|
||||
/**
|
||||
* Set the Visibility of Annotation Types
|
||||
*
|
||||
*
|
||||
* @param TrackChangesView $trackChangesView
|
||||
*/
|
||||
public function setRevisionView(TrackChangesView $trackChangesView = null)
|
||||
|
|
@ -222,7 +223,7 @@ class Settings
|
|||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function hasTrackRevisions()
|
||||
{
|
||||
|
|
@ -230,7 +231,7 @@ class Settings
|
|||
}
|
||||
|
||||
/**
|
||||
* @param boolean $trackRevisions
|
||||
* @param bool $trackRevisions
|
||||
*/
|
||||
public function setTrackRevisions($trackRevisions)
|
||||
{
|
||||
|
|
@ -238,7 +239,7 @@ class Settings
|
|||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDoNotTrackMoves()
|
||||
{
|
||||
|
|
@ -246,7 +247,7 @@ class Settings
|
|||
}
|
||||
|
||||
/**
|
||||
* @param boolean $doNotTrackMoves
|
||||
* @param bool $doNotTrackMoves
|
||||
*/
|
||||
public function setDoNotTrackMoves($doNotTrackMoves)
|
||||
{
|
||||
|
|
@ -254,7 +255,7 @@ class Settings
|
|||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function hasDoNotTrackFormatting()
|
||||
{
|
||||
|
|
@ -262,7 +263,7 @@ class Settings
|
|||
}
|
||||
|
||||
/**
|
||||
* @param boolean $doNotTrackFormatting
|
||||
* @param bool $doNotTrackFormatting
|
||||
*/
|
||||
public function setDoNotTrackFormatting($doNotTrackFormatting)
|
||||
{
|
||||
|
|
@ -293,7 +294,7 @@ class Settings
|
|||
|
||||
/**
|
||||
* Returns the Radix Point for Field Code Evaluation
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDecimalSymbol()
|
||||
|
|
@ -303,7 +304,7 @@ class Settings
|
|||
|
||||
/**
|
||||
* sets the Radix Point for Field Code Evaluation
|
||||
*
|
||||
*
|
||||
* @param string $decimalSymbol
|
||||
*/
|
||||
public function setDecimalSymbol($decimalSymbol)
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Section;
|
||||
|
|
@ -108,9 +107,9 @@ class PhpWord
|
|||
* @param mixed $function
|
||||
* @param mixed $args
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($function, $args)
|
||||
{
|
||||
|
|
@ -251,7 +250,7 @@ class PhpWord
|
|||
/**
|
||||
* Get default font size
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function getDefaultFontSize()
|
||||
{
|
||||
|
|
@ -285,21 +284,20 @@ class PhpWord
|
|||
*
|
||||
* @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead.
|
||||
*
|
||||
* @param string $filename Fully qualified filename.
|
||||
*
|
||||
* @return TemplateProcessor
|
||||
* @param string $filename Fully qualified filename
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*
|
||||
* @return TemplateProcessor
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function loadTemplate($filename)
|
||||
{
|
||||
if (file_exists($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);
|
||||
|
||||
if ($download === true) {
|
||||
header("Content-Description: File Transfer");
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||
header('Content-Type: ' . $mime[$format]);
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
|
|
@ -62,6 +61,7 @@ abstract class AbstractReader implements ReaderInterface
|
|||
public function setReadDataOnly($value = true)
|
||||
{
|
||||
$this->readDataOnly = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
@ -70,21 +70,21 @@ abstract class AbstractReader implements ReaderInterface
|
|||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return resource
|
||||
*
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
protected function openFile($filename)
|
||||
{
|
||||
// Check if file exists
|
||||
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
|
||||
$this->fileHandle = fopen($filename, 'r');
|
||||
if ($this->fileHandle === false) {
|
||||
throw new Exception("Could not open file " . $filename . " for reading.");
|
||||
throw new Exception("Could not open file $filename for reading.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
|
|
|
|||
|
|
@ -11,16 +11,15 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader;
|
||||
|
||||
use PhpOffice\Common\Drawing;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Shared\OLERead;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
|
||||
/**
|
||||
* Reader for Word97
|
||||
|
|
@ -164,13 +163,14 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$arrayCP[$inc] = self::getInt4d($data, $posMem);
|
||||
$posMem += 4;
|
||||
}
|
||||
|
||||
return $arrayCP;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @link http://msdn.microsoft.com/en-us/library/dd949344%28v=office.12%29.aspx
|
||||
* @link https://igor.io/2012/09/24/binary-parsing.html
|
||||
* @param string $data
|
||||
*/
|
||||
private function readFib($data)
|
||||
{
|
||||
|
|
@ -1095,6 +1095,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$this->arrayFib['lcbColorSchemeMapping'] = self::getInt4d($data, $pos);
|
||||
$pos += 4;
|
||||
}
|
||||
|
||||
return $pos;
|
||||
}
|
||||
|
||||
|
|
@ -1215,7 +1216,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
$this->arrayFonts[] = array(
|
||||
'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.f : 0x'.dechex($sprm_F).PHP_EOL);
|
||||
print_r('$sprm.sgc : 0x'.dechex($sprm_Sgc));
|
||||
switch(dechex($sprm_Sgc)) {
|
||||
switch (dechex($sprm_Sgc)) {
|
||||
case 0x01:
|
||||
print_r(' (Paragraph property)');
|
||||
break;
|
||||
|
|
@ -1322,12 +1323,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
print_r(PHP_EOL);
|
||||
print_r('$sprm.spra : 0x'.dechex($sprm_Spra).PHP_EOL);
|
||||
switch(dechex($sprm_Spra)) {
|
||||
switch (dechex($sprm_Spra)) {
|
||||
case 0x0:
|
||||
$operand = self::getInt1d($this->dataWorkDocument, $offset);
|
||||
$offset += 1;
|
||||
$cb -= 1;
|
||||
switch(dechex($operand)) {
|
||||
switch (dechex($operand)) {
|
||||
case 0x00:
|
||||
$operand = 'OFF';
|
||||
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.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
case 0x0A: // sprmPIlvl
|
||||
print_r('sprmPIlvl : '.$operand.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
|
|
@ -1391,28 +1392,28 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
break;
|
||||
case 0x02: // Sprm is modifying a character property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
default:
|
||||
print_r('$sprm_IsPmd(2) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x03: // Sprm is modifying a picture property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
default:
|
||||
print_r('$sprm_IsPmd(3) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x04: // Sprm is modifying a section property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
default:
|
||||
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x05: // Sprm is modifying a table property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
default:
|
||||
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
|
|
@ -1471,7 +1472,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
foreach ($arrayRGB as $keyRGB => $rgb) {
|
||||
$oStyle = new \stdClass();
|
||||
$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;
|
||||
|
||||
if ($rgb > 0) {
|
||||
|
|
@ -1500,12 +1501,13 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$oSprm->f = ($sprm / 512) & 0x0001;
|
||||
$oSprm->sgc = ($sprm / 1024) & 0x0007;
|
||||
$oSprm->spra = ($sprm / 8192);
|
||||
|
||||
return $oSprm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
* @param integer $pos
|
||||
* @param int $pos
|
||||
* @param \stdClass $oSprm
|
||||
* @return array
|
||||
*/
|
||||
|
|
@ -1514,11 +1516,11 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$length = 0;
|
||||
$operand = null;
|
||||
|
||||
switch(dechex($oSprm->spra)) {
|
||||
switch (dechex($oSprm->spra)) {
|
||||
case 0x0:
|
||||
$operand = self::getInt1d($data, $pos);
|
||||
$length = 1;
|
||||
switch(dechex($operand)) {
|
||||
switch (dechex($operand)) {
|
||||
case 0x00:
|
||||
$operand = false;
|
||||
break;
|
||||
|
|
@ -1558,14 +1560,15 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
|
||||
return array(
|
||||
'length' => $length,
|
||||
'length' => $length,
|
||||
'operand' => $operand,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data integer
|
||||
* @param $pos integer
|
||||
* @param $data int
|
||||
* @param $pos int
|
||||
* @param $cbNum int
|
||||
* @return \stdClass
|
||||
* @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'];
|
||||
$operand = $arrayReturn['operand'];
|
||||
|
||||
switch(dechex($oSprm->sgc)) {
|
||||
switch (dechex($oSprm->sgc)) {
|
||||
// Paragraph property
|
||||
case 0x01:
|
||||
break;
|
||||
|
|
@ -1602,7 +1605,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
if (!isset($oStylePrl->styleFont)) {
|
||||
$oStylePrl->styleFont = array();
|
||||
}
|
||||
switch($oSprm->isPmd) {
|
||||
switch ($oSprm->isPmd) {
|
||||
// sprmCFRMarkIns
|
||||
case 0x01:
|
||||
break;
|
||||
|
|
@ -1620,7 +1623,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// sprmCFItalic
|
||||
case 0x36:
|
||||
// By default, text is not italicized.
|
||||
switch($operand) {
|
||||
switch ($operand) {
|
||||
case false:
|
||||
case true:
|
||||
$oStylePrl->styleFont['italic'] = $operand;
|
||||
|
|
@ -1640,7 +1643,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// sprmCFBold
|
||||
case 0x35:
|
||||
// By default, text is not bold.
|
||||
switch($operand) {
|
||||
switch ($operand) {
|
||||
case false:
|
||||
case true:
|
||||
$oStylePrl->styleFont['bold'] = $operand;
|
||||
|
|
@ -1656,7 +1659,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// sprmCFStrike
|
||||
case 0x37:
|
||||
// By default, text is not struck through.
|
||||
switch($operand) {
|
||||
switch ($operand) {
|
||||
case false:
|
||||
case true:
|
||||
$oStylePrl->styleFont['strikethrough'] = $operand;
|
||||
|
|
@ -1671,7 +1674,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
break;
|
||||
// sprmCKul
|
||||
case 0x3E:
|
||||
switch(dechex($operand)) {
|
||||
switch (dechex($operand)) {
|
||||
case 0x00:
|
||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE;
|
||||
break;
|
||||
|
|
@ -1734,7 +1737,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// sprmCIco
|
||||
//@link http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx
|
||||
case 0x42:
|
||||
switch(dechex($operand)) {
|
||||
switch (dechex($operand)) {
|
||||
case 0x00:
|
||||
case 0x01:
|
||||
$oStylePrl->styleFont['color'] = '000000';
|
||||
|
|
@ -1787,7 +1790,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
break;
|
||||
// sprmCHps
|
||||
case 0x43:
|
||||
$oStylePrl->styleFont['size'] = dechex($operand/2);
|
||||
$oStylePrl->styleFont['size'] = dechex($operand / 2);
|
||||
break;
|
||||
// sprmCIss
|
||||
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);
|
||||
$pos += 1;
|
||||
$pos += 1;
|
||||
$oStylePrl->styleFont['color'] = $red.$green.$blue;
|
||||
$oStylePrl->styleFont['color'] = $red . $green . $blue;
|
||||
$cbNum -= 4;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -1873,7 +1876,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
if (!isset($oStylePrl->styleSection)) {
|
||||
$oStylePrl->styleSection = array();
|
||||
}
|
||||
switch($oSprm->isPmd) {
|
||||
switch ($oSprm->isPmd) {
|
||||
// sprmSNfcPgn
|
||||
case 0x0E:
|
||||
// numbering format used for page numbers
|
||||
|
|
@ -1925,7 +1928,6 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
default:
|
||||
// print_r('@todo Section : 0x'.dechex($oSprm->isPmd));
|
||||
// print_r(PHP_EOL);
|
||||
|
||||
}
|
||||
break;
|
||||
// Table property
|
||||
|
|
@ -2193,13 +2195,14 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
|
||||
$oStylePrl->length = $pos - $posStart;
|
||||
|
||||
return $oStylePrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a record header
|
||||
* @param string $stream
|
||||
* @param integer $pos
|
||||
* @param int $pos
|
||||
* @return array
|
||||
*/
|
||||
private function loadRecordHeader($stream, $pos)
|
||||
|
|
@ -2207,11 +2210,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$rec = self::getInt2d($stream, $pos);
|
||||
$recType = self::getInt2d($stream, $pos + 2);
|
||||
$recLen = self::getInt4d($stream, $pos + 4);
|
||||
|
||||
return array(
|
||||
'recVer' => ($rec >> 0) & bindec('1111'),
|
||||
'recVer' => ($rec >> 0) & bindec('1111'),
|
||||
'recInstance' => ($rec >> 4) & bindec('111111111111'),
|
||||
'recType' => $recType,
|
||||
'recLen' => $recLen,
|
||||
'recType' => $recType,
|
||||
'recLen' => $recLen,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -2274,7 +2278,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
if (ord($sText[0]) == 1) {
|
||||
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']);
|
||||
$oSection->addImage($fileImage, array('width' => $oCharacters->style->image['width'], 'height' => $oCharacters->style->image['height']));
|
||||
// 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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 {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader;
|
||||
|
||||
use PhpOffice\Common\XMLReader;
|
||||
|
|
@ -40,7 +39,7 @@ class ODText extends AbstractReader implements ReaderInterface
|
|||
|
||||
$readerParts = array(
|
||||
'content.xml' => 'Content',
|
||||
'meta.xml' => 'Meta',
|
||||
'meta.xml' => 'Meta',
|
||||
);
|
||||
|
||||
foreach ($readerParts as $xmlFile => $partName) {
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\ODText;
|
||||
|
||||
use PhpOffice\PhpWord\Reader\Word2007\AbstractPart as Word2007AbstractPart;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\ODText;
|
||||
|
||||
use PhpOffice\Common\XMLReader;
|
||||
|
|
@ -44,16 +43,13 @@ class Content extends AbstractPart
|
|||
foreach ($nodes as $node) {
|
||||
// $styleName = $xmlReader->getAttribute('text:style-name', $node);
|
||||
switch ($node->nodeName) {
|
||||
|
||||
case 'text:h': // Heading
|
||||
$depth = $xmlReader->getAttribute('text:outline-level', $node);
|
||||
$section->addTitle($node->nodeValue, $depth);
|
||||
break;
|
||||
|
||||
case 'text:p': // Paragraph
|
||||
$section->addText($node->nodeValue);
|
||||
break;
|
||||
|
||||
case 'text:list': // List
|
||||
$listItems = $xmlReader->getElements('text:list-item/text:p', $node);
|
||||
foreach ($listItems as $listItem) {
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\ODText;
|
||||
|
||||
use PhpOffice\Common\XMLReader;
|
||||
|
|
@ -70,9 +69,8 @@ class Meta extends AbstractPart
|
|||
if (in_array($property, array('Category', 'Company', 'Manager'))) {
|
||||
$method = "set{$property}";
|
||||
$docProps->$method($propertyNode->nodeValue);
|
||||
|
||||
// Set other custom properties
|
||||
} else {
|
||||
// Set other custom properties
|
||||
$docProps->setCustomProperty($property, $propertyNode->nodeValue);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\RTF;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
|
|
@ -153,7 +152,7 @@ class Document
|
|||
|
||||
// Walk each characters
|
||||
while ($this->offset < $this->length) {
|
||||
$char = $this->rtf[$this->offset];
|
||||
$char = $this->rtf[$this->offset];
|
||||
$ascii = ord($char);
|
||||
|
||||
if (isset($markers[$ascii])) { // Marker found: {, }, \, LF, or CR
|
||||
|
|
@ -163,7 +162,7 @@ class Document
|
|||
if (false === $this->isControl) { // Non control word: Push character
|
||||
$this->pushText($char);
|
||||
} 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->isFirst = false;
|
||||
} else { // Delimiter found: Parse buffered control
|
||||
|
|
@ -256,7 +255,7 @@ class Document
|
|||
*/
|
||||
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;
|
||||
$this->parseControl($control, $parameter);
|
||||
}
|
||||
|
|
@ -313,9 +312,9 @@ class Document
|
|||
private function pushText($char)
|
||||
{
|
||||
if ('<' == $char) {
|
||||
$this->text .= "<";
|
||||
$this->text .= '<';
|
||||
} elseif ('>' == $char) {
|
||||
$this->text .= ">";
|
||||
$this->text .= '>';
|
||||
} else {
|
||||
$this->text .= $char;
|
||||
}
|
||||
|
|
@ -332,13 +331,13 @@ class Document
|
|||
{
|
||||
$controls = array(
|
||||
'par' => array(self::PARA, 'paragraph', true),
|
||||
'b' => array(self::STYL, 'font', 'bold', true),
|
||||
'i' => array(self::STYL, 'font', 'italic', true),
|
||||
'u' => array(self::STYL, 'font', 'underline', true),
|
||||
'strike' => array(self::STYL, 'font', 'strikethrough',true),
|
||||
'fs' => array(self::STYL, 'font', 'size', $parameter),
|
||||
'qc' => array(self::STYL, 'paragraph', 'alignment', Jc::CENTER),
|
||||
'sa' => array(self::STYL, 'paragraph', 'spaceAfter', $parameter),
|
||||
'b' => array(self::STYL, 'font', 'bold', true),
|
||||
'i' => array(self::STYL, 'font', 'italic', true),
|
||||
'u' => array(self::STYL, 'font', 'underline', true),
|
||||
'strike' => array(self::STYL, 'font', 'strikethrough', true),
|
||||
'fs' => array(self::STYL, 'font', 'size', $parameter),
|
||||
'qc' => array(self::STYL, 'paragraph', 'alignment', Jc::CENTER),
|
||||
'sa' => array(self::STYL, 'paragraph', 'spaceAfter', $parameter),
|
||||
'fonttbl' => array(self::SKIP, 'fonttbl', null),
|
||||
'colortbl' => array(self::SKIP, 'colortbl', null),
|
||||
'info' => array(self::SKIP, 'info', null),
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader;
|
||||
|
||||
/**
|
||||
|
|
@ -28,7 +27,7 @@ interface ReaderInterface
|
|||
* Can the current ReaderInterface read the file?
|
||||
*
|
||||
* @param string $filename
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function canRead($filename);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader;
|
||||
|
||||
use PhpOffice\Common\XMLReader;
|
||||
|
|
@ -55,7 +54,7 @@ class Word2007 extends AbstractReader implements ReaderInterface
|
|||
array('stepPart' => 'document', 'stepItems' => array(
|
||||
'endnotes' => 'Endnotes',
|
||||
'footnotes' => 'Footnotes',
|
||||
'settings' => 'Settings',
|
||||
'settings' => 'Settings',
|
||||
)),
|
||||
);
|
||||
|
||||
|
|
@ -94,7 +93,6 @@ class Word2007 extends AbstractReader implements ReaderInterface
|
|||
$part->setRels($relationships);
|
||||
$part->read($phpWord);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||
|
||||
use PhpOffice\Common\XMLReader;
|
||||
|
|
@ -36,9 +35,9 @@ abstract class AbstractPart
|
|||
*/
|
||||
const READ_VALUE = 'attributeValue'; // Read attribute 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_SIZE = 'attributeMultiplyByTwo'; // Read special attribute value for Font::$size
|
||||
const READ_SIZE = 'attributeMultiplyByTwo'; // Read special attribute value for Font::$size
|
||||
|
||||
/**
|
||||
* Document file
|
||||
|
|
@ -137,9 +136,8 @@ abstract class AbstractPart
|
|||
}
|
||||
}
|
||||
$parent->addPreserveText($textContent, $fontStyle, $paragraphStyle);
|
||||
|
||||
// List item
|
||||
} elseif ($xmlReader->elementExists('w:pPr/w:numPr', $domNode)) {
|
||||
// List item
|
||||
$textContent = '';
|
||||
$numId = $xmlReader->getAttribute('w:val', $domNode, 'w:pPr/w:numPr/w:numId');
|
||||
$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);
|
||||
}
|
||||
$parent->addListItem($textContent, $levelId, null, "PHPWordList{$numId}", $paragraphStyle);
|
||||
|
||||
// Heading
|
||||
} elseif (!empty($headingMatches)) {
|
||||
// Heading
|
||||
$textContent = '';
|
||||
$nodes = $xmlReader->getElements('w:r', $domNode);
|
||||
foreach ($nodes as $node) {
|
||||
$textContent .= $xmlReader->getValue('w:t', $node);
|
||||
}
|
||||
$parent->addTitle($textContent, $headingMatches[1]);
|
||||
|
||||
// Text and TextRun
|
||||
} else {
|
||||
// Text and TextRun
|
||||
$runCount = $xmlReader->countElements('w:r', $domNode);
|
||||
$linkCount = $xmlReader->countElements('w:hyperlink', $domNode);
|
||||
$runLinkCount = $runCount + $linkCount;
|
||||
|
|
@ -205,25 +201,22 @@ abstract class AbstractPart
|
|||
$parent->addLink($target, $textContent, $fontStyle, $paragraphStyle);
|
||||
}
|
||||
} else {
|
||||
// Footnote
|
||||
if ($xmlReader->elementExists('w:footnoteReference', $domNode)) {
|
||||
// Footnote
|
||||
$parent->addFootnote();
|
||||
|
||||
// Endnote
|
||||
} elseif ($xmlReader->elementExists('w:endnoteReference', $domNode)) {
|
||||
// Endnote
|
||||
$parent->addEndnote();
|
||||
|
||||
// Image
|
||||
} elseif ($xmlReader->elementExists('w:pict', $domNode)) {
|
||||
// Image
|
||||
$rId = $xmlReader->getAttribute('r:id', $domNode, 'w:pict/v:shape/v:imagedata');
|
||||
$target = $this->getMediaTarget($docPart, $rId);
|
||||
if (!is_null($target)) {
|
||||
$imageSource = "zip://{$this->docFile}#{$target}";
|
||||
$parent->addImage($imageSource);
|
||||
}
|
||||
|
||||
// Object
|
||||
} elseif ($xmlReader->elementExists('w:object', $domNode)) {
|
||||
// Object
|
||||
$rId = $xmlReader->getAttribute('r:id', $domNode, 'w:object/o:OLEObject');
|
||||
// $rIdIcon = $xmlReader->getAttribute('r:id', $domNode, 'w:object/v:shape/v:imagedata');
|
||||
$target = $this->getMediaTarget($docPart, $rId);
|
||||
|
|
@ -231,9 +224,8 @@ abstract class AbstractPart
|
|||
$textContent = "<Object: {$target}>";
|
||||
$parent->addText($textContent, $fontStyle, $paragraphStyle);
|
||||
}
|
||||
|
||||
// TextRun
|
||||
} else {
|
||||
// TextRun
|
||||
$textContent = $xmlReader->getValue('w:t', $domNode);
|
||||
$parent->addText($textContent, $fontStyle, $paragraphStyle);
|
||||
}
|
||||
|
|
@ -263,7 +255,6 @@ abstract class AbstractPart
|
|||
foreach ($tblNodes as $tblNode) {
|
||||
if ('w:tblGrid' == $tblNode->nodeName) { // Column
|
||||
// @todo Do something with table columns
|
||||
|
||||
} elseif ('w:tr' == $tblNode->nodeName) { // Row
|
||||
$rowHeight = $xmlReader->getAttribute('w:val', $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) {
|
||||
if ('w:trPr' == $rowNode->nodeName) { // Row style
|
||||
// @todo Do something with row style
|
||||
|
||||
} elseif ('w:tc' == $rowNode->nodeName) { // Cell
|
||||
$cellWidth = $xmlReader->getAttribute('w:w', $rowNode, 'w:tcPr/w:tcW');
|
||||
$cellStyle = null;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||
|
||||
use PhpOffice\Common\XMLReader;
|
||||
|
|
@ -33,15 +32,15 @@ class DocPropsCore extends AbstractPart
|
|||
* @var array
|
||||
*/
|
||||
protected $mapping = array(
|
||||
'dc:creator' => 'setCreator',
|
||||
'dc:title' => 'setTitle',
|
||||
'dc:description' => 'setDescription',
|
||||
'dc:subject' => 'setSubject',
|
||||
'cp:keywords' => 'setKeywords',
|
||||
'cp:category' => 'setCategory',
|
||||
'dc:creator' => 'setCreator',
|
||||
'dc:title' => 'setTitle',
|
||||
'dc:description' => 'setDescription',
|
||||
'dc:subject' => 'setSubject',
|
||||
'cp:keywords' => 'setKeywords',
|
||||
'cp:category' => 'setCategory',
|
||||
'cp:lastModifiedBy' => 'setLastModifiedBy',
|
||||
'dcterms:created' => 'setCreated',
|
||||
'dcterms:modified' => 'setModified',
|
||||
'dcterms:created' => 'setCreated',
|
||||
'dcterms:modified' => 'setModified',
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||
|
||||
use PhpOffice\Common\XMLReader;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||
|
||||
use PhpOffice\Common\XMLReader;
|
||||
|
|
@ -40,7 +39,6 @@ class Document extends AbstractPart
|
|||
* Read document.xml.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @return void
|
||||
*/
|
||||
public function read(PhpWord $phpWord)
|
||||
{
|
||||
|
|
@ -66,7 +64,6 @@ class Document extends AbstractPart
|
|||
*
|
||||
* @param array $settings
|
||||
* @param \PhpOffice\PhpWord\Element\Section &$section
|
||||
* @return void
|
||||
*/
|
||||
private function readHeaderFooter($settings, Section &$section)
|
||||
{
|
||||
|
|
@ -131,7 +128,7 @@ class Document extends AbstractPart
|
|||
$id = $xmlReader->getAttribute('r:id', $node);
|
||||
$styles['hf'][$id] = array(
|
||||
'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 \DOMElement $node
|
||||
* @param \PhpOffice\PhpWord\Element\Section &$section
|
||||
* @return void
|
||||
*
|
||||
* @todo <w:lastRenderedPageBreak>
|
||||
*/
|
||||
|
|
@ -175,7 +171,6 @@ class Document extends AbstractPart
|
|||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
||||
* @param \DOMElement $node
|
||||
* @param \PhpOffice\PhpWord\Element\Section &$section
|
||||
* @return void
|
||||
*/
|
||||
private function readWSectPrNode(XMLReader $xmlReader, \DOMElement $node, Section &$section)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||
|
||||
use PhpOffice\Common\XMLReader;
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||
|
||||
use PhpOffice\Common\XMLReader;
|
||||
|
|
@ -31,7 +30,6 @@ class Numbering extends AbstractPart
|
|||
* Read numbering.xml.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @return void
|
||||
*/
|
||||
public function read(PhpWord $phpWord)
|
||||
{
|
||||
|
|
@ -92,7 +90,7 @@ class Numbering extends AbstractPart
|
|||
*
|
||||
* @param \PhpOffice\Common\XMLReader $xmlReader
|
||||
* @param \DOMElement $subnode
|
||||
* @param integer $levelId
|
||||
* @param int $levelId
|
||||
* @return array
|
||||
*/
|
||||
private function readLevel(XMLReader $xmlReader, \DOMElement $subnode, $levelId)
|
||||
|
|
|
|||
|
|
@ -11,15 +11,14 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||
|
||||
use PhpOffice\Common\XMLReader;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
|
||||
/**
|
||||
* Settings reader
|
||||
|
|
@ -28,14 +27,12 @@ use PhpOffice\PhpWord\ComplexType\TrackChangesView;
|
|||
*/
|
||||
class Settings extends AbstractPart
|
||||
{
|
||||
|
||||
private static $booleanProperties = array('hideSpellingErrors', 'hideGrammaticalErrors', 'trackRevisions', 'doNotTrackMoves', 'doNotTrackFormatting', 'evenAndOddHeaders');
|
||||
|
||||
/**
|
||||
* Read settings.xml.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @return void
|
||||
*/
|
||||
public function read(PhpWord $phpWord)
|
||||
{
|
||||
|
|
@ -57,9 +54,9 @@ class Settings extends AbstractPart
|
|||
} else {
|
||||
$docSettings->$method(true);
|
||||
}
|
||||
} else if (method_exists($this, $method)) {
|
||||
} elseif (method_exists($this, $method)) {
|
||||
$this->$method($xmlReader, $phpWord, $node);
|
||||
} else if (method_exists($docSettings, $method)) {
|
||||
} elseif (method_exists($docSettings, $method)) {
|
||||
$docSettings->$method($value);
|
||||
}
|
||||
}
|
||||
|
|
@ -68,7 +65,7 @@ class Settings extends AbstractPart
|
|||
|
||||
/**
|
||||
* Sets the document protection
|
||||
*
|
||||
*
|
||||
* @param XMLReader $xmlReader
|
||||
* @param PhpWord $phpWord
|
||||
* @param \DOMNode $node
|
||||
|
|
@ -83,7 +80,7 @@ class Settings extends AbstractPart
|
|||
|
||||
/**
|
||||
* Sets the proof state
|
||||
*
|
||||
*
|
||||
* @param XMLReader $xmlReader
|
||||
* @param PhpWord $phpWord
|
||||
* @param \DOMNode $node
|
||||
|
|
@ -105,7 +102,7 @@ class Settings extends AbstractPart
|
|||
|
||||
/**
|
||||
* Sets the proof state
|
||||
*
|
||||
*
|
||||
* @param XMLReader $xmlReader
|
||||
* @param PhpWord $phpWord
|
||||
* @param \DOMNode $node
|
||||
|
|
@ -122,7 +119,7 @@ class Settings extends AbstractPart
|
|||
|
||||
/**
|
||||
* Set the Revision view
|
||||
*
|
||||
*
|
||||
* @param XMLReader $xmlReader
|
||||
* @param PhpWord $phpWord
|
||||
* @param \DOMNode $node
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Reader\Word2007;
|
||||
|
||||
use PhpOffice\Common\XMLReader;
|
||||
|
|
@ -31,7 +30,6 @@ class Styles extends AbstractPart
|
|||
* Read styles.xml.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord $phpWord
|
||||
* @return void
|
||||
*/
|
||||
public function read(PhpWord $phpWord)
|
||||
{
|
||||
|
|
@ -49,7 +47,6 @@ class Styles extends AbstractPart
|
|||
preg_match('/Heading(\d)/', $name, $headingMatches);
|
||||
// $default = ($xmlReader->getAttribute('w:default', $node) == 1);
|
||||
switch ($type) {
|
||||
|
||||
case 'paragraph':
|
||||
$paragraphStyle = $this->readParagraphStyle($xmlReader, $node);
|
||||
$fontStyle = $this->readFontStyle($xmlReader, $node);
|
||||
|
|
@ -65,14 +62,12 @@ class Styles extends AbstractPart
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'character':
|
||||
$fontStyle = $this->readFontStyle($xmlReader, $node);
|
||||
if (!empty($fontStyle)) {
|
||||
$phpWord->addFontStyle($name, $fontStyle);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'table':
|
||||
$tStyle = $this->readTableStyle($xmlReader, $node);
|
||||
if (!empty($tStyle)) {
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord;
|
||||
|
||||
/**
|
||||
|
|
@ -30,8 +29,8 @@ class Settings
|
|||
* @const string
|
||||
*/
|
||||
const ZIPARCHIVE = 'ZipArchive';
|
||||
const PCLZIP = 'PclZip';
|
||||
const OLD_LIB = 'PhpOffice\\PhpWord\\Shared\\ZipArchive'; // @deprecated 0.11
|
||||
const PCLZIP = 'PclZip';
|
||||
const OLD_LIB = 'PhpOffice\\PhpWord\\Shared\\ZipArchive'; // @deprecated 0.11
|
||||
|
||||
/**
|
||||
* PDF rendering libraries
|
||||
|
|
@ -39,8 +38,8 @@ class Settings
|
|||
* @const string
|
||||
*/
|
||||
const PDF_RENDERER_DOMPDF = 'DomPDF';
|
||||
const PDF_RENDERER_TCPDF = 'TCPDF';
|
||||
const PDF_RENDERER_MPDF = 'MPDF';
|
||||
const PDF_RENDERER_TCPDF = 'TCPDF';
|
||||
const PDF_RENDERER_MPDF = 'MPDF';
|
||||
|
||||
/**
|
||||
* Measurement units multiplication factor
|
||||
|
|
@ -53,12 +52,12 @@ class Settings
|
|||
*
|
||||
* @const string
|
||||
*/
|
||||
const UNIT_TWIP = 'twip'; // = 1/20 point
|
||||
const UNIT_CM = 'cm';
|
||||
const UNIT_MM = 'mm';
|
||||
const UNIT_INCH = 'inch';
|
||||
const UNIT_TWIP = 'twip'; // = 1/20 point
|
||||
const UNIT_CM = 'cm';
|
||||
const UNIT_MM = 'mm';
|
||||
const UNIT_INCH = '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
|
||||
|
|
@ -154,7 +153,7 @@ class Settings
|
|||
*/
|
||||
public static function setCompatibility($compatibility)
|
||||
{
|
||||
$compatibility = (bool)$compatibility;
|
||||
$compatibility = (bool) $compatibility;
|
||||
self::$xmlWriterCompatibility = $compatibility;
|
||||
|
||||
return true;
|
||||
|
|
@ -180,6 +179,7 @@ class Settings
|
|||
{
|
||||
if (in_array($zipClass, array(self::PCLZIP, self::ZIPARCHIVE, self::OLD_LIB))) {
|
||||
self::$zipClass = $zipClass;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -229,7 +229,6 @@ class Settings
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the directory path to the PDF Rendering Library.
|
||||
*
|
||||
|
|
@ -275,7 +274,7 @@ class Settings
|
|||
public static function setMeasurementUnit($value)
|
||||
{
|
||||
$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)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -289,7 +288,7 @@ class Settings
|
|||
*
|
||||
* @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
|
||||
*/
|
||||
|
|
@ -318,8 +317,8 @@ class Settings
|
|||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -330,8 +329,8 @@ class Settings
|
|||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
* @param boolean $outputEscapingEnabled
|
||||
*
|
||||
* @param bool $outputEscapingEnabled
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
|
|
@ -360,6 +359,7 @@ class Settings
|
|||
{
|
||||
if (is_string($value) && trim($value) !== '') {
|
||||
self::$defaultFontName = $value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -369,7 +369,7 @@ class Settings
|
|||
/**
|
||||
* Get default font size
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public static function getDefaultFontSize()
|
||||
{
|
||||
|
|
@ -384,9 +384,10 @@ class Settings
|
|||
*/
|
||||
public static function setDefaultFontSize($value)
|
||||
{
|
||||
$value = intval($value);
|
||||
$value = (int) $value;
|
||||
if ($value > 0) {
|
||||
self::$defaultFontSize = $value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ namespace PhpOffice\PhpWord\Shared;
|
|||
|
||||
abstract class AbstractEnum
|
||||
{
|
||||
|
||||
private static $constCacheArray = null;
|
||||
|
||||
private static function getConstants()
|
||||
|
|
@ -12,16 +11,17 @@ abstract class AbstractEnum
|
|||
self::$constCacheArray = array();
|
||||
}
|
||||
$calledClass = get_called_class();
|
||||
if (! array_key_exists($calledClass, self::$constCacheArray)) {
|
||||
if (!array_key_exists($calledClass, self::$constCacheArray)) {
|
||||
$reflect = new \ReflectionClass($calledClass);
|
||||
self::$constCacheArray[$calledClass] = $reflect->getConstants();
|
||||
}
|
||||
|
||||
return self::$constCacheArray[$calledClass];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all values for this enum
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function values()
|
||||
|
|
@ -31,19 +31,20 @@ abstract class AbstractEnum
|
|||
|
||||
/**
|
||||
* Returns true the value is valid for this enum
|
||||
*
|
||||
*
|
||||
* @param strign $value
|
||||
* @return boolean true if value is valid
|
||||
* @return bool true if value is valid
|
||||
*/
|
||||
public static function isValid($value)
|
||||
{
|
||||
$values = array_values(self::getConstants());
|
||||
|
||||
return in_array($value, $values, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that the value passed is a valid value
|
||||
*
|
||||
*
|
||||
* @param string $value
|
||||
* @throws \InvalidArgumentException if the value passed is not valid for this enum
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Shared;
|
||||
|
||||
/**
|
||||
|
|
@ -22,12 +21,12 @@ namespace PhpOffice\PhpWord\Shared;
|
|||
*/
|
||||
class Converter
|
||||
{
|
||||
const INCH_TO_CM = 2.54;
|
||||
const INCH_TO_TWIP = 1440;
|
||||
const INCH_TO_PIXEL = 96;
|
||||
const INCH_TO_POINT = 72;
|
||||
const PIXEL_TO_EMU = 9525;
|
||||
const DEGREE_TO_ANGLE = 60000;
|
||||
const INCH_TO_CM = 2.54;
|
||||
const INCH_TO_TWIP = 1440;
|
||||
const INCH_TO_PIXEL = 96;
|
||||
const INCH_TO_POINT = 72;
|
||||
const PIXEL_TO_EMU = 9525;
|
||||
const DEGREE_TO_ANGLE = 60000;
|
||||
|
||||
/**
|
||||
* Convert centimeter to twip
|
||||
|
|
@ -235,7 +234,7 @@ class Converter
|
|||
*/
|
||||
public static function degreeToAngle($degree = 1)
|
||||
{
|
||||
return (int)round($degree * self::DEGREE_TO_ANGLE);
|
||||
return (int) round($degree * self::DEGREE_TO_ANGLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,10 +11,9 @@
|
|||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Shared;
|
||||
|
||||
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.
|
||||
// @todo Find better error checking for this one
|
||||
// if (method_exists($element, 'addText')) {
|
||||
$element->addText($node->nodeValue, $styles['font'], $styles['paragraph']);
|
||||
$element->addText($node->nodeValue, $styles['font'], $styles['paragraph']);
|
||||
// }
|
||||
|
||||
return null;
|
||||
|
|
@ -275,14 +274,14 @@ class Html
|
|||
|
||||
// $attributes = $node->attributes;
|
||||
// if ($attributes->getNamedItem('width') !== null) {
|
||||
// $newElement->setWidth($attributes->getNamedItem('width')->value);
|
||||
// $newElement->setWidth($attributes->getNamedItem('width')->value);
|
||||
// }
|
||||
|
||||
// if ($attributes->getNamedItem('height') !== null) {
|
||||
// $newElement->setHeight($attributes->getNamedItem('height')->value);
|
||||
// $newElement->setHeight($attributes->getNamedItem('height')->value);
|
||||
// }
|
||||
// if ($attributes->getNamedItem('width') !== null) {
|
||||
// $newElement=$element->addCell($width=$attributes->getNamedItem('width')->value);
|
||||
// $newElement=$element->addCell($width=$attributes->getNamedItem('width')->value);
|
||||
// }
|
||||
|
||||
return $newElement;
|
||||
|
|
@ -364,10 +363,10 @@ class Html
|
|||
$styles['alignment'] = $cValue; // todo: any mapping?
|
||||
break;
|
||||
case 'color':
|
||||
$styles['color'] = trim($cValue, "#");
|
||||
$styles['color'] = trim($cValue, '#');
|
||||
break;
|
||||
case 'background-color':
|
||||
$styles['bgColor'] = trim($cValue, "#");
|
||||
$styles['bgColor'] = trim($cValue, '#');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue