Skip to content
This repository
Browse code

Work item 4953 - PowerPoint Charts

git-svn-id: https://phppowerpoint.svn.codeplex.com/svn/trunk@52225 ffd33b8c-2492-42e0-bdc5-587b920b7d6d
  • Loading branch information...
commit 2920a1acdf05e0937207aad6eb40bdfe0f385169 1 parent ee0d0f1
Maarten Balliauw authored October 13, 2010
7  Classes/PHPPowerPoint/Shape/BaseDrawing.php
@@ -69,6 +69,13 @@
69 69
 	 * @var boolean
70 70
 	 */
71 71
 	protected $_resizeProportional;
  72
+	
  73
+    /**
  74
+     * Slide relation ID (should not be used by user code!)
  75
+     * 
  76
+     * @var string
  77
+     */
  78
+    public $__relationId = null;
72 79
 
73 80
     /**
74 81
      * Create a new PHPPowerPoint_Slide_BaseDrawing
186  Classes/PHPPowerPoint/Shape/Chart.php
... ...
@@ -0,0 +1,186 @@
  1
+<?php
  2
+/**
  3
+ * PHPPowerPoint
  4
+ *
  5
+ * Copyright (c) 2009 - 2010 PHPPowerPoint
  6
+ *
  7
+ * This library is free software; you can redistribute it and/or
  8
+ * modify it under the terms of the GNU Lesser General Public
  9
+ * License as published by the Free Software Foundation; either
  10
+ * version 2.1 of the License, or (at your option) any later version.
  11
+ *
  12
+ * This library is distributed in the hope that it will be useful,
  13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15
+ * Lesser General Public License for more details.
  16
+ *
  17
+ * You should have received a copy of the GNU Lesser General Public
  18
+ * License along with this library; if not, write to the Free Software
  19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20
+ *
  21
+ * @category   PHPPowerPoint
  22
+ * @package    PHPPowerPoint_Shape
  23
+ * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  24
+ * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
  25
+ * @version    ##VERSION##, ##DATE##
  26
+ */
  27
+
  28
+
  29
+/**
  30
+ * PHPPowerPoint_Shape_Chart
  31
+ *
  32
+ * @category   PHPPowerPoint
  33
+ * @package    PHPPowerPoint_Shape
  34
+ * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  35
+ */
  36
+class PHPPowerPoint_Shape_Chart extends PHPPowerPoint_Shape_BaseDrawing implements PHPPowerPoint_IComparable
  37
+{
  38
+	/**
  39
+	 * Title
  40
+	 *
  41
+	 * @var PHPPowerPoint_Shape_Chart_Title
  42
+	 */
  43
+	private $_title;
  44
+	
  45
+	/**
  46
+	 * Legend
  47
+	 *
  48
+	 * @var PHPPowerPoint_Shape_Chart_Legend
  49
+	 */
  50
+	private $_legend;
  51
+	
  52
+	/**
  53
+	 * Plot area
  54
+	 *
  55
+	 * @var PHPPowerPoint_Shape_Chart_PlotArea
  56
+	 */
  57
+	private $_plotArea;
  58
+	
  59
+	/**
  60
+	 * View 3D
  61
+	 *
  62
+	 * @var PHPPowerPoint_Shape_Chart_View3D
  63
+	 */
  64
+	private $_view3D;
  65
+
  66
+    /**
  67
+     * Create a new PHPPowerPoint_Slide_MemoryDrawing
  68
+     */
  69
+    public function __construct()
  70
+    {
  71
+    	// Initialize
  72
+    	$this->_title    = new PHPPowerPoint_Shape_Chart_Title();
  73
+    	$this->_legend   = new PHPPowerPoint_Shape_Chart_Legend();
  74
+    	$this->_plotArea = new PHPPowerPoint_Shape_Chart_PlotArea();
  75
+    	$this->_view3D   = new PHPPowerPoint_Shape_Chart_View3D();
  76
+    	
  77
+    	// Initialize parent
  78
+    	parent::__construct();
  79
+    }
  80
+    
  81
+	/**
  82
+	 * Get Title
  83
+	 *
  84
+	 * @return PHPPowerPoint_Shape_Chart_Title
  85
+	 */
  86
+	public function getTitle() {
  87
+	        return $this->_title;
  88
+	}
  89
+	
  90
+	/**
  91
+	 * Get Legend
  92
+	 *
  93
+	 * @return PHPPowerPoint_Shape_Chart_Legend
  94
+	 */
  95
+	public function getLegend() {
  96
+	        return $this->_legend;
  97
+	}
  98
+	
  99
+	/**
  100
+	 * Get PlotArea
  101
+	 *
  102
+	 * @return PHPPowerPoint_Shape_Chart_PlotArea
  103
+	 */
  104
+	public function getPlotArea() {
  105
+	        return $this->_plotArea;
  106
+	}
  107
+	
  108
+	/**
  109
+	 * Get View3D
  110
+	 *
  111
+	 * @return PHPPowerPoint_Shape_Chart_View3D
  112
+	 */
  113
+	public function getView3D() {
  114
+	        return $this->_view3D;
  115
+	}
  116
+
  117
+    /**
  118
+     * Get indexed filename (using image index)
  119
+     *
  120
+     * @return string
  121
+     */
  122
+    public function getIndexedFilename() {
  123
+    	return 'chart' . $this->getImageIndex() . '.xml';
  124
+    }
  125
+    
  126
+	/**
  127
+	 * Get hash code
  128
+	 *
  129
+	 * @return string	Hash code
  130
+	 */
  131
+	public function getHashCode() {
  132
+    	return md5(
  133
+    		  parent::getHashCode()
  134
+    		. $this->_title->getHashCode()
  135
+    		. $this->_legend->getHashCode()
  136
+    		. $this->_plotArea->getHashCode()
  137
+    		. $this->_view3D->getHashCode()
  138
+    		. __CLASS__
  139
+    	);
  140
+    }
  141
+
  142
+    /**
  143
+     * Hash index
  144
+     *
  145
+     * @var string
  146
+     */
  147
+    private $_hashIndex;
  148
+
  149
+	/**
  150
+	 * Get hash index
  151
+	 *
  152
+	 * Note that this index may vary during script execution! Only reliable moment is
  153
+	 * while doing a write of a workbook and when changes are not allowed.
  154
+	 *
  155
+	 * @return string	Hash index
  156
+	 */
  157
+	public function getHashIndex() {
  158
+		return $this->_hashIndex;
  159
+	}
  160
+
  161
+	/**
  162
+	 * Set hash index
  163
+	 *
  164
+	 * Note that this index may vary during script execution! Only reliable moment is
  165
+	 * while doing a write of a workbook and when changes are not allowed.
  166
+	 *
  167
+	 * @param string	$value	Hash index
  168
+	 */
  169
+	public function setHashIndex($value) {
  170
+		$this->_hashIndex = $value;
  171
+	}
  172
+
  173
+	/**
  174
+	 * Implement PHP __clone to create a deep clone, not just a shallow copy.
  175
+	 */
  176
+	public function __clone() {
  177
+		$vars = get_object_vars($this);
  178
+		foreach ($vars as $key => $value) {
  179
+			if (is_object($value)) {
  180
+				$this->$key = clone $value;
  181
+			} else {
  182
+				$this->$key = $value;
  183
+			}
  184
+		}
  185
+	}
  186
+}
159  Classes/PHPPowerPoint/Shape/Chart/Axis.php
... ...
@@ -0,0 +1,159 @@
  1
+<?php
  2
+/**
  3
+ * PHPPowerPoint
  4
+ *
  5
+ * Copyright (c) 2009 - 2010 PHPPowerPoint
  6
+ *
  7
+ * This library is free software; you can redistribute it and/or
  8
+ * modify it under the terms of the GNU Lesser General Public
  9
+ * License as published by the Free Software Foundation; either
  10
+ * version 2.1 of the License, or (at your option) any later version.
  11
+ *
  12
+ * This library is distributed in the hope that it will be useful,
  13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15
+ * Lesser General Public License for more details.
  16
+ *
  17
+ * You should have received a copy of the GNU Lesser General Public
  18
+ * License along with this library; if not, write to the Free Software
  19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20
+ *
  21
+ * @category   PHPPowerPoint
  22
+ * @package    PHPPowerPoint_Shape_Chart
  23
+ * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  24
+ * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
  25
+ * @version    ##VERSION##, ##DATE##
  26
+ */
  27
+
  28
+
  29
+/**
  30
+ * PHPPowerPoint_Shape_Chart_Axis
  31
+ *
  32
+ * @category   PHPPowerPoint
  33
+ * @package    PHPPowerPoint_Shape_Chart
  34
+ * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  35
+ */
  36
+class PHPPowerPoint_Shape_Chart_Axis implements PHPPowerPoint_IComparable
  37
+{	
  38
+	/**
  39
+	 * Title
  40
+	 *
  41
+	 * @var string
  42
+	 */
  43
+	private $_title = 'Axis Title';
  44
+	
  45
+	/**
  46
+	 * Format code
  47
+	 *
  48
+	 * @var string
  49
+	 */
  50
+	private $_formatCode = '';
  51
+
  52
+    /**
  53
+     * Create a new PHPPowerPoint_Shape_Chart_Axis instance
  54
+     * 
  55
+     * @param string $title Title
  56
+     */
  57
+    public function __construct($title = 'Axis Title')
  58
+    {
  59
+    	$this->_title = $title;
  60
+    }
  61
+    
  62
+	/**
  63
+	 * Get Title
  64
+	 *
  65
+	 * @return string
  66
+	 */
  67
+	public function getTitle() {
  68
+	        return $this->_title;
  69
+	}
  70
+	
  71
+	/**
  72
+	 * Set Title
  73
+	 *
  74
+	 * @param string $value
  75
+	 * @return PHPPowerPoint_Shape_Chart_Axis
  76
+	 */
  77
+	public function setTitle($value = 'Axis Title') {
  78
+	        $this->_title = $value;
  79
+	        return $this;
  80
+	}
  81
+	
  82
+	/**
  83
+	 * Get Format Code
  84
+	 *
  85
+	 * @return string
  86
+	 */
  87
+	public function getFormatCode() {
  88
+	        return $this->_formatCode;
  89
+	}
  90
+	
  91
+	/**
  92
+	 * Set Format Code
  93
+	 *
  94
+	 * @param string $value
  95
+	 * @return PHPPowerPoint_Shape_Chart_Axis
  96
+	 */
  97
+	public function setFormatCode($value = '') {
  98
+	        $this->_formatCode = $value;
  99
+	        return $this;
  100
+	}
  101
+	
  102
+	/**
  103
+	 * Get hash code
  104
+	 *
  105
+	 * @return string	Hash code
  106
+	 */
  107
+	public function getHashCode() {
  108
+    	return md5(
  109
+    		  $this->_title
  110
+    		. $this->_formatCode
  111
+    		. __CLASS__
  112
+    	);
  113
+    }
  114
+
  115
+    /**
  116
+     * Hash index
  117
+     *
  118
+     * @var string
  119
+     */
  120
+    private $_hashIndex;
  121
+
  122
+	/**
  123
+	 * Get hash index
  124
+	 *
  125
+	 * Note that this index may vary during script execution! Only reliable moment is
  126
+	 * while doing a write of a workbook and when changes are not allowed.
  127
+	 *
  128
+	 * @return string	Hash index
  129
+	 */
  130
+	public function getHashIndex() {
  131
+		return $this->_hashIndex;
  132
+	}
  133
+
  134
+	/**
  135
+	 * Set hash index
  136
+	 *
  137
+	 * Note that this index may vary during script execution! Only reliable moment is
  138
+	 * while doing a write of a workbook and when changes are not allowed.
  139
+	 *
  140
+	 * @param string	$value	Hash index
  141
+	 */
  142
+	public function setHashIndex($value) {
  143
+		$this->_hashIndex = $value;
  144
+	}
  145
+
  146
+	/**
  147
+	 * Implement PHP __clone to create a deep clone, not just a shallow copy.
  148
+	 */
  149
+	public function __clone() {
  150
+		$vars = get_object_vars($this);
  151
+		foreach ($vars as $key => $value) {
  152
+			if (is_object($value)) {
  153
+				$this->$key = clone $value;
  154
+			} else {
  155
+				$this->$key = $value;
  156
+			}
  157
+		}
  158
+	}
  159
+}
275  Classes/PHPPowerPoint/Shape/Chart/Legend.php
... ...
@@ -0,0 +1,275 @@
  1
+<?php
  2
+/**
  3
+ * PHPPowerPoint
  4
+ *
  5
+ * Copyright (c) 2009 - 2010 PHPPowerPoint
  6
+ *
  7
+ * This library is free software; you can redistribute it and/or
  8
+ * modify it under the terms of the GNU Lesser General Public
  9
+ * License as published by the Free Software Foundation; either
  10
+ * version 2.1 of the License, or (at your option) any later version.
  11
+ *
  12
+ * This library is distributed in the hope that it will be useful,
  13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15
+ * Lesser General Public License for more details.
  16
+ *
  17
+ * You should have received a copy of the GNU Lesser General Public
  18
+ * License along with this library; if not, write to the Free Software
  19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20
+ *
  21
+ * @category   PHPPowerPoint
  22
+ * @package    PHPPowerPoint_Shape_Chart
  23
+ * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  24
+ * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
  25
+ * @version    ##VERSION##, ##DATE##
  26
+ */
  27
+
  28
+
  29
+/**
  30
+ * PHPPowerPoint_Shape_Chart_Legend
  31
+ *
  32
+ * @category   PHPPowerPoint
  33
+ * @package    PHPPowerPoint_Shape_Chart
  34
+ * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  35
+ */
  36
+class PHPPowerPoint_Shape_Chart_Legend implements PHPPowerPoint_IComparable
  37
+{
  38
+	/** Legend positions */
  39
+	const POSITION_BOTTOM   = 'b';
  40
+	const POSITION_LEFT     = 'l';
  41
+	const POSITION_RIGHT    = 'r';
  42
+	const POSITION_TOP      = 't';
  43
+	const POSITION_TOPRIGHT = 'tr';
  44
+	
  45
+	/**
  46
+	 * Visible
  47
+	 *
  48
+	 * @var boolean
  49
+	 */
  50
+	private $_visible = true;
  51
+
  52
+	/**
  53
+	 * Position
  54
+	 *
  55
+	 * @var string
  56
+	 */
  57
+	private $_position = PHPPowerPoint_Shape_Chart_Legend::POSITION_RIGHT;
  58
+	
  59
+	/**
  60
+	 * OffsetX (as a fraction of the chart)
  61
+	 *
  62
+	 * @var float
  63
+	 */
  64
+	private $_offsetX = 0;
  65
+	
  66
+	/**
  67
+	 * OffsetY (as a fraction of the chart)
  68
+	 *
  69
+	 * @var float
  70
+	 */
  71
+	private $_offsetY = 0;
  72
+	
  73
+	/**
  74
+	 * Width (as a fraction of the chart)
  75
+	 *
  76
+	 * @var float
  77
+	 */
  78
+	private $_width = 0;
  79
+	
  80
+	/**
  81
+	 * Height (as a fraction of the chart)
  82
+	 *
  83
+	 * @var float
  84
+	 */
  85
+	private $_height = 0;
  86
+    
  87
+    /**
  88
+     * Create a new PHPPowerPoint_Shape_Chart_Legend instance
  89
+     */
  90
+    public function __construct()
  91
+    {
  92
+    }
  93
+
  94
+	/**
  95
+	 * Get Visible
  96
+	 *
  97
+	 * @return boolean
  98
+	 */
  99
+	public function getVisible() {
  100
+	        return $this->_visible;
  101
+	}
  102
+	
  103
+	/**
  104
+	 * Set Visible
  105
+	 *
  106
+	 * @param boolean $value
  107
+	 * @return PHPPowerPoint_Shape_Chart_Legend
  108
+	 */
  109
+	public function setVisible($value = true) {
  110
+	        $this->_visible = $value;
  111
+	        return $this;
  112
+	}
  113
+
  114
+	/**
  115
+	 * Get Position
  116
+	 *
  117
+	 * @return string
  118
+	 */
  119
+	public function getPosition() {
  120
+	        return $this->_position;
  121
+	}
  122
+	
  123
+	/**
  124
+	 * Set Position
  125
+	 *
  126
+	 * @param string $value
  127
+	 * @return PHPPowerPoint_Shape_Chart_Title
  128
+	 */
  129
+	public function setPosition($value = PHPPowerPoint_Shape_Chart_Legend::POSITION_RIGHT) {
  130
+	        $this->_position = $value;
  131
+	        return $this;
  132
+	}
  133
+	
  134
+	/**
  135
+	 * Get OffsetX (as a fraction of the chart)
  136
+	 *
  137
+	 * @return float
  138
+	 */
  139
+	public function getOffsetX() {
  140
+	        return $this->_offsetX;
  141
+	}
  142
+	
  143
+	/**
  144
+	 * Set OffsetX (as a fraction of the chart)
  145
+	 *
  146
+	 * @param float $value
  147
+	 * @return PHPPowerPoint_Shape_Chart_Legend
  148
+	 */
  149
+	public function setOffsetX($value = 0) {
  150
+	        $this->_offsetX = $value;
  151
+	        return $this;
  152
+	}
  153
+	
  154
+	/**
  155
+	 * Get OffsetY (as a fraction of the chart)
  156
+	 *
  157
+	 * @return float
  158
+	 */
  159
+	public function getOffsetY() {
  160
+	        return $this->_offsetY;
  161
+	}
  162
+	
  163
+	/**
  164
+	 * Set OffsetY (as a fraction of the chart)
  165
+	 *
  166
+	 * @param float $value
  167
+	 * @return PHPPowerPoint_Shape_Chart_Legend
  168
+	 */
  169
+	public function setOffsetY($value = 0) {
  170
+	        $this->_offsetY = $value;
  171
+	        return $this;
  172
+	}
  173
+	
  174
+	/**
  175
+	 * Get Width (as a fraction of the chart)
  176
+	 *
  177
+	 * @return float
  178
+	 */
  179
+	public function getWidth() {
  180
+	        return $this->_width;
  181
+	}
  182
+	
  183
+	/**
  184
+	 * Set Width (as a fraction of the chart)
  185
+	 *
  186
+	 * @param float $value
  187
+	 * @return PHPPowerPoint_Shape_Chart_Legend
  188
+	 */
  189
+	public function setWidth($value = 0) {
  190
+	        $this->_width = $value;
  191
+	        return $this;
  192
+	}
  193
+	
  194
+	/**
  195
+	 * Get Height (as a fraction of the chart)
  196
+	 *
  197
+	 * @return float
  198
+	 */
  199
+	public function getHeight() {
  200
+	        return $this->_height;
  201
+	}
  202
+	
  203
+	/**
  204
+	 * Set Height (as a fraction of the chart)
  205
+	 *
  206
+	 * @param float $value
  207
+	 * @return PHPPowerPoint_Shape_Chart_Legend
  208
+	 */
  209
+	public function setHeight($value = 0) {
  210
+	        $this->_height = $value;
  211
+	        return $this;
  212
+	}
  213
+	
  214
+	/**
  215
+	 * Get hash code
  216
+	 *
  217
+	 * @return string	Hash code
  218
+	 */
  219
+	public function getHashCode() {
  220
+    	return md5(
  221
+    		  $this->_position
  222
+    		. $this->_offsetX
  223
+    		. $this->_offsetY
  224
+    		. $this->_width
  225
+    		. $this->_height
  226
+    		. ($this->_visible ? 't' : 'f')
  227
+    		. __CLASS__
  228
+    	);
  229
+    }
  230
+
  231
+    /**
  232
+     * Hash index
  233
+     *
  234
+     * @var string
  235
+     */
  236
+    private $_hashIndex;
  237
+
  238
+	/**
  239
+	 * Get hash index
  240
+	 *
  241
+	 * Note that this index may vary during script execution! Only reliable moment is
  242
+	 * while doing a write of a workbook and when changes are not allowed.
  243
+	 *
  244
+	 * @return string	Hash index
  245
+	 */
  246
+	public function getHashIndex() {
  247
+		return $this->_hashIndex;
  248
+	}
  249
+
  250
+	/**
  251
+	 * Set hash index
  252
+	 *
  253
+	 * Note that this index may vary during script execution! Only reliable moment is
  254
+	 * while doing a write of a workbook and when changes are not allowed.
  255
+	 *
  256
+	 * @param string	$value	Hash index
  257
+	 */
  258
+	public function setHashIndex($value) {
  259
+		$this->_hashIndex = $value;
  260
+	}
  261
+
  262
+	/**
  263
+	 * Implement PHP __clone to create a deep clone, not just a shallow copy.
  264
+	 */
  265
+	public function __clone() {
  266
+		$vars = get_object_vars($this);
  267
+		foreach ($vars as $key => $value) {
  268
+			if (is_object($value)) {
  269
+				$this->$key = clone $value;
  270
+			} else {
  271
+				$this->$key = $value;
  272
+			}
  273
+		}
  274
+	}
  275
+}
282  Classes/PHPPowerPoint/Shape/Chart/PlotArea.php
... ...
@@ -0,0 +1,282 @@
  1
+<?php
  2
+/**
  3
+ * PHPPowerPoint
  4
+ *
  5
+ * Copyright (c) 2009 - 2010 PHPPowerPoint
  6
+ *
  7
+ * This library is free software; you can redistribute it and/or
  8
+ * modify it under the terms of the GNU Lesser General Public
  9
+ * License as published by the Free Software Foundation; either
  10
+ * version 2.1 of the License, or (at your option) any later version.
  11
+ *
  12
+ * This library is distributed in the hope that it will be useful,
  13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15
+ * Lesser General Public License for more details.
  16
+ *
  17
+ * You should have received a copy of the GNU Lesser General Public
  18
+ * License along with this library; if not, write to the Free Software
  19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20
+ *
  21
+ * @category   PHPPowerPoint
  22
+ * @package    PHPPowerPoint_Shape_Chart
  23
+ * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  24
+ * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
  25
+ * @version    ##VERSION##, ##DATE##
  26
+ */
  27
+
  28
+
  29
+/**
  30
+ * PHPPowerPoint_Shape_Chart_PlotArea
  31
+ *
  32
+ * @category   PHPPowerPoint
  33
+ * @package    PHPPowerPoint_Shape_Chart
  34
+ * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  35
+ */
  36
+class PHPPowerPoint_Shape_Chart_PlotArea implements PHPPowerPoint_IComparable
  37
+{
  38
+	/**
  39
+	 * Type
  40
+	 *
  41
+	 * @var PHPPowerPoint_Shape_Chart_Type
  42
+	 */
  43
+	private $_type;
  44
+	
  45
+	/**
  46
+	 * Axis X
  47
+	 *
  48
+	 * @var PHPPowerPoint_Shape_Chart_Axis
  49
+	 */
  50
+	private $_axisX;
  51
+	
  52
+	/**
  53
+	 * Axis Y
  54
+	 *
  55
+	 * @var PHPPowerPoint_Shape_Chart_Axis
  56
+	 */
  57
+	private $_axisY;
  58
+	
  59
+	/**
  60
+	 * OffsetX (as a fraction of the chart)
  61
+	 *
  62
+	 * @var float
  63
+	 */
  64
+	private $_offsetX = 0;
  65
+	
  66
+	/**
  67
+	 * OffsetY (as a fraction of the chart)
  68
+	 *
  69
+	 * @var float
  70
+	 */
  71
+	private $_offsetY = 0;
  72
+	
  73
+	/**
  74
+	 * Width (as a fraction of the chart)
  75
+	 *
  76
+	 * @var float
  77
+	 */
  78
+	private $_width = 0;
  79
+	
  80
+	/**
  81
+	 * Height (as a fraction of the chart)
  82
+	 *
  83
+	 * @var float
  84
+	 */
  85
+	private $_height = 0;
  86
+    
  87
+    /**
  88
+     * Create a new PHPPowerPoint_Shape_Chart_PlotArea instance
  89
+     */
  90
+    public function __construct()
  91
+    {
  92
+    	$this->_type  = null;
  93
+    	$this->_axisX = new PHPPowerPoint_Shape_Chart_Axis();
  94
+    	$this->_axisY = new PHPPowerPoint_Shape_Chart_Axis();
  95
+    }
  96
+
  97
+	/**
  98
+	 * Get type
  99
+	 *
  100
+	 * @return PHPPowerPoint_Shape_Chart_Type
  101
+	 * @throws Exception
  102
+	 */
  103
+	public function getType() {
  104
+		if (is_null($this->_type)) {
  105
+			throw new Exception('Chart type has not been set.');
  106
+		}
  107
+	    return $this->_type;
  108
+	}
  109
+	
  110
+	/**
  111
+	 * Set type
  112
+	 *
  113
+	 * @param PHPPowerPoint_Shape_Chart_Type $value
  114
+	 * @return PHPPowerPoint_Shape_Chart_PlotArea
  115
+	 * @throws Exception
  116
+	 */
  117
+	public function setType(PHPPowerPoint_Shape_Chart_Type $value) {
  118
+		$this->_type = $value;
  119
+		return $this;
  120
+	}
  121
+	
  122
+	/**
  123
+	 * Get Axis X
  124
+	 *
  125
+	 * @return PHPPowerPoint_Shape_Chart_Axis
  126
+	 */
  127
+	public function getAxisX() {
  128
+		return $this->_axisX;
  129
+	}
  130
+	
  131
+	/**
  132
+	 * Get Axis Y
  133
+	 *
  134
+	 * @return PHPPowerPoint_Shape_Chart_Axis
  135
+	 */
  136
+	public function getAxisY() {
  137
+		return $this->_axisY;
  138
+	}
  139
+	
  140
+	/**
  141
+	 * Get OffsetX (as a fraction of the chart)
  142
+	 *
  143
+	 * @return float
  144
+	 */
  145
+	public function getOffsetX() {
  146
+	        return $this->_offsetX;
  147
+	}
  148
+	
  149
+	/**
  150
+	 * Set OffsetX (as a fraction of the chart)
  151
+	 *
  152
+	 * @param float $value
  153
+	 * @return PHPPowerPoint_Shape_Chart_Title
  154
+	 */
  155
+	public function setOffsetX($value = 0) {
  156
+	        $this->_offsetX = $value;
  157
+	        return $this;
  158
+	}
  159
+	
  160
+	/**
  161
+	 * Get OffsetY (as a fraction of the chart)
  162
+	 *
  163
+	 * @return float
  164
+	 */
  165
+	public function getOffsetY() {
  166
+	        return $this->_offsetY;
  167
+	}
  168
+	
  169
+	/**
  170
+	 * Set OffsetY (as a fraction of the chart)
  171
+	 *
  172
+	 * @param float $value
  173
+	 * @return PHPPowerPoint_Shape_Chart_Title
  174
+	 */
  175
+	public function setOffsetY($value = 0) {
  176
+	        $this->_offsetY = $value;
  177
+	        return $this;
  178
+	}
  179
+	
  180
+	/**
  181
+	 * Get Width (as a fraction of the chart)
  182
+	 *
  183
+	 * @return float
  184
+	 */
  185
+	public function getWidth() {
  186
+	        return $this->_width;
  187
+	}
  188
+	
  189
+	/**
  190
+	 * Set Width (as a fraction of the chart)
  191
+	 *
  192
+	 * @param float $value
  193
+	 * @return PHPPowerPoint_Shape_Chart_Title
  194
+	 */
  195
+	public function setWidth($value = 0) {
  196
+	        $this->_width = $value;
  197
+	        return $this;
  198
+	}
  199
+	
  200
+	/**
  201
+	 * Get Height (as a fraction of the chart)
  202
+	 *
  203
+	 * @return float
  204
+	 */
  205
+	public function getHeight() {
  206
+	        return $this->_height;
  207
+	}
  208
+	
  209
+	/**
  210
+	 * Set Height (as a fraction of the chart)
  211
+	 *
  212
+	 * @param float $value
  213
+	 * @return PHPPowerPoint_Shape_Chart_Title
  214
+	 */
  215
+	public function setHeight($value = 0) {
  216
+	        $this->_height = $value;
  217
+	        return $this;
  218
+	}
  219
+	
  220
+	/**
  221
+	 * Get hash code
  222
+	 *
  223
+	 * @return string	Hash code
  224
+	 */
  225
+	public function getHashCode() {
  226
+    	return md5(
  227
+    		  (is_null($this->_type) ? 'null' : $this->_type->getHashCode())
  228
+    		. $this->_axisX->getHashCode()
  229
+    		. $this->_axisY->getHashCode()
  230
+    		. $this->_offsetX
  231
+    		. $this->_offsetY
  232
+    		. $this->_width
  233
+    		. $this->_height
  234
+    		. __CLASS__
  235
+    	);
  236
+    }
  237
+
  238
+    /**
  239
+     * Hash index
  240
+     *
  241
+     * @var string
  242
+     */
  243
+    private $_hashIndex;
  244
+
  245
+	/**
  246
+	 * Get hash index
  247
+	 *
  248
+	 * Note that this index may vary during script execution! Only reliable moment is
  249
+	 * while doing a write of a workbook and when changes are not allowed.
  250
+	 *
  251
+	 * @return string	Hash index
  252
+	 */
  253
+	public function getHashIndex() {
  254
+		return $this->_hashIndex;
  255
+	}
  256
+
  257
+	/**
  258
+	 * Set hash index
  259
+	 *
  260
+	 * Note that this index may vary during script execution! Only reliable moment is
  261
+	 * while doing a write of a workbook and when changes are not allowed.
  262
+	 *
  263
+	 * @param string	$value	Hash index
  264
+	 */
  265
+	public function setHashIndex($value) {
  266
+		$this->_hashIndex = $value;
  267
+	}
  268
+
  269
+	/**
  270
+	 * Implement PHP __clone to create a deep clone, not just a shallow copy.
  271
+	 */
  272
+	public function __clone() {
  273
+		$vars = get_object_vars($this);
  274
+		foreach ($vars as $key => $value) {
  275
+			if (is_object($value)) {
  276
+				$this->$key = clone $value;
  277
+			} else {
  278
+				$this->$key = $value;
  279
+			}
  280
+		}
  281
+	}
  282
+}
191  Classes/PHPPowerPoint/Shape/Chart/Series.php
... ...
@@ -0,0 +1,191 @@
  1
+<?php
  2
+/**
  3
+ * PHPPowerPoint
  4
+ *
  5
+ * Copyright (c) 2009 - 2010 PHPPowerPoint
  6
+ *
  7
+ * This library is free software; you can redistribute it and/or
  8
+ * modify it under the terms of the GNU Lesser General Public
  9
+ * License as published by the Free Software Foundation; either
  10
+ * version 2.1 of the License, or (at your option) any later version.
  11
+ *
  12
+ * This library is distributed in the hope that it will be useful,
  13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15
+ * Lesser General Public License for more details.
  16
+ *
  17
+ * You should have received a copy of the GNU Lesser General Public
  18
+ * License along with this library; if not, write to the Free Software
  19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20
+ *
  21
+ * @category   PHPPowerPoint
  22
+ * @package    PHPPowerPoint_Shape_Chart
  23
+ * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  24
+ * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt	LGPL
  25
+ * @version    ##VERSION##, ##DATE##
  26
+ */
  27
+
  28
+
  29
+/**
  30
+ * PHPPowerPoint_Shape_Chart_Series
  31
+ *
  32
+ * @category   PHPPowerPoint
  33
+ * @package    PHPPowerPoint_Shape_Chart
  34
+ * @copyright  Copyright (c) 2009 - 2010 PHPPowerPoint (http://www.codeplex.com/PHPPowerPoint)
  35
+ */
  36
+class PHPPowerPoint_Shape_Chart_Series implements PHPPowerPoint_IComparable
  37
+{
  38
+	/**
  39
+	 * Title
  40
+	 *
  41
+	 * @var string
  42
+	 */
  43
+	private $_title = 'Series Title';
  44
+	
  45
+	/**
  46
+	 * Fill
  47
+	 *
  48
+	 * @var PHPPowerPoint_Style_Fill
  49
+	 */
  50
+	private $_fill;
  51
+	
  52
+	/**
  53
+	 * Values (key/value)
  54
+	 *
  55
+	 * @var array
  56
+	 */
  57
+	private $_values = array();
  58
+    
  59
+    /**
  60
+     * Create a new PHPPowerPoint_Shape_Chart_Series instance
  61
+     * 
  62
+     * @param string $title  Title
  63
+     * @param array  $values Values
  64
+     */
  65
+    public function __construct($title = 'Series Title', $values = array())
  66
+    {
  67
+    	$this->_fill   = new PHPPowerPoint_Style_Fill();
  68
+    	$this->_title  = $title;
  69
+    	$this->_values = $values;
  70
+    }
  71
+
  72
+	/**
  73
+	 * Get Title
  74
+	 *
  75
+	 * @return string
  76
+	 */
  77
+	public function getTitle() {
  78
+	        return $this->_title;
  79
+	}
  80
+	
  81
+	/**
  82
+	 * Set Title
  83
+	 *
  84
+	 * @param string $value
  85
+	 * @return PHPPowerPoint_Shape_Chart_Series
  86
+	 */
  87
+	public function setTitle($value = 'Series Title') {
  88
+	        $this->_title = $value;
  89
+	        return $this;
  90
+	}
  91
+	
  92
+    /**
  93
+     * Get Fill
  94
+     *
  95
+     * @return PHPPowerPoint_Style_Fill
  96
+     */
  97
+    public function getFill() {
  98
+		return $this->_fill;
  99
+    }
  100
+    
  101
+	/**
  102
+	 * Get Values
  103
+	 *
  104
+	 * @return array
  105
+	 */
  106
+	public function getValues() {
  107
+	        return $this->_values;
  108
+	}
  109
+	
  110
+	/**
  111
+	 * Set Values
  112
+	 *
  113
+	 * @param array $value
  114
+	 * @return PHPPowerPoint_Shape_Chart_Series
  115
+	 */
  116
+	public function setValues($value = array()) {
  117
+	        $this->_values = $value;
  118
+	        return $this;
  119
+	}
  120
+	
  121
+	/**
  122
+	 * Add Value
  123
+	 *
  124
+	 * @param mixed $key
  125
+	 * @param mixed $value
  126
+	 * @return PHPPowerPoint_Shape_Chart_Series
  127
+	 */
  128
+	public function addValue($key, $value) {
  129
+	        $this->_values[$key] = $value;
  130
+	        return $this;
  131
+	}
  132
+
  133
+	/**
  134
+	 * Get hash code
  135
+	 *
  136
+	 * @return string	Hash code
  137
+	 */
  138
+	public function getHashCode() {
  139
+    	return md5(
  140
+    		  (is_null($this->_fill) ? 'null' : $this->_fill->getHashCode())
  141
+    		. $this->_title
  142
+    		. var_export($this->_values, true)
  143
+    		. __CLASS__
  144
+    	);
  145
+    }
  146
+
  147
+    /**
  148
+     * Hash index
  149
+     *
  150
+     * @var string
  151
+     */
  152
+    private $_hashIndex;
  153
+
  154
+	/**
  155
+	 * Get hash index
  156
+	 *
  157
+	 * Note that this index may vary during script execution! Only reliable moment is
  158
+	 * while doing a write of a workbook and when changes are not allowed.
  159
+	 *
  160
+	 * @return string	Hash index
  161
+	 */
  162
+	public function getHashIndex() {
  163
+		return $this->_hashIndex;
  164
+	}
  165
+
  166
+	/**
  167
+	 * Set hash index
  168
+	 *
  169
+	 * Note that this index may vary during script execution! Only reliable moment is
  170
+	 * while doing a write of a workbook and when changes are not allowed.
  171
+	 *
  172
+	 * @param string	$value	Hash index
  173
+	 */
  174
+	public function setHashIndex($value) {
  175
+		$this->_hashIndex = $value;
  176
+	}
  177
+
  178
+	/**
  179