框架本地无法运行,修复尝试

This commit is contained in:
wangjinlei
2026-06-04 13:33:13 +08:00
parent bbd690ca0f
commit 0ee7c38000
359 changed files with 2767 additions and 3114 deletions

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -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 @@ class HTML extends AbstractReader implements ReaderInterface
*
* @param string $docFile
*
* @return PhpWord
* @return \PhpOffice\PhpWord\PhpWord
*/
public function load($docFile)
{

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -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 ODText extends AbstractReader implements ReaderInterface
*
* @param string $docFile
*
* @return PhpWord
* @return \PhpOffice\PhpWord\PhpWord
*/
public function load($docFile)
{
@@ -59,7 +58,7 @@ class ODText extends AbstractReader implements ReaderInterface
{
$partClass = "PhpOffice\\PhpWord\\Reader\\ODText\\{$partName}";
if (class_exists($partClass)) {
/** @var ODText\AbstractPart $part Type hint */
/** @var \PhpOffice\PhpWord\Reader\ODText\AbstractPart $part Type hint */
$part = new $partClass($docFile, $xmlFile);
$part->setRels($relationships);
$part->read($phpWord);

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -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 @@ class RTF extends AbstractReader implements ReaderInterface
*
* @param string $docFile
*
* @return PhpWord
* @return \PhpOffice\PhpWord\PhpWord
*/
public function load($docFile)
{

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
@@ -43,7 +42,7 @@ class Document
/**
* PhpWord object.
*
* @var PhpWord
* @var \PhpOffice\PhpWord\PhpWord
*/
private $phpWord;

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -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 Word2007 extends AbstractReader implements ReaderInterface
*
* @param string $docFile
*
* @return PhpWord
* @return \PhpOffice\PhpWord\PhpWord
*/
public function load($docFile)
{

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
@@ -22,13 +21,10 @@ use DateTime;
use DOMElement;
use InvalidArgumentException;
use PhpOffice\Math\Reader\OfficeMathML;
use PhpOffice\PhpWord\ComplexType\RubyProperties;
use PhpOffice\PhpWord\ComplexType\TblWidth as TblWidthComplexType;
use PhpOffice\PhpWord\Element\AbstractContainer;
use PhpOffice\PhpWord\Element\AbstractElement;
use PhpOffice\PhpWord\Element\FormField;
use PhpOffice\PhpWord\Element\Ruby;
use PhpOffice\PhpWord\Element\Text;
use PhpOffice\PhpWord\Element\TextRun;
use PhpOffice\PhpWord\Element\TrackChange;
use PhpOffice\PhpWord\PhpWord;
@@ -187,7 +183,7 @@ abstract class AbstractPart
/**
* Read w:p.
*
* @param AbstractContainer $parent
* @param \PhpOffice\PhpWord\Element\AbstractContainer $parent
* @param string $docPart
*
* @todo Get font style for preserve text
@@ -300,8 +296,7 @@ abstract class AbstractPart
if ($headingDepth !== null) {
$textContent = null;
$nodes = $xmlReader->getElements('w:r|w:hyperlink', $domNode);
$hasRubyElement = $xmlReader->elementExists('w:r/w:ruby', $domNode);
if ($nodes->length === 1 && !$hasRubyElement) {
if ($nodes->length === 1) {
$textContent = htmlspecialchars($xmlReader->getValue('w:t', $nodes->item(0)), ENT_QUOTES, 'UTF-8');
} else {
$textContent = new TextRun($paragraphStyle);
@@ -455,7 +450,7 @@ abstract class AbstractPart
/**
* Read w:r.
*
* @param AbstractContainer $parent
* @param \PhpOffice\PhpWord\Element\AbstractContainer $parent
* @param string $docPart
* @param mixed $paragraphStyle
*
@@ -589,47 +584,9 @@ abstract class AbstractPart
}
} elseif ($node->nodeName == 'w:softHyphen') {
$element = $parent->addText("\u{200c}", $fontStyle, $paragraphStyle);
} elseif ($node->nodeName == 'w:ruby') {
$rubyPropertiesNode = $xmlReader->getElement('w:rubyPr', $node);
$properties = $this->readRubyProperties($xmlReader, $rubyPropertiesNode);
// read base text node
$baseText = new TextRun($paragraphStyle);
$baseTextNode = $xmlReader->getElement('w:rubyBase/w:r', $node);
$this->readRun($xmlReader, $baseTextNode, $baseText, $docPart, $paragraphStyle);
// read the actual ruby text (e.g. furigana in Japanese)
$rubyText = new TextRun($paragraphStyle);
$rubyTextNode = $xmlReader->getElement('w:rt/w:r', $node);
$this->readRun($xmlReader, $rubyTextNode, $rubyText, $docPart, $paragraphStyle);
// add element to parent
$parent->addRuby($baseText, $rubyText, $properties);
}
}
/**
* Read w:rubyPr element.
*
* @param XMLReader $xmlReader reader for XML
* @param DOMElement $domNode w:RubyPr element
*
* @return RubyProperties ruby properties from element
*/
protected function readRubyProperties(XMLReader $xmlReader, DOMElement $domNode): RubyProperties
{
$rubyAlignment = $xmlReader->getElement('w:rubyAlign', $domNode)->getAttribute('w:val');
$rubyHps = $xmlReader->getElement('w:hps', $domNode)->getAttribute('w:val'); // font face
$rubyHpsRaise = $xmlReader->getElement('w:hpsRaise', $domNode)->getAttribute('w:val'); // pts above base text
$rubyHpsBaseText = $xmlReader->getElement('w:hpsBaseText', $domNode)->getAttribute('w:val'); // base text size
$rubyLid = $xmlReader->getElement('w:lid', $domNode)->getAttribute('w:val'); // type of ruby
$properties = new RubyProperties();
$properties->setAlignment($rubyAlignment);
$properties->setFontFaceSize((float) $rubyHps);
$properties->setFontPointsAboveBaseText((float) $rubyHpsRaise);
$properties->setFontSizeForBaseText((float) $rubyHpsBaseText);
$properties->setLanguageId($rubyLid);
return $properties;
}
/**
* Read w:tbl.
*
@@ -704,11 +661,8 @@ abstract class AbstractPart
'alignment' => [self::READ_VALUE, 'w:jc'],
'basedOn' => [self::READ_VALUE, 'w:basedOn'],
'next' => [self::READ_VALUE, 'w:next'],
'indentLeft' => [self::READ_VALUE, 'w:ind', 'w:left'],
'indentRight' => [self::READ_VALUE, 'w:ind', 'w:right'],
'indentHanging' => [self::READ_VALUE, 'w:ind', 'w:hanging'],
'indentFirstLine' => [self::READ_VALUE, 'w:ind', 'w:firstLine'],
'indentFirstLineChars' => [self::READ_VALUE, 'w:ind', 'w:firstLineChars'],
'indent' => [self::READ_VALUE, 'w:ind', 'w:left'],
'hanging' => [self::READ_VALUE, 'w:ind', 'w:hanging'],
'spaceAfter' => [self::READ_VALUE, 'w:spacing', 'w:after'],
'spaceBefore' => [self::READ_VALUE, 'w:spacing', 'w:before'],
'widowControl' => [self::READ_FALSE, 'w:widowControl'],

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
@@ -35,7 +34,7 @@ class Document extends AbstractPart
/**
* PhpWord object.
*
* @var PhpWord
* @var \PhpOffice\PhpWord\PhpWord
*/
private $phpWord;

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -1,5 +1,4 @@
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.

View File

@@ -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 Styles extends AbstractPart
if (array_key_exists('size', $fontDefaultStyle)) {
$phpWord->setDefaultFontSize($fontDefaultStyle['size']);
}
if (array_key_exists('color', $fontDefaultStyle)) {
$phpWord->setDefaultFontColor($fontDefaultStyle['color']);
}
if (array_key_exists('lang', $fontDefaultStyle)) {
$phpWord->getSettings()->setThemeFontLang(new Language($fontDefaultStyle['lang']));
}