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 | 113 | 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 | 113 | protected function writeSlideRelationships(Slide $pSlide) |
|
| 57 | { |
||
| 58 | //@todo Group all getShapeCollection()->getIterator |
||
| 59 | |||
| 60 | // Create XML writer |
||
| 61 | 113 | $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); |
|
| 62 | |||
| 63 | // XML header |
||
| 64 | 113 | $objWriter->startDocument('1.0', 'UTF-8', 'yes'); |
|
| 65 | |||
| 66 | // Relationships |
||
| 67 | 113 | $objWriter->startElement('Relationships'); |
|
| 68 | 113 | $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); |
|
| 69 | |||
| 70 | // Starting relation id |
||
| 71 | 113 | $relId = 1; |
|
| 72 | 113 | $idxSlide = $pSlide->getParent()->getIndex($pSlide); |
|
| 73 | |||
| 74 | // Write slideLayout relationship |
||
| 75 | 113 | $layoutId = 1; |
|
| 76 | 113 | if ($pSlide->getSlideLayout()) { |
|
| 77 | 113 | $layoutId = $pSlide->getSlideLayout()->layoutNr; |
|
| 78 | 113 | } |
|
| 79 | 113 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout', '../slideLayouts/slideLayout' . $layoutId . '.xml'); |
|
| 80 | 113 | ++$relId; |
|
| 81 | |||
| 82 | // Write drawing relationships? |
||
| 83 | 113 | if ($pSlide->getShapeCollection()->count() > 0) { |
|
| 84 | // Loop trough images and write relationships |
||
| 85 | 86 | $iterator = $pSlide->getShapeCollection()->getIterator(); |
|
| 86 | 86 | while ($iterator->valid()) { |
|
| 87 | 86 | 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 | 86 | } 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 | 85 | } elseif ($iterator->current() instanceof ShapeChart) { |
|
| 100 | // Write relationship for chart drawing |
||
| 101 | 34 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', '../charts/' . $iterator->current()->getIndexedFilename()); |
|
| 102 | |||
| 103 | 34 | $iterator->current()->relationId = 'rId' . $relId; |
|
| 104 | |||
| 105 | 34 | ++$relId; |
|
| 106 | 77 | } 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 | 86 | $iterator->next(); |
|
| 134 | 86 | } |
|
| 135 | 86 | } |
|
| 136 | |||
| 137 | // Write background relationships? |
||
| 138 | 113 | $oBackground = $pSlide->getBackground(); |
|
| 139 | 113 | 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 | 113 | if ($pSlide->getShapeCollection()->count() > 0) { |
|
| 147 | // Loop trough hyperlinks and write relationships |
||
| 148 | 86 | $iterator = $pSlide->getShapeCollection()->getIterator(); |
|
| 149 | 86 | while ($iterator->valid()) { |
|
| 150 | // Hyperlink on shape |
||
| 151 | 86 | 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 | 86 | if ($iterator->current() instanceof RichText) { |
|
| 167 | 25 | foreach ($iterator->current()->getParagraphs() as $paragraph) { |
|
| 168 | 25 | foreach ($paragraph->getRichTextElements() as $element) { |
|
| 169 | 20 | if ($element instanceof Run || $element instanceof TextElement) { |
|
| 170 | 19 | 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 | 19 | } |
|
| 184 | 25 | } |
|
| 185 | 25 | } |
|
| 186 | 25 | } |
|
| 187 | |||
| 188 | // Hyperlink in table |
||
| 189 | 86 | if ($iterator->current() instanceof ShapeTable) { |
|
| 190 | // Rows |
||
| 191 | 10 | $countRows = count($iterator->current()->getRows()); |
|
| 192 | 10 | for ($row = 0; $row < $countRows; $row++) { |
|
| 193 | // Cells in rows |
||
| 194 | 10 | $countCells = count($iterator->current()->getRow($row)->getCells()); |
|
| 195 | 10 | for ($cell = 0; $cell < $countCells; $cell++) { |
|
| 196 | 10 | $currentCell = $iterator->current()->getRow($row)->getCell($cell); |
|
| 197 | // Paragraphs in cell |
||
| 198 | 10 | foreach ($currentCell->getParagraphs() as $paragraph) { |
|
| 199 | // RichText in paragraph |
||
| 200 | 10 | foreach ($paragraph->getRichTextElements() as $element) { |
|
| 201 | // Run or Text in RichText |
||
| 202 | 10 | if ($element instanceof Run || $element instanceof TextElement) { |
|
| 203 | 10 | 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 | 10 | } |
|
| 217 | 10 | } |
|
| 218 | 10 | } |
|
| 219 | 10 | } |
|
| 220 | 10 | } |
|
| 221 | 10 | } |
|
| 222 | |||
| 223 | 86 | 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 | 86 | $iterator->next(); |
|
| 304 | 86 | } |
|
| 305 | 86 | } |
|
| 306 | |||
| 307 | // Write comment relationships |
||
| 308 | 113 | if ($pSlide->getShapeCollection()->count() > 0) { |
|
| 309 | 86 | $hasSlideComment = false; |
|
| 310 | |||
| 311 | // Loop trough images and write relationships |
||
| 312 | 86 | $iterator = $pSlide->getShapeCollection()->getIterator(); |
|
| 313 | 86 | while ($iterator->valid()) { |
|
| 314 | 86 | if ($iterator->current() instanceof Comment) { |
|
| 315 | 6 | $hasSlideComment = true; |
|
| 316 | 6 | break; |
|
| 317 | 80 | } 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 | 79 | $iterator->next(); |
|
| 329 | 79 | } |
|
| 330 | |||
| 331 | 86 | if ($hasSlideComment) { |
|
| 332 | 7 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments', '../comments/comment'.($idxSlide + 1).'.xml'); |
|
| 333 | 7 | ++$relId; |
|
| 334 | 7 | } |
|
| 335 | 86 | } |
|
| 336 | |||
| 337 | 113 | if ($pSlide->getNote()->getShapeCollection()->count() > 0) { |
|
| 338 | 1 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide', '../notesSlides/notesSlide'.($idxSlide + 1).'.xml'); |
|
| 339 | 1 | } |
|
| 340 | |||
| 341 | 113 | $objWriter->endElement(); |
|
| 342 | |||
| 343 | // Return |
||
| 344 | 113 | 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 | 113 | public function writeSlide(Slide $pSlide) |
|
| 500 | |||
| 501 | /** |
||
| 502 | * @param XMLWriter $objWriter |
||
| 503 | * @param Slide $oSlide |
||
| 504 | */ |
||
| 505 | 88 | protected function writeSlideAnimations(XMLWriter $objWriter, Slide $oSlide) |
|
| 506 | { |
||
| 507 | 88 | $arrayAnimations = $oSlide->getAnimations(); |
|
| 508 | 88 | if (empty($arrayAnimations)) { |
|
| 509 | 88 | return; |
|
| 510 | } |
||
| 511 | |||
| 512 | // Variables |
||
| 513 | $shapeId = 1; |
||
| 514 | $idCount = 1; |
||
| 515 | $hashToIdMap = array(); |
||
| 516 | $arrayAnimationIds = array(); |
||
| 517 | |||
| 518 | foreach ($oSlide->getShapeCollection() as $shape) { |
||
| 519 | $hashToIdMap[$shape->getHashCode()] = ++$shapeId; |
||
| 520 | } |
||
| 521 | foreach ($arrayAnimations as $oAnimation) { |
||
| 522 | foreach ($oAnimation->getShapeCollection() as $oShape) { |
||
| 523 | $arrayAnimationIds[] = $hashToIdMap[$oShape->getHashCode()]; |
||
| 524 | } |
||
| 525 | } |
||
| 526 | |||
| 527 | // p:timing |
||
| 528 | $objWriter->startElement('p:timing'); |
||
| 529 | // p:timing/p:tnLst |
||
| 530 | $objWriter->startElement('p:tnLst'); |
||
| 531 | // p:timing/p:tnLst/p:par |
||
| 532 | $objWriter->startElement('p:par'); |
||
| 533 | // p:timing/p:tnLst/p:par/p:cTn |
||
| 534 | $objWriter->startElement('p:cTn'); |
||
| 535 | $objWriter->writeAttribute('id', $idCount++); |
||
| 536 | $objWriter->writeAttribute('dur', 'indefinite'); |
||
| 537 | $objWriter->writeAttribute('restart', 'never'); |
||
| 538 | $objWriter->writeAttribute('nodeType', 'tmRoot'); |
||
| 539 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst |
||
| 540 | $objWriter->startElement('p:childTnLst'); |
||
| 541 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq |
||
| 542 | $objWriter->startElement('p:seq'); |
||
| 543 | $objWriter->writeAttribute('concurrent', '1'); |
||
| 544 | $objWriter->writeAttribute('nextAc', 'seek'); |
||
| 545 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn |
||
| 546 | $objWriter->startElement('p:cTn'); |
||
| 547 | $objWriter->writeAttribute('id', $idCount++); |
||
| 548 | $objWriter->writeAttribute('dur', 'indefinite'); |
||
| 549 | $objWriter->writeAttribute('nodeType', 'mainSeq'); |
||
| 550 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst |
||
| 551 | $objWriter->startElement('p:childTnLst'); |
||
| 552 | |||
| 553 | // Each animation has multiple shapes |
||
| 554 | foreach ($arrayAnimations as $oAnimation) { |
||
| 555 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par |
||
| 556 | $objWriter->startElement('p:par'); |
||
| 557 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn |
||
| 558 | $objWriter->startElement('p:cTn'); |
||
| 559 | $objWriter->writeAttribute('id', $idCount++); |
||
| 560 | $objWriter->writeAttribute('fill', 'hold'); |
||
| 561 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:stCondLst |
||
| 562 | $objWriter->startElement('p:stCondLst'); |
||
| 563 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:stCondLst/p:cond |
||
| 564 | $objWriter->startElement('p:cond'); |
||
| 565 | $objWriter->writeAttribute('delay', 'indefinite'); |
||
| 566 | $objWriter->endElement(); |
||
| 567 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn\##p:stCondLst |
||
| 568 | $objWriter->endElement(); |
||
| 569 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst |
||
| 570 | $objWriter->startElement('p:childTnLst'); |
||
| 571 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par |
||
| 572 | $objWriter->startElement('p:par'); |
||
| 573 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn |
||
| 574 | $objWriter->startElement('p:cTn'); |
||
| 575 | $objWriter->writeAttribute('id', $idCount++); |
||
| 576 | $objWriter->writeAttribute('fill', 'hold'); |
||
| 577 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:stCondLst |
||
| 578 | $objWriter->startElement('p:stCondLst'); |
||
| 579 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:stCondLst/p:cond |
||
| 580 | $objWriter->startElement('p:cond'); |
||
| 581 | $objWriter->writeAttribute('delay', '0'); |
||
| 582 | $objWriter->endElement(); |
||
| 583 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn\##p:stCondLst |
||
| 584 | $objWriter->endElement(); |
||
| 585 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst |
||
| 586 | $objWriter->startElement('p:childTnLst'); |
||
| 587 | |||
| 588 | $firstAnimation = true; |
||
| 589 | foreach ($oAnimation->getShapeCollection() as $oShape) { |
||
| 590 | $nodeType = $firstAnimation ? 'clickEffect' : 'withEffect'; |
||
| 591 | $shapeId = $hashToIdMap[$oShape->getHashCode()]; |
||
| 592 | |||
| 593 | // p:par |
||
| 594 | $objWriter->startElement('p:par'); |
||
| 595 | // p:par/p:cTn |
||
| 596 | $objWriter->startElement('p:cTn'); |
||
| 597 | $objWriter->writeAttribute('id', $idCount++); |
||
| 598 | $objWriter->writeAttribute('presetID', '1'); |
||
| 599 | $objWriter->writeAttribute('presetClass', 'entr'); |
||
| 600 | $objWriter->writeAttribute('fill', 'hold'); |
||
| 601 | $objWriter->writeAttribute('presetSubtype', '0'); |
||
| 602 | $objWriter->writeAttribute('grpId', '0'); |
||
| 603 | $objWriter->writeAttribute('nodeType', $nodeType); |
||
| 604 | // p:par/p:cTn/p:stCondLst |
||
| 605 | $objWriter->startElement('p:stCondLst'); |
||
| 606 | // p:par/p:cTn/p:stCondLst/p:cond |
||
| 607 | $objWriter->startElement('p:cond'); |
||
| 608 | $objWriter->writeAttribute('delay', '0'); |
||
| 609 | $objWriter->endElement(); |
||
| 610 | // p:par/p:cTn\##p:stCondLst |
||
| 611 | $objWriter->endElement(); |
||
| 612 | // p:par/p:cTn/p:childTnLst |
||
| 613 | $objWriter->startElement('p:childTnLst'); |
||
| 614 | // p:par/p:cTn/p:childTnLst/p:set |
||
| 615 | $objWriter->startElement('p:set'); |
||
| 616 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr |
||
| 617 | $objWriter->startElement('p:cBhvr'); |
||
| 618 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:cTn |
||
| 619 | $objWriter->startElement('p:cTn'); |
||
| 620 | $objWriter->writeAttribute('id', $idCount++); |
||
| 621 | $objWriter->writeAttribute('dur', '1'); |
||
| 622 | $objWriter->writeAttribute('fill', 'hold'); |
||
| 623 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:cTn/p:stCondLst |
||
| 624 | $objWriter->startElement('p:stCondLst'); |
||
| 625 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:cTn/p:stCondLst/p:cond |
||
| 626 | $objWriter->startElement('p:cond'); |
||
| 627 | $objWriter->writeAttribute('delay', '0'); |
||
| 628 | $objWriter->endElement(); |
||
| 629 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:cTn\##p:stCondLst |
||
| 630 | $objWriter->endElement(); |
||
| 631 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr\##p:cTn |
||
| 632 | $objWriter->endElement(); |
||
| 633 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl |
||
| 634 | $objWriter->startElement('p:tgtEl'); |
||
| 635 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt |
||
| 636 | $objWriter->startElement('p:spTgt'); |
||
| 637 | $objWriter->writeAttribute('spid', $shapeId); |
||
| 638 | $objWriter->endElement(); |
||
| 639 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr\##p:tgtEl |
||
| 640 | $objWriter->endElement(); |
||
| 641 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:attrNameLst |
||
| 642 | $objWriter->startElement('p:attrNameLst'); |
||
| 643 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:attrNameLst/p:attrName |
||
| 644 | $objWriter->writeElement('p:attrName', 'style.visibility'); |
||
| 645 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr\##p:attrNameLst |
||
| 646 | $objWriter->endElement(); |
||
| 647 | // p:par/p:cTn/p:childTnLst/p:set\##p:cBhvr |
||
| 648 | $objWriter->endElement(); |
||
| 649 | // p:par/p:cTn/p:childTnLst/p:set/p:to |
||
| 650 | $objWriter->startElement('p:to'); |
||
| 651 | // p:par/p:cTn/p:childTnLst/p:set/p:to/p:strVal |
||
| 652 | $objWriter->startElement('p:strVal'); |
||
| 653 | $objWriter->writeAttribute('val', 'visible'); |
||
| 654 | $objWriter->endElement(); |
||
| 655 | // p:par/p:cTn/p:childTnLst/p:set\##p:to |
||
| 656 | $objWriter->endElement(); |
||
| 657 | // p:par/p:cTn/p:childTnLst\##p:set |
||
| 658 | $objWriter->endElement(); |
||
| 659 | // p:par/p:cTn\##p:childTnLst |
||
| 660 | $objWriter->endElement(); |
||
| 661 | // p:par\##p:cTn |
||
| 662 | $objWriter->endElement(); |
||
| 663 | // ##p:par |
||
| 664 | $objWriter->endElement(); |
||
| 665 | |||
| 666 | $firstAnimation = false; |
||
| 667 | } |
||
| 668 | |||
| 669 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn\##p:childTnLst |
||
| 670 | $objWriter->endElement(); |
||
| 671 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par\##p:cTn |
||
| 672 | $objWriter->endElement(); |
||
| 673 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst\##p:par |
||
| 674 | $objWriter->endElement(); |
||
| 675 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn\##p:childTnLst |
||
| 676 | $objWriter->endElement(); |
||
| 677 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par\##p:cTn |
||
| 678 | $objWriter->endElement(); |
||
| 679 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst\##p:par |
||
| 680 | $objWriter->endElement(); |
||
| 681 | } |
||
| 682 | |||
| 683 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn\##p:childTnLst |
||
| 684 | $objWriter->endElement(); |
||
| 685 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq\##p:cTn |
||
| 686 | $objWriter->endElement(); |
||
| 687 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:prevCondLst |
||
| 688 | $objWriter->startElement('p:prevCondLst'); |
||
| 689 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:prevCondLst/p:cond |
||
| 690 | $objWriter->startElement('p:cond'); |
||
| 691 | $objWriter->writeAttribute('evt', 'onPrev'); |
||
| 692 | $objWriter->writeAttribute('delay', '0'); |
||
| 693 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:prevCondLst/p:cond/p:tgtEl |
||
| 694 | $objWriter->startElement('p:tgtEl'); |
||
| 695 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:prevCondLst/p:cond/p:tgtEl/p:sldTgt |
||
| 696 | $objWriter->writeElement('p:sldTgt', null); |
||
| 697 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:prevCondLst/p:cond\##p:tgtEl |
||
| 698 | $objWriter->endElement(); |
||
| 699 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:prevCondLst\##p:cond |
||
| 700 | $objWriter->endElement(); |
||
| 701 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq\##p:prevCondLst |
||
| 702 | $objWriter->endElement(); |
||
| 703 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:nextCondLst |
||
| 704 | $objWriter->startElement('p:nextCondLst'); |
||
| 705 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:nextCondLst/p:cond |
||
| 706 | $objWriter->startElement('p:cond'); |
||
| 707 | $objWriter->writeAttribute('evt', 'onNext'); |
||
| 708 | $objWriter->writeAttribute('delay', '0'); |
||
| 709 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:nextCondLst/p:cond/p:tgtEl |
||
| 710 | $objWriter->startElement('p:tgtEl'); |
||
| 711 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:nextCondLst/p:cond/p:tgtEl/p:sldTgt |
||
| 712 | $objWriter->writeElement('p:sldTgt', null); |
||
| 713 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:nextCondLst/p:cond\##p:tgtEl |
||
| 714 | $objWriter->endElement(); |
||
| 715 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:nextCondLst\##p:cond |
||
| 716 | $objWriter->endElement(); |
||
| 717 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq\##p:nextCondLst |
||
| 718 | $objWriter->endElement(); |
||
| 719 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst\##p:seq |
||
| 720 | $objWriter->endElement(); |
||
| 721 | // p:timing/p:tnLst/p:par/p:cTn\##p:childTnLst |
||
| 722 | $objWriter->endElement(); |
||
| 723 | // p:timing/p:tnLst/p:par\##p:cTn |
||
| 724 | $objWriter->endElement(); |
||
| 725 | // p:timing/p:tnLst\##p:par |
||
| 726 | $objWriter->endElement(); |
||
| 727 | // p:timing\##p:tnLst |
||
| 728 | $objWriter->endElement(); |
||
| 729 | |||
| 730 | // p:timing/p:bldLst |
||
| 731 | $objWriter->startElement('p:bldLst'); |
||
| 732 | |||
| 733 | // Add in ids of all shapes in this slides animations |
||
| 734 | foreach ($arrayAnimationIds as $id) { |
||
| 735 | // p:timing/p:bldLst/p:bldP |
||
| 736 | $objWriter->startElement('p:bldP'); |
||
| 737 | $objWriter->writeAttribute('spid', $id); |
||
| 738 | $objWriter->writeAttribute('grpId', 0); |
||
| 739 | $objWriter->endELement(); |
||
| 740 | } |
||
| 741 | |||
| 742 | // p:timing\##p:bldLst |
||
| 743 | $objWriter->endElement(); |
||
| 744 | |||
| 745 | // ##p:timing |
||
| 746 | $objWriter->endElement(); |
||
| 747 | } |
||
| 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 |