-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
350 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
/** | ||
* This file is part of PHPWord - A pure PHP library for reading and writing | ||
* word processing documents. | ||
* | ||
* PHPWord is free software distributed under the terms of the GNU Lesser | ||
* General Public License version 3 as published by the Free Software Foundation. | ||
* | ||
* For the full copyright and license information, please read the LICENSE | ||
* file that was distributed with this source code. For the full list of | ||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. | ||
* | ||
* @link https://github.com/PHPOffice/PHPWord | ||
* @copyright 2010-2014 PHPWord contributors | ||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 | ||
*/ | ||
|
||
namespace PhpOffice\PhpWord\Element; | ||
|
||
use PhpOffice\PhpWord\Shared\String; | ||
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle; | ||
use PhpOffice\PhpWord\Style\Paragraph; | ||
|
||
/** | ||
* List item element | ||
*/ | ||
class ListItemRun extends TextRun | ||
{ | ||
/** | ||
* ListItem Style | ||
* | ||
* @var \PhpOffice\PhpWord\Style\ListItem | ||
*/ | ||
private $style; | ||
|
||
/** | ||
* ListItem Depth | ||
* | ||
* @var int | ||
*/ | ||
private $depth; | ||
|
||
/** | ||
* Create a new ListItem | ||
* | ||
* @param int $depth | ||
* @param mixed $fontStyle | ||
* @param array|string|null $listStyle | ||
* @param mixed $paragraphStyle | ||
*/ | ||
public function __construct($depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null) | ||
{ | ||
$this->container = 'listitemrun'; | ||
$this->depth = $depth; | ||
|
||
// Version >= 0.10.0 will pass numbering style name. Older version will use old method | ||
if (!is_null($listStyle) && is_string($listStyle)) { | ||
$this->style = new ListItemStyle($listStyle); | ||
} else { | ||
$this->style = $this->setStyle(new ListItemStyle(), $listStyle, true); | ||
} | ||
$this->paragraphStyle = $this->setStyle(new Paragraph(), $paragraphStyle); | ||
} | ||
|
||
/** | ||
* Get ListItem style | ||
*/ | ||
public function getStyle() | ||
{ | ||
return $this->style; | ||
} | ||
|
||
/** | ||
* Get ListItem depth | ||
*/ | ||
public function getDepth() | ||
{ | ||
return $this->depth; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* This file is part of PHPWord - A pure PHP library for reading and writing | ||
* word processing documents. | ||
* | ||
* PHPWord is free software distributed under the terms of the GNU Lesser | ||
* General Public License version 3 as published by the Free Software Foundation. | ||
* | ||
* For the full copyright and license information, please read the LICENSE | ||
* file that was distributed with this source code. For the full list of | ||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. | ||
* | ||
* @link https://github.com/PHPOffice/PHPWord | ||
* @copyright 2010-2014 PHPWord contributors | ||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 | ||
*/ | ||
|
||
namespace PhpOffice\PhpWord\Writer\Word2007\Element; | ||
|
||
use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; | ||
|
||
/** | ||
* ListItemRun element writer | ||
* | ||
* @since 0.10.0 | ||
*/ | ||
class ListItemRun extends AbstractElement | ||
{ | ||
/** | ||
* Write list item element | ||
*/ | ||
public function write() | ||
{ | ||
$xmlWriter = $this->getXmlWriter(); | ||
$element = $this->getElement(); | ||
|
||
$xmlWriter->startElement('w:p'); | ||
|
||
$xmlWriter->startElement('w:pPr'); | ||
$paragraphStyle = $element->getParagraphStyle(); | ||
$styleWriter = new ParagraphStyleWriter($xmlWriter, $paragraphStyle); | ||
$styleWriter->setIsInline(true); | ||
$styleWriter->write(); | ||
|
||
$xmlWriter->startElement('w:numPr'); | ||
$xmlWriter->startElement('w:ilvl'); | ||
$xmlWriter->writeAttribute('w:val', $element->getDepth()); | ||
$xmlWriter->endElement(); // w:ilvl | ||
$xmlWriter->startElement('w:numId'); | ||
$xmlWriter->writeAttribute('w:val', $element->getStyle()->getNumId()); | ||
$xmlWriter->endElement(); // w:numId | ||
$xmlWriter->endElement(); // w:numPr | ||
|
||
$xmlWriter->endElement(); // w:pPr | ||
|
||
$containerWriter = new Container($xmlWriter, $element); | ||
$containerWriter->write(); | ||
|
||
$xmlWriter->endElement(); // w:p | ||
} | ||
} |
Oops, something went wrong.