当前位置: 首页>>代码示例>>PHP>>正文


PHP PhpPresentation::getLayout方法代码示例

本文整理汇总了PHP中PhpOffice\PhpPresentation\PhpPresentation::getLayout方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpPresentation::getLayout方法的具体用法?PHP PhpPresentation::getLayout怎么用?PHP PhpPresentation::getLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhpOffice\PhpPresentation\PhpPresentation的用法示例。


在下文中一共展示了PhpPresentation::getLayout方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testConstruct

 /**
  * Test create new instance
  */
 public function testConstruct()
 {
     $object = new PhpPresentation();
     $slide = $object->getSlide();
     $this->assertEquals(new DocumentProperties(), $object->getDocumentProperties());
     $this->assertEquals(new DocumentLayout(), $object->getLayout());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide', $object->getSlide());
     $this->assertEquals(1, count($object->getAllSlides()));
     $this->assertEquals(0, $object->getIndex($slide));
     $this->assertEquals(1, $object->getSlideCount());
     $this->assertEquals(0, $object->getActiveSlideIndex());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Slide\\Iterator', $object->getSlideIterator());
 }
开发者ID:phpoffice,项目名称:phppowerpoint,代码行数:16,代码来源:PhpPresentationTest.php

示例2: loadDocumentLayout

 /**
  * Read Document Layout
  * @param $sPart
  */
 protected function loadDocumentLayout($sPart)
 {
     $xmlReader = new XMLReader();
     if ($xmlReader->getDomFromString($sPart)) {
         foreach ($xmlReader->getElements('/p:presentation/p:sldSz') as $oElement) {
             $type = $oElement->getAttribute('type');
             $oLayout = $this->oPhpPresentation->getLayout();
             if ($type == DocumentLayout::LAYOUT_CUSTOM) {
                 $oLayout->setCX($oElement->getAttribute('cx'));
                 $oLayout->setCY($oElement->getAttribute('cy'));
             } else {
                 $oLayout->setDocumentLayout($type, true);
                 if ($oElement->getAttribute('cx') < $oElement->getAttribute('cy')) {
                     $oLayout->setDocumentLayout($type, false);
                 }
             }
         }
     }
 }
开发者ID:phpoffice,项目名称:phppowerpoint,代码行数:23,代码来源:PowerPoint2007.php

示例3: displayPhpPresentationInfo

 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);
             }
         }
     }
 }
开发者ID:phpoffice,项目名称:phppowerpoint,代码行数:52,代码来源:Sample_Header.php

示例4: date

<?php

include_once 'Sample_Header.php';
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Style\Alignment;
use PhpOffice\PhpPresentation\Style\Color;
use PhpOffice\PhpPresentation\Style\Fill;
use PhpOffice\PhpPresentation\Style\Border;
// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();
$oLayout = $objPHPPresentation->getLayout();
// 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'));
// Set Note
开发者ID:phpoffice,项目名称:phppowerpoint,代码行数:31,代码来源:Sample_09_SlideNote.php

示例5: testNote

 public function testNote()
 {
     $oPhpPresentation = new PhpPresentation();
     $oLayout = $oPhpPresentation->getLayout();
     $oSlide = $oPhpPresentation->getActiveSlide();
     $oNote = $oSlide->getNote();
     $oRichText = $oNote->createRichTextShape()->setHeight($oLayout->getCY($oLayout::UNIT_PIXEL))->setWidth($oLayout->getCX($oLayout::UNIT_PIXEL))->setOffsetX(170)->setOffsetY(180);
     $oRichText->createTextRun('testNote');
     $pres = TestHelperDOCX::getDocument($oPhpPresentation, 'PowerPoint2007');
     // Content Types
     // $element = '/Types/Override[@PartName="/ppt/notesSlides/notesSlide1.xml"][@ContentType="application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml"]';
     // $this->assertTrue($pres->elementExists($element, '[Content_Types].xml'));
     // Rels
     // $element = '/Relationships/Relationship[@Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide"][@Target="../notesSlides/notesSlide1.xml"]';
     // $this->assertTrue($pres->elementExists($element, 'ppt/slides/_rels/slide1.xml.rels'));
     // Slide
     $element = '/p:notes';
     $this->assertTrue($pres->elementExists($element, 'ppt/notesSlides/notesSlide1.xml'));
     // Slide Image Placeholder 1
     $element = '/p:notes/p:cSld/p:spTree/p:sp/p:nvSpPr/p:cNvPr[@id="2"][@name="Slide Image Placeholder 1"]';
     $this->assertTrue($pres->elementExists($element, 'ppt/notesSlides/notesSlide1.xml'));
     $element = '/p:notes/p:cSld/p:spTree/p:sp[1]/p:spPr/a:xfrm/a:off';
     $this->assertEquals(0, $pres->getElementAttribute($element, 'x', 'ppt/notesSlides/notesSlide1.xml'));
     $this->assertEquals(0, $pres->getElementAttribute($element, 'y', 'ppt/notesSlides/notesSlide1.xml'));
     $element = '/p:notes/p:cSld/p:spTree/p:sp[1]/p:spPr/a:xfrm/a:ext';
     $this->assertEquals(Drawing::pixelsToEmu(round($oNote->getExtentX() / 2)), $pres->getElementAttribute($element, 'cx', 'ppt/notesSlides/notesSlide1.xml'));
     $this->assertEquals(Drawing::pixelsToEmu(round($oNote->getExtentY() / 2)), $pres->getElementAttribute($element, 'cy', 'ppt/notesSlides/notesSlide1.xml'));
     // Notes Placeholder
     $element = '/p:notes/p:cSld/p:spTree/p:sp/p:nvSpPr/p:cNvPr[@id="3"][@name="Notes Placeholder"]';
     $this->assertTrue($pres->elementExists($element, 'ppt/notesSlides/notesSlide1.xml'));
     // Notes
     $element = '/p:notes/p:cSld/p:spTree/p:sp[2]/p:spPr/a:xfrm/a:off';
     $this->assertEquals(Drawing::pixelsToEmu($oNote->getOffsetX()), $pres->getElementAttribute($element, 'x', 'ppt/notesSlides/notesSlide1.xml'));
     $this->assertEquals(Drawing::pixelsToEmu(round($oNote->getExtentY() / 2) + $oNote->getOffsetY()), $pres->getElementAttribute($element, 'y', 'ppt/notesSlides/notesSlide1.xml'));
     $element = '/p:notes/p:cSld/p:spTree/p:sp[2]/p:spPr/a:xfrm/a:ext';
     $this->assertEquals(5486400, $pres->getElementAttribute($element, 'cx', 'ppt/notesSlides/notesSlide1.xml'));
     $this->assertEquals(3600450, $pres->getElementAttribute($element, 'cy', 'ppt/notesSlides/notesSlide1.xml'));
     $element = '/p:notes/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:t';
     $this->assertTrue($pres->elementExists($element, 'ppt/notesSlides/notesSlide1.xml'));
 }
开发者ID:phpoffice,项目名称:phppowerpoint,代码行数:40,代码来源:PptSlidesTest.php

示例6: writePart

 /**
  * Write Meta file to XML format
  *
  * @param  PhpPresentation $pPhpPresentation
  * @return string        XML Output
  * @throws \Exception
  */
 public function writePart(PhpPresentation $pPhpPresentation)
 {
     // Create XML writer
     $objWriter = $this->getXMLWriter();
     // XML header
     $objWriter->startDocument('1.0', 'UTF-8');
     // office:document-meta
     $objWriter->startElement('office:document-styles');
     $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
     $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0');
     $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0');
     $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0');
     $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0');
     $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0');
     $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
     $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
     $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
     $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0');
     $objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0');
     $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0');
     $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0');
     $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0');
     $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML');
     $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0');
     $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0');
     $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
     $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer');
     $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc');
     $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events');
     $objWriter->writeAttribute('xmlns:smil', 'urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0');
     $objWriter->writeAttribute('xmlns:anim', 'urn:oasis:names:tc:opendocument:xmlns:animation:1.0');
     $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report');
     $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2');
     $objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml');
     $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
     $objWriter->writeAttribute('xmlns:officeooo', 'http://openoffice.org/2009/office');
     $objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table');
     $objWriter->writeAttribute('xmlns:drawooo', 'http://openoffice.org/2010/draw');
     $objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/');
     $objWriter->writeAttribute('office:version', '1.2');
     // Variables
     $stylePageLayout = $pPhpPresentation->getLayout()->getDocumentLayout();
     // office:styles
     $objWriter->startElement('office:styles');
     // style:style
     $objWriter->startElement('style:style');
     $objWriter->writeAttribute('style:name', 'sPres0');
     $objWriter->writeAttribute('style:display-name', 'sPres0');
     $objWriter->writeAttribute('style:family', 'presentation');
     // style:graphic-properties
     $objWriter->startElement('style:graphic-properties');
     $objWriter->writeAttribute('draw:fill-color', '#ffffff');
     // > style:graphic-properties
     $objWriter->endElement();
     // > style:style
     $objWriter->endElement();
     foreach ($pPhpPresentation->getAllSlides() as $slide) {
         foreach ($slide->getShapeCollection() as $shape) {
             if ($shape instanceof Table) {
                 $this->writeTableStyle($objWriter, $shape);
             } elseif ($shape instanceof Group) {
                 $this->writeGroupStyle($objWriter, $shape);
             } elseif ($shape instanceof RichText) {
                 $this->writeRichTextStyle($objWriter, $shape);
             }
         }
     }
     // > office:styles
     $objWriter->endElement();
     // office:automatic-styles
     $objWriter->startElement('office:automatic-styles');
     // style:page-layout
     $objWriter->startElement('style:page-layout');
     if (empty($stylePageLayout)) {
         $objWriter->writeAttribute('style:name', 'sPL0');
     } else {
         $objWriter->writeAttribute('style:name', $stylePageLayout);
     }
     // style:page-layout-properties
     $objWriter->startElement('style:page-layout-properties');
     $objWriter->writeAttribute('fo:margin-top', '0cm');
     $objWriter->writeAttribute('fo:margin-bottom', '0cm');
     $objWriter->writeAttribute('fo:margin-left', '0cm');
     $objWriter->writeAttribute('fo:margin-right', '0cm');
     $objWriter->writeAttribute('fo:page-width', Text::numberFormat(CommonDrawing::pixelsToCentimeters(CommonDrawing::emuToPixels($pPhpPresentation->getLayout()->getCX())), 1) . 'cm');
     $objWriter->writeAttribute('fo:page-height', Text::numberFormat(CommonDrawing::pixelsToCentimeters(CommonDrawing::emuToPixels($pPhpPresentation->getLayout()->getCY())), 1) . 'cm');
     if ($pPhpPresentation->getLayout()->getCX() > $pPhpPresentation->getLayout()->getCY()) {
         $objWriter->writeAttribute('style:print-orientation', 'landscape');
     } else {
         $objWriter->writeAttribute('style:print-orientation', 'portrait');
     }
     $objWriter->endElement();
     $objWriter->endElement();
//.........这里部分代码省略.........
开发者ID:hxsam,项目名称:PHPPresentation,代码行数:101,代码来源:Styles.php

示例7: displayPhpPresentationInfo

 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 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->getProperties()->getCategory() . '</dd>');
     $this->append('<dt>Properties : Company</dt><dd>' . $oPHPPpt->getProperties()->getCompany() . '</dd>');
     $this->append('<dt>Properties : Created</dt><dd>' . $oPHPPpt->getProperties()->getCreated() . '</dd>');
     $this->append('<dt>Properties : Creator</dt><dd>' . $oPHPPpt->getProperties()->getCreator() . '</dd>');
     $this->append('<dt>Properties : Description</dt><dd>' . $oPHPPpt->getProperties()->getDescription() . '</dd>');
     $this->append('<dt>Properties : Keywords</dt><dd>' . $oPHPPpt->getProperties()->getKeywords() . '</dd>');
     $this->append('<dt>Properties : Last Modified By</dt><dd>' . $oPHPPpt->getProperties()->getLastModifiedBy() . '</dd>');
     $this->append('<dt>Properties : Modified</dt><dd>' . $oPHPPpt->getProperties()->getModified() . '</dd>');
     $this->append('<dt>Properties : Subject</dt><dd>' . $oPHPPpt->getProperties()->getSubject() . '</dd>');
     $this->append('<dt>Properties : Title</dt><dd>' . $oPHPPpt->getProperties()->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>');
         $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);
             }
         }
     }
 }
开发者ID:hxsam,项目名称:PHPPresentation,代码行数:41,代码来源:Sample_Header.php


注:本文中的PhpOffice\PhpPresentation\PhpPresentation::getLayout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。