From c6d0a4d3d03526e900ec71f033d95dffcd70b999 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Mon, 14 Jul 2014 23:45:46 +0100 Subject: [PATCH] Additional divide by zero handling --- Classes/PHPExcel/Worksheet/BaseDrawing.php | 12 ++++++++---- changelog.txt | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Classes/PHPExcel/Worksheet/BaseDrawing.php b/Classes/PHPExcel/Worksheet/BaseDrawing.php index 4820afb8..77b0b398 100644 --- a/Classes/PHPExcel/Worksheet/BaseDrawing.php +++ b/Classes/PHPExcel/Worksheet/BaseDrawing.php @@ -321,7 +321,7 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable public function setWidth($pValue = 0) { // Resize proportional? if ($this->_resizeProportional && $pValue != 0) { - $ratio = $this->_height / $this->_width; + $ratio = $this->_height / ($this->_width !== 0 ? $this->_width : 1); $this->_height = round($ratio * $pValue); } @@ -373,8 +373,8 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable * @return PHPExcel_Worksheet_BaseDrawing */ public function setWidthAndHeight($width = 0, $height = 0) { - $xratio = $width / $this->_width; - $yratio = $height / $this->_height; + $xratio = $width / ($this->_width !== 0 ? $this->_width : 1); + $yratio = $height / ($this->_height !== 0 ? $this->_height : 1); if ($this->_resizeProportional && !($width == 0 || $height == 0)) { if (($xratio * $this->_height) < $height) { $this->_height = ceil($xratio * $this->_height); @@ -383,7 +383,11 @@ class PHPExcel_Worksheet_BaseDrawing implements PHPExcel_IComparable $this->_width = ceil($yratio * $this->_width); $this->_height = $height; } - } + } else { + $this->_width = $width; + $this->_height = $height; + } + return $this; } diff --git a/changelog.txt b/changelog.txt index cab93b29..17e2bb0d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -24,8 +24,11 @@ Planned for v1.8.1 - Bugfix: (goncons) Work Item GH-397 - Fix for Writing an Open Document cell with non-numeric formula +- Bugfix: (sarciszewski) Work Item GH-329 - Avoid potential divide by zero in basedrawing +- General: (MBaker) - Small performance improvement for autosize columns - Feature: (WiktrzGE) Work Item GH-404 - Methods to manage most of the existing options for Chart Axis, Major Grid-lines and Minor Grid-lines - Feature: (frost-nzcr4) Work Item GH-403 - ODS read/write comments in the cell +- Feature: (CQD) Work Item GH-389 - Additional Mac CJK codepage definitions 2014-03-02 (v1.8.0):