Skip to content

Commit

Permalink
Core : DocumentLayout : Fixed error when using DocumentLayout::LAYOUT…
Browse files Browse the repository at this point in the history
…_CUSTOM
  • Loading branch information
Progi1984 committed Aug 28, 2024
1 parent 3cae28b commit 93e1077
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/changes/1.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
- PowerPoint2007 Writer : Fixed broken animation for first shape - [@shannan1989](https:/shannan1989) in [#783](https:/PHPOffice/PHPPresentation/pull/783)
- Samples : Allow to run without composer - [@pal-software](https:/pal-software) in [#784](https:/PHPOffice/PHPPresentation/pull/784)
- PowerPoint2007 Writer: Extract relations from nested ShapeContainerInterface objects - [@DennisBirkholz](https:/DennisBirkholz) in [#785](https:/PHPOffice/PHPPresentation/pull/785)
- General : Fixed copying bug when presentation had multiple slides [@dees040](https:/dees040) in [#786](https:/PHPOffice/PHPPresentation/pull/786)
- Core : Fixed copying bug when presentation had multiple slides [@dees040](https:/dees040) in [#786](https:/PHPOffice/PHPPresentation/pull/786)
- Core : DocumentLayout : Fixed error when using DocumentLayout::LAYOUT_CUSTOM by [@jiangzhangchan](https:/dees040) fixing [#722](https:/PHPOffice/PHPPresentation/pull/722) in [#811](https:/PHPOffice/PHPPresentation/pull/811)

## Miscellaneous

Expand Down
2 changes: 2 additions & 0 deletions src/PhpPresentation/DocumentLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public function setDocumentLayout($pValue = self::LAYOUT_SCREEN_4X3, $isLandscap

break;
case self::LAYOUT_CUSTOM:
$this->layout = self::LAYOUT_CUSTOM;
break;
default:
$this->layout = self::LAYOUT_CUSTOM;
$this->dimensionX = $pValue['cx'];
Expand Down
18 changes: 18 additions & 0 deletions tests/PhpPresentation/Tests/DocumentLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ public function testSetCustomLayout(): void
self::assertEquals(9144000, $object->getCY());
}

/**
* Test set custom layout.
*/
public function testSetCustomLayoutWithString(): void
{
$object = new DocumentLayout();
$object->setDocumentLayout(DocumentLayout::LAYOUT_CUSTOM);
self::assertEquals(DocumentLayout::LAYOUT_CUSTOM, $object->getDocumentLayout());
// Default value
self::assertEquals(9144000, $object->getCX());
self::assertEquals(6858000, $object->getCY());

$object->setCX(13.333,DocumentLayout::UNIT_CENTIMETER);
$object->setCY(7.5,DocumentLayout::UNIT_CENTIMETER);
self::assertEquals(4799880, $object->getCX());
self::assertEquals(2700000, $object->getCY());
}

public function testCX(): void
{
$value = mt_rand(1, 100000);
Expand Down

0 comments on commit 93e1077

Please sign in to comment.