Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

   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       * @var int
  13       */
  14      private $rowIndex;
  15  
  16      /**
  17       * Row height (in pt).
  18       *
  19       * When this is set to a negative value, the row height should be ignored by IWriter
  20       *
  21       * @var float
  22       */
  23      private $height = -1;
  24  
  25      /**
  26       * ZeroHeight for Row?
  27       *
  28       * @var bool
  29       */
  30      private $zeroHeight = false;
  31  
  32      /**
  33       * Create a new RowDimension.
  34       *
  35       * @param int $index Numeric row index
  36       */
  37      public function __construct($index = 0)
  38      {
  39          // Initialise values
  40          $this->rowIndex = $index;
  41  
  42          // set dimension as unformatted by default
  43          parent::__construct(null);
  44      }
  45  
  46      /**
  47       * Get Row Index.
  48       */
  49      public function getRowIndex(): int
  50      {
  51          return $this->rowIndex;
  52      }
  53  
  54      /**
  55       * Set Row Index.
  56       *
  57       * @return $this
  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 accepts a unit of measure
  69       *    argument, and will convert the value to the specified UoM.
  70       *
  71       * @return float
  72       */
  73      public function getRowHeight(?string $unitOfMeasure = null)
  74      {
  75          return ($unitOfMeasure === null || $this->height < 0)
  76              ? $this->height
  77              : (new CssDimension($this->height . CssDimension::UOM_POINTS))->toUnit($unitOfMeasure);
  78      }
  79  
  80      /**
  81       * Set Row Height.
  82       *
  83       * @param float $height in points
  84       * By default, this will be the passed argument value; but this method accepts a unit of measure
  85       *    argument, and will convert the passed argument value to points from the specified UoM
  86       *
  87       * @return $this
  88       */
  89      public function setRowHeight($height, ?string $unitOfMeasure = null)
  90      {
  91          $this->height = ($unitOfMeasure === null || $height < 0)
  92              ? $height
  93              : (new CssDimension("{$height}{$unitOfMeasure}"))->height();
  94  
  95          return $this;
  96      }
  97  
  98      /**
  99       * Get ZeroHeight.
 100       */
 101      public function getZeroHeight(): bool
 102      {
 103          return $this->zeroHeight;
 104      }
 105  
 106      /**
 107       * Set ZeroHeight.
 108       *
 109       * @return $this
 110       */
 111      public function setZeroHeight(bool $zeroHeight)
 112      {
 113          $this->zeroHeight = $zeroHeight;
 114  
 115          return $this;
 116      }
 117  }