PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Worksheet / RowDimension.php

RowDimension.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Worksheet/RowDimension.php

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