Skip to content

Commit 03bf65f

Browse files
committed
#28 : ODPresentation Writer : Ability to set auto shrink text
1 parent 6f6b7dd commit 03bf65f

File tree

4 files changed

+36
-31
lines changed

4 files changed

+36
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Features
66
- PowerPoint97 Reader : Implement Basic Reader - @Progi1984 GH-15 GH-14 GH-4
7+
- ODPresentation Writer : Ability to set auto shrink text - @Progi1984 GH-28
78

89
### Bugfix
910
- PowerPoint2007 Writer : Powerpoint Repair Error in Office 2010 - @Progi1984 GH-39

src/PhpPowerpoint/Shape/RichText.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -603,27 +603,30 @@ public function setInsetTop($value = 4.8)
603603
* Set horizontal auto shrink
604604
* @param bool $value
605605
*/
606-
public function setAutoShrinkHorizontal($value = null){
607-
if(is_bool($value)){
608-
$this->autoShrinkHorizontal = $value;
609-
}
610-
return $this;
606+
public function setAutoShrinkHorizontal($value = null)
607+
{
608+
if (is_bool($value)) {
609+
$this->autoShrinkHorizontal = $value;
610+
}
611+
return $this;
611612
}
612613

613614
/**
614615
* Get horizontal auto shrink
615616
* @return bool
616617
*/
617-
public function getAutoShrinkHorizontal(){
618-
return $this->autoShrinkHorizontal;
618+
public function hasAutoShrinkHorizontal()
619+
{
620+
return $this->autoShrinkHorizontal;
619621
}
620622

621623
/**
622624
* Set vertical auto shrink
623625
* @param bool $value
624626
*/
625-
public function setAutoShrinkVertical($value = null){
626-
if(is_bool($value)){
627+
public function setAutoShrinkVertical($value = null)
628+
{
629+
if (is_bool($value)) {
627630
$this->autoShrinkVertical = $value;
628631
}
629632
return $this;
@@ -633,7 +636,8 @@ public function setAutoShrinkVertical($value = null){
633636
* Set vertical auto shrink
634637
* @return bool
635638
*/
636-
public function getAutoShrinkVertical(){
639+
public function hasAutoShrinkVertical()
640+
{
637641
return $this->autoShrinkVertical;
638642
}
639643

src/PhpPowerpoint/Writer/ODPresentation/Content.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ public function writePart(PhpPowerpoint $pPHPPowerPoint)
119119
$objWriter->writeAttribute('style:parent-style-name', 'standard');
120120
// style:graphic-properties
121121
$objWriter->startElement('style:graphic-properties');
122-
if(is_bool($shape->getAutoShrinkVertical())){
122+
if (is_bool($shape->hasAutoShrinkVertical())) {
123123
$objWriter->writeAttribute('draw:auto-grow-height', var_export($shape->getAutoShrinkVertical(), true));
124124
}
125-
if(is_bool($shape->getAutoShrinkHorizontal())){
126-
$objWriter->writeAttribute('draw:auto-grow-width', var_export($shape->getAutoShrinkHorizontal(), true));
125+
if (is_bool($shape->hasAutoShrinkHorizontal())) {
126+
$objWriter->writeAttribute('draw:auto-grow-width', var_export($shape->getAutoShrinkHorizontal(), true));
127127
}
128128
switch ($shape->getFill()->getFillType()){
129129
case Fill::FILL_NONE:

tests/PhpPowerpoint/Tests/Shape/RichTextTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -148,35 +148,35 @@ public function testGetSetAutoFit()
148148

149149
public function testGetSetHAutoShrink()
150150
{
151-
$object = new RichText();
151+
$object = new RichText();
152152

153-
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkHorizontal());
154-
$this->assertNull($object->getAutoShrinkHorizontal());
153+
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkHorizontal());
154+
$this->assertNull($object->hasAutoShrinkHorizontal());
155155

156-
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkHorizontal(2));
157-
$this->assertNull($object->getAutoShrinkHorizontal());
156+
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkHorizontal(2));
157+
$this->assertNull($object->hasAutoShrinkHorizontal());
158158

159-
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkHorizontal(true));
160-
$this->assertTrue($object->getAutoShrinkHorizontal());
159+
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkHorizontal(true));
160+
$this->assertTrue($object->hasAutoShrinkHorizontal());
161161

162-
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkHorizontal(false));
163-
$this->assertFalse($object->getAutoShrinkHorizontal());
162+
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkHorizontal(false));
163+
$this->assertFalse($object->hasAutoShrinkHorizontal());
164164
}
165165
public function testGetSetVAutoShrink()
166166
{
167-
$object = new RichText();
167+
$object = new RichText();
168168

169-
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkVertical());
170-
$this->assertNull($object->getAutoShrinkVertical());
169+
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkVertical());
170+
$this->assertNull($object->hasAutoShrinkVertical());
171171

172-
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkVertical(2));
173-
$this->assertNull($object->getAutoShrinkVertical());
172+
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkVertical(2));
173+
$this->assertNull($object->hasAutoShrinkVertical());
174174

175-
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkVertical(true));
176-
$this->assertTrue($object->getAutoShrinkVertical());
175+
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkVertical(true));
176+
$this->assertTrue($object->hasAutoShrinkVertical());
177177

178-
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkVertical(false));
179-
$this->assertFalse($object->getAutoShrinkVertical());
178+
$this->assertInstanceOf('PhpOffice\\PhpPowerpoint\\Shape\\RichText', $object->setAutoShrinkVertical(false));
179+
$this->assertFalse($object->hasAutoShrinkVertical());
180180
}
181181

182182
public function testGetSetHOverflow()

0 commit comments

Comments
 (0)