ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
PageSetup.php
Go to the documentation of this file.
1 <?php
108 {
109  /* Paper size */
110  const PAPERSIZE_LETTER = 1;
112  const PAPERSIZE_TABLOID = 3;
113  const PAPERSIZE_LEDGER = 4;
114  const PAPERSIZE_LEGAL = 5;
117  const PAPERSIZE_A3 = 8;
118  const PAPERSIZE_A4 = 9;
119  const PAPERSIZE_A4_SMALL = 10;
120  const PAPERSIZE_A5 = 11;
121  const PAPERSIZE_B4 = 12;
122  const PAPERSIZE_B5 = 13;
123  const PAPERSIZE_FOLIO = 14;
124  const PAPERSIZE_QUARTO = 15;
127  const PAPERSIZE_NOTE = 18;
133  const PAPERSIZE_C = 24;
134  const PAPERSIZE_D = 25;
135  const PAPERSIZE_E = 26;
151  const PAPERSIZE_ISO_B4 = 42;
173  const PAPERSIZE_A2_PAPER = 64;
176 
177  /* Page orientation */
178  const ORIENTATION_DEFAULT = 'default';
179  const ORIENTATION_LANDSCAPE = 'landscape';
180  const ORIENTATION_PORTRAIT = 'portrait';
181 
187  private $_paperSize;
188 
194  private $_orientation;
195 
204  private $_scale;
205 
212  private $_fitToHeight;
213 
220  private $_fitToWidth;
221 
227  private $_columnsToRepeatAtLeft = array('', '');
228 
234  private $_rowsToRepeatAtTop = array(0, 0);
235 
241  private $_horizontalCentered = false;
242 
248  private $_verticalCentered = false;
249 
255  private $_printArea = null;
256 
260  public function __construct()
261  {
262  // Initialise values
265  $this->_scale = null;
266  $this->_fitToHeight = null;
267  $this->_fitToWidth = null;
268  $this->_columnsToRepeatAtLeft = array('', '');
269  $this->_rowsToRepeatAtTop = array(0, 0);
270  $this->_horizontalCentered = false;
271  $this->_verticalCentered = false;
272  $this->_printArea = null;
273  }
274 
280  public function getPaperSize() {
281  return $this->_paperSize;
282  }
283 
291  $this->_paperSize = $pValue;
292  return $this;
293  }
294 
300  public function getOrientation() {
301  return $this->_orientation;
302  }
303 
311  $this->_orientation = $pValue;
312  return $this;
313  }
314 
320  public function getScale() {
321  return $this->_scale;
322  }
323 
334  public function setScale($pValue = 100) {
335  // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface,
336  // but it is apparently still able to handle any scale >= 0, where 0 results in 100
337  if (($pValue >= 0) || is_null($pValue)) {
338  $this->_scale = $pValue;
339  } else {
340  throw new Exception("Scale must not be negative");
341  }
342  return $this;
343  }
344 
350  public function getFitToHeight() {
351  return $this->_fitToHeight;
352  }
353 
360  public function setFitToHeight($pValue = 1) {
361  if ($pValue != '') {
362  $this->_fitToHeight = $pValue;
363  }
364  return $this;
365  }
366 
372  public function getFitToWidth() {
373  return $this->_fitToWidth;
374  }
375 
382  public function setFitToWidth($pValue = 1) {
383  if ($pValue != '') {
384  $this->_fitToWidth = $pValue;
385  }
386  return $this;
387  }
388 
394  public function isColumnsToRepeatAtLeftSet() {
395  if (is_array($this->_columnsToRepeatAtLeft)) {
396  if ($this->_columnsToRepeatAtLeft[0] != '' && $this->_columnsToRepeatAtLeft[1] != '') {
397  return true;
398  }
399  }
400 
401  return false;
402  }
403 
409  public function getColumnsToRepeatAtLeft() {
411  }
412 
419  public function setColumnsToRepeatAtLeft($pValue = null) {
420  if (is_array($pValue)) {
421  $this->_columnsToRepeatAtLeft = $pValue;
422  }
423  return $this;
424  }
425 
433  public function setColumnsToRepeatAtLeftByStartAndEnd($pStart = 'A', $pEnd = 'A') {
434  $this->_columnsToRepeatAtLeft = array($pStart, $pEnd);
435  return $this;
436  }
437 
443  public function isRowsToRepeatAtTopSet() {
444  if (is_array($this->_rowsToRepeatAtTop)) {
445  if ($this->_rowsToRepeatAtTop[0] != 0 && $this->_rowsToRepeatAtTop[1] != 0) {
446  return true;
447  }
448  }
449 
450  return false;
451  }
452 
458  public function getRowsToRepeatAtTop() {
460  }
461 
468  public function setRowsToRepeatAtTop($pValue = null) {
469  if (is_array($pValue)) {
470  $this->_rowsToRepeatAtTop = $pValue;
471  }
472  return $this;
473  }
474 
482  public function setRowsToRepeatAtTopByStartAndEnd($pStart = 1, $pEnd = 1) {
483  $this->_rowsToRepeatAtTop = array($pStart, $pEnd);
484  return $this;
485  }
486 
492  public function getHorizontalCentered() {
494  }
495 
502  public function setHorizontalCentered($value = false) {
503  $this->_horizontalCentered = $value;
504  return $this;
505  }
506 
512  public function getVerticalCentered() {
514  }
515 
522  public function setVerticalCentered($value = false) {
523  $this->_verticalCentered = $value;
524  return $this;
525  }
526 
532  public function getPrintArea() {
533  return $this->_printArea;
534  }
535 
541  public function isPrintAreaSet() {
542  return !is_null($this->_printArea);
543  }
544 
552  public function setPrintArea($value) {
553  if (strpos($value,':') === false) {
554  throw new Exception('Cell coordinate must be a range of cells.');
555  } elseif (strpos($value,'$') !== false) {
556  throw new Exception('Cell coordinate must not be absolute.');
557  } else {
558  $this->_printArea = strtoupper($value);
559  }
560  return $this;
561  }
562 
572  public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2)
573  {
574  return $this->setPrintArea(PHPExcel_Cell::stringFromColumnIndex($column1) . $row1 . ':' . PHPExcel_Cell::stringFromColumnIndex($column2) . $row2);
575  }
576 
580  public function __clone() {
581  $vars = get_object_vars($this);
582  foreach ($vars as $key => $value) {
583  if (is_object($value)) {
584  $this->$key = clone $value;
585  } else {
586  $this->$key = $value;
587  }
588  }
589  }
590 }