Merge branch 'develop' into add_html_table_layout
This commit is contained in:
commit
f472bfbc75
|
|
@ -11,6 +11,9 @@ v0.16.0 (xx xxx 2018)
|
||||||
- Fix regex in `cloneBlock` function @nicoder #1269
|
- Fix regex in `cloneBlock` function @nicoder #1269
|
||||||
- HTML Title Writer loses text when Title contains a TextRun instead a string. @begnini #1436
|
- HTML Title Writer loses text when Title contains a TextRun instead a string. @begnini #1436
|
||||||
- Adding table layout to the generated HTML @aarangara #1441
|
- Adding table layout to the generated HTML @aarangara #1441
|
||||||
|
- Fix loading of Sharepoint document @Garrcomm #1498
|
||||||
|
- RTF writer: Round getPageSizeW and getPageSizeH to avoid decimals @Patrick64 #1493
|
||||||
|
- Fix parsing of Office 365 documents @Timanx #1485
|
||||||
|
|
||||||
v0.15.0 (14 Jul 2018)
|
v0.15.0 (14 Jul 2018)
|
||||||
----------------------
|
----------------------
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,4 @@ Fixes # (issue)
|
||||||
|
|
||||||
- [ ] I have run `composer run-script check --timeout=0` and no errors were reported
|
- [ ] I have run `composer run-script check --timeout=0` and no errors were reported
|
||||||
- [ ] The new code is covered by unit tests (check build/coverage for coverage report)
|
- [ ] The new code is covered by unit tests (check build/coverage for coverage report)
|
||||||
- [ ] I have update the documentation to describe the changes
|
- [ ] I have updated the documentation to describe the changes
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ Available Section style options:
|
||||||
- ``marginRight``. Page margin right in *twip*.
|
- ``marginRight``. Page margin right in *twip*.
|
||||||
- ``marginBottom``. Page margin bottom in *twip*.
|
- ``marginBottom``. Page margin bottom in *twip*.
|
||||||
- ``orientation``. Page orientation (``portrait``, which is default, or ``landscape``).
|
- ``orientation``. Page orientation (``portrait``, which is default, or ``landscape``).
|
||||||
|
See ``\PhpOffice\PhpWord\Style\Section::ORIENTATION_...`` class constants for possible values
|
||||||
- ``pageSizeH``. Page height in *twip*. Implicitly defined by ``orientation`` option. Any changes are discouraged.
|
- ``pageSizeH``. Page height in *twip*. Implicitly defined by ``orientation`` option. Any changes are discouraged.
|
||||||
- ``pageSizeW``. Page width in *twip*. Implicitly defined by ``orientation`` option. Any changes are discouraged.
|
- ``pageSizeW``. Page width in *twip*. Implicitly defined by ``orientation`` option. Any changes are discouraged.
|
||||||
|
|
||||||
|
|
@ -45,7 +46,7 @@ Available Font style options:
|
||||||
- ``color``. Font color, e.g. *FF0000*.
|
- ``color``. Font color, e.g. *FF0000*.
|
||||||
- ``doubleStrikethrough``. Double strikethrough, *true* or *false*.
|
- ``doubleStrikethrough``. Double strikethrough, *true* or *false*.
|
||||||
- ``fgColor``. Font highlight color, e.g. *yellow*, *green*, *blue*.
|
- ``fgColor``. Font highlight color, e.g. *yellow*, *green*, *blue*.
|
||||||
See ``\PhpOffice\PhpWord\Style\Font::FGCOLOR_...`` constants for more values
|
See ``\PhpOffice\PhpWord\Style\Font::FGCOLOR_...`` class constants for possible values
|
||||||
- ``hint``. Font content type, *default*, *eastAsia*, or *cs*.
|
- ``hint``. Font content type, *default*, *eastAsia*, or *cs*.
|
||||||
- ``italic``. Italic, *true* or *false*.
|
- ``italic``. Italic, *true* or *false*.
|
||||||
- ``name``. Font name, e.g. *Arial*.
|
- ``name``. Font name, e.g. *Arial*.
|
||||||
|
|
@ -56,7 +57,7 @@ Available Font style options:
|
||||||
- ``subScript``. Subscript, *true* or *false*.
|
- ``subScript``. Subscript, *true* or *false*.
|
||||||
- ``superScript``. Superscript, *true* or *false*.
|
- ``superScript``. Superscript, *true* or *false*.
|
||||||
- ``underline``. Underline, *single*, *dash*, *dotted*, etc.
|
- ``underline``. Underline, *single*, *dash*, *dotted*, etc.
|
||||||
See ``\PhpOffice\PhpWord\Style\Font::UNDERLINE_...`` constants for more values
|
See ``\PhpOffice\PhpWord\Style\Font::UNDERLINE_...`` class constants for possible values
|
||||||
- ``lang``. Language, either a language code like *en-US*, *fr-BE*, etc. or an object (or as an array) if you need to set eastAsian or bidirectional languages
|
- ``lang``. Language, either a language code like *en-US*, *fr-BE*, etc. or an object (or as an array) if you need to set eastAsian or bidirectional languages
|
||||||
See ``\PhpOffice\PhpWord\Style\Language`` class for some language codes.
|
See ``\PhpOffice\PhpWord\Style\Language`` class for some language codes.
|
||||||
- ``position``. The text position, raised or lowered, in half points
|
- ``position``. The text position, raised or lowered, in half points
|
||||||
|
|
@ -69,7 +70,7 @@ Paragraph
|
||||||
Available Paragraph style options:
|
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 for the details.
|
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class constants for possible values.
|
||||||
- ``basedOn``. Parent style.
|
- ``basedOn``. Parent style.
|
||||||
- ``hanging``. Hanging in *twip*.
|
- ``hanging``. Hanging in *twip*.
|
||||||
- ``indent``. Indent in *twip*.
|
- ``indent``. Indent in *twip*.
|
||||||
|
|
@ -82,6 +83,7 @@ Available Paragraph style options:
|
||||||
- ``spaceAfter``. Space after paragraph in *twip*.
|
- ``spaceAfter``. Space after paragraph in *twip*.
|
||||||
- ``spacing``. Space between lines.
|
- ``spacing``. Space between lines.
|
||||||
- ``spacingLineRule``. Line Spacing Rule. *auto*, *exact*, *atLeast*
|
- ``spacingLineRule``. Line Spacing Rule. *auto*, *exact*, *atLeast*
|
||||||
|
See ``\PhpOffice\PhpWord\SimpleType\LineSpacingRule`` class constants for possible values.
|
||||||
- ``suppressAutoHyphens``. Hyphenation for paragraph, *true* or *false*.
|
- ``suppressAutoHyphens``. Hyphenation for paragraph, *true* or *false*.
|
||||||
- ``tabs``. Set of custom tab stops.
|
- ``tabs``. Set of custom tab stops.
|
||||||
- ``widowControl``. Allow first/last line to display on a separate page, *true* or *false*.
|
- ``widowControl``. Allow first/last line to display on a separate page, *true* or *false*.
|
||||||
|
|
@ -89,7 +91,7 @@ Available Paragraph style options:
|
||||||
- ``bidi``. Right to Left Paragraph Layout, *true* or *false*.
|
- ``bidi``. Right to Left Paragraph Layout, *true* or *false*.
|
||||||
- ``shading``. Paragraph Shading.
|
- ``shading``. Paragraph Shading.
|
||||||
- ``textAlignment``. Vertical Character Alignment on Line.
|
- ``textAlignment``. Vertical Character Alignment on Line.
|
||||||
See ``\PhpOffice\PhpWord\SimpleType\TextAlignment`` class for possible values.
|
See ``\PhpOffice\PhpWord\SimpleType\TextAlignment`` class constants for possible values.
|
||||||
|
|
||||||
.. _table-style:
|
.. _table-style:
|
||||||
|
|
||||||
|
|
@ -99,7 +101,7 @@ Table
|
||||||
Available Table style options:
|
Available Table 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\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` classes for the details.
|
See ``\PhpOffice\PhpWord\SimpleType\JcTable`` and ``\PhpOffice\PhpWord\SimpleType\Jc`` class constants for possible values.
|
||||||
- ``bgColor``. Background color, e.g. '9966CC'.
|
- ``bgColor``. Background color, e.g. '9966CC'.
|
||||||
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
- ``border(Top|Right|Bottom|Left)Color``. Border color, e.g. '9966CC'.
|
||||||
- ``border(Top|Right|Bottom|Left)Size``. Border size in *twip*.
|
- ``border(Top|Right|Bottom|Left)Size``. Border size in *twip*.
|
||||||
|
|
@ -168,7 +170,7 @@ Numbering level
|
||||||
Available NumberingLevel style options:
|
Available NumberingLevel 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 for the details.
|
See ``\PhpOffice\PhpWord\SimpleType\Jc`` class constants for possible values.
|
||||||
- ``font``. Font name.
|
- ``font``. Font name.
|
||||||
- ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
|
- ``format``. Numbering format bullet\|decimal\|upperRoman\|lowerRoman\|upperLetter\|lowerLetter.
|
||||||
- ``hanging``. See paragraph style.
|
- ``hanging``. See paragraph style.
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,9 @@ class Word2007 extends AbstractReader implements ReaderInterface
|
||||||
foreach ($steps as $step) {
|
foreach ($steps as $step) {
|
||||||
$stepPart = $step['stepPart'];
|
$stepPart = $step['stepPart'];
|
||||||
$stepItems = $step['stepItems'];
|
$stepItems = $step['stepItems'];
|
||||||
|
if (!isset($relationships[$stepPart])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
foreach ($relationships[$stepPart] as $relItem) {
|
foreach ($relationships[$stepPart] as $relItem) {
|
||||||
$relType = $relItem['type'];
|
$relType = $relItem['type'];
|
||||||
if (isset($stepItems[$relType])) {
|
if (isset($stepItems[$relType])) {
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,9 @@ final class Language extends AbstractStyle
|
||||||
const PT_BR = 'pt-BR';
|
const PT_BR = 'pt-BR';
|
||||||
const PT_BR_ID = 1046;
|
const PT_BR_ID = 1046;
|
||||||
|
|
||||||
|
const NL_NL = 'nl-NL';
|
||||||
|
const NL_NL_ID = 1043;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language ID, used for RTF document generation
|
* Language ID, used for RTF document generation
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -503,11 +503,19 @@ class TemplateProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Usually, the name of main part document will be 'document.xml'. However, some .docx files (possibly those from Office 365, experienced also on documents from Word Online created from blank templates) have file 'document22.xml' in their zip archive instead of 'document.xml'. This method searches content types file to correctly determine the file name.
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function getMainPartName()
|
protected function getMainPartName()
|
||||||
{
|
{
|
||||||
return 'word/document.xml';
|
$contentTypes = $this->zipClass->getFromName('[Content_Types].xml');
|
||||||
|
|
||||||
|
$pattern = '~PartName="\/(word\/document.*?\.xml)" ContentType="application\/vnd\.openxmlformats-officedocument\.wordprocessingml\.document\.main\+xml"~';
|
||||||
|
|
||||||
|
preg_match($pattern, $contentTypes, $matches);
|
||||||
|
|
||||||
|
return array_key_exists(1, $matches) ? $matches[1] : 'word/document.xml';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,8 @@ class Section extends AbstractStyle
|
||||||
$content .= '\sectd ';
|
$content .= '\sectd ';
|
||||||
|
|
||||||
// Size & margin
|
// Size & margin
|
||||||
$content .= $this->getValueIf($style->getPageSizeW() !== null, '\pgwsxn' . $style->getPageSizeW());
|
$content .= $this->getValueIf($style->getPageSizeW() !== null, '\pgwsxn' . round($style->getPageSizeW()));
|
||||||
$content .= $this->getValueIf($style->getPageSizeH() !== null, '\pghsxn' . $style->getPageSizeH());
|
$content .= $this->getValueIf($style->getPageSizeH() !== null, '\pghsxn' . round($style->getPageSizeH()));
|
||||||
$content .= ' ';
|
$content .= ' ';
|
||||||
$content .= $this->getValueIf($style->getMarginTop() !== null, '\margtsxn' . $style->getMarginTop());
|
$content .= $this->getValueIf($style->getMarginTop() !== null, '\margtsxn' . $style->getMarginTop());
|
||||||
$content .= $this->getValueIf($style->getMarginRight() !== null, '\margrsxn' . $style->getMarginRight());
|
$content .= $this->getValueIf($style->getMarginRight() !== null, '\margrsxn' . $style->getMarginRight());
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,9 @@ class Image extends AbstractElement
|
||||||
$style->setPositioning('absolute');
|
$style->setPositioning('absolute');
|
||||||
$styleWriter = new ImageStyleWriter($xmlWriter, $style);
|
$styleWriter = new ImageStyleWriter($xmlWriter, $style);
|
||||||
|
|
||||||
$xmlWriter->startElement('w:p');
|
if (!$this->withoutP) {
|
||||||
|
$xmlWriter->startElement('w:p');
|
||||||
|
}
|
||||||
$xmlWriter->startElement('w:r');
|
$xmlWriter->startElement('w:r');
|
||||||
$xmlWriter->startElement('w:pict');
|
$xmlWriter->startElement('w:pict');
|
||||||
$xmlWriter->startElement('v:shape');
|
$xmlWriter->startElement('v:shape');
|
||||||
|
|
@ -118,6 +120,8 @@ class Image extends AbstractElement
|
||||||
$xmlWriter->endElement(); // v:shape
|
$xmlWriter->endElement(); // v:shape
|
||||||
$xmlWriter->endElement(); // w:pict
|
$xmlWriter->endElement(); // w:pict
|
||||||
$xmlWriter->endElement(); // w:r
|
$xmlWriter->endElement(); // w:r
|
||||||
$xmlWriter->endElement(); // w:p
|
if (!$this->withoutP) {
|
||||||
|
$xmlWriter->endElement(); // w:p
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ class Frame extends AbstractStyle
|
||||||
'hPos' => 'mso-position-horizontal',
|
'hPos' => 'mso-position-horizontal',
|
||||||
'vPos' => 'mso-position-vertical',
|
'vPos' => 'mso-position-vertical',
|
||||||
'hPosRelTo' => 'mso-position-horizontal-relative',
|
'hPosRelTo' => 'mso-position-horizontal-relative',
|
||||||
|
'vPosRelTo' => 'mso-position-vertical-relative',
|
||||||
);
|
);
|
||||||
$posStyles = $this->getStyles($style, $properties);
|
$posStyles = $this->getStyles($style, $properties);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,21 @@ class HtmlTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->assertCount(2, $section->getElements());
|
$this->assertCount(2, $section->getElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test HTML entities
|
||||||
|
*/
|
||||||
|
public function testParseHtmlEntities()
|
||||||
|
{
|
||||||
|
\PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true);
|
||||||
|
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||||
|
$section = $phpWord->addSection();
|
||||||
|
Html::addHtml($section, 'text with entities <my text>');
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
|
||||||
|
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p[1]/w:r/w:t'));
|
||||||
|
$this->assertEquals('text with entities <my text>', $doc->getElement('/w:document/w:body/w:p[1]/w:r/w:t')->nodeValue);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test underline
|
* Test underline
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -276,4 +276,13 @@ final class TemplateProcessorTest extends \PHPUnit\Framework\TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMainPartNameDetection()
|
||||||
|
{
|
||||||
|
$templateProcessor = new TemplateProcessor(__DIR__ . '/_files/templates/document22-xml.docx');
|
||||||
|
|
||||||
|
$variables = array('test');
|
||||||
|
|
||||||
|
$this->assertEquals($variables, $templateProcessor->getVariables());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue