150 $this->_isStyleXf =
false;
151 $this->_BIFFVersion = 0x0600;
152 $this->_fontIndex = 0;
154 $this->_numberFormatIndex = 0;
156 $this->_text_justlast = 0;
158 $this->_fg_color = 0x40;
159 $this->_bg_color = 0x41;
163 $this->_bottom_color = 0x40;
164 $this->_top_color = 0x40;
165 $this->_left_color = 0x40;
166 $this->_right_color = 0x40;
167 $this->_diag_color = 0x40;
168 $this->_style = $style;
182 if ($this->_isStyleXf) {
185 $style = $this->
_mapLocked($this->_style->getProtection()->getLocked());
186 $style |= $this->
_mapHidden($this->_style->getProtection()->getHidden()) << 1;
190 $atr_num = ($this->_numberFormatIndex != 0)?1:0;
191 $atr_fnt = ($this->_fontIndex != 0)?1:0;
192 $atr_alc = ((int) $this->_style->getAlignment()->getWrapText())?1:0;
193 $atr_bdr = ($this->
_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) ||
194 $this->
_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) ||
195 $this->
_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) ||
196 $this->
_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0;
197 $atr_pat = (($this->_fg_color != 0x40) ||
198 ($this->_bg_color != 0x41) ||
199 $this->
_mapFillType($this->_style->getFill()->getFillType()))?1:0;
200 $atr_prot = $this->
_mapLocked($this->_style->getProtection()->getLocked())
201 | $this->
_mapHidden($this->_style->getProtection()->getHidden());
204 if ($this->
_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) {
205 $this->_bottom_color = 0;
207 if ($this->
_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) == 0) {
208 $this->_top_color = 0;
210 if ($this->
_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) {
211 $this->_right_color = 0;
213 if ($this->
_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
214 $this->_left_color = 0;
216 if ($this->
_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) == 0) {
217 $this->_diag_color = 0;
221 if ($this->_BIFFVersion == 0x0500) {
224 if ($this->_BIFFVersion == 0x0600) {
230 if ($this->_BIFFVersion == 0x0500) {
231 $align = $this->
_mapHAlign($this->_style->getAlignment()->getHorizontal());
232 $align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
233 $align |= $this->
_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
234 $align |= $this->_text_justlast << 7;
236 $align |= $atr_num << 10;
237 $align |= $atr_fnt << 11;
238 $align |= $atr_alc << 12;
239 $align |= $atr_bdr << 13;
240 $align |= $atr_pat << 14;
241 $align |= $atr_prot << 15;
244 $icv |= $this->_bg_color << 7;
246 $fill = $this->
_mapFillType($this->_style->getFill()->getFillType());
247 $fill |= $this->
_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 6;
248 $fill |= $this->_bottom_color << 9;
250 $border1 = $this->
_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle());
251 $border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) << 3;
252 $border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 6;
253 $border1 |= $this->_top_color << 9;
256 $border2 |= $this->_right_color << 7;
258 $header = pack(
"vv", $record, $length);
259 $data = pack(
"vvvvvvvv", $ifnt, $ifmt, $style, $align,
262 } elseif ($this->_BIFFVersion == 0x0600) {
263 $align = $this->
_mapHAlign($this->_style->getAlignment()->getHorizontal());
264 $align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
265 $align |= $this->
_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
266 $align |= $this->_text_justlast << 7;
268 $used_attrib = $atr_num << 2;
269 $used_attrib |= $atr_fnt << 3;
270 $used_attrib |= $atr_alc << 4;
271 $used_attrib |= $atr_bdr << 5;
272 $used_attrib |= $atr_pat << 6;
273 $used_attrib |= $atr_prot << 7;
276 $icv |= $this->_bg_color << 7;
278 $border1 = $this->
_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle());
279 $border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4;
280 $border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8;
281 $border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
282 $border1 |= $this->_left_color << 16;
283 $border1 |= $this->_right_color << 23;
285 $diagonalDirection = $this->_style->getBorders()->getDiagonalDirection();
290 $border1 |= $diag_tl_to_rb << 30;
291 $border1 |= $diag_tr_to_lb << 31;
294 $border2 |= $this->_bottom_color << 7;
295 $border2 |= $this->_diag_color << 14;
296 $border2 |= $this->
_mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21;
297 $border2 |= $this->
_mapFillType($this->_style->getFill()->getFillType()) << 26;
299 $header = pack(
"vv", $record, $length);
302 $biff8_options = $this->_style->getAlignment()->getIndent();
303 $biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
305 $data = pack(
"vvvC", $ifnt, $ifmt, $style, $align);
311 $data .= pack(
"VVv", $border1, $border2, $icv);
314 return($header .
$data);
324 $this->_BIFFVersion = $BIFFVersion;
334 $this->_isStyleXf = $value;
345 $this->_bottom_color = $colorIndex;
356 $this->_top_color = $colorIndex;
367 $this->_left_color = $colorIndex;
378 $this->_right_color = $colorIndex;
389 $this->_diag_color = $colorIndex;
401 $this->_fg_color = $colorIndex;
412 $this->_bg_color = $colorIndex;
424 $this->_numberFormatIndex = $numberFormatIndex;
434 $this->_fontIndex = $value;
441 switch ($borderStyle) {
456 default:
return 0x00;
486 default:
return 0x00;
532 if ($textRotation >= 0) {
533 return $textRotation;
535 if ($textRotation == -165) {
538 if ($textRotation < 0) {
539 return 90 - $textRotation;