| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
require_once(HTML2PS_DIR.'value.generic.php');
|
|
|
4 |
|
|
|
5 |
class BorderPDF extends CSSValue {
|
|
|
6 |
var $left;
|
|
|
7 |
var $right;
|
|
|
8 |
var $top;
|
|
|
9 |
var $bottom;
|
|
|
10 |
|
|
|
11 |
function BorderPDF() {
|
|
|
12 |
$this->left =& new EdgePDF();
|
|
|
13 |
$this->right =& new EdgePDF();
|
|
|
14 |
$this->top =& new EdgePDF();
|
|
|
15 |
$this->bottom =& new EdgePDF();
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
function create($data) {
|
|
|
19 |
$border =& new BorderPDF();
|
|
|
20 |
$border->left =& EdgePDF::create($data['left']);
|
|
|
21 |
$border->right =& EdgePDF::create($data['right']);
|
|
|
22 |
$border->top =& EdgePDF::create($data['top']);
|
|
|
23 |
$border->bottom =& EdgePDF::create($data['bottom']);
|
|
|
24 |
return $border;
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* Optimization: note usage of '!=='. It is faster than '!=' in our
|
|
|
29 |
* case (PHP 5.1.1, Win)
|
|
|
30 |
*/
|
|
|
31 |
function ©() {
|
|
|
32 |
$border =& new BorderPDF();
|
|
|
33 |
|
|
|
34 |
if ($this->left !== CSS_PROPERTY_INHERIT) {
|
|
|
35 |
$border->left = $this->left->copy();
|
|
|
36 |
} else {
|
|
|
37 |
$border->left = CSS_PROPERTY_INHERIT;
|
|
|
38 |
};
|
|
|
39 |
|
|
|
40 |
if ($this->right !== CSS_PROPERTY_INHERIT) {
|
|
|
41 |
$border->right = $this->right->copy();
|
|
|
42 |
} else {
|
|
|
43 |
$border->right = CSS_PROPERTY_INHERIT;
|
|
|
44 |
};
|
|
|
45 |
|
|
|
46 |
if ($this->top !== CSS_PROPERTY_INHERIT) {
|
|
|
47 |
$border->top = $this->top->copy();
|
|
|
48 |
} else {
|
|
|
49 |
$border->top = CSS_PROPERTY_INHERIT;
|
|
|
50 |
};
|
|
|
51 |
|
|
|
52 |
if ($this->bottom !== CSS_PROPERTY_INHERIT) {
|
|
|
53 |
$border->bottom = $this->bottom->copy();
|
|
|
54 |
} else {
|
|
|
55 |
$border->bottom = CSS_PROPERTY_INHERIT;
|
|
|
56 |
};
|
|
|
57 |
|
|
|
58 |
return $border;
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
function doInherit(&$state) {
|
|
|
62 |
if ($this->top === CSS_PROPERTY_INHERIT) {
|
|
|
63 |
$value = $state->getInheritedProperty(CSS_BORDER_TOP);
|
|
|
64 |
$this->top = $value->copy();
|
|
|
65 |
};
|
|
|
66 |
|
|
|
67 |
if ($this->right === CSS_PROPERTY_INHERIT) {
|
|
|
68 |
$value = $state->getInheritedProperty(CSS_BORDER_RIGHT);
|
|
|
69 |
$this->right = $value->copy();
|
|
|
70 |
};
|
|
|
71 |
|
|
|
72 |
if ($this->bottom === CSS_PROPERTY_INHERIT) {
|
|
|
73 |
$value = $state->getInheritedProperty(CSS_BORDER_BOTTOM);
|
|
|
74 |
$this->bottom = $value->copy();
|
|
|
75 |
};
|
|
|
76 |
|
|
|
77 |
if ($this->left === CSS_PROPERTY_INHERIT) {
|
|
|
78 |
$value = $state->getInheritedProperty(CSS_BORDER_LEFT);
|
|
|
79 |
$this->left = $value->copy();
|
|
|
80 |
};
|
|
|
81 |
|
|
|
82 |
$this->top->doInherit($state,
|
|
|
83 |
CSS_BORDER_TOP_WIDTH,
|
|
|
84 |
CSS_BORDER_TOP_COLOR,
|
|
|
85 |
CSS_BORDER_TOP_STYLE);
|
|
|
86 |
$this->right->doInherit($state,
|
|
|
87 |
CSS_BORDER_RIGHT_WIDTH,
|
|
|
88 |
CSS_BORDER_RIGHT_COLOR,
|
|
|
89 |
CSS_BORDER_RIGHT_STYLE);
|
|
|
90 |
$this->bottom->doInherit($state,
|
|
|
91 |
CSS_BORDER_BOTTOM_WIDTH,
|
|
|
92 |
CSS_BORDER_BOTTOM_COLOR,
|
|
|
93 |
CSS_BORDER_BOTTOM_STYLE);
|
|
|
94 |
$this->left->doInherit($state,
|
|
|
95 |
CSS_BORDER_LEFT_WIDTH,
|
|
|
96 |
CSS_BORDER_LEFT_COLOR,
|
|
|
97 |
CSS_BORDER_LEFT_STYLE);
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
function &get_bottom() {
|
|
|
101 |
return $this->bottom;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
function &get_left() {
|
|
|
105 |
return $this->left;
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
function &get_right() {
|
|
|
109 |
return $this->right;
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
function &get_top() {
|
|
|
113 |
return $this->top;
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
function is_default() {
|
|
|
117 |
return
|
|
|
118 |
$this->left->style == BS_NONE &&
|
|
|
119 |
$this->right->style == BS_NONE &&
|
|
|
120 |
$this->top->style == BS_NONE &&
|
|
|
121 |
$this->bottom->style == BS_NONE;
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
function show(&$viewport, $box) {
|
|
|
125 |
// Show left border
|
|
|
126 |
if ($this->left->is_visible()) {
|
|
|
127 |
$this->left->show($viewport, $box,
|
|
|
128 |
$box->get_left_border() , $box->get_bottom_border(),
|
|
|
129 |
$box->get_left_border() , $box->get_top_border(),
|
|
|
130 |
$box->get_left_border()+$this->left->get_width(), $box->get_top_border()-$this->top->get_width(),
|
|
|
131 |
$box->get_left_border()+$this->left->get_width(), $box->get_bottom_border()+$this->bottom->get_width(),
|
|
|
132 |
true);
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
// Show right border
|
|
|
136 |
if ($this->right->is_visible()) {
|
|
|
137 |
$this->right->show($viewport, $box,
|
|
|
138 |
$box->get_right_border() , $box->get_bottom_border(),
|
|
|
139 |
$box->get_right_border() , $box->get_top_border(),
|
|
|
140 |
$box->get_right_border()-$this->right->get_width(), $box->get_top_border()-$this->top->get_width(),
|
|
|
141 |
$box->get_right_border()-$this->right->get_width(), $box->get_bottom_border()+$this->bottom->get_width(),
|
|
|
142 |
false);
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
// Show top border
|
|
|
146 |
if ($this->top->is_visible()) {
|
|
|
147 |
$this->top->show($viewport, $box,
|
|
|
148 |
$box->get_left_border() , $box->get_top_border(),
|
|
|
149 |
$box->get_right_border() , $box->get_top_border(),
|
|
|
150 |
$box->get_right_border()-$this->right->get_width() , $box->get_top_border() - $this->top->get_width(),
|
|
|
151 |
$box->get_left_border() +$this->left->get_width() , $box->get_top_border() - $this->top->get_width(),
|
|
|
152 |
true);
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
// Show bottom border
|
|
|
156 |
if ($this->bottom->is_visible()) {
|
|
|
157 |
$this->bottom->show($viewport, $box,
|
|
|
158 |
$box->get_left_border() , $box->get_bottom_border(),
|
|
|
159 |
$box->get_right_border() , $box->get_bottom_border(),
|
|
|
160 |
$box->get_right_border()- $this->right->get_width() , $box->get_bottom_border() + $this->bottom->get_width(),
|
|
|
161 |
$box->get_left_border() + $this->left->get_width() , $box->get_bottom_border() + $this->bottom->get_width(),
|
|
|
162 |
false);
|
|
|
163 |
}
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
function units2pt($base_font_size) {
|
|
|
167 |
$this->left->units2pt($base_font_size);
|
|
|
168 |
$this->right->units2pt($base_font_size);
|
|
|
169 |
$this->top->units2pt($base_font_size);
|
|
|
170 |
$this->bottom->units2pt($base_font_size);
|
|
|
171 |
}
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
?>
|