1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Graze\CiffRenderer\Parser\FieldParser; |
4
|
|
|
|
5
|
|
|
use Graze\CiffRenderer\Parser\FieldParser\FieldParserInterface; |
6
|
|
|
use Graze\CiffRenderer\Parser\FieldParserRegistry; |
7
|
|
|
use \SimpleXMLElement; |
8
|
|
|
|
9
|
|
|
abstract class AbstractFieldParser implements FieldParserInterface |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var FieldParserRegistry |
13
|
|
|
*/ |
14
|
|
|
protected $fieldParserRegistry; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var SimpleXMLElement |
18
|
|
|
*/ |
19
|
|
|
protected $xmlHeader; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var SimpleXMLElement |
23
|
|
|
*/ |
24
|
|
|
protected $xmlField; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var float |
28
|
|
|
*/ |
29
|
|
|
protected $scale; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param FieldParserRegistry $fieldParserRegistry |
33
|
|
|
* @param SimpleXMLElement $xmlHeader |
34
|
|
|
* @param SimpleXMLElement $xmlField |
35
|
|
|
* @param float $scale |
36
|
|
|
*/ |
37
|
58 |
|
public function __construct( |
38
|
|
|
FieldParserRegistry $fieldParserRegistry, |
39
|
|
|
SimpleXMLElement $xmlHeader, |
40
|
|
|
SimpleXMLElement $xmlField, |
41
|
|
|
$scale |
42
|
|
|
) { |
43
|
58 |
|
$this->fieldParserRegistry = $fieldParserRegistry; |
44
|
58 |
|
$this->xmlHeader = $xmlHeader; |
45
|
58 |
|
$this->xmlField = $xmlField; |
46
|
58 |
|
$this->scale = $scale; |
47
|
58 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return string |
51
|
|
|
*/ |
52
|
|
|
public function getFieldType() |
53
|
|
|
{ |
54
|
|
|
return (string) $this->xmlField->FldType; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
6 |
|
public function getFieldName() |
61
|
|
|
{ |
62
|
6 |
|
return (string) $this->xmlField->attributes()->Name; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return int |
67
|
|
|
*/ |
68
|
6 |
|
public function getPositionX() |
69
|
|
|
{ |
70
|
6 |
|
return (int) round($this->xmlField->X * $this->scale); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return int |
75
|
|
|
*/ |
76
|
6 |
|
public function getPositionY() |
77
|
|
|
{ |
78
|
6 |
|
return (int) round($this->xmlField->Y * $this->scale); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return int |
83
|
|
|
*/ |
84
|
6 |
|
public function getWidth() |
85
|
|
|
{ |
86
|
6 |
|
return (int) round($this->xmlField->W * $this->scale); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return int |
91
|
|
|
*/ |
92
|
6 |
|
public function getHeight() |
93
|
|
|
{ |
94
|
6 |
|
return (int) round($this->xmlField->H * $this->scale); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return bool |
99
|
|
|
*/ |
100
|
6 |
|
public function isDisplayed() |
101
|
|
|
{ |
102
|
6 |
|
return (string) $this->xmlField->Displayed != '0'; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return string |
107
|
|
|
*/ |
108
|
|
|
public function getText() |
109
|
|
|
{ |
110
|
|
|
return ''; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return string |
115
|
|
|
*/ |
116
|
|
|
public function getDateFormat() |
117
|
|
|
{ |
118
|
|
|
return ''; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return int |
123
|
|
|
*/ |
124
|
|
|
public function getFontSize() |
125
|
|
|
{ |
126
|
|
|
return (int) 0; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return string |
131
|
|
|
*/ |
132
|
|
|
public function getFontFace() |
133
|
|
|
{ |
134
|
|
|
return ''; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return bool |
139
|
|
|
*/ |
140
|
|
|
public function getIsInverse() |
141
|
|
|
{ |
142
|
|
|
return false; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return int |
147
|
|
|
*/ |
148
|
|
|
public function getOrientation() |
149
|
|
|
{ |
150
|
|
|
return (int) 0; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return string |
155
|
|
|
*/ |
156
|
|
|
public function getShape() |
157
|
|
|
{ |
158
|
|
|
return ''; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @return int |
163
|
|
|
*/ |
164
|
|
|
public function getLineWeight() |
165
|
|
|
{ |
166
|
|
|
return (int) 0; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return string |
171
|
|
|
*/ |
172
|
|
|
public function getGraphic() |
173
|
|
|
{ |
174
|
|
|
return ''; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @return string |
179
|
|
|
*/ |
180
|
|
|
public function getTextAlignment() |
181
|
|
|
{ |
182
|
|
|
return FieldParserFixedText::ALIGN_LEFT; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @param FieldParserRegistry $fieldParserRegistry |
187
|
|
|
* @param SimpleXMLElement $xmlHeader |
188
|
|
|
* @param SimpleXMLElement $xmlField |
189
|
|
|
* @param float $scale |
190
|
|
|
* @return FieldParserInterface |
191
|
|
|
*/ |
192
|
5 |
|
public static function factory( |
193
|
|
|
FieldParserRegistry $fieldParserRegistry, |
194
|
|
|
SimpleXMLElement $xmlHeader, |
195
|
|
|
SimpleXMLElement $xmlField, |
196
|
|
|
$scale |
197
|
|
|
) { |
198
|
5 |
|
return new static( |
199
|
5 |
|
$fieldParserRegistry, |
200
|
|
|
$xmlHeader, |
201
|
|
|
$xmlField, |
202
|
|
|
$scale |
203
|
|
|
); |
204
|
|
|
} |
205
|
|
|
} |
206
|
|
|
|