PHPPowerPoint_Writer_PowerPoint2007
[ class tree: PHPPowerPoint_Writer_PowerPoint2007 ] [ index: PHPPowerPoint_Writer_PowerPoint2007 ] [ all elements ]

Source for file Presentation.php

Documentation is available at Presentation.php

  1. <?php
  2. /**
  3.  * PHPPowerPoint
  4.  *
  5.  * Copyright (c) 2009 - 2010 PHPPowerPoint
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  *
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  *
  21.  * @category   PHPPowerPoint
  22.  * @package    PHPPowerPoint_Writer_PowerPoint2007
  23.  * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    0.1.0, 2009-04-27
  26.  */
  27.  
  28.  
  29. /** PHPPowerPoint */
  30. require_once 'PHPPowerPoint.php';
  31.  
  32. /** PHPPowerPoint_Writer_PowerPoint2007 */
  33. require_once 'PHPPowerPoint/Writer/PowerPoint2007.php';
  34.  
  35. /** PHPPowerPoint_Writer_PowerPoint2007_WriterPart */
  36. require_once 'PHPPowerPoint/Writer/PowerPoint2007/WriterPart.php';
  37.  
  38. /** PHPPowerPoint_Slide */
  39. require_once 'PHPPowerPoint/Slide.php';
  40.  
  41. /** PHPPowerPoint_Shared_XMLWriter */
  42. require_once 'PHPPowerPoint/Shared/XMLWriter.php';
  43.  
  44.  
  45. /**
  46.  * PHPPowerPoint_Writer_PowerPoint2007_Workbook
  47.  *
  48.  * @category   PHPPowerPoint
  49.  * @package    PHPPowerPoint_Writer_PowerPoint2007
  50.  * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  51.  */
  52. {
  53.     /**
  54.      * Write presentation to XML format
  55.      *
  56.      * @param     PHPPowerPoint    $pPHPPowerPoint 
  57.      * @return     string         XML Output
  58.      * @throws     Exception
  59.      */
  60.     public function writePresentation(PHPPowerPoint $pPHPPowerPoint null)
  61.     {
  62.         // Create XML writer
  63.         $objWriter null;
  64.         if ($this->getParentWriter()->getUseDiskCaching()) {
  65.             $objWriter new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK$this->getParentWriter()->getDiskCachingDirectory());
  66.         else {
  67.             $objWriter new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY);
  68.         }
  69.  
  70.         // XML header
  71.         $objWriter->startDocument('1.0','UTF-8','yes');
  72.  
  73.         // p:presentation
  74.         $objWriter->startElement('p:presentation');
  75.         $objWriter->writeAttribute('xmlns:a''http://schemas.openxmlformats.org/drawingml/2006/main');
  76.         $objWriter->writeAttribute('xmlns:r''http://schemas.openxmlformats.org/officeDocument/2006/relationships');
  77.         $objWriter->writeAttribute('xmlns:p''http://schemas.openxmlformats.org/presentationml/2006/main');
  78.         
  79.             // p:sldMasterIdLst
  80.             $objWriter->startElement('p:sldMasterIdLst');
  81.             
  82.                 // p:sldMasterId
  83.                 $objWriter->startElement('p:sldMasterId');
  84.                 $objWriter->writeAttribute('id',    '2147483648');
  85.                 $objWriter->writeAttribute('r:id',    'rId1');
  86.                 $objWriter->endElement();
  87.                 
  88.             $objWriter->endElement();
  89.             
  90.             // p:sldIdLst
  91.             $objWriter->startElement('p:sldIdLst');
  92.             $this->_writeSlides($objWriter$pPHPPowerPoint);
  93.             $objWriter->endElement();
  94.  
  95.             // p:sldSz
  96.             $objWriter->startElement('p:sldSz');
  97.             $objWriter->writeAttribute('cx''9144000');
  98.             $objWriter->writeAttribute('cy''6858000');
  99.             $objWriter->endElement();
  100.             
  101.             // p:notesSz
  102.             $objWriter->startElement('p:notesSz');
  103.             $objWriter->writeAttribute('cx''6858000');
  104.             $objWriter->writeAttribute('cy''9144000');
  105.             $objWriter->endElement();
  106.  
  107.         $objWriter->endElement();
  108.  
  109.         // Return
  110.         return $objWriter->getData();
  111.     }
  112.  
  113.     /**
  114.      * Write slides
  115.      *
  116.      * @param     PHPPowerPoint_Shared_XMLWriter     $objWriter         XML Writer
  117.      * @param     PHPPowerPoint                    $pPHPPowerPoint 
  118.      * @throws     Exception
  119.      */
  120.     private function _writeSlides(PHPPowerPoint_Shared_XMLWriter $objWriter nullPHPPowerPoint $pPHPPowerPoint null)
  121.     {
  122.         // Write slides
  123.         $slideCount $pPHPPowerPoint->getSlideCount();
  124.         for ($i 0$i $slideCount++$i{
  125.             // p:sldId
  126.             $this->_writeSlide(
  127.                 $objWriter,
  128.                 ($i 256),
  129.                 ($i 2)
  130.             );
  131.         }
  132.     }
  133.  
  134.     /**
  135.      * Write slide
  136.      *
  137.      * @param     PHPPowerPoint_Shared_XMLWriter     $objWriter         XML Writer
  138.      * @param     int                            $pSlideId             Slide id
  139.      * @param     int                            $pRelId                Relationship ID
  140.      * @throws     Exception
  141.      */
  142.     private function _writeSlide(PHPPowerPoint_Shared_XMLWriter $objWriter null$pSlideId 1$pRelId 1)
  143.     {
  144.         // p:sldId
  145.         $objWriter->startElement('p:sldId');
  146.         $objWriter->writeAttribute('id',     $pSlideId);
  147.         $objWriter->writeAttribute('r:id',     'rId' $pRelId);
  148.         $objWriter->endElement();
  149.     }
  150. }

Documentation generated on Sat, 25 Apr 2009 11:37:48 +0200 by phpDocumentor 1.4.1