Added flushInstance() method to clear the calculation cache, but only if the calculation engine has been instantiated.

Moved precision setting from functions.php to the calculation engine constructor, with a reset when the calculation engine instance is unset... will be of value when I switch the code to support a calculation engine/cache with each instantiated PHPExcel object.

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@67403 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2011-01-25 23:11:32 +00:00
parent 585ee1514e
commit 59e85a379d
2 changed files with 28 additions and 7 deletions

View File

@ -202,6 +202,9 @@ class PHPExcel_Calculation {
public $cyclicFormulaCount = 0;
private $_savedPrecision = 12;
private static $_localeLanguage = 'en_us'; // US English (default locale)
private static $_validLocaleLanguages = array( 'en' // English (default language)
);
@ -1664,7 +1667,7 @@ class PHPExcel_Calculation {
function __construct() {
private function __construct() {
$localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/';
foreach (glob($localeFileDirectory.'/*',GLOB_ONLYDIR) as $filename) {
$filename = substr($filename,strlen($localeFileDirectory)+1);
@ -1672,9 +1675,19 @@ class PHPExcel_Calculation {
self::$_validLocaleLanguages[] = $filename;
}
}
$setPrecision = (PHP_INT_SIZE == 4) ? 12 : 16;
$this->_savedPrecision = ini_get('precision');
if ($savedPrecision < $setPrecision) {
ini_set('precision',$setPrecision);
}
} // function __construct()
public function __destruct() {
ini_set('precision',$this->_savedPrecision);
}
/**
* Get an instance of this class
*
@ -1690,6 +1703,20 @@ class PHPExcel_Calculation {
} // function getInstance()
/**
* Flush the calculation cache for any existing instance of this class
* but only if a PHPExcel_Calculation instance exists
*
* @access public
* @return null
*/
public static function flushInstance() {
if (isset(self::$_instance) && !is_null(self::$_instance)) {
self::$_instance->clearCalculationCache();
}
} // function flushInstance()
/**
* __clone implementation. Cloning should not be allowed in a Singleton!
*

View File

@ -49,12 +49,6 @@ define('MAX_ITERATIONS', 256);
define('PRECISION', 8.88E-016);
$savedPrecision = ini_get('precision');
if ($savedPrecision < 16) {
ini_set('precision',16);
}
/**
* PHPExcel_Calculation_Functions
*