Complex classes like PowerPoint2007 often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use PowerPoint2007, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 45 | class PowerPoint2007 implements ReaderInterface |
||
| 46 | { |
||
| 47 | /** |
||
| 48 | * Output Object |
||
| 49 | * @var PhpPresentation |
||
| 50 | */ |
||
| 51 | protected $oPhpPresentation; |
||
| 52 | /** |
||
| 53 | * Output Object |
||
| 54 | * @var \ZipArchive |
||
| 55 | */ |
||
| 56 | protected $oZip; |
||
| 57 | /** |
||
| 58 | * @var array[] |
||
| 59 | */ |
||
| 60 | protected $arrayRels = array(); |
||
| 61 | /** |
||
| 62 | * @var SlideLayout[] |
||
| 63 | */ |
||
| 64 | protected $arraySlideLayouts = array(); |
||
| 65 | /* |
||
| 66 | * @var string |
||
| 67 | */ |
||
| 68 | protected $filename; |
||
| 69 | /* |
||
| 70 | * @var string |
||
| 71 | */ |
||
| 72 | protected $fileRels; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Can the current \PhpOffice\PhpPresentation\Reader\ReaderInterface read the file? |
||
| 76 | * |
||
| 77 | * @param string $pFilename |
||
| 78 | * @throws \Exception |
||
| 79 | * @return boolean |
||
| 80 | */ |
||
| 81 | 2 | public function canRead($pFilename) |
|
| 85 | |||
| 86 | /** |
||
| 87 | * Does a file support UnserializePhpPresentation ? |
||
| 88 | * |
||
| 89 | * @param string $pFilename |
||
| 90 | * @throws \Exception |
||
| 91 | * @return boolean |
||
| 92 | */ |
||
| 93 | 9 | public function fileSupportsUnserializePhpPresentation($pFilename = '') |
|
| 111 | |||
| 112 | /** |
||
| 113 | * Loads PhpPresentation Serialized file |
||
| 114 | * |
||
| 115 | * @param string $pFilename |
||
| 116 | * @return \PhpOffice\PhpPresentation\PhpPresentation |
||
| 117 | * @throws \Exception |
||
| 118 | */ |
||
| 119 | 6 | public function load($pFilename) |
|
| 128 | |||
| 129 | /** |
||
| 130 | * Load PhpPresentation Serialized file |
||
| 131 | * |
||
| 132 | * @param string $pFilename |
||
| 133 | * @return \PhpOffice\PhpPresentation\PhpPresentation |
||
| 134 | * @throws \Exception |
||
| 135 | */ |
||
| 136 | 4 | protected function loadFile($pFilename) |
|
| 168 | |||
| 169 | /** |
||
| 170 | * Read Document Layout |
||
| 171 | * @param $sPart |
||
| 172 | */ |
||
| 173 | 4 | protected function loadDocumentLayout($sPart) |
|
| 174 | { |
||
| 175 | 4 | $xmlReader = new XMLReader(); |
|
| 176 | 4 | if ($xmlReader->getDomFromString($sPart)) { |
|
| 177 | 4 | foreach ($xmlReader->getElements('/p:presentation/p:sldSz') as $oElement) { |
|
| 178 | 4 | if (!($oElement instanceof \DOMElement)) { |
|
| 179 | continue; |
||
| 180 | } |
||
| 181 | 4 | $type = $oElement->getAttribute('type'); |
|
| 182 | 4 | $oLayout = $this->oPhpPresentation->getLayout(); |
|
| 183 | 4 | if ($type == DocumentLayout::LAYOUT_CUSTOM) { |
|
| 184 | $oLayout->setCX($oElement->getAttribute('cx')); |
||
| 185 | $oLayout->setCY($oElement->getAttribute('cy')); |
||
| 186 | } else { |
||
| 187 | 4 | $oLayout->setDocumentLayout($type, true); |
|
| 188 | 4 | if ($oElement->getAttribute('cx') < $oElement->getAttribute('cy')) { |
|
| 189 | $oLayout->setDocumentLayout($type, false); |
||
| 190 | } |
||
| 191 | } |
||
| 192 | } |
||
| 193 | } |
||
| 194 | 4 | } |
|
| 195 | |||
| 196 | /** |
||
| 197 | * Read Document Properties |
||
| 198 | * @param string $sPart |
||
| 199 | */ |
||
| 200 | 4 | protected function loadDocumentProperties($sPart) |
|
| 230 | |||
| 231 | /** |
||
| 232 | * Read Custom Properties |
||
| 233 | * @param string $sPart |
||
| 234 | */ |
||
| 235 | 1 | protected function loadCustomProperties($sPart) |
|
| 248 | |||
| 249 | /** |
||
| 250 | * Read View Properties |
||
| 251 | * @param string $sPart |
||
| 252 | */ |
||
| 253 | 4 | protected function loadViewProperties($sPart) |
|
| 266 | |||
| 267 | /** |
||
| 268 | * Extract all slides |
||
| 269 | * @param $sPart |
||
| 270 | * @throws \Exception |
||
| 271 | */ |
||
| 272 | 4 | protected function loadSlides($sPart) |
|
| 273 | { |
||
| 274 | 4 | $xmlReader = new XMLReader(); |
|
| 275 | 4 | if ($xmlReader->getDomFromString($sPart)) { |
|
| 276 | 4 | $fileRels = 'ppt/_rels/presentation.xml.rels'; |
|
| 277 | 4 | $this->loadRels($fileRels); |
|
| 278 | // Load the Masterslides |
||
| 279 | 4 | $this->loadMasterSlides($xmlReader, $fileRels); |
|
| 280 | // Continue with loading the slides |
||
| 281 | 4 | foreach ($xmlReader->getElements('/p:presentation/p:sldIdLst/p:sldId') as $oElement) { |
|
| 282 | 4 | if (!($oElement instanceof \DOMElement)) { |
|
| 283 | continue; |
||
| 284 | } |
||
| 285 | 4 | $rId = $oElement->getAttribute('r:id'); |
|
| 286 | 4 | $pathSlide = isset($this->arrayRels[$fileRels][$rId]) ? $this->arrayRels[$fileRels][$rId]['Target'] : ''; |
|
| 287 | 4 | if (!empty($pathSlide)) { |
|
| 288 | 4 | $pptSlide = $this->oZip->getFromName('ppt/' . $pathSlide); |
|
| 289 | 4 | if ($pptSlide !== false) { |
|
| 290 | 4 | $slideRels = 'ppt/slides/_rels/' . basename($pathSlide) . '.rels'; |
|
| 291 | 4 | $this->loadRels($slideRels); |
|
| 292 | 4 | $this->loadSlide($pptSlide, basename($pathSlide)); |
|
| 293 | 4 | foreach ($this->arrayRels[$slideRels] as $rel) { |
|
| 294 | 4 | if ($rel['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide') { |
|
| 295 | $this->loadSlideNote(basename($rel['Target']), $this->oPhpPresentation->getActiveSlide()); |
||
| 296 | } |
||
| 297 | } |
||
| 298 | } |
||
| 299 | } |
||
| 300 | } |
||
| 301 | } |
||
| 302 | 4 | } |
|
| 303 | |||
| 304 | /** |
||
| 305 | * Extract all MasterSlides |
||
| 306 | * @param XMLReader $xmlReader |
||
| 307 | * @param string $fileRels |
||
| 308 | * @throws \Exception |
||
| 309 | */ |
||
| 310 | 4 | protected function loadMasterSlides(XMLReader $xmlReader, $fileRels) |
|
| 330 | |||
| 331 | /** |
||
| 332 | * Extract data from slide |
||
| 333 | * @param string $sPart |
||
| 334 | * @param string $baseFile |
||
| 335 | * @throws \Exception |
||
| 336 | */ |
||
| 337 | 4 | protected function loadSlide($sPart, $baseFile) |
|
| 420 | |||
| 421 | /** |
||
| 422 | * @param string $sPart |
||
| 423 | * @param string $baseFile |
||
| 424 | * @throws \Exception |
||
| 425 | */ |
||
| 426 | 4 | protected function loadMasterSlide($sPart, $baseFile) |
|
| 562 | |||
| 563 | /** |
||
| 564 | * @param string $sPart |
||
| 565 | * @param string $baseFile |
||
| 566 | * @param SlideMaster $oSlideMaster |
||
| 567 | * @return SlideLayout|null |
||
| 568 | * @throws \Exception |
||
| 569 | */ |
||
| 570 | 4 | protected function loadLayoutSlide($sPart, $baseFile, SlideMaster $oSlideMaster) |
|
| 610 | |||
| 611 | /** |
||
| 612 | * @param string $sPart |
||
| 613 | * @param SlideMaster $oSlideMaster |
||
| 614 | */ |
||
| 615 | 4 | protected function loadTheme($sPart, SlideMaster $oSlideMaster) |
|
| 637 | |||
| 638 | /** |
||
| 639 | * @param XMLReader $xmlReader |
||
| 640 | * @param \DOMElement $oElement |
||
| 641 | * @param AbstractSlide $oSlide |
||
| 642 | * @throws \Exception |
||
| 643 | */ |
||
| 644 | 4 | protected function loadSlideBackground(XMLReader $xmlReader, \DOMElement $oElement, AbstractSlide $oSlide) |
|
| 699 | |||
| 700 | /** |
||
| 701 | * @param string $baseFile |
||
| 702 | * @param Slide $oSlide |
||
| 703 | * @throws \Exception |
||
| 704 | */ |
||
| 705 | protected function loadSlideNote($baseFile, Slide $oSlide) |
||
| 718 | |||
| 719 | /** |
||
| 720 | * @param XMLReader $document |
||
| 721 | * @param \DOMElement $node |
||
| 722 | * @param AbstractSlide $oSlide |
||
| 723 | * @throws \Exception |
||
| 724 | */ |
||
| 725 | 3 | protected function loadShapeDrawing(XMLReader $document, \DOMElement $node, AbstractSlide $oSlide) |
|
| 726 | { |
||
| 727 | // Core |
||
| 728 | 3 | $oShape = new Gd(); |
|
| 729 | 3 | $oShape->getShadow()->setVisible(false); |
|
| 730 | // Variables |
||
| 731 | 3 | $fileRels = $oSlide->getRelsIndex(); |
|
| 732 | |||
| 733 | 3 | $oElement = $document->getElement('p:nvPicPr/p:cNvPr', $node); |
|
| 734 | 3 | if ($oElement instanceof \DOMElement) { |
|
| 735 | 3 | $oShape->setName($oElement->hasAttribute('name') ? $oElement->getAttribute('name') : ''); |
|
| 736 | 3 | $oShape->setDescription($oElement->hasAttribute('descr') ? $oElement->getAttribute('descr') : ''); |
|
| 737 | |||
| 738 | // Hyperlink |
||
| 739 | 3 | $oElementHlinkClick = $document->getElement('a:hlinkClick', $oElement); |
|
| 740 | 3 | if (is_object($oElementHlinkClick)) { |
|
| 741 | 1 | if ($oElementHlinkClick->hasAttribute('tooltip')) { |
|
|
|
|||
| 742 | 1 | $oShape->getHyperlink()->setTooltip($oElementHlinkClick->getAttribute('tooltip')); |
|
| 743 | } |
||
| 744 | 1 | if ($oElementHlinkClick->hasAttribute('r:id') && isset($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target'])) { |
|
| 745 | 1 | $oShape->getHyperlink()->setUrl($this->arrayRels[$fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target']); |
|
| 746 | } |
||
| 747 | } |
||
| 748 | } |
||
| 749 | |||
| 750 | 3 | $oElement = $document->getElement('p:blipFill/a:blip', $node); |
|
| 751 | 3 | if ($oElement instanceof \DOMElement) { |
|
| 752 | 3 | if ($oElement->hasAttribute('r:embed') && isset($this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')]['Target'])) { |
|
| 753 | 3 | $pathImage = 'ppt/slides/' . $this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')]['Target']; |
|
| 754 | 3 | $pathImage = explode('/', $pathImage); |
|
| 755 | 3 | foreach ($pathImage as $key => $partPath) { |
|
| 756 | 3 | if ($partPath == '..') { |
|
| 757 | 3 | unset($pathImage[$key - 1]); |
|
| 758 | 3 | unset($pathImage[$key]); |
|
| 759 | } |
||
| 760 | } |
||
| 761 | 3 | $pathImage = implode('/', $pathImage); |
|
| 762 | 3 | $imageFile = $this->oZip->getFromName($pathImage); |
|
| 763 | 3 | if (!empty($imageFile)) { |
|
| 764 | 3 | $info = getimagesizefromstring($imageFile); |
|
| 765 | 3 | $oShape->setMimeType($info['mime']); |
|
| 766 | 3 | $oShape->setRenderingFunction(str_replace('/', '', $info['mime'])); |
|
| 767 | 3 | $oShape->setImageResource(imagecreatefromstring($imageFile)); |
|
| 768 | } |
||
| 769 | } |
||
| 770 | } |
||
| 771 | |||
| 772 | 3 | $oElement = $document->getElement('p:spPr', $node); |
|
| 773 | 3 | if ($oElement instanceof \DOMElement) { |
|
| 774 | 3 | $oFill = $this->loadStyleFill($document, $oElement); |
|
| 775 | 3 | $oShape->setFill($oFill); |
|
| 776 | } |
||
| 777 | |||
| 778 | 3 | $oElement = $document->getElement('p:spPr/a:xfrm', $node); |
|
| 779 | 3 | if ($oElement instanceof \DOMElement) { |
|
| 780 | 3 | if ($oElement->hasAttribute('rot')) { |
|
| 781 | 3 | $oShape->setRotation(CommonDrawing::angleToDegrees($oElement->getAttribute('rot'))); |
|
| 782 | } |
||
| 783 | } |
||
| 784 | |||
| 785 | 3 | $oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node); |
|
| 786 | 3 | if ($oElement instanceof \DOMElement) { |
|
| 787 | 3 | if ($oElement->hasAttribute('x')) { |
|
| 788 | 3 | $oShape->setOffsetX(CommonDrawing::emuToPixels($oElement->getAttribute('x'))); |
|
| 789 | } |
||
| 790 | 3 | if ($oElement->hasAttribute('y')) { |
|
| 791 | 3 | $oShape->setOffsetY(CommonDrawing::emuToPixels($oElement->getAttribute('y'))); |
|
| 792 | } |
||
| 793 | } |
||
| 794 | |||
| 795 | 3 | $oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node); |
|
| 796 | 3 | if ($oElement instanceof \DOMElement) { |
|
| 797 | 3 | if ($oElement->hasAttribute('cx')) { |
|
| 798 | 3 | $oShape->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('cx'))); |
|
| 799 | } |
||
| 800 | 3 | if ($oElement->hasAttribute('cy')) { |
|
| 801 | 3 | $oShape->setHeight(CommonDrawing::emuToPixels($oElement->getAttribute('cy'))); |
|
| 802 | } |
||
| 803 | } |
||
| 804 | |||
| 805 | 3 | $oElement = $document->getElement('p:spPr/a:effectLst', $node); |
|
| 806 | 3 | if ($oElement instanceof \DOMElement) { |
|
| 807 | 3 | $oShape->getShadow()->setVisible(true); |
|
| 808 | |||
| 809 | 3 | $oSubElement = $document->getElement('a:outerShdw', $oElement); |
|
| 810 | 3 | if ($oSubElement instanceof \DOMElement) { |
|
| 811 | 3 | if ($oSubElement->hasAttribute('blurRad')) { |
|
| 812 | 3 | $oShape->getShadow()->setBlurRadius(CommonDrawing::emuToPixels($oSubElement->getAttribute('blurRad'))); |
|
| 813 | } |
||
| 814 | 3 | if ($oSubElement->hasAttribute('dist')) { |
|
| 815 | 3 | $oShape->getShadow()->setDistance(CommonDrawing::emuToPixels($oSubElement->getAttribute('dist'))); |
|
| 816 | } |
||
| 817 | 3 | if ($oSubElement->hasAttribute('dir')) { |
|
| 818 | 3 | $oShape->getShadow()->setDirection(CommonDrawing::angleToDegrees($oSubElement->getAttribute('dir'))); |
|
| 819 | } |
||
| 820 | 3 | if ($oSubElement->hasAttribute('algn')) { |
|
| 821 | 3 | $oShape->getShadow()->setAlignment($oSubElement->getAttribute('algn')); |
|
| 822 | } |
||
| 823 | } |
||
| 824 | |||
| 825 | 3 | $oSubElement = $document->getElement('a:outerShdw/a:srgbClr', $oElement); |
|
| 826 | 3 | if ($oSubElement instanceof \DOMElement) { |
|
| 827 | 3 | if ($oSubElement->hasAttribute('val')) { |
|
| 828 | 3 | $oColor = new Color(); |
|
| 829 | 3 | $oColor->setRGB($oSubElement->getAttribute('val')); |
|
| 830 | 3 | $oShape->getShadow()->setColor($oColor); |
|
| 831 | } |
||
| 832 | } |
||
| 833 | |||
| 834 | 3 | $oSubElement = $document->getElement('a:outerShdw/a:srgbClr/a:alpha', $oElement); |
|
| 835 | 3 | if ($oSubElement instanceof \DOMElement) { |
|
| 836 | 3 | if ($oSubElement->hasAttribute('val')) { |
|
| 837 | 3 | $oShape->getShadow()->setAlpha((int)$oSubElement->getAttribute('val') / 1000); |
|
| 838 | } |
||
| 839 | } |
||
| 840 | } |
||
| 841 | |||
| 842 | 3 | $oSlide->addShape($oShape); |
|
| 843 | 3 | } |
|
| 844 | |||
| 845 | /** |
||
| 846 | * @param XMLReader $document |
||
| 847 | * @param \DOMElement $node |
||
| 848 | * @param AbstractSlide $oSlide |
||
| 849 | * @throws \Exception |
||
| 850 | */ |
||
| 851 | 4 | protected function loadShapeRichText(XMLReader $document, \DOMElement $node, $oSlide) |
|
| 852 | { |
||
| 853 | 4 | if (!$document->elementExists('p:txBody/a:p/a:r', $node)) { |
|
| 854 | 4 | return; |
|
| 855 | } |
||
| 856 | // Core |
||
| 857 | 4 | $oShape = $oSlide->createRichTextShape(); |
|
| 858 | 4 | $oShape->setParagraphs(array()); |
|
| 859 | // Variables |
||
| 860 | 4 | if ($oSlide instanceof AbstractSlide) { |
|
| 861 | 4 | $this->fileRels = $oSlide->getRelsIndex(); |
|
| 862 | } |
||
| 863 | |||
| 864 | 4 | $oElement = $document->getElement('p:spPr/a:xfrm', $node); |
|
| 865 | 4 | if ($oElement instanceof \DOMElement && $oElement->hasAttribute('rot')) { |
|
| 866 | 4 | $oShape->setRotation(CommonDrawing::angleToDegrees($oElement->getAttribute('rot'))); |
|
| 867 | } |
||
| 868 | |||
| 869 | 4 | $oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node); |
|
| 870 | 4 | if ($oElement instanceof \DOMElement) { |
|
| 871 | 4 | if ($oElement->hasAttribute('x')) { |
|
| 872 | 4 | $oShape->setOffsetX(CommonDrawing::emuToPixels($oElement->getAttribute('x'))); |
|
| 873 | } |
||
| 874 | 4 | if ($oElement->hasAttribute('y')) { |
|
| 875 | 4 | $oShape->setOffsetY(CommonDrawing::emuToPixels($oElement->getAttribute('y'))); |
|
| 876 | } |
||
| 877 | } |
||
| 878 | |||
| 879 | 4 | $oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node); |
|
| 880 | 4 | if ($oElement instanceof \DOMElement) { |
|
| 881 | 4 | if ($oElement->hasAttribute('cx')) { |
|
| 882 | 4 | $oShape->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('cx'))); |
|
| 883 | } |
||
| 884 | 4 | if ($oElement->hasAttribute('cy')) { |
|
| 885 | 4 | $oShape->setHeight(CommonDrawing::emuToPixels($oElement->getAttribute('cy'))); |
|
| 886 | } |
||
| 887 | } |
||
| 888 | |||
| 889 | 4 | $oElement = $document->getElement('p:nvSpPr/p:nvPr/p:ph', $node); |
|
| 890 | 4 | if ($oElement instanceof \DOMElement) { |
|
| 891 | 4 | if ($oElement->hasAttribute('type')) { |
|
| 892 | 4 | $placeholder = new Placeholder($oElement->getAttribute('type')); |
|
| 893 | 4 | $oShape->setPlaceHolder($placeholder); |
|
| 894 | } |
||
| 895 | } |
||
| 896 | |||
| 897 | 4 | $arrayElements = $document->getElements('p:txBody/a:p', $node); |
|
| 898 | 4 | foreach ($arrayElements as $oElement) { |
|
| 899 | 4 | $this->loadParagraph($document, $oElement, $oShape); |
|
| 900 | } |
||
| 901 | |||
| 902 | 4 | if (count($oShape->getParagraphs()) > 0) { |
|
| 903 | 4 | $oShape->setActiveParagraph(0); |
|
| 904 | } |
||
| 905 | 4 | } |
|
| 906 | |||
| 907 | /** |
||
| 908 | * @param XMLReader $document |
||
| 909 | * @param \DOMElement $node |
||
| 910 | * @param AbstractSlide $oSlide |
||
| 911 | * @throws \Exception |
||
| 912 | */ |
||
| 913 | protected function loadShapeTable(XMLReader $document, \DOMElement $node, AbstractSlide $oSlide) |
||
| 1047 | |||
| 1048 | /** |
||
| 1049 | * @param XMLReader $document |
||
| 1050 | * @param \DOMElement $oElement |
||
| 1051 | * @param Cell|RichText $oShape |
||
| 1052 | * @throws \Exception |
||
| 1053 | */ |
||
| 1054 | 4 | protected function loadParagraph(XMLReader $document, \DOMElement $oElement, $oShape) |
|
| 1055 | { |
||
| 1056 | // Core |
||
| 1057 | 4 | $oParagraph = $oShape->createParagraph(); |
|
| 1058 | 4 | $oParagraph->setRichTextElements(array()); |
|
| 1059 | |||
| 1060 | 4 | $oSubElement = $document->getElement('a:pPr', $oElement); |
|
| 1061 | 4 | if ($oSubElement instanceof \DOMElement) { |
|
| 1062 | 4 | if ($oSubElement->hasAttribute('algn')) { |
|
| 1063 | 3 | $oParagraph->getAlignment()->setHorizontal($oSubElement->getAttribute('algn')); |
|
| 1064 | } |
||
| 1065 | 4 | if ($oSubElement->hasAttribute('fontAlgn')) { |
|
| 1066 | 3 | $oParagraph->getAlignment()->setVertical($oSubElement->getAttribute('fontAlgn')); |
|
| 1067 | } |
||
| 1068 | 4 | if ($oSubElement->hasAttribute('marL')) { |
|
| 1069 | 3 | $oParagraph->getAlignment()->setMarginLeft(CommonDrawing::emuToPixels($oSubElement->getAttribute('marL'))); |
|
| 1070 | } |
||
| 1071 | 4 | if ($oSubElement->hasAttribute('marR')) { |
|
| 1072 | 3 | $oParagraph->getAlignment()->setMarginRight(CommonDrawing::emuToPixels($oSubElement->getAttribute('marR'))); |
|
| 1073 | } |
||
| 1074 | 4 | if ($oSubElement->hasAttribute('indent')) { |
|
| 1075 | 3 | $oParagraph->getAlignment()->setIndent(CommonDrawing::emuToPixels($oSubElement->getAttribute('indent'))); |
|
| 1076 | } |
||
| 1077 | 4 | if ($oSubElement->hasAttribute('lvl')) { |
|
| 1078 | 4 | $oParagraph->getAlignment()->setLevel($oSubElement->getAttribute('lvl')); |
|
| 1079 | } |
||
| 1080 | |||
| 1081 | 4 | $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE); |
|
| 1082 | |||
| 1083 | 4 | $oElementBuFont = $document->getElement('a:buFont', $oSubElement); |
|
| 1084 | 4 | if ($oElementBuFont instanceof \DOMElement) { |
|
| 1085 | 3 | if ($oElementBuFont->hasAttribute('typeface')) { |
|
| 1086 | 3 | $oParagraph->getBulletStyle()->setBulletFont($oElementBuFont->getAttribute('typeface')); |
|
| 1087 | } |
||
| 1088 | } |
||
| 1089 | 4 | $oElementBuChar = $document->getElement('a:buChar', $oSubElement); |
|
| 1090 | 4 | if ($oElementBuChar instanceof \DOMElement) { |
|
| 1091 | 3 | $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET); |
|
| 1092 | 3 | if ($oElementBuChar->hasAttribute('char')) { |
|
| 1093 | 3 | $oParagraph->getBulletStyle()->setBulletChar($oElementBuChar->getAttribute('char')); |
|
| 1094 | } |
||
| 1095 | } |
||
| 1096 | 4 | $oElementBuAutoNum = $document->getElement('a:buAutoNum', $oSubElement); |
|
| 1097 | 4 | if ($oElementBuAutoNum instanceof \DOMElement) { |
|
| 1098 | $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NUMERIC); |
||
| 1099 | if ($oElementBuAutoNum->hasAttribute('type')) { |
||
| 1100 | $oParagraph->getBulletStyle()->setBulletNumericStyle($oElementBuAutoNum->getAttribute('type')); |
||
| 1101 | } |
||
| 1102 | if ($oElementBuAutoNum->hasAttribute('startAt') && $oElementBuAutoNum->getAttribute('startAt') != 1) { |
||
| 1103 | $oParagraph->getBulletStyle()->setBulletNumericStartAt($oElementBuAutoNum->getAttribute('startAt')); |
||
| 1104 | } |
||
| 1105 | } |
||
| 1106 | 4 | $oElementBuClr = $document->getElement('a:buClr', $oSubElement); |
|
| 1107 | 4 | if ($oElementBuClr instanceof \DOMElement) { |
|
| 1108 | $oColor = new Color(); |
||
| 1109 | /** |
||
| 1110 | * @todo Create protected for reading Color |
||
| 1111 | */ |
||
| 1112 | $oElementColor = $document->getElement('a:srgbClr', $oElementBuClr); |
||
| 1113 | if ($oElementColor instanceof \DOMElement) { |
||
| 1114 | $oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null); |
||
| 1115 | } |
||
| 1116 | $oParagraph->getBulletStyle()->setBulletColor($oColor); |
||
| 1117 | } |
||
| 1118 | } |
||
| 1119 | 4 | $arraySubElements = $document->getElements('(a:r|a:br)', $oElement); |
|
| 1120 | 4 | foreach ($arraySubElements as $oSubElement) { |
|
| 1121 | 4 | if ($oSubElement->tagName == 'a:br') { |
|
| 1122 | 3 | $oParagraph->createBreak(); |
|
| 1123 | } |
||
| 1124 | 4 | if ($oSubElement->tagName == 'a:r') { |
|
| 1125 | 4 | $oElementrPr = $document->getElement('a:rPr', $oSubElement); |
|
| 1126 | 4 | if (is_object($oElementrPr)) { |
|
| 1127 | 4 | $oText = $oParagraph->createTextRun(); |
|
| 1128 | |||
| 1129 | 4 | if ($oElementrPr->hasAttribute('b')) { |
|
| 1130 | 3 | $att = $oElementrPr->getAttribute('b'); |
|
| 1131 | 3 | $oText->getFont()->setBold($att == 'true' || $att == '1' ? true : false); |
|
| 1132 | } |
||
| 1133 | 4 | if ($oElementrPr->hasAttribute('i')) { |
|
| 1134 | 3 | $att = $oElementrPr->getAttribute('i'); |
|
| 1135 | 3 | $oText->getFont()->setItalic($att == 'true' || $att == '1' ? true : false); |
|
| 1136 | } |
||
| 1137 | 4 | if ($oElementrPr->hasAttribute('strike')) { |
|
| 1138 | 3 | $oText->getFont()->setStrikethrough($oElementrPr->getAttribute('strike') == 'noStrike' ? false : true); |
|
| 1139 | } |
||
| 1140 | 4 | if ($oElementrPr->hasAttribute('sz')) { |
|
| 1141 | 3 | $oText->getFont()->setSize((int)($oElementrPr->getAttribute('sz') / 100)); |
|
| 1142 | } |
||
| 1143 | 4 | if ($oElementrPr->hasAttribute('u')) { |
|
| 1144 | 3 | $oText->getFont()->setUnderline($oElementrPr->getAttribute('u')); |
|
| 1145 | } |
||
| 1146 | // Color |
||
| 1147 | 4 | $oElementSrgbClr = $document->getElement('a:solidFill/a:srgbClr', $oElementrPr); |
|
| 1148 | 4 | if (is_object($oElementSrgbClr) && $oElementSrgbClr->hasAttribute('val')) { |
|
| 1149 | 3 | $oColor = new Color(); |
|
| 1150 | 3 | $oColor->setRGB($oElementSrgbClr->getAttribute('val')); |
|
| 1151 | 3 | $oText->getFont()->setColor($oColor); |
|
| 1152 | } |
||
| 1153 | // Hyperlink |
||
| 1154 | 4 | $oElementHlinkClick = $document->getElement('a:hlinkClick', $oElementrPr); |
|
| 1155 | 4 | if (is_object($oElementHlinkClick)) { |
|
| 1156 | 3 | if ($oElementHlinkClick->hasAttribute('tooltip')) { |
|
| 1157 | 3 | $oText->getHyperlink()->setTooltip($oElementHlinkClick->getAttribute('tooltip')); |
|
| 1158 | } |
||
| 1159 | 3 | if ($oElementHlinkClick->hasAttribute('r:id') && isset($this->arrayRels[$this->fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target'])) { |
|
| 1160 | 3 | $oText->getHyperlink()->setUrl($this->arrayRels[$this->fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target']); |
|
| 1161 | } |
||
| 1162 | } |
||
| 1163 | //} else { |
||
| 1164 | // $oText = $oParagraph->createText(); |
||
| 1165 | |||
| 1166 | 4 | $oSubSubElement = $document->getElement('a:t', $oSubElement); |
|
| 1167 | 4 | $oText->setText($oSubSubElement->nodeValue); |
|
| 1168 | } |
||
| 1169 | } |
||
| 1170 | } |
||
| 1171 | 4 | } |
|
| 1172 | |||
| 1173 | /** |
||
| 1174 | * @param XMLReader $xmlReader |
||
| 1175 | * @param \DOMElement $oElement |
||
| 1176 | * @param Border $oBorder |
||
| 1177 | * @throws \Exception |
||
| 1178 | */ |
||
| 1179 | protected function loadStyleBorder(XMLReader $xmlReader, \DOMElement $oElement, Border $oBorder) |
||
| 1203 | |||
| 1204 | /** |
||
| 1205 | * @param XMLReader $xmlReader |
||
| 1206 | * @param \DOMElement $oElement |
||
| 1207 | * @return Color |
||
| 1208 | */ |
||
| 1209 | protected function loadStyleColor(XMLReader $xmlReader, \DOMElement $oElement) |
||
| 1220 | |||
| 1221 | /** |
||
| 1222 | * @param XMLReader $xmlReader |
||
| 1223 | * @param \DOMElement $oElement |
||
| 1224 | * @return null|Fill |
||
| 1225 | * @throws \Exception |
||
| 1226 | */ |
||
| 1227 | 3 | protected function loadStyleFill(XMLReader $xmlReader, \DOMElement $oElement) |
|
| 1266 | |||
| 1267 | /** |
||
| 1268 | * @param string $fileRels |
||
| 1269 | */ |
||
| 1270 | 4 | protected function loadRels($fileRels) |
|
| 1288 | |||
| 1289 | /** |
||
| 1290 | * @param $oSlide |
||
| 1291 | * @param \DOMNodeList $oElements |
||
| 1292 | * @param XMLReader $xmlReader |
||
| 1293 | * @throws \Exception |
||
| 1294 | * @internal param $baseFile |
||
| 1295 | */ |
||
| 1296 | 4 | protected function loadSlideShapes($oSlide, $oElements, $xmlReader) |
|
| 1314 | } |
||
| 1315 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.