Skip to content

Commit

Permalink
Closing #798
Browse files Browse the repository at this point in the history
  • Loading branch information
gazzoy committed Oct 16, 2024
1 parent 04700ed commit 5544df9
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/PhpPresentation/Style/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@ public function getPanose(): string
*/
public function setPanose(string $pValue): self
{
if (mb_strlen($pValue) !== 10) {
throw new InvalidParameterException('pValue', $pValue, 'The length is not equals to 10');
}

$allowedChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];
foreach (mb_str_split($pValue) as $char) {
if (!in_array($char, $allowedChars)) {
Expand Down
66 changes: 66 additions & 0 deletions tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This file is part of PHPPresentation - A pure PHP library for reading and writing
* presentations documents.
Expand Down Expand Up @@ -593,6 +594,71 @@ public function testLoadFile01(): void
self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
}

public function testLoadFile02(): void
{
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/issue_00798.pptx';
$object = new PowerPoint2007();
$oPhpPresentation = $object->load($file);
self::assertInstanceOf('PhpOffice\\PhpPresentation\\PhpPresentation', $oPhpPresentation);
// Document Properties
self::assertEquals('Elja van Tol', $oPhpPresentation->getDocumentProperties()->getCreator());
self::assertEquals('Elja van Tol', $oPhpPresentation->getDocumentProperties()->getLastModifiedBy());
self::assertEquals('', $oPhpPresentation->getDocumentProperties()->getTitle());
self::assertEquals('', $oPhpPresentation->getDocumentProperties()->getSubject());
self::assertEquals('', $oPhpPresentation->getDocumentProperties()->getDescription());
self::assertEquals('', $oPhpPresentation->getDocumentProperties()->getKeywords());
self::assertEquals('', $oPhpPresentation->getDocumentProperties()->getCategory());
self::assertEquals('10', $oPhpPresentation->getDocumentProperties()->getRevision());
self::assertEquals('', $oPhpPresentation->getDocumentProperties()->getStatus());
self::assertIsArray($oPhpPresentation->getDocumentProperties()->getCustomProperties());
self::assertCount(0, $oPhpPresentation->getDocumentProperties()->getCustomProperties());

// Presentation Properties
self::assertEquals(PresentationProperties::SLIDESHOW_TYPE_PRESENT, $oPhpPresentation->getPresentationProperties()->getSlideshowType());
// Document Layout
self::assertEquals('', $oPhpPresentation->getLayout()->getDocumentLayout());
self::assertEquals(338.6666666666667, $oPhpPresentation->getLayout()->getCX(DocumentLayout::UNIT_MILLIMETER));
self::assertEquals(190.5, $oPhpPresentation->getLayout()->getCY(DocumentLayout::UNIT_MILLIMETER));

// Slides
self::assertCount(1, $oPhpPresentation->getAllSlides());

// Slide 1
$oSlide1 = $oPhpPresentation->getSlide(0);
$arrayShape = (array) $oSlide1->getShapeCollection();
self::assertCount(1, $arrayShape);
// Slide 1 : Shape 1
/** @var Gd $oShape */
$oShape = $arrayShape[0];
self::assertInstanceOf(RichText::class, $oShape);
self::assertEquals('TextBox 8', $oShape->getName());
self::assertEquals(16, $oShape->getHeight());
self::assertEquals(122, $oShape->getWidth());
self::assertEquals(573, $oShape->getOffsetX());
self::assertEquals(454, $oShape->getOffsetY());
$arrayParagraphs = $oShape->getParagraphs();

Check failure on line 639 in tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (7.1)

Call to an undefined method PhpOffice\PhpPresentation\Shape\Drawing\Gd::getParagraphs().
$oParagraph = $arrayParagraphs[0];
self::assertEquals(Alignment::HORIZONTAL_LEFT, $oParagraph->getAlignment()->getHorizontal());
self::assertFalse($oParagraph->getAlignment()->isRTL());
self::assertEquals(0, $oParagraph->getSpacingAfter());
self::assertEquals(0, $oParagraph->getSpacingBefore());
self::assertEquals(Paragraph::LINE_SPACING_MODE_PERCENT, $oParagraph->getLineSpacingMode());
self::assertEquals(100, $oParagraph->getLineSpacing());
$arrayRichText = $oParagraph->getRichTextElements();
self::assertCount(1, $arrayRichText);
// Slide 1 : Shape 2 : Paragraph 1
$oRichText = $arrayRichText[0];
self::assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\RichText\\Run', $oRichText);
self::assertEquals('Classification: Internal', $oRichText->getText());
self::assertFalse($oRichText->getFont()->isBold());
self::assertEquals(10, $oRichText->getFont()->getSize());
self::assertEquals('FF000000', $oRichText->getFont()->getColor()->getARGB());
self::assertEquals('Calibri', $oRichText->getFont()->getName());
self::assertEquals(Font::FORMAT_COMPLEX_SCRIPT, $oRichText->getFont()->getFormat());
self::assertEquals(Font::CAPITALIZATION_NONE, $oRichText->getFont()->getCapitalization());
self::assertCount(1, $arrayParagraphs);
}

public function testMarkAsFinal(): void
{
$file = PHPPRESENTATION_TESTS_BASE_DIR . '/resources/files/Sample_12.pptx';
Expand Down
Binary file added tests/resources/files/issue_00798.pptx
Binary file not shown.

0 comments on commit 5544df9

Please sign in to comment.