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 |
||
| 46 | class PowerPoint2007 implements ReaderInterface |
||
| 47 | { |
||
| 48 | /** |
||
| 49 | * Output Object |
||
| 50 | * @var PhpPresentation |
||
| 51 | */ |
||
| 52 | protected $oPhpPresentation; |
||
| 53 | /** |
||
| 54 | * Output Object |
||
| 55 | * @var \ZipArchive |
||
| 56 | */ |
||
| 57 | protected $oZip; |
||
| 58 | /** |
||
| 59 | * @var array[] |
||
| 60 | */ |
||
| 61 | protected $arrayRels = array(); |
||
| 62 | /** |
||
| 63 | * @var SlideLayout[] |
||
| 64 | */ |
||
| 65 | protected $arraySlideLayouts = array(); |
||
| 66 | /* |
||
| 67 | * @var string |
||
| 68 | */ |
||
| 69 | protected $filename; |
||
| 70 | /* |
||
| 71 | * @var string |
||
| 72 | */ |
||
| 73 | protected $fileRels; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Can the current \PhpOffice\PhpPresentation\Reader\ReaderInterface read the file? |
||
| 77 | * |
||
| 78 | * @param string $pFilename |
||
| 79 | * @throws \Exception |
||
| 80 | * @return boolean |
||
| 81 | */ |
||
| 82 | 2 | public function canRead($pFilename) |
|
| 86 | |||
| 87 | /** |
||
| 88 | * Does a file support UnserializePhpPresentation ? |
||
| 89 | * |
||
| 90 | * @param string $pFilename |
||
| 91 | * @throws \Exception |
||
| 92 | * @return boolean |
||
| 93 | */ |
||
| 94 | 9 | public function fileSupportsUnserializePhpPresentation($pFilename = '') |
|
| 112 | |||
| 113 | /** |
||
| 114 | * Loads PhpPresentation Serialized file |
||
| 115 | * |
||
| 116 | * @param string $pFilename |
||
| 117 | * @return \PhpOffice\PhpPresentation\PhpPresentation |
||
| 118 | * @throws \Exception |
||
| 119 | */ |
||
| 120 | 6 | public function load($pFilename) |
|
| 129 | |||
| 130 | /** |
||
| 131 | * Load PhpPresentation Serialized file |
||
| 132 | * |
||
| 133 | * @param string $pFilename |
||
| 134 | * @return \PhpOffice\PhpPresentation\PhpPresentation |
||
| 135 | */ |
||
| 136 | 4 | protected function loadFile($pFilename) |
|
| 168 | |||
| 169 | /** |
||
| 170 | * Read Document Layout |
||
| 171 | * @param $sPart |
||
| 172 | */ |
||
| 173 | 4 | protected function loadDocumentLayout($sPart) |
|
| 192 | |||
| 193 | /** |
||
| 194 | * Read Document Properties |
||
| 195 | * @param string $sPart |
||
| 196 | */ |
||
| 197 | 4 | protected function loadDocumentProperties($sPart) |
|
| 227 | |||
| 228 | /** |
||
| 229 | * Read Custom Properties |
||
| 230 | * @param string $sPart |
||
| 231 | */ |
||
| 232 | 1 | protected function loadCustomProperties($sPart) |
|
| 245 | |||
| 246 | /** |
||
| 247 | * Read View Properties |
||
| 248 | * @param string $sPart |
||
| 249 | */ |
||
| 250 | 4 | protected function loadViewProperties($sPart) |
|
| 263 | |||
| 264 | /** |
||
| 265 | * Extract all slides |
||
| 266 | */ |
||
| 267 | 4 | protected function loadSlides($sPart) |
|
| 289 | |||
| 290 | /** |
||
| 291 | * Extract all MasterSlides |
||
| 292 | * @param XMLReader $xmlReader |
||
| 293 | * @param string $fileRels |
||
| 294 | */ |
||
| 295 | 4 | protected function loadMasterSlides(XMLReader $xmlReader, $fileRels) |
|
| 312 | |||
| 313 | /** |
||
| 314 | * Extract data from slide |
||
| 315 | * @param string $sPart |
||
| 316 | * @param string $baseFile |
||
| 317 | */ |
||
| 318 | 4 | protected function loadSlide($sPart, $baseFile) |
|
| 389 | |||
| 390 | /** |
||
| 391 | * @param string $baseFile |
||
| 392 | */ |
||
| 393 | 4 | private function loadMasterSlide($sPart, $baseFile) |
|
| 526 | |||
| 527 | /** |
||
| 528 | * @param string $sPart |
||
| 529 | * @param string $baseFile |
||
| 530 | * @param SlideMaster $oSlideMaster |
||
| 531 | */ |
||
| 532 | 4 | private function loadLayoutSlide($sPart, $baseFile, SlideMaster $oSlideMaster) |
|
| 572 | |||
| 573 | /** |
||
| 574 | * @param string $sPart |
||
| 575 | * @param SlideMaster $oSlideMaster |
||
| 576 | */ |
||
| 577 | 4 | private function loadTheme($sPart, SlideMaster $oSlideMaster) |
|
| 599 | |||
| 600 | /** |
||
| 601 | * @param XMLReader $xmlReader |
||
| 602 | * @param \DOMElement $oElement |
||
| 603 | * @param AbstractSlide $oSlide |
||
| 604 | */ |
||
| 605 | 4 | private function loadSlideBackground(XMLReader $xmlReader, \DOMElement $oElement, AbstractSlide $oSlide) |
|
| 660 | |||
| 661 | /** |
||
| 662 | * @param XMLReader $document |
||
| 663 | * @param \DOMElement $node |
||
| 664 | * @param AbstractSlide $oSlide |
||
| 665 | */ |
||
| 666 | 3 | protected function loadShapeDrawing(XMLReader $document, \DOMElement $node, AbstractSlide $oSlide) |
|
| 765 | |||
| 766 | /** |
||
| 767 | * @param XMLReader $document |
||
| 768 | * @param \DOMElement $node |
||
| 769 | * @param AbstractSlide $oSlide |
||
| 770 | * @throws \Exception |
||
| 771 | */ |
||
| 772 | 4 | protected function loadShapeRichText(XMLReader $document, \DOMElement $node, AbstractSlide $oSlide) |
|
| 822 | |||
| 823 | /** |
||
| 824 | * @param XMLReader $document |
||
| 825 | * @param \DOMElement $oElement |
||
| 826 | * @param Cell|RichText $oShape |
||
| 827 | * @throws \Exception |
||
| 828 | */ |
||
| 829 | 4 | protected function loadParagraph(XMLReader $document, \DOMElement $oElement, $oShape) |
|
| 830 | { |
||
| 831 | // Core |
||
| 832 | 4 | $oParagraph = $oShape->createParagraph(); |
|
| 833 | 4 | $oParagraph->setRichTextElements(array()); |
|
| 834 | |||
| 835 | 4 | $oSubElement = $document->getElement('a:pPr', $oElement); |
|
| 836 | 4 | if ($oSubElement instanceof \DOMElement) { |
|
| 837 | 4 | if ($oSubElement->hasAttribute('algn')) { |
|
| 838 | 4 | $oParagraph->getAlignment()->setHorizontal($oSubElement->getAttribute('algn')); |
|
| 839 | } |
||
| 840 | 4 | if ($oSubElement->hasAttribute('fontAlgn')) { |
|
| 841 | 3 | $oParagraph->getAlignment()->setVertical($oSubElement->getAttribute('fontAlgn')); |
|
| 842 | } |
||
| 843 | 4 | if ($oSubElement->hasAttribute('marL')) { |
|
| 844 | 4 | $oParagraph->getAlignment()->setMarginLeft(CommonDrawing::emuToPixels($oSubElement->getAttribute('marL'))); |
|
| 845 | } |
||
| 846 | 4 | if ($oSubElement->hasAttribute('marR')) { |
|
| 847 | 3 | $oParagraph->getAlignment()->setMarginRight(CommonDrawing::emuToPixels($oSubElement->getAttribute('marR'))); |
|
| 848 | } |
||
| 849 | 4 | if ($oSubElement->hasAttribute('indent')) { |
|
| 850 | 3 | $oParagraph->getAlignment()->setIndent(CommonDrawing::emuToPixels($oSubElement->getAttribute('indent'))); |
|
| 851 | } |
||
| 852 | 4 | if ($oSubElement->hasAttribute('lvl')) { |
|
| 853 | 4 | $oParagraph->getAlignment()->setLevel($oSubElement->getAttribute('lvl')); |
|
| 854 | } |
||
| 855 | |||
| 856 | 4 | $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE); |
|
| 857 | |||
| 858 | 4 | $oElementBuFont = $document->getElement('a:buFont', $oSubElement); |
|
| 859 | 4 | if ($oElementBuFont instanceof \DOMElement) { |
|
| 860 | 3 | if ($oElementBuFont->hasAttribute('typeface')) { |
|
| 861 | 3 | $oParagraph->getBulletStyle()->setBulletFont($oElementBuFont->getAttribute('typeface')); |
|
| 862 | } |
||
| 863 | } |
||
| 864 | 4 | $oElementBuChar = $document->getElement('a:buChar', $oSubElement); |
|
| 865 | 4 | if ($oElementBuChar instanceof \DOMElement) { |
|
| 866 | 3 | $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET); |
|
| 867 | 3 | if ($oElementBuChar->hasAttribute('char')) { |
|
| 868 | 3 | $oParagraph->getBulletStyle()->setBulletChar($oElementBuChar->getAttribute('char')); |
|
| 869 | } |
||
| 870 | } |
||
| 871 | 4 | $oElementBuAutoNum = $document->getElement('a:buAutoNum', $oSubElement); |
|
| 872 | 4 | if ($oElementBuAutoNum instanceof \DOMElement) { |
|
| 873 | $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NUMERIC); |
||
| 874 | if ($oElementBuAutoNum->hasAttribute('type')) { |
||
| 875 | $oParagraph->getBulletStyle()->setBulletNumericStyle($oElementBuAutoNum->getAttribute('type')); |
||
| 876 | } |
||
| 877 | if ($oElementBuAutoNum->hasAttribute('startAt') && $oElementBuAutoNum->getAttribute('startAt') != 1) { |
||
| 878 | $oParagraph->getBulletStyle()->setBulletNumericStartAt($oElementBuAutoNum->getAttribute('startAt')); |
||
| 879 | } |
||
| 880 | } |
||
| 881 | 4 | $oElementBuClr = $document->getElement('a:buClr', $oSubElement); |
|
| 882 | 4 | if ($oElementBuClr instanceof \DOMElement) { |
|
| 883 | $oColor = new Color(); |
||
| 884 | /** |
||
| 885 | * @todo Create protected for reading Color |
||
| 886 | */ |
||
| 887 | $oElementColor = $document->getElement('a:srgbClr', $oElementBuClr); |
||
| 888 | if ($oElementColor instanceof \DOMElement) { |
||
| 889 | $oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null); |
||
| 890 | } |
||
| 891 | $oParagraph->getBulletStyle()->setBulletColor($oColor); |
||
| 892 | } |
||
| 893 | } |
||
| 894 | 4 | $arraySubElements = $document->getElements('(a:r|a:br)', $oElement); |
|
| 895 | 4 | foreach ($arraySubElements as $oSubElement) { |
|
| 896 | 4 | if ($oSubElement->tagName == 'a:br') { |
|
| 897 | 3 | $oParagraph->createBreak(); |
|
| 898 | } |
||
| 899 | 4 | if ($oSubElement->tagName == 'a:r') { |
|
| 900 | 4 | $oElementrPr = $document->getElement('a:rPr', $oSubElement); |
|
| 901 | 4 | if (is_object($oElementrPr)) { |
|
| 902 | 4 | $oText = $oParagraph->createTextRun(); |
|
| 903 | |||
| 904 | 4 | if ($oElementrPr->hasAttribute('b')) { |
|
|
|
|||
| 905 | 3 | $att = $oElementrPr->getAttribute('b'); |
|
| 906 | 3 | $oText->getFont()->setBold($att == 'true' || $att == '1' ? true : false); |
|
| 907 | } |
||
| 908 | 4 | if ($oElementrPr->hasAttribute('i')) { |
|
| 909 | 3 | $att = $oElementrPr->getAttribute('i'); |
|
| 910 | 3 | $oText->getFont()->setItalic($att == 'true' || $att == '1' ? true : false); |
|
| 911 | } |
||
| 912 | 4 | if ($oElementrPr->hasAttribute('strike')) { |
|
| 913 | 3 | $oText->getFont()->setStrikethrough($oElementrPr->getAttribute('strike') == 'noStrike' ? false : true); |
|
| 914 | } |
||
| 915 | 4 | if ($oElementrPr->hasAttribute('sz')) { |
|
| 916 | 3 | $oText->getFont()->setSize((int)($oElementrPr->getAttribute('sz') / 100)); |
|
| 917 | } |
||
| 918 | 4 | if ($oElementrPr->hasAttribute('u')) { |
|
| 919 | 3 | $oText->getFont()->setUnderline($oElementrPr->getAttribute('u')); |
|
| 920 | } |
||
| 921 | // Color |
||
| 922 | 4 | $oElementSrgbClr = $document->getElement('a:solidFill/a:srgbClr', $oElementrPr); |
|
| 923 | 4 | if (is_object($oElementSrgbClr) && $oElementSrgbClr->hasAttribute('val')) { |
|
| 924 | 3 | $oColor = new Color(); |
|
| 925 | 3 | $oColor->setRGB($oElementSrgbClr->getAttribute('val')); |
|
| 926 | 3 | $oText->getFont()->setColor($oColor); |
|
| 927 | } |
||
| 928 | // Hyperlink |
||
| 929 | 4 | $oElementHlinkClick = $document->getElement('a:hlinkClick', $oElementrPr); |
|
| 930 | 4 | if (is_object($oElementHlinkClick)) { |
|
| 931 | 3 | if ($oElementHlinkClick->hasAttribute('tooltip')) { |
|
| 932 | 3 | $oText->getHyperlink()->setTooltip($oElementHlinkClick->getAttribute('tooltip')); |
|
| 933 | } |
||
| 934 | 3 | if ($oElementHlinkClick->hasAttribute('r:id') && isset($this->arrayRels[$this->fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target'])) { |
|
| 935 | 3 | $oText->getHyperlink()->setUrl($this->arrayRels[$this->fileRels][$oElementHlinkClick->getAttribute('r:id')]['Target']); |
|
| 936 | } |
||
| 937 | } |
||
| 938 | //} else { |
||
| 939 | // $oText = $oParagraph->createText(); |
||
| 940 | |||
| 941 | 4 | $oSubSubElement = $document->getElement('a:t', $oSubElement); |
|
| 942 | 4 | $oText->setText($oSubSubElement->nodeValue); |
|
| 943 | } |
||
| 944 | } |
||
| 945 | } |
||
| 946 | 4 | } |
|
| 947 | |||
| 948 | /** |
||
| 949 | * @param XMLReader $document |
||
| 950 | * @param \DOMElement $node |
||
| 951 | * @param AbstractSlide $oSlide |
||
| 952 | * @throws \Exception |
||
| 953 | */ |
||
| 954 | protected function loadShapeTable(XMLReader $document, \DOMElement $node, AbstractSlide $oSlide) |
||
| 955 | { |
||
| 956 | $this->fileRels = $oSlide->getRelsIndex(); |
||
| 957 | |||
| 958 | $oShape = $oSlide->createTableShape(); |
||
| 959 | |||
| 960 | $oElement = $document->getElement('p:cNvPr', $node); |
||
| 961 | if ($oElement instanceof \DOMElement) { |
||
| 962 | if ($oElement->hasAttribute('name')) { |
||
| 963 | $oShape->setName($oElement->getAttribute('name')); |
||
| 964 | } |
||
| 965 | if ($oElement->hasAttribute('descr')) { |
||
| 966 | $oShape->setDescription($oElement->getAttribute('descr')); |
||
| 967 | } |
||
| 968 | } |
||
| 969 | |||
| 970 | $oElement = $document->getElement('p:xfrm/a:off', $node); |
||
| 971 | if ($oElement instanceof \DOMElement) { |
||
| 972 | if ($oElement->hasAttribute('x')) { |
||
| 973 | $oShape->setOffsetX(CommonDrawing::emuToPixels($oElement->getAttribute('x'))); |
||
| 974 | } |
||
| 975 | if ($oElement->hasAttribute('y')) { |
||
| 976 | $oShape->setOffsetY(CommonDrawing::emuToPixels($oElement->getAttribute('y'))); |
||
| 977 | } |
||
| 978 | } |
||
| 979 | |||
| 980 | $oElement = $document->getElement('p:xfrm/a:ext', $node); |
||
| 981 | if ($oElement instanceof \DOMElement) { |
||
| 982 | if ($oElement->hasAttribute('cx')) { |
||
| 983 | $oShape->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('cx'))); |
||
| 984 | } |
||
| 985 | if ($oElement->hasAttribute('cy')) { |
||
| 986 | $oShape->setHeight(CommonDrawing::emuToPixels($oElement->getAttribute('cy'))); |
||
| 987 | } |
||
| 988 | } |
||
| 989 | |||
| 990 | $arrayElements = $document->getElements('a:graphic/a:graphicData/a:tbl/a:tblGrid/a:gridCol', $node); |
||
| 991 | $oShape->setNumColumns($arrayElements->length); |
||
| 992 | $oShape->createRow(); |
||
| 993 | foreach ($arrayElements as $key => $oElement) { |
||
| 994 | if ($oElement instanceof \DOMElement && $oElement->getAttribute('w')) { |
||
| 995 | $oShape->getRow(0)->getCell($key)->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('w'))); |
||
| 996 | } |
||
| 997 | } |
||
| 998 | |||
| 999 | $arrayElements = $document->getElements('a:graphic/a:graphicData/a:tbl/a:tr', $node); |
||
| 1000 | foreach ($arrayElements as $keyRow => $oElementRow) { |
||
| 1001 | if (!($oElementRow instanceof \DOMElement)) { |
||
| 1002 | continue; |
||
| 1003 | } |
||
| 1004 | $oRow = $oShape->getRow($keyRow, true); |
||
| 1005 | if (is_null($oRow)) { |
||
| 1006 | $oRow = $oShape->createRow(); |
||
| 1007 | } |
||
| 1008 | if ($oElementRow->hasAttribute('h')) { |
||
| 1009 | $oRow->setHeight(CommonDrawing::emuToPixels($oElementRow->getAttribute('h'))); |
||
| 1010 | } |
||
| 1011 | $arrayElementsCell = $document->getElements('a:tc', $oElementRow); |
||
| 1012 | foreach ($arrayElementsCell as $keyCell => $oElementCell) { |
||
| 1013 | if (!($oElementCell instanceof \DOMElement)) { |
||
| 1014 | continue; |
||
| 1015 | } |
||
| 1016 | $oCell = $oRow->getCell($keyCell); |
||
| 1017 | $oCell->setParagraphs(array()); |
||
| 1018 | if ($oElementCell->hasAttribute('gridSpan')) { |
||
| 1019 | $oCell->setColSpan($oElementCell->getAttribute('gridSpan')); |
||
| 1020 | } |
||
| 1021 | if ($oElementCell->hasAttribute('rowSpan')) { |
||
| 1022 | $oCell->setRowSpan($oElementCell->getAttribute('rowSpan')); |
||
| 1023 | } |
||
| 1024 | |||
| 1025 | foreach ($document->getElements('a:txBody/a:p', $oElementCell) as $oElementPara) { |
||
| 1026 | $this->loadParagraph($document, $oElementPara, $oCell); |
||
| 1027 | } |
||
| 1028 | |||
| 1029 | $oElementTcPr = $document->getElement('a:tcPr', $oElementCell); |
||
| 1030 | if ($oElementTcPr instanceof \DOMElement) { |
||
| 1031 | $numParagraphs = count($oCell->getParagraphs()); |
||
| 1032 | if ($numParagraphs > 0) { |
||
| 1033 | if ($oElementTcPr->hasAttribute('anchor')) { |
||
| 1034 | $oCell->getParagraph(0)->getAlignment()->setVertical($oElementTcPr->getAttribute('anchor')); |
||
| 1035 | } |
||
| 1036 | if ($oElementTcPr->hasAttribute('marB')) { |
||
| 1037 | $oCell->getParagraph(0)->getAlignment()->setMarginBottom($oElementTcPr->getAttribute('marB')); |
||
| 1038 | } |
||
| 1039 | if ($oElementTcPr->hasAttribute('marL')) { |
||
| 1040 | $oCell->getParagraph(0)->getAlignment()->setMarginLeft($oElementTcPr->getAttribute('marL')); |
||
| 1041 | } |
||
| 1042 | if ($oElementTcPr->hasAttribute('marR')) { |
||
| 1043 | $oCell->getParagraph(0)->getAlignment()->setMarginRight($oElementTcPr->getAttribute('marR')); |
||
| 1044 | } |
||
| 1045 | if ($oElementTcPr->hasAttribute('marT')) { |
||
| 1046 | $oCell->getParagraph(0)->getAlignment()->setMarginTop($oElementTcPr->getAttribute('marT')); |
||
| 1047 | } |
||
| 1048 | } |
||
| 1049 | |||
| 1050 | $oFill = $this->loadStyleFill($document, $oElementTcPr); |
||
| 1051 | if ($oFill instanceof Fill) { |
||
| 1052 | $oCell->setFill($oFill); |
||
| 1053 | } |
||
| 1054 | |||
| 1055 | $oBorders = new Borders(); |
||
| 1056 | $oElementBorderL = $document->getElement('a:lnL', $oElementTcPr); |
||
| 1057 | if ($oElementBorderL instanceof \DOMElement) { |
||
| 1058 | $this->loadBorder($document, $oElementBorderL, $oBorders->getLeft()); |
||
| 1059 | } |
||
| 1060 | $oElementBorderR = $document->getElement('a:lnR', $oElementTcPr); |
||
| 1061 | if ($oElementBorderR instanceof \DOMElement) { |
||
| 1062 | $this->loadBorder($document, $oElementBorderR, $oBorders->getRight()); |
||
| 1063 | } |
||
| 1064 | $oElementBorderT = $document->getElement('a:lnT', $oElementTcPr); |
||
| 1065 | if ($oElementBorderT instanceof \DOMElement) { |
||
| 1066 | $this->loadBorder($document, $oElementBorderT, $oBorders->getTop()); |
||
| 1067 | } |
||
| 1068 | $oElementBorderB = $document->getElement('a:lnB', $oElementTcPr); |
||
| 1069 | if ($oElementBorderB instanceof \DOMElement) { |
||
| 1070 | $this->loadBorder($document, $oElementBorderB, $oBorders->getBottom()); |
||
| 1071 | } |
||
| 1072 | $oElementBorderDiagDown = $document->getElement('a:lnTlToBr', $oElementTcPr); |
||
| 1073 | if ($oElementBorderDiagDown instanceof \DOMElement) { |
||
| 1074 | $this->loadBorder($document, $oElementBorderDiagDown, $oBorders->getDiagonalDown()); |
||
| 1075 | } |
||
| 1076 | $oElementBorderDiagUp = $document->getElement('a:lnBlToTr', $oElementTcPr); |
||
| 1077 | if ($oElementBorderDiagUp instanceof \DOMElement) { |
||
| 1078 | $this->loadBorder($document, $oElementBorderDiagUp, $oBorders->getDiagonalUp()); |
||
| 1079 | } |
||
| 1080 | $oCell->setBorders($oBorders); |
||
| 1081 | } |
||
| 1082 | } |
||
| 1083 | } |
||
| 1084 | } |
||
| 1085 | |||
| 1086 | /** |
||
| 1087 | * @param XMLReader $xmlReader |
||
| 1088 | * @param \DOMElement $oElement |
||
| 1089 | * @return null|Fill |
||
| 1090 | */ |
||
| 1091 | protected function loadStyleFill(XMLReader $xmlReader, \DOMElement $oElement) |
||
| 1092 | { |
||
| 1093 | // Gradient fill |
||
| 1094 | $oElementFill = $xmlReader->getElement('a:gradFill', $oElement); |
||
| 1095 | if ($oElementFill instanceof \DOMElement) { |
||
| 1096 | $oFill = new Fill(); |
||
| 1097 | $oFill->setFillType(Fill::FILL_GRADIENT_LINEAR); |
||
| 1098 | |||
| 1099 | $oElementColor = $xmlReader->getElement('a:gsLst/a:gs[@pos="0"]/a:srgbClr', $oElementFill); |
||
| 1100 | if ($oElementColor instanceof \DOMElement && $oElementColor->hasAttribute('val')) { |
||
| 1101 | $oFill->setStartColor($this->loadStyleColor($xmlReader, $oElementColor)); |
||
| 1102 | } |
||
| 1103 | |||
| 1104 | $oElementColor = $xmlReader->getElement('a:gsLst/a:gs[@pos="100000"]/a:srgbClr', $oElementFill); |
||
| 1105 | if ($oElementColor instanceof \DOMElement && $oElementColor->hasAttribute('val')) { |
||
| 1106 | $oFill->setEndColor($this->loadStyleColor($xmlReader, $oElementColor)); |
||
| 1107 | } |
||
| 1108 | |||
| 1109 | $oRotation = $xmlReader->getElement('a:lin', $oElementFill); |
||
| 1110 | if ($oRotation instanceof \DOMElement && $oRotation->hasAttribute('ang')) { |
||
| 1111 | $oFill->setRotation(CommonDrawing::angleToDegrees($oRotation->getAttribute('ang'))); |
||
| 1112 | } |
||
| 1113 | return $oFill; |
||
| 1114 | } |
||
| 1115 | |||
| 1116 | // Solid fill |
||
| 1117 | $oElementFill = $xmlReader->getElement('a:solidFill', $oElement); |
||
| 1118 | if ($oElementFill instanceof \DOMElement) { |
||
| 1119 | $oFill = new Fill(); |
||
| 1120 | $oFill->setFillType(Fill::FILL_SOLID); |
||
| 1121 | |||
| 1122 | $oElementColor = $xmlReader->getElement('a:srgbClr', $oElementFill); |
||
| 1123 | if ($oElementColor instanceof \DOMElement) { |
||
| 1124 | $oFill->setStartColor($this->loadStyleColor($xmlReader, $oElementColor)); |
||
| 1125 | } |
||
| 1126 | return $oFill; |
||
| 1127 | } |
||
| 1128 | return null; |
||
| 1129 | } |
||
| 1130 | |||
| 1131 | /** |
||
| 1132 | * @param XMLReader $xmlReader |
||
| 1133 | * @param \DOMElement $oElement |
||
| 1134 | * @return Color |
||
| 1135 | */ |
||
| 1136 | protected function loadStyleColor(XMLReader $xmlReader, \DOMElement $oElement) |
||
| 1147 | |||
| 1148 | /** |
||
| 1149 | * @param XMLReader $xmlReader |
||
| 1150 | * @param \DOMElement $oElement |
||
| 1151 | * @param Border $oBorder |
||
| 1152 | */ |
||
| 1153 | protected function loadBorder(XMLReader $xmlReader, \DOMElement $oElement, Border $oBorder) |
||
| 1177 | /** |
||
| 1178 | * |
||
| 1179 | * @param string $fileRels |
||
| 1180 | * @return string |
||
| 1181 | */ |
||
| 1182 | 4 | protected function loadRels($fileRels) |
|
| 1197 | |||
| 1198 | /** |
||
| 1199 | * @param $oSlide |
||
| 1200 | * @param \DOMNodeList $oElements |
||
| 1201 | * @param XMLReader $xmlReader |
||
| 1202 | * @internal param $baseFile |
||
| 1203 | */ |
||
| 1204 | 4 | private function loadSlideShapes($oSlide, $oElements, $xmlReader) |
|
| 1222 | } |
||
| 1223 |
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.