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
1dda4d96
Commit
1dda4d96
authored
Mar 24, 2016
by
GoshaZotov
Committed by
Alexander.Trofimov
May 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
убрал неиспользуемый код(+ при вставке текста беру дефолтовый шрифт из темы)
parent
a40afae4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
612 deletions
+9
-612
cell/model/clipboard.js
cell/model/clipboard.js
+9
-612
No files found.
cell/model/clipboard.js
View file @
1dda4d96
"
use strict
"
;
"
use strict
"
;
(
/**
* @param {jQuery} $
...
...
@@ -1468,13 +1468,17 @@
},
_getDefaultCell
:
function
()
_getDefaultCell
:
function
(
worksheet
)
{
var
res
=
[];
var
fn
=
worksheet
.
model
.
workbook
.
getDefaultFont
();
var
fs
=
worksheet
.
model
.
workbook
.
getDefaultSize
();
res
.
push
({
format
:
{
fn
:
'
Arial
'
,
fs
:
'
11
'
,
fn
:
fn
,
fs
:
fs
,
b
:
false
,
i
:
false
,
u
:
Asc
.
EUnderline
.
underlineNone
,
...
...
@@ -1516,225 +1520,6 @@
return
res
;
},
_getArray
:
function
(
node
,
isText
)
{
var
aResult
=
[];
var
oNewItem
=
[];
var
tmpBorderStyle
,
borderStyleName
;
var
t
=
this
;
if
(
node
==
undefined
)
node
=
document
.
createElement
(
'
span
'
);
if
(
node
==
undefined
||
node
==
null
)
{
oNewItem
[
0
]
=
t
.
_getDefaultCell
();
this
.
fontsNew
[
'
Arial
'
]
=
1
;
}
//style for text
else
if
(
node
.
children
!=
undefined
&&
node
.
children
.
length
==
0
)
{
oNewItem
[
0
]
=
t
.
_setStylesTextPaste
(
node
);
this
.
fontsNew
[
oNewItem
[
0
].
format
.
fn
]
=
1
;
}
else
{
if
(
typeof
(
node
)
==
'
string
'
||
node
.
children
.
length
==
0
||
node
.
children
.
length
==
1
&&
node
.
children
[
0
].
nodeName
==
'
#text
'
)
oNewItem
=
t
.
_makeCellValuesHtml
(
node
,
isText
);
else
oNewItem
=
t
.
_makeCellValuesHtml
(
node
.
childNodes
,
isText
);
}
//borders
oNewItem
.
borders
=
new
Border
();
tmpBorderStyle
=
$
(
node
).
css
(
'
border-top-style
'
);
if
(
"
none
"
!==
tmpBorderStyle
&&
null
!=
tmpBorderStyle
)
{
var
borderTopWidth
=
node
.
style
.
borderTopWidth
;
if
(
borderTopWidth
==
''
)
borderTopWidth
=
$
(
node
).
css
(
'
border-top-width
'
);
var
borderTopStyle
=
node
.
style
.
borderTopStyle
;
if
(
borderTopStyle
==
''
)
borderTopStyle
=
tmpBorderStyle
;
var
borderTopColor
=
node
.
style
.
borderTopColor
;
if
(
borderTopColor
==
''
)
borderTopColor
=
$
(
node
).
css
(
'
border-top-color
'
);
if
(
borderTopColor
)
borderTopColor
=
this
.
_getBinaryColor
(
borderTopColor
);
else
borderTopColor
=
0
;
borderStyleName
=
this
.
_getBorderStyleName
(
borderTopStyle
,
borderTopWidth
);
if
(
null
!==
borderStyleName
)
{
oNewItem
.
borders
.
t
.
setStyle
(
borderStyleName
);
oNewItem
.
borders
.
t
.
c
=
new
RgbColor
(
borderTopColor
);
}
}
tmpBorderStyle
=
$
(
node
).
css
(
'
border-bottom-style
'
);
if
(
"
none
"
!==
tmpBorderStyle
&&
null
!=
tmpBorderStyle
)
{
var
borderBottomWidth
=
node
.
style
.
borderBottomWidth
;
if
(
borderBottomWidth
==
''
)
borderBottomWidth
=
$
(
node
).
css
(
'
border-bottom-width
'
);
var
borderBottomStyle
=
node
.
style
.
borderBottomStyle
;
if
(
borderBottomStyle
==
''
)
borderBottomStyle
=
tmpBorderStyle
;
var
borderBottomColor
=
node
.
style
.
borderBottomColor
;
if
(
borderBottomColor
==
''
)
borderBottomColor
=
$
(
node
).
css
(
'
border-bottom-color
'
);
if
(
borderBottomColor
)
borderBottomColor
=
this
.
_getBinaryColor
(
borderBottomColor
);
else
borderBottomColor
=
0
;
borderStyleName
=
this
.
_getBorderStyleName
(
borderBottomStyle
,
borderBottomWidth
);
if
(
null
!==
borderStyleName
)
{
oNewItem
.
borders
.
b
.
setStyle
(
borderStyleName
);
oNewItem
.
borders
.
b
.
c
=
new
RgbColor
(
borderBottomColor
);
}
}
tmpBorderStyle
=
$
(
node
).
css
(
'
border-left-style
'
);
if
(
"
none
"
!==
tmpBorderStyle
&&
null
!=
tmpBorderStyle
)
{
var
borderLeftWidth
=
node
.
style
.
borderLeftWidth
;
if
(
borderLeftWidth
==
''
)
borderLeftWidth
=
$
(
node
).
css
(
'
border-left-width
'
);
var
borderLeftStyle
=
node
.
style
.
borderLeftStyle
;
if
(
borderLeftStyle
==
''
)
borderLeftStyle
=
tmpBorderStyle
;
var
borderLeftColor
=
node
.
style
.
borderLeftColor
;
if
(
borderLeftColor
==
''
)
borderLeftColor
=
$
(
node
).
css
(
'
border-left-color
'
);
if
(
borderLeftColor
)
borderLeftColor
=
this
.
_getBinaryColor
(
borderLeftColor
);
else
borderLeftColor
=
0
;
borderStyleName
=
this
.
_getBorderStyleName
(
borderLeftStyle
,
borderLeftWidth
);
if
(
null
!==
borderStyleName
)
{
oNewItem
.
borders
.
l
.
setStyle
(
borderStyleName
);
oNewItem
.
borders
.
l
.
c
=
new
RgbColor
(
borderLeftColor
);
}
}
tmpBorderStyle
=
$
(
node
).
css
(
'
border-right-style
'
);
if
(
"
none
"
!==
tmpBorderStyle
&&
null
!=
tmpBorderStyle
)
{
var
borderRightWidth
=
node
.
style
.
borderRightWidth
;
if
(
borderRightWidth
==
''
)
borderRightWidth
=
$
(
node
).
css
(
'
border-right-width
'
);
var
borderRightStyle
=
node
.
style
.
borderRightStyle
;
if
(
borderRightStyle
==
''
)
borderRightStyle
=
tmpBorderStyle
;
var
borderRightColor
=
node
.
style
.
borderRightColor
;
if
(
borderRightColor
==
''
)
borderRightColor
=
$
(
node
).
css
(
'
border-right-color
'
);
if
(
borderRightColor
)
borderRightColor
=
this
.
_getBinaryColor
(
borderRightColor
);
else
borderRightColor
=
0
;
borderStyleName
=
this
.
_getBorderStyleName
(
borderRightStyle
,
borderRightWidth
);
if
(
null
!==
borderStyleName
)
{
oNewItem
.
borders
.
r
.
setStyle
(
borderStyleName
);
oNewItem
.
borders
.
r
.
c
=
new
RgbColor
(
borderRightColor
);
}
}
//wrap
if
(
oNewItem
.
wrap
!==
true
)
{
if
(
node
.
style
.
whiteSpace
==
'
nowrap
'
)
oNewItem
.
wrap
=
false
;
else
if
(
node
.
style
.
whiteSpace
==
'
normal
'
)
oNewItem
.
wrap
=
true
;
else
oNewItem
.
wrap
=
false
;
}
//merge
if
(
node
!=
undefined
&&
node
.
colSpan
!=
undefined
)
oNewItem
.
colSpan
=
node
.
colSpan
;
else
oNewItem
.
colSpan
=
1
;
if
(
node
!=
undefined
&&
node
.
rowSpan
!=
undefined
)
oNewItem
.
rowSpan
=
node
.
rowSpan
;
else
oNewItem
.
rowSpan
=
1
;
if
(
node
.
style
.
textAlign
!=
null
&&
node
.
style
.
textAlign
!=
''
)
oNewItem
.
a
=
node
.
style
.
textAlign
;
else
if
(
node
.
children
[
0
]
&&
node
.
children
[
0
].
style
.
textAlign
!=
null
&&
node
.
children
[
0
].
style
.
textAlign
!=
''
)
oNewItem
.
a
=
node
.
children
[
0
].
style
.
textAlign
;
else
if
(
node
.
nodeName
.
toLowerCase
()
==
"
th
"
)
oNewItem
.
a
=
'
center
'
;
if
(
$
(
node
).
css
(
'
background-color
'
)
!=
'
none
'
&&
$
(
node
).
css
(
'
background-color
'
)
!=
null
)
{
oNewItem
.
bc
=
new
RgbColor
(
this
.
_getBinaryColor
(
$
(
node
).
css
(
'
background-color
'
)));
}
if
(
node
.
style
.
verticalAlign
!=
undefined
&&
node
.
style
.
verticalAlign
!=
null
&&
node
.
style
.
verticalAlign
!=
''
&&
node
.
style
.
verticalAlign
!=
'
middle
'
)
oNewItem
.
va
=
node
.
style
.
verticalAlign
;
else
if
(
node
.
style
.
verticalAlign
==
'
middle
'
)
oNewItem
.
va
=
'
center
'
;
else
oNewItem
.
va
=
'
bottom
'
;
//check format
if
(
node
.
getAttribute
(
"
class
"
)
!=
null
){
var
cL
=
node
.
getAttribute
(
"
class
"
).
split
(
"
"
);
for
(
var
i
=
0
;
i
<
cL
.
length
;
i
++
){
if
(
cL
[
i
].
indexOf
(
"
nFormat
"
)
>
-
1
)
{
var
format
=
cL
[
i
].
split
(
'
nFormat
'
);
oNewItem
.
format
=
format
[
1
];
}
}
}
//link
var
findHyperLink
=
$
(
node
).
find
(
"
a
"
);
if
(
$
(
node
).
children
(
'
a
'
).
length
==
1
&&
oNewItem
[
0
]
!=
undefined
)
{
oNewItem
.
hyperLink
=
$
(
node
).
children
(
'
a
'
).
attr
(
'
href
'
);
if
(
$
(
node
).
children
(
'
a
'
).
attr
(
'
title
'
))
oNewItem
.
toolTip
=
$
(
node
).
children
(
'
a
'
).
attr
(
'
title
'
);
else
oNewItem
.
toolTip
=
null
;
}
else
if
(
findHyperLink
&&
findHyperLink
[
0
]
&&
oNewItem
[
0
]
!=
undefined
&&
findHyperLink
.
length
==
1
)
{
oNewItem
.
hyperLink
=
findHyperLink
.
attr
(
'
href
'
);
if
(
findHyperLink
.
attr
(
'
title
'
))
oNewItem
.
toolTip
=
findHyperLink
.
attr
(
'
title
'
);
else
oNewItem
.
toolTip
=
null
;
}
else
if
(
node
.
nodeName
.
toLowerCase
()
==
'
a
'
)
{
oNewItem
.
hyperLink
=
$
(
node
).
attr
(
'
href
'
);
if
(
$
(
node
).
attr
(
'
title
'
))
oNewItem
.
toolTip
=
$
(
node
).
attr
(
'
title
'
);
else
oNewItem
.
toolTip
=
null
;
}
aResult
.
push
(
oNewItem
);
return
aResult
;
},
_IsBlockElem
:
function
(
name
)
{
if
(
"
p
"
==
name
||
"
div
"
==
name
||
"
ul
"
==
name
||
"
ol
"
==
name
||
"
li
"
==
name
||
"
table
"
==
name
||
"
tbody
"
==
name
||
"
tr
"
==
name
||
"
td
"
==
name
||
"
th
"
==
name
||
...
...
@@ -2382,7 +2167,7 @@
aResult
[
this
.
activeRange
.
r1
]
=
[];
var
oNewItem
=
[];
oNewItem
[
0
]
=
this
.
_getDefaultCell
();
oNewItem
[
0
]
=
this
.
_getDefaultCell
(
worksheet
);
aResult
[
this
.
activeRange
.
r1
][
this
.
activeRange
.
c1
]
=
oNewItem
;
oNewItem
[
0
][
0
].
text
=
text
;
...
...
@@ -2435,394 +2220,6 @@
window
.
GlobalPasteFlag
=
false
;
},
_parseHtml
:
function
(
pasteFragment
,
node
,
worksheet
,
isText
)
{
//if(node.children && node.children.length === 0)
//return false;
var
cellCountAll
=
[],
rowSpanPlus
=
0
,
tableRowCount
=
0
,
l
=
0
,
n
=
0
,
s
=
0
,
countEmptyRow
=
0
,
rowCount
=
0
,
arrTags
=
[],
t
=
this
,
aResult
=
[];
var
range
=
worksheet
.
activeRange
.
clone
(
true
);
var
testFragment
=
$
.
extend
(
true
,
{},
node
);
var
is_chrome
=
AscBrowser
.
isChrome
;
$
(
testFragment
).
children
(
'
br
'
).
remove
();
//в случае если приходит простой текст, преращаем его в корректную html - проблема характерна для FF
if
(
testFragment
.
children
.
length
==
0
)
{
var
allChild
=
node
.
childNodes
;
var
sHtml
=
''
;
for
(
n
=
0
;
n
<
allChild
.
length
;
++
n
)
{
text
=
allChild
[
n
].
nodeValue
.
replace
(
/
(\r
|
\t
|
\n)
/g
,
''
);
if
(
allChild
[
n
].
nodeName
.
toLowerCase
()
==
'
#text
'
&&
text
!=
''
)
{
sHtml
+=
"
<p><span style='font-family:Calibri;font-size:11pt;white-space:nowrap'>
"
+
text
+
"
</span></p>
"
}
}
if
(
sHtml
==
''
)
return
;
pasteFragment
.
innerHTML
=
sHtml
;
if
(
!
is_chrome
)
isText
=
true
;
}
var
mainChildrens
=
t
.
_getSignTags
(
pasteFragment
.
childNodes
);
var
countChild
=
mainChildrens
.
length
;
//определяем размер квадрата вставки
var
arrMax
=
[],
findTable
;
for
(
n
=
0
;
n
<
$
(
pasteFragment
).
find
(
'
table
'
).
length
;
++
n
)
{
findTable
=
$
(
$
(
pasteFragment
).
find
(
'
table
'
)[
n
]).
find
(
'
tr
'
);
if
(
findTable
&&
findTable
[
0
])
arrMax
[
n
]
=
findTable
[
0
].
children
.
length
;
}
if
(
arrMax
.
length
!=
0
)
{
var
max
=
Math
.
max
.
apply
(
Math
,
arrMax
);
if
(
max
!=
0
)
range
.
c2
=
range
.
c2
+
max
-
1
;
}
this
.
fontsNew
=
{};
if
(
null
!=
$
(
pasteFragment
).
find
(
'
table
'
)
&&
1
==
countChild
&&
pasteFragment
.
children
[
0
]
!=
undefined
&&
pasteFragment
.
children
[
0
].
children
[
0
]
!=
undefined
&&
pasteFragment
.
children
[
0
].
children
[
0
].
nodeName
.
toLowerCase
()
==
'
table
'
)
{
pasteFragment
=
pasteFragment
.
children
[
0
];
}
var
countTrueTags
=
t
.
_countTags
(
mainChildrens
,
arrTags
);
if
(
countTrueTags
.
length
!=
0
&&
node
.
length
!=
countTrueTags
.
length
&&
node
.
children
[
0
]
!=
countTrueTags
[
0
])
{
var
p
=
document
.
createElement
(
'
p
'
);
$
(
p
).
append
(
countTrueTags
);
pasteFragment
=
p
;
countChild
=
p
.
childNodes
.
length
;
mainChildrens
=
pasteFragment
.
childNodes
;
}
if
(
!
mainChildrens
)
{
countChild
=
pasteFragment
.
children
.
length
;
mainChildrens
=
pasteFragment
.
children
;
}
if
(
mainChildrens
&&
mainChildrens
.
length
==
1
&&
mainChildrens
[
0
].
nodeName
.
toLowerCase
()
==
'
b
'
)
mainChildrens
=
mainChildrens
[
0
].
children
;
var
onlyImages
=
null
;
var
addImages
=
null
;
var
imCount
=
0
;
//пробегаемся по html
for
(
var
r
=
range
.
r1
;
r
-
range
.
r1
<
countChild
;
++
r
)
{
//цикл по r
var
firstRow
=
mainChildrens
[
r
-
range
.
r1
-
countEmptyRow
];
if
(
firstRow
.
nodeName
.
toLowerCase
()
==
'
br
'
)
r
++
;
aResult
[
r
+
tableRowCount
]
=
[];
var
tag
=
mainChildrens
[
r
-
range
.
r1
-
countEmptyRow
];
if
(
pasteFragment
.
children
.
length
==
1
&&
pasteFragment
.
children
[
0
].
nodeName
.
toLowerCase
()
==
'
table
'
)
aResult
.
isOneTable
=
true
;
for
(
var
c
=
range
.
c1
;
c
<=
range
.
c2
;
++
c
)
{
if
((
tag
.
nodeName
.
toLowerCase
()
==
'
div
'
||
tag
.
nodeName
.
toLowerCase
()
==
'
p
'
||
tag
.
nodeName
.
toLowerCase
()
==
'
h
'
||
tag
.
nodeName
.
toLowerCase
().
search
(
'
h
'
)
!=
-
1
)
&&
c
==
range
.
c1
||
tag
.
nodeName
.
toLowerCase
()
==
'
li
'
)
{
var
prevSib
=
mainChildrens
[
r
-
range
.
r1
-
countEmptyRow
-
1
];
//в случае если тег р следует за таблицей или таким же тегом, пропускаем строчку
if
(
prevSib
)
{
if
(
prevSib
.
nodeName
.
toLowerCase
()
==
'
table
'
)
{
var
emtyTag
=
document
.
createElement
(
'
p
'
);
aResult
[
r
+
tableRowCount
][
c
]
=
t
.
_getArray
(
emtyTag
,
isText
);
countChild
++
;
r
++
;
countEmptyRow
++
;
aResult
[
r
+
tableRowCount
]
=
[];
}
}
tag
.
innerHTML
=
tag
.
innerHTML
.
replace
(
/
(\n)
/g
,
''
);
aResult
[
r
+
tableRowCount
][
c
]
=
t
.
_getArray
(
tag
,
isText
);
c
=
range
.
c2
;
cellCountAll
[
s
]
=
1
;
s
++
;
onlyImages
=
false
;
}
else
if
(
tag
.
nodeName
.
toLowerCase
()
==
'
#text
'
)
{
var
prevSib
=
$
(
tag
).
prev
();
//в случае если тег р следует за таблицей или таким же тегом, пропускаем строчку
if
(
prevSib
.
length
!=
0
)
{
if
(
prevSib
[
prevSib
.
length
-
1
].
nodeName
.
toLowerCase
()
==
'
p
'
||
prevSib
[
prevSib
.
length
-
1
].
nodeName
.
toLowerCase
()
==
'
table
'
)
{
var
emtyTag
=
document
.
createElement
(
'
p
'
);
aResult
[
r
+
tableRowCount
][
c
]
=
t
.
_getArray
(
emtyTag
,
isText
);
countChild
++
;
r
++
;
countEmptyRow
++
;
aResult
[
r
+
tableRowCount
]
=
[];
}
}
var
span
=
document
.
createElement
(
'
p
'
);
$
(
span
).
append
(
tag
);
aResult
[
r
+
tableRowCount
][
c
]
=
t
.
_getArray
(
span
,
isText
);
c
=
range
.
c2
;
cellCountAll
[
s
]
=
1
;
s
++
;
onlyImages
=
false
;
}
else
if
(
tag
.
nodeName
.
toLowerCase
()
==
'
span
'
||
tag
.
nodeName
.
toLowerCase
()
==
'
a
'
||
tag
.
nodeName
.
toLowerCase
()
==
'
form
'
)
{
aResult
[
r
+
tableRowCount
][
c
]
=
t
.
_getArray
(
tag
,
isText
);
cellCountAll
[
s
]
=
1
;
c
=
range
.
c2
;
s
++
;
onlyImages
=
false
;
}
else
if
(
tag
.
nodeName
.
toLowerCase
()
==
'
table
'
)
{
var
tableBody
=
tag
.
getElementsByTagName
(
'
tbody
'
)[
0
];
if
(
!
tableBody
)
continue
;
var
startNum
=
r
+
tableRowCount
;
var
n
=
0
;
var
arrCount
=
[];
var
cellCount
=
0
;
for
(
var
i
=
0
;
i
<
tableBody
.
children
.
length
;
++
i
)
{
arrCount
[
i
]
=
0
;
for
(
var
j
=
0
;
j
<
tableBody
.
children
[
i
].
children
.
length
;
++
j
)
{
if
(
tableBody
.
children
[
i
].
children
[
j
]
&&
tableBody
.
children
[
i
].
children
[
j
].
colSpan
!==
undefined
)
arrCount
[
i
]
+=
tableBody
.
children
[
i
].
children
[
j
].
colSpan
;
}
}
cellCount
=
Math
.
max
.
apply
({},
arrCount
);
for
(
var
i
=
0
;
i
<
tableBody
.
children
.
length
;
++
i
)
{
if
(
tableBody
.
children
[
i
].
children
[
0
]
!=
undefined
&&
(
tableBody
.
children
[
i
].
children
.
length
==
cellCount
||
tableBody
.
children
[
i
].
children
[
0
].
colSpan
==
cellCount
))
rowCount
+=
tableBody
.
children
[
i
].
children
[
0
].
rowSpan
;
}
aResult
.
rowCount
=
tag
.
rows
.
length
;
if
(
tag
.
rows
[
0
].
children
[
0
]
!=
undefined
&&
rowCount
>
tag
.
rows
.
length
)
{
aResult
.
rowCount
=
rowCount
;
}
var
mergeArr
=
[];
if
(
tableBody
.
children
.
length
==
1
&&
tableBody
.
children
[
0
].
children
.
length
==
1
&&
tableBody
.
children
[
0
].
children
[
0
].
rowSpan
!=
''
&&
tableBody
.
children
[
0
].
children
[
0
].
rowSpan
!=
null
)
rowSpanPlus
=
tableBody
.
children
[
0
].
children
[
0
].
rowSpan
-
1
;
cellCountAll
[
s
]
=
cellCount
;
s
++
;
var
rowCountTrue
=
startNum
;
for
(
var
tR
=
startNum
;
tR
<
tableBody
.
children
.
length
+
startNum
;
++
tR
)
{
if
(
tableBody
.
children
[
tR
-
startNum
]
&&
tableBody
.
children
[
tR
-
startNum
]
&&
tableBody
.
children
[
tR
-
startNum
].
nodeName
.
toLowerCase
()
!==
"
tr
"
)
{
continue
;
}
aResult
[
rowCountTrue
]
=
[];
var
cNew
=
0
;
for
(
var
tC
=
range
.
c1
;
tC
<
range
.
c1
+
cellCount
;
++
tC
)
{
if
(
tableBody
.
children
[
tR
-
startNum
]
&&
tableBody
.
children
[
tR
-
startNum
].
children
[
cNew
]
&&
tableBody
.
children
[
tR
-
startNum
].
children
[
cNew
].
nodeName
.
toLowerCase
()
!==
"
td
"
)
{
cNew
++
;
tC
--
;
continue
;
}
if
(
0
!=
mergeArr
.
length
)
{
for
(
var
k
=
0
;
k
<
mergeArr
.
length
;
++
k
)
{
if
(
tC
>=
mergeArr
[
k
].
c1
&&
tC
<=
mergeArr
[
k
].
c2
&&
rowCountTrue
>=
mergeArr
[
k
].
r1
&&
rowCountTrue
<=
mergeArr
[
k
].
r2
)
{
break
;
}
else
if
(
k
==
mergeArr
.
length
-
1
)
{
var
_tBody
=
tableBody
.
children
[
tR
-
startNum
].
children
[
cNew
];
var
findImg
=
$
(
_tBody
).
find
(
'
img
'
);
if
(
findImg
.
length
!=
0
)
{
for
(
var
imgCol
=
0
;
imgCol
<
findImg
.
length
;
imgCol
++
)
{
if
(
addImages
==
null
)
addImages
=
[];
var
curCell
=
{
col
:
tC
,
row
:
rowCountTrue
+
imgCol
};
var
tag
=
$
(
_tBody
).
find
(
'
img
'
)[
imgCol
];
addImages
[
imCount
]
=
{
curCell
:
curCell
,
tag
:
tag
};
imCount
++
;
}
}
if
(
_tBody
==
undefined
)
_tBody
=
document
.
createElement
(
'
td
'
);
aResult
[
rowCountTrue
][
tC
]
=
t
.
_getArray
(
_tBody
,
isText
);
if
(
undefined
!=
_tBody
&&
(
_tBody
.
colSpan
>
1
||
_tBody
.
rowSpan
>
1
))
{
mergeArr
[
n
++
]
=
{
r1
:
rowCountTrue
,
r2
:
rowCountTrue
+
_tBody
.
rowSpan
-
1
,
c1
:
tC
,
c2
:
tC
+
_tBody
.
colSpan
-
1
}
}
cNew
++
;
}
}
}
else
{
var
_tBody
=
tableBody
.
children
[
tR
-
startNum
].
children
[
cNew
];
var
findImg
=
$
(
_tBody
).
find
(
'
img
'
);
if
(
findImg
.
length
!=
0
)
{
for
(
var
imgCol
=
0
;
imgCol
<
findImg
.
length
;
imgCol
++
)
{
if
(
addImages
==
null
)
addImages
=
[];
var
curCell
=
{
col
:
tC
,
row
:
rowCountTrue
+
imgCol
};
var
tag
=
$
(
_tBody
).
find
(
'
img
'
)[
imgCol
];
addImages
[
imCount
]
=
{
curCell
:
curCell
,
tag
:
tag
};
imCount
++
;
}
}
aResult
[
rowCountTrue
][
tC
]
=
t
.
_getArray
(
_tBody
,
isText
);
var
changeAResult
=
t
.
_checkMaxTextLength
(
aResult
,
rowCountTrue
,
tC
);
if
(
changeAResult
)
{
aResult
=
changeAResult
.
aResult
;
rowCountTrue
=
changeAResult
.
r
;
tC
=
changeAResult
.
c
;
}
if
(
undefined
!=
_tBody
&&
(
_tBody
.
colSpan
>
1
||
_tBody
.
rowSpan
>
1
))
{
mergeArr
[
n
++
]
=
{
r1
:
rowCountTrue
,
r2
:
rowCountTrue
+
_tBody
.
rowSpan
-
1
,
c1
:
tC
,
c2
:
tC
+
_tBody
.
colSpan
-
1
}
}
cNew
++
;
}
}
rowCountTrue
++
;
}
if
(
countChild
==
1
)
//если только таблица приходит
r
=
rowCountTrue
;
else
//если помимо таблицы есть ещё и прочее содержимое
tableRowCount
+=
rowCountTrue
-
startNum
-
1
;
break
;
onlyImages
=
false
;
}
else
if
(
tag
.
nodeName
.
toLowerCase
()
==
'
img
'
)
{
var
curCell
=
{
col
:
c
,
row
:
r
+
tableRowCount
};
if
(
addImages
==
null
)
addImages
=
[];
addImages
[
imCount
]
=
{
curCell
:
curCell
,
tag
:
tag
};
imCount
++
;
c
=
range
.
c2
;
if
(
onlyImages
!==
false
)
onlyImages
=
true
;
}
else
{
var
textArr
;
if
((
mainChildrens
[
r
-
range
.
r1
]
==
undefined
||
mainChildrens
[
r
-
range
.
r1
].
innerText
==
undefined
||
mainChildrens
[
r
-
range
.
r1
].
innerText
==
null
)
&&
(
$
(
mainChildrens
[
r
-
range
.
r1
]).
text
()
==
undefined
||
$
(
mainChildrens
[
r
-
range
.
r1
]).
text
()
==
null
))
{
textArr
=
[];
textArr
[
0
]
=
''
;
}
else
{
var
text
=
tag
.
innerText
;
if
(
text
==
undefined
)
text
=
$
(
tag
).
text
();
textArr
=
text
.
split
(
'
\n
'
);
}
for
(
k
=
0
;
k
<
textArr
.
length
;
++
k
)
{
aResult
[
r
+
tableRowCount
]
=
[];
var
newP
=
document
.
createElement
(
'
p
'
);
var
newSpan
=
document
.
createElement
(
'
span
'
);
$
(
newP
).
append
(
newSpan
);
newSpan
.
innerText
=
textArr
[
k
];
$
(
newSpan
).
text
(
textArr
[
k
]);
aResult
[
r
+
tableRowCount
][
c
]
=
t
.
_getArray
(
newP
,
isText
);
if
(
textArr
.
length
!=
1
&&
(
textArr
.
length
-
1
)
!=
k
)
r
++
;
}
c
=
range
.
c2
;
cellCountAll
[
s
]
=
1
;
s
++
;
onlyImages
=
false
;
}
}
}
if
(
cellCountAll
.
length
==
0
)
aResult
.
cellCount
=
0
;
else
aResult
.
cellCount
=
Math
.
max
.
apply
(
Math
,
cellCountAll
);
aResult
.
rowSpanSpCount
=
rowSpanPlus
;
var
api
=
window
[
"
Asc
"
][
"
editor
"
];
if
(
!
api
||
(
api
&&
!
api
.
isChartEditor
))
aResult
.
addImages
=
addImages
;
aResult
.
fontsNew
=
t
.
fontsNew
;
aResult
.
onlyImages
=
onlyImages
;
return
aResult
;
},
ReadFromBinaryWord
:
function
(
sBase64
,
worksheet
)
{
History
.
TurnOff
();
...
...
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