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
975f9bc0
Commit
975f9bc0
authored
Mar 03, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
for bugs 34108, 34109 ("mso-list" property)
parent
1e788721
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
256 additions
and
136 deletions
+256
-136
common/wordcopypaste.js
common/wordcopypaste.js
+256
-136
No files found.
common/wordcopypaste.js
View file @
975f9bc0
...
@@ -1890,6 +1890,8 @@ function PasteProcessor(api, bUploadImage, bUploadFonts, bNested, pasteInExcel)
...
@@ -1890,6 +1890,8 @@ function PasteProcessor(api, bUploadImage, bUploadFonts, bNested, pasteInExcel)
"
mso-border-insideh
"
:
1
,
"
mso-row-margin-left
"
:
1
,
"
mso-row-margin-right
"
:
1
,
"
mso-cellspacing
"
:
1
,
"
mso-border-alt
"
:
1
,
"
mso-border-insideh
"
:
1
,
"
mso-row-margin-left
"
:
1
,
"
mso-row-margin-right
"
:
1
,
"
mso-cellspacing
"
:
1
,
"
mso-border-alt
"
:
1
,
"
mso-border-left-alt
"
:
1
,
"
mso-border-top-alt
"
:
1
,
"
mso-border-right-alt
"
:
1
,
"
mso-border-bottom-alt
"
:
1
,
"
mso-border-between
"
:
1
,
"
mso-list
"
:
1
};
"
mso-border-left-alt
"
:
1
,
"
mso-border-top-alt
"
:
1
,
"
mso-border-right-alt
"
:
1
,
"
mso-border-bottom-alt
"
:
1
,
"
mso-border-between
"
:
1
,
"
mso-list
"
:
1
};
this
.
oBorderCache
=
{};
this
.
oBorderCache
=
{};
this
.
msoListMap
=
[];
}
}
PasteProcessor
.
prototype
=
PasteProcessor
.
prototype
=
{
{
...
@@ -4535,6 +4537,7 @@ PasteProcessor.prototype =
...
@@ -4535,6 +4537,7 @@ PasteProcessor.prototype =
_set_pPr
:
function
(
node
,
Para
,
pNoHtmlPr
)
_set_pPr
:
function
(
node
,
Para
,
pNoHtmlPr
)
{
{
//����������� ����� �� ������ � ������� �������� ��������
//����������� ����� �� ������ � ������� �������� ��������
var
t
=
this
;
var
sNodeName
=
node
.
nodeName
.
toLowerCase
();
var
sNodeName
=
node
.
nodeName
.
toLowerCase
();
if
(
node
!=
this
.
oRootNode
)
if
(
node
!=
this
.
oRootNode
)
{
{
...
@@ -4693,7 +4696,7 @@ PasteProcessor.prototype =
...
@@ -4693,7 +4696,7 @@ PasteProcessor.prototype =
Ind
.
FirstLine
=
text_indent
;
Ind
.
FirstLine
=
text_indent
;
// if(null != pPr.Ind.FirstLine && true == this.bUseScaleKoef)
// if(null != pPr.Ind.FirstLine && true == this.bUseScaleKoef)
// pPr.Ind.FirstLine = pPr.Ind.FirstLine * this.dScaleKoef;
// pPr.Ind.FirstLine = pPr.Ind.FirstLine * this.dScaleKoef;
if
(
false
==
this
.
_isEmptyProperty
(
Ind
))
if
(
false
==
this
.
_isEmptyProperty
(
Ind
)
&&
!
pNoHtmlPr
[
'
mso-list
'
]
)
Para
.
Set_Ind
(
Ind
);
Para
.
Set_Ind
(
Ind
);
//Jc
//Jc
var
text_align
=
computedStyle
.
getPropertyValue
(
"
text-align
"
);
var
text_align
=
computedStyle
.
getPropertyValue
(
"
text-align
"
);
...
@@ -4815,22 +4818,173 @@ PasteProcessor.prototype =
...
@@ -4815,22 +4818,173 @@ PasteProcessor.prototype =
}
}
}
}
//
num
//
*****num*****
if
(
PasteElementsId
.
g_bIsDocumentCopyPaste
)
if
(
PasteElementsId
.
g_bIsDocumentCopyPaste
)
{
{
if
(
true
==
pNoHtmlPr
.
bNum
)
if
(
true
==
pNoHtmlPr
.
bNum
)
{
{
var
num
=
numbering_numfmt_Bullet
;
var
setListTextPr
=
function
(
AbstractNum
)
if
(
null
!=
pNoHtmlPr
.
numType
)
{
num
=
pNoHtmlPr
.
numType
;
//��������� ��������� ������ ����� �� ���������� ������� ���������� ��������
var
type
=
pNoHtmlPr
[
"
list-style-type
"
];
var
oFirstTextChild
=
node
;
while
(
true
)
{
var
bContinue
=
false
;
for
(
var
i
=
0
,
length
=
oFirstTextChild
.
childNodes
.
length
;
i
<
length
;
i
++
)
{
var
child
=
oFirstTextChild
.
childNodes
[
i
];
var
nodeType
=
child
.
nodeType
;
if
(
!
(
Node
.
ELEMENT_NODE
==
nodeType
||
Node
.
TEXT_NODE
==
nodeType
))
continue
;
//�������� ������� ��������� ������ �� \t,\n,\r
if
(
Node
.
TEXT_NODE
==
child
.
nodeType
)
{
var
value
=
child
.
nodeValue
;
if
(
!
value
)
continue
;
value
=
value
.
replace
(
/
(\r
|
\t
|
\n)
/g
,
''
);
if
(
""
==
value
)
continue
;
}
if
(
Node
.
ELEMENT_NODE
==
nodeType
)
{
oFirstTextChild
=
child
;
bContinue
=
true
;
break
;
}
}
if
(
false
==
bContinue
)
break
;
}
if
(
node
!=
oFirstTextChild
)
{
if
(
!
t
.
bIsPlainText
)
{
var
oLvl
=
AbstractNum
.
Lvl
[
0
];
var
oTextPr
=
t
.
_read_rPr
(
oFirstTextChild
);
if
(
numbering_numfmt_Bullet
==
num
)
oTextPr
.
RFonts
=
oLvl
.
TextPr
.
RFonts
.
Copy
();
//TODO убираю пока при всатвке извне underline/bold/italic у стиля маркера
oTextPr
.
Bold
=
oTextPr
.
Underline
=
oTextPr
.
Italic
=
undefined
;
if
(
oFirstTextChild
.
nodeName
.
toLowerCase
()
==
"
a
"
&&
oTextPr
.
Color
)
oTextPr
.
Color
.
Set
(
0
,
0
,
0
);
//�������� ��������� �� node
AbstractNum
.
Apply_TextPr
(
0
,
oTextPr
);
}
}
};
//TODO обработать символы из mso html
/*
if(pNoHtmlPr['mso-list'])
if
(
pNoHtmlPr
[
'
mso-list
'
])
{
{
//get listId and level from mso-list property
var
msoListIgnoreSymbol
=
this
.
_getMsoListSymbol
(
node
);
var
msoListIgnoreSymbol
=
this
.
_getMsoListSymbol
(
node
);
var
num
=
this
.
_getTypeMsoListSymbol
(
msoListIgnoreSymbol
);
}*/
var
level
=
0
;
var
listId
=
null
;
var
startIndex
;
if
(
-
1
!=
(
startIndex
=
pNoHtmlPr
[
'
mso-list
'
].
indexOf
(
"
level
"
)))
{
level
=
parseInt
(
pNoHtmlPr
[
'
mso-list
'
].
substr
(
startIndex
+
5
,
1
))
-
1
;
}
if
(
-
1
!=
(
startIndex
=
pNoHtmlPr
[
'
mso-list
'
].
indexOf
(
"
lfo
"
)))
{
listId
=
pNoHtmlPr
[
'
mso-list
'
].
substr
(
startIndex
,
4
);
}
var
NumId
=
null
;
if
(
listId
&&
this
.
msoListMap
[
listId
])
//find list id into map
{
NumId
=
this
.
msoListMap
[
listId
];
}
if
(
null
==
NumId
&&
this
.
pasteInExcel
!==
true
)
//create new NumId
{
// Создаем нумерацию
NumId
=
this
.
oLogicDocument
.
Numbering
.
Create_AbstractNum
();
var
AbstractNum
=
this
.
oLogicDocument
.
Numbering
.
Get_AbstractNum
(
NumId
);
if
(
numbering_numfmt_Bullet
===
num
)
{
AbstractNum
.
Create_Default_Bullet
();
var
LvlText
=
String
.
fromCharCode
(
0x00B7
);
var
NumTextPr
=
new
CTextPr
();
NumTextPr
.
RFonts
.
Set_All
(
"
Symbol
"
,
-
1
);
switch
(
type
)
{
case
"
disc
"
:
{
NumTextPr
.
RFonts
.
Set_All
(
"
Symbol
"
,
-
1
);
LvlText
=
String
.
fromCharCode
(
0x00B7
);
break
;
}
case
"
circle
"
:
{
NumTextPr
.
RFonts
.
Set_All
(
"
Courier New
"
,
-
1
);
LvlText
=
"
o
"
;
break
;
}
case
"
square
"
:
{
NumTextPr
.
RFonts
.
Set_All
(
"
Wingdings
"
,
-
1
);
LvlText
=
String
.
fromCharCode
(
0x00A7
);
break
;
}
}
}
else
{
AbstractNum
.
Create_Default_Numbered
();
}
switch
(
num
)
{
case
numbering_numfmt_Bullet
:
AbstractNum
.
Set_Lvl_Bullet
(
level
,
LvlText
,
NumTextPr
);
break
;
case
numbering_numfmt_Decimal
:
AbstractNum
.
Set_Lvl_Numbered_3
(
level
);
break
;
case
numbering_numfmt_LowerRoman
:
AbstractNum
.
Set_Lvl_Numbered_9
(
level
);
break
;
case
numbering_numfmt_UpperRoman
:
AbstractNum
.
Set_Lvl_Numbered_5
(
level
);
break
;
case
numbering_numfmt_LowerLetter
:
AbstractNum
.
Set_Lvl_Numbered_8
(
level
);
break
;
case
numbering_numfmt_UpperLetter
:
AbstractNum
.
Set_Lvl_Numbered_6
(
level
);
break
;
}
//setListTextPr(AbstractNum);
}
else
{
var
AbstractNum
=
this
.
oLogicDocument
.
Numbering
.
Get_AbstractNum
(
NumId
);
switch
(
num
)
{
case
numbering_numfmt_Decimal
:
AbstractNum
.
Set_Lvl_Numbered_3
(
level
);
break
;
case
numbering_numfmt_LowerRoman
:
AbstractNum
.
Set_Lvl_Numbered_9
(
level
);
break
;
case
numbering_numfmt_UpperRoman
:
AbstractNum
.
Set_Lvl_Numbered_5
(
level
);
break
;
case
numbering_numfmt_LowerLetter
:
AbstractNum
.
Set_Lvl_Numbered_8
(
level
);
break
;
case
numbering_numfmt_UpperLetter
:
AbstractNum
.
Set_Lvl_Numbered_6
(
level
);
break
;
}
}
//put into map listId
if
(
!
this
.
msoListMap
[
listId
])
{
this
.
msoListMap
[
listId
]
=
NumId
;
}
if
(
this
.
pasteInExcel
!==
true
&&
Para
.
bFromDocument
===
true
)
{
Para
.
Numbering_Set
(
NumId
,
level
);
}
}
else
{
var
num
=
numbering_numfmt_Bullet
;
if
(
null
!=
pNoHtmlPr
.
numType
)
num
=
pNoHtmlPr
.
numType
;
var
type
=
pNoHtmlPr
[
"
list-style-type
"
];
if
(
type
)
if
(
type
)
{
{
...
@@ -4847,7 +5001,6 @@ PasteProcessor.prototype =
...
@@ -4847,7 +5001,6 @@ PasteProcessor.prototype =
//����� ���� ����������� �� Document.Set_ParagraphNumbering
//����� ���� ����������� �� Document.Set_ParagraphNumbering
//������� ����������� ��������, ���� ��� ������ ���������, �� ����� ��� ������ �� ����������� ���������
//������� ����������� ��������, ���� ��� ������ ���������, �� ����� ��� ������ �� ����������� ���������
var
NumId
=
null
;
if
(
this
.
aContent
.
length
>
1
)
if
(
this
.
aContent
.
length
>
1
)
{
{
var
prevElem
=
this
.
aContent
[
this
.
aContent
.
length
-
2
];
var
prevElem
=
this
.
aContent
[
this
.
aContent
.
length
-
2
];
...
@@ -4909,74 +5062,13 @@ PasteProcessor.prototype =
...
@@ -4909,74 +5062,13 @@ PasteProcessor.prototype =
case
numbering_numfmt_UpperLetter
:
AbstractNum
.
Set_Lvl_Numbered_6
(
iLvl
);
break
;
case
numbering_numfmt_UpperLetter
:
AbstractNum
.
Set_Lvl_Numbered_6
(
iLvl
);
break
;
}
}
}
}
//��������� ��������� ������ ����� �� ���������� ������� ���������� ��������
var
oFirstTextChild
=
node
;
while
(
true
)
{
var
bContinue
=
false
;
for
(
var
i
=
0
,
length
=
oFirstTextChild
.
childNodes
.
length
;
i
<
length
;
i
++
)
{
var
child
=
oFirstTextChild
.
childNodes
[
i
];
var
nodeType
=
child
.
nodeType
;
if
(
!
(
Node
.
ELEMENT_NODE
==
nodeType
||
Node
.
TEXT_NODE
==
nodeType
))
setListTextPr
(
AbstractNum
);
continue
;
//�������� ������� ��������� ������ �� \t,\n,\r
if
(
Node
.
TEXT_NODE
==
child
.
nodeType
)
{
var
value
=
child
.
nodeValue
;
if
(
!
value
)
continue
;
value
=
value
.
replace
(
/
(\r
|
\t
|
\n)
/g
,
''
);
if
(
""
==
value
)
continue
;
}
if
(
Node
.
ELEMENT_NODE
==
nodeType
)
{
oFirstTextChild
=
child
;
bContinue
=
true
;
break
;
}
}
}
if
(
false
==
bContinue
)
break
;
}
if
(
node
!=
oFirstTextChild
)
{
if
(
!
this
.
bIsPlainText
)
{
var
oLvl
=
AbstractNum
.
Lvl
[
0
];
var
oTextPr
=
this
.
_read_rPr
(
oFirstTextChild
);
if
(
numbering_numfmt_Bullet
==
num
)
oTextPr
.
RFonts
=
oLvl
.
TextPr
.
RFonts
.
Copy
();
//TODO убираю пока при всатвке извне underline/bold/italic у стиля маркера
oTextPr
.
Bold
=
oTextPr
.
Underline
=
oTextPr
.
Italic
=
undefined
;
if
(
oFirstTextChild
.
nodeName
.
toLowerCase
()
==
"
a
"
&&
oTextPr
.
Color
)
oTextPr
.
Color
.
Set
(
0
,
0
,
0
);
//�������� ��������� �� node
AbstractNum
.
Apply_TextPr
(
0
,
oTextPr
);
}
}
}
if
(
this
.
pasteInExcel
!==
true
&&
Para
.
bFromDocument
===
true
)
if
(
this
.
pasteInExcel
!==
true
&&
Para
.
bFromDocument
===
true
)
{
{
var
lvl
=
0
;
Para
.
Numbering_Add
(
NumId
,
0
);
if
(
pNoHtmlPr
[
'
mso-list
'
])
{
//TODO сделать полную поддержку mso-list при копировании списков из mso списков
var
startIndex
;
if
(
-
1
!=
(
startIndex
=
pNoHtmlPr
[
'
mso-list
'
].
indexOf
(
"
level
"
)))
{
lvl
=
parseInt
(
pNoHtmlPr
[
'
mso-list
'
].
substr
(
startIndex
+
5
,
1
))
-
1
;
}
Para
.
Numbering_Set
(
NumId
,
lvl
);
}
else
{
Para
.
Numbering_Add
(
NumId
,
lvl
);
}
}
}
}
}
}
...
@@ -5315,6 +5407,34 @@ PasteProcessor.prototype =
...
@@ -5315,6 +5407,34 @@ PasteProcessor.prototype =
}
}
}
}
},
},
_getTypeMsoListSymbol
:
function
(
str
)
{
//TODO пока делаю так, пересмотреть регулярные выражения
var
res
=
numbering_numfmt_Bullet
;
var
number
=
parseInt
(
str
);
if
(
!
isNaN
(
number
))
{
res
=
numbering_numfmt_Decimal
;
}
else
if
(
str
.
match
(
/^
[
I,X,V
]
/
))
{
res
=
numbering_numfmt_UpperRoman
;
}
else
if
(
str
.
match
(
/^
[
i,x,v
]
/
))
{
res
=
numbering_numfmt_LowerRoman
;
}
else
if
(
str
.
match
(
/^
[
A-Z
]
/
))
{
res
=
numbering_numfmt_UpperLetter
;
}
else
if
(
str
.
match
(
/^
[
a-z
]
/
))
{
res
=
numbering_numfmt_LowerLetter
;
}
return
res
;
},
_AddNextPrevToContent
:
function
(
oDoc
)
_AddNextPrevToContent
:
function
(
oDoc
)
{
{
var
prev
=
null
;
var
prev
=
null
;
...
...
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