Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
41 / 41 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| PptPresentation | |
100.00% |
41 / 41 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
| render | |
100.00% |
41 / 41 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * This file is part of PHPPresentation - A pure PHP library for reading and writing |
| 4 | * presentations documents. |
| 5 | * |
| 6 | * PHPPresentation is free software distributed under the terms of the GNU Lesser |
| 7 | * General Public License version 3 as published by the Free Software Foundation. |
| 8 | * |
| 9 | * For the full copyright and license information, please read the LICENSE |
| 10 | * file that was distributed with this source code. For the full list of |
| 11 | * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. |
| 12 | * |
| 13 | * @see https://github.com/PHPOffice/PHPPresentation |
| 14 | * |
| 15 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
| 16 | */ |
| 17 | |
| 18 | declare(strict_types=1); |
| 19 | |
| 20 | namespace PhpOffice\PhpPresentation\Writer\PowerPoint2007; |
| 21 | |
| 22 | use PhpOffice\Common\Adapter\Zip\ZipInterface; |
| 23 | use PhpOffice\Common\XMLWriter; |
| 24 | use PhpOffice\PhpPresentation\DocumentLayout; |
| 25 | |
| 26 | class PptPresentation extends AbstractDecoratorWriter |
| 27 | { |
| 28 | public function render(): ZipInterface |
| 29 | { |
| 30 | // Create XML writer |
| 31 | $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); |
| 32 | |
| 33 | // XML header |
| 34 | $objWriter->startDocument('1.0', 'UTF-8', 'yes'); |
| 35 | |
| 36 | // p:presentation |
| 37 | $objWriter->startElement('p:presentation'); |
| 38 | $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); |
| 39 | $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); |
| 40 | $objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main'); |
| 41 | |
| 42 | // p:sldMasterIdLst |
| 43 | $objWriter->startElement('p:sldMasterIdLst'); |
| 44 | |
| 45 | // Add slide masters |
| 46 | $relationId = 1; |
| 47 | $slideMasterId = 2147483648; |
| 48 | |
| 49 | $countMasterSlides = count($this->oPresentation->getAllMasterSlides()); |
| 50 | for ($inc = 1; $inc <= $countMasterSlides; ++$inc) { |
| 51 | // p:sldMasterId |
| 52 | $objWriter->startElement('p:sldMasterId'); |
| 53 | $objWriter->writeAttribute('id', $slideMasterId); |
| 54 | $objWriter->writeAttribute('r:id', 'rId' . $relationId++); |
| 55 | $objWriter->endElement(); |
| 56 | |
| 57 | // Increase identifier |
| 58 | $slideMasterId += 12; |
| 59 | } |
| 60 | $objWriter->endElement(); |
| 61 | |
| 62 | // theme |
| 63 | ++$relationId; |
| 64 | |
| 65 | // p:sldIdLst |
| 66 | $objWriter->startElement('p:sldIdLst'); |
| 67 | // Write slides |
| 68 | $slideCount = $this->oPresentation->getSlideCount(); |
| 69 | for ($i = 0; $i < $slideCount; ++$i) { |
| 70 | // p:sldId |
| 71 | $objWriter->startElement('p:sldId'); |
| 72 | $objWriter->writeAttribute('id', ($i + 256)); |
| 73 | $objWriter->writeAttribute('r:id', 'rId' . ($i + $relationId)); |
| 74 | $objWriter->endElement(); |
| 75 | } |
| 76 | $objWriter->endElement(); |
| 77 | |
| 78 | // p:sldSz |
| 79 | $objWriter->startElement('p:sldSz'); |
| 80 | $objWriter->writeAttribute('cx', $this->oPresentation->getLayout()->getCX()); |
| 81 | $objWriter->writeAttribute('cy', $this->oPresentation->getLayout()->getCY()); |
| 82 | if (DocumentLayout::LAYOUT_CUSTOM != $this->oPresentation->getLayout()->getDocumentLayout()) { |
| 83 | $objWriter->writeAttribute('type', $this->oPresentation->getLayout()->getDocumentLayout()); |
| 84 | } |
| 85 | $objWriter->endElement(); |
| 86 | |
| 87 | // p:notesSz |
| 88 | $objWriter->startElement('p:notesSz'); |
| 89 | $objWriter->writeAttribute('cx', '6858000'); |
| 90 | $objWriter->writeAttribute('cy', '9144000'); |
| 91 | $objWriter->endElement(); |
| 92 | |
| 93 | $objWriter->writeRaw('<p:defaultTextStyle> |
| 94 | <a:defPPr> |
| 95 | <a:defRPr lang="fr-FR"/> |
| 96 | </a:defPPr> |
| 97 | <a:lvl1pPr algn="l" defTabSz="914400" eaLnBrk="1" hangingPunct="1" latinLnBrk="0" marL="0" rtl="0"> |
| 98 | <a:defRPr kern="1200" sz="1800"> |
| 99 | <a:solidFill> |
| 100 | <a:schemeClr val="tx1"/> |
| 101 | </a:solidFill> |
| 102 | <a:latin typeface="+mn-lt"/> |
| 103 | <a:ea typeface="+mn-ea"/> |
| 104 | <a:cs typeface="+mn-cs"/> |
| 105 | </a:defRPr> |
| 106 | </a:lvl1pPr> |
| 107 | <a:lvl2pPr algn="l" defTabSz="914400" eaLnBrk="1" hangingPunct="1" latinLnBrk="0" marL="457200" rtl="0"> |
| 108 | <a:defRPr kern="1200" sz="1800"> |
| 109 | <a:solidFill> |
| 110 | <a:schemeClr val="tx1"/> |
| 111 | </a:solidFill> |
| 112 | <a:latin typeface="+mn-lt"/> |
| 113 | <a:ea typeface="+mn-ea"/> |
| 114 | <a:cs typeface="+mn-cs"/> |
| 115 | </a:defRPr> |
| 116 | </a:lvl2pPr> |
| 117 | <a:lvl3pPr algn="l" defTabSz="914400" eaLnBrk="1" hangingPunct="1" latinLnBrk="0" marL="914400" rtl="0"> |
| 118 | <a:defRPr kern="1200" sz="1800"> |
| 119 | <a:solidFill> |
| 120 | <a:schemeClr val="tx1"/> |
| 121 | </a:solidFill> |
| 122 | <a:latin typeface="+mn-lt"/> |
| 123 | <a:ea typeface="+mn-ea"/> |
| 124 | <a:cs typeface="+mn-cs"/> |
| 125 | </a:defRPr> |
| 126 | </a:lvl3pPr> |
| 127 | <a:lvl4pPr algn="l" defTabSz="914400" eaLnBrk="1" hangingPunct="1" latinLnBrk="0" marL="1371600" rtl="0"> |
| 128 | <a:defRPr kern="1200" sz="1800"> |
| 129 | <a:solidFill> |
| 130 | <a:schemeClr val="tx1"/> |
| 131 | </a:solidFill> |
| 132 | <a:latin typeface="+mn-lt"/> |
| 133 | <a:ea typeface="+mn-ea"/> |
| 134 | <a:cs typeface="+mn-cs"/> |
| 135 | </a:defRPr> |
| 136 | </a:lvl4pPr> |
| 137 | <a:lvl5pPr algn="l" defTabSz="914400" eaLnBrk="1" hangingPunct="1" latinLnBrk="0" marL="1828800" rtl="0"> |
| 138 | <a:defRPr kern="1200" sz="1800"> |
| 139 | <a:solidFill> |
| 140 | <a:schemeClr val="tx1"/> |
| 141 | </a:solidFill> |
| 142 | <a:latin typeface="+mn-lt"/> |
| 143 | <a:ea typeface="+mn-ea"/> |
| 144 | <a:cs typeface="+mn-cs"/> |
| 145 | </a:defRPr> |
| 146 | </a:lvl5pPr> |
| 147 | <a:lvl6pPr algn="l" defTabSz="914400" eaLnBrk="1" hangingPunct="1" latinLnBrk="0" marL="2286000" rtl="0"> |
| 148 | <a:defRPr kern="1200" sz="1800"> |
| 149 | <a:solidFill> |
| 150 | <a:schemeClr val="tx1"/> |
| 151 | </a:solidFill> |
| 152 | <a:latin typeface="+mn-lt"/> |
| 153 | <a:ea typeface="+mn-ea"/> |
| 154 | <a:cs typeface="+mn-cs"/> |
| 155 | </a:defRPr> |
| 156 | </a:lvl6pPr> |
| 157 | <a:lvl7pPr algn="l" defTabSz="914400" eaLnBrk="1" hangingPunct="1" latinLnBrk="0" marL="2743200" rtl="0"> |
| 158 | <a:defRPr kern="1200" sz="1800"> |
| 159 | <a:solidFill> |
| 160 | <a:schemeClr val="tx1"/> |
| 161 | </a:solidFill> |
| 162 | <a:latin typeface="+mn-lt"/> |
| 163 | <a:ea typeface="+mn-ea"/> |
| 164 | <a:cs typeface="+mn-cs"/> |
| 165 | </a:defRPr> |
| 166 | </a:lvl7pPr> |
| 167 | <a:lvl8pPr algn="l" defTabSz="914400" eaLnBrk="1" hangingPunct="1" latinLnBrk="0" marL="3200400" rtl="0"> |
| 168 | <a:defRPr kern="1200" sz="1800"> |
| 169 | <a:solidFill> |
| 170 | <a:schemeClr val="tx1"/> |
| 171 | </a:solidFill> |
| 172 | <a:latin typeface="+mn-lt"/> |
| 173 | <a:ea typeface="+mn-ea"/> |
| 174 | <a:cs typeface="+mn-cs"/> |
| 175 | </a:defRPr> |
| 176 | </a:lvl8pPr> |
| 177 | <a:lvl9pPr algn="l" defTabSz="914400" eaLnBrk="1" hangingPunct="1" latinLnBrk="0" marL="3657600" rtl="0"> |
| 178 | <a:defRPr kern="1200" sz="1800"> |
| 179 | <a:solidFill> |
| 180 | <a:schemeClr val="tx1"/> |
| 181 | </a:solidFill> |
| 182 | <a:latin typeface="+mn-lt"/> |
| 183 | <a:ea typeface="+mn-ea"/> |
| 184 | <a:cs typeface="+mn-cs"/> |
| 185 | </a:defRPr> |
| 186 | </a:lvl9pPr> |
| 187 | </p:defaultTextStyle> |
| 188 | '); |
| 189 | |
| 190 | $objWriter->endElement(); |
| 191 | |
| 192 | $this->oZip->addFromString('ppt/presentation.xml', $objWriter->getData()); |
| 193 | |
| 194 | // Return |
| 195 | return $this->oZip; |
| 196 | } |
| 197 | } |