Move UTF-8 StrToUpper(), StrToLower() and StrToTitle() methods from Text Calculation class to Shared String Class

Doc comments for methods in writer abstract
This commit is contained in:
Mark Baker 2012-11-06 22:53:58 +00:00
parent cce77bad0e
commit f3c4d056ed
3 changed files with 55 additions and 16 deletions

View File

@ -440,11 +440,7 @@ class PHPExcel_Calculation_TextData {
$mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
} }
if (function_exists('mb_convert_case')) { return PHPExcel_Shared_String::StrToLower($mixedCaseString);
return mb_convert_case($mixedCaseString, MB_CASE_LOWER, 'UTF-8');
} else {
return strtoupper($mixedCaseString);
}
} // function LOWERCASE() } // function LOWERCASE()
@ -463,11 +459,7 @@ class PHPExcel_Calculation_TextData {
$mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
} }
if (function_exists('mb_convert_case')) { return PHPExcel_Shared_String::StrToUpper($mixedCaseString);
return mb_convert_case($mixedCaseString, MB_CASE_UPPER, 'UTF-8');
} else {
return strtoupper($mixedCaseString);
}
} // function UPPERCASE() } // function UPPERCASE()
@ -486,11 +478,7 @@ class PHPExcel_Calculation_TextData {
$mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE(); $mixedCaseString = ($mixedCaseString) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
} }
if (function_exists('mb_convert_case')) { return PHPExcel_Shared_String::StrToTitle($mixedCaseString);
return mb_convert_case($mixedCaseString, MB_CASE_TITLE, 'UTF-8');
} else {
return ucwords($mixedCaseString);
}
} // function PROPERCASE() } // function PROPERCASE()

View File

@ -583,6 +583,48 @@ class PHPExcel_Shared_String
return substr($pValue, $pStart, $pLength); return substr($pValue, $pStart, $pLength);
} }
/**
* Convert a UTF-8 encoded string to upper case
*
* @param string $pValue UTF-8 encoded string
* @return string
*/
public static function StrToUpper($pValue = '')
{
if (function_exists('mb_convert_case')) {
return mb_convert_case($pValue, MB_CASE_UPPER, "UTF-8");
}
return strtoupper($pValue);
}
/**
* Convert a UTF-8 encoded string to lower case
*
* @param string $pValue UTF-8 encoded string
* @return string
*/
public static function StrToLower($pValue = '')
{
if (function_exists('mb_convert_case')) {
return mb_convert_case($pValue, MB_CASE_LOWER, "UTF-8");
}
return strtolower($pValue);
}
/**
* Convert a UTF-8 encoded string to title/proper case
* (uppercase every first character in each word, lower case all other characters)
*
* @param string $pValue UTF-8 encoded string
* @return string
*/
public static function StrToTitle($pValue = '')
{
if (function_exists('mb_convert_case')) {
return mb_convert_case($pValue, MB_CASE_LOWER, "UTF-8");
}
return ucwords($pValue);
}
/** /**
* Identify whether a string contains a fractional numeric value, * Identify whether a string contains a fractional numeric value,

View File

@ -45,6 +45,8 @@ abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
/** /**
* Pre-calculate formulas * Pre-calculate formulas
* Forces PHPExcel to recalculate all formulae in a workbook when saving, so that the pre-calculated values are
* immediately available to MS Excel or other office spreadsheet viewer when opening the file
* *
* @var boolean * @var boolean
*/ */
@ -89,7 +91,12 @@ abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
} }
/** /**
* Get Pre-Calculate Formulas * Get Pre-Calculate Formulas flag
* If this is true (the default), then the writer will recalculate all formulae in a workbook when saving,
* so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet
* viewer when opening the file
* If false, then formulae are not calculated on save. This is faster for saving in PHPExcel, but slower
* when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself
* *
* @return boolean * @return boolean
*/ */
@ -99,6 +106,8 @@ abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
/** /**
* Set Pre-Calculate Formulas * Set Pre-Calculate Formulas
* Set to true (the default) to advise the Writer to calculate all formulae on save
* Set to false to prevent precalculation of formulae on save.
* *
* @param boolean $pValue Pre-Calculate Formulas? * @param boolean $pValue Pre-Calculate Formulas?
* @return PHPExcel_Writer_IWriter * @return PHPExcel_Writer_IWriter