Styles.php 5.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * PHPExcel_Writer_OpenDocument_Styles
  4. *
  5. * Copyright (c) 2006 - 2015 PHPExcel
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel_Writer_OpenDocument
  23. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. class PHPExcel_Writer_OpenDocument_Styles extends PHPExcel_Writer_OpenDocument_WriterPart
  28. {
  29. /**
  30. * Write styles.xml to XML format
  31. *
  32. * @param PHPExcel $pPHPExcel
  33. * @return string XML Output
  34. * @throws PHPExcel_Writer_Exception
  35. */
  36. public function write(PHPExcel $pPHPExcel = null)
  37. {
  38. if (!$pPHPExcel) {
  39. $pPHPExcel = $this->getParentWriter()->getPHPExcel();
  40. }
  41. $objWriter = null;
  42. if ($this->getParentWriter()->getUseDiskCaching()) {
  43. $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
  44. } else {
  45. $objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
  46. }
  47. // XML header
  48. $objWriter->startDocument('1.0', 'UTF-8');
  49. // Content
  50. $objWriter->startElement('office:document-styles');
  51. $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
  52. $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
  53. $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
  54. $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
  55. $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
  56. $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
  57. $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
  58. $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
  59. $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
  60. $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
  61. $objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0');
  62. $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
  63. $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
  64. $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
  65. $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
  66. $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
  67. $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
  68. $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
  69. $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
  70. $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
  71. $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
  72. $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
  73. $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
  74. $objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
  75. $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
  76. $objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
  77. $objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
  78. $objWriter->writeAttribute('office:version', '1.2');
  79. $objWriter->writeElement('office:font-face-decls');
  80. $objWriter->writeElement('office:styles');
  81. $objWriter->writeElement('office:automatic-styles');
  82. $objWriter->writeElement('office:master-styles');
  83. $objWriter->endElement();
  84. return $objWriter->getData();
  85. }
  86. }