Complex classes like PptSlides often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use PptSlides, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 20 | class PptSlides extends AbstractSlide |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Add slides (drawings, ...) and slide relationships (drawings, ...) |
||
| 24 | * @return \PhpOffice\Common\Adapter\Zip\ZipInterface |
||
| 25 | */ |
||
| 26 | 114 | public function render() |
|
| 48 | |||
| 49 | /** |
||
| 50 | * Write slide relationships to XML format |
||
| 51 | * |
||
| 52 | * @param \PhpOffice\PhpPresentation\Slide $pSlide |
||
| 53 | * @return string XML Output |
||
| 54 | * @throws \Exception |
||
| 55 | */ |
||
| 56 | 114 | protected function writeSlideRelationships(Slide $pSlide) |
|
| 57 | { |
||
| 58 | //@todo Group all getShapeCollection()->getIterator |
||
| 59 | |||
| 60 | // Create XML writer |
||
| 61 | 114 | $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); |
|
| 62 | |||
| 63 | // XML header |
||
| 64 | 114 | $objWriter->startDocument('1.0', 'UTF-8', 'yes'); |
|
| 65 | |||
| 66 | // Relationships |
||
| 67 | 114 | $objWriter->startElement('Relationships'); |
|
| 68 | 114 | $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); |
|
| 69 | |||
| 70 | // Starting relation id |
||
| 71 | 114 | $relId = 1; |
|
| 72 | 114 | $idxSlide = $pSlide->getParent()->getIndex($pSlide); |
|
| 73 | |||
| 74 | // Write slideLayout relationship |
||
| 75 | 114 | $layoutId = 1; |
|
| 76 | 114 | if ($pSlide->getSlideLayout()) { |
|
| 77 | 114 | $layoutId = $pSlide->getSlideLayout()->layoutNr; |
|
| 78 | 114 | } |
|
| 79 | 114 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout', '../slideLayouts/slideLayout' . $layoutId . '.xml'); |
|
| 80 | 114 | ++$relId; |
|
| 81 | |||
| 82 | // Write drawing relationships? |
||
| 83 | 114 | if ($pSlide->getShapeCollection()->count() > 0) { |
|
| 84 | // Loop trough images and write relationships |
||
| 85 | 87 | $iterator = $pSlide->getShapeCollection()->getIterator(); |
|
| 86 | 87 | while ($iterator->valid()) { |
|
| 87 | 87 | if ($iterator->current() instanceof Media) { |
|
| 88 | // Write relationship for image drawing |
||
| 89 | 1 | $iterator->current()->relationId = 'rId' . $relId; |
|
| 90 | 1 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/video', '../media/' . $iterator->current()->getIndexedFilename()); |
|
| 91 | 1 | ++$relId; |
|
| 92 | 1 | $this->writeRelationship($objWriter, $relId, 'http://schemas.microsoft.com/office/2007/relationships/media', '../media/' . $iterator->current()->getIndexedFilename()); |
|
| 93 | 1 | ++$relId; |
|
| 94 | 87 | } elseif ($iterator->current() instanceof ShapeDrawing\AbstractDrawingAdapter) { |
|
| 95 | // Write relationship for image drawing |
||
| 96 | 9 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $iterator->current()->getIndexedFilename()); |
|
| 97 | 9 | $iterator->current()->relationId = 'rId' . $relId; |
|
| 98 | 9 | ++$relId; |
|
| 99 | 86 | } elseif ($iterator->current() instanceof ShapeChart) { |
|
| 100 | // Write relationship for chart drawing |
||
| 101 | 35 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', '../charts/' . $iterator->current()->getIndexedFilename()); |
|
| 102 | |||
| 103 | 35 | $iterator->current()->relationId = 'rId' . $relId; |
|
| 104 | |||
| 105 | 35 | ++$relId; |
|
| 106 | 78 | } elseif ($iterator->current() instanceof Group) { |
|
| 107 | 1 | $iterator2 = $iterator->current()->getShapeCollection()->getIterator(); |
|
| 108 | 1 | while ($iterator2->valid()) { |
|
| 109 | 1 | if ($iterator2->current() instanceof Media) { |
|
| 110 | // Write relationship for image drawing |
||
| 111 | $iterator2->current()->relationId = 'rId' . $relId; |
||
| 112 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/video', '../media/' . $iterator->current()->getIndexedFilename()); |
||
| 113 | ++$relId; |
||
| 114 | $this->writeRelationship($objWriter, $relId, 'http://schemas.microsoft.com/office/2007/relationships/media', '../media/' . $iterator->current()->getIndexedFilename()); |
||
| 115 | ++$relId; |
||
| 116 | 1 | } elseif ($iterator2->current() instanceof ShapeDrawing\AbstractDrawingAdapter) { |
|
| 117 | // Write relationship for image drawing |
||
| 118 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $iterator2->current()->getIndexedFilename()); |
||
| 119 | $iterator2->current()->relationId = 'rId' . $relId; |
||
| 120 | |||
| 121 | ++$relId; |
||
| 122 | 1 | } elseif ($iterator2->current() instanceof ShapeChart) { |
|
| 123 | // Write relationship for chart drawing |
||
| 124 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', '../charts/' . $iterator2->current()->getIndexedFilename()); |
||
| 125 | $iterator2->current()->relationId = 'rId' . $relId; |
||
| 126 | |||
| 127 | ++$relId; |
||
| 128 | } |
||
| 129 | 1 | $iterator2->next(); |
|
| 130 | 1 | } |
|
| 131 | 1 | } |
|
| 132 | |||
| 133 | 87 | $iterator->next(); |
|
| 134 | 87 | } |
|
| 135 | 87 | } |
|
| 136 | |||
| 137 | // Write background relationships? |
||
| 138 | 114 | $oBackground = $pSlide->getBackground(); |
|
| 139 | 114 | if ($oBackground instanceof Image) { |
|
| 140 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $oBackground->getIndexedFilename($idxSlide)); |
||
| 141 | $oBackground->relationId = 'rId' . $relId; |
||
| 142 | ++$relId; |
||
| 143 | } |
||
| 144 | |||
| 145 | // Write hyperlink relationships? |
||
| 146 | 114 | if ($pSlide->getShapeCollection()->count() > 0) { |
|
| 147 | // Loop trough hyperlinks and write relationships |
||
| 148 | 87 | $iterator = $pSlide->getShapeCollection()->getIterator(); |
|
| 149 | 87 | while ($iterator->valid()) { |
|
| 150 | // Hyperlink on shape |
||
| 151 | 87 | if ($iterator->current()->hasHyperlink()) { |
|
| 152 | // Write relationship for hyperlink |
||
| 153 | 3 | $hyperlink = $iterator->current()->getHyperlink(); |
|
| 154 | 3 | $hyperlink->relationId = 'rId' . $relId; |
|
| 155 | |||
| 156 | 3 | if (!$hyperlink->isInternal()) { |
|
| 157 | 3 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); |
|
| 158 | 3 | } else { |
|
| 159 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); |
||
| 160 | } |
||
| 161 | |||
| 162 | 3 | ++$relId; |
|
| 163 | 3 | } |
|
| 164 | |||
| 165 | // Hyperlink on rich text run |
||
| 166 | 87 | if ($iterator->current() instanceof RichText) { |
|
| 167 | 26 | foreach ($iterator->current()->getParagraphs() as $paragraph) { |
|
| 168 | 26 | foreach ($paragraph->getRichTextElements() as $element) { |
|
| 169 | 21 | if ($element instanceof Run || $element instanceof TextElement) { |
|
| 170 | 20 | if ($element->hasHyperlink()) { |
|
| 171 | // Write relationship for hyperlink |
||
| 172 | 2 | $hyperlink = $element->getHyperlink(); |
|
| 173 | 2 | $hyperlink->relationId = 'rId' . $relId; |
|
| 174 | |||
| 175 | 2 | if (!$hyperlink->isInternal()) { |
|
| 176 | 1 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); |
|
| 177 | 1 | } else { |
|
| 178 | 1 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); |
|
| 179 | } |
||
| 180 | |||
| 181 | 2 | ++$relId; |
|
| 182 | 2 | } |
|
| 183 | 20 | } |
|
| 184 | 26 | } |
|
| 185 | 26 | } |
|
| 186 | 26 | } |
|
| 187 | |||
| 188 | // Hyperlink in table |
||
| 189 | 87 | if ($iterator->current() instanceof ShapeTable) { |
|
| 190 | // Rows |
||
| 191 | 11 | $countRows = count($iterator->current()->getRows()); |
|
| 192 | 11 | for ($row = 0; $row < $countRows; $row++) { |
|
| 193 | // Cells in rows |
||
| 194 | 11 | $countCells = count($iterator->current()->getRow($row)->getCells()); |
|
| 195 | 11 | for ($cell = 0; $cell < $countCells; $cell++) { |
|
| 196 | 11 | $currentCell = $iterator->current()->getRow($row)->getCell($cell); |
|
| 197 | // Paragraphs in cell |
||
| 198 | 11 | foreach ($currentCell->getParagraphs() as $paragraph) { |
|
| 199 | // RichText in paragraph |
||
| 200 | 11 | foreach ($paragraph->getRichTextElements() as $element) { |
|
| 201 | // Run or Text in RichText |
||
| 202 | 11 | if ($element instanceof Run || $element instanceof TextElement) { |
|
| 203 | 11 | if ($element->hasHyperlink()) { |
|
| 204 | // Write relationship for hyperlink |
||
| 205 | 1 | $hyperlink = $element->getHyperlink(); |
|
| 206 | 1 | $hyperlink->relationId = 'rId' . $relId; |
|
| 207 | |||
| 208 | 1 | if (!$hyperlink->isInternal()) { |
|
| 209 | 1 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); |
|
| 210 | 1 | } else { |
|
| 211 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); |
||
| 212 | } |
||
| 213 | |||
| 214 | 1 | ++$relId; |
|
| 215 | 1 | } |
|
| 216 | 11 | } |
|
| 217 | 11 | } |
|
| 218 | 11 | } |
|
| 219 | 11 | } |
|
| 220 | 11 | } |
|
| 221 | 11 | } |
|
| 222 | |||
| 223 | 87 | if ($iterator->current() instanceof Group) { |
|
| 224 | 1 | $iterator2 = $pSlide->getShapeCollection()->getIterator(); |
|
| 225 | 1 | while ($iterator2->valid()) { |
|
| 226 | // Hyperlink on shape |
||
| 227 | 1 | if ($iterator2->current()->hasHyperlink()) { |
|
| 228 | // Write relationship for hyperlink |
||
| 229 | $hyperlink = $iterator2->current()->getHyperlink(); |
||
| 230 | $hyperlink->relationId = 'rId' . $relId; |
||
| 231 | |||
| 232 | if (!$hyperlink->isInternal()) { |
||
| 233 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); |
||
| 234 | } else { |
||
| 235 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); |
||
| 236 | } |
||
| 237 | |||
| 238 | ++$relId; |
||
| 239 | } |
||
| 240 | |||
| 241 | // Hyperlink on rich text run |
||
| 242 | 1 | if ($iterator2->current() instanceof RichText) { |
|
| 243 | foreach ($iterator2->current()->getParagraphs() as $paragraph) { |
||
| 244 | foreach ($paragraph->getRichTextElements() as $element) { |
||
| 245 | if ($element instanceof Run || $element instanceof TextElement) { |
||
| 246 | if ($element->hasHyperlink()) { |
||
| 247 | // Write relationship for hyperlink |
||
| 248 | $hyperlink = $element->getHyperlink(); |
||
| 249 | $hyperlink->relationId = 'rId' . $relId; |
||
| 250 | |||
| 251 | if (!$hyperlink->isInternal()) { |
||
| 252 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); |
||
| 253 | } else { |
||
| 254 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); |
||
| 255 | } |
||
| 256 | |||
| 257 | ++$relId; |
||
| 258 | } |
||
| 259 | } |
||
| 260 | } |
||
| 261 | } |
||
| 262 | } |
||
| 263 | |||
| 264 | // Hyperlink in table |
||
| 265 | 1 | if ($iterator2->current() instanceof ShapeTable) { |
|
| 266 | // Rows |
||
| 267 | $countRows = count($iterator2->current()->getRows()); |
||
| 268 | for ($row = 0; $row < $countRows; $row++) { |
||
| 269 | // Cells in rows |
||
| 270 | $countCells = count($iterator2->current()->getRow($row)->getCells()); |
||
| 271 | for ($cell = 0; $cell < $countCells; $cell++) { |
||
| 272 | $currentCell = $iterator2->current()->getRow($row)->getCell($cell); |
||
| 273 | // Paragraphs in cell |
||
| 274 | foreach ($currentCell->getParagraphs() as $paragraph) { |
||
| 275 | // RichText in paragraph |
||
| 276 | foreach ($paragraph->getRichTextElements() as $element) { |
||
| 277 | // Run or Text in RichText |
||
| 278 | if ($element instanceof Run || $element instanceof TextElement) { |
||
| 279 | if ($element->hasHyperlink()) { |
||
| 280 | // Write relationship for hyperlink |
||
| 281 | $hyperlink = $element->getHyperlink(); |
||
| 282 | $hyperlink->relationId = 'rId' . $relId; |
||
| 283 | |||
| 284 | if (!$hyperlink->isInternal()) { |
||
| 285 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); |
||
| 286 | } else { |
||
| 287 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); |
||
| 288 | } |
||
| 289 | |||
| 290 | ++$relId; |
||
| 291 | } |
||
| 292 | } |
||
| 293 | } |
||
| 294 | } |
||
| 295 | } |
||
| 296 | } |
||
| 297 | } |
||
| 298 | |||
| 299 | 1 | $iterator2->next(); |
|
| 300 | 1 | } |
|
| 301 | 1 | } |
|
| 302 | |||
| 303 | 87 | $iterator->next(); |
|
| 304 | 87 | } |
|
| 305 | 87 | } |
|
| 306 | |||
| 307 | // Write comment relationships |
||
| 308 | 114 | if ($pSlide->getShapeCollection()->count() > 0) { |
|
| 309 | 87 | $hasSlideComment = false; |
|
| 310 | |||
| 311 | // Loop trough images and write relationships |
||
| 312 | 87 | $iterator = $pSlide->getShapeCollection()->getIterator(); |
|
| 313 | 87 | while ($iterator->valid()) { |
|
| 314 | 87 | if ($iterator->current() instanceof Comment) { |
|
| 315 | 7 | $hasSlideComment = true; |
|
| 316 | 7 | break; |
|
| 317 | 81 | } elseif ($iterator->current() instanceof Group) { |
|
| 318 | 1 | $iterator2 = $iterator->current()->getShapeCollection()->getIterator(); |
|
| 319 | 1 | while ($iterator2->valid()) { |
|
| 320 | 1 | if ($iterator2->current() instanceof Comment) { |
|
| 321 | 1 | $hasSlideComment = true; |
|
| 322 | 1 | break 2; |
|
| 323 | } |
||
| 324 | $iterator2->next(); |
||
| 325 | } |
||
| 326 | } |
||
| 327 | |||
| 328 | 80 | $iterator->next(); |
|
| 329 | 80 | } |
|
| 330 | |||
| 331 | 87 | if ($hasSlideComment) { |
|
| 332 | 8 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments', '../comments/comment'.($idxSlide + 1).'.xml'); |
|
| 333 | 8 | ++$relId; |
|
| 334 | 8 | } |
|
| 335 | 87 | } |
|
| 336 | |||
| 337 | 114 | if ($pSlide->getNote()->getShapeCollection()->count() > 0) { |
|
| 338 | 2 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide', '../notesSlides/notesSlide'.($idxSlide + 1).'.xml'); |
|
| 339 | 2 | } |
|
| 340 | |||
| 341 | 114 | $objWriter->endElement(); |
|
| 342 | |||
| 343 | // Return |
||
| 344 | 114 | return $objWriter->getData(); |
|
| 345 | } |
||
| 346 | |||
| 347 | /** |
||
| 348 | * Write slide to XML format |
||
| 349 | * |
||
| 350 | * @param \PhpOffice\PhpPresentation\Slide $pSlide |
||
| 351 | * @return string XML Output |
||
| 352 | * @throws \Exception |
||
| 353 | */ |
||
| 354 | 114 | public function writeSlide(Slide $pSlide) |
|
| 355 | { |
||
| 356 | // Create XML writer |
||
| 357 | 114 | $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); |
|
| 358 | |||
| 359 | // XML header |
||
| 360 | 114 | $objWriter->startDocument('1.0', 'UTF-8', 'yes'); |
|
| 361 | |||
| 362 | // p:sld |
||
| 363 | 114 | $objWriter->startElement('p:sld'); |
|
| 364 | 114 | $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); |
|
| 365 | 114 | $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); |
|
| 366 | 114 | $objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main'); |
|
| 367 | 114 | $objWriter->writeAttributeIf(!$pSlide->isVisible(), 'show', 0); |
|
| 368 | |||
| 369 | // p:sld/p:cSld |
||
| 370 | 114 | $objWriter->startElement('p:cSld'); |
|
| 371 | |||
| 372 | // Background |
||
| 373 | 114 | if ($pSlide->getBackground() instanceof Slide\AbstractBackground) { |
|
| 374 | $oBackground = $pSlide->getBackground(); |
||
| 375 | // p:bg |
||
| 376 | $objWriter->startElement('p:bg'); |
||
| 377 | |||
| 378 | // p:bgPr |
||
| 379 | $objWriter->startElement('p:bgPr'); |
||
| 380 | |||
| 381 | if ($oBackground instanceof Slide\Background\Color) { |
||
| 382 | // a:solidFill |
||
| 383 | $objWriter->startElement('a:solidFill'); |
||
| 384 | |||
| 385 | $this->writeColor($objWriter, $oBackground->getColor()); |
||
| 386 | |||
| 387 | // > a:solidFill |
||
| 388 | $objWriter->endElement(); |
||
| 389 | } |
||
| 390 | |||
| 391 | if ($oBackground instanceof Slide\Background\Image) { |
||
| 392 | // a:blipFill |
||
| 393 | $objWriter->startElement('a:blipFill'); |
||
| 394 | |||
| 395 | // a:blip |
||
| 396 | $objWriter->startElement('a:blip'); |
||
| 397 | $objWriter->writeAttribute('r:embed', $oBackground->relationId); |
||
| 398 | |||
| 399 | // > a:blipFill |
||
| 400 | $objWriter->endElement(); |
||
| 401 | |||
| 402 | // a:stretch |
||
| 403 | $objWriter->startElement('a:stretch'); |
||
| 404 | |||
| 405 | // a:fillRect |
||
| 406 | $objWriter->writeElement('a:fillRect'); |
||
| 407 | |||
| 408 | // > a:stretch |
||
| 409 | $objWriter->endElement(); |
||
| 410 | |||
| 411 | // > a:blipFill |
||
| 412 | $objWriter->endElement(); |
||
| 413 | } |
||
| 414 | |||
| 415 | // > p:bgPr |
||
| 416 | $objWriter->endElement(); |
||
| 417 | |||
| 418 | // > p:bg |
||
| 419 | $objWriter->endElement(); |
||
| 420 | } |
||
| 421 | |||
| 422 | // p:spTree |
||
| 423 | 114 | $objWriter->startElement('p:spTree'); |
|
| 424 | |||
| 425 | // p:nvGrpSpPr |
||
| 426 | 114 | $objWriter->startElement('p:nvGrpSpPr'); |
|
| 427 | |||
| 428 | // p:cNvPr |
||
| 429 | 114 | $objWriter->startElement('p:cNvPr'); |
|
| 430 | 114 | $objWriter->writeAttribute('id', '1'); |
|
| 431 | 114 | $objWriter->writeAttribute('name', ''); |
|
| 432 | 114 | $objWriter->endElement(); |
|
| 433 | |||
| 434 | // p:cNvGrpSpPr |
||
| 435 | 114 | $objWriter->writeElement('p:cNvGrpSpPr', null); |
|
| 436 | |||
| 437 | // p:nvPr |
||
| 438 | 114 | $objWriter->writeElement('p:nvPr', null); |
|
| 439 | |||
| 440 | 114 | $objWriter->endElement(); |
|
| 441 | |||
| 442 | // p:grpSpPr |
||
| 443 | 114 | $objWriter->startElement('p:grpSpPr'); |
|
| 444 | |||
| 445 | // a:xfrm |
||
| 446 | 114 | $objWriter->startElement('a:xfrm'); |
|
| 447 | |||
| 448 | // a:off |
||
| 449 | 114 | $objWriter->startElement('a:off'); |
|
| 450 | 114 | $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($pSlide->getOffsetX())); |
|
| 451 | 114 | $objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($pSlide->getOffsetY())); |
|
| 452 | 114 | $objWriter->endElement(); // a:off |
|
| 453 | |||
| 454 | // a:ext |
||
| 455 | 114 | $objWriter->startElement('a:ext'); |
|
| 456 | 114 | $objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($pSlide->getExtentX())); |
|
| 457 | 114 | $objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($pSlide->getExtentY())); |
|
| 458 | 114 | $objWriter->endElement(); // a:ext |
|
| 459 | |||
| 460 | // a:chOff |
||
| 461 | 114 | $objWriter->startElement('a:chOff'); |
|
| 462 | 114 | $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($pSlide->getOffsetX())); |
|
| 463 | 114 | $objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($pSlide->getOffsetY())); |
|
| 464 | 114 | $objWriter->endElement(); // a:chOff |
|
| 465 | |||
| 466 | // a:chExt |
||
| 467 | 114 | $objWriter->startElement('a:chExt'); |
|
| 468 | 114 | $objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($pSlide->getExtentX())); |
|
| 469 | 114 | $objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($pSlide->getExtentY())); |
|
| 470 | 114 | $objWriter->endElement(); // a:chExt |
|
| 471 | |||
| 472 | 114 | $objWriter->endElement(); |
|
| 473 | |||
| 474 | 114 | $objWriter->endElement(); |
|
| 475 | |||
| 476 | // Loop shapes |
||
| 477 | 114 | $this->writeShapeCollection($objWriter, $pSlide->getShapeCollection()); |
|
| 478 | |||
| 479 | // TODO |
||
| 480 | 114 | $objWriter->endElement(); |
|
| 481 | |||
| 482 | 114 | $objWriter->endElement(); |
|
| 483 | |||
| 484 | // p:clrMapOvr |
||
| 485 | 114 | $objWriter->startElement('p:clrMapOvr'); |
|
| 486 | // p:clrMapOvr\a:masterClrMapping |
||
| 487 | 114 | $objWriter->writeElement('a:masterClrMapping', null); |
|
| 488 | // ##p:clrMapOvr |
||
| 489 | 114 | $objWriter->endElement(); |
|
| 490 | |||
| 491 | 114 | $this->writeSlideTransition($objWriter, $pSlide->getTransition()); |
|
| 492 | |||
| 493 | 114 | $this->writeSlideAnimations($objWriter, $pSlide); |
|
| 494 | |||
| 495 | 114 | $objWriter->endElement(); |
|
| 496 | |||
| 497 | // Return |
||
| 498 | 114 | return $objWriter->getData(); |
|
| 499 | } |
||
| 500 | |||
| 501 | /** |
||
| 502 | * @param XMLWriter $objWriter |
||
| 503 | * @param Slide $oSlide |
||
| 504 | */ |
||
| 505 | 114 | protected function writeSlideAnimations(XMLWriter $objWriter, Slide $oSlide) |
|
| 748 | |||
| 749 | /** |
||
| 750 | * Write pic |
||
| 751 | * |
||
| 752 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
| 753 | * @param \PhpOffice\PhpPresentation\Shape\Drawing\AbstractDrawingAdapter $shape |
||
| 754 | * @param int $shapeId |
||
| 755 | * @throws \Exception |
||
| 756 | */ |
||
| 757 | protected function writeShapeDrawing(XMLWriter $objWriter, ShapeDrawing\AbstractDrawingAdapter $shape, $shapeId) |
||
| 871 | } |
||
| 872 |