Refactor: Create writers' `Part` folders and remove all static parts
This commit is contained in:
parent
23db6fa220
commit
4a3400c5b2
|
|
@ -277,7 +277,7 @@ abstract class AbstractContainer extends AbstractElement
|
|||
if (strlen($ext) == 4 && strtolower(substr($ext, -1)) == 'x') {
|
||||
$ext = substr($ext, 0, -1);
|
||||
}
|
||||
$icon = realpath(__DIR__ . "/../_staticDocParts/_{$ext}.png");
|
||||
$icon = realpath(__DIR__ . "/../resources/{$ext}.png");
|
||||
$rId = Media::addElement($elementDocPart, 'object', $src);
|
||||
$object->setRelationId($rId);
|
||||
$rIdimg = Media::addElement($elementDocPart, 'image', $icon, new Image($icon));
|
||||
|
|
|
|||
|
|
@ -9,59 +9,42 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Reader\ODText;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Shared\XMLReader;
|
||||
|
||||
/**
|
||||
* Abstract part reader
|
||||
*/
|
||||
abstract class AbstractPart
|
||||
abstract class AbstractPart extends \PhpOffice\PhpWord\Reader\Word2007\AbstractPart
|
||||
{
|
||||
/**
|
||||
* Document file
|
||||
* Read w:r (override)
|
||||
*
|
||||
* @var string
|
||||
* @param mixed $parent
|
||||
* @param string $docPart
|
||||
* @param mixed $pStyle
|
||||
*/
|
||||
protected $docFile;
|
||||
|
||||
/**
|
||||
* XML file
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $xmlFile;
|
||||
|
||||
/**
|
||||
* Part relationships
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rels = array();
|
||||
|
||||
/**
|
||||
* Read part
|
||||
*/
|
||||
abstract public function read(PhpWord &$phpWord);
|
||||
|
||||
/**
|
||||
* Create new instance
|
||||
*
|
||||
* @param string $docFile
|
||||
* @param string $xmlFile
|
||||
*/
|
||||
public function __construct($docFile, $xmlFile)
|
||||
protected function readRun(XMLReader $xmlReader, \DOMElement $domNode, &$parent, $docPart, $pStyle = null)
|
||||
{
|
||||
$this->docFile = $docFile;
|
||||
$this->xmlFile = $xmlFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set relationships
|
||||
*
|
||||
* @param array $value
|
||||
* Read w:pPr (override)
|
||||
*/
|
||||
public function setRels($value)
|
||||
protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Read w:rPr (override)
|
||||
*/
|
||||
protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Read w:tblPr (override)
|
||||
*/
|
||||
protected function readTableStyle(XMLReader $xmlReader, \DOMElement $domNode)
|
||||
{
|
||||
$this->rels = $value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,6 @@ namespace PhpOffice\PhpWord\Writer;
|
|||
use PhpOffice\PhpWord\Media;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
use PhpOffice\PhpWord\Writer\ODText\Content;
|
||||
use PhpOffice\PhpWord\Writer\ODText\Manifest;
|
||||
use PhpOffice\PhpWord\Writer\ODText\Meta;
|
||||
use PhpOffice\PhpWord\Writer\ODText\Mimetype;
|
||||
use PhpOffice\PhpWord\Writer\ODText\Styles;
|
||||
|
||||
/**
|
||||
* ODText writer
|
||||
|
|
@ -35,14 +30,16 @@ class ODText extends AbstractWriter implements WriterInterface
|
|||
// Assign PhpWord
|
||||
$this->setPhpWord($phpWord);
|
||||
|
||||
// Set writer parts
|
||||
$this->writerParts['content'] = new Content();
|
||||
$this->writerParts['manifest'] = new Manifest();
|
||||
$this->writerParts['meta'] = new Meta();
|
||||
$this->writerParts['mimetype'] = new Mimetype();
|
||||
$this->writerParts['styles'] = new Styles();
|
||||
foreach ($this->writerParts as $writer) {
|
||||
$writer->setParentWriter($this);
|
||||
// Create parts
|
||||
$parts = array('Content', 'Manifest', 'Meta', 'Mimetype', 'Styles');
|
||||
foreach ($parts as $part) {
|
||||
$partName = strtolower($part);
|
||||
$partClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Part\\' . $part;
|
||||
if (class_exists($partClass)) {
|
||||
$partObject = new $partClass();
|
||||
$partObject->setParentWriter($this);
|
||||
$this->writerParts[$partName] = $partObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Set package paths
|
||||
|
|
|
|||
|
|
@ -1,17 +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\Writer\ODText;
|
||||
|
||||
/**
|
||||
* ODText writer part abstract
|
||||
*/
|
||||
abstract class AbstractWriterPart extends \PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart
|
||||
{
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
|||
|
||||
use PhpOffice\PhpWord\Element\AbstractElement;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Writer\ODText\AbstractWriterPart;
|
||||
use PhpOffice\PhpWord\Writer\ODText\Part\AbstractPart;
|
||||
|
||||
/**
|
||||
* Generic element writer
|
||||
|
|
@ -30,7 +30,7 @@ class Element
|
|||
/**
|
||||
* Parent writer
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Writer\ODText\AbstractWriterPart
|
||||
* @var \PhpOffice\PhpWord\Writer\ODText\AbstractPart
|
||||
*/
|
||||
protected $parentWriter;
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ class Element
|
|||
*
|
||||
* @param bool $withoutP
|
||||
*/
|
||||
public function __construct(XMLWriter $xmlWriter, AbstractWriterPart $parentWriter, AbstractElement $element, $withoutP = false)
|
||||
public function __construct(XMLWriter $xmlWriter, AbstractPart $parentWriter, AbstractElement $element, $withoutP = false)
|
||||
{
|
||||
$this->xmlWriter = $xmlWriter;
|
||||
$this->parentWriter = $parentWriter;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Text as TextElement;
|
||||
use PhpOffice\PhpWord\Element\Link as LinkElement;
|
||||
use PhpOffice\PhpWord\Writer\ODText\Element\Element as ElementWriter;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\ODText;
|
||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
|
|
@ -15,11 +15,9 @@ use PhpOffice\PhpWord\Style\Font;
|
|||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
|
||||
/**
|
||||
* ODT base part writer
|
||||
*
|
||||
* @since 0.10.0
|
||||
* ODText writer part abstract
|
||||
*/
|
||||
class Base extends AbstractWriterPart
|
||||
abstract class AbstractPart extends \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write common root attributes
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\ODText;
|
||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Media;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
|
|
@ -23,7 +23,7 @@ use PhpOffice\PhpWord\Writer\ODText\Element\Element as ElementWriter;
|
|||
/**
|
||||
* ODText content part writer
|
||||
*/
|
||||
class Content extends Base
|
||||
class Content extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write content file to XML format
|
||||
|
|
@ -7,14 +7,14 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\ODText;
|
||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Media;
|
||||
|
||||
/**
|
||||
* ODText manifest part writer
|
||||
*/
|
||||
class Manifest extends AbstractWriterPart
|
||||
class Manifest extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write Manifest file to XML format
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\ODText;
|
||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
|
|
@ -15,7 +15,7 @@ use PhpOffice\PhpWord\PhpWord;
|
|||
/**
|
||||
* ODText meta part writer
|
||||
*/
|
||||
class Meta extends AbstractWriterPart
|
||||
class Meta extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write Meta file to XML format
|
||||
|
|
@ -7,12 +7,12 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\ODText;
|
||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||
|
||||
/**
|
||||
* ODText mimetype part writer
|
||||
*/
|
||||
class Mimetype extends AbstractWriterPart
|
||||
class Mimetype extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write Mimetype to Text format
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\ODText;
|
||||
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
|
|
@ -16,7 +16,7 @@ use PhpOffice\PhpWord\Exception\Exception;
|
|||
/**
|
||||
* ODText styloes part writer
|
||||
*/
|
||||
class Styles extends Base
|
||||
class Styles extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write Styles file to XML format
|
||||
|
|
@ -13,17 +13,6 @@ use PhpOffice\PhpWord\PhpWord;
|
|||
use PhpOffice\PhpWord\Media;
|
||||
use PhpOffice\PhpWord\Element\Section;
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\ContentTypes;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\DocProps;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Document;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Footer;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Header;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Notes;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Numbering;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Rels;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Settings;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Styles;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\WebSettings;
|
||||
|
||||
/**
|
||||
* Word2007 writer
|
||||
|
|
@ -54,21 +43,18 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
|||
// Assign PhpWord
|
||||
$this->setPhpWord($phpWord);
|
||||
|
||||
// Set writer parts
|
||||
$this->writerParts['contenttypes'] = new ContentTypes();
|
||||
$this->writerParts['rels'] = new Rels();
|
||||
$this->writerParts['docprops'] = new DocProps();
|
||||
$this->writerParts['document'] = new Document();
|
||||
$this->writerParts['styles'] = new Styles();
|
||||
$this->writerParts['numbering'] = new Numbering();
|
||||
$this->writerParts['settings'] = new Settings();
|
||||
$this->writerParts['websettings'] = new WebSettings();
|
||||
$this->writerParts['header'] = new Header();
|
||||
$this->writerParts['footer'] = new Footer();
|
||||
$this->writerParts['footnotes'] = new Notes();
|
||||
$this->writerParts['endnotes'] = new Notes();
|
||||
foreach ($this->writerParts as $writer) {
|
||||
$writer->setParentWriter($this);
|
||||
// Create parts
|
||||
$parts = array('ContentTypes', 'Rels', 'DocProps', 'Document', 'Styles',
|
||||
'Numbering', 'Settings', 'WebSettings', 'Header', 'Footer', 'Footnotes',
|
||||
'Endnotes', 'FontTable', 'Theme');
|
||||
foreach ($parts as $part) {
|
||||
$partName = strtolower($part);
|
||||
$partClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Part\\' . $part;
|
||||
if (class_exists($partClass)) {
|
||||
$partObject = new $partClass();
|
||||
$partObject->setParentWriter($this);
|
||||
$this->writerParts[$partName] = $partObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Set package paths
|
||||
|
|
@ -117,7 +103,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
|||
$this->addNotes($objZip, $rId, 'footnote');
|
||||
$this->addNotes($objZip, $rId, 'endnote');
|
||||
|
||||
// Write dynamic files
|
||||
// Write parts
|
||||
$objZip->addFromString('[Content_Types].xml', $this->getWriterPart('contenttypes')->writeContentTypes($this->cTypes));
|
||||
$objZip->addFromString('_rels/.rels', $this->getWriterPart('rels')->writeMainRels());
|
||||
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('docprops')->writeDocPropsApp($this->phpWord));
|
||||
|
|
@ -128,10 +114,8 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
|||
$objZip->addFromString('word/numbering.xml', $this->getWriterPart('numbering')->writeNumbering());
|
||||
$objZip->addFromString('word/settings.xml', $this->getWriterPart('settings')->writeSettings());
|
||||
$objZip->addFromString('word/webSettings.xml', $this->getWriterPart('websettings')->writeWebSettings());
|
||||
|
||||
// Write static files
|
||||
$objZip->addFile(__DIR__ . '/../_staticDocParts/theme1.xml', 'word/theme/theme1.xml');
|
||||
$objZip->addFile(__DIR__ . '/../_staticDocParts/fontTable.xml', 'word/fontTable.xml');
|
||||
$objZip->addFromString('word/fontTable.xml', $this->getWriterPart('fonttable')->write());
|
||||
$objZip->addFromString('word/theme/theme1.xml', $this->getWriterPart('theme')->write());
|
||||
|
||||
// Close file
|
||||
if ($objZip->close() === false) {
|
||||
|
|
@ -215,7 +199,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
|||
$objZip->addFromString($relsFile, $this->getWriterPart('rels')->writeMediaRels($media));
|
||||
}
|
||||
$elements = $collection::getElements();
|
||||
$objZip->addFromString($xmlPath, $this->getWriterPart($notesTypes)->writeNotes($elements, $notesTypes));
|
||||
$objZip->addFromString($xmlPath, $this->getWriterPart($notesTypes)->write($elements));
|
||||
$this->cTypes['override']["/{$xmlPath}"] = $notesTypes;
|
||||
$this->docRels[] = array('target' => $xmlFile, 'type' => $notesTypes, 'rID' => ++$rId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,72 +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\Writer\Word2007;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Writer\WriterInterface;
|
||||
|
||||
/**
|
||||
* Word2007 writer part abstract class
|
||||
*/
|
||||
abstract class AbstractWriterPart
|
||||
{
|
||||
/**
|
||||
* Parent writer
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Writer\WriterInterface
|
||||
*/
|
||||
protected $parentWriter;
|
||||
|
||||
/**
|
||||
* Set parent writer
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Writer\WriterInterface $pWriter
|
||||
*/
|
||||
public function setParentWriter(WriterInterface $pWriter = null)
|
||||
{
|
||||
$this->parentWriter = $pWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent writer
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Writer\WriterInterface
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function getParentWriter()
|
||||
{
|
||||
if (!is_null($this->parentWriter)) {
|
||||
return $this->parentWriter;
|
||||
} else {
|
||||
throw new Exception("No parent WriterInterface assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get XML Writer
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Shared\XMLWriter
|
||||
*/
|
||||
protected function getXmlWriter()
|
||||
{
|
||||
$useDiskCaching = false;
|
||||
if (!is_null($this->parentWriter)) {
|
||||
if ($this->parentWriter->getUseDiskCaching()) {
|
||||
$useDiskCaching = true;
|
||||
}
|
||||
}
|
||||
if ($useDiskCaching) {
|
||||
return new XMLWriter(XMLWriter::STORAGE_DISK, $this->parentWriter->getDiskCachingDirectory());
|
||||
} else {
|
||||
return new XMLWriter(XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element;
|
|||
|
||||
use PhpOffice\PhpWord\Element\AbstractElement;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart;
|
||||
|
||||
/**
|
||||
* Generic element writer
|
||||
|
|
@ -30,7 +30,7 @@ class Element
|
|||
/**
|
||||
* Parent writer
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart
|
||||
* @var \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart
|
||||
*/
|
||||
protected $parentWriter;
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ class Element
|
|||
*
|
||||
* @param bool $withoutP
|
||||
*/
|
||||
public function __construct(XMLWriter $xmlWriter, AbstractWriterPart $parentWriter, AbstractElement $element, $withoutP = false)
|
||||
public function __construct(XMLWriter $xmlWriter, AbstractPart $parentWriter, AbstractElement $element, $withoutP = false)
|
||||
{
|
||||
$this->xmlWriter = $xmlWriter;
|
||||
$this->parentWriter = $parentWriter;
|
||||
|
|
|
|||
61
src/PhpWord/Writer/Word2007/Base.php → src/PhpWord/Writer/Word2007/Part/AbstractPart.php
Normal file → Executable file
61
src/PhpWord/Writer/Word2007/Base.php → src/PhpWord/Writer/Word2007/Part/AbstractPart.php
Normal file → Executable file
|
|
@ -7,7 +7,7 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Element\AbstractElement;
|
||||
|
|
@ -15,14 +15,65 @@ use PhpOffice\PhpWord\Element\TextBreak;
|
|||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Element\Element as ElementWriter;
|
||||
use PhpOffice\PhpWord\Writer\WriterInterface;
|
||||
|
||||
/**
|
||||
* Word2007 base part writer
|
||||
*
|
||||
* Write common parts of document.xml, headerx.xml, and footerx.xml
|
||||
* Word2007 writer part abstract class
|
||||
*/
|
||||
class Base extends AbstractWriterPart
|
||||
abstract class AbstractPart
|
||||
{
|
||||
/**
|
||||
* Parent writer
|
||||
*
|
||||
* @var \PhpOffice\PhpWord\Writer\WriterInterface
|
||||
*/
|
||||
protected $parentWriter;
|
||||
|
||||
/**
|
||||
* Set parent writer
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Writer\WriterInterface $pWriter
|
||||
*/
|
||||
public function setParentWriter(WriterInterface $pWriter = null)
|
||||
{
|
||||
$this->parentWriter = $pWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent writer
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Writer\WriterInterface
|
||||
* @throws \PhpOffice\PhpWord\Exception\Exception
|
||||
*/
|
||||
public function getParentWriter()
|
||||
{
|
||||
if (!is_null($this->parentWriter)) {
|
||||
return $this->parentWriter;
|
||||
} else {
|
||||
throw new Exception("No parent WriterInterface assigned.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get XML Writer
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Shared\XMLWriter
|
||||
*/
|
||||
protected function getXmlWriter()
|
||||
{
|
||||
$useDiskCaching = false;
|
||||
if (!is_null($this->parentWriter)) {
|
||||
if ($this->parentWriter->getUseDiskCaching()) {
|
||||
$useDiskCaching = true;
|
||||
}
|
||||
}
|
||||
if ($useDiskCaching) {
|
||||
return new XMLWriter(XMLWriter::STORAGE_DISK, $this->parentWriter->getDiskCachingDirectory());
|
||||
} else {
|
||||
return new XMLWriter(XMLWriter::STORAGE_MEMORY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write container elements
|
||||
*
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
|
|
@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter;
|
|||
/**
|
||||
* Word2007 contenttypes part writer
|
||||
*/
|
||||
class ContentTypes extends AbstractWriterPart
|
||||
class ContentTypes extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write [Content_Types].xml
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
|
|
@ -15,7 +15,7 @@ use PhpOffice\PhpWord\Exception\Exception;
|
|||
/**
|
||||
* Word2007 document properties part writer
|
||||
*/
|
||||
class DocProps extends AbstractWriterPart
|
||||
class DocProps extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write docProps/app.xml
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Element\Section;
|
||||
|
|
@ -17,7 +17,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter;
|
|||
/**
|
||||
* Word2007 document part writer
|
||||
*/
|
||||
class Document extends Base
|
||||
class Document extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write word/document.xml
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?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\Writer\Word2007\Part;
|
||||
|
||||
/**
|
||||
* Word2007 endnotes part writer
|
||||
*/
|
||||
class Endnotes extends Footnotes
|
||||
{
|
||||
/**
|
||||
* Name of XML root element
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rootNode = 'w:endnotes';
|
||||
|
||||
/**
|
||||
* Name of XML node element
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $elementNode = 'w:endnote';
|
||||
|
||||
/**
|
||||
* Name of XML reference element
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $refNode = 'w:endnoteRef';
|
||||
|
||||
/**
|
||||
* Reference style name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $refStyle = 'EndnoteReference';
|
||||
}
|
||||
|
|
@ -1,2 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<w:fonts xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:font w:name="Times New Roman"><w:panose1 w:val="02020603050405020304"/><w:charset w:val="00"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="E0002AFF" w:usb1="C0007841" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Courier New"><w:panose1 w:val="02070309020205020404"/><w:charset w:val="00"/><w:family w:val="modern"/><w:pitch w:val="fixed"/><w:sig w:usb0="E0002AFF" w:usb1="C0007843" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Wingdings"><w:panose1 w:val="05000000000000000000"/><w:charset w:val="02"/><w:family w:val="auto"/><w:pitch w:val="variable"/><w:sig w:usb0="00000000" w:usb1="10000000" w:usb2="00000000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000"/></w:font><w:font w:name="Symbol"><w:panose1 w:val="05050102010706020507"/><w:charset w:val="02"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="00000000" w:usb1="10000000" w:usb2="00000000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000"/></w:font><w:font w:name="Arial"><w:panose1 w:val="020B0604020202020204"/><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/><w:sig w:usb0="E0002AFF" w:usb1="C0007843" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Cambria"><w:panose1 w:val="02040503050406030204"/><w:charset w:val="00"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="A00002EF" w:usb1="4000004B" w:usb2="00000000" w:usb3="00000000" w:csb0="0000019F" w:csb1="00000000"/></w:font><w:font w:name="Calibri"><w:panose1 w:val="020F0502020204030204"/><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/><w:sig w:usb0="E10002FF" w:usb1="4000ACFF" w:usb2="00000009" w:usb3="00000000" w:csb0="0000019F" w:csb1="00000000"/></w:font></w:fonts>
|
||||
<?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\Writer\Word2007\Part;
|
||||
|
||||
/**
|
||||
* Word2007 font table writer
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
class FontTable extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write fontTable.xml
|
||||
*/
|
||||
public function write()
|
||||
{
|
||||
return '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<w:fonts xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:font w:name="Times New Roman"><w:panose1 w:val="02020603050405020304"/><w:charset w:val="00"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="E0002AFF" w:usb1="C0007841" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Courier New"><w:panose1 w:val="02070309020205020404"/><w:charset w:val="00"/><w:family w:val="modern"/><w:pitch w:val="fixed"/><w:sig w:usb0="E0002AFF" w:usb1="C0007843" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Wingdings"><w:panose1 w:val="05000000000000000000"/><w:charset w:val="02"/><w:family w:val="auto"/><w:pitch w:val="variable"/><w:sig w:usb0="00000000" w:usb1="10000000" w:usb2="00000000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000"/></w:font><w:font w:name="Symbol"><w:panose1 w:val="05050102010706020507"/><w:charset w:val="02"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="00000000" w:usb1="10000000" w:usb2="00000000" w:usb3="00000000" w:csb0="80000000" w:csb1="00000000"/></w:font><w:font w:name="Arial"><w:panose1 w:val="020B0604020202020204"/><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/><w:sig w:usb0="E0002AFF" w:usb1="C0007843" w:usb2="00000009" w:usb3="00000000" w:csb0="000001FF" w:csb1="00000000"/></w:font><w:font w:name="Cambria"><w:panose1 w:val="02040503050406030204"/><w:charset w:val="00"/><w:family w:val="roman"/><w:pitch w:val="variable"/><w:sig w:usb0="A00002EF" w:usb1="4000004B" w:usb2="00000000" w:usb3="00000000" w:csb0="0000019F" w:csb1="00000000"/></w:font><w:font w:name="Calibri"><w:panose1 w:val="020F0502020204030204"/><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/><w:sig w:usb0="E10002FF" w:usb1="4000ACFF" w:usb2="00000009" w:usb3="00000000" w:csb0="0000019F" w:csb1="00000000"/></w:font></w:fonts>';
|
||||
}
|
||||
}
|
||||
|
|
@ -7,14 +7,14 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Footer as FooterElement;
|
||||
|
||||
/**
|
||||
* Word2007 footer part writer
|
||||
*/
|
||||
class Footer extends Base
|
||||
class Footer extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write word/footnotes.xml
|
||||
|
|
@ -7,33 +7,56 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Footnote;
|
||||
use PhpOffice\PhpWord\Element\Endnote;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter;
|
||||
|
||||
/**
|
||||
* Word2007 footnotes part writer
|
||||
*/
|
||||
class Notes extends Base
|
||||
class Footnotes extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Name of XML root element
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rootNode = 'w:footnotes';
|
||||
|
||||
/**
|
||||
* Name of XML node element
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $elementNode = 'w:footnote';
|
||||
|
||||
/**
|
||||
* Name of XML reference element
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $refNode = 'w:footnoteRef';
|
||||
|
||||
/**
|
||||
* Reference style name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $refStyle = 'FootnoteReference';
|
||||
|
||||
/**
|
||||
* Write word/(footnotes|endnotes).xml
|
||||
*
|
||||
* @param array $elements
|
||||
* @param string $notesTypes
|
||||
*/
|
||||
public function writeNotes($elements, $notesTypes = 'footnotes')
|
||||
public function write($elements)
|
||||
{
|
||||
$isFootnote = $notesTypes == 'footnotes';
|
||||
$rootNode = $isFootnote ? 'w:footnotes' : 'w:endnotes';
|
||||
$elementNode = $isFootnote ? 'w:footnote' : 'w:endnote';
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
|
||||
$xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
$xmlWriter->startElement($rootNode);
|
||||
$xmlWriter->startElement($this->rootNode);
|
||||
$xmlWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
|
||||
$xmlWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
|
||||
$xmlWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
|
||||
|
|
@ -45,7 +68,7 @@ class Notes extends Base
|
|||
$xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
|
||||
|
||||
// Separator and continuation separator
|
||||
$xmlWriter->startElement($elementNode);
|
||||
$xmlWriter->startElement($this->elementNode);
|
||||
$xmlWriter->writeAttribute('w:id', -1);
|
||||
$xmlWriter->writeAttribute('w:type', 'separator');
|
||||
$xmlWriter->startElement('w:p');
|
||||
|
|
@ -54,8 +77,8 @@ class Notes extends Base
|
|||
$xmlWriter->endElement(); // w:separator
|
||||
$xmlWriter->endElement(); // w:r
|
||||
$xmlWriter->endElement(); // w:p
|
||||
$xmlWriter->endElement(); // $elementNode
|
||||
$xmlWriter->startElement($elementNode);
|
||||
$xmlWriter->endElement(); // $this->elementNode
|
||||
$xmlWriter->startElement($this->elementNode);
|
||||
$xmlWriter->writeAttribute('w:id', 0);
|
||||
$xmlWriter->writeAttribute('w:type', 'continuationSeparator');
|
||||
$xmlWriter->startElement('w:p');
|
||||
|
|
@ -64,16 +87,16 @@ class Notes extends Base
|
|||
$xmlWriter->endElement(); // w:continuationSeparator
|
||||
$xmlWriter->endElement(); // w:r
|
||||
$xmlWriter->endElement(); // w:p
|
||||
$xmlWriter->endElement(); // $elementNode
|
||||
$xmlWriter->endElement(); // $this->elementNode
|
||||
|
||||
// Content
|
||||
foreach ($elements as $element) {
|
||||
if ($element instanceof Footnote || $element instanceof Endnote) {
|
||||
$this->writeNote($xmlWriter, $element, $notesTypes);
|
||||
if ($element instanceof Footnote) {
|
||||
$this->writeNote($xmlWriter, $element);
|
||||
}
|
||||
}
|
||||
|
||||
$xmlWriter->endElement(); // $rootNode
|
||||
$xmlWriter->endElement(); // $this->rootNode
|
||||
|
||||
return $xmlWriter->getData();
|
||||
}
|
||||
|
|
@ -83,16 +106,10 @@ class Notes extends Base
|
|||
*
|
||||
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
||||
* @param \PhpOffice\PhpWord\Element\Footnote|\PhpOffice\PhpWord\Element\Endnote $element
|
||||
* @param string $notesTypes
|
||||
*/
|
||||
protected function writeNote(XMLWriter $xmlWriter, $element, $notesTypes = 'footnotes')
|
||||
protected function writeNote(XMLWriter $xmlWriter, $element)
|
||||
{
|
||||
$isFootnote = ($notesTypes == 'footnotes');
|
||||
$elementNode = $isFootnote ? 'w:footnote' : 'w:endnote';
|
||||
$refNode = $isFootnote ? 'w:footnoteRef' : 'w:endnoteRef';
|
||||
$styleName = $isFootnote ? 'FootnoteReference' : 'EndnoteReference';
|
||||
|
||||
$xmlWriter->startElement($elementNode);
|
||||
$xmlWriter->startElement($this->elementNode);
|
||||
$xmlWriter->writeAttribute('w:id', $element->getRelationId());
|
||||
$xmlWriter->startElement('w:p');
|
||||
|
||||
|
|
@ -105,10 +122,10 @@ class Notes extends Base
|
|||
$xmlWriter->startElement('w:r');
|
||||
$xmlWriter->startElement('w:rPr');
|
||||
$xmlWriter->startElement('w:rStyle');
|
||||
$xmlWriter->writeAttribute('w:val', $styleName);
|
||||
$xmlWriter->writeAttribute('w:val', $this->refStyle);
|
||||
$xmlWriter->endElement(); // w:rStyle
|
||||
$xmlWriter->endElement(); // w:rPr
|
||||
$xmlWriter->writeElement($refNode);
|
||||
$xmlWriter->writeElement($this->refNode);
|
||||
$xmlWriter->endElement(); // w:r
|
||||
|
||||
// Empty space after refence symbol
|
||||
|
|
@ -122,6 +139,6 @@ class Notes extends Base
|
|||
$this->writeContainerElements($xmlWriter, $element);
|
||||
|
||||
$xmlWriter->endElement(); // w:p
|
||||
$xmlWriter->endElement(); // $elementNode
|
||||
$xmlWriter->endElement(); // $this->elementNode
|
||||
}
|
||||
}
|
||||
|
|
@ -7,14 +7,14 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Header as HeaderElement;
|
||||
|
||||
/**
|
||||
* Word2007 header part writer
|
||||
*/
|
||||
class Header extends Base
|
||||
class Header extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write word/headerx.xml
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Style;
|
||||
use PhpOffice\PhpWord\Style\Numbering as NumberingStyle;
|
||||
|
|
@ -16,7 +16,7 @@ use PhpOffice\PhpWord\Style\NumberingLevel;
|
|||
/**
|
||||
* Word2007 numbering part writer
|
||||
*/
|
||||
class Numbering extends Base
|
||||
class Numbering extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write word/numbering.xml
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
|
|
@ -17,7 +17,7 @@ use PhpOffice\PhpWord\Shared\XMLWriter;
|
|||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
class Rels extends AbstractWriterPart
|
||||
class Rels extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Base relationship URL
|
||||
|
|
@ -7,14 +7,14 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
|
||||
/**
|
||||
* Word2007 settings part writer
|
||||
*/
|
||||
class Settings extends AbstractWriterPart
|
||||
class Settings extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write word/settings.xml
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Style;
|
||||
|
|
@ -25,7 +25,7 @@ use PhpOffice\PhpWord\Writer\Word2007\Style\Table as TableStyleWriter;
|
|||
*
|
||||
* @todo Do something with the numbering style introduced in 0.10.0
|
||||
*/
|
||||
class Styles extends Base
|
||||
class Styles extends AbstractPart
|
||||
{
|
||||
/**
|
||||
* Write word/styles.xml
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -7,7 +7,7 @@
|
|||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
||||
|
||||
/**
|
||||
* Word2007 web settings part writer
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
|
@ -6,18 +6,18 @@
|
|||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\ODText;
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Writer\ODText;
|
||||
use PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\ODText\AbstractWriterPart
|
||||
* Test class for PhpOffice\PhpWord\Writer\ODText\Part\AbstractPart
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\AbstractWriterPart
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Part\AbstractPart
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
|
||||
class AbstractPartTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* covers ::setParentWriter
|
||||
|
|
@ -26,7 +26,7 @@ class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
|
|||
public function testSetGetParentWriter()
|
||||
{
|
||||
$object = $this->getMockForAbstractClass(
|
||||
'PhpOffice\\PhpWord\\Writer\\ODText\\AbstractWriterPart'
|
||||
'PhpOffice\\PhpWord\\Writer\\ODText\\Part\\AbstractPart'
|
||||
);
|
||||
$object->setParentWriter(new ODText());
|
||||
$this->assertEquals(
|
||||
|
|
@ -43,7 +43,7 @@ class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
|
|||
public function testSetGetParentWriterNull()
|
||||
{
|
||||
$object = $this->getMockForAbstractClass(
|
||||
'PhpOffice\\PhpWord\\Writer\\ODText\\AbstractWriterPart'
|
||||
'PhpOffice\\PhpWord\\Writer\\ODText\\Part\\AbstractPart'
|
||||
);
|
||||
$object->getParentWriter();
|
||||
}
|
||||
|
|
@ -6,16 +6,16 @@
|
|||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\ODText;
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Writer\ODText\Content;
|
||||
use PhpOffice\PhpWord\Writer\ODText\Part\Content;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\ODText\Content
|
||||
* Test class for PhpOffice\PhpWord\Writer\ODText\Part\Content
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Content
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Part\Content
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class ContentTest extends \PHPUnit_Framework_TestCase
|
||||
|
|
@ -45,8 +45,8 @@ class ContentTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testWriteContent()
|
||||
{
|
||||
$imageSrc = __DIR__ . "/../../_files/images/PhpWord.png";
|
||||
$objectSrc = __DIR__ . "/../../_files/documents/sheet.xls";
|
||||
$imageSrc = __DIR__ . "/../../../_files/images/PhpWord.png";
|
||||
$objectSrc = __DIR__ . "/../../../_files/documents/sheet.xls";
|
||||
$expected = 'Expected';
|
||||
|
||||
$phpWord = new PhpWord();
|
||||
|
|
@ -6,14 +6,14 @@
|
|||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\ODText;
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\ODText\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Writer\ODText\Meta;
|
||||
use PhpOffice\PhpWord\Writer\ODText\Part\Meta;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\ODText\Meta
|
||||
* Test class for PhpOffice\PhpWord\Writer\ODText\Part\Meta
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Meta
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Part\Meta
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class MetaTest extends \PHPUnit_Framework_TestCase
|
||||
|
|
@ -6,14 +6,14 @@
|
|||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\ODText;
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Part\ODText;
|
||||
|
||||
use PhpOffice\PhpWord\Writer\ODText\Styles;
|
||||
use PhpOffice\PhpWord\Writer\ODText\Part\Styles;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\ODText\Styles
|
||||
* Test class for PhpOffice\PhpWord\Writer\ODText\Part\Styles
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Styles
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\ODText\Part\Styles
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class StylesTest extends \PHPUnit_Framework_TestCase
|
||||
|
|
@ -30,7 +30,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals('./', $object->getDiskCachingDirectory());
|
||||
foreach (array('Content', 'Manifest', 'Meta', 'Mimetype', 'Styles') as $part) {
|
||||
$this->assertInstanceOf(
|
||||
"PhpOffice\\PhpWord\\Writer\\ODText\\{$part}",
|
||||
"PhpOffice\\PhpWord\\Writer\\ODText\\Part\\{$part}",
|
||||
$object->getWriterPart($part)
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
|
|
|
|||
|
|
@ -1,141 +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\Tests\Writer\Word2007;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Document;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Document
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class DocumentTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Executed before each method of the class
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
TestHelperDOCX::clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test write word/document.xm with no PhpWord
|
||||
*
|
||||
* @expectedException \PhpOffice\PhpWord\Exception\Exception
|
||||
* @expectedExceptionMessage No PhpWord assigned.
|
||||
*/
|
||||
public function testWriteDocumentNoPhpWord()
|
||||
{
|
||||
$object = new Document();
|
||||
$object->writeDocument();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write end section page numbering
|
||||
*/
|
||||
public function testWriteEndSectionPageNumbering()
|
||||
{
|
||||
$phpWord = new PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
$settings = $section->getSettings();
|
||||
$settings->setLandscape();
|
||||
$settings->setPageNumberingStart(2);
|
||||
$settings->setBorderSize(240);
|
||||
$settings->setBreakType('nextPage');
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
$element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType');
|
||||
|
||||
$this->assertEquals(2, $element->getAttribute('w:start'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write elements
|
||||
*/
|
||||
public function testElements()
|
||||
{
|
||||
$objectSrc = __DIR__ . "/../../_files/documents/sheet.xls";
|
||||
|
||||
$phpWord = new PhpWord();
|
||||
$phpWord->addTitleStyle(1, array('color' => '333333', 'bold'=>true));
|
||||
$phpWord->addTitleStyle(2, array('color'=>'666666'));
|
||||
$section = $phpWord->addSection();
|
||||
$section->addTOC();
|
||||
$section->addPageBreak();
|
||||
$section->addTitle('Title 1', 1);
|
||||
$section->addListItem('List Item 1', 0);
|
||||
$section->addListItem('List Item 2', 0);
|
||||
$section->addListItem('List Item 3', 0);
|
||||
$section = $phpWord->addSection();
|
||||
$section->addTitle('Title 2', 2);
|
||||
$section->addObject($objectSrc);
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
// TOC
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[1]/w:pPr/w:tabs/w:tab');
|
||||
$this->assertEquals('right', $element->getAttribute('w:val'));
|
||||
$this->assertEquals('dot', $element->getAttribute('w:leader'));
|
||||
$this->assertEquals(9062, $element->getAttribute('w:pos'));
|
||||
|
||||
// Page break
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[4]/w:r/w:br');
|
||||
$this->assertEquals('page', $element->getAttribute('w:type'));
|
||||
|
||||
// Title
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[5]/w:pPr/w:pStyle');
|
||||
$this->assertEquals('Heading1', $element->getAttribute('w:val'));
|
||||
|
||||
// List item
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[6]/w:pPr/w:numPr/w:numId');
|
||||
$this->assertEquals(3, $element->getAttribute('w:val'));
|
||||
|
||||
// Object
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[11]/w:r/w:object/o:OLEObject');
|
||||
$this->assertEquals('Embed', $element->getAttribute('Type'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write element with some styles
|
||||
*/
|
||||
public function testElementStyles()
|
||||
{
|
||||
$objectSrc = __DIR__ . "/../../_files/documents/sheet.xls";
|
||||
|
||||
$phpWord = new PhpWord();
|
||||
$phpWord->addParagraphStyle('pStyle', array('align' => 'center')); // Style #1
|
||||
$phpWord->addFontStyle('fStyle', array('size' => '20')); // Style #2
|
||||
$phpWord->addTitleStyle(1, array('color' => '333333', 'bold' => true)); // Style #3
|
||||
$fontStyle = new Font('text', array('align' => 'center'));
|
||||
$section = $phpWord->addSection();
|
||||
$section->addListItem('List Item', 0, null, null, 'pStyle'); // Style #4
|
||||
$section->addObject($objectSrc, array('align' => 'center'));
|
||||
$section->addTOC($fontStyle);
|
||||
$section->addTitle('Title 1', 1);
|
||||
$section->addTOC('fStyle');
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
// List item
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[1]/w:pPr/w:numPr/w:numId');
|
||||
$this->assertEquals(4, $element->getAttribute('w:val'));
|
||||
|
||||
// Object
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject');
|
||||
$this->assertEquals('Embed', $element->getAttribute('Type'));
|
||||
|
||||
// TOC
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[3]/w:pPr/w:tabs/w:tab');
|
||||
$this->assertEquals('right', $element->getAttribute('w:val'));
|
||||
$this->assertEquals('dot', $element->getAttribute('w:leader'));
|
||||
$this->assertEquals(9062, $element->getAttribute('w:pos'));
|
||||
}
|
||||
}
|
||||
|
|
@ -6,16 +6,16 @@
|
|||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Part\AbstractWriterPart;
|
||||
use PhpOffice\PhpWord\Writer\Word2007;
|
||||
use PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\AbstractWriterPart
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\AbstractWriterPart
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractWriterPart
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
|
||||
|
|
@ -27,7 +27,7 @@ class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
|
|||
public function testSetGetParentWriter()
|
||||
{
|
||||
$object = $this->getMockForAbstractClass(
|
||||
'PhpOffice\\PhpWord\\Writer\\Word2007\\AbstractWriterPart'
|
||||
'PhpOffice\\PhpWord\\Writer\\Word2007\\Part\\AbstractPart'
|
||||
);
|
||||
$object->setParentWriter(new Word2007());
|
||||
$this->assertEquals(
|
||||
|
|
@ -44,7 +44,7 @@ class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
|
|||
public function testSetGetParentWriterNull()
|
||||
{
|
||||
$object = $this->getMockForAbstractClass(
|
||||
'PhpOffice\\PhpWord\\Writer\\Word2007\\AbstractWriterPart'
|
||||
'PhpOffice\\PhpWord\\Writer\\Word2007\\Part\\AbstractPart'
|
||||
);
|
||||
$object->getParentWriter();
|
||||
}
|
||||
|
|
@ -6,14 +6,14 @@
|
|||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Writer\Word2007\DocProps;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Part\DocProps;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\DocProps
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\DocProps
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\DocProps
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Part\DocProps
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class DocPropsTest extends \PHPUnit_Framework_TestCase
|
||||
|
|
@ -6,18 +6,19 @@
|
|||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Part\Document;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Base
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Document
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Base
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class BaseTest extends \PHPUnit_Framework_TestCase
|
||||
class DocumentTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Executed before each method of the class
|
||||
|
|
@ -27,6 +28,117 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
|||
TestHelperDOCX::clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test write word/document.xm with no PhpWord
|
||||
*
|
||||
* @expectedException \PhpOffice\PhpWord\Exception\Exception
|
||||
* @expectedExceptionMessage No PhpWord assigned.
|
||||
*/
|
||||
public function testWriteDocumentNoPhpWord()
|
||||
{
|
||||
$object = new Document();
|
||||
$object->writeDocument();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write end section page numbering
|
||||
*/
|
||||
public function testWriteEndSectionPageNumbering()
|
||||
{
|
||||
$phpWord = new PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
$settings = $section->getSettings();
|
||||
$settings->setLandscape();
|
||||
$settings->setPageNumberingStart(2);
|
||||
$settings->setBorderSize(240);
|
||||
$settings->setBreakType('nextPage');
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
$element = $doc->getElement('/w:document/w:body/w:sectPr/w:pgNumType');
|
||||
|
||||
$this->assertEquals(2, $element->getAttribute('w:start'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write elements
|
||||
*/
|
||||
public function testElements()
|
||||
{
|
||||
$objectSrc = __DIR__ . "/../../../_files/documents/sheet.xls";
|
||||
|
||||
$phpWord = new PhpWord();
|
||||
$phpWord->addTitleStyle(1, array('color' => '333333', 'bold'=>true));
|
||||
$phpWord->addTitleStyle(2, array('color'=>'666666'));
|
||||
$section = $phpWord->addSection();
|
||||
$section->addTOC();
|
||||
$section->addPageBreak();
|
||||
$section->addTitle('Title 1', 1);
|
||||
$section->addListItem('List Item 1', 0);
|
||||
$section->addListItem('List Item 2', 0);
|
||||
$section->addListItem('List Item 3', 0);
|
||||
$section = $phpWord->addSection();
|
||||
$section->addTitle('Title 2', 2);
|
||||
$section->addObject($objectSrc);
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
// TOC
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[1]/w:pPr/w:tabs/w:tab');
|
||||
$this->assertEquals('right', $element->getAttribute('w:val'));
|
||||
$this->assertEquals('dot', $element->getAttribute('w:leader'));
|
||||
$this->assertEquals(9062, $element->getAttribute('w:pos'));
|
||||
|
||||
// Page break
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[4]/w:r/w:br');
|
||||
$this->assertEquals('page', $element->getAttribute('w:type'));
|
||||
|
||||
// Title
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[5]/w:pPr/w:pStyle');
|
||||
$this->assertEquals('Heading1', $element->getAttribute('w:val'));
|
||||
|
||||
// List item
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[6]/w:pPr/w:numPr/w:numId');
|
||||
$this->assertEquals(3, $element->getAttribute('w:val'));
|
||||
|
||||
// Object
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[11]/w:r/w:object/o:OLEObject');
|
||||
$this->assertEquals('Embed', $element->getAttribute('Type'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Write element with some styles
|
||||
*/
|
||||
public function testElementStyles()
|
||||
{
|
||||
$objectSrc = __DIR__ . "/../../../_files/documents/sheet.xls";
|
||||
|
||||
$phpWord = new PhpWord();
|
||||
$phpWord->addParagraphStyle('pStyle', array('align' => 'center')); // Style #1
|
||||
$phpWord->addFontStyle('fStyle', array('size' => '20')); // Style #2
|
||||
$phpWord->addTitleStyle(1, array('color' => '333333', 'bold' => true)); // Style #3
|
||||
$fontStyle = new Font('text', array('align' => 'center'));
|
||||
$section = $phpWord->addSection();
|
||||
$section->addListItem('List Item', 0, null, null, 'pStyle'); // Style #4
|
||||
$section->addObject($objectSrc, array('align' => 'center'));
|
||||
$section->addTOC($fontStyle);
|
||||
$section->addTitle('Title 1', 1);
|
||||
$section->addTOC('fStyle');
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
// List item
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[1]/w:pPr/w:numPr/w:numId');
|
||||
$this->assertEquals(4, $element->getAttribute('w:val'));
|
||||
|
||||
// Object
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject');
|
||||
$this->assertEquals('Embed', $element->getAttribute('Type'));
|
||||
|
||||
// TOC
|
||||
$element = $doc->getElement('/w:document/w:body/w:p[3]/w:pPr/w:tabs/w:tab');
|
||||
$this->assertEquals('right', $element->getAttribute('w:val'));
|
||||
$this->assertEquals('dot', $element->getAttribute('w:leader'));
|
||||
$this->assertEquals(9062, $element->getAttribute('w:pos'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test write text element
|
||||
*/
|
||||
|
|
@ -55,7 +167,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$pStyle = 'pStyle';
|
||||
$aStyle = array('align' => 'justify', 'spaceBefore' => 120, 'spaceAfter' => 120);
|
||||
$imageSrc = __DIR__ . "/../../_files/images/earth.jpg";
|
||||
$imageSrc = __DIR__ . "/../../../_files/images/earth.jpg";
|
||||
|
||||
$phpWord = new PhpWord();
|
||||
$phpWord->addParagraphStyle($pStyle, $aStyle);
|
||||
|
|
@ -156,10 +268,10 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
|||
$section = $phpWord->addSection();
|
||||
foreach ($wraps as $wrap) {
|
||||
$styles['wrappingStyle'] = $wrap;
|
||||
$section->addImage(__DIR__ . "/../../_files/images/earth.jpg", $styles);
|
||||
$section->addImage(__DIR__ . "/../../../_files/images/earth.jpg", $styles);
|
||||
}
|
||||
|
||||
$archiveFile = realpath(__DIR__ . '/../../_files/documents/reader.docx');
|
||||
$archiveFile = realpath(__DIR__ . '/../../../_files/documents/reader.docx');
|
||||
$imageFile = 'word/media/image1.jpeg';
|
||||
$source = 'zip://' . $archiveFile . '#' . $imageFile;
|
||||
$section->addImage($source);
|
||||
|
|
@ -181,7 +293,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testWriteWatermark()
|
||||
{
|
||||
$imageSrc = __DIR__ . "/../../_files/images/earth.jpg";
|
||||
$imageSrc = __DIR__ . "/../../../_files/images/earth.jpg";
|
||||
|
||||
$phpWord = new PhpWord();
|
||||
$section = $phpWord->addSection();
|
||||
|
|
@ -305,8 +417,8 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
|||
$tWidth = 120;
|
||||
$rHeight = 120;
|
||||
$cWidth = 120;
|
||||
$imageSrc = __DIR__ . "/../../_files/images/earth.jpg";
|
||||
$objectSrc = __DIR__ . "/../../_files/documents/sheet.xls";
|
||||
$imageSrc = __DIR__ . "/../../../_files/images/earth.jpg";
|
||||
$objectSrc = __DIR__ . "/../../../_files/documents/sheet.xls";
|
||||
|
||||
$tStyles["width"] = 50;
|
||||
$tStyles["cellMarginTop"] = 120;
|
||||
|
|
@ -6,16 +6,16 @@
|
|||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Footer;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Part\Footer;
|
||||
use PhpOffice\PhpWord\Writer\Word2007;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Footer
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Footer
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Footer
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Part\Footer
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class FooterTest extends \PHPUnit_Framework_TestCase
|
||||
|
|
@ -27,7 +27,7 @@ class FooterTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testWriteFooter()
|
||||
{
|
||||
$imageSrc = __DIR__ . "/../../_files/images/PhpWord.png";
|
||||
$imageSrc = __DIR__ . "/../../../_files/images/PhpWord.png";
|
||||
$container = new \PhpOffice\PhpWord\Element\Footer(1);
|
||||
$container->addText('');
|
||||
$container->addPreserveText('');
|
||||
|
|
@ -6,17 +6,17 @@
|
|||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Notes
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Notes
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class NotesTest extends \PHPUnit_Framework_TestCase
|
||||
class FootnotesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Executed before each method of the class
|
||||
|
|
@ -39,10 +39,11 @@ class NotesTest extends \PHPUnit_Framework_TestCase
|
|||
$footnote1->addText('Footnote');
|
||||
$footnote1->addTextBreak();
|
||||
$footnote1->addLink('http://google.com');
|
||||
$footnote2 = $section->addFootnote(array('align' => 'left'));
|
||||
$footnote2->addText('Footnote');
|
||||
$footnote2 = $section->addEndnote(array('align' => 'left'));
|
||||
$footnote2->addText('Endnote');
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
$this->assertTrue($doc->elementExists("/w:document/w:body/w:p/w:r/w:footnoteReference"));
|
||||
$this->assertTrue($doc->elementExists("/w:document/w:body/w:p/w:r/w:endnoteReference"));
|
||||
}
|
||||
}
|
||||
|
|
@ -6,14 +6,14 @@
|
|||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Header;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Part\Header;
|
||||
use PhpOffice\PhpWord\Writer\Word2007;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Header
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Header
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
|
|
@ -24,7 +24,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase
|
|||
*/
|
||||
public function testWriteHeader()
|
||||
{
|
||||
$imageSrc = __DIR__ . "/../../_files/images/PhpWord.png";
|
||||
$imageSrc = __DIR__ . "/../../../_files/images/PhpWord.png";
|
||||
|
||||
$container = new \PhpOffice\PhpWord\Element\Header(1);
|
||||
$container->addText('Test');
|
||||
|
|
@ -6,18 +6,18 @@
|
|||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Style\Numbering as NumberingStyle;
|
||||
use PhpOffice\PhpWord\Style\NumberingLevel;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Numbering;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Part\Numbering;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Numbering
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Numbering
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Numbering
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Part\Numbering
|
||||
* @runTestsInSeparateProcesses
|
||||
* @since 0.10.0
|
||||
*/
|
||||
|
|
@ -6,16 +6,16 @@
|
|||
* @copyright 2014 PHPWord
|
||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||
*/
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007;
|
||||
namespace PhpOffice\PhpWord\Tests\Writer\Word2007\Part;
|
||||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Styles;
|
||||
use PhpOffice\PhpWord\Writer\Word2007\Part\Styles;
|
||||
use PhpOffice\PhpWord\Tests\TestHelperDOCX;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Styles
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Styles
|
||||
*
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Styles
|
||||
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Part\Styles
|
||||
* @runTestsInSeparateProcesses
|
||||
*/
|
||||
class StylesTest extends \PHPUnit_Framework_TestCase
|
||||
|
|
@ -45,12 +45,12 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
|
|||
'WebSettings' => 'WebSettings',
|
||||
'Header' => 'Header',
|
||||
'Footer' => 'Footer',
|
||||
'Footnotes' => 'Notes',
|
||||
'Endnotes' => 'Notes',
|
||||
'Footnotes' => 'Footnotes',
|
||||
'Endnotes' => 'Footnotes',
|
||||
);
|
||||
foreach ($writerParts as $part => $type) {
|
||||
$this->assertInstanceOf(
|
||||
"PhpOffice\\PhpWord\\Writer\\Word2007\\{$type}",
|
||||
"PhpOffice\\PhpWord\\Writer\\Word2007\\Part\\{$type}",
|
||||
$object->getWriterPart($part)
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
|
|
|
|||
Loading…
Reference in New Issue