コード例 #1
0
 /**
  *
  * @param PHPWord $PHPWord
  * @return string
  */
 public function writeDocument(PHPWord $PHPWord = null)
 {
     $numbering = $PHPWord->getNumbering();
     // Create XML writer
     if ($this->getParentWriter()->getUseDiskCaching()) {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
     } else {
         $objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
     }
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8', 'yes');
     // START w:numbering
     $objWriter->startElement('w:numbering');
     $objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
     $objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
     $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
     $objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
     $objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
     $objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
     $objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
     $objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
     $objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
     // Write all of the abstractNum elements
     foreach ($numbering as $key => $value) {
         $value->toXml($objWriter);
     }
     // Write all of the num elements
     foreach ($numbering as $key => $value) {
         $objWriter->startElement('w:num');
         $objWriter->writeAttribute("w:numId", $key + 1);
         $objWriter->startElement('w:abstractNumId');
         $objWriter->writeAttribute("w:val", $key + 1);
         $objWriter->endElement();
         $objWriter->endElement();
     }
     // END w:numbering
     $objWriter->endElement();
     return $objWriter->getData();
 }