Added possiblity to add tables inside textbox
This commit is contained in:
parent
aa151c4010
commit
07b4ae2c0f
|
|
@ -53,4 +53,19 @@ class TextBox extends AbstractContainer
|
||||||
{
|
{
|
||||||
return $this->style;
|
return $this->style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add table element
|
||||||
|
*
|
||||||
|
* @param mixed $style
|
||||||
|
* @return \PhpOffice\PhpWord\Element\Table
|
||||||
|
* @todo Merge with the same function on Footer
|
||||||
|
*/
|
||||||
|
public function addTable($style = null)
|
||||||
|
{
|
||||||
|
$table = new Table($this->getDocPart(), $this->getDocPartId(), $style);
|
||||||
|
$this->addElement($table);
|
||||||
|
|
||||||
|
return $table;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,9 +57,7 @@ class TextBox extends Element
|
||||||
$margins = implode(', ', $tbxStyle->getInnerMargin());
|
$margins = implode(', ', $tbxStyle->getInnerMargin());
|
||||||
$this->xmlWriter->writeAttribute('inset', $margins);
|
$this->xmlWriter->writeAttribute('inset', $margins);
|
||||||
$this->xmlWriter->startElement('w:txbxContent');
|
$this->xmlWriter->startElement('w:txbxContent');
|
||||||
$this->xmlWriter->startElement('w:p');
|
|
||||||
$this->parentWriter->writeContainerElements($this->xmlWriter, $this->element);
|
$this->parentWriter->writeContainerElements($this->xmlWriter, $this->element);
|
||||||
$this->xmlWriter->endElement(); // w:p
|
|
||||||
$this->xmlWriter->endElement(); // w:txbxContent
|
$this->xmlWriter->endElement(); // w:txbxContent
|
||||||
$this->xmlWriter->endElement(); // v: textbox
|
$this->xmlWriter->endElement(); // v: textbox
|
||||||
$styleWriter->writeW10Wrap();
|
$styleWriter->writeW10Wrap();
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ abstract class AbstractPart
|
||||||
|
|
||||||
// Loop through elements
|
// Loop through elements
|
||||||
$elements = $container->getElements();
|
$elements = $container->getElements();
|
||||||
$withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote', 'TextBox')) ? true : false;
|
$withoutP = in_array($containerName, array('TextRun', 'Footnote', 'Endnote')) ? true : false;
|
||||||
if (count($elements) > 0) {
|
if (count($elements) > 0) {
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if ($element instanceof AbstractElement) {
|
if ($element instanceof AbstractElement) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue