Commit a258d7df authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Possibilité de récupérer les cells dépendantes des formules

parent ce196c1a
Loading
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ class Cell
    public function getFormuleExpr(): ?array
    {
        $fText = $this->getFormule();
        if (!$fText) $fText = $this->getValue();
        if (!$fText) return null;

        $formule = new Formule($fText);
@@ -142,6 +143,18 @@ class Cell



    public function getDeps(): array
    {
        $fText = $this->getFormule();
        if (!$fText) return [];

        $formule = new Formule($fText);

        return $formule->getDepCells();
    }



    /**
     * @return mixed
     */
+32 −14
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ class Formule

    public function analyse(): array
    {
        $this->terms = [];
        if (empty($this->terms)) {

            $start = 0;
            if (str_starts_with($this->formule, 'of:=')) {
@@ -61,12 +61,30 @@ class Formule

            $this->lexing();
            $this->grammar();
        }

        return $this->expr;
    }



    public function getDepCells(): array
    {
        $cells = [];

        $this->analyse();

        foreach($this->terms as $term){
            if ($term['type'] === 'cell'){
                $cells[] = $term['name'];
            }
        }

        return $cells;
    }



    public function displayTerms()
    {
        echo '<div style="clear: both"><code>' . htmlentities($this->formule) . '</code></div>';