PHPMD fixes and remove Style\Tabs (not needed)
This commit is contained in:
parent
f829559f65
commit
0060e4316c
|
|
@ -72,6 +72,7 @@ This release marked heavy refactorings on internal code structure with the creat
|
||||||
- General: Rename `Footnote` to `Footnotes` to reflect the nature of collection - @ivanlanin
|
- General: Rename `Footnote` to `Footnotes` to reflect the nature of collection - @ivanlanin
|
||||||
- General: Add some unit tests for Shared & Element (100%!) - @Progi1984
|
- General: Add some unit tests for Shared & Element (100%!) - @Progi1984
|
||||||
- Test: Add some samples and tests for image wrapping style - @brunocasado GH-59
|
- Test: Add some samples and tests for image wrapping style - @brunocasado GH-59
|
||||||
|
- Refactor: Remove Style\Tabs
|
||||||
|
|
||||||
## 0.9.1 - 27 Mar 2014
|
## 0.9.1 - 27 Mar 2014
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="PHPPowerPoint mess detector ruleset"
|
||||||
|
xmlns="http://pmd.sf.net/ruleset/1.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||||
|
xsi:noNamespaceSchemaLocation=" http://pmd.sf.net/ruleset_xml_schema.xsd">
|
||||||
|
<description>PHPPowerPoint ruleset</description>
|
||||||
|
<rule ref="rulesets/unusedcode.xml" />
|
||||||
|
<rule ref="rulesets/design.xml" />
|
||||||
|
<rule ref="rulesets/naming.xml/LongVariable">
|
||||||
|
<properties>
|
||||||
|
<property name="maximum" value="30" />
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
<rule ref="rulesets/naming.xml/ShortVariable" />
|
||||||
|
<rule ref="rulesets/naming.xml/ShortMethodName" />
|
||||||
|
<rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass" />
|
||||||
|
<rule ref="rulesets/naming.xml/ConstantNamingConventions" />
|
||||||
|
</ruleset>
|
||||||
|
|
@ -73,8 +73,8 @@ class Table extends AbstractElement
|
||||||
*/
|
*/
|
||||||
public function addCell($width = null, $style = null)
|
public function addCell($width = null, $style = null)
|
||||||
{
|
{
|
||||||
$i = count($this->rows) - 1;
|
$index = count($this->rows) - 1;
|
||||||
$cell = $this->rows[$i]->addCell($width, $style);
|
$cell = $this->rows[$index]->addCell($width, $style);
|
||||||
return $cell;
|
return $cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ class Media
|
||||||
$mediaCount = 0;
|
$mediaCount = 0;
|
||||||
|
|
||||||
if (array_key_exists($container, self::$elements)) {
|
if (array_key_exists($container, self::$elements)) {
|
||||||
foreach (self::$elements[$container] as $mediaKey => $mediaData) {
|
foreach (self::$elements[$container] as $mediaData) {
|
||||||
if (!is_null($mediaType)) {
|
if (!is_null($mediaType)) {
|
||||||
if ($mediaType == $mediaData['type']) {
|
if ($mediaType == $mediaData['type']) {
|
||||||
$mediaCount++;
|
$mediaCount++;
|
||||||
|
|
|
||||||
|
|
@ -229,12 +229,12 @@ class Cell extends AbstractStyle
|
||||||
*/
|
*/
|
||||||
public function getBorderSize()
|
public function getBorderSize()
|
||||||
{
|
{
|
||||||
$t = $this->getBorderTopSize();
|
$top = $this->getBorderTopSize();
|
||||||
$l = $this->getBorderLeftSize();
|
$left = $this->getBorderLeftSize();
|
||||||
$r = $this->getBorderRightSize();
|
$right = $this->getBorderRightSize();
|
||||||
$b = $this->getBorderBottomSize();
|
$bottom = $this->getBorderBottomSize();
|
||||||
|
|
||||||
return array($t, $l, $r, $b);
|
return array($top, $left, $right, $bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -255,12 +255,12 @@ class Cell extends AbstractStyle
|
||||||
*/
|
*/
|
||||||
public function getBorderColor()
|
public function getBorderColor()
|
||||||
{
|
{
|
||||||
$t = $this->getBorderTopColor();
|
$top = $this->getBorderTopColor();
|
||||||
$l = $this->getBorderLeftColor();
|
$left = $this->getBorderLeftColor();
|
||||||
$r = $this->getBorderRightColor();
|
$right = $this->getBorderRightColor();
|
||||||
$b = $this->getBorderBottomColor();
|
$bottom = $this->getBorderBottomColor();
|
||||||
|
|
||||||
return array($t, $l, $r, $b);
|
return array($top, $left, $right, $bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,9 @@ class Paragraph extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Set of Custom Tab Stops
|
* Set of Custom Tab Stops
|
||||||
*
|
*
|
||||||
* @var array
|
* @var \PhpOffice\PhpWord\Style\Tab[]
|
||||||
*/
|
*/
|
||||||
private $tabs;
|
private $tabs = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indent by how much
|
* Indent by how much
|
||||||
|
|
@ -172,7 +172,7 @@ class Paragraph extends AbstractStyle
|
||||||
* Set Paragraph Alignment
|
* Set Paragraph Alignment
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setAlign($pValue = null)
|
public function setAlign($pValue = null)
|
||||||
{
|
{
|
||||||
|
|
@ -198,7 +198,7 @@ class Paragraph extends AbstractStyle
|
||||||
* Set Space before Paragraph
|
* Set Space before Paragraph
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setSpaceBefore($pValue = null)
|
public function setSpaceBefore($pValue = null)
|
||||||
{
|
{
|
||||||
|
|
@ -220,7 +220,7 @@ class Paragraph extends AbstractStyle
|
||||||
* Set Space after Paragraph
|
* Set Space after Paragraph
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setSpaceAfter($pValue = null)
|
public function setSpaceAfter($pValue = null)
|
||||||
{
|
{
|
||||||
|
|
@ -242,7 +242,7 @@ class Paragraph extends AbstractStyle
|
||||||
* Set Spacing between breaks
|
* Set Spacing between breaks
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setSpacing($pValue = null)
|
public function setSpacing($pValue = null)
|
||||||
{
|
{
|
||||||
|
|
@ -264,7 +264,7 @@ class Paragraph extends AbstractStyle
|
||||||
* Set indentation
|
* Set indentation
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setIndent($pValue = null)
|
public function setIndent($pValue = null)
|
||||||
{
|
{
|
||||||
|
|
@ -286,7 +286,7 @@ class Paragraph extends AbstractStyle
|
||||||
* Set hanging
|
* Set hanging
|
||||||
*
|
*
|
||||||
* @param int $pValue
|
* @param int $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setHanging($pValue = null)
|
public function setHanging($pValue = null)
|
||||||
{
|
{
|
||||||
|
|
@ -297,7 +297,7 @@ class Paragraph extends AbstractStyle
|
||||||
/**
|
/**
|
||||||
* Get tabs
|
* Get tabs
|
||||||
*
|
*
|
||||||
* @return \PhpOffice\PhpWord\Style\Tabs
|
* @return \PhpOffice\PhpWord\Style\Tab[]
|
||||||
*/
|
*/
|
||||||
public function getTabs()
|
public function getTabs()
|
||||||
{
|
{
|
||||||
|
|
@ -308,13 +308,14 @@ class Paragraph extends AbstractStyle
|
||||||
* Set tabs
|
* Set tabs
|
||||||
*
|
*
|
||||||
* @param array $pValue
|
* @param array $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setTabs($pValue = null)
|
public function setTabs($pValue = null)
|
||||||
{
|
{
|
||||||
if (is_array($pValue)) {
|
if (is_array($pValue)) {
|
||||||
$this->tabs = new Tabs($pValue);
|
$this->tabs = $pValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -332,7 +333,7 @@ class Paragraph extends AbstractStyle
|
||||||
* Set parent style ID
|
* Set parent style ID
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setBasedOn($pValue = 'Normal')
|
public function setBasedOn($pValue = 'Normal')
|
||||||
{
|
{
|
||||||
|
|
@ -354,7 +355,7 @@ class Paragraph extends AbstractStyle
|
||||||
* Set style for next paragraph
|
* Set style for next paragraph
|
||||||
*
|
*
|
||||||
* @param string $pValue
|
* @param string $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setNext($pValue = null)
|
public function setNext($pValue = null)
|
||||||
{
|
{
|
||||||
|
|
@ -376,7 +377,7 @@ class Paragraph extends AbstractStyle
|
||||||
* Set keep paragraph with next paragraph setting
|
* Set keep paragraph with next paragraph setting
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setWidowControl($pValue = true)
|
public function setWidowControl($pValue = true)
|
||||||
{
|
{
|
||||||
|
|
@ -401,7 +402,7 @@ class Paragraph extends AbstractStyle
|
||||||
* Set keep paragraph with next paragraph setting
|
* Set keep paragraph with next paragraph setting
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setKeepNext($pValue = false)
|
public function setKeepNext($pValue = false)
|
||||||
{
|
{
|
||||||
|
|
@ -426,7 +427,7 @@ class Paragraph extends AbstractStyle
|
||||||
* Set keep all lines on one page setting
|
* Set keep all lines on one page setting
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setKeepLines($pValue = false)
|
public function setKeepLines($pValue = false)
|
||||||
{
|
{
|
||||||
|
|
@ -451,7 +452,7 @@ class Paragraph extends AbstractStyle
|
||||||
* Set start paragraph on next page setting
|
* Set start paragraph on next page setting
|
||||||
*
|
*
|
||||||
* @param bool $pValue
|
* @param bool $pValue
|
||||||
* @return \PhpOffice\PhpWord\Style\Paragraph
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setPageBreakBefore($pValue = false)
|
public function setPageBreakBefore($pValue = false)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -390,12 +390,12 @@ class Section extends AbstractStyle
|
||||||
*/
|
*/
|
||||||
public function getBorderSize()
|
public function getBorderSize()
|
||||||
{
|
{
|
||||||
$t = $this->getBorderTopSize();
|
$top = $this->getBorderTopSize();
|
||||||
$l = $this->getBorderLeftSize();
|
$left = $this->getBorderLeftSize();
|
||||||
$r = $this->getBorderRightSize();
|
$right = $this->getBorderRightSize();
|
||||||
$b = $this->getBorderBottomSize();
|
$bottom = $this->getBorderBottomSize();
|
||||||
|
|
||||||
return array($t, $l, $r, $b);
|
return array($top, $left, $right, $bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -418,12 +418,12 @@ class Section extends AbstractStyle
|
||||||
*/
|
*/
|
||||||
public function getBorderColor()
|
public function getBorderColor()
|
||||||
{
|
{
|
||||||
$t = $this->getBorderTopColor();
|
$top = $this->getBorderTopColor();
|
||||||
$l = $this->getBorderLeftColor();
|
$left = $this->getBorderLeftColor();
|
||||||
$r = $this->getBorderRightColor();
|
$right = $this->getBorderRightColor();
|
||||||
$b = $this->getBorderBottomColor();
|
$bottom = $this->getBorderBottomColor();
|
||||||
|
|
||||||
return array($t, $l, $r, $b);
|
return array($top, $left, $right, $bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -90,21 +90,33 @@ class Tab extends AbstractStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the XML DOM for the instance of Tab.
|
* Get stop type
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function toXml(XMLWriter &$xmlWriter = null)
|
public function getStopType()
|
||||||
{
|
{
|
||||||
if (isset($xmlWriter)) {
|
return $this->val;
|
||||||
$xmlWriter->startElement("w:tab");
|
}
|
||||||
$xmlWriter->writeAttribute("w:val", $this->val);
|
|
||||||
if (!is_null($this->leader)) {
|
/**
|
||||||
$xmlWriter->writeAttribute("w:leader", $this->leader);
|
* Get leader
|
||||||
}
|
*
|
||||||
$xmlWriter->writeAttribute("w:pos", $this->position);
|
* @return string
|
||||||
$xmlWriter->endElement();
|
*/
|
||||||
}
|
public function getLeader()
|
||||||
|
{
|
||||||
|
return $this->leader;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get position
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function getPosition()
|
||||||
|
{
|
||||||
|
return $this->position;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -247,14 +247,14 @@ class Table extends AbstractStyle
|
||||||
*/
|
*/
|
||||||
public function getBorderSize()
|
public function getBorderSize()
|
||||||
{
|
{
|
||||||
$t = $this->getBorderTopSize();
|
$top = $this->getBorderTopSize();
|
||||||
$l = $this->getBorderLeftSize();
|
$left = $this->getBorderLeftSize();
|
||||||
$r = $this->getBorderRightSize();
|
$right = $this->getBorderRightSize();
|
||||||
$b = $this->getBorderBottomSize();
|
$bottom = $this->getBorderBottomSize();
|
||||||
$h = $this->getBorderInsideHSize();
|
$insideH = $this->getBorderInsideHSize();
|
||||||
$v = $this->getBorderInsideVSize();
|
$insideV = $this->getBorderInsideVSize();
|
||||||
|
|
||||||
return array($t, $l, $r, $b, $h, $v);
|
return array($top, $left, $right, $bottom, $insideH, $insideV);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -278,14 +278,14 @@ class Table extends AbstractStyle
|
||||||
*/
|
*/
|
||||||
public function getBorderColor()
|
public function getBorderColor()
|
||||||
{
|
{
|
||||||
$t = $this->getBorderTopColor();
|
$top = $this->getBorderTopColor();
|
||||||
$l = $this->getBorderLeftColor();
|
$left = $this->getBorderLeftColor();
|
||||||
$r = $this->getBorderRightColor();
|
$right = $this->getBorderRightColor();
|
||||||
$b = $this->getBorderBottomColor();
|
$bottom = $this->getBorderBottomColor();
|
||||||
$h = $this->getBorderInsideHColor();
|
$insideH = $this->getBorderInsideHColor();
|
||||||
$v = $this->getBorderInsideVColor();
|
$insideV = $this->getBorderInsideVColor();
|
||||||
|
|
||||||
return array($t, $l, $r, $b, $h, $v);
|
return array($top, $left, $right, $bottom, $insideH, $insideV);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* PHPWord
|
|
||||||
*
|
|
||||||
* @link https://github.com/PHPOffice/PHPWord
|
|
||||||
* @copyright 2014 PHPWord
|
|
||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Style;
|
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tabs style
|
|
||||||
*/
|
|
||||||
class Tabs extends AbstractStyle
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Tabs
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $tabs;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create new tab collection style
|
|
||||||
*
|
|
||||||
* @param array $tabs
|
|
||||||
*/
|
|
||||||
public function __construct(array $tabs)
|
|
||||||
{
|
|
||||||
$this->tabs = $tabs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return XML
|
|
||||||
*
|
|
||||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter
|
|
||||||
*/
|
|
||||||
public function toXml(XMLWriter &$xmlWriter = null)
|
|
||||||
{
|
|
||||||
if (isset($xmlWriter)) {
|
|
||||||
$xmlWriter->startElement("w:tabs");
|
|
||||||
foreach ($this->tabs as &$tab) {
|
|
||||||
$tab->toXml($xmlWriter);
|
|
||||||
}
|
|
||||||
$xmlWriter->endElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -75,16 +75,16 @@ class Template
|
||||||
$this->zipClass->open($this->tempFileName);
|
$this->zipClass->open($this->tempFileName);
|
||||||
|
|
||||||
// Find and load headers and footers
|
// Find and load headers and footers
|
||||||
$i = 1;
|
$index = 1;
|
||||||
while ($this->zipClass->locateName($this->getHeaderName($i)) !== false) {
|
while ($this->zipClass->locateName($this->getHeaderName($index)) !== false) {
|
||||||
$this->headerXMLs[$i] = $this->zipClass->getFromName($this->getHeaderName($i));
|
$this->headerXMLs[$index] = $this->zipClass->getFromName($this->getHeaderName($index));
|
||||||
$i++;
|
$index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = 1;
|
$index = 1;
|
||||||
while ($this->zipClass->locateName($this->getFooterName($i)) !== false) {
|
while ($this->zipClass->locateName($this->getFooterName($index)) !== false) {
|
||||||
$this->footerXMLs[$i] = $this->zipClass->getFromName($this->getFooterName($i));
|
$this->footerXMLs[$index] = $this->zipClass->getFromName($this->getFooterName($index));
|
||||||
$i++;
|
$index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->documentXML = $this->zipClass->getFromName('word/document.xml');
|
$this->documentXML = $this->zipClass->getFromName('word/document.xml');
|
||||||
|
|
|
||||||
|
|
@ -251,9 +251,9 @@ abstract class AbstractWriter implements WriterInterface
|
||||||
|
|
||||||
// Retrieve OVERWRITE and CREATE constants from the instantiated zip class
|
// Retrieve OVERWRITE and CREATE constants from the instantiated zip class
|
||||||
// This method of accessing constant values from a dynamic class should work with all appropriate versions of PHP
|
// This method of accessing constant values from a dynamic class should work with all appropriate versions of PHP
|
||||||
$ro = new \ReflectionObject($objZip);
|
$reflection = new \ReflectionObject($objZip);
|
||||||
$zipOverWrite = $ro->getConstant('OVERWRITE');
|
$zipOverWrite = $reflection->getConstant('OVERWRITE');
|
||||||
$zipCreate = $ro->getConstant('CREATE');
|
$zipCreate = $reflection->getConstant('CREATE');
|
||||||
|
|
||||||
// Remove any existing file
|
// Remove any existing file
|
||||||
if (file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
|
|
|
||||||
|
|
@ -69,9 +69,13 @@ class HTML extends AbstractWriter implements WriterInterface
|
||||||
{
|
{
|
||||||
if (!is_null($this->getPhpWord())) {
|
if (!is_null($this->getPhpWord())) {
|
||||||
$this->setTempDir(sys_get_temp_dir() . '/PHPWordWriter/');
|
$this->setTempDir(sys_get_temp_dir() . '/PHPWordWriter/');
|
||||||
$hFile = fopen($filename, 'w') or die("can't open file");
|
$hFile = fopen($filename, 'w');
|
||||||
fwrite($hFile, $this->writeDocument());
|
if ($hFile !== false) {
|
||||||
fclose($hFile);
|
fwrite($hFile, $this->writeDocument());
|
||||||
|
fclose($hFile);
|
||||||
|
} else {
|
||||||
|
throw new Exception("Can't open file");
|
||||||
|
}
|
||||||
$this->clearTempDir();
|
$this->clearTempDir();
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("No PHPWord assigned.");
|
throw new Exception("No PHPWord assigned.");
|
||||||
|
|
@ -739,9 +743,9 @@ class HTML extends AbstractWriter implements WriterInterface
|
||||||
$imageBinary = ob_get_contents();
|
$imageBinary = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
} else {
|
} else {
|
||||||
if ($fp = fopen($actualSource, 'rb', false)) {
|
if ($fileHandle = fopen($actualSource, 'rb', false)) {
|
||||||
$imageBinary = fread($fp, filesize($actualSource));
|
$imageBinary = fread($fileHandle, filesize($actualSource));
|
||||||
fclose($fp);
|
fclose($fileHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!is_null($imageBinary)) {
|
if (!is_null($imageBinary)) {
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class Base extends AbstractWriterPart
|
||||||
$styles = Style::getStyles();
|
$styles = Style::getStyles();
|
||||||
$numFonts = 0;
|
$numFonts = 0;
|
||||||
if (count($styles) > 0) {
|
if (count($styles) > 0) {
|
||||||
foreach ($styles as $styleName => $style) {
|
foreach ($styles as $style) {
|
||||||
// Font
|
// Font
|
||||||
if ($style instanceof Font) {
|
if ($style instanceof Font) {
|
||||||
$numFonts++;
|
$numFonts++;
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ class Content extends Base
|
||||||
|
|
||||||
if ($SfIsObject) {
|
if ($SfIsObject) {
|
||||||
// Don't never be the case, because I browse all sections for cleaning all styles not declared
|
// Don't never be the case, because I browse all sections for cleaning all styles not declared
|
||||||
die('PhpWord : $SfIsObject wouldn\'t be an object');
|
throw new Exception('PhpWord : $SfIsObject wouldn\'t be an object');
|
||||||
} else {
|
} else {
|
||||||
if (!$withoutP) {
|
if (!$withoutP) {
|
||||||
$xmlWriter->startElement('text:p'); // text:p
|
$xmlWriter->startElement('text:p'); // text:p
|
||||||
|
|
@ -457,8 +457,8 @@ class Content extends Base
|
||||||
}
|
}
|
||||||
|
|
||||||
// Images
|
// Images
|
||||||
$imageData = Media::getElements('section');
|
$images = Media::getElements('section');
|
||||||
foreach ($imageData as $imageId => $image) {
|
foreach ($images as $image) {
|
||||||
if ($image['type'] == 'image') {
|
if ($image['type'] == 'image') {
|
||||||
$xmlWriter->startElement('style:style');
|
$xmlWriter->startElement('style:style');
|
||||||
$xmlWriter->writeAttribute('style:name', 'fr' . $image['rID']);
|
$xmlWriter->writeAttribute('style:name', 'fr' . $image['rID']);
|
||||||
|
|
|
||||||
|
|
@ -45,13 +45,6 @@ abstract class AbstractRenderer extends \PhpOffice\PhpWord\Writer\HTML
|
||||||
*/
|
*/
|
||||||
protected $orientation = null;
|
protected $orientation = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Temporary storage for Save Array Return type
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $saveArrayReturnType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paper Sizes xRef List
|
* Paper Sizes xRef List
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
namespace PhpOffice\PhpWord\Writer;
|
namespace PhpOffice\PhpWord\Writer;
|
||||||
|
|
||||||
|
use PhpOffice\PhpWord\PhpWord;
|
||||||
|
use PhpOffice\PhpWord\TOC;
|
||||||
use PhpOffice\PhpWord\Element\Image;
|
use PhpOffice\PhpWord\Element\Image;
|
||||||
use PhpOffice\PhpWord\Element\Link;
|
use PhpOffice\PhpWord\Element\Link;
|
||||||
use PhpOffice\PhpWord\Element\ListItem;
|
use PhpOffice\PhpWord\Element\ListItem;
|
||||||
|
|
@ -20,11 +22,9 @@ use PhpOffice\PhpWord\Element\TextBreak;
|
||||||
use PhpOffice\PhpWord\Element\TextRun;
|
use PhpOffice\PhpWord\Element\TextRun;
|
||||||
use PhpOffice\PhpWord\Element\Title;
|
use PhpOffice\PhpWord\Element\Title;
|
||||||
use PhpOffice\PhpWord\Exception\Exception;
|
use PhpOffice\PhpWord\Exception\Exception;
|
||||||
use PhpOffice\PhpWord\PhpWord;
|
|
||||||
use PhpOffice\PhpWord\Shared\Drawing;
|
use PhpOffice\PhpWord\Shared\Drawing;
|
||||||
use PhpOffice\PhpWord\Style\Font;
|
|
||||||
use PhpOffice\PhpWord\Style;
|
use PhpOffice\PhpWord\Style;
|
||||||
use PhpOffice\PhpWord\TOC;
|
use PhpOffice\PhpWord\Style\Font;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RTF writer
|
* RTF writer
|
||||||
|
|
@ -75,10 +75,13 @@ class RTF extends AbstractWriter implements WriterInterface
|
||||||
if (!is_null($this->phpWord)) {
|
if (!is_null($this->phpWord)) {
|
||||||
$pFilename = $this->getTempFile($pFilename);
|
$pFilename = $this->getTempFile($pFilename);
|
||||||
|
|
||||||
$hFile = fopen($pFilename, 'w') or die("can't open file");
|
$hFile = fopen($pFilename, 'w');
|
||||||
fwrite($hFile, $this->getData());
|
if ($hFile !== false) {
|
||||||
fclose($hFile);
|
fwrite($hFile, $this->getData());
|
||||||
|
fclose($hFile);
|
||||||
|
} else {
|
||||||
|
throw new Exception("Can't open file");
|
||||||
|
}
|
||||||
$this->cleanupTempFile();
|
$this->cleanupTempFile();
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("PhpWord object unassigned.");
|
throw new Exception("PhpWord object unassigned.");
|
||||||
|
|
@ -160,7 +163,7 @@ class RTF extends AbstractWriter implements WriterInterface
|
||||||
// Browse styles
|
// Browse styles
|
||||||
$styles = Style::getStyles();
|
$styles = Style::getStyles();
|
||||||
if (count($styles) > 0) {
|
if (count($styles) > 0) {
|
||||||
foreach ($styles as $styleName => $style) {
|
foreach ($styles as $style) {
|
||||||
// Font
|
// Font
|
||||||
if ($style instanceof Font) {
|
if ($style instanceof Font) {
|
||||||
if (in_array($style->getName(), $arrFonts) == false) {
|
if (in_array($style->getName(), $arrFonts) == false) {
|
||||||
|
|
@ -212,7 +215,7 @@ class RTF extends AbstractWriter implements WriterInterface
|
||||||
// Browse styles
|
// Browse styles
|
||||||
$styles = Style::getStyles();
|
$styles = Style::getStyles();
|
||||||
if (count($styles) > 0) {
|
if (count($styles) > 0) {
|
||||||
foreach ($styles as $styleName => $style) {
|
foreach ($styles as $style) {
|
||||||
// Font
|
// Font
|
||||||
if ($style instanceof Font) {
|
if ($style instanceof Font) {
|
||||||
$color = $style->getColor();
|
$color = $style->getColor();
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
||||||
$writeFunction = $elmType == 'header' ? 'writeHeader' : 'writeFooter';
|
$writeFunction = $elmType == 'header' ? 'writeHeader' : 'writeFooter';
|
||||||
$elmCount = ($section->getSectionId() - 1) * 3;
|
$elmCount = ($section->getSectionId() - 1) * 3;
|
||||||
$elmObjects = $section->$getFunction();
|
$elmObjects = $section->$getFunction();
|
||||||
foreach ($elmObjects as $index => &$elmObject) {
|
foreach ($elmObjects as &$elmObject) {
|
||||||
$elmCount++;
|
$elmCount++;
|
||||||
$elmObject->setRelationId(++$rId);
|
$elmObject->setRelationId(++$rId);
|
||||||
$elmFile = "{$elmType}{$elmCount}.xml";
|
$elmFile = "{$elmType}{$elmCount}.xml";
|
||||||
|
|
|
||||||
|
|
@ -814,8 +814,18 @@ class Base extends AbstractWriterPart
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tabs
|
// Tabs
|
||||||
if (!is_null($tabs)) {
|
if (!empty($tabs)) {
|
||||||
$tabs->toXml($xmlWriter);
|
$xmlWriter->startElement("w:tabs");
|
||||||
|
foreach ($tabs as $tab) {
|
||||||
|
$xmlWriter->startElement("w:tab");
|
||||||
|
$xmlWriter->writeAttribute("w:val", $tab->getStopType());
|
||||||
|
if (!is_null($tab->getLeader())) {
|
||||||
|
$xmlWriter->writeAttribute("w:leader", $tab->getLeader());
|
||||||
|
}
|
||||||
|
$xmlWriter->writeAttribute("w:pos", $tab->getPosition());
|
||||||
|
$xmlWriter->endElement();
|
||||||
|
}
|
||||||
|
$xmlWriter->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$withoutPPR) {
|
if (!$withoutPPR) {
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,9 @@ class Rels extends AbstractWriterPart
|
||||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param null|array $xmlRels
|
* @param null|array $xmlRels
|
||||||
* @param null|array $mediaRels
|
* @param null|array $mediaRels
|
||||||
* @param integer $id
|
* @param integer $relId
|
||||||
*/
|
*/
|
||||||
private function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = null, $id = 1)
|
private function writeRels(XMLWriter $xmlWriter, $xmlRels = null, $mediaRels = null, $relId = 1)
|
||||||
{
|
{
|
||||||
$xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
|
$xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||||
$xmlWriter->startElement('Relationships');
|
$xmlWriter->startElement('Relationships');
|
||||||
|
|
@ -91,7 +91,7 @@ class Rels extends AbstractWriterPart
|
||||||
// XML files relationships
|
// XML files relationships
|
||||||
if (is_array($xmlRels)) {
|
if (is_array($xmlRels)) {
|
||||||
foreach ($xmlRels as $target => $type) {
|
foreach ($xmlRels as $target => $type) {
|
||||||
$this->writeRel($xmlWriter, $id++, $type, $target);
|
$this->writeRel($xmlWriter, $relId++, $type, $target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,7 +105,7 @@ class Rels extends AbstractWriterPart
|
||||||
$target = array_key_exists($mediaType, $targetPaths) ? $targetPaths[$mediaType] : '';
|
$target = array_key_exists($mediaType, $targetPaths) ? $targetPaths[$mediaType] : '';
|
||||||
$target .= $mediaRel['target'];
|
$target .= $mediaRel['target'];
|
||||||
$targetMode = ($type == 'hyperlink') ? 'External' : '';
|
$targetMode = ($type == 'hyperlink') ? 'External' : '';
|
||||||
$this->writeRel($xmlWriter, $id++, "officeDocument/2006/relationships/{$type}", $target, $targetMode);
|
$this->writeRel($xmlWriter, $relId++, "officeDocument/2006/relationships/{$type}", $target, $targetMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,19 +119,19 @@ class Rels extends AbstractWriterPart
|
||||||
* <Relationship Id="rId..." Type="http://..." Target="....xml" TargetMode="..." />
|
* <Relationship Id="rId..." Type="http://..." Target="....xml" TargetMode="..." />
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||||
* @param int $id Relationship ID
|
* @param int $relId Relationship ID
|
||||||
* @param string $type Relationship type
|
* @param string $type Relationship type
|
||||||
* @param string $target Relationship target
|
* @param string $target Relationship target
|
||||||
* @param string $targetMode Relationship target mode
|
* @param string $targetMode Relationship target mode
|
||||||
*/
|
*/
|
||||||
private function writeRel(XMLWriter $xmlWriter, $id, $type, $target, $targetMode = '')
|
private function writeRel(XMLWriter $xmlWriter, $relId, $type, $target, $targetMode = '')
|
||||||
{
|
{
|
||||||
if ($type != '' && $target != '') {
|
if ($type != '' && $target != '') {
|
||||||
if (strpos($id, 'rId') === false) {
|
if (strpos($relId, 'rId') === false) {
|
||||||
$id = 'rId' . $id;
|
$relId = 'rId' . $relId;
|
||||||
}
|
}
|
||||||
$xmlWriter->startElement('Relationship');
|
$xmlWriter->startElement('Relationship');
|
||||||
$xmlWriter->writeAttribute('Id', $id);
|
$xmlWriter->writeAttribute('Id', $relId);
|
||||||
$xmlWriter->writeAttribute('Type', self::RELS_BASE . $type);
|
$xmlWriter->writeAttribute('Type', self::RELS_BASE . $type);
|
||||||
$xmlWriter->writeAttribute('Target', $target);
|
$xmlWriter->writeAttribute('Target', $target);
|
||||||
if ($targetMode != '') {
|
if ($targetMode != '') {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
|
||||||
$object = new Paragraph();
|
$object = new Paragraph();
|
||||||
|
|
||||||
$attributes = array(
|
$attributes = array(
|
||||||
'tabs' => null,
|
|
||||||
'widowControl' => true,
|
'widowControl' => true,
|
||||||
'keepNext' => false,
|
'keepNext' => false,
|
||||||
'keepLines' => false,
|
'keepLines' => false,
|
||||||
|
|
@ -96,7 +95,7 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$object = new Paragraph();
|
$object = new Paragraph();
|
||||||
$object->setTabs(array(new Tab('left', 1550), new Tab('right', 5300)));
|
$object->setTabs(array(new Tab('left', 1550), new Tab('right', 5300)));
|
||||||
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Tabs', $object->getTabs());
|
$this->assertEquals(2, count($object->getTabs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue