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 |
||
| 29 | class PptSlides extends AbstractSlide |
||
| 30 | { |
||
| 31 | /** |
||
| 32 | * Add slides (drawings, ...) and slide relationships (drawings, ...) |
||
| 33 | * @return \PhpOffice\Common\Adapter\Zip\ZipInterface |
||
| 34 | */ |
||
| 35 | 98 | public function render() |
|
| 55 | |||
| 56 | /** |
||
| 57 | * Write slide relationships to XML format |
||
| 58 | * |
||
| 59 | * @param \PhpOffice\PhpPresentation\Slide $pSlide |
||
| 60 | * @return string XML Output |
||
| 61 | * @throws \Exception |
||
| 62 | */ |
||
| 63 | 98 | protected function writeSlideRelationships(Slide $pSlide) |
|
| 64 | { |
||
| 65 | //@todo Group all getShapeCollection()->getIterator |
||
| 66 | |||
| 67 | // Create XML writer |
||
| 68 | 98 | $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); |
|
| 69 | |||
| 70 | // XML header |
||
| 71 | 98 | $objWriter->startDocument('1.0', 'UTF-8', 'yes'); |
|
| 72 | |||
| 73 | // Relationships |
||
| 74 | 98 | $objWriter->startElement('Relationships'); |
|
| 75 | 98 | $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); |
|
| 76 | |||
| 77 | // Starting relation id |
||
| 78 | 98 | $relId = 1; |
|
| 79 | 98 | $idxSlide = $pSlide->getParent()->getIndex($pSlide); |
|
| 80 | |||
| 81 | // Write slideLayout relationship |
||
| 82 | 98 | $layoutId = 1; |
|
| 83 | 98 | if ($pSlide->getSlideLayout()) { |
|
| 84 | 98 | $layoutId = $pSlide->getSlideLayout()->layoutNr; |
|
| 85 | 98 | } |
|
| 86 | 98 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout', '../slideLayouts/slideLayout' . $layoutId . '.xml'); |
|
| 87 | 98 | ++$relId; |
|
| 88 | |||
| 89 | // Write drawing relationships? |
||
| 90 | 98 | if ($pSlide->getShapeCollection()->count() > 0) { |
|
| 91 | // Loop trough images and write relationships |
||
| 92 | 73 | $iterator = $pSlide->getShapeCollection()->getIterator(); |
|
| 93 | 73 | while ($iterator->valid()) { |
|
| 94 | 73 | if ($iterator->current() instanceof Media) { |
|
| 95 | // Write relationship for image drawing |
||
| 96 | 1 | $iterator->current()->relationId = 'rId' . $relId; |
|
| 97 | 1 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/video', '../media/' . $iterator->current()->getIndexedFilename()); |
|
| 98 | 1 | ++$relId; |
|
| 99 | 1 | $this->writeRelationship($objWriter, $relId, 'http://schemas.microsoft.com/office/2007/relationships/media', '../media/' . $iterator->current()->getIndexedFilename()); |
|
| 100 | 1 | ++$relId; |
|
| 101 | 73 | } elseif ($iterator->current() instanceof ShapeDrawing\AbstractDrawingAdapter) { |
|
| 102 | // Write relationship for image drawing |
||
| 103 | 7 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $iterator->current()->getIndexedFilename()); |
|
| 104 | 7 | $iterator->current()->relationId = 'rId' . $relId; |
|
| 105 | 7 | ++$relId; |
|
| 106 | 72 | } elseif ($iterator->current() instanceof ShapeChart) { |
|
| 107 | // Write relationship for chart drawing |
||
| 108 | 24 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', '../charts/' . $iterator->current()->getIndexedFilename()); |
|
| 109 | |||
| 110 | 24 | $iterator->current()->relationId = 'rId' . $relId; |
|
| 111 | |||
| 112 | 24 | ++$relId; |
|
| 113 | 65 | } elseif ($iterator->current() instanceof Group) { |
|
| 114 | 1 | $iterator2 = $iterator->current()->getShapeCollection()->getIterator(); |
|
| 115 | 1 | while ($iterator2->valid()) { |
|
| 116 | 1 | if ($iterator2->current() instanceof Media) { |
|
| 117 | // Write relationship for image drawing |
||
| 118 | $iterator2->current()->relationId = 'rId' . $relId; |
||
| 119 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/video', '../media/' . $iterator->current()->getIndexedFilename()); |
||
| 120 | ++$relId; |
||
| 121 | $this->writeRelationship($objWriter, $relId, 'http://schemas.microsoft.com/office/2007/relationships/media', '../media/' . $iterator->current()->getIndexedFilename()); |
||
| 122 | ++$relId; |
||
| 123 | 1 | } elseif ($iterator2->current() instanceof ShapeDrawing\AbstractDrawingAdapter) { |
|
| 124 | // Write relationship for image drawing |
||
| 125 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $iterator2->current()->getIndexedFilename()); |
||
| 126 | $iterator2->current()->relationId = 'rId' . $relId; |
||
| 127 | |||
| 128 | ++$relId; |
||
| 129 | 1 | } elseif ($iterator2->current() instanceof ShapeChart) { |
|
| 130 | // Write relationship for chart drawing |
||
| 131 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', '../charts/' . $iterator2->current()->getIndexedFilename()); |
||
| 132 | $iterator2->current()->relationId = 'rId' . $relId; |
||
| 133 | |||
| 134 | ++$relId; |
||
| 135 | } |
||
| 136 | 1 | $iterator2->next(); |
|
| 137 | 1 | } |
|
| 138 | 1 | } |
|
| 139 | |||
| 140 | 73 | $iterator->next(); |
|
| 141 | 73 | } |
|
| 142 | 73 | } |
|
| 143 | |||
| 144 | // Write background relationships? |
||
| 145 | 98 | $oBackground = $pSlide->getBackground(); |
|
| 146 | 98 | if ($oBackground instanceof Image) { |
|
| 147 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . $oBackground->getIndexedFilename($idxSlide)); |
||
| 148 | $oBackground->relationId = 'rId' . $relId; |
||
| 149 | ++$relId; |
||
| 150 | } |
||
| 151 | |||
| 152 | // Write hyperlink relationships? |
||
| 153 | 98 | if ($pSlide->getShapeCollection()->count() > 0) { |
|
| 154 | // Loop trough hyperlinks and write relationships |
||
| 155 | 73 | $iterator = $pSlide->getShapeCollection()->getIterator(); |
|
| 156 | 73 | while ($iterator->valid()) { |
|
| 157 | // Hyperlink on shape |
||
| 158 | 73 | if ($iterator->current()->hasHyperlink()) { |
|
| 159 | // Write relationship for hyperlink |
||
| 160 | 2 | $hyperlink = $iterator->current()->getHyperlink(); |
|
| 161 | 2 | $hyperlink->relationId = 'rId' . $relId; |
|
| 162 | |||
| 163 | 2 | if (!$hyperlink->isInternal()) { |
|
| 164 | 2 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); |
|
| 165 | 2 | } else { |
|
| 166 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); |
||
| 167 | } |
||
| 168 | |||
| 169 | 2 | ++$relId; |
|
| 170 | 2 | } |
|
| 171 | |||
| 172 | // Hyperlink on rich text run |
||
| 173 | 73 | if ($iterator->current() instanceof RichText) { |
|
| 174 | 24 | foreach ($iterator->current()->getParagraphs() as $paragraph) { |
|
| 175 | 24 | foreach ($paragraph->getRichTextElements() as $element) { |
|
| 176 | 19 | if ($element instanceof Run || $element instanceof RunTextElement) { |
|
| 177 | 18 | if ($element->hasHyperlink()) { |
|
| 178 | // Write relationship for hyperlink |
||
| 179 | 2 | $hyperlink = $element->getHyperlink(); |
|
| 180 | 2 | $hyperlink->relationId = 'rId' . $relId; |
|
| 181 | |||
| 182 | 2 | if (!$hyperlink->isInternal()) { |
|
| 183 | 1 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); |
|
| 184 | 1 | } else { |
|
| 185 | 1 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); |
|
| 186 | } |
||
| 187 | |||
| 188 | 2 | ++$relId; |
|
| 189 | 2 | } |
|
| 190 | 18 | } |
|
| 191 | 24 | } |
|
| 192 | 24 | } |
|
| 193 | 24 | } |
|
| 194 | |||
| 195 | // Hyperlink in table |
||
| 196 | 73 | if ($iterator->current() instanceof ShapeTable) { |
|
| 197 | // Rows |
||
| 198 | 9 | $countRows = count($iterator->current()->getRows()); |
|
| 199 | 9 | for ($row = 0; $row < $countRows; $row++) { |
|
| 200 | // Cells in rows |
||
| 201 | 9 | $countCells = count($iterator->current()->getRow($row)->getCells()); |
|
| 202 | 9 | for ($cell = 0; $cell < $countCells; $cell++) { |
|
| 203 | 9 | $currentCell = $iterator->current()->getRow($row)->getCell($cell); |
|
| 204 | // Paragraphs in cell |
||
| 205 | 9 | foreach ($currentCell->getParagraphs() as $paragraph) { |
|
| 206 | // RichText in paragraph |
||
| 207 | 9 | foreach ($paragraph->getRichTextElements() as $element) { |
|
| 208 | // Run or Text in RichText |
||
| 209 | 9 | if ($element instanceof Run || $element instanceof TextElement) { |
|
| 210 | 9 | if ($element->hasHyperlink()) { |
|
| 211 | // Write relationship for hyperlink |
||
| 212 | 1 | $hyperlink = $element->getHyperlink(); |
|
| 213 | 1 | $hyperlink->relationId = 'rId' . $relId; |
|
| 214 | |||
| 215 | 1 | if (!$hyperlink->isInternal()) { |
|
| 216 | 1 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); |
|
| 217 | 1 | } else { |
|
| 218 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); |
||
| 219 | } |
||
| 220 | |||
| 221 | 1 | ++$relId; |
|
| 222 | 1 | } |
|
| 223 | 9 | } |
|
| 224 | 9 | } |
|
| 225 | 9 | } |
|
| 226 | 9 | } |
|
| 227 | 9 | } |
|
| 228 | 9 | } |
|
| 229 | |||
| 230 | 73 | if ($iterator->current() instanceof Group) { |
|
| 231 | 1 | $iterator2 = $pSlide->getShapeCollection()->getIterator(); |
|
| 232 | 1 | while ($iterator2->valid()) { |
|
| 233 | // Hyperlink on shape |
||
| 234 | 1 | if ($iterator2->current()->hasHyperlink()) { |
|
| 235 | // Write relationship for hyperlink |
||
| 236 | $hyperlink = $iterator2->current()->getHyperlink(); |
||
| 237 | $hyperlink->relationId = 'rId' . $relId; |
||
| 238 | |||
| 239 | if (!$hyperlink->isInternal()) { |
||
| 240 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); |
||
| 241 | } else { |
||
| 242 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); |
||
| 243 | } |
||
| 244 | |||
| 245 | ++$relId; |
||
| 246 | } |
||
| 247 | |||
| 248 | // Hyperlink on rich text run |
||
| 249 | 1 | if ($iterator2->current() instanceof RichText) { |
|
| 250 | foreach ($iterator2->current()->getParagraphs() as $paragraph) { |
||
| 251 | foreach ($paragraph->getRichTextElements() as $element) { |
||
| 252 | if ($element instanceof Run || $element instanceof TextElement) { |
||
| 253 | if ($element->hasHyperlink()) { |
||
| 254 | // Write relationship for hyperlink |
||
| 255 | $hyperlink = $element->getHyperlink(); |
||
| 256 | $hyperlink->relationId = 'rId' . $relId; |
||
| 257 | |||
| 258 | if (!$hyperlink->isInternal()) { |
||
| 259 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); |
||
| 260 | } else { |
||
| 261 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); |
||
| 262 | } |
||
| 263 | |||
| 264 | ++$relId; |
||
| 265 | } |
||
| 266 | } |
||
| 267 | } |
||
| 268 | } |
||
| 269 | } |
||
| 270 | |||
| 271 | // Hyperlink in table |
||
| 272 | 1 | if ($iterator2->current() instanceof ShapeTable) { |
|
| 273 | // Rows |
||
| 274 | $countRows = count($iterator2->current()->getRows()); |
||
| 275 | for ($row = 0; $row < $countRows; $row++) { |
||
| 276 | // Cells in rows |
||
| 277 | $countCells = count($iterator2->current()->getRow($row)->getCells()); |
||
| 278 | for ($cell = 0; $cell < $countCells; $cell++) { |
||
| 279 | $currentCell = $iterator2->current()->getRow($row)->getCell($cell); |
||
| 280 | // Paragraphs in cell |
||
| 281 | foreach ($currentCell->getParagraphs() as $paragraph) { |
||
| 282 | // RichText in paragraph |
||
| 283 | foreach ($paragraph->getRichTextElements() as $element) { |
||
| 284 | // Run or Text in RichText |
||
| 285 | if ($element instanceof Run || $element instanceof TextElement) { |
||
| 286 | if ($element->hasHyperlink()) { |
||
| 287 | // Write relationship for hyperlink |
||
| 288 | $hyperlink = $element->getHyperlink(); |
||
| 289 | $hyperlink->relationId = 'rId' . $relId; |
||
| 290 | |||
| 291 | if (!$hyperlink->isInternal()) { |
||
| 292 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); |
||
| 293 | } else { |
||
| 294 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); |
||
| 295 | } |
||
| 296 | |||
| 297 | ++$relId; |
||
| 298 | } |
||
| 299 | } |
||
| 300 | } |
||
| 301 | } |
||
| 302 | } |
||
| 303 | } |
||
| 304 | } |
||
| 305 | |||
| 306 | 1 | $iterator2->next(); |
|
| 307 | 1 | } |
|
| 308 | 1 | } |
|
| 309 | |||
| 310 | 73 | $iterator->next(); |
|
| 311 | 73 | } |
|
| 312 | 73 | } |
|
| 313 | |||
| 314 | // Write comment relationships |
||
| 315 | 98 | if ($pSlide->getShapeCollection()->count() > 0) { |
|
| 316 | 73 | $hasSlideComment = false; |
|
| 317 | |||
| 318 | // Loop trough images and write relationships |
||
| 319 | 73 | $iterator = $pSlide->getShapeCollection()->getIterator(); |
|
| 320 | 73 | while ($iterator->valid()) { |
|
| 321 | 73 | if ($iterator->current() instanceof Comment) { |
|
| 322 | 6 | $hasSlideComment = true; |
|
| 323 | 6 | break; |
|
| 324 | 67 | } elseif ($iterator->current() instanceof Group) { |
|
| 325 | 1 | $iterator2 = $iterator->current()->getShapeCollection()->getIterator(); |
|
| 326 | 1 | while ($iterator2->valid()) { |
|
| 327 | 1 | if ($iterator2->current() instanceof Comment) { |
|
| 328 | 1 | $hasSlideComment = true; |
|
| 329 | 1 | break 2; |
|
| 330 | } |
||
| 331 | $iterator2->next(); |
||
| 332 | } |
||
| 333 | } |
||
| 334 | |||
| 335 | 66 | $iterator->next(); |
|
| 336 | 66 | } |
|
| 337 | |||
| 338 | 73 | if ($hasSlideComment) { |
|
| 339 | 7 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments', '../comments/comment'.($idxSlide + 1).'.xml'); |
|
| 340 | 7 | ++$relId; |
|
| 341 | 7 | } |
|
| 342 | 73 | } |
|
| 343 | |||
| 344 | 98 | if ($pSlide->getNote()->getShapeCollection()->count() > 0) { |
|
| 345 | 1 | $this->writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide', '../notesSlides/notesSlide'.($idxSlide + 1).'.xml'); |
|
| 346 | 1 | } |
|
| 347 | |||
| 348 | 98 | $objWriter->endElement(); |
|
| 349 | |||
| 350 | // Return |
||
| 351 | 98 | return $objWriter->getData(); |
|
| 352 | } |
||
| 353 | |||
| 354 | /** |
||
| 355 | * Write slide to XML format |
||
| 356 | * |
||
| 357 | * @param \PhpOffice\PhpPresentation\Slide $pSlide |
||
| 358 | * @return string XML Output |
||
| 359 | * @throws \Exception |
||
| 360 | */ |
||
| 361 | 98 | public function writeSlide(Slide $pSlide) |
|
| 362 | { |
||
| 363 | // Create XML writer |
||
| 364 | 98 | $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); |
|
| 365 | |||
| 366 | // XML header |
||
| 367 | 98 | $objWriter->startDocument('1.0', 'UTF-8', 'yes'); |
|
| 368 | |||
| 369 | // p:sld |
||
| 370 | 98 | $objWriter->startElement('p:sld'); |
|
| 371 | 98 | $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); |
|
| 372 | 98 | $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); |
|
| 373 | 98 | $objWriter->writeAttribute('xmlns:p', 'http://schemas.openxmlformats.org/presentationml/2006/main'); |
|
| 374 | 98 | $objWriter->writeAttributeIf(!$pSlide->isVisible(), 'show', 0); |
|
| 375 | |||
| 376 | // p:sld/p:cSld |
||
| 377 | 98 | $objWriter->startElement('p:cSld'); |
|
| 378 | |||
| 379 | // Background |
||
| 380 | 98 | if ($pSlide->getBackground() instanceof Slide\AbstractBackground) { |
|
| 381 | $oBackground = $pSlide->getBackground(); |
||
| 382 | // p:bg |
||
| 383 | $objWriter->startElement('p:bg'); |
||
| 384 | |||
| 385 | // p:bgPr |
||
| 386 | $objWriter->startElement('p:bgPr'); |
||
| 387 | |||
| 388 | if ($oBackground instanceof Slide\Background\Color) { |
||
| 389 | // a:solidFill |
||
| 390 | $objWriter->startElement('a:solidFill'); |
||
| 391 | |||
| 392 | $this->writeColor($objWriter, $oBackground->getColor()); |
||
| 393 | |||
| 394 | // > a:solidFill |
||
| 395 | $objWriter->endElement(); |
||
| 396 | } |
||
| 397 | |||
| 398 | if ($oBackground instanceof Slide\Background\Image) { |
||
| 399 | // a:blipFill |
||
| 400 | $objWriter->startElement('a:blipFill'); |
||
| 401 | |||
| 402 | // a:blip |
||
| 403 | $objWriter->startElement('a:blip'); |
||
| 404 | $objWriter->writeAttribute('r:embed', $oBackground->relationId); |
||
| 405 | |||
| 406 | // > a:blipFill |
||
| 407 | $objWriter->endElement(); |
||
| 408 | |||
| 409 | // a:stretch |
||
| 410 | $objWriter->startElement('a:stretch'); |
||
| 411 | |||
| 412 | // a:fillRect |
||
| 413 | $objWriter->writeElement('a:fillRect'); |
||
| 414 | |||
| 415 | // > a:stretch |
||
| 416 | $objWriter->endElement(); |
||
| 417 | |||
| 418 | // > a:blipFill |
||
| 419 | $objWriter->endElement(); |
||
| 420 | } |
||
| 421 | |||
| 422 | // > p:bgPr |
||
| 423 | $objWriter->endElement(); |
||
| 424 | |||
| 425 | // > p:bg |
||
| 426 | $objWriter->endElement(); |
||
| 427 | } |
||
| 428 | |||
| 429 | // p:spTree |
||
| 430 | 98 | $objWriter->startElement('p:spTree'); |
|
| 431 | |||
| 432 | // p:nvGrpSpPr |
||
| 433 | 98 | $objWriter->startElement('p:nvGrpSpPr'); |
|
| 434 | |||
| 435 | // p:cNvPr |
||
| 436 | 98 | $objWriter->startElement('p:cNvPr'); |
|
| 437 | 98 | $objWriter->writeAttribute('id', '1'); |
|
| 438 | 98 | $objWriter->writeAttribute('name', ''); |
|
| 439 | 98 | $objWriter->endElement(); |
|
| 440 | |||
| 441 | // p:cNvGrpSpPr |
||
| 442 | 98 | $objWriter->writeElement('p:cNvGrpSpPr', null); |
|
| 443 | |||
| 444 | // p:nvPr |
||
| 445 | 98 | $objWriter->writeElement('p:nvPr', null); |
|
| 446 | |||
| 447 | 98 | $objWriter->endElement(); |
|
| 448 | |||
| 449 | // p:grpSpPr |
||
| 450 | 98 | $objWriter->startElement('p:grpSpPr'); |
|
| 451 | |||
| 452 | // a:xfrm |
||
| 453 | 98 | $objWriter->startElement('a:xfrm'); |
|
| 454 | |||
| 455 | // a:off |
||
| 456 | 98 | $objWriter->startElement('a:off'); |
|
| 457 | 98 | $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($pSlide->getOffsetX())); |
|
| 458 | 98 | $objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($pSlide->getOffsetY())); |
|
| 459 | 98 | $objWriter->endElement(); // a:off |
|
| 460 | |||
| 461 | // a:ext |
||
| 462 | 98 | $objWriter->startElement('a:ext'); |
|
| 463 | 98 | $objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($pSlide->getExtentX())); |
|
| 464 | 98 | $objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($pSlide->getExtentY())); |
|
| 465 | 98 | $objWriter->endElement(); // a:ext |
|
| 466 | |||
| 467 | // a:chOff |
||
| 468 | 98 | $objWriter->startElement('a:chOff'); |
|
| 469 | 98 | $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($pSlide->getOffsetX())); |
|
| 470 | 98 | $objWriter->writeAttribute('y', CommonDrawing::pixelsToEmu($pSlide->getOffsetY())); |
|
| 471 | 98 | $objWriter->endElement(); // a:chOff |
|
| 472 | |||
| 473 | // a:chExt |
||
| 474 | 98 | $objWriter->startElement('a:chExt'); |
|
| 475 | 98 | $objWriter->writeAttribute('cx', CommonDrawing::pixelsToEmu($pSlide->getExtentX())); |
|
| 476 | 98 | $objWriter->writeAttribute('cy', CommonDrawing::pixelsToEmu($pSlide->getExtentY())); |
|
| 477 | 98 | $objWriter->endElement(); // a:chExt |
|
| 478 | |||
| 479 | 98 | $objWriter->endElement(); |
|
| 480 | |||
| 481 | 98 | $objWriter->endElement(); |
|
| 482 | |||
| 483 | // Loop shapes |
||
| 484 | 98 | $this->writeShapeCollection($objWriter, $pSlide->getShapeCollection()); |
|
| 485 | |||
| 486 | // TODO |
||
| 487 | 98 | $objWriter->endElement(); |
|
| 488 | |||
| 489 | 98 | $objWriter->endElement(); |
|
| 490 | |||
| 491 | // p:clrMapOvr |
||
| 492 | 98 | $objWriter->startElement('p:clrMapOvr'); |
|
| 493 | // p:clrMapOvr\a:masterClrMapping |
||
| 494 | 98 | $objWriter->writeElement('a:masterClrMapping', null); |
|
| 495 | // ##p:clrMapOvr |
||
| 496 | 98 | $objWriter->endElement(); |
|
| 497 | |||
| 498 | 98 | $this->writeSlideTransition($objWriter, $pSlide->getTransition()); |
|
| 499 | |||
| 500 | 98 | $this->writeSlideAnimations($objWriter, $pSlide); |
|
| 501 | |||
| 502 | 98 | $objWriter->endElement(); |
|
| 503 | |||
| 504 | // Return |
||
| 505 | 98 | return $objWriter->getData(); |
|
| 506 | } |
||
| 507 | |||
| 508 | /** |
||
| 509 | * @param XMLWriter $objWriter |
||
| 510 | * @param Slide $oSlide |
||
| 511 | */ |
||
| 512 | 98 | protected function writeSlideAnimations(XMLWriter $objWriter, Slide $oSlide) |
|
| 513 | { |
||
| 514 | 98 | $arrayAnimations = $oSlide->getAnimations(); |
|
| 515 | 98 | if (empty($arrayAnimations)) { |
|
| 516 | 97 | return; |
|
| 517 | } |
||
| 518 | |||
| 519 | // Variables |
||
| 520 | 1 | $shapeId = 1; |
|
| 521 | 1 | $idCount = 1; |
|
| 522 | 1 | $hashToIdMap = array(); |
|
| 523 | 1 | $arrayAnimationIds = array(); |
|
| 524 | |||
| 525 | 1 | foreach ($oSlide->getShapeCollection() as $shape) { |
|
| 526 | 1 | $hashToIdMap[$shape->getHashCode()] = ++$shapeId; |
|
| 527 | 1 | } |
|
| 528 | 1 | foreach ($arrayAnimations as $oAnimation) { |
|
| 529 | 1 | foreach ($oAnimation->getShapeCollection() as $oShape) { |
|
| 530 | 1 | $arrayAnimationIds[] = $hashToIdMap[$oShape->getHashCode()]; |
|
| 531 | 1 | } |
|
| 532 | 1 | } |
|
| 533 | |||
| 534 | // p:timing |
||
| 535 | 1 | $objWriter->startElement('p:timing'); |
|
| 536 | // p:timing/p:tnLst |
||
| 537 | 1 | $objWriter->startElement('p:tnLst'); |
|
| 538 | // p:timing/p:tnLst/p:par |
||
| 539 | 1 | $objWriter->startElement('p:par'); |
|
| 540 | // p:timing/p:tnLst/p:par/p:cTn |
||
| 541 | 1 | $objWriter->startElement('p:cTn'); |
|
| 542 | 1 | $objWriter->writeAttribute('id', $idCount++); |
|
| 543 | 1 | $objWriter->writeAttribute('dur', 'indefinite'); |
|
| 544 | 1 | $objWriter->writeAttribute('restart', 'never'); |
|
| 545 | 1 | $objWriter->writeAttribute('nodeType', 'tmRoot'); |
|
| 546 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst |
||
| 547 | 1 | $objWriter->startElement('p:childTnLst'); |
|
| 548 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq |
||
| 549 | 1 | $objWriter->startElement('p:seq'); |
|
| 550 | 1 | $objWriter->writeAttribute('concurrent', '1'); |
|
| 551 | 1 | $objWriter->writeAttribute('nextAc', 'seek'); |
|
| 552 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn |
||
| 553 | 1 | $objWriter->startElement('p:cTn'); |
|
| 554 | 1 | $objWriter->writeAttribute('id', $idCount++); |
|
| 555 | 1 | $objWriter->writeAttribute('dur', 'indefinite'); |
|
| 556 | 1 | $objWriter->writeAttribute('nodeType', 'mainSeq'); |
|
| 557 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst |
||
| 558 | 1 | $objWriter->startElement('p:childTnLst'); |
|
| 559 | |||
| 560 | // Each animation has multiple shapes |
||
| 561 | 1 | foreach ($arrayAnimations as $oAnimation) { |
|
| 562 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par |
||
| 563 | 1 | $objWriter->startElement('p:par'); |
|
| 564 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn |
||
| 565 | 1 | $objWriter->startElement('p:cTn'); |
|
| 566 | 1 | $objWriter->writeAttribute('id', $idCount++); |
|
| 567 | 1 | $objWriter->writeAttribute('fill', 'hold'); |
|
| 568 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:stCondLst |
||
| 569 | 1 | $objWriter->startElement('p:stCondLst'); |
|
| 570 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:stCondLst/p:cond |
||
| 571 | 1 | $objWriter->startElement('p:cond'); |
|
| 572 | 1 | $objWriter->writeAttribute('delay', 'indefinite'); |
|
| 573 | 1 | $objWriter->endElement(); |
|
| 574 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn\##p:stCondLst |
||
| 575 | 1 | $objWriter->endElement(); |
|
| 576 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst |
||
| 577 | 1 | $objWriter->startElement('p:childTnLst'); |
|
| 578 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par |
||
| 579 | 1 | $objWriter->startElement('p:par'); |
|
| 580 | // 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 |
||
| 581 | 1 | $objWriter->startElement('p:cTn'); |
|
| 582 | 1 | $objWriter->writeAttribute('id', $idCount++); |
|
| 583 | 1 | $objWriter->writeAttribute('fill', 'hold'); |
|
| 584 | // 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 |
||
| 585 | 1 | $objWriter->startElement('p:stCondLst'); |
|
| 586 | // 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 |
||
| 587 | 1 | $objWriter->startElement('p:cond'); |
|
| 588 | 1 | $objWriter->writeAttribute('delay', '0'); |
|
| 589 | 1 | $objWriter->endElement(); |
|
| 590 | // 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 |
||
| 591 | 1 | $objWriter->endElement(); |
|
| 592 | // 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 |
||
| 593 | 1 | $objWriter->startElement('p:childTnLst'); |
|
| 594 | |||
| 595 | 1 | $firstAnimation = true; |
|
| 596 | 1 | foreach ($oAnimation->getShapeCollection() as $oShape) { |
|
| 597 | 1 | $nodeType = $firstAnimation ? 'clickEffect' : 'withEffect'; |
|
| 598 | 1 | $shapeId = $hashToIdMap[$oShape->getHashCode()]; |
|
| 599 | |||
| 600 | // p:par |
||
| 601 | 1 | $objWriter->startElement('p:par'); |
|
| 602 | // p:par/p:cTn |
||
| 603 | 1 | $objWriter->startElement('p:cTn'); |
|
| 604 | 1 | $objWriter->writeAttribute('id', $idCount++); |
|
| 605 | 1 | $objWriter->writeAttribute('presetID', '1'); |
|
| 606 | 1 | $objWriter->writeAttribute('presetClass', 'entr'); |
|
| 607 | 1 | $objWriter->writeAttribute('fill', 'hold'); |
|
| 608 | 1 | $objWriter->writeAttribute('presetSubtype', '0'); |
|
| 609 | 1 | $objWriter->writeAttribute('grpId', '0'); |
|
| 610 | 1 | $objWriter->writeAttribute('nodeType', $nodeType); |
|
| 611 | // p:par/p:cTn/p:stCondLst |
||
| 612 | 1 | $objWriter->startElement('p:stCondLst'); |
|
| 613 | // p:par/p:cTn/p:stCondLst/p:cond |
||
| 614 | 1 | $objWriter->startElement('p:cond'); |
|
| 615 | 1 | $objWriter->writeAttribute('delay', '0'); |
|
| 616 | 1 | $objWriter->endElement(); |
|
| 617 | // p:par/p:cTn\##p:stCondLst |
||
| 618 | 1 | $objWriter->endElement(); |
|
| 619 | // p:par/p:cTn/p:childTnLst |
||
| 620 | 1 | $objWriter->startElement('p:childTnLst'); |
|
| 621 | // p:par/p:cTn/p:childTnLst/p:set |
||
| 622 | 1 | $objWriter->startElement('p:set'); |
|
| 623 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr |
||
| 624 | 1 | $objWriter->startElement('p:cBhvr'); |
|
| 625 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:cTn |
||
| 626 | 1 | $objWriter->startElement('p:cTn'); |
|
| 627 | 1 | $objWriter->writeAttribute('id', $idCount++); |
|
| 628 | 1 | $objWriter->writeAttribute('dur', '1'); |
|
| 629 | 1 | $objWriter->writeAttribute('fill', 'hold'); |
|
| 630 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:cTn/p:stCondLst |
||
| 631 | 1 | $objWriter->startElement('p:stCondLst'); |
|
| 632 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:cTn/p:stCondLst/p:cond |
||
| 633 | 1 | $objWriter->startElement('p:cond'); |
|
| 634 | 1 | $objWriter->writeAttribute('delay', '0'); |
|
| 635 | 1 | $objWriter->endElement(); |
|
| 636 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:cTn\##p:stCondLst |
||
| 637 | 1 | $objWriter->endElement(); |
|
| 638 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr\##p:cTn |
||
| 639 | 1 | $objWriter->endElement(); |
|
| 640 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl |
||
| 641 | 1 | $objWriter->startElement('p:tgtEl'); |
|
| 642 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt |
||
| 643 | 1 | $objWriter->startElement('p:spTgt'); |
|
| 644 | 1 | $objWriter->writeAttribute('spid', $shapeId); |
|
| 645 | 1 | $objWriter->endElement(); |
|
| 646 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr\##p:tgtEl |
||
| 647 | 1 | $objWriter->endElement(); |
|
| 648 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:attrNameLst |
||
| 649 | 1 | $objWriter->startElement('p:attrNameLst'); |
|
| 650 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:attrNameLst/p:attrName |
||
| 651 | 1 | $objWriter->writeElement('p:attrName', 'style.visibility'); |
|
| 652 | // p:par/p:cTn/p:childTnLst/p:set/p:cBhvr\##p:attrNameLst |
||
| 653 | 1 | $objWriter->endElement(); |
|
| 654 | // p:par/p:cTn/p:childTnLst/p:set\##p:cBhvr |
||
| 655 | 1 | $objWriter->endElement(); |
|
| 656 | // p:par/p:cTn/p:childTnLst/p:set/p:to |
||
| 657 | 1 | $objWriter->startElement('p:to'); |
|
| 658 | // p:par/p:cTn/p:childTnLst/p:set/p:to/p:strVal |
||
| 659 | 1 | $objWriter->startElement('p:strVal'); |
|
| 660 | 1 | $objWriter->writeAttribute('val', 'visible'); |
|
| 661 | 1 | $objWriter->endElement(); |
|
| 662 | // p:par/p:cTn/p:childTnLst/p:set\##p:to |
||
| 663 | 1 | $objWriter->endElement(); |
|
| 664 | // p:par/p:cTn/p:childTnLst\##p:set |
||
| 665 | 1 | $objWriter->endElement(); |
|
| 666 | // p:par/p:cTn\##p:childTnLst |
||
| 667 | 1 | $objWriter->endElement(); |
|
| 668 | // p:par\##p:cTn |
||
| 669 | 1 | $objWriter->endElement(); |
|
| 670 | // ##p:par |
||
| 671 | 1 | $objWriter->endElement(); |
|
| 672 | |||
| 673 | 1 | $firstAnimation = false; |
|
| 674 | 1 | } |
|
| 675 | |||
| 676 | // 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 |
||
| 677 | 1 | $objWriter->endElement(); |
|
| 678 | // 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 |
||
| 679 | 1 | $objWriter->endElement(); |
|
| 680 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst\##p:par |
||
| 681 | 1 | $objWriter->endElement(); |
|
| 682 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn\##p:childTnLst |
||
| 683 | 1 | $objWriter->endElement(); |
|
| 684 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par\##p:cTn |
||
| 685 | 1 | $objWriter->endElement(); |
|
| 686 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst\##p:par |
||
| 687 | 1 | $objWriter->endElement(); |
|
| 688 | 1 | } |
|
| 689 | |||
| 690 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn\##p:childTnLst |
||
| 691 | 1 | $objWriter->endElement(); |
|
| 692 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq\##p:cTn |
||
| 693 | 1 | $objWriter->endElement(); |
|
| 694 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:prevCondLst |
||
| 695 | 1 | $objWriter->startElement('p:prevCondLst'); |
|
| 696 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:prevCondLst/p:cond |
||
| 697 | 1 | $objWriter->startElement('p:cond'); |
|
| 698 | 1 | $objWriter->writeAttribute('evt', 'onPrev'); |
|
| 699 | 1 | $objWriter->writeAttribute('delay', '0'); |
|
| 700 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:prevCondLst/p:cond/p:tgtEl |
||
| 701 | 1 | $objWriter->startElement('p:tgtEl'); |
|
| 702 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:prevCondLst/p:cond/p:tgtEl/p:sldTgt |
||
| 703 | 1 | $objWriter->writeElement('p:sldTgt', null); |
|
| 704 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:prevCondLst/p:cond\##p:tgtEl |
||
| 705 | 1 | $objWriter->endElement(); |
|
| 706 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:prevCondLst\##p:cond |
||
| 707 | 1 | $objWriter->endElement(); |
|
| 708 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq\##p:prevCondLst |
||
| 709 | 1 | $objWriter->endElement(); |
|
| 710 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:nextCondLst |
||
| 711 | 1 | $objWriter->startElement('p:nextCondLst'); |
|
| 712 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:nextCondLst/p:cond |
||
| 713 | 1 | $objWriter->startElement('p:cond'); |
|
| 714 | 1 | $objWriter->writeAttribute('evt', 'onNext'); |
|
| 715 | 1 | $objWriter->writeAttribute('delay', '0'); |
|
| 716 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:nextCondLst/p:cond/p:tgtEl |
||
| 717 | 1 | $objWriter->startElement('p:tgtEl'); |
|
| 718 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:nextCondLst/p:cond/p:tgtEl/p:sldTgt |
||
| 719 | 1 | $objWriter->writeElement('p:sldTgt', null); |
|
| 720 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:nextCondLst/p:cond\##p:tgtEl |
||
| 721 | 1 | $objWriter->endElement(); |
|
| 722 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:nextCondLst\##p:cond |
||
| 723 | 1 | $objWriter->endElement(); |
|
| 724 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq\##p:nextCondLst |
||
| 725 | 1 | $objWriter->endElement(); |
|
| 726 | // p:timing/p:tnLst/p:par/p:cTn/p:childTnLst\##p:seq |
||
| 727 | 1 | $objWriter->endElement(); |
|
| 728 | // p:timing/p:tnLst/p:par/p:cTn\##p:childTnLst |
||
| 729 | 1 | $objWriter->endElement(); |
|
| 730 | // p:timing/p:tnLst/p:par\##p:cTn |
||
| 731 | 1 | $objWriter->endElement(); |
|
| 732 | // p:timing/p:tnLst\##p:par |
||
| 733 | 1 | $objWriter->endElement(); |
|
| 734 | // p:timing\##p:tnLst |
||
| 735 | 1 | $objWriter->endElement(); |
|
| 736 | |||
| 737 | // p:timing/p:bldLst |
||
| 738 | 1 | $objWriter->startElement('p:bldLst'); |
|
| 739 | |||
| 740 | // Add in ids of all shapes in this slides animations |
||
| 741 | 1 | foreach ($arrayAnimationIds as $id) { |
|
| 742 | // p:timing/p:bldLst/p:bldP |
||
| 743 | 1 | $objWriter->startElement('p:bldP'); |
|
| 744 | 1 | $objWriter->writeAttribute('spid', $id); |
|
| 745 | 1 | $objWriter->writeAttribute('grpId', 0); |
|
| 746 | 1 | $objWriter->endELement(); |
|
| 747 | 1 | } |
|
| 748 | |||
| 749 | // p:timing\##p:bldLst |
||
| 750 | 1 | $objWriter->endElement(); |
|
| 751 | |||
| 752 | // ##p:timing |
||
| 753 | 1 | $objWriter->endElement(); |
|
| 754 | 1 | } |
|
| 755 | |||
| 756 | /** |
||
| 757 | * Write group |
||
| 758 | * |
||
| 759 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
| 760 | * @param \PhpOffice\PhpPresentation\Shape\Group $group |
||
| 761 | * @param int $shapeId |
||
| 762 | */ |
||
| 763 | 1 | protected function writeShapeGroup(XMLWriter $objWriter, Group $group, &$shapeId) |
|
| 823 | |||
| 824 | /** |
||
| 825 | * Write chart |
||
| 826 | * |
||
| 827 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
| 828 | * @param \PhpOffice\PhpPresentation\Shape\Chart $shape |
||
| 829 | * @param int $shapeId |
||
| 830 | */ |
||
| 831 | 24 | protected function writeShapeChart(XMLWriter $objWriter, ShapeChart $shape, $shapeId) |
|
| 898 | |||
| 899 | /** |
||
| 900 | * Write pic |
||
| 901 | * |
||
| 902 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
| 903 | * @param \PhpOffice\PhpPresentation\Shape\Drawing\AbstractDrawingAdapter $shape |
||
| 904 | * @param int $shapeId |
||
| 905 | * @throws \Exception |
||
| 906 | */ |
||
| 907 | protected function writeShapeDrawing(XMLWriter $objWriter, ShapeDrawing\AbstractDrawingAdapter $shape, $shapeId) |
||
| 1026 | |||
| 1027 | /** |
||
| 1028 | * Write txt |
||
| 1029 | * |
||
| 1030 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
| 1031 | * @param \PhpOffice\PhpPresentation\Shape\RichText $shape |
||
| 1032 | * @param int $shapeId |
||
| 1033 | * @throws \Exception |
||
| 1034 | */ |
||
| 1035 | 24 | protected function writeShapeText(XMLWriter $objWriter, RichText $shape, $shapeId) |
|
| 1172 | |||
| 1173 | /** |
||
| 1174 | * Write table |
||
| 1175 | * |
||
| 1176 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
| 1177 | * @param \PhpOffice\PhpPresentation\Shape\Table $shape |
||
| 1178 | * @param int $shapeId |
||
| 1179 | * @throws \Exception |
||
| 1180 | */ |
||
| 1181 | 9 | protected function writeShapeTable(XMLWriter $objWriter, ShapeTable $shape, $shapeId) |
|
| 1398 | |||
| 1399 | /** |
||
| 1400 | * Write paragraphs |
||
| 1401 | * |
||
| 1402 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
| 1403 | * @param \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] $paragraphs |
||
| 1404 | * @param bool $bIsPlaceholder |
||
| 1405 | * @throws \Exception |
||
| 1406 | */ |
||
| 1407 | 34 | protected function writeParagraphs(XMLWriter $objWriter, $paragraphs, $bIsPlaceholder = false) |
|
| 1527 | |||
| 1528 | /** |
||
| 1529 | * Write Line Shape |
||
| 1530 | * |
||
| 1531 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
| 1532 | * @param \PhpOffice\PhpPresentation\Shape\Line $shape |
||
| 1533 | * @param int $shapeId |
||
| 1534 | */ |
||
| 1535 | 1 | protected function writeShapeLine(XMLWriter $objWriter, Line $shape, $shapeId) |
|
| 1639 | |||
| 1640 | /** |
||
| 1641 | * Write hyperlink |
||
| 1642 | * |
||
| 1643 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
| 1644 | * @param \PhpOffice\PhpPresentation\AbstractShape|\PhpOffice\PhpPresentation\Shape\RichText\TextElement $shape |
||
| 1645 | */ |
||
| 1646 | 30 | protected function writeHyperlink(XMLWriter $objWriter, $shape) |
|
| 1660 | |||
| 1661 | /** |
||
| 1662 | * Write Note Slide |
||
| 1663 | * @param Note $pNote |
||
| 1664 | * @throws \Exception |
||
| 1665 | * @return string |
||
| 1666 | */ |
||
| 1667 | 1 | protected function writeNote(Note $pNote) |
|
| 1947 | |||
| 1948 | /** |
||
| 1949 | * Write Transition Slide |
||
| 1950 | * @link http://officeopenxml.com/prSlide-transitions.php |
||
| 1951 | * @param XMLWriter $objWriter |
||
| 1952 | * @param Transition $transition |
||
| 1953 | */ |
||
| 1954 | 98 | protected function writeSlideTransition(XMLWriter $objWriter, $transition) |
|
| 2201 | } |
||
| 2202 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: