Example #1
0
 public function testTransition()
 {
     $object = new Slide();
     $oTransition = new Transition();
     $this->assertNull($object->getTransition());
     $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Slide', $object->setTransition());
     $this->assertNull($object->getTransition());
     $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Slide', $object->setTransition($oTransition));
     $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Slide\\Transition', $object->getTransition());
     $this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Slide', $object->setTransition(null));
     $this->assertNull($object->getTransition());
 }
Example #2
0
 /**
  * Write style of a slide
  * @param XMLWriter $objWriter
  * @param Slide $slide
  * @param int $incPage
  */
 public function writeStyleSlide(XMLWriter $objWriter, Slide $slide, $incPage)
 {
     // style:style
     $objWriter->startElement('style:style');
     $objWriter->writeAttribute('style:family', 'drawing-page');
     $objWriter->writeAttribute('style:name', 'stylePage' . $incPage);
     // style:style/style:drawing-page-properties
     $objWriter->startElement('style:drawing-page-properties');
     if (!is_null($oTransition = $slide->getTransition())) {
         $objWriter->writeAttribute('presentation:duration', 'PT' . number_format($oTransition->getAdvanceTimeTrigger() / 1000, 6, '.', '') . 'S');
         if ($oTransition->hasManualTrigger()) {
             $objWriter->writeAttribute('presentation:transition-type', 'manual');
         } elseif ($oTransition->hasTimeTrigger()) {
             $objWriter->writeAttribute('presentation:transition-type', 'automatic');
         }
         switch ($oTransition->getSpeed()) {
             case Transition::SPEED_FAST:
                 $objWriter->writeAttribute('presentation:transition-speed', 'fast');
                 break;
             case Transition::SPEED_MEDIUM:
                 $objWriter->writeAttribute('presentation:transition-speed', 'medium');
                 break;
             case Transition::SPEED_SLOW:
                 $objWriter->writeAttribute('presentation:transition-speed', 'slow');
                 break;
         }
         /**
          * http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#property-presentation_transition-style
          */
         switch ($oTransition->getTransitionType()) {
             case Transition::TRANSITION_BLINDS_HORIZONTAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'horizontal-stripes');
                 break;
             case Transition::TRANSITION_BLINDS_VERTICAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'vertical-stripes');
                 break;
             case Transition::TRANSITION_CHECKER_HORIZONTAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'horizontal-checkerboard');
                 break;
             case Transition::TRANSITION_CHECKER_VERTICAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'vertical-checkerboard');
                 break;
             case Transition::TRANSITION_CIRCLE_HORIZONTAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_CIRCLE_VERTICAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_COMB_HORIZONTAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_COMB_VERTICAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_COVER_DOWN:
                 $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-bottom');
                 break;
             case Transition::TRANSITION_COVER_LEFT:
                 $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-left');
                 break;
             case Transition::TRANSITION_COVER_LEFT_DOWN:
                 $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-lowerleft');
                 break;
             case Transition::TRANSITION_COVER_LEFT_UP:
                 $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-upperleft');
                 break;
             case Transition::TRANSITION_COVER_RIGHT:
                 $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-right');
                 break;
             case Transition::TRANSITION_COVER_RIGHT_DOWN:
                 $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-lowerright');
                 break;
             case Transition::TRANSITION_COVER_RIGHT_UP:
                 $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-upperright');
                 break;
             case Transition::TRANSITION_COVER_UP:
                 $objWriter->writeAttribute('presentation:transition-style', 'uncover-to-top');
                 break;
             case Transition::TRANSITION_CUT:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_DIAMOND:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_DISSOLVE:
                 $objWriter->writeAttribute('presentation:transition-style', 'dissolve');
                 break;
             case Transition::TRANSITION_FADE:
                 $objWriter->writeAttribute('presentation:transition-style', 'fade-from-center');
                 break;
             case Transition::TRANSITION_NEWSFLASH:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_PLUS:
                 $objWriter->writeAttribute('presentation:transition-style', 'close');
                 break;
             case Transition::TRANSITION_PULL_DOWN:
                 $objWriter->writeAttribute('presentation:transition-style', 'stretch-from-bottom');
                 break;
             case Transition::TRANSITION_PULL_LEFT:
                 $objWriter->writeAttribute('presentation:transition-style', 'stretch-from-left');
                 break;
             case Transition::TRANSITION_PULL_RIGHT:
                 $objWriter->writeAttribute('presentation:transition-style', 'stretch-from-right');
                 break;
             case Transition::TRANSITION_PULL_UP:
                 $objWriter->writeAttribute('presentation:transition-style', 'stretch-from-top');
                 break;
             case Transition::TRANSITION_PUSH_DOWN:
                 $objWriter->writeAttribute('presentation:transition-style', 'roll-from-bottom');
                 break;
             case Transition::TRANSITION_PUSH_LEFT:
                 $objWriter->writeAttribute('presentation:transition-style', 'roll-from-left');
                 break;
             case Transition::TRANSITION_PUSH_RIGHT:
                 $objWriter->writeAttribute('presentation:transition-style', 'roll-from-right');
                 break;
             case Transition::TRANSITION_PUSH_UP:
                 $objWriter->writeAttribute('presentation:transition-style', 'roll-from-top');
                 break;
             case Transition::TRANSITION_RANDOM:
                 $objWriter->writeAttribute('presentation:transition-style', 'random');
                 break;
             case Transition::TRANSITION_RANDOMBAR_HORIZONTAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'horizontal-lines');
                 break;
             case Transition::TRANSITION_RANDOMBAR_VERTICAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'vertical-lines');
                 break;
             case Transition::TRANSITION_SPLIT_IN_HORIZONTAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'close-horizontal');
                 break;
             case Transition::TRANSITION_SPLIT_OUT_HORIZONTAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'open-horizontal');
                 break;
             case Transition::TRANSITION_SPLIT_IN_VERTICAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'close-vertical');
                 break;
             case Transition::TRANSITION_SPLIT_OUT_VERTICAL:
                 $objWriter->writeAttribute('presentation:transition-style', 'open-vertical');
                 break;
             case Transition::TRANSITION_STRIPS_LEFT_DOWN:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_STRIPS_LEFT_UP:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_STRIPS_RIGHT_DOWN:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_STRIPS_RIGHT_UP:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_WEDGE:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_WIPE_DOWN:
                 $objWriter->writeAttribute('presentation:transition-style', 'fade-from-bottom');
                 break;
             case Transition::TRANSITION_WIPE_LEFT:
                 $objWriter->writeAttribute('presentation:transition-style', 'fade-from-left');
                 break;
             case Transition::TRANSITION_WIPE_RIGHT:
                 $objWriter->writeAttribute('presentation:transition-style', 'fade-from-right');
                 break;
             case Transition::TRANSITION_WIPE_UP:
                 $objWriter->writeAttribute('presentation:transition-style', 'fade-from-top');
                 break;
             case Transition::TRANSITION_ZOOM_IN:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
             case Transition::TRANSITION_ZOOM_OUT:
                 $objWriter->writeAttribute('presentation:transition-style', 'none');
                 break;
         }
     }
     $objWriter->endElement();
     // > style:style
     $objWriter->endElement();
 }