Commit 574063c0 authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

для диаграмм

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@50834 954022d7-b5bf-4e40-9824-e11837661b57
parent 66393e4d
......@@ -782,10 +782,10 @@ function checkTypeCell( val ) {
/** @constructor */
function cBaseOperator( name, priority, argumentCount ) {
this.name = name ? name : "";
this.priority = priority ? priority : 10;
this.priority = priority !== undefined ? priority : 10;
this.type = cElementType.operator;
this.isRightAssociative = false;
this.argumentsCurrent = argumentCount ? argumentCount : 2;
this.argumentsCurrent = argumentCount !== undefined ? argumentCount : 2;
this.value = null;
this.formatType = {
def:-1, //подразумевается формат первой ячейки входящей в формулу.
......@@ -974,9 +974,9 @@ var cFormulaOperators = {
arg0 = arg0.tocNumber();
return this.value = arg0 instanceof cError ? arg0 : new cNumber( -arg0.getValue() )
},
r.toString = function () { // toString function
return '-';
}
r.toString = function () { // toString function
return '-';
}
r.Assemble = function ( arg ) {
return new cString( "-" + arg[0] );
}
......@@ -2259,7 +2259,8 @@ parserFormula.prototype = {
if ( this.isParsed )
return this.isParsed;
/*
Парсер формулы реализует алгоритм перевода инфиксной формы записи выражения в постфиксную или Обратную Польскую Нотацию. Что упрощает вычисление результата формулы.
Парсер формулы реализует алгоритм перевода инфиксной формы записи выражения в постфиксную или Обратную Польскую Нотацию.
Что упрощает вычисление результата формулы.
При разборе формулы важен порядок проверки очередной части выражения на принадлежность тому или иному типу.
*/
var operand_expected = true;
......@@ -2467,6 +2468,7 @@ parserFormula.prototype = {
this.outStack.push( arr );
operand_expected = false;
}
/* Operands*/
else {
var found_operand = null, _3DRefTmp = null;
......@@ -3094,6 +3096,38 @@ parserFormula.prototype = {
this.wb.dependencyFormulas.addEdge( this.ws.Id, this.cellId.replace( /\$/g, "" ), wsR[j].Id, ref._cells.replace( /\$/g, "" ) );
}
}
},
parseDiagramRef: function(){
var operand_expected = true, res = [[]];
while ( this.pCurrPos < this.Formula.length ) {
if ( parserHelp.isComma.call( this, this.Formula, this.pCurrPos ) ) {
if( this.operand_str == ";" ){
res.push([])
}
}
else{
var found_operand = null, _3DRefTmp = null;
if ( (_3DRefTmp = parserHelp.is3DRef.call( this, this.Formula, this.pCurrPos ))[0] ) {
this.is3D = true;
var _wsFrom = _3DRefTmp[1],
_wsTo = ( (_3DRefTmp[2] !== null) && (_3DRefTmp[2] !== undefined) ) ? _3DRefTmp[2] : _wsFrom;
if ( parserHelp.isArea.call( this, this.Formula, this.pCurrPos ) ) {
res[res.length-1].push({sheetNameFrom:_wsFrom, sheetNameTo:_wsTo, ref:this.operand_str.toUpperCase()})
}
else if ( parserHelp.isRef.call( this, this.Formula, this.pCurrPos ) ) {
res[res.length-1].push({sheetNameFrom:_wsFrom, sheetNameTo:_wsTo, ref:this.operand_str.toUpperCase()})
}
}
}
}
return res;
}
}
......@@ -3127,6 +3161,178 @@ function searchRegExp(str, flags){
return new RegExp( vFS + "$", flags ? flags : "i" );
}
/*
Next code take from OpenOffice Source.
*/
var maxGammaArgument = 171.624376956302;
function lcl_Erf0065( x ) {
var pn = [
1.12837916709551256,
1.35894887627277916E-1,
4.03259488531795274E-2,
1.20339380863079457E-3,
6.49254556481904354E-5
],
qn = [
1.00000000000000000,
4.53767041780002545E-1,
8.69936222615385890E-2,
8.49717371168693357E-3,
3.64915280629351082E-4
];
var fPSum = 0.0, fQSum = 0.0, fXPow = 1.0, fVal;
for ( var i = 0; i <= 4; ++i ) {
fPSum += pn[i] * fXPow;
fQSum += qn[i] * fXPow;
fXPow *= x * x;
}
return fVal = x * fPSum / fQSum;
}
/** Approximation algorithm for erfc for 0.65 < x < 6.0. */
function lcl_Erfc0600( x ) {
var fPSum = 0.0,
fQSum = 0.0,
fXPow = 1.0, pn, qn,
fVal;
if ( x < 2.2 ) {
var pn22 = [
9.99999992049799098E-1,
1.33154163936765307,
8.78115804155881782E-1,
3.31899559578213215E-1,
7.14193832506776067E-2,
7.06940843763253131E-3
],
qn22 = [
1.00000000000000000,
2.45992070144245533,
2.65383972869775752,
1.61876655543871376,
5.94651311286481502E-1,
1.26579413030177940E-1,
1.25304936549413393E-2
];
pn = pn22;
qn = qn22;
}
else /* if ( x < 6.0 ) this is true, but the compiler does not know */
{
var pn60 = [
9.99921140009714409E-1,
1.62356584489366647,
1.26739901455873222,
5.81528574177741135E-1,
1.57289620742838702E-1,
2.25716982919217555E-2
],
qn60 = [
1.00000000000000000,
2.75143870676376208,
3.37367334657284535,
2.38574194785344389,
1.05074004614827206,
2.78788439273628983E-1,
4.00072964526861362E-2
];
pn = pn60;
qn = qn60;
}
for ( var i = 0; i < 6; ++i ) {
fPSum += pn[i] * fXPow;
fQSum += qn[i] * fXPow;
fXPow *= x;
}
fQSum += qn[6] * fXPow;
return fVal = Math.exp( -1.0 * x * x ) * fPSum / fQSum;
}
/** Approximation algorithm for erfc for 6.0 < x < 26.54 (but used for all
x > 6.0). */
function lcl_Erfc2654( x ) {
var pn = [
5.64189583547756078E-1,
8.80253746105525775,
3.84683103716117320E1,
4.77209965874436377E1,
8.08040729052301677
],
qn = [
1.00000000000000000,
1.61020914205869003E1,
7.54843505665954743E1,
1.12123870801026015E2,
3.73997570145040850E1
];
var fPSum = 0.0, fQSum = 0.0, fXPow = 1.0, fVal;
for ( var i = 0; i <= 4; ++i ) {
fPSum += pn[i] * fXPow;
fQSum += qn[i] * fXPow;
fXPow /= x * x;
}
return fVal = Math.exp( -1.0 * x * x ) * fPSum / (x * fQSum);
}
function rtl_math_erf( x ) {
if ( x == 0.0 )
return 0.0;
var bNegative = false;
if ( x < 0.0 ) {
x = Math.abs( x );
bNegative = true;
}
var fErf = 1.0;
if ( x < 1.0e-10 )
fErf = parceFloat( x * 1.1283791670955125738961589031215452 );
else if ( x < 0.65 )
fErf = lcl_Erf0065( x );
else
fErf = 1.0 - rtl_math_erfc( x );
if ( bNegative )
fErf *= -1.0;
return fErf;
}
function rtl_math_erfc( x ) {
if ( x == 0.0 )
return 1.0;
var bNegative = false;
if ( x < 0.0 ) {
x = Math.abs( x );
bNegative = true;
}
var fErfc = 0.0;
if ( x >= 0.65 ) {
if ( x < 6.0 )
fErfc = lcl_Erfc0600( x );
else
fErfc = lcl_Erfc2654( x );
}
else
fErfc = 1.0 - rtl_math_erf( x );
if ( bNegative )
fErfc = 2.0 - fErfc;
return fErfc;
}
function integralPhi( x ) { // Using gauss(x)+0.5 has severe cancellation errors for x<-4
return 0.5 * rtl_math_erfc( -x * 0.7071067811865475 ); // * 1/sqrt(2)
}
function phi( x ) {
return 0.39894228040143268 * Math.exp( -(x * x) / 2.0 );
}
......@@ -3342,14 +3548,6 @@ function gaussinv( x ) {
return z;
}
/*
from OpenOffice Source.
\sc\source\core\tool\interpr3.cxx
begin
*/
var maxGammaArgument = 171.624376956302;
function lcl_getLanczosSum( fZ ) {
var num = [
23531376880.41075968857200767445163675473,
......@@ -3438,170 +3636,4 @@ function getLogGamma( fZ ) {
if ( fZ >= 0.5 )
return Math.log( lcl_GetGammaHelper( fZ + 1 ) / fZ );
return lcl_GetLogGammaHelper( fZ + 2 ) - Math.log( fZ + 1 ) - Math.log( fZ );
}
function lcl_Erf0065( x ) {
var pn = [
1.12837916709551256,
1.35894887627277916E-1,
4.03259488531795274E-2,
1.20339380863079457E-3,
6.49254556481904354E-5
],
qn = [
1.00000000000000000,
4.53767041780002545E-1,
8.69936222615385890E-2,
8.49717371168693357E-3,
3.64915280629351082E-4
];
var fPSum = 0.0, fQSum = 0.0, fXPow = 1.0, fVal;
for ( var i = 0; i <= 4; ++i ) {
fPSum += pn[i] * fXPow;
fQSum += qn[i] * fXPow;
fXPow *= x * x;
}
return fVal = x * fPSum / fQSum;
}
/** Approximation algorithm for erfc for 0.65 < x < 6.0. */
function lcl_Erfc0600( x ) {
var fPSum = 0.0,
fQSum = 0.0,
fXPow = 1.0, pn, qn,
fVal;
if ( x < 2.2 ) {
var pn22 = [
9.99999992049799098E-1,
1.33154163936765307,
8.78115804155881782E-1,
3.31899559578213215E-1,
7.14193832506776067E-2,
7.06940843763253131E-3
],
qn22 = [
1.00000000000000000,
2.45992070144245533,
2.65383972869775752,
1.61876655543871376,
5.94651311286481502E-1,
1.26579413030177940E-1,
1.25304936549413393E-2
];
pn = pn22;
qn = qn22;
}
else /* if ( x < 6.0 ) this is true, but the compiler does not know */
{
var pn60 = [
9.99921140009714409E-1,
1.62356584489366647,
1.26739901455873222,
5.81528574177741135E-1,
1.57289620742838702E-1,
2.25716982919217555E-2
],
qn60 = [
1.00000000000000000,
2.75143870676376208,
3.37367334657284535,
2.38574194785344389,
1.05074004614827206,
2.78788439273628983E-1,
4.00072964526861362E-2
];
pn = pn60;
qn = qn60;
}
for ( var i = 0; i < 6; ++i ) {
fPSum += pn[i] * fXPow;
fQSum += qn[i] * fXPow;
fXPow *= x;
}
fQSum += qn[6] * fXPow;
return fVal = Math.exp( -1.0 * x * x ) * fPSum / fQSum;
}
/** Approximation algorithm for erfc for 6.0 < x < 26.54 (but used for all
x > 6.0). */
function lcl_Erfc2654( x ) {
var pn = [
5.64189583547756078E-1,
8.80253746105525775,
3.84683103716117320E1,
4.77209965874436377E1,
8.08040729052301677
],
qn = [
1.00000000000000000,
1.61020914205869003E1,
7.54843505665954743E1,
1.12123870801026015E2,
3.73997570145040850E1
];
var fPSum = 0.0, fQSum = 0.0, fXPow = 1.0, fVal;
for ( var i = 0; i <= 4; ++i ) {
fPSum += pn[i] * fXPow;
fQSum += qn[i] * fXPow;
fXPow /= x * x;
}
return fVal = Math.exp( -1.0 * x * x ) * fPSum / (x * fQSum);
}
function rtl_math_erf( x ) {
if ( x == 0.0 )
return 0.0;
var bNegative = false;
if ( x < 0.0 ) {
x = Math.abs( x );
bNegative = true;
}
var fErf = 1.0;
if ( x < 1.0e-10 )
fErf = parceFloat( x * 1.1283791670955125738961589031215452 );
else if ( x < 0.65 )
fErf = lcl_Erf0065( x );
else
fErf = 1.0 - rtl_math_erfc( x );
if ( bNegative )
fErf *= -1.0;
return fErf;
}
function rtl_math_erfc( x ) {
if ( x == 0.0 )
return 1.0;
var bNegative = false;
if ( x < 0.0 ) {
x = Math.abs( x );
bNegative = true;
}
var fErfc = 0.0;
if ( x >= 0.65 ) {
if ( x < 6.0 )
fErfc = lcl_Erfc0600( x );
else
fErfc = lcl_Erfc2654( x );
}
else
fErfc = 1.0 - rtl_math_erf( x );
if ( bNegative )
fErfc = 2.0 - fErfc;
return fErfc;
}
function integralPhi( x ) { // Using gauss(x)+0.5 has severe cancellation errors for x<-4
return 0.5 * rtl_math_erfc( -x * 0.7071067811865475 ); // * 1/sqrt(2)
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment