HTML writer fixes
* fixed HTML superscript, and added allcaps, smallcaps, and letter-spacing * make Comment constructor attributes optional
This commit is contained in:
commit
aa4c3f8486
1
.gitignore
vendored
1
.gitignore
vendored
@ -19,4 +19,5 @@ vendor
|
|||||||
phpword.ini
|
phpword.ini
|
||||||
/.buildpath
|
/.buildpath
|
||||||
/.project
|
/.project
|
||||||
|
/nbproject
|
||||||
/.php_cs.cache
|
/.php_cs.cache
|
||||||
|
|||||||
@ -29,6 +29,7 @@ This is the last version to support PHP 5.3
|
|||||||
- Impossible to add element PreserveText in Section - @rvanlaak #452
|
- Impossible to add element PreserveText in Section - @rvanlaak #452
|
||||||
- Added missing options for numbering format - @troosan #1041
|
- Added missing options for numbering format - @troosan #1041
|
||||||
- Fixed impossibility to set a different footer for first page - @ctrlaltca #1116
|
- Fixed impossibility to set a different footer for first page - @ctrlaltca #1116
|
||||||
|
- Fixed styles not being applied by HTML writer, better pdf output - @sarke #1047 #500 #1139
|
||||||
|
|
||||||
v0.13.0 (31 July 2016)
|
v0.13.0 (31 July 2016)
|
||||||
-------------------
|
-------------------
|
||||||
|
|||||||
@ -29,6 +29,9 @@
|
|||||||
{
|
{
|
||||||
"name": "Roman Syroeshko",
|
"name": "Roman Syroeshko",
|
||||||
"homepage": "http://ru.linkedin.com/pub/roman-syroeshko/34/a53/994/"
|
"homepage": "http://ru.linkedin.com/pub/roman-syroeshko/34/a53/994/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Antoine de Troostembergh"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
|
|||||||
@ -41,14 +41,14 @@ master_doc = 'index'
|
|||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'PHPWord'
|
project = u'PHPWord'
|
||||||
copyright = u'2014-2015, PHPWord Contributors'
|
copyright = u'2014-2017, PHPWord Contributors'
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
# The version info for the project you're documenting, acts as replacement for
|
||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '0.13.0'
|
version = '0.14.0'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = version
|
release = version
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ html_theme = 'default'
|
|||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
html_static_path = ['_static']
|
#html_static_path = ['_static']
|
||||||
|
|
||||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||||
# using the given strftime format.
|
# using the given strftime format.
|
||||||
|
|||||||
@ -432,7 +432,7 @@ Comments
|
|||||||
---------
|
---------
|
||||||
|
|
||||||
Comments can be added to a document by using ``addComment``.
|
Comments can be added to a document by using ``addComment``.
|
||||||
The comment can contain formatted text. Once the comment has been added, it can be linked to any to any element.
|
The comment can contain formatted text. Once the comment has been added, it can be linked to any element with ``setCommentStart``.
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ Example:
|
|||||||
|
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"phpoffice/phpword": "v0.13.*"
|
"phpoffice/phpword": "v0.14.*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ References
|
|||||||
==========
|
==========
|
||||||
|
|
||||||
ISO/IEC 29500, Third edition, 2012-09-01
|
ISO/IEC 29500, Third edition, 2012-09-01
|
||||||
---------------------
|
----------------------------------------
|
||||||
|
|
||||||
- `Part 1: Fundamentals and Markup Language Reference
|
- `Part 1: Fundamentals and Markup Language Reference
|
||||||
<http://standards.iso.org/ittf/PubliclyAvailableStandards/c061750_ISO_IEC_29500-1_2012.zip>`__
|
<http://standards.iso.org/ittf/PubliclyAvailableStandards/c061750_ISO_IEC_29500-1_2012.zip>`__
|
||||||
|
|||||||
@ -21,7 +21,7 @@ $textrun->addText(' a test');
|
|||||||
$section->addTextBreak(2);
|
$section->addTextBreak(2);
|
||||||
|
|
||||||
// Let's create a comment that we will link to a start element and an end element
|
// Let's create a comment that we will link to a start element and an end element
|
||||||
$commentWithStartAndEnd = new \PhpOffice\PhpWord\Element\Comment('Foo Bar', new \DateTime(), '');
|
$commentWithStartAndEnd = new \PhpOffice\PhpWord\Element\Comment('Foo Bar', new \DateTime());
|
||||||
$commentWithStartAndEnd->addText('A comment with a start and an end');
|
$commentWithStartAndEnd->addText('A comment with a start and an end');
|
||||||
$phpWord->addComment($commentWithStartAndEnd);
|
$phpWord->addComment($commentWithStartAndEnd);
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ $textToEndOn->setCommentRangeEnd($commentWithStartAndEnd);
|
|||||||
$section->addTextBreak(2);
|
$section->addTextBreak(2);
|
||||||
|
|
||||||
// Let's add a comment on an image
|
// Let's add a comment on an image
|
||||||
$commentOnImage = new \PhpOffice\PhpWord\Element\Comment('Mr Smart', new \DateTime(), '');
|
$commentOnImage = new \PhpOffice\PhpWord\Element\Comment('Mr Smart', new \DateTime());
|
||||||
$imageComment = $commentOnImage->addTextRun();
|
$imageComment = $commentOnImage->addTextRun();
|
||||||
$imageComment->addText('Hey, Mars does look ');
|
$imageComment->addText('Hey, Mars does look ');
|
||||||
$imageComment->addText('red', array('color' => 'FF0000'));
|
$imageComment->addText('red', array('color' => 'FF0000'));
|
||||||
|
|||||||
@ -57,7 +57,7 @@ class Comment extends TrackChange
|
|||||||
* @param \DateTime $date
|
* @param \DateTime $date
|
||||||
* @param string $initials
|
* @param string $initials
|
||||||
*/
|
*/
|
||||||
public function __construct($author, $date, $initials)
|
public function __construct($author, $date = null, $initials = null)
|
||||||
{
|
{
|
||||||
parent::__construct($author, $date);
|
parent::__construct($author, $date);
|
||||||
$this->initials = $initials;
|
$this->initials = $initials;
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class TrackChange extends AbstractContainer
|
|||||||
* @param string $author
|
* @param string $author
|
||||||
* @param \DateTime $date
|
* @param \DateTime $date
|
||||||
*/
|
*/
|
||||||
public function __construct($author, \DateTime $date)
|
public function __construct($author, \DateTime $date = null)
|
||||||
{
|
{
|
||||||
$this->author = $author;
|
$this->author = $author;
|
||||||
$this->date = $date;
|
$this->date = $date;
|
||||||
|
|||||||
@ -164,6 +164,8 @@ class Text extends AbstractElement
|
|||||||
if ($pStyleIsObject) {
|
if ($pStyleIsObject) {
|
||||||
$styleWriter = new ParagraphStyleWriter($paragraphStyle);
|
$styleWriter = new ParagraphStyleWriter($paragraphStyle);
|
||||||
$style = $styleWriter->write();
|
$style = $styleWriter->write();
|
||||||
|
} elseif (is_string($paragraphStyle)) {
|
||||||
|
$style = $paragraphStyle;
|
||||||
}
|
}
|
||||||
if ($style) {
|
if ($style) {
|
||||||
$attribute = $pStyleIsObject ? 'style' : 'class';
|
$attribute = $pStyleIsObject ? 'style' : 'class';
|
||||||
@ -186,6 +188,8 @@ class Text extends AbstractElement
|
|||||||
if ($fStyleIsObject) {
|
if ($fStyleIsObject) {
|
||||||
$styleWriter = new FontStyleWriter($fontStyle);
|
$styleWriter = new FontStyleWriter($fontStyle);
|
||||||
$style = $styleWriter->write();
|
$style = $styleWriter->write();
|
||||||
|
} elseif (is_string($fontStyle)) {
|
||||||
|
$style = $fontStyle;
|
||||||
}
|
}
|
||||||
if ($style) {
|
if ($style) {
|
||||||
$attribute = $fStyleIsObject ? 'style' : 'class';
|
$attribute = $fStyleIsObject ? 'style' : 'class';
|
||||||
|
|||||||
@ -52,12 +52,17 @@ class Font extends AbstractStyle
|
|||||||
$css['background'] = $this->getValueIf($fgColor != '', $fgColor);
|
$css['background'] = $this->getValueIf($fgColor != '', $fgColor);
|
||||||
$css['font-weight'] = $this->getValueIf($style->isBold(), 'bold');
|
$css['font-weight'] = $this->getValueIf($style->isBold(), 'bold');
|
||||||
$css['font-style'] = $this->getValueIf($style->isItalic(), 'italic');
|
$css['font-style'] = $this->getValueIf($style->isItalic(), 'italic');
|
||||||
$css['vertical-align'] = $this->getValueIf($style->isSuperScript(), 'italic');
|
$css['vertical-align'] = '';
|
||||||
$css['vertical-align'] = $this->getValueIf($style->isSuperScript(), 'super');
|
$css['vertical-align'] .= $this->getValueIf($style->isSuperScript(), 'super');
|
||||||
$css['vertical-align'] = $this->getValueIf($style->isSubScript(), 'sub');
|
$css['vertical-align'] .= $this->getValueIf($style->isSubScript(), 'sub');
|
||||||
$css['text-decoration'] = '';
|
$css['text-decoration'] = '';
|
||||||
$css['text-decoration'] .= $this->getValueIf($underline, 'underline ');
|
$css['text-decoration'] .= $this->getValueIf($underline, 'underline ');
|
||||||
$css['text-decoration'] .= $this->getValueIf($lineThrough, 'line-through ');
|
$css['text-decoration'] .= $this->getValueIf($lineThrough, 'line-through ');
|
||||||
|
$css['text-transform'] = $this->getValueIf($style->isAllCaps(), 'uppercase');
|
||||||
|
$css['font-variant'] = $this->getValueIf($style->isSmallCaps(), 'small-caps');
|
||||||
|
|
||||||
|
$spacing = $style->getSpacing();
|
||||||
|
$css['letter-spacing'] = $this->getValueIf(!is_null($spacing), ($spacing / 20) . 'pt');
|
||||||
|
|
||||||
return $this->assembleCss($css);
|
return $this->assembleCss($css);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,6 +80,9 @@ class Paragraph extends AbstractStyle
|
|||||||
$after = $spacing->getAfter();
|
$after = $spacing->getAfter();
|
||||||
$css['margin-top'] = $this->getValueIf(!is_null($before), ($before / 20) . 'pt');
|
$css['margin-top'] = $this->getValueIf(!is_null($before), ($before / 20) . 'pt');
|
||||||
$css['margin-bottom'] = $this->getValueIf(!is_null($after), ($after / 20) . 'pt');
|
$css['margin-bottom'] = $this->getValueIf(!is_null($after), ($after / 20) . 'pt');
|
||||||
|
} else {
|
||||||
|
$css['margin-top'] = '0';
|
||||||
|
$css['margin-bottom'] = '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->assembleCss($css);
|
return $this->assembleCss($css);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user