make FontStyle basedOn paragraph if the paragraph is set on the font (#926)
* make FontStyle based on paragraph if it set * replace tab with spaces * basedOn not correctly set if FontStyle is based on other FontStyle * Fix warnings
This commit is contained in:
parent
2fc685b4da
commit
8ce1a19ec4
|
|
@ -65,7 +65,7 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Get the Footnote Positioning Location
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPos()
|
||||
|
|
@ -75,7 +75,7 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd)
|
||||
*
|
||||
*
|
||||
* @param string $pos
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
|
|
@ -99,7 +99,7 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Get the Footnote Numbering Format
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNumFmt()
|
||||
|
|
@ -109,7 +109,7 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Set the Footnote Numbering Format
|
||||
*
|
||||
*
|
||||
* @param string $numFmt One of NumberFormat
|
||||
* @return self
|
||||
*/
|
||||
|
|
@ -122,7 +122,7 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Get the Footnote Numbering Format
|
||||
*
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public function getNumStart()
|
||||
|
|
@ -132,7 +132,7 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Set the Footnote Numbering Format
|
||||
*
|
||||
*
|
||||
* @param double $numStart
|
||||
* @return self
|
||||
*/
|
||||
|
|
@ -144,7 +144,7 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Get the Footnote and Endnote Numbering Starting Value
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNumRestart()
|
||||
|
|
@ -154,7 +154,7 @@ final class FootnoteProperties
|
|||
|
||||
/**
|
||||
* Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage)
|
||||
*
|
||||
*
|
||||
* @param string $numRestart
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ final class ProofState
|
|||
/**
|
||||
* Set the Spell Checking State (dirty or clean)
|
||||
*
|
||||
* @param string $spelling
|
||||
* @param string $spelling
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
*/
|
||||
|
|
@ -78,7 +78,7 @@ final class ProofState
|
|||
/**
|
||||
* Set the Grammatical Checking State (dirty or clean)
|
||||
*
|
||||
* @param string $grammar
|
||||
* @param string $grammar
|
||||
* @throws \InvalidArgumentException
|
||||
* @return self
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -116,14 +116,14 @@ abstract class AbstractElement
|
|||
|
||||
/**
|
||||
* The start position for the linked comment
|
||||
*
|
||||
*
|
||||
* @var Comment
|
||||
*/
|
||||
protected $commentRangeStart;
|
||||
|
||||
/**
|
||||
* The end position for the linked comment
|
||||
*
|
||||
*
|
||||
* @var Comment
|
||||
*/
|
||||
protected $commentRangeEnd;
|
||||
|
|
@ -291,7 +291,7 @@ abstract class AbstractElement
|
|||
|
||||
/**
|
||||
* Set comment start
|
||||
*
|
||||
*
|
||||
* @param Comment $value
|
||||
*/
|
||||
public function setCommentRangeStart(Comment $value)
|
||||
|
|
|
|||
|
|
@ -31,14 +31,14 @@ class Comment extends TrackChange
|
|||
|
||||
/**
|
||||
* The Element where this comment starts
|
||||
*
|
||||
*
|
||||
* @var AbstractElement
|
||||
*/
|
||||
private $startElement;
|
||||
|
||||
/**
|
||||
* The Element where this comment ends
|
||||
*
|
||||
*
|
||||
* @var AbstractElement
|
||||
*/
|
||||
private $endElement;
|
||||
|
|
@ -76,7 +76,7 @@ class Comment extends TrackChange
|
|||
|
||||
/**
|
||||
* Sets the element where this comment starts
|
||||
*
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $value
|
||||
*/
|
||||
public function setStartElement(AbstractElement $value)
|
||||
|
|
@ -89,7 +89,7 @@ class Comment extends TrackChange
|
|||
|
||||
/**
|
||||
* Get the element where this comment starts
|
||||
*
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
public function getStartElement()
|
||||
|
|
@ -99,7 +99,7 @@ class Comment extends TrackChange
|
|||
|
||||
/**
|
||||
* Sets the element where this comment ends
|
||||
*
|
||||
*
|
||||
* @param \PhpOffice\PhpWord\Element\AbstractElement $value
|
||||
*/
|
||||
public function setEndElement(AbstractElement $value)
|
||||
|
|
@ -112,7 +112,7 @@ class Comment extends TrackChange
|
|||
|
||||
/**
|
||||
* Get the element where this comment ends
|
||||
*
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\AbstractElement
|
||||
*/
|
||||
public function getEndElement()
|
||||
|
|
|
|||
|
|
@ -476,9 +476,9 @@ class Image extends AbstractElement
|
|||
|
||||
/**
|
||||
* get image size from string
|
||||
*
|
||||
*
|
||||
* @param string $source
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore this method is just a replacement for getimagesizefromstring which exists only as of PHP 5.4
|
||||
*/
|
||||
private function getStringImageSize($source)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class Section extends AbstractContainer
|
|||
|
||||
/**
|
||||
* The properties for the footnote of this section
|
||||
*
|
||||
*
|
||||
* @var FootnoteProperties
|
||||
*/
|
||||
private $footnoteProperties;
|
||||
|
|
@ -148,7 +148,7 @@ class Section extends AbstractContainer
|
|||
|
||||
/**
|
||||
* Get the footnote properties
|
||||
*
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\Element\FooterProperties
|
||||
*/
|
||||
public function getFootnotePropoperties()
|
||||
|
|
@ -158,7 +158,7 @@ class Section extends AbstractContainer
|
|||
|
||||
/**
|
||||
* Set the footnote properties
|
||||
*
|
||||
*
|
||||
* @param FootnoteProperties $footnoteProperties
|
||||
*/
|
||||
public function setFootnoteProperties(FootnoteProperties $footnoteProperties = null)
|
||||
|
|
@ -219,7 +219,6 @@ class Section extends AbstractContainer
|
|||
} else {
|
||||
throw new \Exception('Invalid header/footer type.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
|||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
abstract class AbstractEscaper implements EscaperInterface
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
|||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
interface EscaperInterface
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
|||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class RegExp extends AbstractEscaper
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
|||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Rtf extends AbstractEscaper
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace PhpOffice\PhpWord\Escaper;
|
|||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class Xml extends AbstractEscaper
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ class Settings
|
|||
|
||||
/**
|
||||
* Get the Visibility of Annotation Types
|
||||
*
|
||||
*
|
||||
* @return \PhpOffice\PhpWord\ComplexType\TrackChangesView
|
||||
*/
|
||||
public function getRevisionView()
|
||||
|
|
@ -213,7 +213,7 @@ class Settings
|
|||
|
||||
/**
|
||||
* Set the Visibility of Annotation Types
|
||||
*
|
||||
*
|
||||
* @param TrackChangesView $trackChangesView
|
||||
*/
|
||||
public function setRevisionView(TrackChangesView $trackChangesView = null)
|
||||
|
|
@ -293,7 +293,7 @@ class Settings
|
|||
|
||||
/**
|
||||
* Returns the Radix Point for Field Code Evaluation
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDecimalSymbol()
|
||||
|
|
@ -303,7 +303,7 @@ class Settings
|
|||
|
||||
/**
|
||||
* sets the Radix Point for Field Code Evaluation
|
||||
*
|
||||
*
|
||||
* @param string $decimalSymbol
|
||||
*/
|
||||
public function setDecimalSymbol($decimalSymbol)
|
||||
|
|
|
|||
|
|
@ -1303,7 +1303,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
print_r('$sprm.ispmd : 0x'.dechex($sprm_IsPmd).PHP_EOL);
|
||||
print_r('$sprm.f : 0x'.dechex($sprm_F).PHP_EOL);
|
||||
print_r('$sprm.sgc : 0x'.dechex($sprm_Sgc));
|
||||
switch(dechex($sprm_Sgc)) {
|
||||
switch (dechex($sprm_Sgc)) {
|
||||
case 0x01:
|
||||
print_r(' (Paragraph property)');
|
||||
break;
|
||||
|
|
@ -1322,12 +1322,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
print_r(PHP_EOL);
|
||||
print_r('$sprm.spra : 0x'.dechex($sprm_Spra).PHP_EOL);
|
||||
switch(dechex($sprm_Spra)) {
|
||||
switch (dechex($sprm_Spra)) {
|
||||
case 0x0:
|
||||
$operand = self::getInt1d($this->dataWorkDocument, $offset);
|
||||
$offset += 1;
|
||||
$cb -= 1;
|
||||
switch(dechex($operand)) {
|
||||
switch (dechex($operand)) {
|
||||
case 0x00:
|
||||
$operand = 'OFF';
|
||||
break;
|
||||
|
|
@ -1376,9 +1376,9 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
|
||||
//
|
||||
switch(dechex($sprm_Sgc)) {
|
||||
switch (dechex($sprm_Sgc)) {
|
||||
case 0x01: // Sprm is modifying a paragraph property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
case 0x0A: // sprmPIlvl
|
||||
print_r('sprmPIlvl : '.$operand.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
|
|
@ -1391,28 +1391,28 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
break;
|
||||
case 0x02: // Sprm is modifying a character property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
default:
|
||||
print_r('$sprm_IsPmd(2) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x03: // Sprm is modifying a picture property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
default:
|
||||
print_r('$sprm_IsPmd(3) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x04: // Sprm is modifying a section property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
default:
|
||||
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x05: // Sprm is modifying a table property.
|
||||
switch($sprm_IsPmd) {
|
||||
switch ($sprm_IsPmd) {
|
||||
default:
|
||||
print_r('$sprm_IsPmd(4) : '.$sprm_IsPmd.PHP_EOL.PHP_EOL);
|
||||
break;
|
||||
|
|
@ -1514,11 +1514,11 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$length = 0;
|
||||
$operand = null;
|
||||
|
||||
switch(dechex($oSprm->spra)) {
|
||||
switch (dechex($oSprm->spra)) {
|
||||
case 0x0:
|
||||
$operand = self::getInt1d($data, $pos);
|
||||
$length = 1;
|
||||
switch(dechex($operand)) {
|
||||
switch (dechex($operand)) {
|
||||
case 0x00:
|
||||
$operand = false;
|
||||
break;
|
||||
|
|
@ -1593,7 +1593,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
$cbNum -= $arrayReturn['length'];
|
||||
$operand = $arrayReturn['operand'];
|
||||
|
||||
switch(dechex($oSprm->sgc)) {
|
||||
switch (dechex($oSprm->sgc)) {
|
||||
// Paragraph property
|
||||
case 0x01:
|
||||
break;
|
||||
|
|
@ -1602,7 +1602,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
if (!isset($oStylePrl->styleFont)) {
|
||||
$oStylePrl->styleFont = array();
|
||||
}
|
||||
switch($oSprm->isPmd) {
|
||||
switch ($oSprm->isPmd) {
|
||||
// sprmCFRMarkIns
|
||||
case 0x01:
|
||||
break;
|
||||
|
|
@ -1620,7 +1620,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// sprmCFItalic
|
||||
case 0x36:
|
||||
// By default, text is not italicized.
|
||||
switch($operand) {
|
||||
switch ($operand) {
|
||||
case false:
|
||||
case true:
|
||||
$oStylePrl->styleFont['italic'] = $operand;
|
||||
|
|
@ -1640,7 +1640,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// sprmCFBold
|
||||
case 0x35:
|
||||
// By default, text is not bold.
|
||||
switch($operand) {
|
||||
switch ($operand) {
|
||||
case false:
|
||||
case true:
|
||||
$oStylePrl->styleFont['bold'] = $operand;
|
||||
|
|
@ -1656,7 +1656,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// sprmCFStrike
|
||||
case 0x37:
|
||||
// By default, text is not struck through.
|
||||
switch($operand) {
|
||||
switch ($operand) {
|
||||
case false:
|
||||
case true:
|
||||
$oStylePrl->styleFont['strikethrough'] = $operand;
|
||||
|
|
@ -1671,7 +1671,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
break;
|
||||
// sprmCKul
|
||||
case 0x3E:
|
||||
switch(dechex($operand)) {
|
||||
switch (dechex($operand)) {
|
||||
case 0x00:
|
||||
$oStylePrl->styleFont['underline'] = Style\Font::UNDERLINE_NONE;
|
||||
break;
|
||||
|
|
@ -1734,7 +1734,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
// sprmCIco
|
||||
//@link http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx
|
||||
case 0x42:
|
||||
switch(dechex($operand)) {
|
||||
switch (dechex($operand)) {
|
||||
case 0x00:
|
||||
case 0x01:
|
||||
$oStylePrl->styleFont['color'] = '000000';
|
||||
|
|
@ -1873,7 +1873,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
if (!isset($oStylePrl->styleSection)) {
|
||||
$oStylePrl->styleSection = array();
|
||||
}
|
||||
switch($oSprm->isPmd) {
|
||||
switch ($oSprm->isPmd) {
|
||||
// sprmSNfcPgn
|
||||
case 0x0E:
|
||||
// numbering format used for page numbers
|
||||
|
|
@ -1925,7 +1925,6 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
default:
|
||||
// print_r('@todo Section : 0x'.dechex($oSprm->isPmd));
|
||||
// print_r(PHP_EOL);
|
||||
|
||||
}
|
||||
break;
|
||||
// Table property
|
||||
|
|
@ -2285,7 +2284,6 @@ class MsDoc extends AbstractReader implements ReaderInterface
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ class Content extends AbstractPart
|
|||
foreach ($nodes as $node) {
|
||||
// $styleName = $xmlReader->getAttribute('text:style-name', $node);
|
||||
switch ($node->nodeName) {
|
||||
|
||||
case 'text:h': // Heading
|
||||
$depth = $xmlReader->getAttribute('text:outline-level', $node);
|
||||
$section->addTitle($node->nodeValue, $depth);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ class Word2007 extends AbstractReader implements ReaderInterface
|
|||
$part->setRels($relationships);
|
||||
$part->read($phpWord);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -263,7 +263,6 @@ abstract class AbstractPart
|
|||
foreach ($tblNodes as $tblNode) {
|
||||
if ('w:tblGrid' == $tblNode->nodeName) { // Column
|
||||
// @todo Do something with table columns
|
||||
|
||||
} elseif ('w:tr' == $tblNode->nodeName) { // Row
|
||||
$rowHeight = $xmlReader->getAttribute('w:val', $tblNode, 'w:trPr/w:trHeight');
|
||||
$rowHRule = $xmlReader->getAttribute('w:hRule', $tblNode, 'w:trPr/w:trHeight');
|
||||
|
|
@ -279,7 +278,6 @@ abstract class AbstractPart
|
|||
foreach ($rowNodes as $rowNode) {
|
||||
if ('w:trPr' == $rowNode->nodeName) { // Row style
|
||||
// @todo Do something with row style
|
||||
|
||||
} elseif ('w:tc' == $rowNode->nodeName) { // Cell
|
||||
$cellWidth = $xmlReader->getAttribute('w:w', $rowNode, 'w:tcPr/w:tcW');
|
||||
$cellStyle = null;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class Settings extends AbstractPart
|
|||
|
||||
/**
|
||||
* Sets the document protection
|
||||
*
|
||||
*
|
||||
* @param XMLReader $xmlReader
|
||||
* @param PhpWord $phpWord
|
||||
* @param \DOMNode $node
|
||||
|
|
@ -83,7 +83,7 @@ class Settings extends AbstractPart
|
|||
|
||||
/**
|
||||
* Sets the proof state
|
||||
*
|
||||
*
|
||||
* @param XMLReader $xmlReader
|
||||
* @param PhpWord $phpWord
|
||||
* @param \DOMNode $node
|
||||
|
|
@ -105,7 +105,7 @@ class Settings extends AbstractPart
|
|||
|
||||
/**
|
||||
* Sets the proof state
|
||||
*
|
||||
*
|
||||
* @param XMLReader $xmlReader
|
||||
* @param PhpWord $phpWord
|
||||
* @param \DOMNode $node
|
||||
|
|
@ -122,7 +122,7 @@ class Settings extends AbstractPart
|
|||
|
||||
/**
|
||||
* Set the Revision view
|
||||
*
|
||||
*
|
||||
* @param XMLReader $xmlReader
|
||||
* @param PhpWord $phpWord
|
||||
* @param \DOMNode $node
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ class Styles extends AbstractPart
|
|||
preg_match('/Heading(\d)/', $name, $headingMatches);
|
||||
// $default = ($xmlReader->getAttribute('w:default', $node) == 1);
|
||||
switch ($type) {
|
||||
|
||||
case 'paragraph':
|
||||
$paragraphStyle = $this->readParagraphStyle($xmlReader, $node);
|
||||
$fontStyle = $this->readFontStyle($xmlReader, $node);
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ class Settings
|
|||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
|
|
@ -330,7 +330,7 @@ class Settings
|
|||
|
||||
/**
|
||||
* @since 0.13.0
|
||||
*
|
||||
*
|
||||
* @param boolean $outputEscapingEnabled
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ abstract class AbstractEnum
|
|||
|
||||
/**
|
||||
* Returns all values for this enum
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function values()
|
||||
|
|
@ -31,7 +31,7 @@ abstract class AbstractEnum
|
|||
|
||||
/**
|
||||
* Returns true the value is valid for this enum
|
||||
*
|
||||
*
|
||||
* @param strign $value
|
||||
* @return boolean true if value is valid
|
||||
*/
|
||||
|
|
@ -43,7 +43,7 @@ abstract class AbstractEnum
|
|||
|
||||
/**
|
||||
* Validates that the value passed is a valid value
|
||||
*
|
||||
*
|
||||
* @param string $value
|
||||
* @throws \InvalidArgumentException if the value passed is not valid for this enum
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -294,7 +294,6 @@ class OLERead
|
|||
|
||||
$offset += self::PROPERTY_STORAGE_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ class Font extends AbstractStyle
|
|||
private $shading;
|
||||
|
||||
/**
|
||||
* Right to left languages
|
||||
* Right to left languages
|
||||
* @var boolean
|
||||
*/
|
||||
private $rtl = false;
|
||||
|
|
@ -725,7 +725,7 @@ class Font extends AbstractStyle
|
|||
}
|
||||
|
||||
/**
|
||||
* Set shading
|
||||
* Set Paragraph
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return self
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class NumberingLevel extends AbstractStyle
|
|||
|
||||
/**
|
||||
* Justification, w:lvlJc
|
||||
*
|
||||
*
|
||||
* @var string, one of PhpOffice\PhpWord\SimpleType\Jc
|
||||
*/
|
||||
private $alignment = '';
|
||||
|
|
|
|||
|
|
@ -742,7 +742,7 @@ class Paragraph extends Border
|
|||
|
||||
/**
|
||||
* Get contextualSpacing
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasContextualSpacing()
|
||||
|
|
@ -752,7 +752,7 @@ class Paragraph extends Border
|
|||
|
||||
/**
|
||||
* Set contextualSpacing
|
||||
*
|
||||
*
|
||||
* @param bool $contextualSpacing
|
||||
* @return self
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class TemplateProcessor
|
|||
|
||||
/**
|
||||
* Applies XSL style sheet to template's parts.
|
||||
*
|
||||
*
|
||||
* Note: since the method doesn't make any guess on logic of the provided XSL style sheet,
|
||||
* make sure that output is correctly escaped. Otherwise you may get broken document.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ abstract class AbstractPart
|
|||
|
||||
/**
|
||||
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setParentWriter(AbstractWriter $writer = null)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ abstract class AbstractPart
|
|||
|
||||
/**
|
||||
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setParentWriter(AbstractWriter $writer = null)
|
||||
|
|
|
|||
|
|
@ -134,7 +134,6 @@ abstract class AbstractElement
|
|||
}
|
||||
|
||||
$this->xmlWriter->writeElementBlock('w:commentRangeStart', array('w:id' => $comment->getElementId()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -213,7 +213,6 @@ class Chart extends AbstractPart
|
|||
$xmlWriter->endElement(); // c:ser
|
||||
$index++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class Settings extends AbstractPart
|
|||
|
||||
/**
|
||||
* Adds a boolean attribute to the settings array
|
||||
*
|
||||
*
|
||||
* @param string $settingName
|
||||
* @param boolean $booleanValue
|
||||
*/
|
||||
|
|
@ -219,7 +219,6 @@ class Settings extends AbstractPart
|
|||
private function setRevisionView(TrackChangesView $trackChangesView = null)
|
||||
{
|
||||
if ($trackChangesView != null) {
|
||||
|
||||
$revisionView['w:markup'] = $trackChangesView->hasMarkup() ? 'true': 'false';
|
||||
$revisionView['w:comments'] = $trackChangesView->hasComments() ? 'true': 'false';
|
||||
$revisionView['w:insDel'] = $trackChangesView->hasInsDel() ? 'true': 'false';
|
||||
|
|
@ -232,7 +231,7 @@ class Settings extends AbstractPart
|
|||
|
||||
/**
|
||||
* Set the magnification
|
||||
*
|
||||
*
|
||||
* @param mixed $zoom
|
||||
*/
|
||||
private function setZoom($zoom = null)
|
||||
|
|
|
|||
|
|
@ -170,6 +170,9 @@ class Styles extends AbstractPart
|
|||
$xmlWriter->startElement('w:link');
|
||||
$xmlWriter->writeAttribute('w:val', $styleLink);
|
||||
$xmlWriter->endElement();
|
||||
} else if (!is_null($paragraphStyle)) {
|
||||
// if type is 'paragraph' it should have a styleId
|
||||
$xmlWriter->writeAttribute('w:styleId', $styleName);
|
||||
}
|
||||
|
||||
// Style name
|
||||
|
|
@ -178,7 +181,13 @@ class Styles extends AbstractPart
|
|||
$xmlWriter->endElement();
|
||||
|
||||
// Parent style
|
||||
$xmlWriter->writeElementIf(!is_null($paragraphStyle), 'w:basedOn', 'w:val', 'Normal');
|
||||
if (!is_null($paragraphStyle)) {
|
||||
if ($paragraphStyle->getStyleName() != null) {
|
||||
$xmlWriter->writeElementBlock('w:basedOn', 'w:val', $paragraphStyle->getStyleName());
|
||||
} elseif ($paragraphStyle->getBasedOn() != null) {
|
||||
$xmlWriter->writeElementBlock('w:basedOn', 'w:val', $paragraphStyle->getBasedOn());
|
||||
}
|
||||
}
|
||||
|
||||
// w:pPr
|
||||
if (!is_null($paragraphStyle)) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class FootnotePropertiesTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
/**
|
||||
* Test throws exception if wrong position given
|
||||
*
|
||||
*
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testWrongPos()
|
||||
|
|
@ -58,7 +58,7 @@ class FootnotePropertiesTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
/**
|
||||
* Test throws exception if wrong number format given
|
||||
*
|
||||
*
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testWrongNumFmt()
|
||||
|
|
@ -69,7 +69,7 @@ class FootnotePropertiesTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
/**
|
||||
* Test throws exception if wrong number restart given
|
||||
*
|
||||
*
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testWrongNumRestart()
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
|
|||
$phpWord->$method($styleId, array());
|
||||
$this->assertInstanceOf("PhpOffice\\PhpWord\\Style\\{$value}", Style::getStyle($styleId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -18,7 +18,10 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part;
|
|||
|
||||
use PhpOffice\PhpWord\PhpWord;
|
||||
use PhpOffice\PhpWord\SimpleType\Jc;
|
||||
use PhpOffice\PhpWord\Style\Font;
|
||||
use PhpOffice\PhpWord\Style\Paragraph;
|
||||
use PhpOffice\PhpWord\TestHelperDOCX;
|
||||
use PhpOffice\PhpWord\Writer\Word2007;
|
||||
|
||||
/**
|
||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Styles
|
||||
|
|
@ -74,4 +77,70 @@ class StylesTest extends \PHPUnit_Framework_TestCase
|
|||
$element = $doc->getElement($path, $file);
|
||||
$this->assertEquals('Normal', $element->getAttribute('w:val'));
|
||||
}
|
||||
|
||||
public function testFontStyleBasedOn()
|
||||
{
|
||||
$phpWord = new PhpWord();
|
||||
|
||||
$baseParagraphStyle = new Paragraph();
|
||||
$baseParagraphStyle->setAlignment(Jc::CENTER);
|
||||
$baseParagraphStyle = $phpWord->addParagraphStyle('BaseStyle', $baseParagraphStyle);
|
||||
|
||||
$childFont = new Font();
|
||||
$childFont->setParagraph($baseParagraphStyle);
|
||||
$childFont->setSize(16);
|
||||
$childFont = $phpWord->addFontStyle('ChildFontStyle', $childFont);
|
||||
|
||||
$otherFont = new Font();
|
||||
$otherFont->setSize(20);
|
||||
$otherFont = $phpWord->addFontStyle('OtherFontStyle', $otherFont);
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
$file = 'word/styles.xml';
|
||||
|
||||
// Normal style generated?
|
||||
$path = '/w:styles/w:style[@w:styleId="BaseStyle"]/w:name';
|
||||
$element = $doc->getElement($path, $file);
|
||||
$this->assertEquals('BaseStyle', $element->getAttribute('w:val'));
|
||||
|
||||
// Font style with paragraph should have it's base style set to that paragraphs style name
|
||||
$path = '/w:styles/w:style[w:name/@w:val="ChildFontStyle"]/w:basedOn';
|
||||
$element = $doc->getElement($path, $file);
|
||||
$this->assertEquals('BaseStyle', $element->getAttribute('w:val'));
|
||||
|
||||
// Font style without paragraph should not have a base style set
|
||||
$path = '/w:styles/w:style[w:name/@w:val="OtherFontStyle"]/w:basedOn';
|
||||
$element = $doc->getElement($path, $file);
|
||||
$this->assertNull($element);
|
||||
}
|
||||
|
||||
public function testFontStyleBasedOnOtherFontStyle()
|
||||
{
|
||||
$phpWord = new PhpWord();
|
||||
|
||||
$styleGenerationP = new Paragraph();
|
||||
$styleGenerationP->setAlignment(Jc::BOTH);
|
||||
|
||||
$styleGeneration = new Font();
|
||||
$styleGeneration->setParagraph($styleGenerationP);
|
||||
$styleGeneration->setSize(9.5);
|
||||
$phpWord->addFontStyle('Generation', $styleGeneration);
|
||||
|
||||
$styleGenerationEteinteP = new Paragraph();
|
||||
$styleGenerationEteinteP->setBasedOn('Generation');
|
||||
|
||||
$styleGenerationEteinte = new Font();
|
||||
$styleGenerationEteinte->setParagraph($styleGenerationEteinteP);
|
||||
$styleGenerationEteinte->setSize(8.5);
|
||||
$phpWord->addFontStyle('GeneratEteinte', $styleGenerationEteinte);
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
$file = 'word/styles.xml';
|
||||
|
||||
$path = '/w:styles/w:style[@w:styleId="GeneratEteinte"]/w:basedOn';
|
||||
$element = $doc->getElement($path, $file);
|
||||
$this->assertEquals('Generation', $element->getAttribute('w:val'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ class XmlDocument
|
|||
|
||||
if (null === $this->xpath) {
|
||||
$this->xpath = new \DOMXpath($this->dom);
|
||||
|
||||
}
|
||||
|
||||
return $this->xpath->query($path);
|
||||
|
|
|
|||
Loading…
Reference in New Issue