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

Core : DocumentLayout : Fixed error when using DocumentLayout::LAYOUT_CUSTOM #811

Merged
merged 1 commit into from
Aug 28, 2024
Merged
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
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://github.com/shannan1989) in [#783](https://github.com/PHPOffice/PHPPresentation/pull/783)
- Samples : Allow to run without composer - [@pal-software](https://github.com/pal-software) in [#784](https://github.com/PHPOffice/PHPPresentation/pull/784)
- PowerPoint2007 Writer: Extract relations from nested ShapeContainerInterface objects - [@DennisBirkholz](https://github.com/DennisBirkholz) in [#785](https://github.com/PHPOffice/PHPPresentation/pull/785)
- General : Fixed copying bug when presentation had multiple slides [@dees040](https://github.com/dees040) in [#786](https://github.com/PHPOffice/PHPPresentation/pull/786)
- Core : Fixed copying bug when presentation had multiple slides [@dees040](https://github.com/dees040) in [#786](https://github.com/PHPOffice/PHPPresentation/pull/786)
- Core : DocumentLayout : Fixed error when using DocumentLayout::LAYOUT_CUSTOM by [@jiangzhangchan](https://github.com/dees040) fixing [#722](https://github.com/PHPOffice/PHPPresentation/pull/722) in [#811](https://github.com/PHPOffice/PHPPresentation/pull/811)

## Miscellaneous

Expand Down
3 changes: 3 additions & 0 deletions src/PhpPresentation/DocumentLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ 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
Loading