diff --git a/.gitignore b/.gitignore index 42f03ebe..2ac6e2b5 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ vendor phpword.ini /.buildpath /.project +/nbproject /.php_cs.cache diff --git a/CHANGELOG.md b/CHANGELOG.md index f963a3cd..ad046951 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ This is the last version to support PHP 5.3 - Impossible to add element PreserveText in Section - @rvanlaak #452 - Added missing options for numbering format - @troosan #1041 - 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) ------------------- diff --git a/composer.json b/composer.json index ab8b6aa6..5b5a91d2 100644 --- a/composer.json +++ b/composer.json @@ -29,6 +29,9 @@ { "name": "Roman Syroeshko", "homepage": "http://ru.linkedin.com/pub/roman-syroeshko/34/a53/994/" + }, + { + "name": "Antoine de Troostembergh" } ], "require": { diff --git a/docs/conf.py b/docs/conf.py index e9b1c59e..6b7cf8e8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -41,14 +41,14 @@ master_doc = 'index' # General information about the project. 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 # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '0.13.0' +version = '0.14.0' # The full version, including alpha/beta/rc tags. release = version @@ -120,7 +120,7 @@ html_theme = 'default' # 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, # 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, # using the given strftime format. diff --git a/docs/elements.rst b/docs/elements.rst index 848e3f98..124f4431 100644 --- a/docs/elements.rst +++ b/docs/elements.rst @@ -432,7 +432,7 @@ Comments --------- 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 diff --git a/docs/installing.rst b/docs/installing.rst index 9593484a..37e4d379 100644 --- a/docs/installing.rst +++ b/docs/installing.rst @@ -34,7 +34,7 @@ Example: { "require": { - "phpoffice/phpword": "v0.13.*" + "phpoffice/phpword": "v0.14.*" } } diff --git a/docs/references.rst b/docs/references.rst index 9c4e06a8..a17f558d 100644 --- a/docs/references.rst +++ b/docs/references.rst @@ -4,7 +4,7 @@ References ========== ISO/IEC 29500, Third edition, 2012-09-01 ---------------------- +---------------------------------------- - `Part 1: Fundamentals and Markup Language Reference `__ diff --git a/samples/Sample_37_Comments.php b/samples/Sample_37_Comments.php index 5c0e8abc..268739bc 100644 --- a/samples/Sample_37_Comments.php +++ b/samples/Sample_37_Comments.php @@ -21,7 +21,7 @@ $textrun->addText(' a test'); $section->addTextBreak(2); // 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'); $phpWord->addComment($commentWithStartAndEnd); @@ -36,7 +36,7 @@ $textToEndOn->setCommentRangeEnd($commentWithStartAndEnd); $section->addTextBreak(2); // 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->addText('Hey, Mars does look '); $imageComment->addText('red', array('color' => 'FF0000')); diff --git a/src/PhpWord/Element/Comment.php b/src/PhpWord/Element/Comment.php index a8f39748..908b8785 100644 --- a/src/PhpWord/Element/Comment.php +++ b/src/PhpWord/Element/Comment.php @@ -57,7 +57,7 @@ class Comment extends TrackChange * @param \DateTime $date * @param string $initials */ - public function __construct($author, $date, $initials) + public function __construct($author, $date = null, $initials = null) { parent::__construct($author, $date); $this->initials = $initials; diff --git a/src/PhpWord/Element/TrackChange.php b/src/PhpWord/Element/TrackChange.php index 11cc763a..d900b053 100644 --- a/src/PhpWord/Element/TrackChange.php +++ b/src/PhpWord/Element/TrackChange.php @@ -47,7 +47,7 @@ class TrackChange extends AbstractContainer * @param string $author * @param \DateTime $date */ - public function __construct($author, \DateTime $date) + public function __construct($author, \DateTime $date = null) { $this->author = $author; $this->date = $date; diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php index ed1ba4a3..71cb7566 100644 --- a/src/PhpWord/Writer/HTML/Element/Text.php +++ b/src/PhpWord/Writer/HTML/Element/Text.php @@ -164,6 +164,8 @@ class Text extends AbstractElement if ($pStyleIsObject) { $styleWriter = new ParagraphStyleWriter($paragraphStyle); $style = $styleWriter->write(); + } elseif (is_string($paragraphStyle)) { + $style = $paragraphStyle; } if ($style) { $attribute = $pStyleIsObject ? 'style' : 'class'; @@ -186,6 +188,8 @@ class Text extends AbstractElement if ($fStyleIsObject) { $styleWriter = new FontStyleWriter($fontStyle); $style = $styleWriter->write(); + } elseif (is_string($fontStyle)) { + $style = $fontStyle; } if ($style) { $attribute = $fStyleIsObject ? 'style' : 'class'; diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php index cb96cf64..8daa8823 100644 --- a/src/PhpWord/Writer/HTML/Style/Font.php +++ b/src/PhpWord/Writer/HTML/Style/Font.php @@ -52,12 +52,17 @@ class Font extends AbstractStyle $css['background'] = $this->getValueIf($fgColor != '', $fgColor); $css['font-weight'] = $this->getValueIf($style->isBold(), 'bold'); $css['font-style'] = $this->getValueIf($style->isItalic(), 'italic'); - $css['vertical-align'] = $this->getValueIf($style->isSuperScript(), 'italic'); - $css['vertical-align'] = $this->getValueIf($style->isSuperScript(), 'super'); - $css['vertical-align'] = $this->getValueIf($style->isSubScript(), 'sub'); + $css['vertical-align'] = ''; + $css['vertical-align'] .= $this->getValueIf($style->isSuperScript(), 'super'); + $css['vertical-align'] .= $this->getValueIf($style->isSubScript(), 'sub'); $css['text-decoration'] = ''; $css['text-decoration'] .= $this->getValueIf($underline, 'underline '); $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); } diff --git a/src/PhpWord/Writer/HTML/Style/Paragraph.php b/src/PhpWord/Writer/HTML/Style/Paragraph.php index e264ead0..af551dc5 100644 --- a/src/PhpWord/Writer/HTML/Style/Paragraph.php +++ b/src/PhpWord/Writer/HTML/Style/Paragraph.php @@ -80,6 +80,9 @@ class Paragraph extends AbstractStyle $after = $spacing->getAfter(); $css['margin-top'] = $this->getValueIf(!is_null($before), ($before / 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);