Skip to content
Closed
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
31 changes: 31 additions & 0 deletions src/PhpWord/Style/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ class Font extends AbstractStyle
*/
private $rtl = false;

/**
* Vertically raised or lowered text
* @var int
* @link http://www.datypic.com/sc/ooxml/e-w_position-1.html
*/
private $position;

/**
* Create new font style
*
Expand Down Expand Up @@ -272,6 +279,7 @@ public function getStyleValues()
'scale' => $this->getScale(),
'spacing' => $this->getSpacing(),
'kerning' => $this->getKerning(),
'position' => $this->getPosition(),
),
'paragraph' => $this->getParagraph(),
'rtl' => $this->isRTL(),
Expand Down Expand Up @@ -854,4 +862,27 @@ public function getParagraphStyle()
{
return $this->getParagraph();
}

/**
* Get position
*
* @return int
*/
public function getPosition()
{
return $this->position;
}

/**
* Set position
*
* @param int $value
* @return self
*/
public function setPosition($value = null)
{
$this->position = $this->setNumericVal($value, null);

return $this;
}
}
30 changes: 30 additions & 0 deletions src/PhpWord/Style/Frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ class Frame extends AbstractStyle
*/
private $wrap;

/**
* Vertically raised or lowered text
* @var int
* @link http://www.datypic.com/sc/ooxml/e-w_position-1.html
*/
private $position;

/**
* Create a new instance
*
Expand Down Expand Up @@ -538,4 +545,27 @@ public function setWrap($value)

return $this;
}

/**
* Get position
*
* @return int
*/
public function getPosition()
{
return $this->position;
}

/**
* Set position
*
* @param int $value
* @return self
*/
public function setPosition($value = null)
{
$this->position = $this->setNumericVal($value, null);

return $this;
}
}
13 changes: 13 additions & 0 deletions src/PhpWord/Writer/Word2007/Element/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
use PhpOffice\PhpWord\Element\Image as ImageElement;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Writer\Word2007\Style\Image as ImageStyleWriter;
use PhpOffice\PhpWord\Style\Frame as FrameStyle;
use PhpOffice\PhpWord\Style\Font as FontStyle;
use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter;

/**
* Image element writer
Expand Down Expand Up @@ -65,6 +68,16 @@ private function writeImage(XMLWriter $xmlWriter, ImageElement $element)
}

$xmlWriter->startElement('w:r');

// Write position
$position = $style->getPosition();
if ($position && $style->getWrap() == FrameStyle::WRAP_INLINE) {
$fontStyle = new FontStyle('text');
$fontStyle->setPosition($position);
$fontStyleWriter = new FontStyleWriter($xmlWriter, $fontStyle);
$fontStyleWriter->write();
}

$xmlWriter->startElement('w:pict');
$xmlWriter->startElement('v:shape');
$xmlWriter->writeAttribute('type', '#_x0000_t75');
Expand Down
3 changes: 3 additions & 0 deletions src/PhpWord/Writer/Word2007/Style/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ private function writeStyle()
$xmlWriter->writeElementIf($styleName === null && $style->isRTL(), 'w:rtl');
}

// Position
$xmlWriter->writeElementIf($style->getPosition(), 'w:position', 'w:val', $style->getPosition());

$xmlWriter->endElement();
}

Expand Down