Merge branch 'develop' into fixes-1750-block-with-images-inside

This commit is contained in:
troosan 2019-12-08 14:35:14 +01:00 committed by GitHub
commit d9cb88e987
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 84 additions and 5 deletions

View File

@ -75,8 +75,10 @@ Available Paragraph style options:
- ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012. - ``alignment``. Supports all alignment modes since 1st Edition of ECMA-376 standard up till ISO/IEC 29500:2012.
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class constants for possible values. See ``\PhpOffice\PhpWord\SimpleType\Jc`` class constants for possible values.
- ``basedOn``. Parent style. - ``basedOn``. Parent style.
- ``hanging``. Hanging in *twip*. - ``hanging``. Hanging indentation in *half inches*.
- ``indent``. Indent in *twip*. - ``indent``. Indent (left indentation) in *half inches*.
- ``indentation``. An array of indentation key => value pairs in *twip*. Supports *left*, *right*, *firstLine* and *hanging* indentation.
See ``\PhpOffice\PhpWord\Style\Indentation`` for possible identation types.
- ``keepLines``. Keep all lines on one page, *true* or *false*. - ``keepLines``. Keep all lines on one page, *true* or *false*.
- ``keepNext``. Keep paragraph with next paragraph, *true* or *false*. - ``keepNext``. Keep paragraph with next paragraph, *true* or *false*.
- ``lineHeight``. Text line height, e.g. *1.0*, *1.5*, etc. - ``lineHeight``. Text line height, e.g. *1.0*, *1.5*, etc.

View File

@ -244,3 +244,20 @@ See ``Sample_40_TemplateSetComplexValue.php`` for examples.
$table->addCell(150)->addText('Cell B2'); $table->addCell(150)->addText('Cell B2');
$table->addCell(150)->addText('Cell B3'); $table->addCell(150)->addText('Cell B3');
$templateProcessor->setComplexBlock('table', $table); $templateProcessor->setComplexBlock('table', $table);
save
"""""""""
Saves the loaded template within the current directory. Returns the file path.
.. code-block:: php
$filepath = $templateProcessor->save();
saveAs
"""""""""
Saves a copy of the loaded template in the indicated path.
.. code-block:: php
$pathToSave = 'path/to/save/file.ext';
$templateProcessor->saveAs($pathToSave);

View File

@ -198,7 +198,7 @@ class Paragraph extends Border
{ {
$key = Text::removeUnderscorePrefix($key); $key = Text::removeUnderscorePrefix($key);
if ('indent' == $key || 'hanging' == $key) { if ('indent' == $key || 'hanging' == $key) {
$value = $value * 720; $value = $value * 720; // 720 twips is 0.5 inch
} }
return parent::setStyleValue($key, $value); return parent::setStyleValue($key, $value);

View File

@ -34,6 +34,22 @@ class MediaTest extends AbstractWebServerEmbeddedTest
$this->assertEquals(array(), Media::getElements('section')); $this->assertEquals(array(), Media::getElements('section'));
} }
/**
* Get header media elements
*/
public function testGetHeaderMediaElementsWithNull()
{
$this->assertEquals(array(), Media::getElements('header'));
}
/**
* Get footer media elements
*/
public function testGetFooterMediaElementsWithNull()
{
$this->assertEquals(array(), Media::getElements('footer'));
}
/** /**
* Count section media elements * Count section media elements
*/ */

View File

@ -225,4 +225,13 @@ class PhpWordTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(2, $phpWord->getSection(0)->countElements()); $this->assertEquals(2, $phpWord->getSection(0)->countElements());
$this->assertEquals(1, $phpWord->getSection(1)->countElements()); $this->assertEquals(1, $phpWord->getSection(1)->countElements());
} }
/**
* @covers \PhpOffice\PhpWord\PhpWord::getSettings
*/
public function testGetSettings()
{
$phpWord = new PhpWord();
$this->assertInstanceOf('PhpOffice\\PhpWord\\Metadata\\Settings', $phpWord->getSettings());
}
} }

View File

@ -33,6 +33,7 @@ class StyleTest extends \PHPUnit\Framework\TestCase
* @covers ::addParagraphStyle * @covers ::addParagraphStyle
* @covers ::addFontStyle * @covers ::addFontStyle
* @covers ::addLinkStyle * @covers ::addLinkStyle
* @covers ::addNumberingStyle
* @covers ::addTitleStyle * @covers ::addTitleStyle
* @covers ::addTableStyle * @covers ::addTableStyle
* @covers ::setDefaultParagraphStyle * @covers ::setDefaultParagraphStyle
@ -47,6 +48,20 @@ class StyleTest extends \PHPUnit\Framework\TestCase
$paragraph = array('alignment' => Jc::CENTER); $paragraph = array('alignment' => Jc::CENTER);
$font = array('italic' => true, '_bold' => true); $font = array('italic' => true, '_bold' => true);
$table = array('bgColor' => 'CCCCCC'); $table = array('bgColor' => 'CCCCCC');
$numbering = array(
'type' => 'multilevel',
'levels' => array(
array(
'start' => 1,
'format' => 'decimal',
'restart' => 1,
'suffix' => 'space',
'text' => '%1.',
'alignment' => Jc::START,
),
),
);
$styles = array( $styles = array(
'Paragraph' => 'Paragraph', 'Paragraph' => 'Paragraph',
'Font' => 'Font', 'Font' => 'Font',
@ -54,12 +69,13 @@ class StyleTest extends \PHPUnit\Framework\TestCase
'Table' => 'Table', 'Table' => 'Table',
'Heading_1' => 'Font', 'Heading_1' => 'Font',
'Normal' => 'Paragraph', 'Normal' => 'Paragraph',
'Numbering' => 'Numbering',
); );
Style::addParagraphStyle('Paragraph', $paragraph); Style::addParagraphStyle('Paragraph', $paragraph);
Style::addFontStyle('Font', $font); Style::addFontStyle('Font', $font);
Style::addLinkStyle('Link', $font); Style::addLinkStyle('Link', $font);
// @todo Style::addNumberingStyle Style::addNumberingStyle('Numbering', $numbering);
Style::addTitleStyle(1, $font); Style::addTitleStyle(1, $font);
Style::addTableStyle('Table', $table); Style::addTableStyle('Table', $table);
Style::setDefaultParagraphStyle($paragraph); Style::setDefaultParagraphStyle($paragraph);

View File

@ -26,7 +26,26 @@ abstract class AbstractWebServerEmbeddedTest extends \PHPUnit\Framework\TestCase
public static function setUpBeforeClass() public static function setUpBeforeClass()
{ {
if (self::isBuiltinServerSupported()) { if (self::isBuiltinServerSupported()) {
self::$httpServer = new Process(array('php', '-S', 'localhost:8080', '-t', 'tests/PhpWord/_files')); $commandLine = 'php -S localhost:8080 -t tests/PhpWord/_files';
/*
* Make sure to invoke \Symfony\Component\Process\Process correctly
* regardless of PHP version used.
*
* In Process version >= 5 / PHP >= 7.2.5, the constructor requires
* an array, while in version < 3.3 / PHP < 5.5.9 it requires a string.
* In between, it can accept both.
*
* Process::fromShellCommandLine() was introduced in version 4.2.0,
* to enable recent versions of Process to parse a command string,
* so if it is not available it means it is still possible to pass
* a string to the constructor.
*/
if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandLine')) {
self::$httpServer = Process::fromShellCommandline($commandLine);
} else {
self::$httpServer = new Process($commandLine);
}
self::$httpServer->start(); self::$httpServer->start();
while (!self::$httpServer->isRunning()) { while (!self::$httpServer->isRunning()) {
usleep(1000); usleep(1000);