0
0

Settings.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * PHPExcel_Writer_OpenDocument_Settings
  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_Settings extends PHPExcel_Writer_OpenDocument_WriterPart
  28. {
  29. /**
  30. * Write settings.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. // Settings
  50. $objWriter->startElement('office:document-settings');
  51. $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
  52. $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
  53. $objWriter->writeAttribute('xmlns:config', 'urn:oasis:names:tc:opendocument:xmlns:config:1.0');
  54. $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
  55. $objWriter->writeAttribute('office:version', '1.2');
  56. $objWriter->startElement('office:settings');
  57. $objWriter->startElement('config:config-item-set');
  58. $objWriter->writeAttribute('config:name', 'ooo:view-settings');
  59. $objWriter->startElement('config:config-item-map-indexed');
  60. $objWriter->writeAttribute('config:name', 'Views');
  61. $objWriter->endElement();
  62. $objWriter->endElement();
  63. $objWriter->startElement('config:config-item-set');
  64. $objWriter->writeAttribute('config:name', 'ooo:configuration-settings');
  65. $objWriter->endElement();
  66. $objWriter->endElement();
  67. $objWriter->endElement();
  68. return $objWriter->getData();
  69. }
  70. }