getDocumentProperties() публичный Метод

Get properties
public getDocumentProperties ( ) : PhpOffice\PhpPresentation\DocumentProperties
Результат PhpOffice\PhpPresentation\DocumentProperties
 public function testProperties()
 {
     $object = new PhpPresentation();
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getProperties());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->setProperties(new DocumentProperties()));
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getProperties());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $object->setDocumentProperties(new DocumentProperties()));
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getProperties());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\DocumentProperties', $object->getDocumentProperties());
 }
Пример #2
0
 public function testCompany()
 {
     $expected = 'aAbBcDeE';
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getDocumentProperties()->setCompany($expected);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($oXMLDoc->fileExists('docProps/app.xml'));
     $this->assertTrue($oXMLDoc->elementExists('/Properties/Company', 'docProps/app.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/Properties/Company', 'docProps/app.xml')->nodeValue);
 }
Пример #3
0
 public function testDocumentProperties()
 {
     $expected = 'aAbBcDeE';
     $oPhpPresentation = new PhpPresentation();
     $oPhpPresentation->getDocumentProperties()->setCreator($expected);
     $oPhpPresentation->getDocumentProperties()->setTitle($expected);
     $oPhpPresentation->getDocumentProperties()->setDescription($expected);
     $oPhpPresentation->getDocumentProperties()->setSubject($expected);
     $oPhpPresentation->getDocumentProperties()->setKeywords($expected);
     $oPhpPresentation->getDocumentProperties()->setCategory($expected);
     $oXMLDoc = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     $this->assertTrue($oXMLDoc->fileExists('docProps/core.xml'));
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:creator', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:creator', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:title', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:title', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:description', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:description', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/dc:subject', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/dc:subject', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/cp:keywords', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/cp:keywords', 'docProps/core.xml')->nodeValue);
     $this->assertTrue($oXMLDoc->elementExists('/cp:coreProperties/cp:category', 'docProps/core.xml'));
     $this->assertEquals($expected, $oXMLDoc->getElement('/cp:coreProperties/cp:category', 'docProps/core.xml')->nodeValue);
 }
Пример #4
0
 /**
  * Read Document Properties
  */
 protected function loadDocumentProperties()
 {
     $arrayProperties = array('/office:document-meta/office:meta/meta:initial-creator' => 'setCreator', '/office:document-meta/office:meta/dc:creator' => 'setLastModifiedBy', '/office:document-meta/office:meta/dc:title' => 'setTitle', '/office:document-meta/office:meta/dc:description' => 'setDescription', '/office:document-meta/office:meta/dc:subject' => 'setSubject', '/office:document-meta/office:meta/meta:keyword' => 'setKeywords', '/office:document-meta/office:meta/meta:creation-date' => 'setCreated', '/office:document-meta/office:meta/dc:date' => 'setModified');
     $oProperties = $this->oPhpPresentation->getDocumentProperties();
     foreach ($arrayProperties as $path => $property) {
         if (is_object($oElement = $this->oXMLReader->getElement($path))) {
             if (in_array($property, array('setCreated', 'setModified'))) {
                 $oDateTime = new \DateTime();
                 $oDateTime->createFromFormat(\DateTime::W3C, $oElement->nodeValue);
                 $oProperties->{$property}($oDateTime->getTimestamp());
             } else {
                 $oProperties->{$property}($oElement->nodeValue);
             }
         }
     }
 }
Пример #5
0
 /**
  * Read Document Properties
  * @param string $sPart
  */
 protected function loadDocumentProperties($sPart)
 {
     $xmlReader = new XMLReader();
     if ($xmlReader->getDomFromString($sPart)) {
         $arrayProperties = array('/cp:coreProperties/dc:creator' => 'setCreator', '/cp:coreProperties/cp:lastModifiedBy' => 'setLastModifiedBy', '/cp:coreProperties/dc:title' => 'setTitle', '/cp:coreProperties/dc:description' => 'setDescription', '/cp:coreProperties/dc:subject' => 'setSubject', '/cp:coreProperties/cp:keywords' => 'setKeywords', '/cp:coreProperties/cp:category' => 'setCategory', '/cp:coreProperties/dcterms:created' => 'setCreated', '/cp:coreProperties/dcterms:modified' => 'setModified');
         $oProperties = $this->oPhpPresentation->getDocumentProperties();
         foreach ($arrayProperties as $path => $property) {
             if (is_object($oElement = $xmlReader->getElement($path))) {
                 if ($oElement->hasAttribute('xsi:type') && $oElement->getAttribute('xsi:type') == 'dcterms:W3CDTF') {
                     $oDateTime = new \DateTime();
                     $oDateTime->createFromFormat(\DateTime::W3C, $oElement->nodeValue);
                     $oProperties->{$property}($oDateTime->getTimestamp());
                 } else {
                     $oProperties->{$property}($oElement->nodeValue);
                 }
             }
         }
     }
 }
Пример #6
0
 protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt)
 {
     $this->append('<div class="infoBlk" id="divPhpPresentationInfo">');
     $this->append('<dl>');
     $this->append('<dt>Number of slides</dt><dd>' . $oPHPPpt->getSlideCount() . '</dd>');
     $this->append('<dt>Document Layout Name</dt><dd>' . (empty($oPHPPpt->getLayout()->getDocumentLayout()) ? 'Custom' : $oPHPPpt->getLayout()->getDocumentLayout()) . '</dd>');
     $this->append('<dt>Document Layout Height</dt><dd>' . $oPHPPpt->getLayout()->getCY(DocumentLayout::UNIT_MILLIMETER) . ' mm</dd>');
     $this->append('<dt>Document Layout Width</dt><dd>' . $oPHPPpt->getLayout()->getCX(DocumentLayout::UNIT_MILLIMETER) . ' mm</dd>');
     $this->append('<dt>Properties : Category</dt><dd>' . $oPHPPpt->getDocumentProperties()->getCategory() . '</dd>');
     $this->append('<dt>Properties : Company</dt><dd>' . $oPHPPpt->getDocumentProperties()->getCompany() . '</dd>');
     $this->append('<dt>Properties : Created</dt><dd>' . $oPHPPpt->getDocumentProperties()->getCreated() . '</dd>');
     $this->append('<dt>Properties : Creator</dt><dd>' . $oPHPPpt->getDocumentProperties()->getCreator() . '</dd>');
     $this->append('<dt>Properties : Description</dt><dd>' . $oPHPPpt->getDocumentProperties()->getDescription() . '</dd>');
     $this->append('<dt>Properties : Keywords</dt><dd>' . $oPHPPpt->getDocumentProperties()->getKeywords() . '</dd>');
     $this->append('<dt>Properties : Last Modified By</dt><dd>' . $oPHPPpt->getDocumentProperties()->getLastModifiedBy() . '</dd>');
     $this->append('<dt>Properties : Modified</dt><dd>' . $oPHPPpt->getDocumentProperties()->getModified() . '</dd>');
     $this->append('<dt>Properties : Subject</dt><dd>' . $oPHPPpt->getDocumentProperties()->getSubject() . '</dd>');
     $this->append('<dt>Properties : Title</dt><dd>' . $oPHPPpt->getDocumentProperties()->getTitle() . '</dd>');
     $this->append('</dl>');
     $this->append('</div>');
     foreach ($oPHPPpt->getAllSlides() as $oSlide) {
         $this->append('<div class="infoBlk" id="div' . $oSlide->getHashCode() . 'Info">');
         $this->append('<dl>');
         $this->append('<dt>HashCode</dt><dd>' . $oSlide->getHashCode() . '</dd>');
         $this->append('<dt>Slide Layout</dt><dd>Layout::' . $this->getConstantName('\\PhpOffice\\PhpPresentation\\Slide\\Layout', $oSlide->getSlideLayout()) . '</dd>');
         $this->append('<dt>Offset X</dt><dd>' . $oSlide->getOffsetX() . '</dd>');
         $this->append('<dt>Offset Y</dt><dd>' . $oSlide->getOffsetY() . '</dd>');
         $this->append('<dt>Extent X</dt><dd>' . $oSlide->getExtentX() . '</dd>');
         $this->append('<dt>Extent Y</dt><dd>' . $oSlide->getExtentY() . '</dd>');
         $oBkg = $oSlide->getBackground();
         if ($oBkg instanceof Slide\AbstractBackground) {
             if ($oBkg instanceof Slide\Background\Color) {
                 $this->append('<dt>Background Color</dt><dd>#' . $oBkg->getColor()->getRGB() . '</dd>');
             }
             if ($oBkg instanceof Slide\Background\Image) {
                 $sBkgImgContents = file_get_contents($oBkg->getPath());
                 $this->append('<dt>Background Image</dt><dd><img src="data:image/png;base64,' . base64_encode($sBkgImgContents) . '"></dd>');
             }
         }
         $this->append('</dl>');
         $this->append('</div>');
         foreach ($oSlide->getShapeCollection() as $oShape) {
             if ($oShape instanceof Group) {
                 foreach ($oShape->getShapeCollection() as $oShapeChild) {
                     $this->displayShapeInfo($oShapeChild);
                 }
             } else {
                 $this->displayShapeInfo($oShape);
             }
         }
     }
 }
Пример #7
0
    echo date('H:i:s') . ' Create a shape (rich text) with list with red bullet' . EOL;
    $shape = $currentSlide->createRichTextShape();
    $shape->setHeight(100);
    $shape->setWidth(400);
    $shape->setOffsetX(100);
    $shape->setOffsetY(100);
    $shape->getActiveParagraph()->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET)->setBulletColor(new Color(Color::COLOR_RED));
    $shape->createTextRun('Alpha');
    $shape->createParagraph()->createTextRun('Beta');
    $shape->createParagraph()->createTextRun('Delta');
    $shape->createParagraph()->createTextRun('Epsilon');
}
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
// Set properties
echo date('H:i:s') . ' Set properties' . EOL;
$oProperties = $objPHPPresentation->getDocumentProperties();
$oProperties->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 11 Title')->setSubject('Sample 11 Subject')->setDescription('Sample 11 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
// Remove first slide
echo date('H:i:s') . ' Remove first slide' . EOL;
$objPHPPresentation->removeSlideByIndex(0);
fnSlideRichText($objPHPPresentation);
fnSlideRichTextLineSpacing($objPHPPresentation);
fnSlideRichTextShadow($objPHPPresentation);
fnSlideRichTextList($objPHPPresentation);
// Save file
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
}
Пример #8
0
<?php

include_once 'Sample_Header.php';
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Color;
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
// Set properties
echo date('H:i:s') . ' Set properties' . EOL;
$objPHPPresentation->getDocumentProperties()->setCreator('PHPOffice')->setLastModifiedBy('PHPPresentation Team')->setTitle('Sample 01 Title')->setSubject('Sample 01 Subject')->setDescription('Sample 01 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$currentSlide = $objPHPPresentation->getActiveSlide();
// Create a shape (drawing)
echo date('H:i:s') . ' Create a shape (drawing)' . EOL;
$shape = $currentSlide->createDrawingShape();
$shape->setName('PHPPresentation logo')->setDescription('PHPPresentation logo')->setPath('./resources/phppowerpoint_logo.gif')->setHeight(36)->setOffsetX(10)->setOffsetY(10);
$shape->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
$shape->getHyperlink()->setUrl('https://github.com/PHPOffice/PHPPresentation/')->setTooltip('PHPPresentation');
// Create a shape (text)
echo date('H:i:s') . ' Create a shape (rich text)' . EOL;
$shape = $currentSlide->createRichTextShape()->setHeight(300)->setWidth(600)->setOffsetX(170)->setOffsetY(180);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
$textRun = $shape->createTextRun('Thank you for using PHPPresentation!');
$textRun->getFont()->setBold(true)->setSize(60)->setColor(new Color('FFE06B20'));
// Save file
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
if (!CLI) {
    include_once 'Sample_Footer.php';
Пример #9
0
 /**
  * Write chart to XML format
  *
  * @param  PhpPresentation             $presentation
  * @param  \PhpOffice\PhpPresentation\Shape\Chart $chart
  * @param  string                    $tempName
  * @return string                    String output
  * @throws \Exception
  */
 public function writeSpreadsheet(PhpPresentation $presentation, $chart, $tempName)
 {
     // Need output?
     if (!$chart->hasIncludedSpreadsheet()) {
         throw new \Exception('No spreadsheet output is required for the given chart.');
     }
     // Verify PHPExcel
     if (!class_exists('PHPExcel')) {
         throw new \Exception('PHPExcel has not been loaded. Include PHPExcel.php in your script, e.g. require_once \'PHPExcel.php\'.');
     }
     // Create new spreadsheet
     $workbook = new \PHPExcel();
     // Set properties
     $title = $chart->getTitle()->getText();
     if (strlen($title) == 0) {
         $title = 'Chart';
     }
     $workbook->getProperties()->setCreator($presentation->getDocumentProperties()->getCreator())->setLastModifiedBy($presentation->getDocumentProperties()->getLastModifiedBy())->setTitle($title);
     // Add chart data
     $sheet = $workbook->setActiveSheetIndex(0);
     $sheet->setTitle('Sheet1');
     // Write series
     $seriesIndex = 0;
     foreach ($chart->getPlotArea()->getType()->getSeries() as $series) {
         // Title
         $sheet->setCellValueByColumnAndRow(1 + $seriesIndex, 1, $series->getTitle());
         // X-axis
         $axisXData = array_keys($series->getValues());
         $numAxisXData = count($axisXData);
         for ($i = 0; $i < $numAxisXData; $i++) {
             $sheet->setCellValueByColumnAndRow(0, $i + 2, $axisXData[$i]);
         }
         // Y-axis
         $axisYData = array_values($series->getValues());
         $numAxisYData = count($axisYData);
         for ($i = 0; $i < $numAxisYData; $i++) {
             $sheet->setCellValueByColumnAndRow(1 + $seriesIndex, $i + 2, $axisYData[$i]);
         }
         ++$seriesIndex;
     }
     // Save to string
     $writer = \PHPExcel_IOFactory::createWriter($workbook, 'Excel2007');
     $writer->save($tempName);
     // Load file in memory
     $returnValue = file_get_contents($tempName);
     if (@unlink($tempName) === false) {
         throw new \Exception('The file ' . $tempName . ' could not removed.');
     }
     return $returnValue;
 }