Skip to content

BUG: Repair Error / Wrong anchor if you don't set vertical alignment different to VERTICAL_BASE #42

@fregge

Description

@fregge

When you create a richText shape and set the vertical alignment to "VERTICAL_BASE" or leave the default value, the "a:bodyPr" attribute "anchor" is set to "base" wich is wrong and results in a repair error message. The "anchor" attribute is of type "ST_TextAnchoringType".

Valid values can be found here: http://www.datypic.com/sc/ooxml/t-a_ST_TextAnchoringType.html

Steps to reproduce:

$shape = $slide->createRichTextShape();
$shape->setWidth(20);
$shape->setHeight(17);
$shape->setOffsetX(26);
$shape->setOffsetY(20);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(\PhpOffice\PhpPowerpoint\Style\Alignment::HORIZONTAL_CENTER);
$textRun = $shape->createTextRun("test");
$textRun->getFont()->setSize(8);
$textRun->getFont()->setColor( new \PhpOffice\PhpPowerpoint\Style\Color( "000000" ) );

To fix this you have to do it like with the "a:tcPr" Element. But there is a little mistake, too! Not realy a mistake but a wrong variable name. The vertical align is stored in $horizontalAlign (line 628) Perhaps you want to fix this, too...

Anyway... in Writer/PowerPoint2007/Slide.php change line 422 from

$objWriter->writeAttribute('anchor', $shape->getActiveParagraph()->getAlignment()->getVertical());

to

$verticalAlign = $shape->getActiveParagraph()->getAlignment()->getVertical();
if ($verticalAlign != Alignment::VERTICAL_BASE && $verticalAlign != Alignment::VERTICAL_AUTO) {
       $objWriter->writeAttribute('anchor', $verticalAlign);
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions