Generate an Excel BIFF XF record (style or cell).
{
if ($this->_isStyleXf) {
$style = 0xFFF5;
} else {
$style = $this->
_mapLocked($this->_style->getProtection()->getLocked());
$style |= $this->
_mapHidden($this->_style->getProtection()->getHidden()) << 1;
}
$atr_num = ($this->_numberFormatIndex != 0)?1:0;
$atr_fnt = ($this->_fontIndex != 0)?1:0;
$atr_alc = ((int) $this->_style->getAlignment()->getWrapText())?1:0;
$atr_bdr = ($this->
_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) ||
$this->
_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) ||
$this->
_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) ||
$this->
_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0;
$atr_pat = (($this->_fg_color != 0x40) ||
($this->_bg_color != 0x41) ||
$this->
_mapFillType($this->_style->getFill()->getFillType()))?1:0;
$atr_prot = $this->
_mapLocked($this->_style->getProtection()->getLocked())
| $this->
_mapHidden($this->_style->getProtection()->getHidden());
if ($this->
_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) == 0) {
$this->_bottom_color = 0;
}
if ($this->
_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) == 0) {
$this->_top_color = 0;
}
if ($this->
_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) == 0) {
$this->_right_color = 0;
}
if ($this->
_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) == 0) {
$this->_left_color = 0;
}
if ($this->_diag == 0) {
$this->_diag_color = 0;
}
$record = 0x00E0;
if ($this->_BIFFVersion == 0x0500) {
$length = 0x0010;
}
if ($this->_BIFFVersion == 0x0600) {
$length = 0x0014;
}
if ($this->_BIFFVersion == 0x0500) {
$align = $this->
_mapHAlign($this->_style->getAlignment()->getHorizontal());
$align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
$align |= $this->
_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
$align |= $this->_text_justlast << 7;
$align |= 0 << 8;
$align |= $atr_num << 10;
$align |= $atr_fnt << 11;
$align |= $atr_alc << 12;
$align |= $atr_bdr << 13;
$align |= $atr_pat << 14;
$align |= $atr_prot << 15;
$icv |= $this->_bg_color << 7;
$fill = $this->
_mapFillType($this->_style->getFill()->getFillType());
$fill |= $this->
_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 6;
$fill |= $this->_bottom_color << 9;
$border1 = $this->
_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle());
$border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) << 3;
$border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 6;
$border1 |= $this->_top_color << 9;
$border2 |= $this->_right_color << 7;
$header = pack("vv", $record, $length);
$data = pack(
"vvvvvvvv", $ifnt, $ifmt, $style, $align,
$icv, $fill,
$border1, $border2);
}
elseif ($this->_BIFFVersion == 0x0600) {
$align = $this->
_mapHAlign($this->_style->getAlignment()->getHorizontal());
$align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
$align |= $this->
_mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
$align |= $this->_text_justlast << 7;
$used_attrib = $atr_num << 2;
$used_attrib |= $atr_fnt << 3;
$used_attrib |= $atr_alc << 4;
$used_attrib |= $atr_bdr << 5;
$used_attrib |= $atr_pat << 6;
$used_attrib |= $atr_prot << 7;
$icv |= $this->_bg_color << 7;
$border1 = $this->
_mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle());
$border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4;
$border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8;
$border1 |= $this->
_mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
$border1 |= $this->_left_color << 16;
$border1 |= $this->_right_color << 23;
$diag_tl_to_rb = 0;
$diag_tr_to_lb = 0;
$border1 |= $diag_tl_to_rb << 30;
$border1 |= $diag_tr_to_lb << 31;
$border2 |= $this->_bottom_color << 7;
$border2 |= $this->_diag_color << 14;
$border2 |= $this->_diag << 21;
$border2 |= $this->
_mapFillType($this->_style->getFill()->getFillType()) << 26;
$header = pack("vv", $record, $length);
$biff8_options = $this->_style->getAlignment()->getIndent();
$biff8_options |= (int) $this->_style->getAlignment()->getShrinkToFit() << 4;
$data = pack(
"vvvC", $ifnt, $ifmt, $style, $align);
, $biff8_options
, $used_attrib
);
$data .= pack(
"VVv", $border1, $border2, $icv);
}
}