Skip to content

Commit

Permalink
Merge a839683 into 1fcc840
Browse files Browse the repository at this point in the history
  • Loading branch information
dpylypen committed Oct 22, 2017
2 parents 1fcc840 + a839683 commit cf0982e
Show file tree
Hide file tree
Showing 32 changed files with 943 additions and 197 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Expand Up @@ -2,7 +2,6 @@ sudo: false
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
Expand All @@ -12,7 +11,6 @@ php:

matrix:
allow_failures:
- php: 7.1
- php: hhvm

env:
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,24 @@
# Changelog

## 0.10.0 - WIP

### Bugfix
- PowerPoint2007 : Text is subscripted when set superscript to false - @qmachard GH-360

### Changes
- PHP 7.1 is now supported - @Progi1984 GH-355
- PhpOffice\PhpPresentation\Style\Color : Define only the transparency - @Progi1984 GH-370
- PowerPoint2007 Reader : Background Color based on SchemeColor - @Progi1984 GH-397

### Features
- ODPresentation Writer : Support for the position of Legend - @Progi1984 GH-355
- ODPresentation Writer : Support for DoughnutChart - @Progi1984 GH-355
- PowerPoint2007 Writer : Support for DoughnutChart - @Progi1984 GH-355
- ODPresentation Reader : Support for fill for image - @Progi1984 GH-370
- PowerPoint2007 Reader : Support for fill for image - @Progi1984 GH-370
- ODPresentation Writer : Support for fill for transparent image - @Progi1984 GH-370
- PowerPoint2007 Writer : Support for fill for transparent image - @JewrassicPark GH-370

## 0.9.0 - 2017-07-05

### Bugfix
Expand Down
1 change: 0 additions & 1 deletion composer.json
Expand Up @@ -27,7 +27,6 @@
"require-dev": {
"phpunit/phpunit": "3.7.*",
"phpdocumentor/phpdocumentor":"2.*",
"twig/twig":"1.27",
"phpmd/phpmd": "2.*",
"sebastian/phpcpd": "2.*",
"phploc/phploc": "2.*",
Expand Down
28 changes: 15 additions & 13 deletions samples/Sample_03_Image.php

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions samples/Sample_03_Video.php
@@ -0,0 +1,33 @@
<?php

include_once 'Sample_Header.php';

use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Shape\Drawing;
use PhpOffice\PhpPresentation\Shape\Media;

// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();

// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$currentSlide = $objPHPPresentation->getActiveSlide();

// Add a video to the slide
$shape = new Media();
$shape->setName('Video')
->setDescription('Video')
->setPath(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? './resources/sintel_trailer-480p.wmv' : './resources/sintel_trailer-480p.ogv')
->setResizeProportional(false)
->setHeight(90)
->setWidth(90)
->setOffsetX(10)
->setOffsetY(300);
$currentSlide->addShape($shape);

// Save file
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}
113 changes: 85 additions & 28 deletions samples/Sample_05_Chart.php
Expand Up @@ -172,23 +172,23 @@ function fnSlide_BarStacked(PhpPresentation $objPHPPresentation) {
echo date( 'H:i:s' ) . ' Create a stacked bar chart (that should be inserted in a chart shape)' . EOL;
$StackedBarChart = new Bar();
$series1 = new Series( '2009', $series1Data );
$series1->setShowSeriesName( false );
$series1->setShowSeriesName(false);
$series1->getFill()->setFillType( Fill::FILL_SOLID )->setStartColor( new Color( 'FF4F81BD' ) );
$series1->getFont()->getColor()->setRGB( '00FF00' );
$series1->setShowValue( true );
$series1->setShowPercentage( false );
$series1->setShowValue(true);
$series1->setShowPercentage(false);
$series2 = new Series( '2010', $series2Data );
$series2->setShowSeriesName( false );
$series2->setShowSeriesName(false);
$series2->getFont()->getColor()->setRGB( 'FF0000' );
$series2->getFill()->setFillType( Fill::FILL_SOLID )->setStartColor( new Color( 'FFC0504D' ) );
$series2->setShowValue( true );
$series2->setShowPercentage( false );
$series2->setShowValue(true);
$series2->setShowPercentage(false);
$series3 = new Series( '2011', $series3Data );
$series3->setShowSeriesName( false );
$series3->setShowSeriesName(false);
$series3->getFont()->getColor()->setRGB( 'FF0000' );
$series3->getFill()->setFillType( Fill::FILL_SOLID )->setStartColor( new Color( 'FF804DC0' ) );
$series3->setShowValue( true );
$series3->setShowPercentage( false );
$series3->setShowValue(true);
$series3->setShowPercentage(false);
$StackedBarChart->addSeries( $series1 );
$StackedBarChart->addSeries( $series2 );
$StackedBarChart->addSeries( $series3 );
Expand All @@ -197,7 +197,7 @@ function fnSlide_BarStacked(PhpPresentation $objPHPPresentation) {
echo date( 'H:i:s' ) . ' Create a shape (chart)' . EOL;
$shape = $currentSlide->createChartShape();
$shape->setName( 'PHPPresentation Monthly Downloads' )
->setResizeProportional( false )
->setResizeProportional(false)
->setHeight( 550 )
->setWidth( 700 )
->setOffsetX( 120 )
Expand All @@ -206,13 +206,13 @@ function fnSlide_BarStacked(PhpPresentation $objPHPPresentation) {
$shape->setFill( $oFill );
$shape->getBorder()->setLineStyle( Border::LINE_SINGLE );
$shape->getTitle()->setText( 'PHPPresentation Monthly Downloads' );
$shape->getTitle()->getFont()->setItalic( true );
$shape->getTitle()->getFont()->setItalic(true);
$shape->getTitle()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_RIGHT );
$shape->getPlotArea()->getAxisX()->setTitle( 'Month' );
$shape->getPlotArea()->getAxisY()->setTitle( 'Downloads' );
$shape->getPlotArea()->setType( $StackedBarChart );
$shape->getLegend()->getBorder()->setLineStyle( Border::LINE_SINGLE );
$shape->getLegend()->getFont()->setItalic( true );
$shape->getLegend()->getFont()->setItalic(true);
}

function fnSlide_BarPercentStacked(PhpPresentation $objPHPPresentation) {
Expand Down Expand Up @@ -245,26 +245,26 @@ function fnSlide_BarPercentStacked(PhpPresentation $objPHPPresentation) {
echo date( 'H:i:s' ) . ' Create a percent stacked horizontal bar chart (that should be inserted in a chart shape)' . EOL;
$PercentStackedBarChartHoriz = new Bar();
$series1 = new Series( '2009', $series1Data );
$series1->setShowSeriesName( false );
$series1->setShowSeriesName(false);
$series1->getFill()->setFillType( Fill::FILL_SOLID )->setStartColor( new Color( 'FF4F81BD' ) );
$series1->getFont()->getColor()->setRGB( '00FF00' );
$series1->setShowValue( true );
$series1->setShowPercentage( false );
$series1->setShowValue(true);
$series1->setShowPercentage(false);
// Set Data Label Format For Chart To Display Percent
$series1->setDlblNumFormat( '#%' );
$series2 = new Series( '2010', $series2Data );
$series2->setShowSeriesName( false );
$series2->setShowSeriesName(false);
$series2->getFont()->getColor()->setRGB( 'FF0000' );
$series2->getFill()->setFillType( Fill::FILL_SOLID )->setStartColor( new Color( 'FFC0504D' ) );
$series2->setShowValue( true );
$series2->setShowPercentage( false );
$series2->setShowValue(true);
$series2->setShowPercentage(false);
$series2->setDlblNumFormat( '#%' );
$series3 = new Series( '2011', $series3Data );
$series3->setShowSeriesName( false );
$series3->setShowSeriesName(false);
$series3->getFont()->getColor()->setRGB( 'FF0000' );
$series3->getFill()->setFillType( Fill::FILL_SOLID )->setStartColor( new Color( 'FF804DC0' ) );
$series3->setShowValue( true );
$series3->setShowPercentage( false );
$series3->setShowValue(true);
$series3->setShowPercentage(false);
$series3->setDlblNumFormat( '#%' );
$PercentStackedBarChartHoriz->addSeries( $series1 );
$PercentStackedBarChartHoriz->addSeries( $series2 );
Expand All @@ -275,7 +275,7 @@ function fnSlide_BarPercentStacked(PhpPresentation $objPHPPresentation) {
echo date( 'H:i:s' ) . ' Create a shape (chart)' . EOL;
$shape = $currentSlide->createChartShape();
$shape->setName( 'PHPPresentation Monthly Downloads' )
->setResizeProportional( false )
->setResizeProportional(false)
->setHeight( 550 )
->setWidth( 700 )
->setOffsetX( 120 )
Expand All @@ -284,13 +284,13 @@ function fnSlide_BarPercentStacked(PhpPresentation $objPHPPresentation) {
$shape->setFill( $oFill );
$shape->getBorder()->setLineStyle( Border::LINE_SINGLE );
$shape->getTitle()->setText( 'PHPPresentation Monthly Downloads' );
$shape->getTitle()->getFont()->setItalic( true );
$shape->getTitle()->getFont()->setItalic(true);
$shape->getTitle()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_RIGHT );
$shape->getPlotArea()->getAxisX()->setTitle( 'Month' );
$shape->getPlotArea()->getAxisY()->setTitle( 'Downloads' );
$shape->getPlotArea()->setType( $PercentStackedBarChartHoriz );
$shape->getLegend()->getBorder()->setLineStyle( Border::LINE_SINGLE );
$shape->getLegend()->getFont()->setItalic( true );
$shape->getLegend()->getFont()->setItalic(true);
}

function fnSlide_Bar3D(PhpPresentation $objPHPPresentation) {
Expand Down Expand Up @@ -384,6 +384,61 @@ function fnSlide_Bar3DHorizontal(PhpPresentation $objPHPPresentation) {
$shape->getLegend()->getFont()->setItalic(true);
}

function fnSlide_Doughnut(PhpPresentation $objPHPPresentation)
{
global $oFill;
global $oShadow;

// Create templated slide
echo EOL . date('H:i:s') . ' Create templated slide' . EOL;
$currentSlide = createTemplatedSlide($objPHPPresentation);

// Generate sample data for second chart
echo date('H:i:s') . ' Generate sample data for chart' . EOL;
$seriesData = array('Monday' => 18, 'Tuesday' => 23, 'Wednesday' => 14, 'Thursday' => 12, 'Friday' => 20, 'Saturday' => 8, 'Sunday' => 10);

// Create a doughnut chart (that should be inserted in a shape)
echo date('H:i:s') . ' Create a non-3D Doughnut chart (that should be inserted in a chart shape)' . EOL;
$doughnutChart = new \PhpOffice\PhpPresentation\Shape\Chart\Type\Doughnut();
$doughnutChart->setHoleSize(43);
$series = new Series('Downloads', $seriesData);
$series->getDataPointFill(0)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF7CB5EC'));
$series->getDataPointFill(1)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF434348'));
$series->getDataPointFill(2)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF90ED7D'));
$series->getDataPointFill(3)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFF7A35C'));
$series->getDataPointFill(4)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF8085E9'));
$series->getDataPointFill(5)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFF15C80'));
$series->getDataPointFill(6)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFE4D354'));
$series->setShowPercentage(true);
$series->setShowValue(false);
$series->setShowSeriesName(false);
$series->setShowCategoryName(true);
$series->setDlblNumFormat('%d');
$series->setSeparator(' > ');
$series->getFont()->getColor()->setRGB('FFFF00');
$series->getFont()->setBold(true);
$doughnutChart->addSeries($series);

// Create a shape (chart)
echo date('H:i:s') . ' Create a shape (chart)' . EOL;
$shape = $currentSlide->createChartShape();
$shape->setName('PHPPresentation Daily Downloads')
->setResizeProportional(false)
->setHeight(550)
->setWidth(700)
->setOffsetX(120)
->setOffsetY(80);
$shape->setShadow($oShadow);
$shape->setFill($oFill);
$shape->getBorder()->setLineStyle(Border::LINE_SINGLE);
$shape->getTitle()->setText('PHPPresentation Daily Downloads');
$shape->getTitle()->getFont()->setItalic(true);
$shape->getPlotArea()->setType($doughnutChart);
$shape->getLegend()->getBorder()->setLineStyle(Border::LINE_SINGLE);
$shape->getLegend()->getFont()->setItalic(true);
$shape->getLegend()->setPosition(\PhpOffice\PhpPresentation\Shape\Chart\Legend::POSITION_LEFT);
}

function fnSlide_Pie3D(PhpPresentation $objPHPPresentation) {
global $oFill;
global $oShadow;
Expand Down Expand Up @@ -456,10 +511,10 @@ function fnSlide_Pie(PhpPresentation $objPHPPresentation) {
$series->getDataPointFill(4)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FF8085E9'));
$series->getDataPointFill(5)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFF15C80'));
$series->getDataPointFill(6)->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFE4D354'));
$series->setShowPercentage( true );
$series->setShowValue( false );
$series->setShowSeriesName( false );
$series->setShowCategoryName( true );
$series->setShowPercentage(true);
$series->setShowValue(false);
$series->setShowSeriesName(false);
$series->setShowCategoryName(true);
$series->setDlblNumFormat('%d');
$pieChart->addSeries($series);

Expand Down Expand Up @@ -563,6 +618,8 @@ function fnSlide_Scatter(PhpPresentation $objPHPPresentation) {

fnSlide_Bar3DHorizontal($objPHPPresentation);

fnSlide_Doughnut($objPHPPresentation);

fnSlide_Pie3D($objPHPPresentation);

fnSlide_Pie($objPHPPresentation);
Expand Down
37 changes: 29 additions & 8 deletions samples/Sample_Header.php
Expand Up @@ -3,13 +3,13 @@
* Header file
*/
use PhpOffice\PhpPresentation\Autoloader;
use PhpOffice\PhpPresentation\Settings;
use PhpOffice\PhpPresentation\IOFactory;
use PhpOffice\PhpPresentation\Slide;
use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\AbstractShape;
use PhpOffice\PhpPresentation\DocumentLayout;
use PhpOffice\PhpPresentation\Shape\Drawing;
use PhpOffice\PhpPresentation\Shape\Group;
use PhpOffice\PhpPresentation\Shape\RichText;
use PhpOffice\PhpPresentation\Shape\RichText\BreakElement;
use PhpOffice\PhpPresentation\Shape\RichText\TextElement;
Expand Down Expand Up @@ -69,12 +69,16 @@


// Populate samples
$files = '';
$files = array();
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if (preg_match('/^Sample_\d+_/', $file)) {
$name = str_replace('_', ' ', preg_replace('/(Sample_|\.php)/', '', $file));
$files .= "<li><a href='{$file}'>{$name}</a></li>";
$group = substr($name, 0, 1);
if (!isset($files[$group])) {
$files[$group] = '';
}
$files[$group] .= "<li><a href='{$file}'>{$name}</a></li>";
}
}
closedir($handle);
Expand Down Expand Up @@ -248,7 +252,7 @@ protected function displayShape(AbstractShape $shape)
$this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "Drawing\File"</span></li>');
} elseif($shape instanceof Drawing\Base64) {
$this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "Drawing\Base64"</span></li>');
} elseif($shape instanceof Drawing\Zip) {
} elseif($shape instanceof Drawing\ZipFile) {
$this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "Drawing\Zip"</span></li>');
} elseif($shape instanceof RichText) {
$this->append('<li><span class="shape" id="div'.$shape->getHashCode().'">Shape "RichText"</span></li>');
Expand Down Expand Up @@ -334,7 +338,22 @@ protected function displayShapeInfo(AbstractShape $oShape)
$this->append('<dt>Width</dt><dd>'.$oShape->getWidth().'</dd>');
$this->append('<dt>Rotation</dt><dd>'.$oShape->getRotation().'°</dd>');
$this->append('<dt>Hyperlink</dt><dd>'.ucfirst(var_export($oShape->hasHyperlink(), true)).'</dd>');
$this->append('<dt>Fill</dt><dd>@Todo</dd>');
$this->append('<dt>Fill</dt>');
if (is_null($oShape->getFill())) {
$this->append('<dd>None</dd>');
} else {
switch($oShape->getFill()->getFillType()) {
case \PhpOffice\PhpPresentation\Style\Fill::FILL_NONE:
$this->append('<dd>None</dd>');
break;
case \PhpOffice\PhpPresentation\Style\Fill::FILL_SOLID:
$this->append('<dd>Solid (');
$this->append('Color : #'.$oShape->getFill()->getStartColor()->getRGB());
$this->append(' - Alpha : '.$oShape->getFill()->getStartColor()->getAlpha().'%');
$this->append(')</dd>');
break;
}
}
$this->append('<dt>Border</dt><dd>@Todo</dd>');
$this->append('<dt>IsPlaceholder</dt><dd>' . ($oShape->isPlaceholder() ? 'true' : 'false') . '</dd>');
if($oShape instanceof Drawing\Gd) {
Expand All @@ -346,7 +365,7 @@ protected function displayShapeInfo(AbstractShape $oShape)
ob_end_clean();
$this->append('<dt>Mime-Type</dt><dd>'.$oShape->getMimeType().'</dd>');
$this->append('<dt>Image</dt><dd><img src="data:'.$oShape->getMimeType().';base64,'.base64_encode($sShapeImgContents).'"></dd>');
} elseif($oShape instanceof Drawing) {
} elseif($oShape instanceof Drawing\AbstractDrawingAdapter) {
$this->append('<dt>Name</dt><dd>'.$oShape->getName().'</dd>');
$this->append('<dt>Description</dt><dd>'.$oShape->getDescription().'</dd>');
} elseif($oShape instanceof RichText) {
Expand Down Expand Up @@ -456,10 +475,12 @@ protected function getConstantName($class, $search, $startWith = '') {
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<?php foreach ($files as $key => $fileStr) :?>
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-code fa-lg"></i>&nbsp;Samples<strong class="caret"></strong></a>
<ul class="dropdown-menu"><?php echo $files; ?></ul>
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-code fa-lg"></i>&nbsp;Samples <?php echo $key?>x<strong class="caret"></strong></a>
<ul class="dropdown-menu"><?php echo $fileStr; ?></ul>
</li>
<?php endforeach; ?>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="https://github.com/PHPOffice/PHPPresentation"><i class="fa fa-github fa-lg" title="GitHub"></i>&nbsp;</a></li>
Expand Down
Binary file added samples/resources/logo_ubuntu_transparent.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 2 additions & 3 deletions src/PhpPresentation/HashTable.php
Expand Up @@ -79,13 +79,12 @@ public function add(ComparableInterface $pSource)
{
// Determine hashcode
$hashIndex = $pSource->getHashIndex();

$hashCode = $pSource->getHashCode();

if (is_null($hashIndex)) {
$hashCode = $pSource->getHashCode();
} elseif (isset($this->keyMap[$hashIndex])) {
$hashCode = $this->keyMap[$hashIndex];
} else {
$hashCode = $pSource->getHashCode();
}

// Add value
Expand Down

0 comments on commit cf0982e

Please sign in to comment.