Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
92ddbb5e
Commit
92ddbb5e
authored
Jul 06, 2017
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring bool values in formulas
parent
fb1a6397
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
82 deletions
+37
-82
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+6
-10
cell/model/WorkbookElems.js
cell/model/WorkbookElems.js
+10
-12
cell/view/WorkbookView.js
cell/view/WorkbookView.js
+1
-1
common/editorscommon.js
common/editorscommon.js
+20
-59
No files found.
cell/model/FormulaObjects/parserFormula.js
View file @
92ddbb5e
...
...
@@ -751,7 +751,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cString
.
prototype
.
tocBool
=
function
()
{
var
res
;
if
(
parserHelp
.
isBoolean
(
this
.
value
,
0
))
{
res
=
new
cBool
(
parserHelp
.
operand_str
.
toUpperCase
()
===
cBoolLocal
[
"
t
"
].
toUpperCase
()
);
res
=
new
cBool
(
parserHelp
.
operand_str
.
toUpperCase
()
===
cBoolLocal
.
t
);
}
else
{
res
=
this
;
}
...
...
@@ -769,7 +769,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
var
v
=
false
;
switch
(
val
.
toString
().
toUpperCase
())
{
case
"
TRUE
"
:
case
cBoolLocal
[
"
t
"
].
toUpperCase
()
:
case
cBoolLocal
.
t
:
v
=
true
;
}
cBaseType
.
call
(
this
,
v
);
...
...
@@ -791,7 +791,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
return
new
cString
(
this
.
value
?
"
TRUE
"
:
"
FALSE
"
);
};
cBool
.
prototype
.
toLocaleString
=
function
()
{
return
new
cString
(
this
.
value
?
cBoolLocal
[
"
t
"
].
toUpperCase
()
:
cBoolLocal
[
"
f
"
].
toUpperCase
()
);
return
new
cString
(
this
.
value
?
cBoolLocal
.
t
:
cBoolLocal
.
f
);
};
cBool
.
prototype
.
tocBool
=
function
()
{
return
this
;
...
...
@@ -881,10 +881,9 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cError
.
prototype
=
Object
.
create
(
cBaseType
.
prototype
);
cError
.
prototype
.
constructor
=
cError
;
cError
.
prototype
.
type
=
cElementType
.
error
;
cError
.
prototype
.
tocNumber
=
cError
.
prototype
.
tocString
=
cError
.
prototype
.
tocBool
=
cError
.
prototype
.
tocEmpty
=
function
()
{
return
this
;
};
cError
.
prototype
.
tocNumber
=
cError
.
prototype
.
tocString
=
cError
.
prototype
.
tocBool
=
function
()
{
return
this
;
};
cError
.
prototype
.
toLocaleString
=
function
()
{
switch
(
this
.
value
)
{
case
cErrorOrigin
[
"
value
"
]:
...
...
@@ -941,9 +940,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
}
return
cErrorLocal
[
"
na
"
];
};
/*cError.prototype.toString = function () {
return new cString( this.value ? cBoolLocal["t"].toUpperCase() : cBoolLocal["f"].toUpperCase() );
};*/
/**
* @constructor
...
...
cell/model/WorkbookElems.js
View file @
92ddbb5e
...
...
@@ -3092,8 +3092,8 @@ CCellValue.prototype =
var
sResult
=
""
;
if
(
null
!=
this
.
number
)
{
if
(
CellValueType
.
Bool
==
this
.
type
)
sResult
=
this
.
number
==
1
?
cBoolLocal
[
"
t
"
].
toUpperCase
()
:
cBoolLocal
[
"
f
"
].
toUpperCase
()
;
if
(
CellValueType
.
Bool
==
=
this
.
type
)
sResult
=
this
.
number
==
1
?
cBoolLocal
.
t
:
cBoolLocal
.
f
;
else
sResult
=
this
.
number
.
toString
();
}
...
...
@@ -3256,11 +3256,11 @@ CCellValue.prototype =
}
}
}
}
else
if
(
CellValueType
.
Bool
==
this
.
type
)
{
}
else
if
(
CellValueType
.
Bool
==
=
this
.
type
)
{
if
(
null
!=
this
.
number
)
{
sText
=
(
0
!=
this
.
number
)
?
cBoolLocal
[
"
t
"
].
toUpperCase
()
:
cBoolLocal
[
"
f
"
].
toUpperCase
()
;
sText
=
(
0
!=
this
.
number
)
?
cBoolLocal
.
t
:
cBoolLocal
.
f
;
}
}
else
if
(
CellValueType
.
Error
==
this
.
type
)
{
}
else
if
(
CellValueType
.
Error
==
=
this
.
type
)
{
if
(
null
!=
this
.
text
)
{
sText
=
this
.
_getValueTypeError
(
this
.
text
);
}
...
...
@@ -3299,13 +3299,13 @@ CCellValue.prototype =
{
if
(
null
!=
this
.
text
||
null
!=
this
.
number
)
{
if
(
CellValueType
.
Bool
==
this
.
type
&&
null
!=
this
.
number
)
oValueText
=
(
this
.
number
==
1
)
?
cBoolLocal
[
"
t
"
].
toUpperCase
()
:
cBoolLocal
[
"
f
"
].
toUpperCase
()
;
if
(
CellValueType
.
Bool
==
=
this
.
type
&&
null
!=
this
.
number
)
oValueText
=
(
this
.
number
==
1
)
?
cBoolLocal
.
t
:
cBoolLocal
.
f
;
else
{
if
(
null
!=
this
.
text
)
oValueText
=
this
.
text
;
if
(
CellValueType
.
Number
==
this
.
type
||
CellValueType
.
String
==
this
.
type
)
if
(
CellValueType
.
Number
==
=
this
.
type
||
CellValueType
.
String
=
==
this
.
type
)
{
var
oNumFormat
;
if
(
null
!=
xfs
&&
null
!=
xfs
.
num
)
...
...
@@ -3511,13 +3511,11 @@ CCellValue.prototype =
else
{
var
sUpText
=
val
.
toUpperCase
();
if
(
cBoolLocal
[
"
t
"
].
toUpperCase
()
==
sUpText
||
cBoolLocal
[
"
f
"
].
toUpperCase
()
==
sUpText
)
if
(
cBoolLocal
.
t
===
sUpText
||
cBoolLocal
.
f
=
==
sUpText
)
{
this
.
type
=
CellValueType
.
Bool
;
this
.
number
=
(
cBoolLocal
[
"
t
"
].
toUpperCase
()
==
sUpText
)
?
1
:
0
;
this
.
number
=
(
cBoolLocal
.
t
=
==
sUpText
)
?
1
:
0
;
}
// else if( "#NULL!" == sUpText || "#DIV/0!" == sUpText || "#NAME?" == sUpText || "#NUM!" == sUpText ||
// "#N/A" == sUpText || "#REF!" == sUpText || "#VALUE!" == sUpText )
else
if
(
checkCellValueTypeError
(
sUpText
))
{
this
.
type
=
CellValueType
.
Error
;
...
...
cell/view/WorkbookView.js
View file @
92ddbb5e
...
...
@@ -2615,7 +2615,7 @@
for
(
var
f
in
oFormulaList
)
{
this
.
formulasList
.
push
(
f
);
}
this
.
arrExcludeFormulas
=
[
cBoolLocal
[
"
t
"
].
toUpperCase
(),
cBoolLocal
[
"
f
"
].
toUpperCase
()
];
this
.
arrExcludeFormulas
=
[
cBoolLocal
.
t
,
cBoolLocal
.
f
];
};
WorkbookView
.
prototype
.
_setHintsProps
=
function
(
bIsHinting
,
bIsSubpixHinting
)
{
...
...
common/editorscommon.js
View file @
92ddbb5e
...
...
@@ -792,25 +792,26 @@
columns
:
6
};
var
cStrucTableLocalColumns
=
null
,
cBoolLocal
=
{},
cErrorOrigin
=
{
"
nil
"
:
"
#NULL!
"
,
"
div
"
:
"
#DIV
\
/0!
"
,
"
value
"
:
"
#VALUE!
"
,
"
ref
"
:
"
#REF!
"
,
"
name
"
:
"
#NAME?
"
,
"
num
"
:
"
#NUM!
"
,
"
na
"
:
"
#N
\
/A
"
,
"
getdata
"
:
"
#GETTING_DATA
"
,
"
uf
"
:
"
#UNSUPPORTED_FUNCTION!
"
},
cErrorLocal
=
{};
var
cStrucTableLocalColumns
=
null
;
var
cBoolOrigin
=
{
'
t
'
:
'
TRUE
'
,
'
f
'
:
'
FALSE
'
};
var
cBoolLocal
=
{};
var
cErrorOrigin
=
{
"
nil
"
:
"
#NULL!
"
,
"
div
"
:
"
#DIV
\
/0!
"
,
"
value
"
:
"
#VALUE!
"
,
"
ref
"
:
"
#REF!
"
,
"
name
"
:
"
#NAME?
"
,
"
num
"
:
"
#NUM!
"
,
"
na
"
:
"
#N
\
/A
"
,
"
getdata
"
:
"
#GETTING_DATA
"
,
"
uf
"
:
"
#UNSUPPORTED_FUNCTION!
"
};
var
cErrorLocal
=
{};
function
build_local_rx
(
data
)
{
rx_table_local
=
build_rx_table
(
data
?
data
[
"
StructureTables
"
]
:
null
);
rx_bool_local
=
build_rx_bool
(
data
?
data
[
"
CONST_TRUE_FALSE
"
]
:
null
);
rx_bool_local
=
build_rx_bool
(
(
data
&&
data
[
"
CONST_TRUE_FALSE
"
])
||
cBoolOrigin
);
rx_error_local
=
build_rx_error
(
data
?
data
[
"
CONST_ERROR
"
]
:
null
);
}
...
...
@@ -858,12 +859,9 @@
function
build_rx_bool
(
local
)
{
// ToDo переделать на более правильную реализацию. Не особо правильное копирование
local
=
local
?
local
:
{
"
t
"
:
"
TRUE
"
,
"
f
"
:
"
FALSE
"
};
var
t
=
cBoolLocal
[
'
t
'
]
=
local
[
'
t
'
];
var
f
=
cBoolLocal
[
'
f
'
]
=
local
[
'
f
'
];
var
t
=
cBoolLocal
.
t
=
local
[
'
t
'
].
toUpperCase
();
var
f
=
cBoolLocal
.
f
=
local
[
'
f
'
].
toUpperCase
();
build_rx_array_local
(
local
);
return
new
RegExp
(
"
^(
"
+
t
+
"
|
"
+
f
+
"
)([-+*
\\
/^&%<=>: ;),]|$)
"
,
"
i
"
);
}
...
...
@@ -902,20 +900,6 @@
cErrorLocal
[
"
uf
"
]
+
"
)
"
,
"
i
"
);
}
function
build_rx_array_local
(
localBool
,
digitSepar
,
localError
)
{
var
localBool
=
(
localBool
?
localBool
:
{
"
t
"
:
"
TRUE
"
,
"
f
"
:
"
FALSE
"
}
);
rx_array_local
=
build_rx_array
(
localBool
,
digitSepar
,
localError
);
}
function
build_rx_array
(
localBool
,
digitSepar
,
localError
)
{
return
new
RegExp
(
"
^
\\
{(([+-]?
\\
d*(
\\
d|
\\
"
+
digitSepar
+
"
)
\\
d*([eE][+-]?
\\
d+)?)?(
\"
((
\"\"
|[^
\"
])*)
\"
)?
"
+
"
(#NULL!|#DIV
\
/0!|#VALUE!|#REF!|#NAME
\\
?|#NUM!|#UNSUPPORTED_FUNCTION!|#N
\
/A|#GETTING_DATA|
"
+
localBool
[
"
t
"
]
+
"
|
"
+
localBool
[
"
f
"
]
+
"
)?[
"
+
FormulaSeparators
.
arrayRowSeparator
+
"
\\
"
+
FormulaSeparators
.
arrayColSeparator
+
"
]?)*
\\
}
"
,
"
i
"
);
}
var
PostMessageType
=
{
UploadImage
:
0
,
ExtensionExist
:
1
...
...
@@ -1416,7 +1400,7 @@
rx_error
=
build_rx_error
(
null
),
rx_error_local
=
build_rx_error
(
null
),
rx_bool
=
build_rx_bool
(
null
),
rx_bool
=
build_rx_bool
(
cBoolOrigin
),
rx_bool_local
=
rx_bool
,
rx_string
=
/^
\"((\"\"
|
[^\"])
*
)\"
/
,
rx_test_ws_name
=
new
test_ws_name2
(),
...
...
@@ -1430,9 +1414,6 @@
rx_numberDef
=
/^ *
[
+-
]?\d
*
(\d
|
\.)\d
*
([
eE
][
+-
]?\d
+
)?
/
,
rx_CommaDef
=
/^ *
[
,;
]
*/
,
rx_array_local
=
/^
\{(([
+-
]?\d
*
(\d
|
\.)\d
*
([
eE
][
+-
]?\d
+
)?)?(\"((\"\"
|
[^\"])
*
)\")?(
#NULL!|#DIV
\/
0!|#VALUE!|#REF!|#NAME
\?
|#NUM!|#UNSUPPORTED_FUNCTION!|#N
\/
A|#GETTING_DATA|FALSE|TRUE
)?[
,;
]?)
*
\}
/i
,
rx_array
=
/^
\{(([
+-
]?\d
*
(\d
|
\.)\d
*
([
eE
][
+-
]?\d
+
)?)?(\"((\"\"
|
[^\"])
*
)\")?(
#NULL!|#DIV
\/
0!|#VALUE!|#REF!|#NAME
\?
|#NUM!|#UNSUPPORTED_FUNCTION!|#N
\/
A|#GETTING_DATA|FALSE|TRUE
)?[
,;
]?)
*
\}
/i
,
rx_ControlSymbols
=
/^ *
[\u
0000-
\u
001F
\u
007F-
\u
009F
]
*/
,
emailRe
=
/^
(
mailto:
)?([
a-z0-9'
\.
_-
]
+@
[
a-z0-9
\.
-
]
+
\.[
a-z0-9
]{2,4})([
a-яё0-9
\.
_%+-=
\?
:&
]
*
)
/i
,
...
...
@@ -1866,7 +1847,7 @@
if
(
match
!=
null
)
{
var
name
=
match
[
"
name
"
];
if
(
name
&&
name
.
length
!=
0
&&
name
!=
cBoolLocal
[
"
t
"
]
&&
name
!=
cBoolLocal
[
"
f
"
]
/*&& wb.DefinedNames && wb.isDefinedNamesExists( name, ws ? ws.getId() : null )*/
)
if
(
name
&&
0
!==
name
.
length
&&
name
.
toUpperCase
()
!==
cBoolLocal
.
t
&&
name
.
toUpperCase
()
!==
cBoolLocal
.
f
/*&& wb.DefinedNames && wb.isDefinedNamesExists( name, ws ? ws.getId() : null )*/
)
{
this
.
pCurrPos
+=
name
.
length
;
this
.
operand_str
=
name
;
...
...
@@ -1876,24 +1857,6 @@
}
return
[
false
];
};
parserHelper
.
prototype
.
isArray
=
function
(
formula
,
start_pos
,
digitDelim
)
{
if
(
this
instanceof
parserHelper
)
{
this
.
_reset
();
}
var
match
=
(
formula
.
substring
(
start_pos
)).
match
(
digitDelim
?
rx_array_local
:
rx_array
);
if
(
match
!=
null
)
{
this
.
operand_str
=
match
[
0
].
substring
(
1
,
match
[
0
].
length
-
1
);
this
.
pCurrPos
+=
match
[
0
].
length
;
return
true
;
}
return
false
;
};
parserHelper
.
prototype
.
isLeftBrace
=
function
(
formula
,
start_pos
)
{
if
(
this
instanceof
parserHelper
)
...
...
@@ -2140,7 +2103,6 @@
FormulaSeparators
.
functionArgumentSeparator
=
"
;
"
;
rx_number
=
new
RegExp
(
"
^ *[+-]?
\\
d*(
\\
d|
\\
"
+
FormulaSeparators
.
digitSeparator
+
"
)
\\
d*([eE][+-]?
\\
d+)?
"
);
rx_Comma
=
new
RegExp
(
"
^ *[
"
+
FormulaSeparators
.
functionArgumentSeparator
+
"
] *
"
);
// build_rx_array_local( cBoolLocal, digitSeparator, null);
rx_arraySeparators
=
new
RegExp
(
"
^ *[
"
+
FormulaSeparators
.
arrayRowSeparator
+
"
\\
"
+
FormulaSeparators
.
arrayColSeparator
+
"
] *
"
);
}
else
...
...
@@ -2151,7 +2113,6 @@
FormulaSeparators
.
functionArgumentSeparator
=
FormulaSeparators
.
functionArgumentSeparatorDef
;
rx_number
=
new
RegExp
(
"
^ *[+-]?
\\
d*(
\\
d|
\\
"
+
FormulaSeparators
.
digitSeparatorDef
+
"
)
\\
d*([eE][+-]?
\\
d+)?
"
);
rx_Comma
=
new
RegExp
(
"
^ *[
"
+
FormulaSeparators
.
functionArgumentSeparatorDef
+
"
] *
"
);
// build_rx_array_local( cBoolLocal, digitSeparatorDef, null);
rx_arraySeparators
=
new
RegExp
(
"
^ *[
"
+
FormulaSeparators
.
arrayRowSeparatorDef
+
"
\\
"
+
FormulaSeparators
.
arrayColSeparatorDef
+
"
] *
"
);
}
rx_table_local
=
build_rx_table_cur
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment