Remove some duplication on Word2007 writers
This commit is contained in:
parent
237625d22a
commit
04e6dbc86a
|
|
@ -9,7 +9,9 @@
|
|||
|
||||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
|
||||
use PhpOffice\PhpWord\Exception\Exception;
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\Container\Container;
|
||||
use PhpOffice\PhpWord\Element\Text;
|
||||
use PhpOffice\PhpWord\Element\TextRun;
|
||||
use PhpOffice\PhpWord\Element\Link;
|
||||
|
|
@ -75,27 +77,10 @@ class Base extends WriterPart
|
|||
*/
|
||||
protected function writeTextRun(XMLWriter $xmlWriter, TextRun $textrun)
|
||||
{
|
||||
$elements = $textrun->getElements();
|
||||
$styleParagraph = $textrun->getParagraphStyle();
|
||||
$xmlWriter->startElement('w:p');
|
||||
$this->writeInlineParagraphStyle($xmlWriter, $styleParagraph);
|
||||
if (count($elements) > 0) {
|
||||
foreach ($elements as $element) {
|
||||
if ($element instanceof Text) {
|
||||
$this->writeText($xmlWriter, $element, true);
|
||||
} elseif ($element instanceof Link) {
|
||||
$this->writeLink($xmlWriter, $element, true);
|
||||
} elseif ($element instanceof TextBreak) {
|
||||
$xmlWriter->writeElement('w:br');
|
||||
} elseif ($element instanceof Image) {
|
||||
$this->writeImage($xmlWriter, $element, true);
|
||||
} elseif ($element instanceof Object) {
|
||||
$this->writeObject($xmlWriter, $element, true);
|
||||
} elseif ($element instanceof Footnote) {
|
||||
$this->writeFootnote($xmlWriter, $element, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->writeContainerElements($xmlWriter, $textrun);
|
||||
$xmlWriter->endElement(); // w:p
|
||||
}
|
||||
|
||||
|
|
@ -254,8 +239,9 @@ class Base extends WriterPart
|
|||
* @param XMLWriter $xmlWriter
|
||||
* @param TextBreak $element
|
||||
*/
|
||||
protected function writeTextBreak($xmlWriter, TextBreak $element = null)
|
||||
protected function writeTextBreak(XMLWriter $xmlWriter, TextBreak $element = null, $withoutP = false)
|
||||
{
|
||||
if (!$withoutP) {
|
||||
$hasStyle = false;
|
||||
$styleFont = null;
|
||||
$styleParagraph = null;
|
||||
|
|
@ -274,8 +260,10 @@ class Base extends WriterPart
|
|||
}
|
||||
$xmlWriter->endElement(); // w:p
|
||||
} else {
|
||||
// Null element. No paragraph nor font style
|
||||
$xmlWriter->writeElement('w:p', null);
|
||||
$xmlWriter->writeElement('w:p');
|
||||
}
|
||||
} else {
|
||||
$xmlWriter->writeElement('w:br');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -316,16 +304,16 @@ class Base extends WriterPart
|
|||
*/
|
||||
protected function writeTable(XMLWriter $xmlWriter, Table $table)
|
||||
{
|
||||
$_rows = $table->getRows();
|
||||
$_cRows = count($_rows);
|
||||
$rows = $table->getRows();
|
||||
$cRows = count($rows);
|
||||
|
||||
if ($_cRows > 0) {
|
||||
if ($cRows > 0) {
|
||||
$xmlWriter->startElement('w:tbl');
|
||||
|
||||
// Table grid
|
||||
$cellWidths = array();
|
||||
for ($i = 0; $i < $_cRows; $i++) {
|
||||
$row = $_rows[$i];
|
||||
for ($i = 0; $i < $cRows; $i++) {
|
||||
$row = $rows[$i];
|
||||
$cells = $row->getCells();
|
||||
if (count($cells) <= count($cellWidths)) {
|
||||
continue;
|
||||
|
|
@ -368,8 +356,8 @@ class Base extends WriterPart
|
|||
}
|
||||
|
||||
// Table rows
|
||||
for ($i = 0; $i < $_cRows; $i++) {
|
||||
$row = $_rows[$i];
|
||||
for ($i = 0; $i < $cRows; $i++) {
|
||||
$row = $rows[$i];
|
||||
$height = $row->getHeight();
|
||||
$rowStyle = $row->getStyle();
|
||||
$tblHeader = $rowStyle->getTblHeader();
|
||||
|
|
@ -377,7 +365,6 @@ class Base extends WriterPart
|
|||
$exactHeight = $rowStyle->getExactHeight();
|
||||
|
||||
$xmlWriter->startElement('w:tr');
|
||||
|
||||
if (!is_null($height) || !is_null($tblHeader) || !is_null($cantSplit)) {
|
||||
$xmlWriter->startElement('w:trPr');
|
||||
if (!is_null($height)) {
|
||||
|
|
@ -398,55 +385,23 @@ class Base extends WriterPart
|
|||
}
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
foreach ($row->getCells() as $cell) {
|
||||
$xmlWriter->startElement('w:tc');
|
||||
|
||||
$cellStyle = $cell->getStyle();
|
||||
$width = $cell->getWidth();
|
||||
|
||||
$xmlWriter->startElement('w:tc');
|
||||
$xmlWriter->startElement('w:tcPr');
|
||||
$xmlWriter->startElement('w:tcW');
|
||||
$xmlWriter->writeAttribute('w:w', $width);
|
||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
||||
$xmlWriter->endElement();
|
||||
|
||||
$xmlWriter->endElement(); // w:tcW
|
||||
if ($cellStyle instanceof Cell) {
|
||||
$this->writeCellStyle($xmlWriter, $cellStyle);
|
||||
}
|
||||
|
||||
$xmlWriter->endElement();
|
||||
|
||||
$_elements = $cell->getElements();
|
||||
if (count($_elements) > 0) {
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof Text) {
|
||||
$this->writeText($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextRun) {
|
||||
$this->writeTextRun($xmlWriter, $element);
|
||||
} elseif ($element instanceof Link) {
|
||||
$this->writeLink($xmlWriter, $element);
|
||||
} elseif ($element instanceof PreserveText) {
|
||||
$this->writePreserveText($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextBreak) {
|
||||
$this->writeTextBreak($xmlWriter, $element);
|
||||
} elseif ($element instanceof ListItem) {
|
||||
$this->writeListItem($xmlWriter, $element);
|
||||
} elseif ($element instanceof Image) {
|
||||
$this->writeImage($xmlWriter, $element);
|
||||
} elseif ($element instanceof Object) {
|
||||
$this->writeObject($xmlWriter, $element);
|
||||
} elseif ($element instanceof CheckBox) {
|
||||
$this->writeCheckBox($xmlWriter, $element);
|
||||
$xmlWriter->endElement(); // w:tcPr
|
||||
$this->writeContainerElements($xmlWriter, $cell);
|
||||
$xmlWriter->endElement(); // w:tc
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->writeTextBreak($xmlWriter);
|
||||
}
|
||||
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
$xmlWriter->endElement();
|
||||
$xmlWriter->endElement(); // w:tr
|
||||
}
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
|
@ -953,98 +908,35 @@ class Base extends WriterPart
|
|||
{
|
||||
$bgColor = $style->getBgColor();
|
||||
$brdCol = $style->getBorderColor();
|
||||
|
||||
$brdSz = $style->getBorderSize();
|
||||
$bTop = (!is_null($brdSz[0])) ? true : false;
|
||||
$bLeft = (!is_null($brdSz[1])) ? true : false;
|
||||
$bRight = (!is_null($brdSz[2])) ? true : false;
|
||||
$bBottom = (!is_null($brdSz[3])) ? true : false;
|
||||
$bInsH = (!is_null($brdSz[4])) ? true : false;
|
||||
$bInsV = (!is_null($brdSz[5])) ? true : false;
|
||||
$borders = ($bTop || $bLeft || $bRight || $bBottom || $bInsH || $bInsV) ? true : false;
|
||||
|
||||
$cellMargin = $style->getCellMargin();
|
||||
$mTop = (!is_null($cellMargin[0])) ? true : false;
|
||||
$mLeft = (!is_null($cellMargin[1])) ? true : false;
|
||||
$mRight = (!is_null($cellMargin[2])) ? true : false;
|
||||
$mBottom = (!is_null($cellMargin[3])) ? true : false;
|
||||
$margins = ($mTop || $mLeft || $mRight || $mBottom) ? true : false;
|
||||
|
||||
if ($margins || $borders) {
|
||||
// If any of the borders/margins is set, process them
|
||||
$hasBorders = false;
|
||||
for ($i = 0; $i < 6; $i++) {
|
||||
if (!is_null($brdSz[$i])) {
|
||||
$hasBorders = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$hasMargins = false;
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
if (!is_null($cellMargin[$i])) {
|
||||
$hasMargins = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($hasMargins || $hasBorders) {
|
||||
$xmlWriter->startElement('w:tblPr');
|
||||
if ($margins) {
|
||||
if ($hasMargins) {
|
||||
$xmlWriter->startElement('w:tblCellMar');
|
||||
if ($mTop) {
|
||||
$xmlWriter->startElement('w:top');
|
||||
$xmlWriter->writeAttribute('w:w', $cellMargin[0]);
|
||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
||||
$xmlWriter->endElement();
|
||||
$this->writeMarginBorder($xmlWriter, $cellMargin);
|
||||
$xmlWriter->endElement(); // w:tblCellMar
|
||||
}
|
||||
if ($mLeft) {
|
||||
$xmlWriter->startElement('w:left');
|
||||
$xmlWriter->writeAttribute('w:w', $cellMargin[1]);
|
||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
if ($mRight) {
|
||||
$xmlWriter->startElement('w:right');
|
||||
$xmlWriter->writeAttribute('w:w', $cellMargin[2]);
|
||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
if ($mBottom) {
|
||||
$xmlWriter->startElement('w:bottom');
|
||||
$xmlWriter->writeAttribute('w:w', $cellMargin[3]);
|
||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
if ($borders) {
|
||||
if ($hasBorders) {
|
||||
$xmlWriter->startElement('w:tblBorders');
|
||||
if ($bTop) {
|
||||
$xmlWriter->startElement('w:top');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[0]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[0]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
if ($bLeft) {
|
||||
$xmlWriter->startElement('w:left');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[1]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[1]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
if ($bRight) {
|
||||
$xmlWriter->startElement('w:right');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[2]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[2]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
if ($bBottom) {
|
||||
$xmlWriter->startElement('w:bottom');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[3]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[3]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
if ($bInsH) {
|
||||
$xmlWriter->startElement('w:insideH');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[4]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[4]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
if ($bInsV) {
|
||||
$xmlWriter->startElement('w:insideV');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[5]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[5]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
$xmlWriter->endElement();
|
||||
$this->writeMarginBorder($xmlWriter, $brdSz, $brdCol);
|
||||
$xmlWriter->endElement(); // w:tblBorders
|
||||
}
|
||||
$xmlWriter->endElement(); // w:tblPr
|
||||
}
|
||||
|
|
@ -1077,61 +969,37 @@ class Base extends WriterPart
|
|||
*/
|
||||
protected function writeRowStyle(XMLWriter $xmlWriter, $type, TableStyle $style)
|
||||
{
|
||||
$brdSz = $style->getBorderSize();
|
||||
$brdCol = $style->getBorderColor();
|
||||
$bgColor = $style->getBgColor();
|
||||
|
||||
$bTop = (!is_null($brdSz[0])) ? true : false;
|
||||
$bLeft = (!is_null($brdSz[1])) ? true : false;
|
||||
$bRight = (!is_null($brdSz[2])) ? true : false;
|
||||
$bBottom = (!is_null($brdSz[3])) ? true : false;
|
||||
|
||||
$xmlWriter->startElement('w:tblStylePr');
|
||||
$xmlWriter->writeAttribute('w:type', $type);
|
||||
|
||||
$xmlWriter->startElement('w:tcPr');
|
||||
if (!is_null($bgColor)) {
|
||||
$xmlWriter->startElement('w:shd');
|
||||
$xmlWriter->writeAttribute('w:val', 'clear');
|
||||
$xmlWriter->writeAttribute('w:color', 'auto');
|
||||
$xmlWriter->writeAttribute('w:fill', $bgColor);
|
||||
$xmlWriter->endElement();
|
||||
$xmlWriter->endElement(); // w:shd
|
||||
}
|
||||
|
||||
// Borders
|
||||
$brdSz = $style->getBorderSize();
|
||||
$brdCol = $style->getBorderColor();
|
||||
$hasBorders = false;
|
||||
for ($i = 0; $i < 6; $i++) {
|
||||
if (!is_null($brdSz[$i])) {
|
||||
$hasBorders = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($hasBorders) {
|
||||
$xmlWriter->startElement('w:tcBorders');
|
||||
if ($bTop) {
|
||||
$xmlWriter->startElement('w:top');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[0]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[0]);
|
||||
$xmlWriter->endElement();
|
||||
$this->writeMarginBorder($xmlWriter, $brdSz, $brdCol);
|
||||
$xmlWriter->endElement(); // w:tcBorders
|
||||
}
|
||||
if ($bLeft) {
|
||||
$xmlWriter->startElement('w:left');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[1]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[1]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
if ($bRight) {
|
||||
$xmlWriter->startElement('w:right');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[2]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[2]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
if ($bBottom) {
|
||||
$xmlWriter->startElement('w:bottom');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[3]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[3]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
$xmlWriter->endElement();
|
||||
|
||||
$xmlWriter->endElement();
|
||||
|
||||
$xmlWriter->endElement();
|
||||
$xmlWriter->endElement(); // w:tcPr
|
||||
$xmlWriter->endElement(); // w:tblStylePr
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1147,14 +1015,15 @@ class Base extends WriterPart
|
|||
$textDir = $style->getTextDirection();
|
||||
$brdSz = $style->getBorderSize();
|
||||
$brdCol = $style->getBorderColor();
|
||||
$hasBorders = false;
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
if (!is_null($brdSz[$i])) {
|
||||
$hasBorders = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$bTop = (!is_null($brdSz[0])) ? true : false;
|
||||
$bLeft = (!is_null($brdSz[1])) ? true : false;
|
||||
$bRight = (!is_null($brdSz[2])) ? true : false;
|
||||
$bBottom = (!is_null($brdSz[3])) ? true : false;
|
||||
$borders = ($bTop || $bLeft || $bRight || $bBottom) ? true : false;
|
||||
|
||||
$styles = (!is_null($bgColor) || !is_null($valign) || !is_null($textDir) || $borders) ? true : false;
|
||||
$styles = (!is_null($bgColor) || !is_null($valign) || !is_null($textDir) || $hasBorders) ? true : false;
|
||||
|
||||
if ($styles) {
|
||||
if (!is_null($textDir)) {
|
||||
|
|
@ -1177,54 +1046,11 @@ class Base extends WriterPart
|
|||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
if ($borders) {
|
||||
$_defaultColor = $style->getDefaultBorderColor();
|
||||
if ($hasBorders) {
|
||||
$defaultColor = $style->getDefaultBorderColor();
|
||||
|
||||
$xmlWriter->startElement('w:tcBorders');
|
||||
if ($bTop) {
|
||||
if (is_null($brdCol[0])) {
|
||||
$brdCol[0] = $_defaultColor;
|
||||
}
|
||||
$xmlWriter->startElement('w:top');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[0]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[0]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
if ($bLeft) {
|
||||
if (is_null($brdCol[1])) {
|
||||
$brdCol[1] = $_defaultColor;
|
||||
}
|
||||
$xmlWriter->startElement('w:left');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[1]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[1]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
if ($bRight) {
|
||||
if (is_null($brdCol[2])) {
|
||||
$brdCol[2] = $_defaultColor;
|
||||
}
|
||||
$xmlWriter->startElement('w:right');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[2]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[2]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
if ($bBottom) {
|
||||
if (is_null($brdCol[3])) {
|
||||
$brdCol[3] = $_defaultColor;
|
||||
}
|
||||
$xmlWriter->startElement('w:bottom');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $brdSz[3]);
|
||||
$xmlWriter->writeAttribute('w:color', $brdCol[3]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
$this->writeMarginBorder($xmlWriter, $brdSz, $brdCol, array('defaultColor' => $defaultColor));
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
|
@ -1337,4 +1163,94 @@ class Base extends WriterPart
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write container elements
|
||||
*
|
||||
* @param XMLWriter $xmlWriter
|
||||
* @param Container $container
|
||||
* @param Container $textBreak Add text break when no element found
|
||||
*/
|
||||
protected function writeContainerElements(XMLWriter $xmlWriter, Container $container)
|
||||
{
|
||||
$allowedElements = array(
|
||||
'Section' => array('Text', 'TextRun', 'Link', 'Title', 'TextBreak', 'ListItem', 'Table', 'Image', 'Object', 'CheckBox', 'Footnote', 'TOC'),
|
||||
'Header' => array('Text', 'TextRun', 'Link', 'PreserveText', 'TextBreak', 'ListItem', 'Image', 'CheckBox'),
|
||||
'Footer' => array('Text', 'TextRun', 'Link', 'PreserveText', 'TextBreak', 'ListItem', 'Image', 'CheckBox'),
|
||||
'Cell' => array('Text', 'TextRun', 'Link', 'PreserveText', 'TextBreak', 'ListItem', 'Image', 'Object', 'CheckBox', 'Footnote'),
|
||||
'TextRun' => array('Text', 'Link', 'TextBreak', 'Image', 'Object', 'Footnote'),
|
||||
'Footnote' => array('Text', 'Link', 'TextBreak', 'Image', 'Object'),
|
||||
);
|
||||
$containerName = get_class($container);
|
||||
$containerName = substr($containerName, strrpos($containerName, '\\') + 1);
|
||||
if (array_key_exists($containerName, $allowedElements)) {
|
||||
$containerElements = $allowedElements[$containerName];
|
||||
} else {
|
||||
throw new Exception('Invalid container.');
|
||||
}
|
||||
|
||||
$elements = $container->getElements();
|
||||
if (count($elements) > 0) {
|
||||
foreach ($elements as $element) {
|
||||
$elmName = get_class($element);
|
||||
$elmName = substr($elmName, strrpos($elmName, '\\') + 1);
|
||||
if (in_array($elmName, $containerElements)) {
|
||||
$method = "write{$elmName}";
|
||||
// Image on Header could be watermark
|
||||
if ($containerName == 'Header' && $elmName == 'Image') {
|
||||
if ($element->getIsWatermark()) {
|
||||
$method = "writeWatermark";
|
||||
}
|
||||
}
|
||||
if (in_array($containerName, array('TextRun', 'Footnote'))) {
|
||||
$this->$method($xmlWriter, $element, true);
|
||||
} else {
|
||||
$this->$method($xmlWriter, $element);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($containerName == 'Cell') {
|
||||
$this->writeTextBreak($xmlWriter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write margin or border
|
||||
*
|
||||
* @param XMLWriter $xmlWriter
|
||||
* @param boolean $isBorder
|
||||
* @param array $sizes
|
||||
* @param array $colors
|
||||
*/
|
||||
protected function writeMarginBorder(XMLWriter $xmlWriter, $sizes, $colors = array(), $attributes = array())
|
||||
{
|
||||
$sides = array('top', 'left', 'right', 'bottom', 'insideH', 'insideV');
|
||||
$sizeCount = count($sizes) - 1;
|
||||
for ($i = 0; $i < $sizeCount; $i++) {
|
||||
if (!is_null($sizes[$i])) {
|
||||
$xmlWriter->startElement('w:' . $sides[$i]);
|
||||
if (!empty($colors)) {
|
||||
if (is_null($colors[$i]) && !empty($attributes)) {
|
||||
if (array_key_exists('defaultColor', $attributes))
|
||||
$colors[$i] = $attributes['defaultColor'];
|
||||
|
||||
}
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $sizes[$i]);
|
||||
$xmlWriter->writeAttribute('w:color', $colors[$i]);
|
||||
if (!empty($attributes)) {
|
||||
if (array_key_exists('space', $attributes)) {
|
||||
$xmlWriter->writeAttribute('w:space', '24');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$xmlWriter->writeAttribute('w:w', $sizes[$i]);
|
||||
$xmlWriter->writeAttribute('w:type', 'dxa');
|
||||
}
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,18 +12,7 @@ namespace PhpOffice\PhpWord\Writer\Word2007;
|
|||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\TOC;
|
||||
use PhpOffice\PhpWord\Container\Section;
|
||||
use PhpOffice\PhpWord\Element\Text;
|
||||
use PhpOffice\PhpWord\Element\TextRun;
|
||||
use PhpOffice\PhpWord\Element\Link;
|
||||
use PhpOffice\PhpWord\Element\Title;
|
||||
use PhpOffice\PhpWord\Element\TextBreak;
|
||||
use PhpOffice\PhpWord\Element\PageBreak;
|
||||
use PhpOffice\PhpWord\Element\ListItem;
|
||||
use PhpOffice\PhpWord\Element\Table;
|
||||
use PhpOffice\PhpWord\Element\Image;
|
||||
use PhpOffice\PhpWord\Element\Object;
|
||||
use PhpOffice\PhpWord\Element\Footnote;
|
||||
use PhpOffice\PhpWord\Element\CheckBox;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
|
|
@ -61,44 +50,15 @@ class Document extends Base
|
|||
|
||||
$xmlWriter->startElement('w:body');
|
||||
|
||||
$_sections = $phpWord->getSections();
|
||||
$countSections = count($_sections);
|
||||
$sections = $phpWord->getSections();
|
||||
$countSections = count($sections);
|
||||
$pSection = 0;
|
||||
|
||||
if ($countSections > 0) {
|
||||
foreach ($_sections as $section) {
|
||||
foreach ($sections as $section) {
|
||||
$pSection++;
|
||||
|
||||
$_elements = $section->getElements();
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof Text) {
|
||||
$this->writeText($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextRun) {
|
||||
$this->writeTextRun($xmlWriter, $element);
|
||||
} elseif ($element instanceof Link) {
|
||||
$this->writeLink($xmlWriter, $element);
|
||||
} elseif ($element instanceof Title) {
|
||||
$this->writeTitle($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextBreak) {
|
||||
$this->writeTextBreak($xmlWriter, $element);
|
||||
} elseif ($element instanceof PageBreak) {
|
||||
$this->writePageBreak($xmlWriter);
|
||||
} elseif ($element instanceof ListItem) {
|
||||
$this->writeListItem($xmlWriter, $element);
|
||||
} elseif ($element instanceof Table) {
|
||||
$this->writeTable($xmlWriter, $element);
|
||||
} elseif ($element instanceof Image) {
|
||||
$this->writeImage($xmlWriter, $element);
|
||||
} elseif ($element instanceof Object) {
|
||||
$this->writeObject($xmlWriter, $element);
|
||||
} elseif ($element instanceof TOC) {
|
||||
$this->writeTOC($xmlWriter);
|
||||
} elseif ($element instanceof Footnote) {
|
||||
$this->writeFootnote($xmlWriter, $element);
|
||||
} elseif ($element instanceof CheckBox) {
|
||||
$this->writeCheckBox($xmlWriter, $element);
|
||||
}
|
||||
}
|
||||
$this->writeContainerElements($xmlWriter, $section);
|
||||
|
||||
if ($pSection == $countSections) {
|
||||
$this->writeEndSection($xmlWriter, $section);
|
||||
|
|
@ -139,8 +99,8 @@ class Document extends Base
|
|||
private function writeEndSection(XMLWriter $xmlWriter, Section $section)
|
||||
{
|
||||
$settings = $section->getSettings();
|
||||
$_headers = $section->getHeaders();
|
||||
$_footer = $section->getFooter();
|
||||
$headers = $section->getHeaders();
|
||||
$footer = $section->getFooter();
|
||||
$pgSzW = $settings->getPageSizeW();
|
||||
$pgSzH = $settings->getPageSizeH();
|
||||
$orientation = $settings->getOrientation();
|
||||
|
|
@ -161,43 +121,45 @@ class Document extends Base
|
|||
|
||||
$xmlWriter->startElement('w:sectPr');
|
||||
|
||||
foreach ($_headers as &$_header) {
|
||||
$rId = $_header->getRelationId();
|
||||
$xmlWriter->startElement('w:headerReference');
|
||||
$xmlWriter->writeAttribute('w:type', $_header->getType());
|
||||
$xmlWriter->writeAttribute('r:id', 'rId' . $rId);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
if ($section->hasDifferentFirstPage()) {
|
||||
$xmlWriter->startElement('w:titlePg');
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
// Section break
|
||||
if (!is_null($breakType)) {
|
||||
$xmlWriter->startElement('w:type');
|
||||
$xmlWriter->writeAttribute('w:val', $breakType);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
if (!is_null($_footer)) {
|
||||
$rId = $_footer->getRelationId();
|
||||
// Header reference
|
||||
foreach ($headers as &$header) {
|
||||
$rId = $header->getRelationId();
|
||||
$xmlWriter->startElement('w:headerReference');
|
||||
$xmlWriter->writeAttribute('w:type', $header->getType());
|
||||
$xmlWriter->writeAttribute('r:id', 'rId' . $rId);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
if ($section->hasDifferentFirstPage()) {
|
||||
$xmlWriter->startElement('w:titlePg');
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
// Footer reference
|
||||
if (!is_null($footer)) {
|
||||
$rId = $footer->getRelationId();
|
||||
$xmlWriter->startElement('w:footerReference');
|
||||
$xmlWriter->writeAttribute('w:type', 'default');
|
||||
$xmlWriter->writeAttribute('r:id', 'rId' . $rId);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
// Page size & orientation
|
||||
$xmlWriter->startElement('w:pgSz');
|
||||
$xmlWriter->writeAttribute('w:w', $pgSzW);
|
||||
$xmlWriter->writeAttribute('w:h', $pgSzH);
|
||||
|
||||
if (!is_null($orientation) && strtolower($orientation) != 'portrait') {
|
||||
$xmlWriter->writeAttribute('w:orient', $orientation);
|
||||
}
|
||||
$xmlWriter->endElement(); // w:pgSz
|
||||
|
||||
$xmlWriter->endElement();
|
||||
|
||||
// Margins
|
||||
$xmlWriter->startElement('w:pgMar');
|
||||
$xmlWriter->writeAttribute('w:top', $marginTop);
|
||||
$xmlWriter->writeAttribute('w:right', $marginRight);
|
||||
|
|
@ -208,48 +170,19 @@ class Document extends Base
|
|||
$xmlWriter->writeAttribute('w:gutter', '0');
|
||||
$xmlWriter->endElement();
|
||||
|
||||
|
||||
if (!is_null($borders[0]) || !is_null($borders[1]) || !is_null($borders[2]) || !is_null($borders[3])) {
|
||||
// Borders
|
||||
$hasBorders = false;
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
if (!is_null($borders[$i])) {
|
||||
$hasBorders = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($hasBorders) {
|
||||
$borderColor = $settings->getBorderColor();
|
||||
|
||||
$xmlWriter->startElement('w:pgBorders');
|
||||
$xmlWriter->writeAttribute('w:offsetFrom', 'page');
|
||||
|
||||
if (!is_null($borders[0])) {
|
||||
$xmlWriter->startElement('w:top');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $borders[0]);
|
||||
$xmlWriter->writeAttribute('w:space', '24');
|
||||
$xmlWriter->writeAttribute('w:color', $borderColor[0]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
if (!is_null($borders[1])) {
|
||||
$xmlWriter->startElement('w:left');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $borders[1]);
|
||||
$xmlWriter->writeAttribute('w:space', '24');
|
||||
$xmlWriter->writeAttribute('w:color', $borderColor[1]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
if (!is_null($borders[2])) {
|
||||
$xmlWriter->startElement('w:right');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $borders[2]);
|
||||
$xmlWriter->writeAttribute('w:space', '24');
|
||||
$xmlWriter->writeAttribute('w:color', $borderColor[2]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
if (!is_null($borders[3])) {
|
||||
$xmlWriter->startElement('w:bottom');
|
||||
$xmlWriter->writeAttribute('w:val', 'single');
|
||||
$xmlWriter->writeAttribute('w:sz', $borders[3]);
|
||||
$xmlWriter->writeAttribute('w:space', '24');
|
||||
$xmlWriter->writeAttribute('w:color', $borderColor[3]);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
$this->writeMarginBorder($xmlWriter, $borders, $borderColor, array('space' => '24'));
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
|
|
@ -260,12 +193,12 @@ class Document extends Base
|
|||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
// Columns
|
||||
$xmlWriter->startElement('w:cols');
|
||||
$xmlWriter->writeAttribute('w:num', $colsNum);
|
||||
$xmlWriter->writeAttribute('w:space', $colsSpace);
|
||||
$xmlWriter->endElement();
|
||||
|
||||
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
|
|
@ -274,7 +207,7 @@ class Document extends Base
|
|||
*
|
||||
* @param XMLWriter $xmlWriter
|
||||
*/
|
||||
private function writePageBreak(XMLWriter $xmlWriter)
|
||||
protected function writePageBreak(XMLWriter $xmlWriter, PageBreak $pagebreak)
|
||||
{
|
||||
$xmlWriter->startElement('w:p');
|
||||
$xmlWriter->startElement('w:r');
|
||||
|
|
@ -290,7 +223,7 @@ class Document extends Base
|
|||
*
|
||||
* @param XMLWriter $xmlWriter
|
||||
*/
|
||||
private function writeTOC(XMLWriter $xmlWriter)
|
||||
protected function writeTOC(XMLWriter $xmlWriter, TOC $toc)
|
||||
{
|
||||
$titles = TOC::getTitles();
|
||||
$styleFont = TOC::getStyleFont();
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ class DocumentRels extends Base
|
|||
/**
|
||||
* Write word/_rels/document.xml.rels
|
||||
*
|
||||
* @param array $_relsCollection
|
||||
* @param array $relsCollection
|
||||
*/
|
||||
public function writeDocumentRels($_relsCollection)
|
||||
public function writeDocumentRels($relsCollection)
|
||||
{
|
||||
// Create XML writer
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
|
|
@ -34,73 +34,42 @@ class DocumentRels extends Base
|
|||
$xmlWriter->startElement('Relationships');
|
||||
$xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
|
||||
// Relationship word/document.xml
|
||||
$this->writeRel(
|
||||
$xmlWriter,
|
||||
1,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles',
|
||||
'styles.xml'
|
||||
// Write static files
|
||||
$staticFiles = array(
|
||||
'styles' => 'styles.xml',
|
||||
'numbering' => 'numbering.xml',
|
||||
'settings' => 'settings.xml',
|
||||
'theme' => 'theme/theme1.xml',
|
||||
'webSettings' => 'webSettings.xml',
|
||||
'fontTable' => 'fontTable.xml',
|
||||
);
|
||||
$i = 0;
|
||||
foreach ($staticFiles as $type => $file) {
|
||||
$i++;
|
||||
$schema = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/' . $type;
|
||||
$this->writeRel($xmlWriter, $i, $schema, $file);
|
||||
}
|
||||
|
||||
// Relationship word/numbering.xml
|
||||
$this->writeRel(
|
||||
$xmlWriter,
|
||||
2,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering',
|
||||
'numbering.xml'
|
||||
);
|
||||
// Write media relationship (image, oleObject, hyperlink)
|
||||
$this->writeMediaRels($xmlWriter, $relsCollection);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->writeRel(
|
||||
$xmlWriter,
|
||||
3,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings',
|
||||
'settings.xml'
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->writeRel(
|
||||
$xmlWriter,
|
||||
4,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme',
|
||||
'theme/theme1.xml'
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->writeRel(
|
||||
$xmlWriter,
|
||||
5,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings',
|
||||
'webSettings.xml'
|
||||
);
|
||||
|
||||
// Relationship word/settings.xml
|
||||
$this->writeRel(
|
||||
$xmlWriter,
|
||||
6,
|
||||
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable',
|
||||
'fontTable.xml'
|
||||
);
|
||||
|
||||
$this->writeMediaRels($xmlWriter, $_relsCollection);
|
||||
$xmlWriter->endElement(); // Relationships
|
||||
|
||||
// Return
|
||||
return $xmlWriter->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write header footer rels word/_rels/*.xml.rels
|
||||
*
|
||||
* @param array $_relsCollection
|
||||
* @param array $relsCollection
|
||||
*/
|
||||
public function writeHeaderFooterRels($_relsCollection)
|
||||
public function writeHeaderFooterRels($relsCollection)
|
||||
{
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
$xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
$xmlWriter->startElement('Relationships');
|
||||
$xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
$this->writeMediaRels($xmlWriter, $_relsCollection);
|
||||
$this->writeMediaRels($xmlWriter, $relsCollection);
|
||||
$xmlWriter->endElement();
|
||||
|
||||
return $xmlWriter->getData();
|
||||
|
|
|
|||
|
|
@ -10,15 +10,6 @@
|
|||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
|
||||
use PhpOffice\PhpWord\Container\Footer as FooterElement;
|
||||
use PhpOffice\PhpWord\Element\Text;
|
||||
use PhpOffice\PhpWord\Element\TextRun;
|
||||
use PhpOffice\PhpWord\Element\Link;
|
||||
use PhpOffice\PhpWord\Element\PreserveText;
|
||||
use PhpOffice\PhpWord\Element\TextBreak;
|
||||
use PhpOffice\PhpWord\Element\ListItem;
|
||||
use PhpOffice\PhpWord\Element\Table;
|
||||
use PhpOffice\PhpWord\Element\Image;
|
||||
use PhpOffice\PhpWord\Element\CheckBox;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
|
||||
/**
|
||||
|
|
@ -50,29 +41,7 @@ class Footer extends Base
|
|||
$xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
|
||||
$xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
|
||||
|
||||
$_elements = $footer->getElements();
|
||||
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof Text) {
|
||||
$this->writeText($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextRun) {
|
||||
$this->writeTextRun($xmlWriter, $element);
|
||||
} elseif ($element instanceof Link) {
|
||||
$this->writeLink($xmlWriter, $element);
|
||||
} elseif ($element instanceof PreserveText) {
|
||||
$this->writePreserveText($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextBreak) {
|
||||
$this->writeTextBreak($xmlWriter, $element);
|
||||
} elseif ($element instanceof ListItem) {
|
||||
$this->writeListItem($xmlWriter, $element);
|
||||
} elseif ($element instanceof Table) {
|
||||
$this->writeTable($xmlWriter, $element);
|
||||
} elseif ($element instanceof Image) {
|
||||
$this->writeImage($xmlWriter, $element);
|
||||
} elseif ($element instanceof CheckBox) {
|
||||
$this->writeCheckBox($xmlWriter, $element);
|
||||
}
|
||||
}
|
||||
$this->writeContainerElements($xmlWriter, $footer);
|
||||
|
||||
$xmlWriter->endElement();
|
||||
|
||||
|
|
|
|||
|
|
@ -110,23 +110,9 @@ class Footnotes extends Base
|
|||
$xmlWriter->writeRaw(' ');
|
||||
$xmlWriter->endElement(); // w:t
|
||||
$xmlWriter->endElement(); // w:r
|
||||
// Actual footnote contents
|
||||
$elements = $footnote->getElements();
|
||||
if (count($elements) > 0) {
|
||||
foreach ($elements as $element) {
|
||||
if ($element instanceof Text) {
|
||||
$this->writeText($xmlWriter, $element, true);
|
||||
} elseif ($element instanceof Link) {
|
||||
$this->writeLink($xmlWriter, $element, true);
|
||||
} elseif ($element instanceof Image) {
|
||||
$this->writeImage($xmlWriter, $element, true);
|
||||
} elseif ($element instanceof Object) {
|
||||
$this->writeObject($xmlWriter, $element, true);
|
||||
} elseif ($element instanceof TextBreak) {
|
||||
$xmlWriter->writeElement('w:br');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->writeContainerElements($xmlWriter, $footnote);
|
||||
|
||||
$xmlWriter->endElement(); // w:p
|
||||
$xmlWriter->endElement(); // w:footnote
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,15 +20,15 @@ class FootnotesRels extends Base
|
|||
/**
|
||||
* Write word/_rels/footnotes.xml.rels
|
||||
*
|
||||
* @param mixed $_relsCollection
|
||||
* @param mixed $relsCollection
|
||||
*/
|
||||
public function writeFootnotesRels($_relsCollection)
|
||||
public function writeFootnotesRels($relsCollection)
|
||||
{
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
$xmlWriter->startDocument('1.0', 'UTF-8', 'yes');
|
||||
$xmlWriter->startElement('Relationships');
|
||||
$xmlWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
|
||||
$this->writeMediaRels($xmlWriter, $_relsCollection);
|
||||
$this->writeMediaRels($xmlWriter, $relsCollection);
|
||||
$xmlWriter->endElement();
|
||||
|
||||
return $xmlWriter->getData();
|
||||
|
|
|
|||
|
|
@ -10,15 +10,6 @@
|
|||
namespace PhpOffice\PhpWord\Writer\Word2007;
|
||||
|
||||
use PhpOffice\PhpWord\Container\Header as HeaderElement;
|
||||
use PhpOffice\PhpWord\Element\Text;
|
||||
use PhpOffice\PhpWord\Element\TextRun;
|
||||
use PhpOffice\PhpWord\Element\Link;
|
||||
use PhpOffice\PhpWord\Element\PreserveText;
|
||||
use PhpOffice\PhpWord\Element\TextBreak;
|
||||
use PhpOffice\PhpWord\Element\ListItem;
|
||||
use PhpOffice\PhpWord\Element\Table;
|
||||
use PhpOffice\PhpWord\Element\Image;
|
||||
use PhpOffice\PhpWord\Element\CheckBox;
|
||||
use PhpOffice\PhpWord\Shared\XMLWriter;
|
||||
|
||||
/**
|
||||
|
|
@ -50,33 +41,7 @@ class Header extends Base
|
|||
$xmlWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
|
||||
$xmlWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
|
||||
|
||||
$_elements = $header->getElements();
|
||||
|
||||
foreach ($_elements as $element) {
|
||||
if ($element instanceof Text) {
|
||||
$this->writeText($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextRun) {
|
||||
$this->writeTextRun($xmlWriter, $element);
|
||||
} elseif ($element instanceof Link) {
|
||||
$this->writeLink($xmlWriter, $element);
|
||||
} elseif ($element instanceof PreserveText) {
|
||||
$this->writePreserveText($xmlWriter, $element);
|
||||
} elseif ($element instanceof TextBreak) {
|
||||
$this->writeTextBreak($xmlWriter, $element);
|
||||
} elseif ($element instanceof ListItem) {
|
||||
$this->writeListItem($xmlWriter, $element);
|
||||
} elseif ($element instanceof Table) {
|
||||
$this->writeTable($xmlWriter, $element);
|
||||
} elseif ($element instanceof Image) {
|
||||
if (!$element->getIsWatermark()) {
|
||||
$this->writeImage($xmlWriter, $element);
|
||||
} else {
|
||||
$this->writeWatermark($xmlWriter, $element);
|
||||
}
|
||||
} elseif ($element instanceof CheckBox) {
|
||||
$this->writeCheckBox($xmlWriter, $element);
|
||||
}
|
||||
}
|
||||
$this->writeContainerElements($xmlWriter, $header);
|
||||
|
||||
$xmlWriter->endElement();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue