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
bdc4855b
Commit
bdc4855b
authored
Jan 13, 2017
by
konovalovsergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asc_getLocaleExample2 for cell
parent
e0543f5a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
136 additions
and
113 deletions
+136
-113
cell/api.js
cell/api.js
+15
-3
cell/model/Workbook.js
cell/model/Workbook.js
+4
-0
cell/model/WorkbookElems.js
cell/model/WorkbookElems.js
+117
-110
No files found.
cell/api.js
View file @
bdc4855b
...
...
@@ -236,11 +236,23 @@ var editor;
}
return
res
;
};
spreadsheet_api
.
prototype
.
asc_getLocaleExample2
=
function
(
format
,
value
,
culture
)
{
spreadsheet_api
.
prototype
.
asc_getLocaleExample2
=
function
(
format
,
value
,
culture
)
{
var
cultureInfo
=
AscCommon
.
g_aCultureInfos
[
culture
]
||
AscCommon
.
g_oDefaultCultureInfo
;
var
numFormat
=
AscCommon
.
oNumFormatCache
.
get
(
format
);
value
=
(
null
==
value
)
?
this
.
wb
.
getSelectionInfo
().
asc_getFormula
()
:
value
;
return
numFormat
.
formatToChart
(
value
,
cultureInfo
);
var
res
;
if
(
null
==
value
)
{
var
ws
=
this
.
wbModel
.
getActiveWs
();
var
activeCell
=
ws
.
selectionRange
.
activeCell
;
var
cell
=
ws
.
_getCellNoEmpty
(
activeCell
.
row
,
activeCell
.
col
);
if
(
cell
)
{
res
=
cell
.
getValueForExample
(
numFormat
,
cultureInfo
);
}
else
{
res
=
''
;
}
}
else
{
res
=
numFormat
.
formatToChart
(
value
,
cultureInfo
);
}
return
res
;
};
spreadsheet_api
.
prototype
.
asc_getFormatCells
=
function
(
info
)
{
...
...
cell/model/Workbook.js
View file @
bdc4855b
...
...
@@ -5084,6 +5084,10 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
this
.
_checkDirty
();
return
this
.
oValue
.
getValueForEdit2
(
this
);
};
Cell
.
prototype
.
getValueForExample
=
function
(
numFormat
,
cultureInfo
){
this
.
_checkDirty
();
return
this
.
oValue
.
getValueForExample
(
this
,
AscCommon
.
gc_nMaxDigCountView
,
function
(){
return
true
;},
numFormat
,
cultureInfo
);
};
Cell
.
prototype
.
getValueWithoutFormat
=
function
(){
this
.
_checkDirty
();
return
this
.
oValue
.
getValueWithoutFormat
();
...
...
cell/model/WorkbookElems.js
View file @
bdc4855b
...
...
@@ -3139,16 +3139,20 @@ CCellValue.prototype =
if
(
null
==
this
.
textValue
)
{
this
.
getValue2
(
cell
,
gc_nMaxDigCountView
,
function
(){
return
true
;});
this
.
textValue
=
""
;
var
aText
=
this
.
aTextValue2
[
gc_nMaxDigCountView
];
for
(
var
i
=
0
,
length
=
aText
.
length
;
i
<
length
;
++
i
)
{
if
(
aText
[
i
].
format
&&
aText
[
i
].
format
.
getSkip
()
==
false
)
this
.
textValue
+=
aText
[
i
].
text
;
}
this
.
textValue
=
this
.
_textArrayToString
(
this
.
aTextValue2
[
gc_nMaxDigCountView
]);
}
return
this
.
textValue
;
},
_textArrayToString
:
function
(
aText
)
{
var
res
=
''
;
for
(
var
i
=
0
,
length
=
aText
.
length
;
i
<
length
;
++
i
)
{
var
elem
=
aText
[
i
];
if
(
elem
.
format
&&
elem
.
format
.
getSkip
()
==
false
)
{
res
+=
elem
.
text
;
}
}
return
res
;
},
getValueForEdit
:
function
(
cell
)
{
if
(
null
==
this
.
textValueForEdit
)
...
...
@@ -3170,73 +3174,88 @@ CCellValue.prototype =
aRes
=
this
.
aTextValue2
[
dDigitsCount
];
if
(
null
==
aRes
)
{
aRes
=
this
.
_getValue2
(
cell
,
dDigitsCount
,
fIsFitMeasurer
);
var
formula
=
cell
.
getFormula
();
if
(
formula
){
aRes
[
0
].
sFormula
=
formula
;
aRes
[
0
].
sId
=
cell
.
getName
();
}
this
.
aTextValue2
[
dDigitsCount
]
=
aRes
;
}
return
aRes
;
},
getValueForExample
:
function
(
cell
,
dDigitsCount
,
fIsFitMeasurer
,
numFormat
,
cultureInfo
)
{
var
aText
=
this
.
_getValue2
(
cell
,
dDigitsCount
,
fIsFitMeasurer
,
numFormat
,
cultureInfo
);
return
this
.
_textArrayToString
(
aText
);
},
_getValue2
:
function
(
cell
,
dDigitsCount
,
fIsFitMeasurer
,
opt_numFormat
,
opt_cultureInfo
)
{
var
aRes
=
null
;
var
bNeedMeasure
=
true
;
var
sText
=
null
;
var
aText
=
null
;
if
(
CellValueType
.
Number
==
this
.
type
||
CellValueType
.
String
==
this
.
type
)
{
if
(
null
!=
this
.
text
)
if
(
CellValueType
.
Number
==
this
.
type
||
CellValueType
.
String
==
this
.
type
)
{
if
(
null
!=
this
.
text
)
{
sText
=
this
.
text
;
else
if
(
null
!=
this
.
multiText
)
}
else
if
(
null
!=
this
.
multiText
)
{
aText
=
this
.
multiText
;
}
if
(
CellValueType
.
String
==
this
.
type
)
if
(
CellValueType
.
String
==
this
.
type
)
{
bNeedMeasure
=
false
;
}
var
oNumFormat
;
if
(
opt_numFormat
)
{
oNumFormat
=
opt_numFormat
;
}
else
{
var
xfs
=
cell
.
getCompiledStyle
();
if
(
null
!=
xfs
&&
null
!=
xfs
.
num
)
if
(
null
!=
xfs
&&
null
!=
xfs
.
num
)
{
oNumFormat
=
oNumFormatCache
.
get
(
xfs
.
num
.
getFormat
());
else
}
else
{
oNumFormat
=
oNumFormatCache
.
get
(
g_oDefaultFormat
.
Num
.
getFormat
());
if
(
false
==
oNumFormat
.
isGeneralFormat
())
{
if
(
null
!=
this
.
number
)
{
aText
=
oNumFormat
.
format
(
this
.
number
,
this
.
type
,
dDigitsCount
);
sText
=
null
;
}
else
if
(
CellValueType
.
String
==
this
.
type
)
{
}
if
(
false
==
oNumFormat
.
isGeneralFormat
())
{
if
(
null
!=
this
.
number
)
{
aText
=
oNumFormat
.
format
(
this
.
number
,
this
.
type
,
dDigitsCount
,
false
,
opt_cultureInfo
);
sText
=
null
;
}
else
if
(
CellValueType
.
String
==
this
.
type
)
{
var
oTextFormat
=
oNumFormat
.
getTextFormat
();
if
(
null
!=
oTextFormat
&&
"
@
"
!=
oTextFormat
.
formatString
)
{
if
(
null
!=
this
.
text
)
{
aText
=
oNumFormat
.
format
(
this
.
text
,
this
.
type
,
dDigitsCount
);
aText
=
oNumFormat
.
format
(
this
.
text
,
this
.
type
,
dDigitsCount
,
false
,
opt_cultureInfo
);
sText
=
null
;
}
else
if
(
null
!=
this
.
multiText
)
{
}
else
if
(
null
!=
this
.
multiText
)
{
var
sSimpleString
=
this
.
getStringFromMultiText
();
aText
=
oNumFormat
.
format
(
sSimpleString
,
this
.
type
,
dDigitsCount
);
aText
=
oNumFormat
.
format
(
sSimpleString
,
this
.
type
,
dDigitsCount
,
false
,
opt_cultureInfo
);
sText
=
null
;
}
}
}
}
else
if
(
CellValueType
.
Number
==
this
.
type
&&
null
!=
this
.
number
)
{
}
else
if
(
CellValueType
.
Number
==
this
.
type
&&
null
!=
this
.
number
)
{
bNeedMeasure
=
false
;
var
bFindResult
=
false
;
//варируем dDigitsCount чтобы результат влез в ячейку
var
nTempDigCount
=
Math
.
ceil
(
dDigitsCount
);
var
sOriginText
=
this
.
number
;
while
(
nTempDigCount
>=
1
)
{
while
(
nTempDigCount
>=
1
)
{
//Строим подходящий general format
var
sGeneral
=
AscCommon
.
DecodeGeneralFormat
(
sOriginText
,
this
.
type
,
nTempDigCount
);
if
(
null
!=
sGeneral
)
if
(
null
!=
sGeneral
)
{
oNumFormat
=
oNumFormatCache
.
get
(
sGeneral
);
}
if
(
null
!=
oNumFormat
)
{
if
(
null
!=
oNumFormat
)
{
sText
=
null
;
aText
=
oNumFormat
.
format
(
sOriginText
,
this
.
type
,
dDigitsCount
);
if
(
true
==
oNumFormat
.
isTextFormat
())
aText
=
oNumFormat
.
format
(
sOriginText
,
this
.
type
,
dDigitsCount
,
false
,
opt_cultureInfo
);
if
(
true
==
oNumFormat
.
isTextFormat
())
{
break
;
else
{
}
else
{
aRes
=
this
.
_getValue2Result
(
cell
,
sText
,
aText
);
//Проверяем влезает ли текст
if
(
true
==
fIsFitMeasurer
(
aRes
))
{
if
(
true
==
fIsFitMeasurer
(
aRes
))
{
bFindResult
=
true
;
break
;
}
...
...
@@ -3245,52 +3264,40 @@ CCellValue.prototype =
}
nTempDigCount
--
;
}
if
(
false
==
bFindResult
)
{
if
(
false
==
bFindResult
)
{
aRes
=
null
;
sText
=
null
;
var
font
=
new
AscCommonExcel
.
Font
();
if
(
dDigitsCount
>
1
)
{
if
(
dDigitsCount
>
1
)
{
font
.
setRepeat
(
true
);
aText
=
[{
text
:
"
#
"
,
format
:
font
}];
}
else
aText
=
[{
text
:
"
#
"
,
format
:
font
}];
}
else
{
aText
=
[{
text
:
""
,
format
:
font
}];
}
}
}
else
if
(
CellValueType
.
Bool
==
this
.
type
)
{
if
(
null
!=
this
.
number
)
sText
=
(
0
!=
this
.
number
)
?
cBoolLocal
[
"
t
"
].
toUpperCase
():
cBoolLocal
[
"
f
"
].
toUpperCase
();
}
else
if
(
CellValueType
.
Bool
==
this
.
type
)
{
if
(
null
!=
this
.
number
)
{
sText
=
(
0
!=
this
.
number
)
?
cBoolLocal
[
"
t
"
].
toUpperCase
()
:
cBoolLocal
[
"
f
"
].
toUpperCase
();
}
else
if
(
CellValueType
.
Error
==
this
.
type
)
{
if
(
null
!=
this
.
text
)
}
else
if
(
CellValueType
.
Error
==
this
.
type
)
{
if
(
null
!=
this
.
text
)
{
sText
=
this
.
_getValueTypeError
(
this
.
text
);
}
if
(
bNeedMeasure
)
{
}
if
(
bNeedMeasure
)
{
aRes
=
this
.
_getValue2Result
(
cell
,
sText
,
aText
);
//Проверяем влезает ли текст
if
(
false
==
fIsFitMeasurer
(
aRes
))
{
if
(
false
==
fIsFitMeasurer
(
aRes
))
{
aRes
=
null
;
sText
=
null
;
var
font
=
new
AscCommonExcel
.
Font
();
font
.
setRepeat
(
true
);
aText
=
[{
text
:
"
#
"
,
format
:
font
}];
aText
=
[{
text
:
"
#
"
,
format
:
font
}];
}
}
if
(
null
==
aRes
)
if
(
null
==
aRes
)
{
aRes
=
this
.
_getValue2Result
(
cell
,
sText
,
aText
);
var
formula
=
cell
.
getFormula
();
if
(
formula
){
aRes
[
0
].
sFormula
=
formula
;
aRes
[
0
].
sId
=
cell
.
getName
();
}
this
.
aTextValue2
[
dDigitsCount
]
=
aRes
;
}
return
aRes
;
},
...
...
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