Skip to content

Commit

Permalink
Merge branch 'develop' into issue192
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Apr 1, 2016
2 parents 1468e7d + ee07eb7 commit f33d8f3
Show file tree
Hide file tree
Showing 15 changed files with 255 additions and 333 deletions.
68 changes: 33 additions & 35 deletions src/PhpPresentation/Reader/PowerPoint97.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,10 @@ private function loadPicturesStream()
$stream = $this->streamPictures;

$pos = 0;
$readSuccess = true;
do {
$arrayRH = $this->loadRecordHeader($stream, $pos);
$pos += 8;
$readSuccess = false;
if ($arrayRH['recVer'] == 0x00 && ($arrayRH['recType'] == 0xF007 || ($arrayRH['recType'] >= 0xF018 && $arrayRH['recType'] <= 0xF117))) {
//@link : http://msdn.microsoft.com/en-us/library/dd950560(v=office.12).aspx
if ($arrayRH['recType'] == 0xF007) {
Expand All @@ -481,8 +481,7 @@ private function loadPicturesStream()
$this->arrayPictures[] = $arrayRecord['picture'];
}
}
} else {
$readSuccess = false;
$readSuccess = true;
}
} while ($readSuccess === true);
}
Expand Down Expand Up @@ -677,11 +676,11 @@ public static function getInt4d($data, $pos)
// http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334
// Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems
$or24 = ord($data[$pos + 3]);

$ord24 = ($or24 & 127) << 24;
if ($or24 >= 128) {
// negative number
$ord24 = -abs((256 - $or24) << 24);
} else {
$ord24 = ($or24 & 127) << 24;
}
return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $ord24;
}
Expand Down Expand Up @@ -825,37 +824,36 @@ private function readRecordDocumentContainer($stream, $pos)
$fontCollection['recLen'] -= 8;
if ($fontEntityAtom['recVer'] != 0x0 || $fontEntityAtom['recInstance'] > 128 || $fontEntityAtom['recType'] != self::RT_FONTENTITYATOM) {
throw new \Exception('File PowerPoint 97 in error (Location : RTDocument > RT_Environment > RT_FontCollection > RT_FontEntityAtom).');
} else {
$string = '';
for ($inc = 0; $inc < 32; $inc++) {
$char = self::getInt2d($stream, $pos);
$pos += 2;
$fontCollection['recLen'] -= 2;
$string .= chr($char);
}
$this->arrayFonts[] = $string;

// lfCharSet (1 byte)
$pos += 1;
$fontCollection['recLen'] -= 1;

// fEmbedSubsetted (1 bit)
// unused (7 bits)
$pos += 1;
$fontCollection['recLen'] -= 1;

// rasterFontType (1 bit)
// deviceFontType (1 bit)
// truetypeFontType (1 bit)
// fNoFontSubstitution (1 bit)
// reserved (4 bits)
$pos += 1;
$fontCollection['recLen'] -= 1;

// lfPitchAndFamily (1 byte)
$pos += 1;
$fontCollection['recLen'] -= 1;
}
$string = '';
for ($inc = 0; $inc < 32; $inc++) {
$char = self::getInt2d($stream, $pos);
$pos += 2;
$fontCollection['recLen'] -= 2;
$string .= chr($char);
}
$this->arrayFonts[] = $string;

// lfCharSet (1 byte)
$pos += 1;
$fontCollection['recLen'] -= 1;

// fEmbedSubsetted (1 bit)
// unused (7 bits)
$pos += 1;
$fontCollection['recLen'] -= 1;

// rasterFontType (1 bit)
// deviceFontType (1 bit)
// truetypeFontType (1 bit)
// fNoFontSubstitution (1 bit)
// reserved (4 bits)
$pos += 1;
$fontCollection['recLen'] -= 1;

// lfPitchAndFamily (1 byte)
$pos += 1;
$fontCollection['recLen'] -= 1;

$fontEmbedData1 = $this->loadRecordHeader($stream, $pos);
if ($fontEmbedData1['recVer'] == 0x0 && $fontEmbedData1['recInstance'] >= 0x000 && $fontEmbedData1['recInstance'] <= 0x003 && $fontEmbedData1['recType'] == self::RT_FONTEMBEDDATABLOB) {
Expand Down
7 changes: 3 additions & 4 deletions src/PhpPresentation/Shape/RichText.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,12 @@ public function getParagraphs()
*/
public function setParagraphs($paragraphs = null)
{
if (is_array($paragraphs)) {
$this->richTextParagraphs = $paragraphs;
$this->activeParagraph = count($this->richTextParagraphs) - 1;
} else {
if (!is_array($paragraphs)) {
throw new \Exception("Invalid \PhpOffice\PhpPresentation\Shape\RichText\Paragraph[] array passed.");
}

$this->richTextParagraphs = $paragraphs;
$this->activeParagraph = count($this->richTextParagraphs) - 1;
return $this;
}

Expand Down
16 changes: 8 additions & 8 deletions src/PhpPresentation/Slide/Background/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ public function getPath()
public function setPath($pValue = '', $pVerifyFile = true)
{
if ($pVerifyFile) {
if (file_exists($pValue)) {
$this->path = $pValue;

if ($this->width == 0 && $this->height == 0) {
// Get width/height
list($this->width, $this->height) = getimagesize($pValue);
}
} else {
if (!file_exists($pValue)) {
throw new \Exception("File $pValue not found!");
}
$this->path = $pValue;

if ($this->width == 0 && $this->height == 0) {
// Get width/height
list($this->width, $this->height) = getimagesize($pValue);
}

} else {
$this->path = $pValue;
}
Expand Down
36 changes: 16 additions & 20 deletions src/PhpPresentation/Style/Alignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class Alignment implements ComparableInterface
const VERTICAL_TOP = 't';
const VERTICAL_CENTER = 'ctr';

private $supportedStyles = array(
self::HORIZONTAL_GENERAL,
self::HORIZONTAL_LEFT,
self::HORIZONTAL_RIGHT,
);

/**
* Horizontal
*
Expand All @@ -58,28 +64,28 @@ class Alignment implements ComparableInterface
*
* @var int
*/
private $level;
private $level = 0;

/**
* Indent - only possible with horizontal alignment left and right
*
* @var int
*/
private $indent;
private $indent = 0;

/**
* Margin left - only possible with horizontal alignment left and right
*
* @var int
*/
private $marginLeft;
private $marginLeft = 0;

/**
* Margin right - only possible with horizontal alignment left and right
*
* @var int
*/
private $marginRight;
private $marginRight = 0;

/**
* Hash index
Expand All @@ -96,10 +102,6 @@ public function __construct()
// Initialise values
$this->horizontal = self::HORIZONTAL_LEFT;
$this->vertical = self::VERTICAL_BASE;
$this->level = 0;
$this->indent = 0;
$this->marginLeft = 0;
$this->marginRight = 0;
}

/**
Expand Down Expand Up @@ -199,10 +201,8 @@ public function getIndent()
*/
public function setIndent($pValue = 0)
{
if ($pValue > 0) {
if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && $this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_RIGHT) {
$pValue = 0; // indent not supported
}
if ($pValue > 0 && !in_array($this->getHorizontal(), $this->supportedStyles)) {
$pValue = 0; // indent not supported
}

$this->indent = $pValue;
Expand All @@ -228,10 +228,8 @@ public function getMarginLeft()
*/
public function setMarginLeft($pValue = 0)
{
if ($pValue > 0) {
if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && $this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_RIGHT) {
$pValue = 0; // margin left not supported
}
if ($pValue > 0 && !in_array($this->getHorizontal(), $this->supportedStyles)) {
$pValue = 0; // margin left not supported
}

$this->marginLeft = $pValue;
Expand All @@ -257,10 +255,8 @@ public function getMarginRight()
*/
public function setMarginRight($pValue = 0)
{
if ($pValue > 0) {
if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && $this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_RIGHT) {
$pValue = 0; // margin left not supported
}
if ($pValue > 0 && !in_array($this->getHorizontal(), $this->supportedStyles)) {
$pValue = 0; // margin right not supported
}

$this->marginRight = $pValue;
Expand Down
5 changes: 2 additions & 3 deletions src/PhpPresentation/Writer/ODPresentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,10 @@ public function setUseDiskCaching($pValue = false, $pDirectory = null)
$this->useDiskCaching = $pValue;

if (!is_null($pDirectory)) {
if (is_dir($pDirectory)) {
$this->diskCachingDirectory = $pDirectory;
} else {
if (!is_dir($pDirectory)) {
throw new \Exception("Directory does not exist: $pDirectory");
}
$this->diskCachingDirectory = $pDirectory;
}

return $this;
Expand Down
Loading

0 comments on commit f33d8f3

Please sign in to comment.