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
37b37826
Commit
37b37826
authored
Oct 12, 2016
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change PasteProcessor.Start(refactoring)
parent
e9fb7600
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1103 additions
and
1176 deletions
+1103
-1176
common/wordcopypaste.js
common/wordcopypaste.js
+1103
-1176
No files found.
common/wordcopypaste.js
View file @
37b37826
...
...
@@ -2227,11 +2227,21 @@ PasteProcessor.prototype =
}
},
Start
:
function
(
node
,
nodeDisplay
,
bDuplicate
,
only
Binary
)
Start
:
function
(
node
,
nodeDisplay
,
bDuplicate
,
from
Binary
)
{
//PASTE
if
(
null
==
nodeDisplay
)
nodeDisplay
=
node
;
var
bInsertFromBinary
=
false
;
if
(
PasteElementsId
.
copyPasteUseBinary
)
{
//get binary
var
base64FromWord
=
null
,
base64FromExcel
=
null
,
base64FromPresentation
;
var
binaryObj
=
this
.
_getClassBinaryFromHtml
(
node
,
fromBinary
);
base64FromExcel
=
binaryObj
.
base64FromExcel
;
base64FromWord
=
binaryObj
.
base64FromWord
;
base64FromPresentation
=
binaryObj
.
base64FromPresentation
;
var
bTurnOffTrackRevisions
=
false
;
if
(
PasteElementsId
.
g_bIsDocumentCopyPaste
)
//document
{
var
oThis
=
this
;
...
...
@@ -2240,80 +2250,241 @@ PasteProcessor.prototype =
this
.
oLogicDocument
.
Remove
(
1
,
true
,
true
,
true
);
this
.
oDocument
=
this
.
_GetTargetDocument
(
this
.
oDocument
);
var
bTurnOffTrackRevisions
=
false
;
if
(
this
.
oDocument
&&
this
.
oDocument
.
bPresentation
){
if
(
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
){
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
false
;
bTurnOffTrackRevisions
=
true
;
}
}
if
(
PasteElementsId
.
copyPasteUseBinary
)
}
//insert from binary
if
(
base64FromExcel
)
//вставка из редактора таблиц
{
this
.
_pasteBinaryFromExcel
(
base64FromExcel
);
bInsertFromBinary
=
true
;
}
else
if
(
base64FromWord
)
//вставка из редактора документов
{
if
(
null
===
node
&&
""
===
onlyBinary
)
this
.
_pasteBinaryFromWord
(
base64FromWord
,
!!
(
fromBinary
));
bInsertFromBinary
=
true
;
}
else
if
(
base64FromPresentation
)
//вставка из редактора презентаций
{
return
;
this
.
_pasteBinaryFromPresentation
(
base64FromPresentation
);
bInsertFromBinary
=
true
;
}
if
(
only
Binary
)
if
(
from
Binary
)
{
if
(
onlyBinary
.
indexOf
(
"
xslData;
"
)
>
-
1
)
bInsertFromBinary
=
true
;
}
}
if
(
true
===
bInsertFromBinary
)
{
base64FromExcel
=
onlyBinary
.
split
(
'
xslData;
'
)[
1
];
if
(
bTurnOffTrackRevisions
){
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
true
;
}
else
if
(
onlyBinary
.
indexOf
(
"
docData;
"
)
>
-
1
)
}
else
{
base64
=
onlyBinary
.
split
(
'
docData;
'
)[
1
]
;
this
.
_pasteFromHtml
(
node
,
bTurnOffTrackRevisions
)
;
}
else
if
(
onlyBinary
.
indexOf
(
"
pptData;
"
)
>
-
1
)
},
_pasteBinaryFromExcel
:
function
(
base64FromExcel
)
{
base64FromPresentation
=
onlyBinary
.
split
(
'
pptData;
'
)[
1
];
var
oThis
=
this
;
if
(
PasteElementsId
.
g_bIsDocumentCopyPaste
)
{
var
fPrepasteCallback
=
function
(){
if
(
false
==
oThis
.
bNested
)
{
oThis
.
InsertInDocument
();
if
(
oThis
.
aContent
.
bAddNewStyles
)
oThis
.
api
.
GenerateStyles
();
}
};
History
.
TurnOff
();
var
aContentExcel
=
this
.
_readFromBinaryExcel
(
base64FromExcel
);
History
.
TurnOn
();
if
(
aContentExcel
.
arrImages
&&
aContentExcel
.
arrImages
.
length
)
{
var
oObjectsForDownload
=
GetObjectsForImageDownload
(
aContentExcel
.
arrImages
);
AscCommon
.
sendImgUrls
(
oThis
.
api
,
oObjectsForDownload
.
aUrls
,
function
(
data
)
{
var
oImageMap
=
{};
ResetNewUrls
(
data
,
oObjectsForDownload
.
aUrls
,
oObjectsForDownload
.
aBuilderImagesByUrl
,
oImageMap
);
var
aContent
=
oThis
.
_convertExcelBinary
(
aContentExcel
);
oThis
.
aContent
=
aContent
.
content
;
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
oImageMap
,
fPrepasteCallback
);
});
}
else
{
var
aContent
=
oThis
.
_convertExcelBinary
(
aContentExcel
);
oThis
.
aContent
=
aContent
.
content
;
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
aContent
.
images
,
fPrepasteCallback
);
}
}
else
{
var
base64
=
null
,
base64FromExcel
=
null
,
base64FromPresentation
,
classNode
,
aContent
,
aContentExcel
,
pasteFromBinary
=
false
;
var
presentation
=
editor
.
WordControl
.
m_oLogicDocument
;
if
(
node
.
children
[
0
]
&&
node
.
children
[
0
].
getAttribute
(
"
class
"
)
!=
null
&&
(
node
.
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
xslData;
"
)
>
-
1
||
node
.
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
docData;
"
)
>
-
1
||
node
.
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
pptData;
"
)
>
-
1
))
classNode
=
node
.
children
[
0
].
getAttribute
(
"
class
"
);
else
if
(
node
.
children
[
0
]
&&
node
.
children
[
0
].
children
[
0
]
&&
node
.
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
)
!=
null
&&
(
node
.
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
xslData;
"
)
>
-
1
||
node
.
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
docData;
"
)
>
-
1
||
node
.
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
pptData;
"
)
>
-
1
))
classNode
=
node
.
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
);
else
if
(
node
.
children
[
0
]
&&
node
.
children
[
0
].
children
[
0
]
&&
node
.
children
[
0
].
children
[
0
].
children
[
0
]
&&
node
.
children
[
0
].
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
)
!=
null
&&
(
node
.
children
[
0
].
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
xslData;
"
)
>
-
1
||
node
.
children
[
0
].
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
docData;
"
)
>
-
1
||
node
.
children
[
0
].
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
pptData;
"
)
>
-
1
))
classNode
=
node
.
children
[
0
].
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
);
var
excelContent
=
AscFormat
.
ExecuteNoHistory
(
this
.
_readFromBinaryExcel
,
this
,
[
base64FromExcel
]);
var
aContentExcel
=
excelContent
.
workbook
;
var
aPastedImages
=
excelContent
.
arrImages
;
if
(
classNode
!=
null
){
var
cL
=
classNode
.
split
(
"
"
);
for
(
var
i
=
0
;
i
<
cL
.
length
;
i
++
){
if
(
cL
[
i
].
indexOf
(
"
xslData;
"
)
>
-
1
)
//если есть шейпы, то вставляем их из excel
if
(
aContentExcel
&&
aContentExcel
.
aWorksheets
&&
aContentExcel
.
aWorksheets
[
0
]
&&
aContentExcel
.
aWorksheets
[
0
].
Drawings
&&
aContentExcel
.
aWorksheets
[
0
].
Drawings
.
length
)
{
base64FromExcel
=
cL
[
i
].
split
(
'
xslData;
'
)[
1
];
var
paste_callback
=
function
()
{
if
(
false
==
oThis
.
bNested
)
{
for
(
var
i
=
0
;
i
<
arr_shapes
.
length
;
++
i
)
{
shape
=
arr_shapes
[
i
].
graphicObject
.
copy
();
shape
.
worksheet
=
null
;
shape
.
drawingBase
=
null
;
arr_shapes
[
i
]
=
new
DrawingCopyObject
(
shape
,
0
,
0
,
0
,
0
);
}
else
if
(
cL
[
i
].
indexOf
(
"
docData;
"
)
>
-
1
)
var
presentationSelectedContent
=
new
PresentationSelectedContent
();
presentationSelectedContent
.
Drawings
=
arr_shapes
;
presentation
.
Insert_Content
(
presentationSelectedContent
);
presentation
.
Recalculate
();
presentation
.
Check_CursorMoveRight
();
presentation
.
Document_UpdateInterfaceState
();
}
};
var
arr_shapes
=
aContentExcel
.
aWorksheets
[
0
].
Drawings
;
var
aImagesToDownload
=
[];
for
(
var
i
=
0
;
i
<
aPastedImages
.
length
;
i
++
)
{
base64
=
cL
[
i
].
split
(
'
docData;
'
)[
1
]
;
aImagesToDownload
.
push
(
aPastedImages
[
i
].
Url
)
;
}
else
if
(
cL
[
i
].
indexOf
(
"
pptData;
"
)
>
-
1
)
var
aContent
=
{
aPastedImages
:
aPastedImages
,
images
:
aImagesToDownload
};
//fonts
var
font_map
=
{};
for
(
var
i
=
0
;
i
<
arr_shapes
.
length
;
++
i
)
{
base64FromPresentation
=
cL
[
i
].
split
(
'
pptData;
'
)[
1
];
var
shape
=
arr_shapes
[
i
].
graphicObject
;
shape
.
getAllFonts
(
font_map
);
}
var
fonts
=
[];
//грузим картинки и фонты
for
(
var
i
in
font_map
)
fonts
.
push
(
new
CFont
(
i
,
0
,
""
,
0
));
//images
var
images
=
aContent
.
images
;
var
arrImages
=
aContent
.
aPastedImages
;
var
oObjectsForDownload
=
GetObjectsForImageDownload
(
arrImages
);
if
(
oObjectsForDownload
.
aUrls
.
length
>
0
)
{
AscCommon
.
sendImgUrls
(
oThis
.
api
,
oObjectsForDownload
.
aUrls
,
function
(
data
)
{
var
oImageMap
=
{};
History
.
TurnOff
();
ResetNewUrls
(
data
,
oObjectsForDownload
.
aUrls
,
oObjectsForDownload
.
aBuilderImagesByUrl
,
oImageMap
);
oThis
.
api
.
pre_Paste
(
fonts
,
oImageMap
,
paste_callback
);
History
.
TurnOn
();
});
}
else
{
var
im_arr
=
[];
for
(
var
key
in
images
)
im_arr
.
push
(
key
);
this
.
SetShortImageId
(
arrImages
);
this
.
api
.
pre_Paste
(
fonts
,
im_arr
,
paste_callback
);
}
return
;
}
else
{
var
presentationSelectedContent
=
new
PresentationSelectedContent
();
presentationSelectedContent
.
DocContent
=
new
CSelectedContent
();
var
aContent
=
AscFormat
.
ExecuteNoHistory
(
this
.
_convertExcelBinary
,
this
,
[
excelContent
]);
//если находимся внутри шейп, вставляем html
if
(
this
.
oDocument
.
Parent
&&
this
.
oDocument
.
Parent
instanceof
CShape
)
var
elements
=
[],
selectedElement
,
element
,
drawings
=
[],
pDrawings
=
[],
drawingCopyObject
;
var
defaultTableStyleId
=
presentation
.
DefaultTableStyleId
;
for
(
var
i
=
0
;
i
<
aContent
.
content
.
length
;
++
i
)
{
if
(
oThis
.
oDocument
&&
oThis
.
oDocument
.
Parent
&&
oThis
.
oDocument
.
Parent
.
parent
&&
oThis
.
oDocument
.
Parent
.
parent
.
parent
&&
oThis
.
oDocument
.
Parent
.
parent
.
parent
.
getObjectType
&&
oThis
.
oDocument
.
Parent
.
parent
.
parent
.
getObjectType
()
==
AscDFH
.
historyitem_type_Chart
)
base64
=
null
;
base64FromExcel
=
null
;
selectedElement
=
new
CSelectedElement
();
element
=
aContent
.
content
[
i
];
if
(
type_Table
==
element
.
GetType
())
//table
{
//TODO переделать количество строк и ширину
var
W
=
100
;
var
Rows
=
3
;
var
graphic_frame
=
new
CGraphicFrame
();
graphic_frame
.
setSpPr
(
new
AscFormat
.
CSpPr
());
graphic_frame
.
spPr
.
setParent
(
graphic_frame
);
graphic_frame
.
spPr
.
setXfrm
(
new
AscFormat
.
CXfrm
());
graphic_frame
.
spPr
.
xfrm
.
setParent
(
graphic_frame
.
spPr
);
graphic_frame
.
spPr
.
xfrm
.
setOffX
((
this
.
oDocument
.
Width
-
W
)
/
2
);
graphic_frame
.
spPr
.
xfrm
.
setOffY
(
this
.
oDocument
.
Height
/
5
);
graphic_frame
.
spPr
.
xfrm
.
setExtX
(
W
);
graphic_frame
.
spPr
.
xfrm
.
setExtY
(
7.478268771701388
*
Rows
);
graphic_frame
.
setNvSpPr
(
new
AscFormat
.
UniNvPr
());
element
=
this
.
_convertTableToPPTX
(
element
);
graphic_frame
.
setGraphicObject
(
element
.
Copy
(
graphic_frame
));
graphic_frame
.
graphicObject
.
Set_TableStyle
(
defaultTableStyleId
);
drawingCopyObject
=
new
DrawingCopyObject
();
drawingCopyObject
.
Drawing
=
graphic_frame
;
pDrawings
.
push
(
drawingCopyObject
);
}
}
else
if
(
this
.
oDocument
.
bPresentation
)
presentationSelectedContent
.
Drawings
=
pDrawings
;
var
presentation
=
editor
.
WordControl
.
m_oLogicDocument
;
//вставка
var
paste_callback
=
function
()
{
if
(
false
==
oThis
.
bNested
)
{
this
.
pasteInPresentationShape
=
true
;
presentation
.
Insert_Content
(
presentationSelectedContent
);
presentation
.
Recalculate
();
presentation
.
Check_CursorMoveRight
();
presentation
.
Document_UpdateInterfaceState
();
}
}
var
isImageInNode
=
node
&&
node
.
getElementsByTagName
(
'
img
'
)
&&
node
.
getElementsByTagName
(
'
img
'
).
length
?
true
:
false
;
if
(
base64
!=
null
)
aContent
=
this
.
ReadFromBinary
(
base64
);
oThis
.
api
.
pre_Paste
(
aContent
.
content
.
fonts
,
null
,
paste_callback
);
}
}
},
_pasteBinaryFromWord
:
function
(
base64FromWord
,
bIsOnlyFromBinary
)
{
var
oThis
=
this
;
if
(
PasteElementsId
.
g_bIsDocumentCopyPaste
)
{
var
aContent
=
this
.
ReadFromBinary
(
base64FromWord
);
//вставляем в заголовок диаграммы, предварительно конвертируем все параграфы в презентационный формат
if
(
aContent
&&
aContent
.
content
&&
this
.
oDocument
.
bPresentation
&&
oThis
.
oDocument
&&
oThis
.
oDocument
.
Parent
&&
oThis
.
oDocument
.
Parent
.
parent
&&
oThis
.
oDocument
.
Parent
.
parent
.
parent
&&
oThis
.
oDocument
.
Parent
.
parent
.
parent
.
getObjectType
&&
oThis
.
oDocument
.
Parent
.
parent
.
parent
.
getObjectType
()
==
AscDFH
.
historyitem_type_Chart
)
...
...
@@ -2330,104 +2501,209 @@ PasteProcessor.prototype =
aContent
.
content
=
newContent
;
}
if
(
base64
!=
null
&&
aContent
)
pasteFromBinary
=
true
;
else
if
(
aContentExcel
!=
null
&&
aContent
&&
aContent
.
content
)
pasteFromBinary
=
true
;
//***вставка из редактора таблиц в документы***
if
(
base64FromExcel
/* && pasteFromBinary === false && false*/
)
{
var
fPrepasteCallback
=
function
(){
if
(
false
==
oThis
.
bNested
)
{
oThis
.
InsertInDocument
();
if
(
oThis
.
aContent
.
bAddNewStyles
)
if
(
aContent
.
bAddNewStyles
)
oThis
.
api
.
GenerateStyles
();
}
};
}
History
.
TurnOff
()
;
aContentExcel
=
this
.
_readFromBinaryExcel
(
base64FromExcel
);
History
.
TurnOn
(
);
this
.
aContent
=
aContent
.
content
;
//проверяем список фонтов
aContent
.
fonts
=
oThis
.
_checkFontsOnLoad
(
aContent
.
fonts
);
var
oObjectsForDownload
=
GetObjectsForImageDownload
(
aContent
.
aPastedImages
);
if
(
oObjectsForDownload
.
aUrls
.
length
>
0
)
{
if
(
onlyBinary
&&
window
[
"
NativeCorrectImageUrlOnPaste
"
])
{
var
url
;
for
(
var
i
=
0
,
length
=
aContent
.
aPastedImages
.
length
;
i
<
length
;
++
i
)
{
url
=
window
[
"
NativeCorrectImageUrlOnPaste
"
](
aContent
.
aPastedImages
[
i
].
Url
);
aContent
.
images
[
i
]
=
url
;
var
imageElem
=
aContent
.
aPastedImages
[
i
];
if
(
null
!=
imageElem
)
{
imageElem
.
SetUrl
(
url
);
}
}
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
aContent
.
images
,
fPrepasteCallback
);
}
else
{
AscCommon
.
sendImgUrls
(
oThis
.
api
,
oObjectsForDownload
.
aUrls
,
function
(
data
)
{
ResetNewUrls
(
data
,
oObjectsForDownload
.
aUrls
,
oObjectsForDownload
.
aBuilderImagesByUrl
,
aContent
.
images
);
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
aContent
.
images
,
fPrepasteCallback
);
});
}
}
else
{
oThis
.
SetShortImageId
(
aContent
.
aPastedImages
);
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
aContent
.
images
,
fPrepasteCallback
);
}
}
else
{
var
presentation
=
editor
.
WordControl
.
m_oLogicDocument
;
var
trueDocument
=
this
.
oDocument
;
var
tempCDocument
=
function
()
{
return
new
CDocument
(
this
.
oDocument
.
DrawingDocument
,
false
);
}
//создаём темповый CDocument
this
.
oDocument
=
AscFormat
.
ExecuteNoHistory
(
tempCDocument
,
this
,
[]);
AscCommon
.
g_oIdCounter
.
m_bRead
=
true
;
var
aContent
=
AscFormat
.
ExecuteNoHistory
(
this
.
ReadFromBinary
,
this
,
[
base64FromWord
,
this
.
oDocument
]);
AscCommon
.
g_oIdCounter
.
m_bRead
=
false
;
//возврщаем обратно переменные и историю, документ которой заменяется при создании CDocument
this
.
oDocument
=
trueDocument
;
History
.
Document
=
trueDocument
;
var
presentationSelectedContent
=
new
PresentationSelectedContent
();
presentationSelectedContent
.
DocContent
=
new
CSelectedContent
();
var
elements
=
[],
selectedElement
,
element
,
drawings
=
[],
pDrawings
=
[],
drawingCopyObject
;
var
defaultTableStyleId
=
presentation
.
DefaultTableStyleId
;
for
(
var
i
=
0
;
i
<
aContent
.
content
.
length
;
++
i
)
{
selectedElement
=
new
CSelectedElement
();
element
=
aContent
.
content
[
i
];
//drawings
element
.
Get_AllDrawingObjects
(
drawings
);
if
(
type_Paragraph
==
element
.
GetType
())
//paragraph
{
selectedElement
.
Element
=
AscFormat
.
ConvertParagraphToPPTX
(
element
);
elements
.
push
(
selectedElement
);
}
else
if
(
type_Table
==
element
.
GetType
())
//table
{
//TODO переделать количество строк и ширину
var
W
=
100
;
var
Rows
=
3
;
var
graphic_frame
=
new
CGraphicFrame
();
graphic_frame
.
setSpPr
(
new
AscFormat
.
CSpPr
());
graphic_frame
.
spPr
.
setParent
(
graphic_frame
);
graphic_frame
.
spPr
.
setXfrm
(
new
AscFormat
.
CXfrm
());
graphic_frame
.
spPr
.
xfrm
.
setParent
(
graphic_frame
.
spPr
);
graphic_frame
.
spPr
.
xfrm
.
setOffX
((
this
.
oDocument
.
Width
-
W
)
/
2
);
graphic_frame
.
spPr
.
xfrm
.
setOffY
(
this
.
oDocument
.
Height
/
5
);
graphic_frame
.
spPr
.
xfrm
.
setExtX
(
W
);
graphic_frame
.
spPr
.
xfrm
.
setExtY
(
7.478268771701388
*
Rows
);
graphic_frame
.
setNvSpPr
(
new
AscFormat
.
UniNvPr
());
element
=
this
.
_convertTableToPPTX
(
element
,
true
);
graphic_frame
.
setGraphicObject
(
element
.
Copy
(
graphic_frame
));
graphic_frame
.
graphicObject
.
Set_TableStyle
(
defaultTableStyleId
);
drawingCopyObject
=
new
DrawingCopyObject
();
drawingCopyObject
.
Drawing
=
graphic_frame
;
pDrawings
.
push
(
drawingCopyObject
);
}
}
if
(
aContentExcel
.
arrImages
&&
aContentExcel
.
arrImage
s
.
length
)
if
(
drawings
&&
drawing
s
.
length
)
{
var
oObjectsForDownload
=
GetObjectsForImageDownload
(
aContentExcel
.
arrImages
);
AscCommon
.
sendImgUrls
(
oThis
.
api
,
oObjectsForDownload
.
aUrls
,
function
(
data
)
{
var
oImageMap
=
{};
ResetNewUrls
(
data
,
oObjectsForDownload
.
aUrls
,
oObjectsForDownload
.
aBuilderImagesByUrl
,
oImageMap
);
var
aContent
=
oThis
.
_convertExcelBinary
(
aContentExcel
);
oThis
.
aContent
=
aContent
.
content
;
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
oImageMap
,
fPrepasteCallback
);
});
}
else
//если массив содержит только изображения
if
(
elements
&&
1
===
elements
.
length
&&
elements
[
0
].
Element
&&
type_Paragraph
==
elements
[
0
].
Element
.
Get_Type
())
{
var
aContent
=
oThis
.
_convertExcelBinary
(
aContentExcel
);
oThis
.
aContent
=
aContent
.
content
;
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
aContent
.
images
,
fPrepasteCallback
)
;
if
(
true
===
this
.
_isParagraphContainsOnlyDrawing
(
elements
[
0
].
Element
))
{
elements
=
[]
;
}
if
(
bTurnOffTrackRevisions
){
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
true
;
}
return
;
for
(
var
j
=
0
;
j
<
drawings
.
length
;
j
++
)
{
drawingCopyObject
=
new
DrawingCopyObject
();
drawingCopyObject
.
Drawing
=
drawings
[
j
].
GraphicObj
;
pDrawings
.
push
(
drawingCopyObject
);
}
}
else
if
(
pasteFromBinary
)
//вставка из редактора документов
presentationSelectedContent
.
DocContent
.
Elements
=
elements
;
presentationSelectedContent
.
Drawings
=
pDrawings
;
//вставка
var
paste_callback
=
function
()
{
var
fPrepasteCallback
=
function
(){
if
(
false
==
oThis
.
bNested
)
{
oThis
.
InsertInDocument
();
if
(
aContent
.
bAddNewStyles
)
oThis
.
api
.
GenerateStyles
();
presentation
.
Insert_Content
(
presentationSelectedContent
);
presentation
.
Recalculate
();
presentation
.
Check_CursorMoveRight
();
presentation
.
Document_UpdateInterfaceState
();
}
}
this
.
aContent
=
aContent
.
content
;
//проверяем список фонтов
aContent
.
fonts
=
oThis
.
_checkFontsOnLoad
(
aContent
.
fonts
);
var
font_map
=
{};
var
images
=
[];
//shape.getAllFonts(font_map);
//перебираем шрифты
var
fonts
=
[];
for
(
var
i
in
font_map
)
fonts
.
push
(
new
CFont
(
i
,
0
,
""
,
0
));
var
oObjectsForDownload
=
GetObjectsForImageDownload
(
aContent
.
aPastedImages
);
if
(
oObjectsForDownload
.
aUrls
.
length
>
0
)
{
if
(
onlyBinary
&&
window
[
"
NativeCorrectImageUrlOnPaste
"
])
AscCommon
.
sendImgUrls
(
oThis
.
api
,
oObjectsForDownload
.
aUrls
,
function
(
data
){
var
oImageMap
=
{};
ResetNewUrls
(
data
,
oObjectsForDownload
.
aUrls
,
oObjectsForDownload
.
aBuilderImagesByUrl
,
oImageMap
);
//ковертим изображения в презентационный формат
for
(
var
i
=
0
;
i
<
presentationSelectedContent
.
Drawings
.
length
;
i
++
)
{
var
url
;
for
(
var
i
=
0
,
length
=
aContent
.
aPastedImages
.
length
;
i
<
length
;
++
i
)
if
(
!
(
presentationSelectedContent
.
Drawings
[
i
].
Drawing
instanceof
CGraphicFrame
))
{
url
=
window
[
"
NativeCorrectImageUrlOnPaste
"
](
aContent
.
aPastedImages
[
i
].
Url
);
aContent
.
images
[
i
]
=
url
;
var
imageElem
=
aContent
.
aPastedImages
[
i
];
if
(
null
!=
imageElem
)
AscFormat
.
ExecuteNoHistory
(
function
(){
if
(
presentationSelectedContent
.
Drawings
[
i
].
Drawing
.
setBDeleted2
)
{
imageElem
.
SetUrl
(
url
);
}
}
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
aContent
.
images
,
fPrepasteCallback
);
presentationSelectedContent
.
Drawings
[
i
].
Drawing
.
setBDeleted2
(
true
);
}
else
{
AscCommon
.
sendImgUrls
(
oThis
.
api
,
oObjectsForDownload
.
aUrls
,
function
(
data
)
{
ResetNewUrls
(
data
,
oObjectsForDownload
.
aUrls
,
oObjectsForDownload
.
aBuilderImagesByUrl
,
aContent
.
images
);
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
aContent
.
images
,
fPrepasteCallback
);
});
presentationSelectedContent
.
Drawings
[
i
].
Drawing
.
setBDeleted
(
true
);
}
},
this
,
[]);
presentationSelectedContent
.
Drawings
[
i
].
Drawing
=
presentationSelectedContent
.
Drawings
[
i
].
Drawing
.
convertToPPTX
(
oThis
.
oDocument
.
DrawingDocument
);
AscFormat
.
checkBlipFillRasterImages
(
presentationSelectedContent
.
Drawings
[
i
].
Drawing
);
}
}
oThis
.
api
.
pre_Paste
(
fonts
,
oImageMap
,
paste_callback
);
});
}
else
{
oThis
.
SetShortImageId
(
aContent
.
aPastedImages
);
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
aContent
.
images
,
fPrepasteCallback
);
//ковертим изображения в презентационный формат
for
(
var
i
=
0
;
i
<
presentationSelectedContent
.
Drawings
.
length
;
i
++
)
{
if
(
!
(
presentationSelectedContent
.
Drawings
[
i
].
Drawing
instanceof
CGraphicFrame
))
{
presentationSelectedContent
.
Drawings
[
i
].
Drawing
=
presentationSelectedContent
.
Drawings
[
i
].
Drawing
.
convertToPPTX
(
oThis
.
oDocument
.
DrawingDocument
);
AscFormat
.
checkBlipFillRasterImages
(
presentationSelectedContent
.
Drawings
[
i
].
Drawing
);
}
if
(
bTurnOffTrackRevisions
){
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
true
;
}
return
;
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
aContent
.
images
,
paste_callback
);
}
else
if
(
base64FromPresentation
)
//вставка из редактора презентаций в документы
}
},
_pasteBinaryFromPresentation
:
function
(
base64
)
{
var
oThis
=
this
;
if
(
PasteElementsId
.
g_bIsDocumentCopyPaste
)
{
var
fPrepasteCallback
=
function
(){
if
(
false
==
oThis
.
bNested
)
...
...
@@ -2441,7 +2717,7 @@ PasteProcessor.prototype =
pptx_content_loader
.
Clear
();
var
_stream
=
AscFormat
.
CreateBinaryReader
(
base64FromPresentation
,
0
,
base64FromPresentation
.
length
);
var
_stream
=
AscFormat
.
CreateBinaryReader
(
base64
,
0
,
base64
.
length
);
var
stream
=
new
AscCommon
.
FileStream
(
_stream
.
data
,
_stream
.
size
);
var
p_url
=
stream
.
GetString2
();
var
p_width
=
stream
.
GetULong
()
/
100000
;
...
...
@@ -2465,9 +2741,6 @@ PasteProcessor.prototype =
this
.
aContent
=
aContent
;
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
aContent
.
images
,
fPrepasteCallback
);
if
(
bTurnOffTrackRevisions
){
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
true
;
}
return
;
}
case
"
Drawings
"
:
...
...
@@ -2494,9 +2767,6 @@ PasteProcessor.prototype =
this
.
aContent
=
aContent
;
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
aContent
.
images
,
fPrepasteCallback
);
if
(
bTurnOffTrackRevisions
){
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
true
;
}
return
;
}
...
...
@@ -2568,10 +2838,6 @@ PasteProcessor.prototype =
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
image_map
,
fPrepasteCallback
);
});
if
(
bTurnOffTrackRevisions
)
{
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
true
;
}
return
;
}
case
"
SlideObjects
"
:
...
...
@@ -2591,163 +2857,45 @@ PasteProcessor.prototype =
var
aImagesToDownload
=
[];
aImagesToDownload
.
push
(
imageUrl
);
//load image(slide base64)
AscCommon
.
sendImgUrls
(
oThis
.
api
,
aImagesToDownload
,
function
(
data
)
{
var
image_map
=
{};
var
elem
=
data
[
0
];
if
(
null
!=
elem
.
url
)
{
imageUrl
=
g_oDocumentUrls
.
imagePath2Local
(
elem
.
path
);
image_map
[
0
]
=
imageUrl
;
}
//create paragraph, pararun and paradrawing
var
tempParagraph
=
new
Paragraph
(
oThis
.
oDocument
.
DrawingDocument
,
oThis
.
oDocument
,
0
,
0
,
0
,
0
,
0
);
var
graphicObj
=
AscFormat
.
DrawingObjectsController
.
prototype
.
createImage
(
imageUrl
,
0
,
0
,
p_width
,
p_height
);
var
tempParaRun
=
new
ParaRun
();
tempParaRun
.
Paragraph
=
null
;
tempParaRun
.
Add_ToContent
(
0
,
new
ParaDrawing
(),
false
);
tempParaRun
.
Content
[
0
].
Set_GraphicObject
(
graphicObj
);
tempParaRun
.
Content
[
0
].
GraphicObj
.
setParent
(
tempParaRun
.
Content
[
0
]);
tempParaRun
.
Content
[
0
].
CheckWH
();
tempParagraph
.
Content
.
splice
(
tempParagraph
.
Content
.
length
-
1
,
0
,
tempParaRun
);
aContent
=
[];
aContent
.
push
(
tempParagraph
);
oThis
.
aContent
=
aContent
;
oThis
.
api
.
pre_Paste
(
null
,
image_map
,
fPrepasteCallback
);
});
if
(
bTurnOffTrackRevisions
)
{
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
true
;
}
return
;
}
}
}
}
if
(
onlyBinary
)
{
return
;
}
//***вставляем извне в редактор документов***
var
presentation
=
editor
.
WordControl
.
m_oLogicDocument
;
this
.
oRootNode
=
node
;
this
.
bIsPlainText
=
this
.
_CheckIsPlainText
(
node
);
this
.
_Prepeare
(
node
,
function
(){
oThis
.
aContent
=
[];
//если находимся внутри текстовой области диаграммы, то не вставляем ссылки
if
(
oThis
.
oDocument
&&
oThis
.
oDocument
.
Parent
&&
oThis
.
oDocument
.
Parent
.
parent
&&
oThis
.
oDocument
.
Parent
.
parent
.
parent
&&
oThis
.
oDocument
.
Parent
.
parent
.
parent
.
getObjectType
&&
oThis
.
oDocument
.
Parent
.
parent
.
parent
.
getObjectType
()
==
AscDFH
.
historyitem_type_Chart
)
{
var
hyperlinks
=
node
.
getElementsByTagName
(
"
a
"
);
if
(
hyperlinks
&&
hyperlinks
.
length
)
{
var
newElement
;
for
(
var
i
=
0
;
i
<
hyperlinks
.
length
;
i
++
)
{
newElement
=
document
.
createElement
(
"
span
"
);
var
cssText
=
hyperlinks
[
i
].
getAttribute
(
'
style
'
);
if
(
cssText
)
newElement
.
getAttribute
(
'
style
'
,
cssText
);
$
(
newElement
).
append
(
hyperlinks
[
i
].
children
);
hyperlinks
[
i
].
parentNode
.
replaceChild
(
newElement
,
hyperlinks
[
i
]);
}
}
//Todo пока сделал так, чтобы не вставлялись графические объекты в название диаграммы, потом нужно будет сделать так же запутанно, как в MS
var
images
=
node
.
getElementsByTagName
(
"
img
"
);
if
(
images
&&
images
.
length
)
{
for
(
var
i
=
0
;
i
<
images
.
length
;
i
++
)
{
images
[
i
].
parentNode
.
removeChild
(
images
[
i
]);
}
}
}
if
(
bTurnOffTrackRevisions
){
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
false
;
}
//�� ����� ���������� �������� ��� ������� ��������� �������
oThis
.
_Execute
(
node
,
{},
true
,
true
,
false
);
oThis
.
_AddNextPrevToContent
(
oThis
.
oDocument
);
if
(
false
==
oThis
.
bNested
)
{
oThis
.
InsertInDocument
();
}
if
(
bTurnOffTrackRevisions
){
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
true
;
}
});
if
(
bTurnOffTrackRevisions
){
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
true
;
}
}
else
//presentation
{
var
oThis
=
this
;
var
presentation
=
editor
.
WordControl
.
m_oLogicDocument
;
if
(
PasteElementsId
.
copyPasteUseBinary
)
{
var
base64
=
null
,
base64FromWord
=
null
,
base64FromExcel
=
null
;
if
(
onlyBinary
)
{
if
(
onlyBinary
.
indexOf
(
"
pptData;
"
)
>
-
1
)
{
base64
=
onlyBinary
.
split
(
'
pptData;
'
)[
1
];
}
else
if
(
onlyBinary
.
indexOf
(
"
docData;
"
)
>
-
1
)
{
base64FromWord
=
onlyBinary
.
split
(
'
docData;
'
)[
1
];
}
else
if
(
onlyBinary
.
indexOf
(
"
xslData;
"
)
>
-
1
)
{
base64FromExcel
=
onlyBinary
.
split
(
'
xslData;
'
)[
1
];
}
}
else
{
var
classNode
;
if
(
node
.
children
[
0
]
&&
node
.
children
[
0
].
getAttribute
(
"
class
"
)
!=
null
)
classNode
=
node
.
children
[
0
].
getAttribute
(
"
class
"
);
else
if
(
node
.
children
[
0
]
&&
node
.
children
[
0
].
children
[
0
]
&&
node
.
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
)
!=
null
)
classNode
=
node
.
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
);
if
(
classNode
!=
null
){
cL
=
classNode
.
split
(
"
"
);
for
(
var
i
=
0
;
i
<
cL
.
length
;
i
++
){
if
(
cL
[
i
].
indexOf
(
"
pptData;
"
)
>
-
1
)
{
base64
=
cL
[
i
].
split
(
'
pptData;
'
)[
1
];
}
else
if
(
cL
[
i
].
indexOf
(
"
docData;
"
)
>
-
1
)
{
base64FromWord
=
cL
[
i
].
split
(
'
docData;
'
)[
1
];
}
else
if
(
cL
[
i
].
indexOf
(
"
xslData;
"
)
>
-
1
)
//load image(slide base64)
AscCommon
.
sendImgUrls
(
oThis
.
api
,
aImagesToDownload
,
function
(
data
)
{
var
image_map
=
{};
var
elem
=
data
[
0
];
if
(
null
!=
elem
.
url
)
{
base64FromExcel
=
cL
[
i
].
split
(
'
xslData;
'
)[
1
];
imageUrl
=
g_oDocumentUrls
.
imagePath2Local
(
elem
.
path
);
image_map
[
0
]
=
imageUrl
;
}
//create paragraph, pararun and paradrawing
var
tempParagraph
=
new
Paragraph
(
oThis
.
oDocument
.
DrawingDocument
,
oThis
.
oDocument
,
0
,
0
,
0
,
0
,
0
);
var
graphicObj
=
AscFormat
.
DrawingObjectsController
.
prototype
.
createImage
(
imageUrl
,
0
,
0
,
p_width
,
p_height
);
var
tempParaRun
=
new
ParaRun
();
tempParaRun
.
Paragraph
=
null
;
tempParaRun
.
Add_ToContent
(
0
,
new
ParaDrawing
(),
false
);
tempParaRun
.
Content
[
0
].
Set_GraphicObject
(
graphicObj
);
tempParaRun
.
Content
[
0
].
GraphicObj
.
setParent
(
tempParaRun
.
Content
[
0
]);
tempParaRun
.
Content
[
0
].
CheckWH
();
tempParagraph
.
Content
.
splice
(
tempParagraph
.
Content
.
length
-
1
,
0
,
tempParaRun
);
aContent
=
[];
aContent
.
push
(
tempParagraph
);
oThis
.
aContent
=
aContent
;
oThis
.
api
.
pre_Paste
(
null
,
image_map
,
fPrepasteCallback
);
});
return
;
}
}
}
if
(
typeof
base64
===
"
string
"
)
//вставляем в презентации из презентаций
else
{
var
presentation
=
editor
.
WordControl
.
m_oLogicDocument
;
pptx_content_loader
.
Clear
();
var
_stream
=
AscFormat
.
CreateBinaryReader
(
base64
,
0
,
base64
.
length
);
...
...
@@ -2783,11 +2931,6 @@ PasteProcessor.prototype =
for
(
var
i
in
font_map
)
fonts
.
push
(
new
CFont
(
i
,
0
,
""
,
0
));
/*if(shape.getAllImages)
shape.getAllImages(images);*/
var
presentation
=
editor
.
WordControl
.
m_oLogicDocument
;
oThis
=
this
;
//вставка
var
paste_callback
=
function
()
{
...
...
@@ -2809,9 +2952,7 @@ PasteProcessor.prototype =
var
objects
=
this
.
ReadPresentationShapes
(
stream
);
var
arr_shapes
=
objects
.
arrShapes
;
//var arrTransforms = objects.arrTransforms;
var
presentation
=
editor
.
WordControl
.
m_oLogicDocument
;
oThis
=
this
;
var
font_map
=
{};
var
images
=
[];
for
(
var
i
=
0
;
i
<
arr_shapes
.
length
;
++
i
)
...
...
@@ -3044,317 +3185,42 @@ PasteProcessor.prototype =
arr_slides
[
i
].
getAllImages
(
images
);
slideCopyObjects
[
i
]
=
new
SlideCopyObject
();
slideCopyObjects
[
i
].
Slide
=
arr_slides
[
i
];
}
for
(
var
i
=
0
;
i
<
arr_layouts
.
length
;
++
i
)
{
if
(
arr_layouts
[
i
].
getAllFonts
)
arr_layouts
[
i
].
getAllFonts
(
font_map
);
if
(
arr_layouts
[
i
].
getAllImages
)
arr_layouts
[
i
].
getAllImages
(
images
);
}
for
(
var
i
in
font_map
)
fonts
.
push
(
new
CFont
(
i
,
0
,
""
,
0
));
//вставка
var
paste_callback
=
function
()
{
var
presentationSelectedContent
=
new
PresentationSelectedContent
();
presentationSelectedContent
.
SlideObjects
=
slideCopyObjects
;
presentation
.
Insert_Content
(
presentationSelectedContent
);
presentation
.
Recalculate
();
presentation
.
Document_UpdateInterfaceState
();
/*if(false == oThis.bNested)
{
for(var i = 0; i < arr_slides.length; ++i)
{
var cur_arr_transform = arr_arrTransforms[i];
var cur_slide = arr_slides[i];
var sp_tree = cur_slide.cSld.spTree;
for(var j = 0; j < sp_tree.length; ++j)
{
var sp = sp_tree[j];
if(!sp.checkNotNullTransform() && cur_arr_transform && cur_arr_transform[j])
{
var t_object = cur_arr_transform[j];
sp.setOffset(t_object.x, t_object.y);
sp.setExtents(t_object.extX, t_object.extY);
if(sp instanceof CGroupShape)
{
sp.setChildOffset(0, 0);
sp.setChildExtents(t_object.extX, t_object.extY);
}
}
}
presentation.insertSlide(presentation.CurPage + i+1, cur_slide);
}
presentation.Recalculate();
nodeDisplay.blur();
nodeDisplay.style.display = PasteElementsId.ELEMENT_DISPAY_STYLE;
}*/
};
var
image_objects
=
loader
.
End_UseFullUrl
();
var
objects
=
{
arrImages
:
image_objects
};
//load images
var
oObjectsForDownload
=
GetObjectsForImageDownload
(
objects
.
arrImages
);
if
(
oObjectsForDownload
.
aUrls
.
length
>
0
)
{
AscCommon
.
sendImgUrls
(
oThis
.
api
,
oObjectsForDownload
.
aUrls
,
function
(
data
)
{
var
oImageMap
=
{};
ResetNewUrls
(
data
,
oObjectsForDownload
.
aUrls
,
oObjectsForDownload
.
aBuilderImagesByUrl
,
oImageMap
);
oThis
.
api
.
pre_Paste
(
fonts
,
oImageMap
,
paste_callback
);
});
}
else
{
var
im_arr
=
[];
for
(
var
key
in
images
)
im_arr
.
push
(
key
);
this
.
SetShortImageId
(
objects
.
arrImages
);
this
.
api
.
pre_Paste
(
fonts
,
im_arr
,
paste_callback
);
}
return
;
}
}
}
else
if
(
base64FromWord
)
//вставляем в презентации из документов
{
var
trueDocument
=
this
.
oDocument
;
var
tempCDocument
=
function
()
{
return
new
CDocument
(
this
.
oDocument
.
DrawingDocument
,
false
);
}
//создаём темповый CDocument
this
.
oDocument
=
AscFormat
.
ExecuteNoHistory
(
tempCDocument
,
this
,
[]);
AscCommon
.
g_oIdCounter
.
m_bRead
=
true
;
var
aContent
=
AscFormat
.
ExecuteNoHistory
(
this
.
ReadFromBinary
,
this
,
[
base64FromWord
,
this
.
oDocument
]);
AscCommon
.
g_oIdCounter
.
m_bRead
=
false
;
//возврщаем обратно переменные и историю, документ которой заменяется при создании CDocument
this
.
oDocument
=
trueDocument
;
History
.
Document
=
trueDocument
;
var
presentationSelectedContent
=
new
PresentationSelectedContent
();
presentationSelectedContent
.
DocContent
=
new
CSelectedContent
();
var
elements
=
[],
selectedElement
,
element
,
drawings
=
[],
pDrawings
=
[],
drawingCopyObject
;
var
defaultTableStyleId
=
presentation
.
DefaultTableStyleId
;
for
(
var
i
=
0
;
i
<
aContent
.
content
.
length
;
++
i
)
{
selectedElement
=
new
CSelectedElement
();
element
=
aContent
.
content
[
i
];
//drawings
element
.
Get_AllDrawingObjects
(
drawings
);
if
(
type_Paragraph
==
element
.
GetType
())
//paragraph
{
selectedElement
.
Element
=
AscFormat
.
ConvertParagraphToPPTX
(
element
);
elements
.
push
(
selectedElement
);
}
else
if
(
type_Table
==
element
.
GetType
())
//table
{
//TODO переделать количество строк и ширину
var
W
=
100
;
var
Rows
=
3
;
var
graphic_frame
=
new
CGraphicFrame
();
graphic_frame
.
setSpPr
(
new
AscFormat
.
CSpPr
());
graphic_frame
.
spPr
.
setParent
(
graphic_frame
);
graphic_frame
.
spPr
.
setXfrm
(
new
AscFormat
.
CXfrm
());
graphic_frame
.
spPr
.
xfrm
.
setParent
(
graphic_frame
.
spPr
);
graphic_frame
.
spPr
.
xfrm
.
setOffX
((
this
.
oDocument
.
Width
-
W
)
/
2
);
graphic_frame
.
spPr
.
xfrm
.
setOffY
(
this
.
oDocument
.
Height
/
5
);
graphic_frame
.
spPr
.
xfrm
.
setExtX
(
W
);
graphic_frame
.
spPr
.
xfrm
.
setExtY
(
7.478268771701388
*
Rows
);
graphic_frame
.
setNvSpPr
(
new
AscFormat
.
UniNvPr
());
element
=
this
.
_convertTableToPPTX
(
element
,
true
);
graphic_frame
.
setGraphicObject
(
element
.
Copy
(
graphic_frame
));
graphic_frame
.
graphicObject
.
Set_TableStyle
(
defaultTableStyleId
);
drawingCopyObject
=
new
DrawingCopyObject
();
drawingCopyObject
.
Drawing
=
graphic_frame
;
pDrawings
.
push
(
drawingCopyObject
);
}
}
if
(
drawings
&&
drawings
.
length
)
{
//если массив содержит только изображения
if
(
elements
&&
1
===
elements
.
length
&&
elements
[
0
].
Element
&&
type_Paragraph
==
elements
[
0
].
Element
.
Get_Type
())
{
if
(
true
===
this
.
_isParagraphContainsOnlyDrawing
(
elements
[
0
].
Element
))
{
elements
=
[];
}
}
for
(
var
j
=
0
;
j
<
drawings
.
length
;
j
++
)
{
drawingCopyObject
=
new
DrawingCopyObject
();
drawingCopyObject
.
Drawing
=
drawings
[
j
].
GraphicObj
;
pDrawings
.
push
(
drawingCopyObject
);
}
}
presentationSelectedContent
.
DocContent
.
Elements
=
elements
;
presentationSelectedContent
.
Drawings
=
pDrawings
;
var
presentation
=
editor
.
WordControl
.
m_oLogicDocument
;
oThis
=
this
;
//вставка
var
paste_callback
=
function
()
{
if
(
false
==
oThis
.
bNested
)
{
presentation
.
Insert_Content
(
presentationSelectedContent
);
presentation
.
Recalculate
();
presentation
.
Check_CursorMoveRight
();
presentation
.
Document_UpdateInterfaceState
();
}
}
var
font_map
=
{};
var
images
=
[];
//shape.getAllFonts(font_map);
//перебираем шрифты
var
fonts
=
[];
for
(
var
i
in
font_map
)
fonts
.
push
(
new
CFont
(
i
,
0
,
""
,
0
));
var
oObjectsForDownload
=
GetObjectsForImageDownload
(
aContent
.
aPastedImages
);
if
(
oObjectsForDownload
.
aUrls
.
length
>
0
)
{
AscCommon
.
sendImgUrls
(
oThis
.
api
,
oObjectsForDownload
.
aUrls
,
function
(
data
){
var
oImageMap
=
{};
ResetNewUrls
(
data
,
oObjectsForDownload
.
aUrls
,
oObjectsForDownload
.
aBuilderImagesByUrl
,
oImageMap
);
//ковертим изображения в презентационный формат
for
(
var
i
=
0
;
i
<
presentationSelectedContent
.
Drawings
.
length
;
i
++
)
{
if
(
!
(
presentationSelectedContent
.
Drawings
[
i
].
Drawing
instanceof
CGraphicFrame
))
{
AscFormat
.
ExecuteNoHistory
(
function
(){
if
(
presentationSelectedContent
.
Drawings
[
i
].
Drawing
.
setBDeleted2
)
{
presentationSelectedContent
.
Drawings
[
i
].
Drawing
.
setBDeleted2
(
true
);
}
else
{
presentationSelectedContent
.
Drawings
[
i
].
Drawing
.
setBDeleted
(
true
);
}
},
this
,
[]);
presentationSelectedContent
.
Drawings
[
i
].
Drawing
=
presentationSelectedContent
.
Drawings
[
i
].
Drawing
.
convertToPPTX
(
oThis
.
oDocument
.
DrawingDocument
);
AscFormat
.
checkBlipFillRasterImages
(
presentationSelectedContent
.
Drawings
[
i
].
Drawing
);
}
}
oThis
.
api
.
pre_Paste
(
fonts
,
oImageMap
,
paste_callback
);
});
}
else
{
//ковертим изображения в презентационный формат
for
(
var
i
=
0
;
i
<
presentationSelectedContent
.
Drawings
.
length
;
i
++
)
{
if
(
!
(
presentationSelectedContent
.
Drawings
[
i
].
Drawing
instanceof
CGraphicFrame
))
{
presentationSelectedContent
.
Drawings
[
i
].
Drawing
=
presentationSelectedContent
.
Drawings
[
i
].
Drawing
.
convertToPPTX
(
oThis
.
oDocument
.
DrawingDocument
);
AscFormat
.
checkBlipFillRasterImages
(
presentationSelectedContent
.
Drawings
[
i
].
Drawing
);
}
}
oThis
.
api
.
pre_Paste
(
aContent
.
fonts
,
aContent
.
images
,
paste_callback
);
slideCopyObjects
[
i
].
Slide
=
arr_slides
[
i
];
}
return
;
}
else
if
(
base64FromExcel
)
//вставляем в презентации из таблиц
for
(
var
i
=
0
;
i
<
arr_layouts
.
length
;
++
i
)
{
var
excelContent
=
AscFormat
.
ExecuteNoHistory
(
this
.
_readFromBinaryExcel
,
this
,
[
base64FromExcel
]);
if
(
arr_layouts
[
i
].
getAllFonts
)
arr_layouts
[
i
].
getAllFonts
(
font_map
);
if
(
arr_layouts
[
i
].
getAllImages
)
arr_layouts
[
i
].
getAllImages
(
images
);
}
for
(
var
i
in
font_map
)
fonts
.
push
(
new
CFont
(
i
,
0
,
""
,
0
));
var
aContentExcel
=
excelContent
.
workbook
;
var
aPastedImages
=
excelContent
.
arrImages
;
//если есть шейпы, то вставляем их из excel
if
(
aContentExcel
&&
aContentExcel
.
aWorksheets
&&
aContentExcel
.
aWorksheets
[
0
]
&&
aContentExcel
.
aWorksheets
[
0
].
Drawings
&&
aContentExcel
.
aWorksheets
[
0
].
Drawings
.
length
)
{
//вставка
var
paste_callback
=
function
()
{
if
(
false
==
oThis
.
bNested
)
{
for
(
var
i
=
0
;
i
<
arr_shapes
.
length
;
++
i
)
{
shape
=
arr_shapes
[
i
].
graphicObject
.
copy
();
shape
.
worksheet
=
null
;
shape
.
drawingBase
=
null
;
arr_shapes
[
i
]
=
new
DrawingCopyObject
(
shape
,
0
,
0
,
0
,
0
);
}
var
presentationSelectedContent
=
new
PresentationSelectedContent
();
presentationSelectedContent
.
Drawings
=
arr_shapes
;
presentationSelectedContent
.
SlideObjects
=
slideCopyObjects
;
presentation
.
Insert_Content
(
presentationSelectedContent
);
presentation
.
Recalculate
();
presentation
.
Check_CursorMoveRight
();
presentation
.
Document_UpdateInterfaceState
();
}
};
var
image_objects
=
loader
.
End_UseFullUrl
();
var
objects
=
{
arrImages
:
image_objects
};
//load images
var
arr_shapes
=
aContentExcel
.
aWorksheets
[
0
].
Drawings
;
var
aImagesToDownload
=
[];
for
(
var
i
=
0
;
i
<
aPastedImages
.
length
;
i
++
)
{
aImagesToDownload
.
push
(
aPastedImages
[
i
].
Url
);
}
var
aContent
=
{
aPastedImages
:
aPastedImages
,
images
:
aImagesToDownload
};
//var arrTransforms = objects.arrTransforms;
var
presentation
=
editor
.
WordControl
.
m_oLogicDocument
;
oThis
=
this
;
//fonts
var
font_map
=
{};
for
(
var
i
=
0
;
i
<
arr_shapes
.
length
;
++
i
)
{
var
shape
=
arr_shapes
[
i
].
graphicObject
;
shape
.
getAllFonts
(
font_map
);
}
var
fonts
=
[];
//грузим картинки и фонты
for
(
var
i
in
font_map
)
fonts
.
push
(
new
CFont
(
i
,
0
,
""
,
0
));
//images
var
images
=
aContent
.
images
;
var
arrImages
=
aContent
.
aPastedImages
;
var
oObjectsForDownload
=
GetObjectsForImageDownload
(
arrImages
);
var
oObjectsForDownload
=
GetObjectsForImageDownload
(
objects
.
arrImages
);
if
(
oObjectsForDownload
.
aUrls
.
length
>
0
)
{
AscCommon
.
sendImgUrls
(
oThis
.
api
,
oObjectsForDownload
.
aUrls
,
function
(
data
)
{
var
oImageMap
=
{};
History
.
TurnOff
();
ResetNewUrls
(
data
,
oObjectsForDownload
.
aUrls
,
oObjectsForDownload
.
aBuilderImagesByUrl
,
oImageMap
);
oThis
.
api
.
pre_Paste
(
fonts
,
oImageMap
,
paste_callback
);
History
.
TurnOn
();
});
}
else
...
...
@@ -3363,84 +3229,22 @@ PasteProcessor.prototype =
for
(
var
key
in
images
)
im_arr
.
push
(
key
);
this
.
SetShortImageId
(
arrImages
);
this
.
SetShortImageId
(
objects
.
arrImages
);
this
.
api
.
pre_Paste
(
fonts
,
im_arr
,
paste_callback
);
}
return
;
}
else
{
var
presentationSelectedContent
=
new
PresentationSelectedContent
();
presentationSelectedContent
.
DocContent
=
new
CSelectedContent
();
var
aContent
=
AscFormat
.
ExecuteNoHistory
(
this
.
_convertExcelBinary
,
this
,
[
excelContent
]);
var
elements
=
[],
selectedElement
,
element
,
drawings
=
[],
pDrawings
=
[],
drawingCopyObject
;
var
defaultTableStyleId
=
presentation
.
DefaultTableStyleId
;
for
(
var
i
=
0
;
i
<
aContent
.
content
.
length
;
++
i
)
{
selectedElement
=
new
CSelectedElement
();
element
=
aContent
.
content
[
i
];
if
(
type_Table
==
element
.
GetType
())
//table
{
//TODO переделать количество строк и ширину
var
W
=
100
;
var
Rows
=
3
;
var
graphic_frame
=
new
CGraphicFrame
();
graphic_frame
.
setSpPr
(
new
AscFormat
.
CSpPr
());
graphic_frame
.
spPr
.
setParent
(
graphic_frame
);
graphic_frame
.
spPr
.
setXfrm
(
new
AscFormat
.
CXfrm
());
graphic_frame
.
spPr
.
xfrm
.
setParent
(
graphic_frame
.
spPr
);
graphic_frame
.
spPr
.
xfrm
.
setOffX
((
this
.
oDocument
.
Width
-
W
)
/
2
);
graphic_frame
.
spPr
.
xfrm
.
setOffY
(
this
.
oDocument
.
Height
/
5
);
graphic_frame
.
spPr
.
xfrm
.
setExtX
(
W
);
graphic_frame
.
spPr
.
xfrm
.
setExtY
(
7.478268771701388
*
Rows
);
graphic_frame
.
setNvSpPr
(
new
AscFormat
.
UniNvPr
());
element
=
this
.
_convertTableToPPTX
(
element
);
graphic_frame
.
setGraphicObject
(
element
.
Copy
(
graphic_frame
));
graphic_frame
.
graphicObject
.
Set_TableStyle
(
defaultTableStyleId
);
drawingCopyObject
=
new
DrawingCopyObject
();
drawingCopyObject
.
Drawing
=
graphic_frame
;
pDrawings
.
push
(
drawingCopyObject
);
}
}
presentationSelectedContent
.
Drawings
=
pDrawings
;
var
presentation
=
editor
.
WordControl
.
m_oLogicDocument
;
},
//вставка
var
paste_callback
=
function
()
{
if
(
false
==
oThis
.
bNested
)
_pasteFromHtml
:
function
(
node
,
bTurnOffTrackRevisions
)
{
presentation
.
Insert_Content
(
presentationSelectedContent
);
presentation
.
Recalculate
();
presentation
.
Check_CursorMoveRight
();
presentation
.
Document_UpdateInterfaceState
();
}
}
oThis
.
api
.
pre_Paste
(
aContent
.
content
.
fonts
,
null
,
paste_callback
);
return
;
}
}
}
var
oThis
=
this
;
if
(
onlyBinary
)
var
fPasteHtmlPresentationCallback
=
function
(
)
{
return
;
}
this
.
oRootNode
=
node
;
this
.
_Prepeare
(
node
,
function
(){
/*if(node.innerHTML == " ")
return;*/
oThis
.
aContent
=
[];
//�� ����� ���������� �������� ��� ������� ��������� �������
var
arrShapes
=
[],
arrImages
=
[],
arrTables
=
[];
...
...
@@ -3537,8 +3341,131 @@ PasteProcessor.prototype =
presentation
.
Check_CursorMoveRight
();
presentation
.
Document_UpdateInterfaceState
();
}
});
};
var
fPasteHtmlWordCallback
=
function
()
{
oThis
.
aContent
=
[];
//если находимся внутри текстовой области диаграммы, то не вставляем ссылки
if
(
oThis
.
oDocument
&&
oThis
.
oDocument
.
Parent
&&
oThis
.
oDocument
.
Parent
.
parent
&&
oThis
.
oDocument
.
Parent
.
parent
.
parent
&&
oThis
.
oDocument
.
Parent
.
parent
.
parent
.
getObjectType
&&
oThis
.
oDocument
.
Parent
.
parent
.
parent
.
getObjectType
()
==
AscDFH
.
historyitem_type_Chart
)
{
var
hyperlinks
=
node
.
getElementsByTagName
(
"
a
"
);
if
(
hyperlinks
&&
hyperlinks
.
length
)
{
var
newElement
;
for
(
var
i
=
0
;
i
<
hyperlinks
.
length
;
i
++
)
{
newElement
=
document
.
createElement
(
"
span
"
);
var
cssText
=
hyperlinks
[
i
].
getAttribute
(
'
style
'
);
if
(
cssText
)
newElement
.
getAttribute
(
'
style
'
,
cssText
);
$
(
newElement
).
append
(
hyperlinks
[
i
].
children
);
hyperlinks
[
i
].
parentNode
.
replaceChild
(
newElement
,
hyperlinks
[
i
]);
}
}
//Todo пока сделал так, чтобы не вставлялись графические объекты в название диаграммы, потом нужно будет сделать так же запутанно, как в MS
var
images
=
node
.
getElementsByTagName
(
"
img
"
);
if
(
images
&&
images
.
length
)
{
for
(
var
i
=
0
;
i
<
images
.
length
;
i
++
)
{
images
[
i
].
parentNode
.
removeChild
(
images
[
i
]);
}
}
}
if
(
bTurnOffTrackRevisions
){
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
false
;
}
//�� ����� ���������� �������� ��� ������� ��������� �������
oThis
.
_Execute
(
node
,
{},
true
,
true
,
false
);
oThis
.
_AddNextPrevToContent
(
oThis
.
oDocument
);
if
(
false
==
oThis
.
bNested
)
{
oThis
.
InsertInDocument
();
}
if
(
bTurnOffTrackRevisions
){
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
true
;
}
};
this
.
oRootNode
=
node
;
if
(
PasteElementsId
.
g_bIsDocumentCopyPaste
)
{
this
.
bIsPlainText
=
this
.
_CheckIsPlainText
(
node
);
this
.
_Prepeare
(
node
,
fPasteHtmlWordCallback
);
if
(
bTurnOffTrackRevisions
){
oThis
.
api
.
WordControl
.
m_oLogicDocument
.
TrackRevisions
=
true
;
}
}
else
{
this
.
oRootNode
=
node
;
this
.
_Prepeare
(
node
,
fPasteHtmlPresentationCallback
);
}
},
_getClassBinaryFromHtml
:
function
(
node
,
onlyBinary
)
{
var
classNode
,
base64FromExcel
=
null
,
base64FromWord
=
null
,
base64FromPresentation
=
null
;
if
(
onlyBinary
)
{
if
(
onlyBinary
.
indexOf
(
"
pptData;
"
)
>
-
1
)
{
base64FromPresentation
=
onlyBinary
.
split
(
'
pptData;
'
)[
1
];
}
else
if
(
onlyBinary
.
indexOf
(
"
docData;
"
)
>
-
1
)
{
base64FromWord
=
onlyBinary
.
split
(
'
docData;
'
)[
1
];
}
else
if
(
onlyBinary
.
indexOf
(
"
xslData;
"
)
>
-
1
)
{
base64FromExcel
=
onlyBinary
.
split
(
'
xslData;
'
)[
1
];
}
}
else
{
//todo переделать получения класса
if
(
node
.
children
[
0
]
&&
node
.
children
[
0
].
getAttribute
(
"
class
"
)
!=
null
&&
(
node
.
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
xslData;
"
)
>
-
1
||
node
.
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
docData;
"
)
>
-
1
||
node
.
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
pptData;
"
)
>
-
1
))
{
classNode
=
node
.
children
[
0
].
getAttribute
(
"
class
"
);
}
else
if
(
node
.
children
[
0
]
&&
node
.
children
[
0
].
children
[
0
]
&&
node
.
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
)
!=
null
&&
(
node
.
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
xslData;
"
)
>
-
1
||
node
.
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
docData;
"
)
>
-
1
||
node
.
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
pptData;
"
)
>
-
1
))
{
classNode
=
node
.
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
);
}
else
if
(
node
.
children
[
0
]
&&
node
.
children
[
0
].
children
[
0
]
&&
node
.
children
[
0
].
children
[
0
].
children
[
0
]
&&
node
.
children
[
0
].
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
)
!=
null
&&
(
node
.
children
[
0
].
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
xslData;
"
)
>
-
1
||
node
.
children
[
0
].
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
docData;
"
)
>
-
1
||
node
.
children
[
0
].
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
).
indexOf
(
"
pptData;
"
)
>
-
1
))
{
classNode
=
node
.
children
[
0
].
children
[
0
].
children
[
0
].
getAttribute
(
"
class
"
);
}
if
(
classNode
!=
null
){
var
cL
=
classNode
.
split
(
"
"
);
for
(
var
i
=
0
;
i
<
cL
.
length
;
i
++
){
if
(
cL
[
i
].
indexOf
(
"
xslData;
"
)
>
-
1
)
{
base64FromExcel
=
cL
[
i
].
split
(
'
xslData;
'
)[
1
];
}
else
if
(
cL
[
i
].
indexOf
(
"
docData;
"
)
>
-
1
)
{
base64FromWord
=
cL
[
i
].
split
(
'
docData;
'
)[
1
];
}
else
if
(
cL
[
i
].
indexOf
(
"
pptData;
"
)
>
-
1
)
{
base64FromPresentation
=
cL
[
i
].
split
(
'
pptData;
'
)[
1
];
}
}
}
}
return
{
base64FromExcel
:
base64FromExcel
,
base64FromWord
:
base64FromWord
,
base64FromPresentation
:
base64FromPresentation
};
},
_isParagraphContainsOnlyDrawing
:
function
(
par
)
...
...
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