2014-05-07 21:27:51 +02:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This file is part of PHPWord - A pure PHP library for reading and writing
|
2014-05-08 12:58:44 +07:00
|
|
|
* word processing documents.
|
|
|
|
|
*
|
|
|
|
|
* PHPWord is free software distributed under the terms of the GNU Lesser
|
|
|
|
|
* General Public License version 3 as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* For the full copyright and license information, please read the LICENSE
|
|
|
|
|
* file that was distributed with this source code. For the full list of
|
|
|
|
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
|
|
|
|
*
|
2017-11-04 22:44:12 +01:00
|
|
|
* @see https://github.com/PHPOffice/PHPWord
|
2022-09-16 11:45:45 +02:00
|
|
|
*
|
2014-05-08 12:58:44 +07:00
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
|
|
|
|
*/
|
2014-05-07 21:27:51 +02:00
|
|
|
|
|
|
|
|
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
|
|
|
|
|
|
|
|
|
|
use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-09-16 11:45:45 +02:00
|
|
|
* TextBox style writer.
|
2014-05-07 21:27:51 +02:00
|
|
|
*
|
2014-05-08 12:58:44 +07:00
|
|
|
* @since 0.11.0
|
2014-05-07 21:27:51 +02:00
|
|
|
*/
|
2014-06-05 12:52:39 +07:00
|
|
|
class TextBox extends Frame
|
2014-05-07 21:27:51 +02:00
|
|
|
{
|
2014-05-08 22:42:56 +07:00
|
|
|
/**
|
2014-07-03 15:40:24 +04:00
|
|
|
* Writer inner margin.
|
2014-05-08 22:42:56 +07:00
|
|
|
*/
|
2022-09-16 11:45:45 +02:00
|
|
|
public function writeInnerMargin(): void
|
2014-05-08 22:42:56 +07:00
|
|
|
{
|
|
|
|
|
$style = $this->getStyle();
|
2014-05-15 14:41:08 +07:00
|
|
|
if (!$style instanceof TextBoxStyle || !$style->hasInnerMargins()) {
|
2014-05-08 22:42:56 +07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$xmlWriter = $this->getXmlWriter();
|
|
|
|
|
$margins = implode(', ', $style->getInnerMargin());
|
2014-06-05 12:52:39 +07:00
|
|
|
|
2014-05-08 22:42:56 +07:00
|
|
|
$xmlWriter->writeAttribute('inset', $margins);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-08 19:25:29 +07:00
|
|
|
/**
|
2014-07-03 15:40:24 +04:00
|
|
|
* Writer border.
|
2014-05-08 19:25:29 +07:00
|
|
|
*/
|
2022-09-16 11:45:45 +02:00
|
|
|
public function writeBorder(): void
|
2014-05-08 19:25:29 +07:00
|
|
|
{
|
2014-06-05 12:52:39 +07:00
|
|
|
$style = $this->getStyle();
|
|
|
|
|
if (!$style instanceof TextBoxStyle) {
|
|
|
|
|
return;
|
2014-05-07 21:27:51 +02:00
|
|
|
}
|
2014-06-05 12:52:39 +07:00
|
|
|
$xmlWriter = $this->getXmlWriter();
|
2014-05-08 09:52:11 +07:00
|
|
|
|
2014-06-05 12:52:39 +07:00
|
|
|
$xmlWriter->startElement('v:stroke');
|
|
|
|
|
$xmlWriter->writeAttributeIf($style->getBorderSize() !== null, 'weight', $style->getBorderSize() . 'pt');
|
|
|
|
|
$xmlWriter->writeAttributeIf($style->getBorderColor() !== null, 'color', $style->getBorderColor());
|
|
|
|
|
$xmlWriter->endElement(); // v:stroke
|
2014-05-07 21:27:51 +02:00
|
|
|
}
|
|
|
|
|
}
|