More Scrutinizer Changes
Still one report that I don't understand at all, and one I'm not sure of.
This commit is contained in:
parent
cfa29cc1c2
commit
46c41c5ac1
|
|
@ -33,6 +33,7 @@ class TextRun extends Text
|
||||||
$element = $this->getElement();
|
$element = $this->getElement();
|
||||||
|
|
||||||
$xmlWriter->startElement('text:p');
|
$xmlWriter->startElement('text:p');
|
||||||
|
/** @scrutinizer ignore-call */
|
||||||
$pStyle = $element->getParagraphStyle();
|
$pStyle = $element->getParagraphStyle();
|
||||||
if (!is_string($pStyle)) {
|
if (!is_string($pStyle)) {
|
||||||
$pStyle = 'Normal';
|
$pStyle = 'Normal';
|
||||||
|
|
|
||||||
|
|
@ -266,7 +266,7 @@ class Content extends AbstractPart
|
||||||
$elements = $container->getElements();
|
$elements = $container->getElements();
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if ($element instanceof TextRun) {
|
if ($element instanceof TextRun) {
|
||||||
$this->getElementStyle($element, $paragraphStyleCount, $fontStyleCount);
|
$this->getElementStyleTextRun($element, $paragraphStyleCount);
|
||||||
$this->getContainerStyle($element, $paragraphStyleCount, $fontStyleCount);
|
$this->getContainerStyle($element, $paragraphStyleCount, $fontStyleCount);
|
||||||
} elseif ($element instanceof Text) {
|
} elseif ($element instanceof Text) {
|
||||||
$this->getElementStyle($element, $paragraphStyleCount, $fontStyleCount);
|
$this->getElementStyle($element, $paragraphStyleCount, $fontStyleCount);
|
||||||
|
|
@ -298,7 +298,7 @@ class Content extends AbstractPart
|
||||||
/**
|
/**
|
||||||
* Get style of individual element
|
* Get style of individual element
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\PhpWord\Element\Text|\PhpOffice\PhpWord\Element\TextRun $element
|
* @param \PhpOffice\PhpWord\Element\Text $element
|
||||||
* @param int $paragraphStyleCount
|
* @param int $paragraphStyleCount
|
||||||
* @param int $fontStyleCount
|
* @param int $fontStyleCount
|
||||||
*/
|
*/
|
||||||
|
|
@ -341,6 +341,37 @@ class Content extends AbstractPart
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get style of individual element
|
||||||
|
*
|
||||||
|
* @param \PhpOffice\PhpWord\Element\TextRun $element
|
||||||
|
* @param int $paragraphStyleCount
|
||||||
|
*/
|
||||||
|
private function getElementStyleTextRun(&$element, &$paragraphStyleCount)
|
||||||
|
{
|
||||||
|
$paragraphStyle = $element->getParagraphStyle();
|
||||||
|
$phpWord = $this->getParentWriter()->getPhpWord();
|
||||||
|
|
||||||
|
if ($paragraphStyle instanceof Paragraph) {
|
||||||
|
// Paragraph
|
||||||
|
$name = $paragraphStyle->getStyleName();
|
||||||
|
if (!$name) {
|
||||||
|
$paragraphStyleCount++;
|
||||||
|
$style = $phpWord->addParagraphStyle("P{$paragraphStyleCount}", $paragraphStyle);
|
||||||
|
$style->setAuto();
|
||||||
|
$element->setParagraphStyle("P{$paragraphStyleCount}");
|
||||||
|
} else {
|
||||||
|
$element->setParagraphStyle($name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$paragraphStyleCount++;
|
||||||
|
$parstylename = "P$paragraphStyleCount" . "_$paragraphStyle";
|
||||||
|
$style = $phpWord->addParagraphStyle($parstylename, $paragraphStyle);
|
||||||
|
$style->setAuto();
|
||||||
|
$element->setParagraphStyle($parstylename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all tracked changes
|
* Finds all tracked changes
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,8 @@ class Paragraph extends AbstractStyle
|
||||||
|
|
||||||
//Indentation
|
//Indentation
|
||||||
$indent = $style->getIndentation();
|
$indent = $style->getIndentation();
|
||||||
if ($indent instanceof \PhpOffice\PhpWord\Style\Indentation) {
|
//if ($indent instanceof \PhpOffice\PhpWord\Style\Indentation) {
|
||||||
|
if (!empty($indent)) {
|
||||||
$marg = $indent->getLeft();
|
$marg = $indent->getLeft();
|
||||||
$xmlWriter->writeAttributeIf($marg !== null, 'fo:margin-left', (string) ($marg / Converter::INCH_TO_TWIP) . 'in');
|
$xmlWriter->writeAttributeIf($marg !== null, 'fo:margin-left', (string) ($marg / Converter::INCH_TO_TWIP) . 'in');
|
||||||
$marg = $indent->getRight();
|
$marg = $indent->getRight();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue