Skip to content

Commit 02e6f62

Browse files
committed
PowerPoint2007 Reader : Initial Commit - GH-44
1 parent c205a89 commit 02e6f62

File tree

10 files changed

+1300
-227
lines changed

10 files changed

+1300
-227
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
## 0.5.0 - Not released
33

44
### Features
5+
- PowerPoint2007 Reader : Initial Commit - @Progi1984 GH-44
56

67
### Bugfix
78
- Fixed the sample in Readme.md - @Progi1984 GH-114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
set_time_limit(10);
4+
5+
include_once 'Sample_Header.php';
6+
7+
use PhpOffice\PhpPresentation\PhpPresentation;
8+
use PhpOffice\PhpPresentation\DocumentLayout;
9+
use PhpOffice\PhpPresentation\IOFactory;
10+
use PhpOffice\PhpPresentation\Style\Alignment;
11+
use PhpOffice\PhpPresentation\Style\Color;
12+
use PhpOffice\PhpPresentation\Slide;
13+
use PhpOffice\PhpPresentation\AbstractShape;
14+
use PhpOffice\PhpPresentation\Shape\MemoryDrawing;
15+
use PhpOffice\PhpPresentation\Shape\RichText;
16+
use PhpOffice\PhpPresentation\Shape\Group;
17+
18+
$pptReader = IOFactory::createReader('PowerPoint2007');
19+
$oPHPPresentation = $pptReader->load('resources/Sample_12.pptx');
20+
21+
$oTree = new PhpPptTree($oPHPPresentation);
22+
echo $oTree->display();
23+
if (!CLI) {
24+
include_once 'Sample_Footer.php';
25+
}

samples/Sample_12_Reader_PowerPoint97.php

-147
Original file line numberDiff line numberDiff line change
@@ -15,153 +15,6 @@
1515
use PhpOffice\PhpPresentation\Shape\RichText;
1616
use PhpOffice\PhpPresentation\Shape\Group;
1717

18-
class PhpPptTree {
19-
protected $oPhpPresentation;
20-
protected $htmlOutput;
21-
22-
public function __construct(PhpPresentation $oPHPPpt)
23-
{
24-
$this->oPhpPresentation = $oPHPPpt;
25-
}
26-
27-
public function display()
28-
{
29-
$this->append('<div class="container-fluid pptTree">');
30-
$this->append('<div class="row">');
31-
$this->append('<div class="collapse in col-md-6">');
32-
$this->append('<div class="tree">');
33-
$this->append('<ul>');
34-
$this->displayPhpPresentation($this->oPhpPresentation);
35-
$this->append('</ul>');
36-
$this->append('</div>');
37-
$this->append('</div>');
38-
$this->append('<div class="col-md-6">');
39-
$this->displayPhpPresentationInfo($this->oPhpPresentation);
40-
$this->append('</div>');
41-
$this->append('</div>');
42-
$this->append('</div>');
43-
44-
return $this->htmlOutput;
45-
}
46-
47-
protected function append($sHTML)
48-
{
49-
$this->htmlOutput .= $sHTML;
50-
}
51-
52-
protected function displayPhpPresentation(PhpPresentation $oPHPPpt)
53-
{
54-
$this->append('<li><span><i class="fa fa-folder-open"></i> PhpPresentation</span>');
55-
$this->append('<ul>');
56-
$this->append('<li><span class="shape" id="divPhpPresentation"><i class="fa fa-info-circle"></i> Info "PhpPresentation"</span></li>');
57-
foreach ($oPHPPpt->getAllSlides() as $oSlide) {
58-
$this->append('<li><span><i class="fa fa-minus-square"></i> Slide</span>');
59-
$this->append('<ul>');
60-
$this->append('<li><span class="shape" id="div'.$oSlide->getHashCode().'"><i class="fa fa-info-circle"></i> Info "Slide"</span></li>');
61-
foreach ($oSlide->getShapeCollection() as $oShape) {
62-
if($oShape instanceof Group) {
63-
$this->append('<li><span><i class="fa fa-minus-square"></i> Shape "Group"</span>');
64-
$this->append('<ul>');
65-
// $this->append('<li><span class="shape" id="div'.$oShape->getHashCode().'"><i class="fa fa-info-circle"></i> Info "Group"</span></li>');
66-
foreach ($oShape->getShapeCollection() as $oShapeChild) {
67-
$this->displayShape($oShapeChild);
68-
}
69-
$this->append('</ul>');
70-
$this->append('</li>');
71-
} else {
72-
$this->displayShape($oShape);
73-
}
74-
}
75-
$this->append('</ul>');
76-
$this->append('</li>');
77-
}
78-
$this->append('</ul>');
79-
$this->append('</li>');
80-
}
81-
82-
protected function displayShape(AbstractShape $shape)
83-
{
84-
if($shape instanceof MemoryDrawing) {
85-
$this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "MemoryDrawing"</span></li>');
86-
} elseif($shape instanceof RichText) {
87-
$this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "RichText"</span></li>');
88-
} else {
89-
var_export($shape);
90-
}
91-
}
92-
93-
protected function displayPhpPresentationInfo(PhpPresentation $oPHPPpt)
94-
{
95-
$this->append('<div class="infoBlk" id="divPhpPresentationInfo">');
96-
$this->append('<dl>');
97-
$this->append('<dt>Number of slides</dt><dd>'.$oPHPPpt->getSlideCount().'</dd>');
98-
$this->append('<dt>Document Layout Height</dt><dd>'.$oPHPPpt->getLayout()->getCY(DocumentLayout::UNIT_MILLIMETER).' mm</dd>');
99-
$this->append('<dt>Document Layout Width</dt><dd>'.$oPHPPpt->getLayout()->getCX(DocumentLayout::UNIT_MILLIMETER).' mm</dd>');
100-
$this->append('<dt>Properties : Category</dt><dd>'.$oPHPPpt->getProperties()->getCategory().'</dd>');
101-
$this->append('<dt>Properties : Company</dt><dd>'.$oPHPPpt->getProperties()->getCompany().'</dd>');
102-
$this->append('<dt>Properties : Created</dt><dd>'.$oPHPPpt->getProperties()->getCreated().'</dd>');
103-
$this->append('<dt>Properties : Creator</dt><dd>'.$oPHPPpt->getProperties()->getCreator().'</dd>');
104-
$this->append('<dt>Properties : Description</dt><dd>'.$oPHPPpt->getProperties()->getDescription().'</dd>');
105-
$this->append('<dt>Properties : Keywords</dt><dd>'.$oPHPPpt->getProperties()->getKeywords().'</dd>');
106-
$this->append('<dt>Properties : Last Modified By</dt><dd>'.$oPHPPpt->getProperties()->getLastModifiedBy().'</dd>');
107-
$this->append('<dt>Properties : Modified</dt><dd>'.$oPHPPpt->getProperties()->getModified().'</dd>');
108-
$this->append('<dt>Properties : Subject</dt><dd>'.$oPHPPpt->getProperties()->getSubject().'</dd>');
109-
$this->append('<dt>Properties : Title</dt><dd>'.$oPHPPpt->getProperties()->getTitle().'</dd>');
110-
$this->append('</dl>');
111-
$this->append('</div>');
112-
113-
foreach ($oPHPPpt->getAllSlides() as $oSlide) {
114-
$this->append('<div class="infoBlk" id="div'.$oSlide->getHashCode().'Info">');
115-
$this->append('<dl>');
116-
$this->append('<dt>HashCode</dt><dd>'.$oSlide->getHashCode().'</dd>');
117-
$this->append('<dt>Slide Layout</dt><dd>'.$oSlide->getSlideLayout().'</dd>');
118-
$this->append('<dt>Offset X</dt><dd>'.$oSlide->getOffsetX().'</dd>');
119-
$this->append('<dt>Offset Y</dt><dd>'.$oSlide->getOffsetY().'</dd>');
120-
$this->append('<dt>Extent X</dt><dd>'.$oSlide->getExtentX().'</dd>');
121-
$this->append('<dt>Extent Y</dt><dd>'.$oSlide->getExtentY().'</dd>');
122-
$this->append('</dl>');
123-
$this->append('</div>');
124-
125-
foreach ($oSlide->getShapeCollection() as $oShape) {
126-
if($oShape instanceof Group) {
127-
foreach ($oShape->getShapeCollection() as $oShapeChild) {
128-
$this->displayShapeInfo($oShapeChild);
129-
}
130-
} else {
131-
$this->displayShapeInfo($oShape);
132-
}
133-
}
134-
}
135-
}
136-
137-
protected function displayShapeInfo(AbstractShape $oShape)
138-
{
139-
$this->append('<div class="infoBlk" id="div'.$oShape->getHashCode().'Info">');
140-
$this->append('<dl>');
141-
$this->append('<dt>HashCode</dt><dd>'.$oShape->getHashCode().'</dd>');
142-
$this->append('<dt>Offset X</dt><dd>'.$oShape->getOffsetX().'</dd>');
143-
$this->append('<dt>Offset Y</dt><dd>'.$oShape->getOffsetY().'</dd>');
144-
$this->append('<dt>Height</dt><dd>'.$oShape->getHeight().'</dd>');
145-
$this->append('<dt>Width</dt><dd>'.$oShape->getWidth().'</dd>');
146-
$this->append('<dt>Rotation</dt><dd>'.$oShape->getRotation().'°</dd>');
147-
$this->append('<dt>Hyperlink</dt><dd>'.ucfirst(var_export($oShape->hasHyperlink(), true)).'</dd>');
148-
$this->append('<dt>Fill</dt><dd>@Todo</dd>');
149-
$this->append('<dt>Border</dt><dd>@Todo</dd>');
150-
if($oShape instanceof MemoryDrawing) {
151-
ob_start();
152-
call_user_func($oShape->getRenderingFunction(), $oShape->getImageResource());
153-
$sShapeImgContents = ob_get_contents();
154-
ob_end_clean();
155-
$this->append('<dt>Mime-Type</dt><dd>'.$oShape->getMimeType().'</dd>');
156-
$this->append('<dt>Image</dt><dd><img src="data:'.$oShape->getMimeType().';base64,'.base64_encode($sShapeImgContents).'"></dd>');
157-
} else {
158-
// Add another shape
159-
}
160-
$this->append('</dl>');
161-
$this->append('</div>');
162-
}
163-
}
164-
16518
$pptReader = PhpOffice\PhpPresentation\IOFactory::createReader('PowerPoint97');
16619
$oPHPPresentation = $pptReader->load('resources/Sample_12.ppt');
16720

0 commit comments

Comments
 (0)