ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing Class Reference
+ Inheritance diagram for PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing:
+ Collaboration diagram for PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing:

Public Member Functions

 __construct ()
 Create a new BaseDrawing. More...
 
 getImageIndex ()
 Get image index. More...
 
 getName ()
 Get Name. More...
 
 setName ($pValue)
 Set Name. More...
 
 getDescription ()
 Get Description. More...
 
 setDescription ($description)
 Set Description. More...
 
 getWorksheet ()
 Get Worksheet. More...
 
 setWorksheet (?Worksheet $pValue=null, $pOverrideOld=false)
 Set Worksheet. More...
 
 getCoordinates ()
 Get Coordinates. More...
 
 setCoordinates ($pValue)
 Set Coordinates. More...
 
 getOffsetX ()
 Get OffsetX. More...
 
 setOffsetX ($pValue)
 Set OffsetX. More...
 
 getOffsetY ()
 Get OffsetY. More...
 
 setOffsetY ($pValue)
 Set OffsetY. More...
 
 getWidth ()
 Get Width. More...
 
 setWidth ($pValue)
 Set Width. More...
 
 getHeight ()
 Get Height. More...
 
 setHeight ($pValue)
 Set Height. More...
 
 setWidthAndHeight ($width, $height)
 Set width and height with proportional resize. More...
 
 getResizeProportional ()
 Get ResizeProportional. More...
 
 setResizeProportional ($pValue)
 Set ResizeProportional. More...
 
 getRotation ()
 Get Rotation. More...
 
 setRotation ($pValue)
 Set Rotation. More...
 
 getShadow ()
 Get Shadow. More...
 
 setShadow (?Drawing\Shadow $pValue=null)
 Set Shadow. More...
 
 getHashCode ()
 Get hash code. More...
 
 __clone ()
 Implement PHP __clone to create a deep clone, not just a shallow copy. More...
 
 setHyperlink (?Hyperlink $pHyperlink=null)
 
 getHyperlink ()
 

Protected Attributes

 $name
 
 $description
 
 $worksheet
 
 $coordinates
 
 $offsetX
 
 $offsetY
 
 $width
 
 $height
 
 $resizeProportional
 
 $rotation
 
 $shadow
 

Private Attributes

 $imageIndex = 0
 
 $hyperlink
 

Static Private Attributes

static $imageCounter = 0
 

Detailed Description

Definition at line 9 of file BaseDrawing.php.

Constructor & Destructor Documentation

◆ __construct()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::__construct ( )

Create a new BaseDrawing.

Definition at line 112 of file BaseDrawing.php.

113  {
114  // Initialise values
115  $this->name = '';
116  $this->description = '';
117  $this->worksheet = null;
118  $this->coordinates = 'A1';
119  $this->offsetX = 0;
120  $this->offsetY = 0;
121  $this->width = 0;
122  $this->height = 0;
123  $this->resizeProportional = true;
124  $this->rotation = 0;
125  $this->shadow = new Drawing\Shadow();
126 
127  // Set image index
128  ++self::$imageCounter;
129  $this->imageIndex = self::$imageCounter;
130  }

Member Function Documentation

◆ __clone()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::__clone ( )

Implement PHP __clone to create a deep clone, not just a shallow copy.

Definition at line 506 of file BaseDrawing.php.

References $key.

507  {
508  $vars = get_object_vars($this);
509  foreach ($vars as $key => $value) {
510  if ($key == 'worksheet') {
511  $this->worksheet = null;
512  } elseif (is_object($value)) {
513  $this->$key = clone $value;
514  } else {
515  $this->$key = $value;
516  }
517  }
518  }
$key
Definition: croninfo.php:18

◆ getCoordinates()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getCoordinates ( )

Get Coordinates.

Returns
string

Definition at line 244 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$coordinates.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing\writeDrawing().

+ Here is the caller graph for this function:

◆ getDescription()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getDescription ( )

Get Description.

Returns
string

Definition at line 171 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$description.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing\writeDrawing().

+ Here is the caller graph for this function:

◆ getHashCode()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getHashCode ( )

Get hash code.

Returns
string Hash code

Implements PhpOffice\PhpSpreadsheet\IComparable.

Definition at line 486 of file BaseDrawing.php.

Referenced by PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\setWorksheet().

487  {
488  return md5(
489  $this->name .
490  $this->description .
491  $this->worksheet->getHashCode() .
492  $this->coordinates .
493  $this->offsetX .
494  $this->offsetY .
495  $this->width .
496  $this->height .
497  $this->rotation .
498  $this->shadow->getHashCode() .
499  __CLASS__
500  );
501  }
+ Here is the caller graph for this function:

◆ getHeight()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getHeight ( )

Get Height.

Returns
int

Definition at line 347 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$height.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing\writeDrawing().

+ Here is the caller graph for this function:

◆ getHyperlink()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getHyperlink ( )
Returns
null|Hyperlink

Definition at line 528 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$hyperlink.

◆ getImageIndex()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getImageIndex ( )

◆ getName()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getName ( )

Get Name.

Returns
string

Definition at line 147 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$name.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing\writeDrawing().

+ Here is the caller graph for this function:

◆ getOffsetX()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getOffsetX ( )

Get OffsetX.

Returns
int

Definition at line 268 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$offsetX.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing\writeDrawing().

+ Here is the caller graph for this function:

◆ getOffsetY()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getOffsetY ( )

Get OffsetY.

Returns
int

Definition at line 292 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$offsetY.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing\writeDrawing().

+ Here is the caller graph for this function:

◆ getResizeProportional()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getResizeProportional ( )

Get ResizeProportional.

Returns
bool

Definition at line 414 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$resizeProportional.

◆ getRotation()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getRotation ( )

Get Rotation.

Returns
int

Definition at line 438 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$rotation.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing\writeDrawing().

+ Here is the caller graph for this function:

◆ getShadow()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getShadow ( )

Get Shadow.

Returns
Drawing

Definition at line 462 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$shadow.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing\writeDrawing().

+ Here is the caller graph for this function:

◆ getWidth()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getWidth ( )

Get Width.

Returns
int

Definition at line 316 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$width.

Referenced by PhpOffice\PhpSpreadsheet\Writer\Xlsx\Drawing\writeDrawing().

+ Here is the caller graph for this function:

◆ getWorksheet()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::getWorksheet ( )

Get Worksheet.

Returns
null|Worksheet

Definition at line 195 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$worksheet.

◆ setCoordinates()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setCoordinates (   $pValue)

Set Coordinates.

Parameters
string$pValueeg: 'A1'
Returns
$this

Definition at line 256 of file BaseDrawing.php.

257  {
258  $this->coordinates = $pValue;
259 
260  return $this;
261  }

◆ setDescription()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setDescription (   $description)

Set Description.

Parameters
string$description
Returns
$this

Definition at line 183 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$description.

184  {
185  $this->description = $description;
186 
187  return $this;
188  }

◆ setHeight()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setHeight (   $pValue)

Set Height.

Parameters
int$pValue
Returns
$this

Definition at line 359 of file BaseDrawing.php.

360  {
361  // Resize proportional?
362  if ($this->resizeProportional && $pValue != 0) {
363  $ratio = $this->width / ($this->height != 0 ? $this->height : 1);
364  $this->width = (int) round($ratio * $pValue);
365  }
366 
367  // Set height
368  $this->height = $pValue;
369 
370  return $this;
371  }

◆ setHyperlink()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setHyperlink ( ?Hyperlink  $pHyperlink = null)

Definition at line 520 of file BaseDrawing.php.

520  : void
521  {
522  $this->hyperlink = $pHyperlink;
523  }

◆ setName()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setName (   $pValue)

Set Name.

Parameters
string$pValue
Returns
$this

Definition at line 159 of file BaseDrawing.php.

160  {
161  $this->name = $pValue;
162 
163  return $this;
164  }

◆ setOffsetX()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setOffsetX (   $pValue)

Set OffsetX.

Parameters
int$pValue
Returns
$this

Definition at line 280 of file BaseDrawing.php.

281  {
282  $this->offsetX = $pValue;
283 
284  return $this;
285  }

◆ setOffsetY()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setOffsetY (   $pValue)

Set OffsetY.

Parameters
int$pValue
Returns
$this

Definition at line 304 of file BaseDrawing.php.

305  {
306  $this->offsetY = $pValue;
307 
308  return $this;
309  }

◆ setResizeProportional()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setResizeProportional (   $pValue)

Set ResizeProportional.

Parameters
bool$pValue
Returns
$this

Definition at line 426 of file BaseDrawing.php.

427  {
428  $this->resizeProportional = $pValue;
429 
430  return $this;
431  }

◆ setRotation()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setRotation (   $pValue)

Set Rotation.

Parameters
int$pValue
Returns
$this

Definition at line 450 of file BaseDrawing.php.

451  {
452  $this->rotation = $pValue;
453 
454  return $this;
455  }

◆ setShadow()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setShadow ( ?Drawing\Shadow  $pValue = null)

Set Shadow.

Parameters
Drawing\Shadow$pValue
Returns
$this

Definition at line 474 of file BaseDrawing.php.

475  {
476  $this->shadow = $pValue;
477 
478  return $this;
479  }

◆ setWidth()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setWidth (   $pValue)

Set Width.

Parameters
int$pValue
Returns
$this

Definition at line 328 of file BaseDrawing.php.

329  {
330  // Resize proportional?
331  if ($this->resizeProportional && $pValue != 0) {
332  $ratio = $this->height / ($this->width != 0 ? $this->width : 1);
333  $this->height = (int) round($ratio * $pValue);
334  }
335 
336  // Set width
337  $this->width = $pValue;
338 
339  return $this;
340  }

◆ setWidthAndHeight()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setWidthAndHeight (   $width,
  $height 
)

Set width and height with proportional resize.

Example: $objDrawing->setResizeProportional(true); $objDrawing->setWidthAndHeight(160,120);

Author
Vincent MSN:kele_.nosp@m.100@.nosp@m.hotma.nosp@m.il.c.nosp@m.om
Parameters
int$width
int$height
Returns
$this

Definition at line 389 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$height, and PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\$width.

390  {
391  $xratio = $width / ($this->width != 0 ? $this->width : 1);
392  $yratio = $height / ($this->height != 0 ? $this->height : 1);
393  if ($this->resizeProportional && !($width == 0 || $height == 0)) {
394  if (($xratio * $this->height) < $height) {
395  $this->height = (int) ceil($xratio * $this->height);
396  $this->width = $width;
397  } else {
398  $this->width = (int) ceil($yratio * $this->width);
399  $this->height = $height;
400  }
401  } else {
402  $this->width = $width;
403  $this->height = $height;
404  }
405 
406  return $this;
407  }

◆ setWorksheet()

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::setWorksheet ( ?Worksheet  $pValue = null,
  $pOverrideOld = false 
)

Set Worksheet.

Parameters
Worksheet$pValue
bool$pOverrideOldIf a Worksheet has already been assigned, overwrite it and remove image from old Worksheet?
Returns
$this

Definition at line 208 of file BaseDrawing.php.

References PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing\getHashCode().

209  {
210  if ($this->worksheet === null) {
211  // Add drawing to \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
212  $this->worksheet = $pValue;
213  $this->worksheet->getCell($this->coordinates);
214  $this->worksheet->getDrawingCollection()->append($this);
215  } else {
216  if ($pOverrideOld) {
217  // Remove drawing from old \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
218  $iterator = $this->worksheet->getDrawingCollection()->getIterator();
219 
220  while ($iterator->valid()) {
221  if ($iterator->current()->getHashCode() === $this->getHashCode()) {
222  $this->worksheet->getDrawingCollection()->offsetUnset($iterator->key());
223  $this->worksheet = null;
224 
225  break;
226  }
227  }
228 
229  // Set new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
230  $this->setWorksheet($pValue);
231  } else {
232  throw new PhpSpreadsheetException('A Worksheet has already been assigned. Drawings can only exist on one \\PhpOffice\\PhpSpreadsheet\\Worksheet.');
233  }
234  }
235 
236  return $this;
237  }
setWorksheet(?Worksheet $pValue=null, $pOverrideOld=false)
Set Worksheet.
+ Here is the call graph for this function:

Field Documentation

◆ $coordinates

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::$coordinates
protected

◆ $description

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::$description
protected

◆ $height

◆ $hyperlink

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::$hyperlink
private

◆ $imageCounter

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::$imageCounter = 0
staticprivate

Definition at line 16 of file BaseDrawing.php.

◆ $imageIndex

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::$imageIndex = 0
private

◆ $name

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::$name
protected

◆ $offsetX

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::$offsetX
protected

◆ $offsetY

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::$offsetY
protected

◆ $resizeProportional

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::$resizeProportional
protected

◆ $rotation

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::$rotation
protected

◆ $shadow

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::$shadow
protected

◆ $width

◆ $worksheet

PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing::$worksheet
protected

The documentation for this class was generated from the following file: