框架本地无法运行,修复尝试
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -34,7 +33,7 @@ abstract class AbstractWriter implements WriterInterface
|
||||
/**
|
||||
* PHPWord object.
|
||||
*
|
||||
* @var PhpWord
|
||||
* @var \PhpOffice\PhpWord\PhpWord
|
||||
*/
|
||||
protected $phpWord;
|
||||
|
||||
@@ -97,7 +96,7 @@ abstract class AbstractWriter implements WriterInterface
|
||||
/**
|
||||
* Get PhpWord object.
|
||||
*
|
||||
* @return PhpWord
|
||||
* @return \PhpOffice\PhpWord\PhpWord
|
||||
*/
|
||||
public function getPhpWord()
|
||||
{
|
||||
@@ -111,6 +110,8 @@ abstract class AbstractWriter implements WriterInterface
|
||||
/**
|
||||
* Set PhpWord object.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setPhpWord(?PhpWord $phpWord = null)
|
||||
@@ -266,7 +267,7 @@ abstract class AbstractWriter implements WriterInterface
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return ZipArchive
|
||||
* @return \PhpOffice\PhpWord\Shared\ZipArchive
|
||||
*/
|
||||
protected function getZipArchive($filename)
|
||||
{
|
||||
@@ -359,7 +360,7 @@ abstract class AbstractWriter implements WriterInterface
|
||||
*
|
||||
* Get the actual source from an archive image.
|
||||
*
|
||||
* @param ZipArchive $zipPackage
|
||||
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zipPackage
|
||||
* @param string $source
|
||||
* @param string $target
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -78,7 +77,7 @@ class HTML extends AbstractWriter implements WriterInterface
|
||||
foreach ($this->parts as $partName) {
|
||||
$partClass = 'PhpOffice\\PhpWord\\Writer\\HTML\\Part\\' . $partName;
|
||||
if (class_exists($partClass)) {
|
||||
/** @var HTML\Part\AbstractPart $part Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\HTML\Part\AbstractPart $part Type hint */
|
||||
$part = new $partClass();
|
||||
$part->setParentWriter($this);
|
||||
$this->writerParts[strtolower($partName)] = $part;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -38,7 +37,7 @@ abstract class AbstractElement
|
||||
/**
|
||||
* Element.
|
||||
*
|
||||
* @var Element
|
||||
* @var \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
protected $element;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -54,7 +53,7 @@ class Container extends AbstractElement
|
||||
$elementClass = get_class($element);
|
||||
$writerClass = str_replace('PhpOffice\\PhpWord\\Element', $this->namespace, $elementClass);
|
||||
if (class_exists($writerClass)) {
|
||||
/** @var AbstractElement $writer Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\HTML\Element\AbstractElement $writer Type hint */
|
||||
$writer = new $writerClass($this->parentWriter, $element, $withoutP);
|
||||
$content .= $writer->write();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -73,7 +72,7 @@ class Text extends AbstractElement
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Type hint */
|
||||
$element = $this->element;
|
||||
|
||||
$text = $this->parentWriter->escapeHTML($element->getText() ?? '');
|
||||
$text = $this->parentWriter->escapeHTML($element->getText());
|
||||
if (!$this->withoutP && !trim($text)) {
|
||||
$text = ' ';
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -23,7 +22,7 @@ use PhpOffice\PhpWord\Writer\HTML\Element\TextRun as TextRunWriter;
|
||||
use PhpOffice\PhpWord\Writer\PDF\TCPDF;
|
||||
|
||||
/**
|
||||
* HTML body part writer.
|
||||
* RTF body part writer.
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -30,7 +29,7 @@ use PhpOffice\PhpWord\Writer\HTML\Style\Paragraph as ParagraphStyleWriter;
|
||||
use PhpOffice\PhpWord\Writer\HTML\Style\Table as TableStyleWriter;
|
||||
|
||||
/**
|
||||
* HTML head part writer.
|
||||
* RTF head part writer.
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
@@ -85,12 +84,11 @@ class Head extends AbstractPart
|
||||
private function writeStyles(): string
|
||||
{
|
||||
$css = '<style>' . PHP_EOL;
|
||||
$defaultFontColor = Settings::getDefaultFontColor();
|
||||
|
||||
// Default styles
|
||||
$astarray = [
|
||||
'font-family' => $this->getFontFamily(Settings::getDefaultFontName(), $this->getParentWriter()->getDefaultGenericFont()),
|
||||
'font-size' => Settings::getDefaultFontSize() . 'pt',
|
||||
'color' => "#{$defaultFontColor}",
|
||||
];
|
||||
// Mpdf sometimes needs separate tag for body; doesn't harm others.
|
||||
$bodyarray = $astarray;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -47,9 +46,6 @@ class Table extends AbstractStyle
|
||||
$css['direction'] = 'rtl';
|
||||
}
|
||||
}
|
||||
if (is_object($style) && method_exists($style, 'getVAlign')) {
|
||||
$css['vertical-align'] = $style->getVAlign();
|
||||
}
|
||||
|
||||
foreach (['Top', 'Left', 'Bottom', 'Right'] as $direction) {
|
||||
$method = 'getBorder' . $direction . 'Style';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -56,7 +55,7 @@ class ODText extends AbstractWriter implements WriterInterface
|
||||
foreach (array_keys($this->parts) as $partName) {
|
||||
$partClass = static::class . '\\Part\\' . $partName;
|
||||
if (class_exists($partClass)) {
|
||||
/** @var AbstractPart $partObject Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\ODText\Part\AbstractPart $partObject Type hint */
|
||||
$partObject = new $partClass();
|
||||
$partObject->setParentWriter($this);
|
||||
$this->writerParts[strtolower($partName)] = $partObject;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -27,32 +26,4 @@ use PhpOffice\PhpWord\Writer\Word2007\Element\AbstractElement as Word2007Abstrac
|
||||
*/
|
||||
abstract class AbstractElement extends Word2007AbstractElement
|
||||
{
|
||||
protected function replaceTabs($text, $xmlWriter): void
|
||||
{
|
||||
if (preg_match('/^ +/', $text, $matches)) {
|
||||
$num = strlen($matches[0]);
|
||||
$xmlWriter->startElement('text:s');
|
||||
$xmlWriter->writeAttributeIf($num > 1, 'text:c', "$num");
|
||||
$xmlWriter->endElement();
|
||||
$text = preg_replace('/^ +/', '', $text);
|
||||
}
|
||||
preg_match_all('/([\\s\\S]*?)(\\t| +| ?$)/', $text, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $match) {
|
||||
$this->writeText($match[1]);
|
||||
if ($match[2] === '') {
|
||||
break;
|
||||
} elseif ($match[2] === "\t") {
|
||||
$xmlWriter->writeElement('text:tab');
|
||||
} elseif ($match[2] === ' ') {
|
||||
$xmlWriter->writeElement('text:s');
|
||||
|
||||
break;
|
||||
} else {
|
||||
$num = strlen($match[2]);
|
||||
$xmlWriter->startElement('text:s');
|
||||
$xmlWriter->writeAttributeIf($num > 1, 'text:c', "$num");
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -33,9 +32,4 @@ class Container extends Word2007Container
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'PhpOffice\\PhpWord\\Writer\\ODText\\Element';
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $containerWithoutP = ['TextRun', 'Footnote', 'Endnote'];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -18,7 +17,6 @@
|
||||
|
||||
namespace PhpOffice\PhpWord\Writer\ODText\Element;
|
||||
|
||||
use PhpOffice\PhpWord\Element\Image as ElementImage;
|
||||
use PhpOffice\PhpWord\Shared\Converter;
|
||||
|
||||
/**
|
||||
@@ -33,8 +31,9 @@ class Image extends AbstractElement
|
||||
*/
|
||||
public function write(): void
|
||||
{
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
$element = $this->getElement();
|
||||
if (!$element instanceof ElementImage) {
|
||||
if (!$element instanceof \PhpOffice\PhpWord\Element\Image) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,16 +43,11 @@ class Image extends AbstractElement
|
||||
$width = Converter::pixelToCm($style->getWidth());
|
||||
$height = Converter::pixelToCm($style->getHeight());
|
||||
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
|
||||
if (!$this->withoutP) {
|
||||
$xmlWriter->startElement('text:p');
|
||||
$xmlWriter->writeAttribute('text:style-name', 'IM' . $mediaIndex);
|
||||
}
|
||||
$xmlWriter->startElement('text:p');
|
||||
$xmlWriter->writeAttribute('text:style-name', 'IM' . $mediaIndex);
|
||||
|
||||
$xmlWriter->startElement('draw:frame');
|
||||
$xmlWriter->writeAttribute('draw:style-name', 'fr' . $mediaIndex);
|
||||
$xmlWriter->writeAttributeIf($this->withoutP, 'draw:text-style-name', 'IM' . $mediaIndex);
|
||||
$xmlWriter->writeAttribute('draw:name', $element->getElementId());
|
||||
$xmlWriter->writeAttribute('text:anchor-type', 'as-char');
|
||||
$xmlWriter->writeAttribute('svg:width', $width . 'cm');
|
||||
@@ -69,8 +63,6 @@ class Image extends AbstractElement
|
||||
|
||||
$xmlWriter->endElement(); // draw:frame
|
||||
|
||||
if (!$this->withoutP) {
|
||||
$xmlWriter->endElement(); // text:p
|
||||
}
|
||||
$xmlWriter->endElement(); // text:p
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -36,7 +35,7 @@ class Table extends AbstractElement
|
||||
{
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
$element = $this->getElement();
|
||||
if (!$element instanceof TableElement) {
|
||||
if (!$element instanceof \PhpOffice\PhpWord\Element\Table) {
|
||||
return;
|
||||
}
|
||||
$rows = $element->getRows();
|
||||
@@ -78,7 +77,7 @@ class Table extends AbstractElement
|
||||
private function writeRow(XMLWriter $xmlWriter, RowElement $row): void
|
||||
{
|
||||
$xmlWriter->startElement('table:table-row');
|
||||
/** @var RowElement $row Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
|
||||
foreach ($row->getCells() as $cell) {
|
||||
$xmlWriter->startElement('table:table-cell');
|
||||
$xmlWriter->writeAttribute('office:value-type', 'string');
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -58,29 +57,37 @@ class Text extends AbstractElement
|
||||
$xmlWriter->writeAttribute('text:change-id', $element->getTrackChange()->getElementId());
|
||||
$xmlWriter->endElement();
|
||||
} else {
|
||||
if (empty($paragraphStyle)) {
|
||||
if (!$this->withoutP) {
|
||||
$xmlWriter->writeAttribute('text:style-name', 'Normal');
|
||||
if (empty($fontStyle)) {
|
||||
if (empty($paragraphStyle)) {
|
||||
if (!$this->withoutP) {
|
||||
$xmlWriter->writeAttribute('text:style-name', 'Normal');
|
||||
}
|
||||
} elseif (is_string($paragraphStyle)) {
|
||||
if (!$this->withoutP) {
|
||||
$xmlWriter->writeAttribute('text:style-name', $paragraphStyle);
|
||||
}
|
||||
}
|
||||
} elseif (is_string($paragraphStyle)) {
|
||||
if (!$this->withoutP) {
|
||||
$xmlWriter->writeAttribute('text:style-name', $paragraphStyle);
|
||||
$this->writeChangeInsertion(true, $element->getTrackChange());
|
||||
$this->replaceTabs($element->getText(), $xmlWriter);
|
||||
$this->writeChangeInsertion(false, $element->getTrackChange());
|
||||
} else {
|
||||
if (empty($paragraphStyle)) {
|
||||
if (!$this->withoutP) {
|
||||
$xmlWriter->writeAttribute('text:style-name', 'Normal');
|
||||
}
|
||||
} elseif (is_string($paragraphStyle)) {
|
||||
if (!$this->withoutP) {
|
||||
$xmlWriter->writeAttribute('text:style-name', $paragraphStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fontStyle)) {
|
||||
// text:span
|
||||
$xmlWriter->startElement('text:span');
|
||||
if (is_string($fontStyle)) {
|
||||
$xmlWriter->writeAttribute('text:style-name', $fontStyle);
|
||||
}
|
||||
}
|
||||
|
||||
$this->writeChangeInsertion(true, $element->getTrackChange());
|
||||
$this->replaceTabs($element->getText(), $xmlWriter);
|
||||
$this->writeChangeInsertion(false, $element->getTrackChange());
|
||||
|
||||
if (!empty($fontStyle)) {
|
||||
$this->writeChangeInsertion(true, $element->getTrackChange());
|
||||
$this->replaceTabs($element->getText(), $xmlWriter);
|
||||
$this->writeChangeInsertion(false, $element->getTrackChange());
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
}
|
||||
@@ -89,6 +96,35 @@ class Text extends AbstractElement
|
||||
}
|
||||
}
|
||||
|
||||
private function replacetabs($text, $xmlWriter): void
|
||||
{
|
||||
if (preg_match('/^ +/', $text, $matches)) {
|
||||
$num = strlen($matches[0]);
|
||||
$xmlWriter->startElement('text:s');
|
||||
$xmlWriter->writeAttributeIf($num > 1, 'text:c', "$num");
|
||||
$xmlWriter->endElement();
|
||||
$text = preg_replace('/^ +/', '', $text);
|
||||
}
|
||||
preg_match_all('/([\\s\\S]*?)(\\t| +| ?$)/', $text, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $match) {
|
||||
$this->writeText($match[1]);
|
||||
if ($match[2] === '') {
|
||||
break;
|
||||
} elseif ($match[2] === "\t") {
|
||||
$xmlWriter->writeElement('text:tab');
|
||||
} elseif ($match[2] === ' ') {
|
||||
$xmlWriter->writeElement('text:s');
|
||||
|
||||
break;
|
||||
} else {
|
||||
$num = strlen($match[2]);
|
||||
$xmlWriter->startElement('text:s');
|
||||
$xmlWriter->writeAttributeIf($num > 1, 'text:c', "$num");
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function writeChangeInsertion($start = true, ?TrackChange $trackChange = null): void
|
||||
{
|
||||
if ($trackChange == null || $trackChange->getChangeType() != TrackChange::INSERTED) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -231,7 +230,7 @@ class Content extends AbstractPart
|
||||
}
|
||||
}
|
||||
foreach ($this->imageParagraphStyles as $style) {
|
||||
$styleWriter = new ParagraphStyleWriter($xmlWriter, $style);
|
||||
$styleWriter = new \PhpOffice\PhpWord\Writer\ODText\Style\Paragraph($xmlWriter, $style);
|
||||
$styleWriter->write();
|
||||
}
|
||||
}
|
||||
@@ -257,7 +256,7 @@ class Content extends AbstractPart
|
||||
*
|
||||
* Table style can be null or string of the style name
|
||||
*
|
||||
* @param AbstractContainer $container
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractContainer $container
|
||||
* @param int $paragraphStyleCount
|
||||
* @param int $fontStyleCount
|
||||
*
|
||||
@@ -278,7 +277,7 @@ class Content extends AbstractPart
|
||||
$style = $element->getStyle();
|
||||
$style->setStyleName('fr' . $element->getMediaIndex());
|
||||
$this->autoStyles['Image'][] = $style;
|
||||
$sty = new Paragraph();
|
||||
$sty = new \PhpOffice\PhpWord\Style\Paragraph();
|
||||
$sty->setStyleName('IM' . $element->getMediaIndex());
|
||||
$sty->setAuto();
|
||||
$sty->setAlignment($style->getAlignment());
|
||||
@@ -301,7 +300,7 @@ class Content extends AbstractPart
|
||||
/**
|
||||
* Get style of individual element.
|
||||
*
|
||||
* @param Text $element
|
||||
* @param \PhpOffice\PhpWord\Element\Text $element
|
||||
* @param int $paragraphStyleCount
|
||||
* @param int $fontStyleCount
|
||||
*/
|
||||
@@ -347,7 +346,7 @@ class Content extends AbstractPart
|
||||
/**
|
||||
* Get font style of individual field element.
|
||||
*
|
||||
* @param Field $element
|
||||
* @param \PhpOffice\PhpWord\Element\Field $element
|
||||
* @param int $fontStyleCount
|
||||
*/
|
||||
private function getElementStyleField($element, &$fontStyleCount): void
|
||||
@@ -372,7 +371,7 @@ class Content extends AbstractPart
|
||||
/**
|
||||
* Get style of individual element.
|
||||
*
|
||||
* @param TextRun $element
|
||||
* @param \PhpOffice\PhpWord\Element\TextRun $element
|
||||
* @param int $paragraphStyleCount
|
||||
*/
|
||||
private function getElementStyleTextRun($element, &$paragraphStyleCount): void
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -92,12 +91,11 @@ class Styles extends AbstractPart
|
||||
|
||||
// Font
|
||||
$xmlWriter->startElement('style:text-properties');
|
||||
$xmlWriter->writeAttribute('style:use-window-font-color', 'false');
|
||||
$xmlWriter->writeAttribute('style:use-window-font-color', 'true');
|
||||
$xmlWriter->writeAttribute('style:font-name', Settings::getDefaultFontName());
|
||||
$xmlWriter->writeAttribute('fo:font-size', Settings::getDefaultFontSize() . 'pt');
|
||||
$xmlWriter->writeAttribute('fo:language', $latinLang[0]);
|
||||
$xmlWriter->writeAttribute('fo:country', $latinLang[1]);
|
||||
$xmlWriter->writeAttribute('fo:color', '#' . Settings::getDefaultFontColor());
|
||||
$xmlWriter->writeAttribute('style:letter-kerning', 'true');
|
||||
$xmlWriter->writeAttribute('style:font-name-asian', Settings::getDefaultFontName() . '2');
|
||||
$xmlWriter->writeAttribute('style:font-size-asian', Settings::getDefaultFontSize() . 'pt');
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -40,7 +39,7 @@ class Font extends AbstractStyle
|
||||
if ($stylep instanceof \PhpOffice\PhpWord\Style\Paragraph) {
|
||||
$temp1 = clone $stylep;
|
||||
$temp1->setStyleName($style->getStyleName());
|
||||
$temp2 = new Paragraph($xmlWriter, $temp1);
|
||||
$temp2 = new \PhpOffice\PhpWord\Writer\ODText\Style\Paragraph($xmlWriter, $temp1);
|
||||
$temp2->write();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -46,7 +45,7 @@ class Paragraph extends AbstractStyle
|
||||
public function write(): void
|
||||
{
|
||||
$style = $this->getStyle();
|
||||
if (!$style instanceof Style\Paragraph) {
|
||||
if (!$style instanceof \PhpOffice\PhpWord\Style\Paragraph) {
|
||||
return;
|
||||
}
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
@@ -74,13 +73,13 @@ class Paragraph extends AbstractStyle
|
||||
} elseif (substr($styleName, 0, 2) === 'HD') {
|
||||
$styleAuto = true;
|
||||
$psm = 'Heading_' . substr($styleName, 2);
|
||||
$stylep = Style::getStyle($psm);
|
||||
if ($stylep instanceof Style\Font) {
|
||||
$stylep = \PhpOffice\PhpWord\Style::getStyle($psm);
|
||||
if ($stylep instanceof \PhpOffice\PhpWord\Style\Font) {
|
||||
if (method_exists($stylep, 'getParagraph')) {
|
||||
$stylep = $stylep->getParagraph();
|
||||
}
|
||||
}
|
||||
if ($stylep instanceof Style\Paragraph) {
|
||||
if ($stylep instanceof \PhpOffice\PhpWord\Style\Paragraph) {
|
||||
if ($stylep->hasPageBreakBefore()) {
|
||||
$breakbefore = true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -33,7 +32,7 @@ class PDF
|
||||
/**
|
||||
* The wrapper for the requested PDF rendering engine.
|
||||
*
|
||||
* @var AbstractRenderer
|
||||
* @var \PhpOffice\PhpWord\Writer\PDF\AbstractRenderer
|
||||
*/
|
||||
private $renderer;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -45,7 +44,7 @@ class RTF extends AbstractWriter implements WriterInterface
|
||||
foreach ($this->parts as $partName) {
|
||||
$partClass = static::class . '\\Part\\' . $partName;
|
||||
if (class_exists($partClass)) {
|
||||
/** @var RTF\Part\AbstractPart $part Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\RTF\Part\AbstractPart $part Type hint */
|
||||
$part = new $partClass();
|
||||
$part->setParentWriter($this);
|
||||
$this->writerParts[strtolower($partName)] = $part;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -46,7 +45,7 @@ abstract class AbstractElement
|
||||
/**
|
||||
* Element.
|
||||
*
|
||||
* @var Element
|
||||
* @var \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
protected $element;
|
||||
|
||||
@@ -67,14 +66,14 @@ abstract class AbstractElement
|
||||
/**
|
||||
* Font style.
|
||||
*
|
||||
* @var FontStyle
|
||||
* @var \PhpOffice\PhpWord\Style\Font
|
||||
*/
|
||||
protected $fontStyle;
|
||||
|
||||
/**
|
||||
* Paragraph style.
|
||||
*
|
||||
* @var ParagraphStyle
|
||||
* @var \PhpOffice\PhpWord\Style\Paragraph
|
||||
*/
|
||||
protected $paragraphStyle;
|
||||
|
||||
@@ -96,7 +95,7 @@ abstract class AbstractElement
|
||||
*/
|
||||
protected function getStyles(): void
|
||||
{
|
||||
/** @var WriterRTF $parentWriter Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Type hint */
|
||||
$parentWriter = $this->parentWriter;
|
||||
|
||||
/** @var \PhpOffice\PhpWord\Element\Text $element Type hint */
|
||||
@@ -189,7 +188,7 @@ abstract class AbstractElement
|
||||
return '';
|
||||
}
|
||||
|
||||
/** @var WriterRTF $parentWriter Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\RTF $parentWriter Type hint */
|
||||
$parentWriter = $this->parentWriter;
|
||||
|
||||
// Create style writer and set color/name index
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -59,15 +58,10 @@ class Title extends Text
|
||||
/** @var \PhpOffice\PhpWord\Element\Title $element Type hint */
|
||||
$element = $this->element;
|
||||
$elementClass = str_replace('\\Writer\\RTF', '', static::class);
|
||||
if (!$element instanceof $elementClass) {
|
||||
if (!$element instanceof $elementClass || !is_string($element->getText())) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$textToWrite = $element->getText();
|
||||
if ($textToWrite instanceof \PhpOffice\PhpWord\Element\TextRun) {
|
||||
$textToWrite = $textToWrite->getText(); // gets text from TextRun
|
||||
}
|
||||
|
||||
$this->getStyles();
|
||||
|
||||
$content = '';
|
||||
@@ -88,7 +82,7 @@ class Title extends Text
|
||||
|
||||
$content .= '{';
|
||||
$content .= $this->writeFontStyle();
|
||||
$content .= $this->writeText($textToWrite);
|
||||
$content .= $this->writeText($element->getText());
|
||||
$content .= '}';
|
||||
$content .= $this->writeClosing();
|
||||
$content .= $endout;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -163,12 +162,12 @@ class Document extends AbstractPart
|
||||
|
||||
foreach ($section->getHeaders() as $header) {
|
||||
$type = $header->getType();
|
||||
if ($evenOdd || $type !== Footer::EVEN) {
|
||||
if ($evenOdd || $type !== FOOTER::EVEN) {
|
||||
$content .= '{\\header';
|
||||
if ($type === Footer::FIRST) {
|
||||
$content .= 'f';
|
||||
} elseif ($evenOdd) {
|
||||
$content .= ($type === Footer::EVEN) ? 'l' : 'r';
|
||||
$content .= ($type === FOOTER::EVEN) ? 'l' : 'r';
|
||||
}
|
||||
foreach ($header->getElements() as $element) {
|
||||
$cl = get_class($element);
|
||||
@@ -183,12 +182,12 @@ class Document extends AbstractPart
|
||||
}
|
||||
foreach ($section->getFooters() as $footer) {
|
||||
$type = $footer->getType();
|
||||
if ($evenOdd || $type !== Footer::EVEN) {
|
||||
if ($evenOdd || $type !== FOOTER::EVEN) {
|
||||
$content .= '{\\footer';
|
||||
if ($type === Footer::FIRST) {
|
||||
$content .= 'f';
|
||||
} elseif ($evenOdd) {
|
||||
$content .= ($type === Footer::EVEN) ? 'l' : 'r';
|
||||
$content .= ($type === FOOTER::EVEN) ? 'l' : 'r';
|
||||
}
|
||||
foreach ($footer->getElements() as $element) {
|
||||
$cl = get_class($element);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -212,7 +211,7 @@ class Header extends AbstractPart
|
||||
/**
|
||||
* Register border colors.
|
||||
*
|
||||
* @param Style\Border $style
|
||||
* @param \PhpOffice\PhpWord\Style\Border $style
|
||||
*/
|
||||
private function registerBorderColor($style): void
|
||||
{
|
||||
@@ -227,7 +226,7 @@ class Header extends AbstractPart
|
||||
/**
|
||||
* Register fonts and colors.
|
||||
*
|
||||
* @param Style\AbstractStyle $style
|
||||
* @param \PhpOffice\PhpWord\Style\AbstractStyle $style
|
||||
*/
|
||||
private function registerFontItems($style): void
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -44,6 +43,8 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
||||
|
||||
/**
|
||||
* Create new Word2007 writer.
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\PhpWord
|
||||
*/
|
||||
public function __construct(?PhpWord $phpWord = null)
|
||||
{
|
||||
@@ -77,7 +78,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
||||
foreach (array_keys($this->parts) as $partName) {
|
||||
$partClass = static::class . '\\Part\\' . $partName;
|
||||
if (class_exists($partClass)) {
|
||||
/** @var Word2007\Part\AbstractPart $part Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart $part Type hint */
|
||||
$part = new $partClass();
|
||||
$part->setParentWriter($this);
|
||||
$this->writerParts[strtolower($partName)] = $part;
|
||||
@@ -178,7 +179,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
||||
$this->registerContentTypes($media);
|
||||
}
|
||||
|
||||
/** @var Word2007\Part\AbstractPart $writerPart Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart $writerPart Type hint */
|
||||
$writerPart = $this->getWriterPart('relspart')->setMedia($media);
|
||||
$zip->addFromString("word/_rels/{$file}.xml.rels", $writerPart->write());
|
||||
}
|
||||
@@ -205,7 +206,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
||||
$this->contentTypes['override']["/word/$elmFile"] = $elmType;
|
||||
$this->relationships[] = ['target' => $elmFile, 'type' => $elmType, 'rID' => $rId];
|
||||
|
||||
/** @var Word2007\Part\AbstractPart $writerPart Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart $writerPart Type hint */
|
||||
$writerPart = $this->getWriterPart($elmType)->setElement($element);
|
||||
$zip->addFromString("word/$elmFile", $writerPart->write());
|
||||
}
|
||||
@@ -235,7 +236,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
|
||||
|
||||
// Write relationships file, e.g. word/_rels/footnotes.xml
|
||||
if (!empty($media)) {
|
||||
/** @var Word2007\Part\AbstractPart $writerPart Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart $writerPart Type hint */
|
||||
$writerPart = $this->getWriterPart('relspart')->setMedia($media);
|
||||
$zip->addFromString("word/_rels/{$partName}.xml.rels", $writerPart->write());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -34,14 +33,14 @@ abstract class AbstractElement
|
||||
/**
|
||||
* XML writer.
|
||||
*
|
||||
* @var XMLWriter
|
||||
* @var \PhpOffice\PhpWord\Shared\XMLWriter
|
||||
*/
|
||||
private $xmlWriter;
|
||||
|
||||
/**
|
||||
* Element.
|
||||
*
|
||||
* @var Element
|
||||
* @var \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
private $element;
|
||||
|
||||
@@ -64,8 +63,10 @@ abstract class AbstractElement
|
||||
|
||||
/**
|
||||
* Create new instance.
|
||||
*
|
||||
* @param bool $withoutP
|
||||
*/
|
||||
public function __construct(XMLWriter $xmlWriter, Element $element, bool $withoutP = false)
|
||||
public function __construct(XMLWriter $xmlWriter, Element $element, $withoutP = false)
|
||||
{
|
||||
$this->xmlWriter = $xmlWriter;
|
||||
$this->element = $element;
|
||||
@@ -75,7 +76,7 @@ abstract class AbstractElement
|
||||
/**
|
||||
* Get XML Writer.
|
||||
*
|
||||
* @return XMLWriter
|
||||
* @return \PhpOffice\PhpWord\Shared\XMLWriter
|
||||
*/
|
||||
protected function getXmlWriter()
|
||||
{
|
||||
@@ -85,7 +86,7 @@ abstract class AbstractElement
|
||||
/**
|
||||
* Get element.
|
||||
*
|
||||
* @return Element
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
protected function getElement()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -37,11 +36,6 @@ class Container extends AbstractElement
|
||||
*/
|
||||
protected $namespace = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element';
|
||||
|
||||
/**
|
||||
* @var array<string>
|
||||
*/
|
||||
protected $containerWithoutP = ['TextRun', 'Footnote', 'Endnote', 'ListItemRun'];
|
||||
|
||||
/**
|
||||
* Write element.
|
||||
*/
|
||||
@@ -52,7 +46,7 @@ class Container extends AbstractElement
|
||||
return;
|
||||
}
|
||||
$containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1);
|
||||
$withoutP = in_array($containerClass, $this->containerWithoutP);
|
||||
$withoutP = in_array($containerClass, ['TextRun', 'Footnote', 'Endnote', 'ListItemRun']);
|
||||
$xmlWriter = $this->getXmlWriter();
|
||||
|
||||
// Loop through elements
|
||||
@@ -68,7 +62,7 @@ class Container extends AbstractElement
|
||||
$writeLastTextBreak = ($containerClass == 'Cell') && ($elementClass == '' || $elementClass == 'Table');
|
||||
if ($writeLastTextBreak) {
|
||||
$writerClass = $this->namespace . '\\TextBreak';
|
||||
/** @var AbstractElement $writer Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\Word2007\Element\AbstractElement $writer Type hint */
|
||||
$writer = new $writerClass($xmlWriter, new TextBreakElement(), $withoutP);
|
||||
$writer->write();
|
||||
}
|
||||
@@ -76,14 +70,18 @@ class Container extends AbstractElement
|
||||
|
||||
/**
|
||||
* Write individual element.
|
||||
*
|
||||
* @param bool $withoutP
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function writeElement(XMLWriter $xmlWriter, Element $element, bool $withoutP): string
|
||||
private function writeElement(XMLWriter $xmlWriter, Element $element, $withoutP)
|
||||
{
|
||||
$elementClass = substr(get_class($element), strrpos(get_class($element), '\\') + 1);
|
||||
$writerClass = $this->namespace . '\\' . $elementClass;
|
||||
|
||||
if (class_exists($writerClass)) {
|
||||
/** @var AbstractElement $writer Type hint */
|
||||
/** @var \PhpOffice\PhpWord\Writer\Word2007\Element\AbstractElement $writer Type hint */
|
||||
$writer = new $writerClass($xmlWriter, $element, $withoutP);
|
||||
$writer->setPart($this->getPart());
|
||||
$writer->write();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
@@ -148,7 +147,7 @@ class Field extends Text
|
||||
$xmlWriter->endElement(); // w:r
|
||||
|
||||
if ($element->getText() != null) {
|
||||
if ($element->getText() instanceof TextRun) {
|
||||
if ($element->getText() instanceof \PhpOffice\PhpWord\Element\TextRun) {
|
||||
$containerWriter = new Container($xmlWriter, $element->getText(), true);
|
||||
$containerWriter->write();
|
||||
}
|
||||
@@ -263,7 +262,7 @@ class Field extends Text
|
||||
$xmlWriter->endElement(); // w:r
|
||||
|
||||
if ($element->getText() != null) {
|
||||
if ($element->getText() instanceof TextRun) {
|
||||
if ($element->getText() instanceof \PhpOffice\PhpWord\Element\TextRun) {
|
||||
$containerWriter = new Container($xmlWriter, $element->getText(), true);
|
||||
$containerWriter->write();
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||
* word processing documents.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user