Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
 
3
namespace PhpOffice\PhpSpreadsheet\Worksheet;
4
 
5
use PhpOffice\PhpSpreadsheet\Helper\Dimension as CssDimension;
6
 
7
class RowDimension extends Dimension
8
{
9
    /**
10
     * Row index.
11
     */
12
    private ?int $rowIndex;
13
 
14
    /**
15
     * Row height (in pt).
16
     *
17
     * When this is set to a negative value, the row height should be ignored by IWriter
18
     */
19
    private float $height = -1;
20
 
21
    /**
22
     * ZeroHeight for Row?
23
     */
24
    private bool $zeroHeight = false;
25
 
26
    /**
27
     * Create a new RowDimension.
28
     *
29
     * @param ?int $index Numeric row index
30
     */
31
    public function __construct(?int $index = 0)
32
    {
33
        // Initialise values
34
        $this->rowIndex = $index;
35
 
36
        // set dimension as unformatted by default
37
        parent::__construct(null);
38
    }
39
 
40
    /**
41
     * Get Row Index.
42
     */
43
    public function getRowIndex(): ?int
44
    {
45
        return $this->rowIndex;
46
    }
47
 
48
    /**
49
     * Set Row Index.
50
     *
51
     * @return $this
52
     */
53
    public function setRowIndex(int $index): static
54
    {
55
        $this->rowIndex = $index;
56
 
57
        return $this;
58
    }
59
 
60
    /**
61
     * Get Row Height.
62
     * By default, this will be in points; but this method also accepts an optional unit of measure
63
     *    argument, and will convert the value from points to the specified UoM.
64
     *    A value of -1 tells Excel to display this column in its default height.
65
     */
66
    public function getRowHeight(?string $unitOfMeasure = null): float
67
    {
68
        return ($unitOfMeasure === null || $this->height < 0)
69
            ? $this->height
70
            : (new CssDimension($this->height . CssDimension::UOM_POINTS))->toUnit($unitOfMeasure);
71
    }
72
 
73
    /**
74
     * Set Row Height.
75
     *
76
     * @param float $height in points. A value of -1 tells Excel to display this column in its default height.
77
     * By default, this will be the passed argument value; but this method also accepts an optional unit of measure
78
     *    argument, and will convert the passed argument value to points from the specified UoM
79
     *
80
     * @return $this
81
     */
82
    public function setRowHeight(float $height, ?string $unitOfMeasure = null): static
83
    {
84
        $this->height = ($unitOfMeasure === null || $height < 0)
85
            ? $height
86
            : (new CssDimension("{$height}{$unitOfMeasure}"))->height();
87
 
88
        return $this;
89
    }
90
 
91
    /**
92
     * Get ZeroHeight.
93
     */
94
    public function getZeroHeight(): bool
95
    {
96
        return $this->zeroHeight;
97
    }
98
 
99
    /**
100
     * Set ZeroHeight.
101
     *
102
     * @return $this
103
     */
104
    public function setZeroHeight(bool $zeroHeight): static
105
    {
106
        $this->zeroHeight = $zeroHeight;
107
 
108
        return $this;
109
    }
110
}