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


PHP PhpPresentation::createMasterSlide方法代码示例

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


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

示例1: loadMasterSlide

 private function loadMasterSlide($sPart, $baseFile)
 {
     $xmlReader = new XMLReader();
     if ($xmlReader->getDomFromString($sPart)) {
         // Core
         $oSlideMaster = $this->oPhpPresentation->createMasterSlide();
         $oSlideMaster->setTextStyles(new TextStyle(false));
         $oSlideMaster->setRelsIndex('ppt/slideMasters/_rels/' . $baseFile . '.rels');
         // Background
         $oElement = $xmlReader->getElement('/p:sldMaster/p:cSld/p:bg');
         if ($oElement) {
             $this->loadSlideBackground($xmlReader, $oElement, $oSlideMaster);
         }
         // Shapes
         $arrayElements = $xmlReader->getElements('/p:sldMaster/p:cSld/p:spTree/*');
         if ($arrayElements) {
             $this->loadSlideShapes($oSlideMaster, $arrayElements, $xmlReader);
         }
         // Header & Footer
         // ColorMapping
         $colorMap = array();
         $oElement = $xmlReader->getElement('/p:sldMaster/p:clrMap');
         if ($oElement->hasAttributes()) {
             foreach ($oElement->attributes as $attr) {
                 $colorMap[$attr->nodeName] = $attr->nodeValue;
             }
             $oSlideMaster->colorMap->setMapping($colorMap);
         }
         // TextStyles
         $arrayElementTxStyles = $xmlReader->getElements('/p:sldMaster/p:txStyles/*');
         if ($arrayElementTxStyles) {
             foreach ($arrayElementTxStyles as $oElementTxStyle) {
                 $arrayElementsLvl = $xmlReader->getElements('/p:sldMaster/p:txStyles/' . $oElementTxStyle->nodeName . '/*');
                 foreach ($arrayElementsLvl as $oElementLvl) {
                     if ($oElementLvl->nodeName == 'a:extLst') {
                         continue;
                     }
                     $oRTParagraph = new Paragraph();
                     if ($oElementLvl->nodeName == 'a:defPPr') {
                         $level = 0;
                     } else {
                         $level = str_replace('a:lvl', '', $oElementLvl->nodeName);
                         $level = str_replace('pPr', '', $level);
                     }
                     if ($oElementLvl->hasAttribute('algn')) {
                         $oRTParagraph->getAlignment()->setHorizontal($oElementLvl->getAttribute('algn'));
                     }
                     if ($oElementLvl->hasAttribute('marL')) {
                         $val = $oElementLvl->getAttribute('marL');
                         $val = CommonDrawing::emuToPixels($val);
                         $oRTParagraph->getAlignment()->setMarginLeft($val);
                     }
                     if ($oElementLvl->hasAttribute('marR')) {
                         $val = $oElementLvl->getAttribute('marR');
                         $val = CommonDrawing::emuToPixels($val);
                         $oRTParagraph->getAlignment()->setMarginRight($val);
                     }
                     if ($oElementLvl->hasAttribute('indent')) {
                         $val = $oElementLvl->getAttribute('indent');
                         $val = CommonDrawing::emuToPixels($val);
                         $oRTParagraph->getAlignment()->setIndent($val);
                     }
                     $oElementLvlDefRPR = $xmlReader->getElement('a:defRPr', $oElementLvl);
                     if ($oElementLvlDefRPR) {
                         if ($oElementLvlDefRPR->hasAttribute('sz')) {
                             $oRTParagraph->getFont()->setSize($oElementLvlDefRPR->getAttribute('sz') / 100);
                         }
                         if ($oElementLvlDefRPR->hasAttribute('b') && $oElementLvlDefRPR->getAttribute('b') == 1) {
                             $oRTParagraph->getFont()->setBold(true);
                         }
                         if ($oElementLvlDefRPR->hasAttribute('i') && $oElementLvlDefRPR->getAttribute('i') == 1) {
                             $oRTParagraph->getFont()->setItalic(true);
                         }
                     }
                     $oElementSchemeColor = $xmlReader->getElement('a:defRPr/a:solidFill/a:schemeClr', $oElementLvl);
                     if ($oElementSchemeColor) {
                         if ($oElementSchemeColor->hasAttribute('val')) {
                             $oRTParagraph->getFont()->setColor(new SchemeColor())->getColor()->setValue($oElementSchemeColor->getAttribute('val'));
                         }
                     }
                     switch ($oElementTxStyle->nodeName) {
                         case 'p:bodyStyle':
                             $oSlideMaster->getTextStyles()->setBodyStyleAtLvl($oRTParagraph, $level);
                             break;
                         case 'p:otherStyle':
                             $oSlideMaster->getTextStyles()->setOtherStyleAtLvl($oRTParagraph, $level);
                             break;
                         case 'p:titleStyle':
                             $oSlideMaster->getTextStyles()->setTitleStyleAtLvl($oRTParagraph, $level);
                             break;
                     }
                 }
             }
         }
         // Load the theme
         foreach ($this->arrayRels[$oSlideMaster->getRelsIndex()] as $arrayRel) {
             if ($arrayRel['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme') {
                 $pptTheme = $this->oZip->getFromName('ppt/' . substr($arrayRel['Target'], strrpos($arrayRel['Target'], '../') + 3));
                 if ($pptTheme !== false) {
                     $this->loadTheme($pptTheme, $oSlideMaster);
//.........这里部分代码省略.........
开发者ID:phpoffice,项目名称:phppowerpoint,代码行数:101,代码来源:PowerPoint2007.php


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