From 3cdcf4958dacc48ca4225d743bd4a36ec3a959de Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Tue, 29 Apr 2025 11:06:50 +0400 Subject: [PATCH 1/2] =?UTF-8?q?support=20de=20multiples=20d=C3=A9finitions?= =?UTF-8?q?=20pour=20border?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ext/spout/SpoutBuilder.php | 41 ++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/ext/spout/SpoutBuilder.php b/src/ext/spout/SpoutBuilder.php index 5abdade..ad1035c 100644 --- a/src/ext/spout/SpoutBuilder.php +++ b/src/ext/spout/SpoutBuilder.php @@ -86,20 +86,23 @@ class SpoutBuilder extends AbstractBuilder { if (($wrap = $cell["wrap"] ?? null) !== null) $style->setShouldWrapText($wrap); if (($format = $cell["format"] ?? null) !== null) $style->setFormat($format); if (($border = $cell["border"] ?? null) !== null) { - if (is_string($border)) { - $parts = explode(" ", $border); - $border = []; + if (is_array($border)) $borderDefs = $border; + else $borderDefs = preg_split('/\s*,\s*/', trim(strval($border))); + $border = null; + foreach ($borderDefs as $borderDef) { + $parts = preg_split('/\s+/', $borderDef); + $borderDef = []; $styleAll = null; $widthAll = null; $colorAll = null; foreach ($parts as $part) { if ($part === "all") { - $border["left"] = []; - $border["top"] = []; - $border["right"] = []; - $border["bottom"] = []; + $borderDef["left"] = []; + $borderDef["top"] = []; + $borderDef["right"] = []; + $borderDef["bottom"] = []; } elseif (preg_match('/^(left|top|right|bottom)$/', $part)) { - $border[$part] = []; + $borderDef[$part] = []; } elseif (preg_match('/^(none|solid|dashed|dotted|double)$/', $part)) { $styleAll = $part; } elseif (preg_match('/^(thin|medium|thick)$/', $part)) { @@ -108,22 +111,22 @@ class SpoutBuilder extends AbstractBuilder { $colorAll = $part; } } - foreach ($border as &$part) { + foreach ($borderDef as &$part) { if ($styleAll !== null) $part["style"] = $styleAll; if ($widthAll !== null) $part["width"] = $widthAll; if ($colorAll !== null) $part["color"] = $colorAll; }; unset($part); - } - $top = $border["top"] ?? null; - $right = $border["right"] ?? null; - $bottom = $border["bottom"] ?? null; - $left = $border["left"] ?? null; - $border = null; - self::add_border_part($border, "top", $top); - self::add_border_part($border, "right", $right); - self::add_border_part($border, "bottom", $bottom); - self::add_border_part($border, "left", $left); + $top = $borderDef["top"] ?? null; + $right = $borderDef["right"] ?? null; + $bottom = $borderDef["bottom"] ?? null; + $left = $borderDef["left"] ?? null; + + self::add_border_part($border, "top", $top); + self::add_border_part($border, "right", $right); + self::add_border_part($border, "bottom", $bottom); + self::add_border_part($border, "left", $left); + } if ($border !== null) $style->setBorder($border); } return $style; From 6c1c85bcd26d8f4814360f94e9869d285394bb09 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Tue, 29 Apr 2025 11:07:02 +0400 Subject: [PATCH 2/2] remplacer nur_func par func --- src/ext/spout/SpoutBuilder.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/ext/spout/SpoutBuilder.php b/src/ext/spout/SpoutBuilder.php index ad1035c..83ba5e1 100644 --- a/src/ext/spout/SpoutBuilder.php +++ b/src/ext/spout/SpoutBuilder.php @@ -6,7 +6,6 @@ use nulib\file\tab\AbstractBuilder; use nulib\file\tab\TAbstractBuilder; use nulib\os\path; use nulib\php\func; -use nulib\php\nur_func; use nulib\php\time\Date; use nulib\php\time\DateTime; use nulib\ref\ext\spout\ref_builder; @@ -324,13 +323,8 @@ class SpoutBuilder extends AbstractBuilder { } if (array_key_exists("cook_func", $sheetParams)) { $cookFunc = $sheetParams["cook_func"] ?? null; - $cookCtx = $cookArgs = null; - if ($cookFunc !== null) { - nur_func::ensure_func($cookFunc, $this, $cookArgs); - $cookCtx = nur_func::_prepare($cookFunc); - } - $this->cookCtx = $cookCtx; - $this->cookArgs = $cookArgs; + if ($cookFunc !== null) $cookFunc = func::with($cookFunc)->bind($this); + $this->cookFunc = $cookFunc; } } return $this;