Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] #119 : Protection with password #208

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ script:
## PHPLOC
- ./vendor/bin/phploc src/
## PHPDocumentor
- ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --template="responsive-twig"
# - ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --template="responsive-twig"

after_script:
## PHPDocumentor
- bash .travis_shell_after_success.sh
# - bash .travis_shell_after_success.sh
## Scrutinizer
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"phpoffice/common": "0.2.*"
},
"require-dev": {
"phpunit/phpunit": "~4.8.36",
"phpunit/phpunit": "4.*|5.*|6.*|7.*",
"phpdocumentor/phpdocumentor":"2.*",
"phpmd/phpmd": "2.*",
"sebastian/phpcpd": "2.*",
Expand Down
5 changes: 5 additions & 0 deletions docs/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ MSDN :
MSDN <http://msdn.microsoft.com/en-us/library/documentformat.openxml.presentation(v=office.14).aspx>`__
- `Open XML SDK 2.5 with Validator <http://www.microsoft.com/en-gb/download/details.aspx?id=30425>`__

Library of Congress :

- `OOXML Format Family -- ISO/IEC 29500 and ECMA 376 <https://www.loc.gov/preservation/digital/formats/fdd/fdd000395.shtml>`__
- `Schemas in W3C XML Schema language and in RELAX NG for the Strict variant of PPTX, etc. <http://standards.iso.org/ittf/PubliclyAvailableStandards/c071691_ISO_IEC_29500-1_2016_Electronic_inserts.zip>`__

OpenDocument
---------------------

Expand Down
7 changes: 3 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
stopOnFailure="false">
<testsuites>
<testsuite name="PHPPresentation Test Suite">
<directory>./tests/PhpPresentation</directory>
Expand All @@ -19,7 +18,7 @@
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./build/coverage" charset="UTF-8" highlight="true" />
<log type="coverage-html" target="./build/coverage" />
<log type="coverage-clover" target="./build/logs/clover.xml" />
</logging>
</phpunit>
</phpunit>
6 changes: 3 additions & 3 deletions samples/Sample_02_Serialized.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
echo date('H:i:s') . ' Set properties'.EOL;
$objPHPPresentation->getDocumentProperties()->setCreator('PHPOffice')
->setLastModifiedBy('PHPPresentation Team')
->setTitle('Sample 03 Title')
->setSubject('Sample 03 Subject')
->setDescription('Sample 03 Description')
->setTitle('Sample 02 Title')
->setSubject('Sample 02 Subject')
->setDescription('Sample 02 Description')
->setKeywords('office 2007 openxml libreoffice odt php')
->setCategory('Sample Category');

Expand Down
28 changes: 28 additions & 0 deletions samples/Sample_21_Password.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

set_time_limit(10);

include_once 'Sample_Header.php';

use PhpOffice\PhpPresentation\IOFactory;
use PhpOffice\PhpPresentation\Slide;
use PhpOffice\PhpPresentation\Shape\RichText;

echo '<h2>ODPresentation</h2>';
$pptReader = IOFactory::createReader('ODPresentation');
$pptReader->setPassword('motdepasse');
$oPHPPresentation = $pptReader->load('resources/SamplePassword.odp');

$oTree = new PhpPptTree($oPHPPresentation);
echo $oTree->display();

echo '<h2>PowerPoint2007</h2>';
$pptReader = IOFactory::createReader('PowerPoint2007');
$pptReader->setPassword('motdepasse');
$oPHPPresentation = $pptReader->load('resources/SamplePassword.pptx');

$oTree = new PhpPptTree($oPHPPresentation);
echo $oTree->display();
if (!CLI) {
include_once 'Sample_Footer.php';
}
258 changes: 146 additions & 112 deletions samples/Sample_Header.php

Large diffs are not rendered by default.

Binary file added samples/resources/SamplePassword.odp
Binary file not shown.
18 changes: 9 additions & 9 deletions src/PhpPresentation/AbstractShape.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function getContainer()
* @param \PhpOffice\PhpPresentation\ShapeContainerInterface $pValue
* @param bool $pOverrideOld If a Slide has already been assigned, overwrite it and remove image from old Slide?
* @throws \Exception
* @return self
* @return $this
*/
public function setContainer(ShapeContainerInterface $pValue = null, $pOverrideOld = false)
{
Expand Down Expand Up @@ -204,7 +204,7 @@ public function getOffsetX()
* Set OffsetX
*
* @param int $pValue
* @return self
* @return $this
*/
public function setOffsetX($pValue = 0)
{
Expand All @@ -227,7 +227,7 @@ public function getOffsetY()
* Set OffsetY
*
* @param int $pValue
* @return self
* @return $this
*/
public function setOffsetY($pValue = 0)
{
Expand All @@ -250,7 +250,7 @@ public function getWidth()
* Set Width
*
* @param int $pValue
* @return self
* @return $this
*/
public function setWidth($pValue = 0)
{
Expand All @@ -272,7 +272,7 @@ public function getHeight()
* Set Height
*
* @param int $pValue
* @return self
* @return $this
*/
public function setHeight($pValue = 0)
{
Expand All @@ -286,7 +286,7 @@ public function setHeight($pValue = 0)
* @param int $width
* @param int $height
* @example $objDrawing->setWidthAndHeight(160,120);
* @return self
* @return $this
*/
public function setWidthAndHeight($width = 0, $height = 0)
{
Expand All @@ -309,7 +309,7 @@ public function getRotation()
* Set Rotation
*
* @param int $pValue
* @return self
* @return $this
*/
public function setRotation($pValue = 0)
{
Expand Down Expand Up @@ -363,7 +363,7 @@ public function getShadow()
*
* @param \PhpOffice\PhpPresentation\Style\Shadow $pValue
* @throws \Exception
* @return self
* @return $this
*/
public function setShadow(Shadow $pValue = null)
{
Expand Down Expand Up @@ -400,7 +400,7 @@ public function getHyperlink()
*
* @param \PhpOffice\PhpPresentation\Shape\Hyperlink $pHyperlink
* @throws \Exception
* @return self
* @return $this
*/
public function setHyperlink(Hyperlink $pHyperlink = null)
{
Expand Down
44 changes: 44 additions & 0 deletions src/PhpPresentation/Reader/AbstractReader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* This file is part of PHPPresentation - A pure PHP library for reading and writing
* presentations documents.
*
* PHPPresentation is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
*
* @link https://github.com/PHPOffice/PHPPresentation
* @copyright 2009-2015 PHPPresentation contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/

namespace PhpOffice\PhpPresentation\Reader;

abstract class AbstractReader
{
/**
* @var string
*/
protected $password;

/**
* @return string
*/
public function getPassword()
{
return $this->password;
}

/**
* @param string $password
* @return AbstractReader
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
}
Loading