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
Hide 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;
...
@@ -236,11 +236,23 @@ var editor;
}
}
return
res
;
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
cultureInfo
=
AscCommon
.
g_aCultureInfos
[
culture
]
||
AscCommon
.
g_oDefaultCultureInfo
;
var
numFormat
=
AscCommon
.
oNumFormatCache
.
get
(
format
);
var
numFormat
=
AscCommon
.
oNumFormatCache
.
get
(
format
);
value
=
(
null
==
value
)
?
this
.
wb
.
getSelectionInfo
().
asc_getFormula
()
:
value
;
var
res
;
return
numFormat
.
formatToChart
(
value
,
cultureInfo
);
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
)
{
spreadsheet_api
.
prototype
.
asc_getFormatCells
=
function
(
info
)
{
...
...
cell/model/Workbook.js
View file @
bdc4855b
...
@@ -5084,6 +5084,10 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
...
@@ -5084,6 +5084,10 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
this
.
_checkDirty
();
this
.
_checkDirty
();
return
this
.
oValue
.
getValueForEdit2
(
this
);
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
(){
Cell
.
prototype
.
getValueWithoutFormat
=
function
(){
this
.
_checkDirty
();
this
.
_checkDirty
();
return
this
.
oValue
.
getValueWithoutFormat
();
return
this
.
oValue
.
getValueWithoutFormat
();
...
...
cell/model/WorkbookElems.js
View file @
bdc4855b
...
@@ -3139,16 +3139,20 @@ CCellValue.prototype =
...
@@ -3139,16 +3139,20 @@ CCellValue.prototype =
if
(
null
==
this
.
textValue
)
if
(
null
==
this
.
textValue
)
{
{
this
.
getValue2
(
cell
,
gc_nMaxDigCountView
,
function
(){
return
true
;});
this
.
getValue2
(
cell
,
gc_nMaxDigCountView
,
function
(){
return
true
;});
this
.
textValue
=
""
;
this
.
textValue
=
this
.
_textArrayToString
(
this
.
aTextValue2
[
gc_nMaxDigCountView
]);
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
;
}
}
}
return
this
.
textValue
;
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
)
getValueForEdit
:
function
(
cell
)
{
{
if
(
null
==
this
.
textValueForEdit
)
if
(
null
==
this
.
textValueForEdit
)
...
@@ -3170,127 +3174,130 @@ CCellValue.prototype =
...
@@ -3170,127 +3174,130 @@ CCellValue.prototype =
aRes
=
this
.
aTextValue2
[
dDigitsCount
];
aRes
=
this
.
aTextValue2
[
dDigitsCount
];
if
(
null
==
aRes
)
if
(
null
==
aRes
)
{
{
var
bNeedMeasure
=
true
;
aRes
=
this
.
_getValue2
(
cell
,
dDigitsCount
,
fIsFitMeasurer
);
var
sText
=
null
;
var
formula
=
cell
.
getFormula
();
var
aText
=
null
;
if
(
formula
){
if
(
CellValueType
.
Number
==
this
.
type
||
CellValueType
.
String
==
this
.
type
)
aRes
[
0
].
sFormula
=
formula
;
{
aRes
[
0
].
sId
=
cell
.
getName
();
if
(
null
!=
this
.
text
)
}
sText
=
this
.
text
;
else
if
(
null
!=
this
.
multiText
)
this
.
aTextValue2
[
dDigitsCount
]
=
aRes
;
aText
=
this
.
multiText
;
}
return
aRes
;
if
(
CellValueType
.
String
==
this
.
type
)
},
bNeedMeasure
=
false
;
getValueForExample
:
function
(
cell
,
dDigitsCount
,
fIsFitMeasurer
,
numFormat
,
cultureInfo
)
var
oNumFormat
;
{
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
)
{
sText
=
this
.
text
;
}
else
if
(
null
!=
this
.
multiText
)
{
aText
=
this
.
multiText
;
}
if
(
CellValueType
.
String
==
this
.
type
)
{
bNeedMeasure
=
false
;
}
var
oNumFormat
;
if
(
opt_numFormat
)
{
oNumFormat
=
opt_numFormat
;
}
else
{
var
xfs
=
cell
.
getCompiledStyle
();
var
xfs
=
cell
.
getCompiledStyle
();
if
(
null
!=
xfs
&&
null
!=
xfs
.
num
)
if
(
null
!=
xfs
&&
null
!=
xfs
.
num
)
{
oNumFormat
=
oNumFormatCache
.
get
(
xfs
.
num
.
getFormat
());
oNumFormat
=
oNumFormatCache
.
get
(
xfs
.
num
.
getFormat
());
else
}
else
{
oNumFormat
=
oNumFormatCache
.
get
(
g_oDefaultFormat
.
Num
.
getFormat
());
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
)
{
var
oTextFormat
=
oNumFormat
.
getTextFormat
();
if
(
null
!=
oTextFormat
&&
"
@
"
!=
oTextFormat
.
formatString
)
{
if
(
null
!=
this
.
text
)
{
aText
=
oNumFormat
.
format
(
this
.
text
,
this
.
type
,
dDigitsCount
);
sText
=
null
;
}
else
if
(
null
!=
this
.
multiText
)
{
var
sSimpleString
=
this
.
getStringFromMultiText
();
aText
=
oNumFormat
.
format
(
sSimpleString
,
this
.
type
,
dDigitsCount
);
sText
=
null
;
}
}
}
}
}
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
)
{
//Строим подходящий general format
var
sGeneral
=
AscCommon
.
DecodeGeneralFormat
(
sOriginText
,
this
.
type
,
nTempDigCount
);
if
(
null
!=
sGeneral
)
oNumFormat
=
oNumFormatCache
.
get
(
sGeneral
);
if
(
null
!=
oNumFormat
)
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
,
false
,
opt_cultureInfo
);
sText
=
null
;
}
else
if
(
null
!=
this
.
multiText
)
{
var
sSimpleString
=
this
.
getStringFromMultiText
();
aText
=
oNumFormat
.
format
(
sSimpleString
,
this
.
type
,
dDigitsCount
,
false
,
opt_cultureInfo
);
sText
=
null
;
sText
=
null
;
aText
=
oNumFormat
.
format
(
sOriginText
,
this
.
type
,
dDigitsCount
);
if
(
true
==
oNumFormat
.
isTextFormat
())
break
;
else
{
aRes
=
this
.
_getValue2Result
(
cell
,
sText
,
aText
);
//Проверяем влезает ли текст
if
(
true
==
fIsFitMeasurer
(
aRes
))
{
bFindResult
=
true
;
break
;
}
aRes
=
null
;
}
}
}
nTempDigCount
--
;
}
}
if
(
false
==
bFindResult
)
}
{
}
else
if
(
CellValueType
.
Number
==
this
.
type
&&
null
!=
this
.
number
)
{
aRes
=
null
;
bNeedMeasure
=
false
;
var
bFindResult
=
false
;
//варируем dDigitsCount чтобы результат влез в ячейку
var
nTempDigCount
=
Math
.
ceil
(
dDigitsCount
);
var
sOriginText
=
this
.
number
;
while
(
nTempDigCount
>=
1
)
{
//Строим подходящий general format
var
sGeneral
=
AscCommon
.
DecodeGeneralFormat
(
sOriginText
,
this
.
type
,
nTempDigCount
);
if
(
null
!=
sGeneral
)
{
oNumFormat
=
oNumFormatCache
.
get
(
sGeneral
);
}
if
(
null
!=
oNumFormat
)
{
sText
=
null
;
sText
=
null
;
var
font
=
new
AscCommonExcel
.
Font
();
aText
=
oNumFormat
.
format
(
sOriginText
,
this
.
type
,
dDigitsCount
,
false
,
opt_cultureInfo
);
if
(
dDigitsCount
>
1
){
if
(
true
==
oNumFormat
.
isTextFormat
())
{
font
.
setRepeat
(
true
);
break
;
aText
=
[{
text
:
"
#
"
,
format
:
font
}];
}
else
{
aRes
=
this
.
_getValue2Result
(
cell
,
sText
,
aText
);
//Проверяем влезает ли текст
if
(
true
==
fIsFitMeasurer
(
aRes
))
{
bFindResult
=
true
;
break
;
}
aRes
=
null
;
}
}
else
aText
=
[{
text
:
""
,
format
:
font
}];
}
}
nTempDigCount
--
;
}
}
}
if
(
false
==
bFindResult
)
{
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
)
sText
=
this
.
_getValueTypeError
(
this
.
text
);
}
if
(
bNeedMeasure
)
{
aRes
=
this
.
_getValue2Result
(
cell
,
sText
,
aText
);
//Проверяем влезает ли текст
if
(
false
==
fIsFitMeasurer
(
aRes
))
{
aRes
=
null
;
aRes
=
null
;
sText
=
null
;
sText
=
null
;
var
font
=
new
AscCommonExcel
.
Font
();
var
font
=
new
AscCommonExcel
.
Font
();
font
.
setRepeat
(
true
);
if
(
dDigitsCount
>
1
)
{
aText
=
[{
text
:
"
#
"
,
format
:
font
}];
font
.
setRepeat
(
true
);
aText
=
[{
text
:
"
#
"
,
format
:
font
}];
}
else
{
aText
=
[{
text
:
""
,
format
:
font
}];
}
}
}
}
}
if
(
null
==
aRes
)
}
else
if
(
CellValueType
.
Bool
==
this
.
type
)
{
aRes
=
this
.
_getValue2Result
(
cell
,
sText
,
aText
);
if
(
null
!=
this
.
number
)
{
var
formula
=
cell
.
getFormula
();
sText
=
(
0
!=
this
.
number
)
?
cBoolLocal
[
"
t
"
].
toUpperCase
()
:
cBoolLocal
[
"
f
"
].
toUpperCase
();
if
(
formula
){
aRes
[
0
].
sFormula
=
formula
;
aRes
[
0
].
sId
=
cell
.
getName
();
}
}
}
else
if
(
CellValueType
.
Error
==
this
.
type
)
{
this
.
aTextValue2
[
dDigitsCount
]
=
aRes
;
if
(
null
!=
this
.
text
)
{
sText
=
this
.
_getValueTypeError
(
this
.
text
);
}
}
if
(
bNeedMeasure
)
{
aRes
=
this
.
_getValue2Result
(
cell
,
sText
,
aText
);
//Проверяем влезает ли текст
if
(
false
==
fIsFitMeasurer
(
aRes
))
{
aRes
=
null
;
sText
=
null
;
var
font
=
new
AscCommonExcel
.
Font
();
font
.
setRepeat
(
true
);
aText
=
[{
text
:
"
#
"
,
format
:
font
}];
}
}
if
(
null
==
aRes
)
{
aRes
=
this
.
_getValue2Result
(
cell
,
sText
,
aText
);
}
}
return
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