new methods: setTextRotation() and setStrikeOut(), plus some minor changes
git-svn-id: https://svn.php.net/repository/pear/packages/Spreadsheet_Excel_Writer/trunk@110007 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
50b6b6ade4
commit
6a4986152f
|
|
@ -39,8 +39,56 @@
|
||||||
* @package Spreadsheet_Excel_Writer
|
* @package Spreadsheet_Excel_Writer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Format
|
class Format extends PEAR
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* The index given by the workbook when creating a new format.
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
var $_xf_index;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Height of font (1/20 of a point)
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
var $_size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bold style
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
var $_bold;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bit specifiying if the font is italic.
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
var $_italic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index to the cell's color
|
||||||
|
* @var
|
||||||
|
*/
|
||||||
|
var $_color;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The text underline property
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
var $_underline;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bit specifiying if the font has strikeout.
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
var $_font_strikeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The two bits specifying the text rotation.
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
var $_rotation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
|
@ -50,16 +98,16 @@ class Format
|
||||||
*/
|
*/
|
||||||
function Format($index = 0,$properties = array())
|
function Format($index = 0,$properties = array())
|
||||||
{
|
{
|
||||||
$this->xf_index = $index;
|
$this->_xf_index = $index;
|
||||||
|
|
||||||
$this->font_index = 0;
|
$this->font_index = 0;
|
||||||
$this->font = 'Arial';
|
$this->font = 'Arial';
|
||||||
$this->size = 10;
|
$this->_size = 10;
|
||||||
$this->bold = 0x0190;
|
$this->_bold = 0x0190;
|
||||||
$this->_italic = 0;
|
$this->_italic = 0;
|
||||||
$this->color = 0x7FFF;
|
$this->_color = 0x7FFF;
|
||||||
$this->_underline = 0;
|
$this->_underline = 0;
|
||||||
$this->font_strikeout = 0;
|
$this->_font_strikeout = 0;
|
||||||
$this->font_outline = 0;
|
$this->font_outline = 0;
|
||||||
$this->font_shadow = 0;
|
$this->font_shadow = 0;
|
||||||
$this->font_script = 0;
|
$this->font_script = 0;
|
||||||
|
|
@ -68,14 +116,14 @@ class Format
|
||||||
|
|
||||||
$this->_num_format = 0;
|
$this->_num_format = 0;
|
||||||
|
|
||||||
$this->hidden = 0;
|
$this->_hidden = 0;
|
||||||
$this->locked = 1;
|
$this->_locked = 1;
|
||||||
|
|
||||||
$this->_text_h_align = 0;
|
$this->_text_h_align = 0;
|
||||||
$this->_text_wrap = 0;
|
$this->_text_wrap = 0;
|
||||||
$this->text_v_align = 2;
|
$this->_text_v_align = 2;
|
||||||
$this->text_justlast = 0;
|
$this->_text_justlast = 0;
|
||||||
$this->rotation = 0;
|
$this->_rotation = 0;
|
||||||
|
|
||||||
$this->fg_color = 0x40;
|
$this->fg_color = 0x40;
|
||||||
$this->bg_color = 0x41;
|
$this->bg_color = 0x41;
|
||||||
|
|
@ -117,8 +165,8 @@ class Format
|
||||||
$style = 0xFFF5;
|
$style = 0xFFF5;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$style = $this->locked;
|
$style = $this->_locked;
|
||||||
$style |= $this->hidden << 1;
|
$style |= $this->_hidden << 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flags to indicate if attributes have been set.
|
// Flags to indicate if attributes have been set.
|
||||||
|
|
@ -156,9 +204,9 @@ class Format
|
||||||
|
|
||||||
$align = $this->_text_h_align; // Alignment
|
$align = $this->_text_h_align; // Alignment
|
||||||
$align |= $this->_text_wrap << 3;
|
$align |= $this->_text_wrap << 3;
|
||||||
$align |= $this->text_v_align << 4;
|
$align |= $this->_text_v_align << 4;
|
||||||
$align |= $this->text_justlast << 7;
|
$align |= $this->_text_justlast << 7;
|
||||||
$align |= $this->rotation << 8;
|
$align |= $this->_rotation << 8;
|
||||||
$align |= $atr_num << 10;
|
$align |= $atr_num << 10;
|
||||||
$align |= $atr_fnt << 11;
|
$align |= $atr_fnt << 11;
|
||||||
$align |= $atr_alc << 12;
|
$align |= $atr_alc << 12;
|
||||||
|
|
@ -196,9 +244,9 @@ class Format
|
||||||
*/
|
*/
|
||||||
function getFont()
|
function getFont()
|
||||||
{
|
{
|
||||||
$dyHeight = $this->size * 20; // Height of font (1/20 of a point)
|
$dyHeight = $this->_size * 20; // Height of font (1/20 of a point)
|
||||||
$icv = $this->color; // Index to color palette
|
$icv = $this->_color; // Index to color palette
|
||||||
$bls = $this->bold; // Bold style
|
$bls = $this->_bold; // Bold style
|
||||||
$sss = $this->font_script; // Superscript/subscript
|
$sss = $this->font_script; // Superscript/subscript
|
||||||
$uls = $this->_underline; // Underline
|
$uls = $this->_underline; // Underline
|
||||||
$bFamily = $this->font_family; // Font family
|
$bFamily = $this->font_family; // Font family
|
||||||
|
|
@ -213,7 +261,7 @@ class Format
|
||||||
if ($this->_italic) {
|
if ($this->_italic) {
|
||||||
$grbit |= 0x02;
|
$grbit |= 0x02;
|
||||||
}
|
}
|
||||||
if ($this->font_strikeout) {
|
if ($this->_font_strikeout) {
|
||||||
$grbit |= 0x08;
|
$grbit |= 0x08;
|
||||||
}
|
}
|
||||||
if ($this->font_outline) {
|
if ($this->font_outline) {
|
||||||
|
|
@ -241,11 +289,11 @@ class Format
|
||||||
*/
|
*/
|
||||||
function getFontKey()
|
function getFontKey()
|
||||||
{
|
{
|
||||||
$key = "$this->font$this->size";
|
$key = "$this->font$this->_size";
|
||||||
$key .= "$this->font_script$this->_underline";
|
$key .= "$this->font_script$this->_underline";
|
||||||
$key .= "$this->font_strikeout$this->bold$this->font_outline";
|
$key .= "$this->_font_strikeout$this->_bold$this->font_outline";
|
||||||
$key .= "$this->font_family$this->font_charset";
|
$key .= "$this->font_family$this->font_charset";
|
||||||
$key .= "$this->font_shadow$this->color$this->_italic";
|
$key .= "$this->font_shadow$this->_color$this->_italic";
|
||||||
$key = str_replace(" ","_",$key);
|
$key = str_replace(" ","_",$key);
|
||||||
return ($key);
|
return ($key);
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +305,7 @@ class Format
|
||||||
*/
|
*/
|
||||||
function getXfIndex()
|
function getXfIndex()
|
||||||
{
|
{
|
||||||
return($this->xf_index);
|
return($this->_xf_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -351,17 +399,17 @@ class Format
|
||||||
if ($location == 'equal_space') // For T.K.
|
if ($location == 'equal_space') // For T.K.
|
||||||
$this->_text_h_align = 7;
|
$this->_text_h_align = 7;
|
||||||
if ($location == 'top')
|
if ($location == 'top')
|
||||||
$this->text_v_align = 0;
|
$this->_text_v_align = 0;
|
||||||
if ($location == 'vcentre')
|
if ($location == 'vcentre')
|
||||||
$this->text_v_align = 1;
|
$this->_text_v_align = 1;
|
||||||
if ($location == 'vcenter')
|
if ($location == 'vcenter')
|
||||||
$this->text_v_align = 1;
|
$this->_text_v_align = 1;
|
||||||
if ($location == 'bottom')
|
if ($location == 'bottom')
|
||||||
$this->text_v_align = 2;
|
$this->_text_v_align = 2;
|
||||||
if ($location == 'vjustify')
|
if ($location == 'vjustify')
|
||||||
$this->text_v_align = 3;
|
$this->_text_v_align = 3;
|
||||||
if ($location == 'vequal_space') // For T.K.
|
if ($location == 'vequal_space') // For T.K.
|
||||||
$this->text_v_align = 4;
|
$this->_text_v_align = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -396,7 +444,7 @@ class Format
|
||||||
if($weight > 0x3E8) {
|
if($weight > 0x3E8) {
|
||||||
$weight = 0x190; // Upper bound
|
$weight = 0x190; // Upper bound
|
||||||
}
|
}
|
||||||
$this->bold = $weight;
|
$this->_bold = $weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -565,7 +613,7 @@ class Format
|
||||||
function setColor($color)
|
function setColor($color)
|
||||||
{
|
{
|
||||||
$value = $this->_getColor($color);
|
$value = $this->_getColor($color);
|
||||||
$this->color = $value;
|
$this->_color = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -609,7 +657,7 @@ class Format
|
||||||
*/
|
*/
|
||||||
function setSize($size)
|
function setSize($size)
|
||||||
{
|
{
|
||||||
$this->size = $size;
|
$this->_size = $size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -634,5 +682,49 @@ class Format
|
||||||
{
|
{
|
||||||
$this->_text_wrap = $text_wrap;
|
$this->_text_wrap = $text_wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the orientation of the text
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $angle The rotation angle for the text (clockwise). Possible
|
||||||
|
values are: 0, 90, 270 and -1 for stacking top-to-bottom.
|
||||||
|
*/
|
||||||
|
function setTextRotation($angle)
|
||||||
|
{
|
||||||
|
switch ($angle)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
$this->_rotation = 0;
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
$this->_rotation = 3;
|
||||||
|
break;
|
||||||
|
case 270:
|
||||||
|
$this->_rotation = 2;
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
$this->_rotation = 1;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
$this->raiseError("Invalid value for angle.".
|
||||||
|
" Possible values are: 0, 90, 270 and -1 ".
|
||||||
|
"for stacking top-to-bottom.");
|
||||||
|
$this->_rotation = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets Font Strikeout.
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $strikeout Optional. 0 => no font strikeout, 1 => font strikeout.
|
||||||
|
* Defaults to 1.
|
||||||
|
*/
|
||||||
|
function setStrikeOut($strikeout = 1)
|
||||||
|
{
|
||||||
|
$this->_font_strikeout = $strikeout;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue