f90e19c3
Andrea Petta
plugin update
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
<?php
/*
PHPRtfLite
Copyright 2007-2008 Denis Slaveckij <sinedas@gmail.com>
Copyright 2010-2012 Steffen Zeidler <sigma_z@sigma-scripts.de>
This file is part of PHPRtfLite.
PHPRtfLite is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PHPRtfLite is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PHPRtfLite. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Class for border format.
* @version 1.2
* @author Denis Slaveckij <sinedas@gmail.com>
* @author Steffen Zeidler <sigma_z@sigma-scripts.de>
* @copyright 2007-2008 Denis Slaveckij, 2010-2012 Steffen Zeidler
* @package PHPRtfLite
* @subpackage PHPRtfLite_Border
*/
class PHPRtfLite_Border_Format
{
/**
* constants for border format type
*/
const TYPE_SINGLE = 'single';
const TYPE_DOT = 'dot';
const TYPE_DASH = 'dash';
const TYPE_DOTDASH = 'dotdash';
/**
* @var integer
*/
protected $_size;
/**
* @var string
*/
protected $_type;
/**
* @var string
*/
protected $_color;
/**
* rtf color table
* @var PHPRtfLite_DocHead_ColorTable
*/
protected $_colorTable;
/**
* @var integer
*/
protected $_space;
/**
* constructor
*
* @param float $size size of border
* @param string $color color of border (example '#ff0000' or '#f00')
* @param string $type represented by class constants PHPRtfLite_Border_Format::TYPE_*<br>
* Possible values:<br>
* TYPE_SINGLE: single (default)<br>
* TYPE_DOT: dot<br>
* TYPE_DASH: dash<br>
* TYPE_DOTDASH: dotdash<br>
* @param float $space space between borders and the paragraph
*/
public function __construct($size = 0.0, $color = null, $type = null, $space = 0.0)
{
$this->_size = round($size * PHPRtfLite::SPACE_IN_POINTS); // convert points to twips
$this->_type = $type;
$this->_color = $color;
$this->_space = PHPRtfLite_Unit::getUnitInTwips($space);
}
/**
* Gets border format type as rtf code
*
* @return string rtf code
*/
private function getTypeAsRtfCode()
{
switch ($this->_type) {
case self::TYPE_DOT:
return '\brdrdot';
case self::TYPE_DASH:
return '\brdrdash';
case self::TYPE_DOTDASH:
return '\brdrdashd';
default:
return '\brdrs';
}
}
/**
* gets border format type
*
* @return string
*/
public function getType()
{
return $this->_type;
}
/**
* gets border color
*
* @return string
*/
public function getColor()
{
return $this->_color;
}
/**
* gets size in twips
*
* @return integer
*/
public function getSize()
{
return $this->_size;
}
/**
* gets border space
*
* @return float
*/
public function getSpace()
{
return $this->_space;
}
/**
* sets rtf color table
*
* @param PHPRtfLite_DocHead_ColorTable $colorTable
*/
public function setColorTable(PHPRtfLite_DocHead_ColorTable $colorTable)
{
if ($this->_color) {
$colorTable->add($this->_color);
}
$this->_colorTable = $colorTable;
}
/**
* gets rtf code
*
* @return string rtf code
*/
public function getContent()
{
$content = ($this->_size > 0 ? $this->getTypeAsRtfCode() : '')
. '\brdrw' . $this->_size
. '\brsp' . $this->_space;
if ($this->_color && $this->_colorTable) {
$colorIndex = $this->_colorTable->getColorIndex($this->_color);
if ($colorIndex !== false) {
$content .= '\brdrcf' . $colorIndex;
}
}
return $content . ' ';
}
}
|