2014-03-22 10:06:08 +04:00
|
|
|
<?php
|
|
|
|
|
/**
|
2014-05-05 13:06:53 +04:00
|
|
|
* This file is part of PHPWord - A pure PHP library for reading and writing
|
|
|
|
|
* word processing documents.
|
|
|
|
|
*
|
|
|
|
|
* PHPWord is free software distributed under the terms of the GNU Lesser
|
|
|
|
|
* General Public License version 3 as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* For the full copyright and license information, please read the LICENSE
|
|
|
|
|
* file that was distributed with this source code. For the full list of
|
|
|
|
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
2014-03-22 10:06:08 +04:00
|
|
|
*
|
2014-03-27 23:55:06 +07:00
|
|
|
* @link https://github.com/PHPOffice/PHPWord
|
2014-05-05 12:38:31 +04:00
|
|
|
* @copyright 2010-2014 PHPWord contributors
|
2014-05-04 21:03:28 +04:00
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
2014-03-22 10:06:08 +04:00
|
|
|
*/
|
|
|
|
|
|
2014-04-30 08:54:38 +07:00
|
|
|
namespace PhpOffice\PhpWord\Writer\ODText\Part;
|
2014-03-22 10:06:08 +04:00
|
|
|
|
2014-05-18 11:13:38 +07:00
|
|
|
use PhpOffice\PhpWord\Shared\XMLWriter;
|
2014-03-22 10:06:08 +04:00
|
|
|
|
2014-03-24 00:26:10 +07:00
|
|
|
/**
|
2014-05-06 08:50:55 +07:00
|
|
|
* ODText styloes part writer: styles.xml
|
2014-03-24 00:26:10 +07:00
|
|
|
*/
|
2014-04-30 08:54:38 +07:00
|
|
|
class Styles extends AbstractPart
|
2014-03-22 10:06:08 +04:00
|
|
|
{
|
|
|
|
|
/**
|
2014-05-06 08:50:55 +07:00
|
|
|
* Write part
|
2014-03-22 10:06:08 +04:00
|
|
|
*
|
2014-05-06 08:50:55 +07:00
|
|
|
* @return string
|
2014-03-22 10:06:08 +04:00
|
|
|
*/
|
2014-05-06 08:50:55 +07:00
|
|
|
public function write()
|
2014-03-22 10:06:08 +04:00
|
|
|
{
|
2014-03-30 16:31:01 +07:00
|
|
|
$xmlWriter = $this->getXmlWriter();
|
2014-03-22 10:06:08 +04:00
|
|
|
|
|
|
|
|
// XML header
|
|
|
|
|
$xmlWriter->startDocument('1.0', 'UTF-8');
|
|
|
|
|
$xmlWriter->startElement('office:document-styles');
|
2014-04-08 03:03:14 +07:00
|
|
|
$this->writeCommonRootAttributes($xmlWriter);
|
2014-03-22 10:06:08 +04:00
|
|
|
|
2014-05-18 11:13:38 +07:00
|
|
|
// Font declarations
|
2014-04-08 03:03:14 +07:00
|
|
|
$this->writeFontFaces($xmlWriter);
|
2014-03-22 10:06:08 +04:00
|
|
|
|
2014-05-18 11:13:38 +07:00
|
|
|
// Office styles
|
2014-03-22 10:06:08 +04:00
|
|
|
$xmlWriter->startElement('office:styles');
|
2014-05-18 11:13:38 +07:00
|
|
|
$this->writePart($xmlWriter, 'Default');
|
|
|
|
|
$this->writePart($xmlWriter, 'Named');
|
2014-03-22 10:06:08 +04:00
|
|
|
$xmlWriter->endElement();
|
|
|
|
|
|
2014-05-18 11:13:38 +07:00
|
|
|
// Automatic styles
|
2014-03-22 10:06:08 +04:00
|
|
|
$xmlWriter->startElement('office:automatic-styles');
|
2014-05-18 11:13:38 +07:00
|
|
|
$this->writePart($xmlWriter, 'PageLayout');
|
|
|
|
|
$this->writePart($xmlWriter, 'Master');
|
2014-03-22 10:06:08 +04:00
|
|
|
$xmlWriter->endElement();
|
|
|
|
|
|
2014-05-18 11:13:38 +07:00
|
|
|
$xmlWriter->endElement(); // office:document-styles
|
2014-03-22 10:06:08 +04:00
|
|
|
|
|
|
|
|
return $xmlWriter->getData();
|
|
|
|
|
}
|
2014-05-18 11:13:38 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Write style part
|
|
|
|
|
*
|
|
|
|
|
* @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
|
|
|
|
|
* @param string $subStyle
|
|
|
|
|
*/
|
|
|
|
|
private function writePart(XMLWriter $xmlWriter, $subStyle)
|
|
|
|
|
{
|
|
|
|
|
$writerClass = "PhpOffice\\PhpWord\\Writer\\ODText\\Style\\{$subStyle}Style";
|
|
|
|
|
$styleWriter = new $writerClass($xmlWriter);
|
|
|
|
|
$styleWriter->write();
|
|
|
|
|
}
|
2014-03-22 10:06:08 +04:00
|
|
|
}
|