|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of PHPPresentation - A pure PHP library for reading and writing |
|
4
|
|
|
* presentations documents. |
|
5
|
|
|
* |
|
6
|
|
|
* PHPPresentation is free software distributed under the terms of the GNU Lesser |
|
7
|
|
|
* General Public License version 3 as published by the Free Software Foundation. |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please read the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. For the full list of |
|
11
|
|
|
* contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. |
|
12
|
|
|
* |
|
13
|
|
|
* @link https://github.com/PHPOffice/PHPPresentation |
|
14
|
|
|
* @copyright 2009-2015 PHPPresentation contributors |
|
15
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
|
16
|
|
|
*/ |
|
17
|
|
|
namespace PhpOffice\PhpPresentation\Slide; |
|
18
|
|
|
|
|
19
|
|
|
use PhpOffice\PhpPresentation\ComparableInterface; |
|
20
|
|
|
use PhpOffice\PhpPresentation\PhpPresentation; |
|
21
|
|
|
use PhpOffice\PhpPresentation\ShapeContainerInterface; |
|
22
|
|
|
use PhpOffice\PhpPresentation\Slide\Background\Color as BackgroundColor; |
|
23
|
|
|
use PhpOffice\PhpPresentation\Style\Color; |
|
24
|
|
|
use PhpOffice\PhpPresentation\Style\ColorMap; |
|
25
|
|
|
use PhpOffice\PhpPresentation\Style\SchemeColor; |
|
26
|
|
|
use PhpOffice\PhpPresentation\Style\TextStyle; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class SlideMaster |
|
30
|
|
|
*/ |
|
31
|
|
|
class SlideMaster extends AbstractSlide implements ComparableInterface, ShapeContainerInterface |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* Collection of Slide objects |
|
35
|
|
|
* |
|
36
|
|
|
* @var \PhpOffice\PhpPresentation\Slide\SlideLayout[] |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $slideLayouts = array(); |
|
39
|
|
|
/** |
|
40
|
|
|
* Mapping of colors to the theme |
|
41
|
|
|
* |
|
42
|
|
|
* @var \PhpOffice\PhpPresentation\Style\ColorMap |
|
43
|
|
|
*/ |
|
44
|
|
|
public $colorMap; |
|
45
|
|
|
/** |
|
46
|
|
|
* @var \PhpOffice\PhpPresentation\Style\TextStyle |
|
47
|
|
|
*/ |
|
48
|
|
|
protected $textStyles; |
|
49
|
|
|
/** |
|
50
|
|
|
* @var \PhpOffice\PhpPresentation\Style\SchemeColor[] |
|
51
|
|
|
*/ |
|
52
|
|
|
protected $arraySchemeColor = array(); |
|
53
|
|
|
/** |
|
54
|
|
|
* @var array |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $defaultSchemeColor = array( |
|
57
|
|
|
'dk1' => '000000', |
|
58
|
|
|
'lt1' => 'FFFFFF', |
|
59
|
|
|
'dk2' => '1F497D', |
|
60
|
|
|
'lt2' => 'EEECE1', |
|
61
|
|
|
'accent1' => '4F81BD', |
|
62
|
|
|
'accent2' => 'C0504D', |
|
63
|
|
|
'accent3' => '9BBB59', |
|
64
|
|
|
'accent4' => '8064A2', |
|
65
|
|
|
'accent5' => '4BACC6', |
|
66
|
|
|
'accent6' => 'F79646', |
|
67
|
|
|
'hlink' => '0000FF', |
|
68
|
|
|
'folHlink' => '800080', |
|
69
|
|
|
); |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Create a new slideMaster |
|
73
|
|
|
* |
|
74
|
|
|
* @param PhpPresentation $pParent |
|
75
|
|
|
*/ |
|
76
|
191 |
|
public function __construct(PhpPresentation $pParent = null) |
|
77
|
|
|
{ |
|
78
|
|
|
// Set parent |
|
79
|
191 |
|
$this->parent = $pParent; |
|
80
|
|
|
// Shape collection |
|
81
|
191 |
|
$this->shapeCollection = new \ArrayObject(); |
|
82
|
|
|
// Set identifier |
|
83
|
191 |
|
$this->identifier = md5(rand(0, 9999) . time()); |
|
84
|
|
|
// Set a basic colorMap |
|
85
|
191 |
|
$this->colorMap = new ColorMap(); |
|
86
|
|
|
// Set a white background |
|
87
|
191 |
|
$this->background = new BackgroundColor(); |
|
88
|
191 |
|
$this->background->setColor(new Color(Color::COLOR_WHITE)); |
|
89
|
|
|
// Set basic textStyles |
|
90
|
191 |
|
$this->textStyles = new TextStyle(true); |
|
91
|
|
|
// Set basic scheme colors |
|
92
|
191 |
|
foreach ($this->defaultSchemeColor as $key => $value) { |
|
93
|
191 |
|
$oSchemeColor = new SchemeColor(); |
|
94
|
191 |
|
$oSchemeColor->setValue($key); |
|
95
|
191 |
|
$oSchemeColor->setRGB($value); |
|
96
|
191 |
|
$this->addSchemeColor($oSchemeColor); |
|
97
|
|
|
} |
|
98
|
191 |
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Create a slideLayout and add it to this presentation |
|
102
|
|
|
* |
|
103
|
|
|
* @return \PhpOffice\PhpPresentation\Slide\SlideLayout |
|
104
|
|
|
*/ |
|
105
|
191 |
|
public function createSlideLayout() |
|
106
|
|
|
{ |
|
107
|
191 |
|
$newSlideLayout = new SlideLayout($this); |
|
108
|
191 |
|
$this->addSlideLayout($newSlideLayout); |
|
109
|
191 |
|
return $newSlideLayout; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Add slideLayout |
|
114
|
|
|
* |
|
115
|
|
|
* @param \PhpOffice\PhpPresentation\Slide\SlideLayout $slideLayout |
|
116
|
|
|
* @throws \Exception |
|
117
|
|
|
* @return \PhpOffice\PhpPresentation\Slide\SlideLayout |
|
118
|
|
|
*/ |
|
119
|
191 |
|
public function addSlideLayout(SlideLayout $slideLayout = null) |
|
120
|
|
|
{ |
|
121
|
191 |
|
$this->slideLayouts[] = $slideLayout; |
|
122
|
191 |
|
return $slideLayout; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @return SlideLayout[] |
|
127
|
|
|
*/ |
|
128
|
98 |
|
public function getAllSlideLayouts() |
|
129
|
|
|
{ |
|
130
|
98 |
|
return $this->slideLayouts; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @return TextStyle |
|
135
|
|
|
*/ |
|
136
|
98 |
|
public function getTextStyles() |
|
137
|
|
|
{ |
|
138
|
98 |
|
return $this->textStyles; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @param TextStyle $textStyle |
|
143
|
|
|
* @return $this |
|
144
|
|
|
*/ |
|
145
|
3 |
|
public function setTextStyles(TextStyle $textStyle) |
|
146
|
|
|
{ |
|
147
|
3 |
|
$this->textStyles = $textStyle; |
|
148
|
3 |
|
return $this; |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* @param SchemeColor $schemeColor |
|
153
|
|
|
* @return $this |
|
154
|
|
|
*/ |
|
155
|
191 |
|
public function addSchemeColor(SchemeColor $schemeColor) |
|
156
|
|
|
{ |
|
157
|
191 |
|
$this->arraySchemeColor[$schemeColor->getValue()] = $schemeColor; |
|
158
|
191 |
|
return $this; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
/** |
|
162
|
|
|
* @return \PhpOffice\PhpPresentation\Style\SchemeColor[] |
|
163
|
|
|
*/ |
|
164
|
95 |
|
public function getAllSchemeColors() |
|
165
|
|
|
{ |
|
166
|
95 |
|
return $this->arraySchemeColor; |
|
167
|
|
|
} |
|
168
|
|
|
} |
|
169
|
|
|
|