Adding setNumId method for ListItem style
By allowing to set the numId in the ListItem style manually, you can separate lists. Every ListItem with the same numId belongs to one list. This allows you to restart list counting.
This commit is contained in:
parent
400ee57bee
commit
71618f704d
|
|
@ -11,7 +11,7 @@
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @see https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
* @copyright 2010-2018 PHPWord contributors
|
* @copyright 2010-2017 PHPWord contributors
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -139,6 +139,16 @@ class ListItem extends AbstractStyle
|
||||||
return $this->numId;
|
return $this->numId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set numbering Id, to force list to restart counting. Same num id means same list
|
||||||
|
* @param int
|
||||||
|
*/
|
||||||
|
public function setNumId($numInt)
|
||||||
|
{
|
||||||
|
$this->numId = $numInt;
|
||||||
|
$this->getListTypeStyle();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get legacy numbering definition
|
* Get legacy numbering definition
|
||||||
*
|
*
|
||||||
|
|
@ -148,7 +158,12 @@ class ListItem extends AbstractStyle
|
||||||
private function getListTypeStyle()
|
private function getListTypeStyle()
|
||||||
{
|
{
|
||||||
// Check if legacy style already registered in global Style collection
|
// Check if legacy style already registered in global Style collection
|
||||||
$numStyle = "PHPWordList{$this->listType}";
|
$numStyle = "PHPWordList_" . $this->listType;
|
||||||
|
|
||||||
|
if ($this->numId) {
|
||||||
|
$numStyle .= '_' . $this->numId;
|
||||||
|
}
|
||||||
|
|
||||||
if (Style::getStyle($numStyle) !== null) {
|
if (Style::getStyle($numStyle) !== null) {
|
||||||
$this->setNumStyle($numStyle);
|
$this->setNumStyle($numStyle);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue