From 71618f704d092ac32b73f5dc8ca2862946fba930 Mon Sep 17 00:00:00 2001 From: eweso <6918714+eweso@users.noreply.github.com> Date: Fri, 30 Mar 2018 19:24:45 +0200 Subject: [PATCH 1/4] 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. --- src/PhpWord/Style/ListItem.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php index 306ecff305..c8bd2101f5 100644 --- a/src/PhpWord/Style/ListItem.php +++ b/src/PhpWord/Style/ListItem.php @@ -11,7 +11,7 @@ * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * * @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 */ @@ -139,6 +139,16 @@ public function getNumId() 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 * @@ -148,7 +158,12 @@ public function getNumId() private function getListTypeStyle() { // 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) { $this->setNumStyle($numStyle); From a09e7151acd71f1681f4bf70824b12a92099c359 Mon Sep 17 00:00:00 2001 From: eweso <6918714+eweso@users.noreply.github.com> Date: Fri, 30 Mar 2018 22:58:03 +0200 Subject: [PATCH 2/4] Update ListItem.php --- src/PhpWord/Style/ListItem.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php index c8bd2101f5..4a844e48ed 100644 --- a/src/PhpWord/Style/ListItem.php +++ b/src/PhpWord/Style/ListItem.php @@ -140,8 +140,8 @@ public function getNumId() } /** - * Set numbering Id, to force list to restart counting. Same num id means same list - * @param int + * Set numbering Id. Same numId means same list + * @param mixed */ public function setNumId($numInt) { From 5741e47129b6c4c4c82af443bc120c8273c123db Mon Sep 17 00:00:00 2001 From: eweso <6918714+eweso@users.noreply.github.com> Date: Sat, 31 Mar 2018 00:37:50 +0200 Subject: [PATCH 3/4] Update ListItem.php --- src/PhpWord/Style/ListItem.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php index 4a844e48ed..74bf3c9738 100644 --- a/src/PhpWord/Style/ListItem.php +++ b/src/PhpWord/Style/ListItem.php @@ -141,7 +141,7 @@ public function getNumId() /** * Set numbering Id. Same numId means same list - * @param mixed + * @param mixed $numInt */ public function setNumId($numInt) { @@ -158,12 +158,12 @@ public function setNumId($numInt) private function getListTypeStyle() { // Check if legacy style already registered in global Style collection - $numStyle = "PHPWordList_" . $this->listType; - + $numStyle = 'PHPWordListType' . $this->listType; + if ($this->numId) { - $numStyle .= '_' . $this->numId; + $numStyle .= 'NumId' . $this->numId; } - + if (Style::getStyle($numStyle) !== null) { $this->setNumStyle($numStyle); From 91ada213c525cb5a2712111e6c73d9ecd587b36a Mon Sep 17 00:00:00 2001 From: eweso <6918714+eweso@users.noreply.github.com> Date: Sat, 31 Mar 2018 00:38:43 +0200 Subject: [PATCH 4/4] Update ListItem.php --- src/PhpWord/Style/ListItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php index 74bf3c9738..4293940fd2 100644 --- a/src/PhpWord/Style/ListItem.php +++ b/src/PhpWord/Style/ListItem.php @@ -11,7 +11,7 @@ * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. * * @see https://github.com/PHPOffice/PHPWord - * @copyright 2010-2017 PHPWord contributors + * @copyright 2010-2018 PHPWord contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */