Merge pull request #7 from stevleibelt/master

Reverteds protected and private properties to public ones.
This commit is contained in:
Carsten Schmitz 2016-03-16 08:15:02 +01:00
commit 3b766dc161
11 changed files with 233 additions and 163 deletions

View File

@ -55,44 +55,44 @@ class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
* The BIFF/Excel version (5).
* @var integer
*/
protected $BIFF_version = 0x0500;
public $BIFF_version = 0x0500;
/**
* The byte order of this architecture. 0 => little endian, 1 => big endian
* @var integer
*/
protected $byteOrder;
public $byteOrder;
/**
* The string containing the data of the BIFF stream
* @var string
*/
protected $data;
public $data;
/**
* The size of the data in bytes. Should be the same as strlen($this->data)
* @var integer
*/
protected $dataSize;
public $dataSize;
/**
* The maximun length for a BIFF record. See addContinue()
* @var integer
* @see addContinue()
*/
protected $limit;
public $limit;
/**
* The temporary dir for storing the OLE file
* @var string
*/
protected $temporaryDirectory;
public $temporaryDirectory;
/**
* The temporary file for storing the OLE file
* @var string
*/
protected $temporaryFile;
public $temporaryFile;
/**
* Constructor

View File

@ -42,208 +42,215 @@
class Spreadsheet_Excel_Writer_Format extends PEAR
{
/**
* The BIFF version for the workbook
* @var integer
*/
public $_BIFF_version;
/**
* Index to the FONT record.
* @var integer
*/
public $font_index;
/**
* The index given by the workbook when creating a new format.
* @var integer
*/
protected $_xf_index;
/**
* Index to the FONT record.
* @var integer
*/
public $font_index;
public $_xf_index;
/**
* The font name (ASCII).
* @var string
*/
protected $_font_name;
public $_font_name;
/**
* Height of font (1/20 of a point)
* @var integer
*/
protected $_size;
public $_size;
/**
* Bold style
* @var integer
*/
protected $_bold;
public $_bold;
/**
* Bit specifiying if the font is italic.
* @var integer
*/
protected $_italic;
public $_italic;
/**
* Index to the cell's color
* @var integer
*/
protected $_color;
public $_color;
/**
* The text underline property
* @var integer
*/
protected $_underline;
public $_underline;
/**
* Bit specifiying if the font has strikeout.
* @var integer
*/
protected $_font_strikeout;
public $_font_strikeout;
/**
* Bit specifiying if the font has outline.
* @var integer
*/
protected $_font_outline;
public $_font_outline;
/**
* Bit specifiying if the font has shadow.
* @var integer
*/
protected $_font_shadow;
public $_font_shadow;
/**
* 2 bytes specifiying the script type for the font.
* @var integer
*/
protected $_font_script;
public $_font_script;
/**
* Byte specifiying the font family.
* @var integer
*/
protected $_font_family;
public $_font_family;
/**
* Byte specifiying the font charset.
* @var integer
*/
protected $_font_charset;
public $_font_charset;
/**
* An index (2 bytes) to a FORMAT record (number format).
* @var integer
*/
protected $_num_format;
public $_num_format;
/**
* Bit specifying if formulas are hidden.
* @var integer
*/
protected $_hidden;
public $_hidden;
/**
* Bit specifying if the cell is locked.
* @var integer
*/
protected $_locked;
public $_locked;
/**
* The three bits specifying the text horizontal alignment.
* @var integer
*/
protected $_text_h_align;
public $_text_h_align;
/**
* Bit specifying if the text is wrapped at the right border.
* @var integer
*/
protected $_text_wrap;
public $_text_wrap;
/**
* The three bits specifying the text vertical alignment.
* @var integer
*/
protected $_text_v_align;
public $_text_v_align;
/**
* 1 bit, apparently not used.
* @var integer
*/
protected $_text_justlast;
public $_text_justlast;
/**
* The two bits specifying the text rotation.
* @var integer
*/
protected $_rotation;
public $_rotation;
/**
* The cell's foreground color.
* @var integer
*/
protected $_fg_color;
public $_fg_color;
/**
* The cell's background color.
* @var integer
*/
protected $_bg_color;
public $_bg_color;
/**
* The cell's background fill pattern.
* @var integer
*/
protected $_pattern;
public $_pattern;
/**
* Style of the bottom border of the cell
* @var integer
*/
protected $_bottom;
public $_bottom;
/**
* Color of the bottom border of the cell.
* @var integer
*/
protected $_bottom_color;
public $_bottom_color;
/**
* Style of the top border of the cell
* @var integer
*/
protected $_top;
public $_top;
/**
* Color of the top border of the cell.
* @var integer
*/
protected $_top_color;
public $_top_color;
/**
* Style of the left border of the cell
* @var integer
*/
protected $_left;
public $_left;
/**
* Color of the left border of the cell.
* @var integer
*/
protected $_left_color;
public $_left_color;
/**
* Style of the right border of the cell
* @var integer
*/
protected $_right;
public $_right;
/**
* Color of the right border of the cell.
* @var integer
*/
protected $_right_color;
public $_right_color;
/**
* Constructor
*
* @access private
* @param integer $BIFF_version
* @param integer $index the XF index for the format.
* @param array $properties array with properties to be set on initialization.
*/
@ -1096,7 +1103,7 @@ class Spreadsheet_Excel_Writer_Format extends PEAR
* Sets the font family name.
*
* @access public
* @param string $fontfamily The font family name. Possible values are:
* @param string $font_family The font family name. Possible values are:
* 'Times New Roman', 'Arial', 'Courier'.
*/
public function setFontFamily($font_family)

View File

@ -107,65 +107,71 @@ define('SPREADSHEET_EXCEL_WRITER_CONCAT', '&');
class Spreadsheet_Excel_Writer_Parser extends PEAR
{
/**
* The BIFF version for the workbook
* @var integer
*/
public $_BIFF_version;
/**
* The index of the character we are currently looking at
* @var integer
*/
protected $_current_char;
public $_current_char;
/**
* The token we are working on.
* @var string
*/
protected $_current_token;
public $_current_token;
/**
* The formula to parse
* @var string
*/
protected $_formula;
public $_formula;
/**
* @var array
*/
public $_functions;
/**
* The character ahead of the current char
* @var string
*/
protected $_lookahead;
public $_lookahead;
/**
* The parse tree to be generated
* @var string
*/
protected $_parse_tree;
public $_parse_tree;
/**
* The byte order. 1 => big endian, 0 => little endian.
* @var integer
*/
protected $_byte_order;
public $_byte_order;
/**
* Array of external sheets
* @var array
*/
protected $_ext_sheets;
public $_ext_sheets;
/**
* Array of sheet references in the form of REF structures
* @var array
*/
protected $_references;
/**
* The BIFF version for the workbook
* @var integer
*/
protected $_BIFF_version;
public $_references;
/**
* The class constructor
*
* @param integer $byte_order The byte order (Little endian or Big endian) of the architecture
(optional). 1 => big endian, 0 (default) little endian.
* (optional). 1 => big endian, 0 (default) little endian.
* @param integer $biff_version
*/
public function __construct($byte_order, $biff_version)
{
@ -597,6 +603,7 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
*
* @access private
* @param mixed $num an integer or double for conversion to its ptg value
* @return string
*/
protected function _convertNumber($num)
{
@ -660,11 +667,13 @@ class Spreadsheet_Excel_Writer_Parser extends PEAR
}
/**
* Convert an Excel range such as A1:D4 to a ptgRefV.
*
* @access private
* @param string $range An Excel range in the A1:A2 or A1..A2 format.
*/
* Convert an Excel range such as A1:D4 to a ptgRefV.
*
* @access private
* @param string $range An Excel range in the A1:A2 or A1..A2 format.
* @param int $class
* @return array|string
*/
protected function _convertRange2d($range, $class=0)
{

View File

@ -45,25 +45,25 @@ define('OP_LTE', 0x07);
*/
class Spreadsheet_Excel_Writer_Validator
{
protected $_type;
protected $_style;
protected $_fixedList;
protected $_blank;
protected $_incell;
protected $_showprompt;
protected $_showerror;
protected $_title_prompt;
protected $_descr_prompt;
protected $_title_error;
protected $_descr_error;
protected $_operator;
protected $_formula1;
protected $_formula2;
public $_type;
public $_style;
public $_fixedList;
public $_blank;
public $_incell;
public $_showprompt;
public $_showerror;
public $_title_prompt;
public $_descr_prompt;
public $_title_error;
public $_descr_error;
public $_operator;
public $_formula1;
public $_formula2;
/**
* The parser from the workbook. Used to parse validation formulas also
* @var Spreadsheet_Excel_Writer_Parser
*/
protected $_parser;
public $_parser;
public function __construct($parser)
{

View File

@ -51,132 +51,132 @@ class Spreadsheet_Excel_Writer_Workbook extends Spreadsheet_Excel_Writer_BIFFwri
* Filename for the Workbook
* @var string
*/
protected $fileName;
public $fileName;
/**
* Formula parser
* @var object Parser
* @var Spreadsheet_Excel_Writer_Parser
*/
protected $parser;
public $parser;
/**
* Flag for 1904 date system (0 => base date is 1900, 1 => base date is 1904)
* @var integer
*/
protected $flagFor1904;
public $flagFor1904;
/**
* The active worksheet of the workbook (0 indexed)
* @var integer
*/
protected $activeSheet;
public $activeSheet;
/**
* 1st displayed worksheet in the workbook (0 indexed)
* @var integer
*/
protected $firstSheet;
public $firstSheet;
/**
* Number of workbook tabs selected
* @var integer
*/
protected $selectedWorkBook;
public $selectedWorkBook;
/**
* Index for creating adding new formats to the workbook
* @var integer
*/
protected $xf_index;
public $xf_index;
/**
* Flag for preventing close from being called twice.
* @var integer
* @see close()
*/
protected $fileIsClosed;
public $fileIsClosed;
/**
* The BIFF file size for the workbook.
* @var integer
* @see calcSheetOffsets()
*/
protected $biffSize;
public $biffSize;
/**
* The default sheetname for all sheets created.
* @var string
*/
protected $sheetName;
public $sheetName;
/**
* The default XF format.
* @var object Format
* @var Spreadsheet_Excel_Writer_Format
*/
protected $temporaryFormat;
public $temporaryFormat;
/**
* Array containing references to all of this workbook's worksheets
* @var array
*/
protected $workSheet;
public $workSheet;
/**
* Array of sheet names for creating the EXTERNSHEET records
* @var array
*/
protected $sheetNames;
public $sheetNames;
/**
* Array containing references to all of this workbook's formats
* @var array|Spreadsheet_Excel_Writer_Format[]
*/
protected $formats;
public $formats;
/**
* Array containing the colour palette
* @var array
*/
protected $palette;
public $palette;
/**
* The default format for URLs.
* @var object Format
* @var Spreadsheet_Excel_Writer_Format
*/
protected $urlFormat;
public $urlFormat;
/**
* The codepage indicates the text encoding used for strings
* @var integer
*/
protected $codePage;
public $codePage;
/**
* The country code used for localization
* @var integer
*/
protected $countryCode;
public $countryCode;
/**
* number of bytes for size info of strings
* @var integer
*/
protected $stringSizeInfoSize;
public $stringSizeInfoSize;
/** @var int */
protected $totalStringLength;
public $totalStringLength;
/** @var int */
protected $uniqueString;
public $uniqueString;
/** @var array */
protected $tableOfStrings;
public $tableOfStrings;
/** @var int */
protected $stringSizeInfo;
public $stringSizeInfo;
/** @var array */
private $blockSize;
public $blockSize;
/**
* Class constructor

View File

@ -59,319 +59,319 @@ class Spreadsheet_Excel_Writer_Worksheet extends Spreadsheet_Excel_Writer_BIFFwr
/**
* Reference to the (default) Format object for URLs
* @var object Format
* @var Spreadsheet_Excel_Writer_Format
*/
protected $_url_format;
public $_url_format;
/**
* Reference to the parser used for parsing formulas
* @var object Format
* @var Spreadsheet_Excel_Writer_Format
*/
protected $_parser;
public $_parser;
/**
* Filehandle to the temporary file for storing data
* @var resource
*/
protected $_filehandle;
public $_filehandle;
/**
* Boolean indicating if we are using a temporary file for storing data
* @var bool
*/
protected $_using_tmpfile;
public $_using_tmpfile;
/**
* Maximum number of rows for an Excel spreadsheet (BIFF5)
* @var integer
*/
protected $_xls_rowmax;
public $_xls_rowmax;
/**
* Maximum number of columns for an Excel spreadsheet (BIFF5)
* @var integer
*/
protected $_xls_colmax;
public $_xls_colmax;
/**
* Maximum number of characters for a string (LABEL record in BIFF5)
* @var integer
*/
protected $_xls_strmax;
public $_xls_strmax;
/**
* First row for the DIMENSIONS record
* @var integer
* @see _storeDimensions()
*/
protected $_dim_rowmin;
public $_dim_rowmin;
/**
* Last row for the DIMENSIONS record
* @var integer
* @see _storeDimensions()
*/
protected $_dim_rowmax;
public $_dim_rowmax;
/**
* First column for the DIMENSIONS record
* @var integer
* @see _storeDimensions()
*/
protected $_dim_colmin;
public $_dim_colmin;
/**
* Last column for the DIMENSIONS record
* @var integer
* @see _storeDimensions()
*/
protected $_dim_colmax;
public $_dim_colmax;
/**
* Array containing format information for columns
* @var array
*/
protected $_colinfo;
public $_colinfo;
/**
* Array containing the selected area for the worksheet
* @var array
*/
protected $_selection;
public $_selection;
/**
* Array containing the panes for the worksheet
* @var array
*/
protected $_panes;
public $_panes;
/**
* The active pane for the worksheet
* @var integer
*/
protected $_active_pane;
public $_active_pane;
/**
* Bit specifying if panes are frozen
* @var integer
*/
protected $_frozen;
public $_frozen;
/**
* Bit specifying if the worksheet is selected
* @var integer
*/
protected $selected;
public $selected;
/**
* The paper size (for printing) (DOCUMENT!!!)
* @var integer
*/
protected $_paper_size;
public $_paper_size;
/**
* Bit specifying paper orientation (for printing). 0 => landscape, 1 => portrait
* @var integer
*/
protected $_orientation;
public $_orientation;
/**
* The page header caption
* @var string
*/
protected $_header;
public $_header;
/**
* The page footer caption
* @var string
*/
protected $_footer;
public $_footer;
/**
* The horizontal centering value for the page
* @var integer
*/
protected $_hcenter;
public $_hcenter;
/**
* The vertical centering value for the page
* @var integer
*/
protected $_vcenter;
public $_vcenter;
/**
* The margin for the header
* @var float
*/
protected $_margin_head;
public $_margin_head;
/**
* The margin for the footer
* @var float
*/
protected $_margin_foot;
public $_margin_foot;
/**
* The left margin for the worksheet in inches
* @var float
*/
protected $_margin_left;
public $_margin_left;
/**
* The right margin for the worksheet in inches
* @var float
*/
protected $_margin_right;
public $_margin_right;
/**
* The top margin for the worksheet in inches
* @var float
*/
protected $_margin_top;
public $_margin_top;
/**
* The bottom margin for the worksheet in inches
* @var float
*/
protected $_margin_bottom;
public $_margin_bottom;
/**
* First row to reapeat on each printed page
* @var integer
*/
protected $title_rowmin;
public $title_rowmin;
/**
* Last row to reapeat on each printed page
* @var integer
*/
protected $title_rowmax;
public $title_rowmax;
/**
* First column to reapeat on each printed page
* @var integer
*/
protected $title_colmin;
public $title_colmin;
/**
* First row of the area to print
* @var integer
*/
protected $print_rowmin;
public $print_rowmin;
/**
* Last row to of the area to print
* @var integer
*/
protected $print_rowmax;
public $print_rowmax;
/**
* First column of the area to print
* @var integer
*/
protected $print_colmin;
public $print_colmin;
/**
* Last column of the area to print
* @var integer
*/
protected $print_colmax;
public $print_colmax;
/**
* Whether to display RightToLeft.
* @var integer
*/
protected $_Arabic;
public $_Arabic;
/**
* Whether to use outline.
* @var integer
*/
protected $_outline_on;
public $_outline_on;
/**
* Auto outline styles.
* @var bool
*/
protected $_outline_style;
public $_outline_style;
/**
* Whether to have outline summary below.
* @var bool
*/
protected $_outline_below;
public $_outline_below;
/**
* Whether to have outline summary at the right.
* @var bool
*/
protected $_outline_right;
public $_outline_right;
/**
* Outline row level.
* @var integer
*/
protected $_outline_row_level;
public $_outline_row_level;
/**
* Whether to fit to page when printing or not.
* @var bool
*/
protected $_fit_page;
public $_fit_page;
/**
* Number of pages to fit wide
* @var integer
*/
protected $_fit_width;
public $_fit_width;
/**
* Number of pages to fit high
* @var integer
*/
protected $_fit_height;
public $_fit_height;
/**
* Reference to the total number of strings in the workbook
* @var integer
*/
protected $_str_total;
public $_str_total;
/**
* Reference to the number of unique strings in the workbook
* @var integer
*/
protected $_str_unique;
public $_str_unique;
/**
* Reference to the array containing all the unique strings in the workbook
* @var array
*/
protected $_str_table;
public $_str_table;
/**
* Number of merged cell ranges in actual record
* @var int $_merged_cells_counter
*/
protected $_merged_cells_counter = 0;
public $_merged_cells_counter = 0;
/**
* Number of actual mergedcells record
* @var int $_merged_cells_record
*/
protected $_merged_cells_record = 0;
public $_merged_cells_record = 0;
/**
* Merged cell ranges
* @var array
*/
protected $_merged_ranges;
public $_merged_ranges;
/**
* Charset encoding currently used when calling writeString()
* @var string
*/
protected $_input_encoding;
public $_input_encoding;
public $activesheet;

View File

@ -23,7 +23,8 @@
],
"autoload": {
"psr-0": {
"Spreadsheet": "./"
"Spreadsheet": "./",
"Test": "./test"
}
},
"description": "More info available on: http://pear.php.net/package/Spreadsheet_Excel_Writer",

17
phpunit.xml.dist Normal file
View File

@ -0,0 +1,17 @@
<phpunit bootstrap="test/bootstrap.php"
cacheTokens="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false">
<testsuites>
<testsuite name="Test Suite">
<directory>test/</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@ -0,0 +1,17 @@
<?php
/**
* @author stev leibelt <artodeto@bazzline.net>
* @since 2016-01-17
*/
class Test_Spreadsheet_Excel_WriterTestCase extends PHPUnit_Framework_TestCase
{
/**
* @param string $fileName
* @return Spreadsheet_Excel_Writer_Workbook
*/
protected function getNewWorkbook($fileName = 'my_workbook')
{
return new Spreadsheet_Excel_Writer_Workbook($fileName);
}
}

View File

@ -0,0 +1,15 @@
<?php
/**
* @author stev leibelt <artodeto@bazzline.net>
* @since 2016-01-17
*/
class Test_Spreadsheet_Excel_Writer_WorkbookTest extends Test_Spreadsheet_Excel_WriterTestCase
{
public function testSetVersion()
{
$workbook = $this->getNewWorkbook();
$workbook->setVersion(8);
}
}

4
test/bootstrap.php Normal file
View File

@ -0,0 +1,4 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/Test/Spreadsheet/Excel/Writer/Test_Spreadsheet_Excel_WriterTestCase.php'; //@todo fix this