| 1 |
<?php |
| 2 |
|
| 3 |
namespace PhpOffice\PhpSpreadsheet\Writer\Ods; |
| 4 |
|
| 5 |
use PhpOffice\PhpSpreadsheet\Shared\XMLWriter; |
| 6 |
use PhpOffice\PhpSpreadsheet\Spreadsheet; |
| 7 |
|
| 8 |
class Styles extends WriterPart |
| 9 |
{ |
| 10 |
/** |
| 11 |
* Write styles.xml to XML format. |
| 12 |
* |
| 13 |
* @param Spreadsheet $spreadsheet |
| 14 |
* |
| 15 |
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception |
| 16 |
* |
| 17 |
* @return string XML Output |
| 18 |
*/ |
| 19 |
public function write(Spreadsheet $spreadsheet = null) |
| 20 |
{ |
| 21 |
$objWriter = null; |
| 22 |
if ($this->getParentWriter()->getUseDiskCaching()) { |
| 23 |
$objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); |
| 24 |
} else { |
| 25 |
$objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); |
| 26 |
} |
| 27 |
|
| 28 |
// XML header |
| 29 |
$objWriter->startDocument('1.0', 'UTF-8'); |
| 30 |
|
| 31 |
// Content |
| 32 |
$objWriter->startElement('office:document-styles'); |
| 33 |
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); |
| 34 |
$objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); |
| 35 |
$objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); |
| 36 |
$objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); |
| 37 |
$objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); |
| 38 |
$objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); |
| 39 |
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); |
| 40 |
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); |
| 41 |
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); |
| 42 |
$objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); |
| 43 |
$objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0'); |
| 44 |
$objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); |
| 45 |
$objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); |
| 46 |
$objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); |
| 47 |
$objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); |
| 48 |
$objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); |
| 49 |
$objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); |
| 50 |
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); |
| 51 |
$objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); |
| 52 |
$objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); |
| 53 |
$objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); |
| 54 |
$objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); |
| 55 |
$objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); |
| 56 |
$objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); |
| 57 |
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); |
| 58 |
$objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); |
| 59 |
$objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); |
| 60 |
$objWriter->writeAttribute('office:version', '1.2'); |
| 61 |
|
| 62 |
$objWriter->writeElement('office:font-face-decls'); |
| 63 |
$objWriter->writeElement('office:styles'); |
| 64 |
$objWriter->writeElement('office:automatic-styles'); |
| 65 |
$objWriter->writeElement('office:master-styles'); |
| 66 |
$objWriter->endElement(); |
| 67 |
|
| 68 |
return $objWriter->getData(); |
| 69 |
} |
| 70 |
} |
| 71 |
|