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
Hide 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,138 +4818,51 @@ PasteProcessor.prototype =
...
@@ -4815,138 +4818,51 @@ 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
"
];
//TODO обработать символы из mso html
/*if(pNoHtmlPr['mso-list'])
{
{
var msoListIgnoreSymbol = this._getMsoListSymbol(node);
//��������� ��������� ������ ����� �� ���������� ������� ���������� ��������
var
oFirstTextChild
=
node
;
}*/
while
(
true
)
{
if
(
type
)
var
bContinue
=
false
;
{
for
(
var
i
=
0
,
length
=
oFirstTextChild
.
childNodes
.
length
;
i
<
length
;
i
++
)
switch
(
type
)
{
{
var
child
=
oFirstTextChild
.
childNodes
[
i
];
case
"
disc
"
:
num
=
numbering_numfmt_Bullet
;
break
;
var
nodeType
=
child
.
nodeType
;
case
"
decimal
"
:
num
=
numbering_numfmt_Decimal
;
break
;
case
"
lower-roman
"
:
num
=
numbering_numfmt_LowerRoman
;
break
;
case
"
upper-roman
"
:
num
=
numbering_numfmt_UpperRoman
;
break
;
case
"
lower-alpha
"
:
num
=
numbering_numfmt_LowerLetter
;
break
;
case
"
upper-alpha
"
:
num
=
numbering_numfmt_UpperLetter
;
break
;
}
}
//����� ���� ����������� �� Document.Set_ParagraphNumbering
//������� ����������� ��������, ���� ��� ������ ���������, �� ����� ��� ������ �� ����������� ���������
var
NumId
=
null
;
if
(
this
.
aContent
.
length
>
1
)
{
var
prevElem
=
this
.
aContent
[
this
.
aContent
.
length
-
2
];
if
(
null
!=
prevElem
&&
type_Paragraph
===
prevElem
.
GetType
())
{
var
PrevNumPr
=
prevElem
.
Numbering_Get
();
if
(
null
!=
PrevNumPr
&&
true
===
this
.
oLogicDocument
.
Numbering
.
Check_Format
(
PrevNumPr
.
NumId
,
PrevNumPr
.
Lvl
,
num
)
)
NumId
=
PrevNumPr
.
NumId
;
}
}
if
(
null
==
NumId
&&
this
.
pasteInExcel
!==
true
)
{
// Создаем нумерацию
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
();
}
for
(
var
iLvl
=
0
;
iLvl
<=
8
;
iLvl
++
)
{
switch
(
num
)
{
case
numbering_numfmt_Bullet
:
AbstractNum
.
Set_Lvl_Bullet
(
iLvl
,
LvlText
,
NumTextPr
);
break
;
case
numbering_numfmt_Decimal
:
AbstractNum
.
Set_Lvl_Numbered_2
(
iLvl
);
break
;
case
numbering_numfmt_LowerRoman
:
AbstractNum
.
Set_Lvl_Numbered_5
(
iLvl
);
break
;
case
numbering_numfmt_UpperRoman
:
AbstractNum
.
Set_Lvl_Numbered_9
(
iLvl
);
break
;
case
numbering_numfmt_LowerLetter
:
AbstractNum
.
Set_Lvl_Numbered_8
(
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
))
if
(
!
(
Node
.
ELEMENT_NODE
==
nodeType
||
Node
.
TEXT_NODE
==
nodeType
))
continue
;
continue
;
//�������� ������� ��������� ������ �� \t,\n,\r
//�������� ������� ��������� ������ �� \t,\n,\r
if
(
Node
.
TEXT_NODE
==
child
.
nodeType
)
if
(
Node
.
TEXT_NODE
==
child
.
nodeType
)
{
{
var
value
=
child
.
nodeValue
;
var
value
=
child
.
nodeValue
;
if
(
!
value
)
if
(
!
value
)
continue
;
continue
;
value
=
value
.
replace
(
/
(\r
|
\t
|
\n)
/g
,
''
);
value
=
value
.
replace
(
/
(\r
|
\t
|
\n)
/g
,
''
);
if
(
""
==
value
)
if
(
""
==
value
)
continue
;
continue
;
}
}
if
(
Node
.
ELEMENT_NODE
==
nodeType
)
if
(
Node
.
ELEMENT_NODE
==
nodeType
)
{
{
oFirstTextChild
=
child
;
oFirstTextChild
=
child
;
bContinue
=
true
;
bContinue
=
true
;
break
;
break
;
}
}
}
}
if
(
false
==
bContinue
)
if
(
false
==
bContinue
)
break
;
break
;
}
}
if
(
node
!=
oFirstTextChild
)
if
(
node
!=
oFirstTextChild
)
{
{
if
(
!
t
his
.
bIsPlainText
)
if
(
!
t
.
bIsPlainText
)
{
{
var
oLvl
=
AbstractNum
.
Lvl
[
0
];
var
oLvl
=
AbstractNum
.
Lvl
[
0
];
var
oTextPr
=
t
his
.
_read_rPr
(
oFirstTextChild
);
var
oTextPr
=
t
.
_read_rPr
(
oFirstTextChild
);
if
(
numbering_numfmt_Bullet
==
num
)
if
(
numbering_numfmt_Bullet
==
num
)
oTextPr
.
RFonts
=
oLvl
.
TextPr
.
RFonts
.
Copy
();
oTextPr
.
RFonts
=
oLvl
.
TextPr
.
RFonts
.
Copy
();
...
@@ -4958,25 +4874,201 @@ PasteProcessor.prototype =
...
@@ -4958,25 +4874,201 @@ PasteProcessor.prototype =
//�������� ��������� �� node
//�������� ��������� �� node
AbstractNum
.
Apply_TextPr
(
0
,
oTextPr
);
AbstractNum
.
Apply_TextPr
(
0
,
oTextPr
);
}
}
}
}
}
};
if
(
this
.
pasteInExcel
!==
true
&&
Para
.
bFromDocument
===
true
)
if
(
pNoHtmlPr
[
'
mso-list
'
])
{
{
var
lvl
=
0
;
//get listId and level from mso-list property
if
(
pNoHtmlPr
[
'
mso-list
'
])
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
{
{
//TODO сделать полную поддержку mso-list при копировании списков из mso списков
NumId
=
this
.
msoListMap
[
listId
];
var
startIndex
;
}
if
(
-
1
!=
(
startIndex
=
pNoHtmlPr
[
'
mso-list
'
].
indexOf
(
"
level
"
)))
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
)
{
{
lvl
=
parseInt
(
pNoHtmlPr
[
'
mso-list
'
].
substr
(
startIndex
+
5
,
1
))
-
1
;
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
;
}
}
Para
.
Numbering_Set
(
NumId
,
lvl
);
//setListTextPr(AbstractNum
);
}
}
else
else
{
{
Para
.
Numbering_Add
(
NumId
,
lvl
);
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
)
{
switch
(
type
)
{
case
"
disc
"
:
num
=
numbering_numfmt_Bullet
;
break
;
case
"
decimal
"
:
num
=
numbering_numfmt_Decimal
;
break
;
case
"
lower-roman
"
:
num
=
numbering_numfmt_LowerRoman
;
break
;
case
"
upper-roman
"
:
num
=
numbering_numfmt_UpperRoman
;
break
;
case
"
lower-alpha
"
:
num
=
numbering_numfmt_LowerLetter
;
break
;
case
"
upper-alpha
"
:
num
=
numbering_numfmt_UpperLetter
;
break
;
}
}
//����� ���� ����������� �� Document.Set_ParagraphNumbering
//������� ����������� ��������, ���� ��� ������ ���������, �� ����� ��� ������ �� ����������� ���������
if
(
this
.
aContent
.
length
>
1
)
{
var
prevElem
=
this
.
aContent
[
this
.
aContent
.
length
-
2
];
if
(
null
!=
prevElem
&&
type_Paragraph
===
prevElem
.
GetType
())
{
var
PrevNumPr
=
prevElem
.
Numbering_Get
();
if
(
null
!=
PrevNumPr
&&
true
===
this
.
oLogicDocument
.
Numbering
.
Check_Format
(
PrevNumPr
.
NumId
,
PrevNumPr
.
Lvl
,
num
)
)
NumId
=
PrevNumPr
.
NumId
;
}
}
if
(
null
==
NumId
&&
this
.
pasteInExcel
!==
true
)
{
// Создаем нумерацию
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
();
}
for
(
var
iLvl
=
0
;
iLvl
<=
8
;
iLvl
++
)
{
switch
(
num
)
{
case
numbering_numfmt_Bullet
:
AbstractNum
.
Set_Lvl_Bullet
(
iLvl
,
LvlText
,
NumTextPr
);
break
;
case
numbering_numfmt_Decimal
:
AbstractNum
.
Set_Lvl_Numbered_2
(
iLvl
);
break
;
case
numbering_numfmt_LowerRoman
:
AbstractNum
.
Set_Lvl_Numbered_5
(
iLvl
);
break
;
case
numbering_numfmt_UpperRoman
:
AbstractNum
.
Set_Lvl_Numbered_9
(
iLvl
);
break
;
case
numbering_numfmt_LowerLetter
:
AbstractNum
.
Set_Lvl_Numbered_8
(
iLvl
);
break
;
case
numbering_numfmt_UpperLetter
:
AbstractNum
.
Set_Lvl_Numbered_6
(
iLvl
);
break
;
}
}
setListTextPr
(
AbstractNum
);
}
if
(
this
.
pasteInExcel
!==
true
&&
Para
.
bFromDocument
===
true
)
{
Para
.
Numbering_Add
(
NumId
,
0
);
}
}
}
}
}
}
...
@@ -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